Skip to content

Make dns port be string and number #734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-06-24 13:19:19.818164",
"spec_repo_commit": "8772660e"
"regenerated": "2025-06-25 11:39:37.419068",
"spec_repo_commit": "5d86661b"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-06-24 13:19:19.835947",
"spec_repo_commit": "8772660e"
"regenerated": "2025-06-25 11:39:37.437815",
"spec_repo_commit": "5d86661b"
}
}
}
15 changes: 14 additions & 1 deletion .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17201,8 +17201,8 @@ components:
description: DNS server to use for DNS tests.
type: string
dnsServerPort:
$ref: '#/components/schemas/SyntheticsTestRequestDNSServerPort'
description: DNS server port to use for DNS tests.
type: string
files:
description: Files to be used as part of the request in the test. Only valid
if `bodyType` is `multipart/form-data`.
Expand Down Expand Up @@ -17356,6 +17356,15 @@ components:
description: Date of update of the certificate or key, ISO format.
type: string
type: object
SyntheticsTestRequestDNSServerPort:
description: DNS server port to use for DNS tests.
oneOf:
- $ref: '#/components/schemas/SyntheticsTestRequestNumericalDNSServerPort'
- $ref: '#/components/schemas/SyntheticsTestRequestVariableDNSServerPort'
SyntheticsTestRequestNumericalDNSServerPort:
description: Integer DNS server port number to use when performing the test.
format: int64
type: integer
SyntheticsTestRequestNumericalPort:
description: Integer Port number to use when performing the test.
format: int64
Expand All @@ -17377,6 +17386,10 @@ components:
required:
- url
type: object
SyntheticsTestRequestVariableDNSServerPort:
description: String DNS server port number to use when performing the test.
Supports templated variables.
type: string
SyntheticsTestRequestVariablePort:
description: String Port number to use when performing the test. Supports templated
variables.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use datadog_api_client::datadogV1::model::SyntheticsTestOptions;
use datadog_api_client::datadogV1::model::SyntheticsTestOptionsHTTPVersion;
use datadog_api_client::datadogV1::model::SyntheticsTestOptionsRetry;
use datadog_api_client::datadogV1::model::SyntheticsTestRequest;
use datadog_api_client::datadogV1::model::SyntheticsTestRequestDNSServerPort;
use datadog_api_client::datadogV1::model::SyntheticsTestRequestPort;
use datadog_api_client::datadogV1::model::SyntheticsVariableParser;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -186,7 +187,12 @@ async fn main() {
"DNS step".to_string(),
SyntheticsTestRequest::new()
.dns_server("8.8.8.8".to_string())
.dns_server_port("53".to_string())
.dns_server_port(
SyntheticsTestRequestDNSServerPort
::SyntheticsTestRequestVariableDNSServerPort(
"53".to_string(),
),
)
.host("troisdizaines.com".to_string()),
SyntheticsAPITestStepSubtype::DNS,
)
Expand Down
2 changes: 2 additions & 0 deletions src/datadogV1/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,8 @@ pub mod model_synthetics_test_request_certificate;
pub use self::model_synthetics_test_request_certificate::SyntheticsTestRequestCertificate;
pub mod model_synthetics_test_request_certificate_item;
pub use self::model_synthetics_test_request_certificate_item::SyntheticsTestRequestCertificateItem;
pub mod model_synthetics_test_request_dns_server_port;
pub use self::model_synthetics_test_request_dns_server_port::SyntheticsTestRequestDNSServerPort;
pub mod model_synthetics_test_request_body_file;
pub use self::model_synthetics_test_request_body_file::SyntheticsTestRequestBodyFile;
pub mod model_synthetics_test_options_http_version;
Expand Down
19 changes: 16 additions & 3 deletions src/datadogV1/model/model_synthetics_test_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct SyntheticsTestRequest {
pub dns_server: Option<String>,
/// DNS server port to use for DNS tests.
#[serde(rename = "dnsServerPort")]
pub dns_server_port: Option<String>,
pub dns_server_port: Option<crate::datadogV1::model::SyntheticsTestRequestDNSServerPort>,
/// Files to be used as part of the request in the test. Only valid if `bodyType` is `multipart/form-data`.
#[serde(rename = "files")]
pub files: Option<Vec<crate::datadogV1::model::SyntheticsTestRequestBodyFile>>,
Expand Down Expand Up @@ -221,7 +221,10 @@ impl SyntheticsTestRequest {
self
}

pub fn dns_server_port(mut self, value: String) -> Self {
pub fn dns_server_port(
mut self,
value: crate::datadogV1::model::SyntheticsTestRequestDNSServerPort,
) -> Self {
self.dns_server_port = Some(value);
self
}
Expand Down Expand Up @@ -383,7 +386,9 @@ impl<'de> Deserialize<'de> for SyntheticsTestRequest {
let mut compressed_json_descriptor: Option<String> = None;
let mut compressed_proto_file: Option<String> = None;
let mut dns_server: Option<String> = None;
let mut dns_server_port: Option<String> = None;
let mut dns_server_port: Option<
crate::datadogV1::model::SyntheticsTestRequestDNSServerPort,
> = None;
let mut files: Option<Vec<crate::datadogV1::model::SyntheticsTestRequestBodyFile>> =
None;
let mut follow_redirects: Option<bool> = None;
Expand Down Expand Up @@ -518,6 +523,14 @@ impl<'de> Deserialize<'de> for SyntheticsTestRequest {
}
dns_server_port =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _dns_server_port) = dns_server_port {
match _dns_server_port {
crate::datadogV1::model::SyntheticsTestRequestDNSServerPort::UnparsedObject(_dns_server_port) => {
_unparsed = true;
},
_ => {}
}
}
}
"files" => {
if v.is_null() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.
use serde::{Deserialize, Deserializer, Serialize};

/// DNS server port to use for DNS tests.
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq, Serialize)]
#[serde(untagged)]
pub enum SyntheticsTestRequestDNSServerPort {
SyntheticsTestRequestNumericalDNSServerPort(i64),
SyntheticsTestRequestVariableDNSServerPort(String),
UnparsedObject(crate::datadog::UnparsedObject),
}

impl<'de> Deserialize<'de> for SyntheticsTestRequestDNSServerPort {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let value: serde_json::Value = Deserialize::deserialize(deserializer)?;
if let Ok(_v) = serde_json::from_value::<i64>(value.clone()) {
return Ok(
SyntheticsTestRequestDNSServerPort::SyntheticsTestRequestNumericalDNSServerPort(_v),
);
}
if let Ok(_v) = serde_json::from_value::<String>(value.clone()) {
return Ok(
SyntheticsTestRequestDNSServerPort::SyntheticsTestRequestVariableDNSServerPort(_v),
);
}

return Ok(SyntheticsTestRequestDNSServerPort::UnparsedObject(
crate::datadog::UnparsedObject { value },
));
}
}
Loading