Skip to content

Commit

Permalink
oneOfs wow
Browse files Browse the repository at this point in the history
  • Loading branch information
nkzou committed Jan 4, 2024
1 parent 0c0b8dd commit b43d587
Show file tree
Hide file tree
Showing 2,481 changed files with 156,098 additions and 19,281 deletions.
34,473 changes: 24,739 additions & 9,734 deletions .generator/schemas/v1/openapi.yaml

Large diffs are not rendered by default.

34,796 changes: 29,936 additions & 4,860 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .generator/src/generator/templates/api.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::datadog::*;
{%- for name, parameter in operation|parameters %}
{%- if loop.first %}
/// {{ operation.operationId }}Params is a struct for passing parameters to the method [`{{operation.operationId}}`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct {{operation.operationId}}Params {
{%- endif %}
{%- if parameter.description is defined %}
Expand Down
6 changes: 0 additions & 6 deletions .generator/src/generator/templates/model_enum.j2
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,3 @@ impl ToString for {{name}} {
}
}
}

impl Default for {{name}} {
fn default() -> {{name}} {
Self::{{ model["x-enum-varnames"].0 }}
}
}
12 changes: 12 additions & 0 deletions .generator/src/generator/templates/model_oneof.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use serde::{Deserialize, Serialize};

{{ model.description | block_comment }}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum {{name}} {
{%- for oneOf in model.oneOf %}
{%- set dataType = get_type(oneOf, render_nullable=False, render_option=False, version=version) %}
{%- set attributeName = (get_name(oneOf) or dataType)|upperfirst %}
{{attributeName}}(Box<{{dataType}}>),
{%- endfor%}
}
8 changes: 2 additions & 6 deletions .generator/src/generator/templates/model_simple.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde_with::skip_serializing_none;

{{ model.description | block_comment }}
#[skip_serializing_none]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct {{ name }} {
{%- for attr, schema in model.get("properties", {}).items() %}
{%- set propertyName = attr|variable_name %}
Expand All @@ -25,7 +25,7 @@ pub struct {{ name }} {
}

impl {{ name }} {
pub fn new({% for attr, schema in model.get("properties", {}).items() if attr in model.required %}{%- set nullable = schema.get("nullable", False)%}{%- set propertyName = attr|variable_name %}{%- set dataType = get_type(schema, alternative_name=name + propertyName, render_nullable=nullable, render_option=False, version=version) %}{{propertyName}}: {{ dataType }}{%- if not loop.last %}, {% endif %}{% endfor %}) -> {{ name }} {
pub fn new({% for attr, schema in model.get("properties", {}).items() if attr in model.required %}{%- set nullable = schema.get("nullable", False)%}{%- set propertyName = attr|variable_name %}{%- set dataType = get_type(schema, alternative_name=name + propertyName, render_nullable=nullable, render_option=False, render_box=True, version=version) %}{{propertyName}}: {{ dataType }}{%- if not loop.last %}, {% endif %}{% endfor %}) -> {{ name }} {
{%- if get_deprecated(model) %}
#[allow(deprecated)]
{%- endif %}
Expand All @@ -36,11 +36,7 @@ impl {{ name }} {
{%- set nullable = schema.get("nullable", False)%}
{%- set dataType = get_type(schema, alternative_name=name + propertyName, render_nullable=nullable, render_option=not required, render_box=True, version=version) %}
{%- if attr in model.get("required", []) %}
{%- if "Box<" in dataType %}
{{ attr|variable_name }}: Box::new({{ attr|variable_name }}),
{%- else %}
{{ attr|variable_name }},
{%- endif %}
{%- else %}
{{ attr|variable_name }}: None,
{%- endif %}
Expand Down
20 changes: 10 additions & 10 deletions src/datadogV1/api/api_aws_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ use reqwest;
use serde::{Deserialize, Serialize};

/// CreateAWSAccountParams is a struct for passing parameters to the method [`CreateAWSAccount`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct CreateAWSAccountParams {
/// AWS Request Object
pub body: crate::datadogV1::model::AWSAccount,
}

/// CreateAWSEventBridgeSourceParams is a struct for passing parameters to the method [`CreateAWSEventBridgeSource`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct CreateAWSEventBridgeSourceParams {
/// Create an Amazon EventBridge source for an AWS account with a given name and region.
pub body: crate::datadogV1::model::AWSEventBridgeCreateRequest,
}

/// CreateAWSTagFilterParams is a struct for passing parameters to the method [`CreateAWSTagFilter`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct CreateAWSTagFilterParams {
/// Set an AWS tag filter using an `aws_account_identifier`, `namespace`, and filtering string.
/// Namespace options are `application_elb`, `elb`, `lambda`, `network_elb`, `rds`, `sqs`, and `custom`.
pub body: crate::datadogV1::model::AWSTagFilterCreateRequest,
}

/// CreateNewAWSExternalIDParams is a struct for passing parameters to the method [`CreateNewAWSExternalID`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct CreateNewAWSExternalIDParams {
/// Your Datadog role delegation name.
/// For more information about your AWS account Role name,
Expand All @@ -38,28 +38,28 @@ pub struct CreateNewAWSExternalIDParams {
}

/// DeleteAWSAccountParams is a struct for passing parameters to the method [`DeleteAWSAccount`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct DeleteAWSAccountParams {
/// AWS request object
pub body: crate::datadogV1::model::AWSAccountDeleteRequest,
}

