Skip to content

Commit 1689f47

Browse files
authored
Implement OneOfs and remove default on enums (#6)
1 parent 0c0b8dd commit 1689f47

File tree

2,481 files changed

+156098
-19281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,481 files changed

+156098
-19281
lines changed

.generator/schemas/v1/openapi.yaml

+24,739-9,734
Large diffs are not rendered by default.

.generator/schemas/v2/openapi.yaml

+29,936-4,860
Large diffs are not rendered by default.

.generator/src/generator/templates/api.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::datadog::*;
1313
{%- for name, parameter in operation|parameters %}
1414
{%- if loop.first %}
1515
/// {{ operation.operationId }}Params is a struct for passing parameters to the method [`{{operation.operationId}}`]
16-
#[derive(Clone, Debug, Default)]
16+
#[derive(Clone, Debug)]
1717
pub struct {{operation.operationId}}Params {
1818
{%- endif %}
1919
{%- if parameter.description is defined %}

.generator/src/generator/templates/model_enum.j2

-6
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,3 @@ impl ToString for {{name}} {
3333
}
3434
}
3535
}
36-
37-
impl Default for {{name}} {
38-
fn default() -> {{name}} {
39-
Self::{{ model["x-enum-varnames"].0 }}
40-
}
41-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
{{ model.description | block_comment }}
4+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
5+
#[serde(untagged)]
6+
pub enum {{name}} {
7+
{%- for oneOf in model.oneOf %}
8+
{%- set dataType = get_type(oneOf, render_nullable=False, render_option=False, version=version) %}
9+
{%- set attributeName = (get_name(oneOf) or dataType)|upperfirst %}
10+
{{attributeName}}(Box<{{dataType}}>),
11+
{%- endfor%}
12+
}

.generator/src/generator/templates/model_simple.j2

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use serde_with::skip_serializing_none;
33

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

2727
impl {{ name }} {
28-
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 }} {
28+
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 }} {
2929
{%- if get_deprecated(model) %}
3030
#[allow(deprecated)]
3131
{%- endif %}
@@ -36,11 +36,7 @@ impl {{ name }} {
3636
{%- set nullable = schema.get("nullable", False)%}
3737
{%- set dataType = get_type(schema, alternative_name=name + propertyName, render_nullable=nullable, render_option=not required, render_box=True, version=version) %}
3838
{%- if attr in model.get("required", []) %}
39-
{%- if "Box<" in dataType %}
40-
{{ attr|variable_name }}: Box::new({{ attr|variable_name }}),
41-
{%- else %}
4239
{{ attr|variable_name }},
43-
{%- endif %}
4440
{%- else %}
4541
{{ attr|variable_name }}: None,
4642
{%- endif %}

src/datadogV1/api/api_aws_integration.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@ use reqwest;
77
use serde::{Deserialize, Serialize};
88

99
/// CreateAWSAccountParams is a struct for passing parameters to the method [`CreateAWSAccount`]
10-
#[derive(Clone, Debug, Default)]
10+
#[derive(Clone, Debug)]
1111
pub struct CreateAWSAccountParams {
1212
/// AWS Request Object
1313
pub body: crate::datadogV1::model::AWSAccount,
1414
}
1515

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

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

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

4040
/// DeleteAWSAccountParams is a struct for passing parameters to the method [`DeleteAWSAccount`]
41-
#[derive(Clone, Debug, Default)]
41+
#[derive(Clone, Debug)]
4242
pub struct DeleteAWSAccountParams {
4343
/// AWS request object
4444
pub body: crate::datadogV1::model::AWSAccountDeleteRequest,
4545
}
4646

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

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

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

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

7979
/// UpdateAWSAccountParams is a struct for passing parameters to the method [`UpdateAWSAccount`]
80-
#[derive(Clone, Debug, Default)]
80+
#[derive(Clone, Debug)]
8181
pub struct UpdateAWSAccountParams {
8282
/// AWS request object
8383
pub body: crate::datadogV1::model::AWSAccount,

src/datadogV1/api/api_aws_logs_integration.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@ use reqwest;
77
use serde::{Deserialize, Serialize};
88

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

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

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

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

3737
/// EnableAWSLogServicesParams is a struct for passing parameters to the method [`EnableAWSLogServices`]
38-
#[derive(Clone, Debug, Default)]
38+
#[derive(Clone, Debug)]
3939
pub struct EnableAWSLogServicesParams {
4040
/// Enable AWS Log Services request body.
4141
pub body: crate::datadogV1::model::AWSLogsServicesRequest,

src/datadogV1/api/api_azure_integration.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ use reqwest;
77
use serde::{Deserialize, Serialize};
88

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

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

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

3030
/// UpdateAzureIntegrationParams is a struct for passing parameters to the method [`UpdateAzureIntegration`]
31-
#[derive(Clone, Debug, Default)]
31+
#[derive(Clone, Debug)]
3232
pub struct UpdateAzureIntegrationParams {
3333
/// Update a Datadog-Azure integration request body.
3434
pub body: crate::datadogV1::model::AzureAccount,

src/datadogV1/api/api_dashboard_lists.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ use reqwest;
77
use serde::{Deserialize, Serialize};
88

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

1616
/// DeleteDashboardListParams is a struct for passing parameters to the method [`DeleteDashboardList`]
17-
#[derive(Clone, Debug, Default)]
17+
#[derive(Clone, Debug)]
1818
pub struct DeleteDashboardListParams {
1919
/// ID of the dashboard list to delete.
2020
pub list_id: i64,
2121
}
2222

2323
/// GetDashboardListParams is a struct for passing parameters to the method [`GetDashboardList`]
24-
#[derive(Clone, Debug, Default)]
24+
#[derive(Clone, Debug)]
2525
pub struct GetDashboardListParams {
2626
/// ID of the dashboard list to fetch.
2727
pub list_id: i64,
2828
}
2929

3030
/// UpdateDashboardListParams is a struct for passing parameters to the method [`UpdateDashboardList`]
31-
#[derive(Clone, Debug, Default)]
31+
#[derive(Clone, Debug)]
3232
pub struct UpdateDashboardListParams {
3333
/// ID of the dashboard list to update.
3434
pub list_id: i64,

0 commit comments

Comments
 (0)