/// DeleteAWSEventBridgeSourceParams is a struct for passing parameters to the method [`DeleteAWSEventBridgeSource`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct DeleteAWSEventBridgeSourceParams {
/// Delete the Amazon EventBridge source with the given name, region, and associated AWS account.
pub body: crate::datadogV1::model::AWSEventBridgeDeleteRequest,
}

/// DeleteAWSTagFilterParams is a struct for passing parameters to the method [`DeleteAWSTagFilter`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct DeleteAWSTagFilterParams {
/// Delete a tag filtering entry for a given AWS account and `dd-aws` namespace.
pub body: crate::datadogV1::model::AWSTagFilterDeleteRequest,
}

/// ListAWSAccountsParams is a struct for passing parameters to the method [`ListAWSAccounts`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct ListAWSAccountsParams {
/// Only return AWS accounts that matches this `account_id`.
pub account_id: Option<String>,
Expand All @@ -70,14 +70,14 @@ pub struct ListAWSAccountsParams {
}

/// ListAWSTagFiltersParams is a struct for passing parameters to the method [`ListAWSTagFilters`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct ListAWSTagFiltersParams {
/// Only return AWS filters that matches this `account_id`.
pub account_id: String,
}

/// UpdateAWSAccountParams is a struct for passing parameters to the method [`UpdateAWSAccount`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct UpdateAWSAccountParams {
/// AWS request object
pub body: crate::datadogV1::model::AWSAccount,
Expand Down
10 changes: 5 additions & 5 deletions src/datadogV1/api/api_aws_logs_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ use reqwest;
use serde::{Deserialize, Serialize};

/// CheckAWSLogsLambdaAsyncParams is a struct for passing parameters to the method [`CheckAWSLogsLambdaAsync`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct CheckAWSLogsLambdaAsyncParams {
/// Check AWS Log Lambda Async request body.
pub body: crate::datadogV1::model::AWSAccountAndLambdaRequest,
}

/// CheckAWSLogsServicesAsyncParams is a struct for passing parameters to the method [`CheckAWSLogsServicesAsync`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct CheckAWSLogsServicesAsyncParams {
/// Check AWS Logs Async Services request body.
pub body: crate::datadogV1::model::AWSLogsServicesRequest,
}

/// CreateAWSLambdaARNParams is a struct for passing parameters to the method [`CreateAWSLambdaARN`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct CreateAWSLambdaARNParams {
/// AWS Log Lambda Async request body.
pub body: crate::datadogV1::model::AWSAccountAndLambdaRequest,
}

/// DeleteAWSLambdaARNParams is a struct for passing parameters to the method [`DeleteAWSLambdaARN`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct DeleteAWSLambdaARNParams {
/// Delete AWS Lambda ARN request body.
pub body: crate::datadogV1::model::AWSAccountAndLambdaRequest,
}

/// EnableAWSLogServicesParams is a struct for passing parameters to the method [`EnableAWSLogServices`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct EnableAWSLogServicesParams {
/// Enable AWS Log Services request body.
pub body: crate::datadogV1::model::AWSLogsServicesRequest,
Expand Down
8 changes: 4 additions & 4 deletions src/datadogV1/api/api_azure_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ use reqwest;
use serde::{Deserialize, Serialize};

/// CreateAzureIntegrationParams is a struct for passing parameters to the method [`CreateAzureIntegration`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct CreateAzureIntegrationParams {
/// Create a Datadog-Azure integration for your Datadog account request body.
pub body: crate::datadogV1::model::AzureAccount,
}

/// DeleteAzureIntegrationParams is a struct for passing parameters to the method [`DeleteAzureIntegration`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct DeleteAzureIntegrationParams {
/// Delete a given Datadog-Azure integration request body.
pub body: crate::datadogV1::model::AzureAccount,
}

/// UpdateAzureHostFiltersParams is a struct for passing parameters to the method [`UpdateAzureHostFilters`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct UpdateAzureHostFiltersParams {
/// Update a Datadog-Azure integration's host filters request body.
pub body: crate::datadogV1::model::AzureAccount,
}

/// UpdateAzureIntegrationParams is a struct for passing parameters to the method [`UpdateAzureIntegration`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct UpdateAzureIntegrationParams {
/// Update a Datadog-Azure integration request body.
pub body: crate::datadogV1::model::AzureAccount,
Expand Down
8 changes: 4 additions & 4 deletions src/datadogV1/api/api_dashboard_lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ use reqwest;
use serde::{Deserialize, Serialize};

/// CreateDashboardListParams is a struct for passing parameters to the method [`CreateDashboardList`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct CreateDashboardListParams {
/// Create a dashboard list request body.
pub body: crate::datadogV1::model::DashboardList,
}

/// DeleteDashboardListParams is a struct for passing parameters to the method [`DeleteDashboardList`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct DeleteDashboardListParams {
/// ID of the dashboard list to delete.
pub list_id: i64,
}

/// GetDashboardListParams is a struct for passing parameters to the method [`GetDashboardList`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct GetDashboardListParams {
/// ID of the dashboard list to fetch.
pub list_id: i64,
}

/// UpdateDashboardListParams is a struct for passing parameters to the method [`UpdateDashboardList`]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct UpdateDashboardListParams {
/// ID of the dashboard list to update.
pub list_id: i64,
Expand Down
Loading

0 comments on commit b43d587

Please sign in to comment.