Skip to content

Commit 8d5fecf

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 1943b0b of spec repo
1 parent 37d739b commit 8d5fecf

File tree

9 files changed

+378
-16
lines changed

9 files changed

+378
-16
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16644,6 +16644,14 @@ components:
1664416644
required:
1664516645
- id
1664616646
type: object
16647+
DeploymentGateRulesResponse:
16648+
description: Response for a deployment gate rules.
16649+
properties:
16650+
data:
16651+
items:
16652+
$ref: '#/components/schemas/DeploymentRuleResponseData'
16653+
type: array
16654+
type: object
1664716655
DeploymentMetadata:
1664816656
description: Metadata object containing the publication creation information.
1664916657
properties:
@@ -64391,6 +64399,50 @@ paths:
6439164399

6439264400
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6439364401
/api/v2/deployment_gates/{gate_id}/rules:
64402+
get:
64403+
description: Endpoint to get rules for a deployment gate.
64404+
operationId: GetDeploymentGateRules
64405+
parameters:
64406+
- description: The ID of the deployment gate.
64407+
in: path
64408+
name: gate_id
64409+
required: true
64410+
schema:
64411+
type: string
64412+
responses:
64413+
'200':
64414+
content:
64415+
application/json:
64416+
schema:
64417+
$ref: '#/components/schemas/DeploymentGateRulesResponse'
64418+
description: OK
64419+
'400':
64420+
$ref: '#/components/responses/HTTPCDGatesBadRequestResponse'
64421+
'401':
64422+
$ref: '#/components/responses/UnauthorizedResponse'
64423+
'403':
64424+
$ref: '#/components/responses/ForbiddenResponse'
64425+
'429':
64426+
$ref: '#/components/responses/TooManyRequestsResponse'
64427+
'500':
64428+
content:
64429+
application/json:
64430+
schema:
64431+
$ref: '#/components/schemas/HTTPCIAppErrors'
64432+
description: Internal Server Error
64433+
security:
64434+
- apiKeyAuth: []
64435+
appKeyAuth: []
64436+
summary: Get rules for a deployment gate
64437+
tags:
64438+
- Deployment Gates
64439+
x-permission:
64440+
operator: OR
64441+
permissions:
64442+
- deployment_gates_read
64443+
x-unstable: '**Note**: This endpoint is in preview and may be subject to change.
64444+
64445+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6439464446
post:
6439564447
description: Endpoint to create a deployment rule. A gate for the rule must
6439664448
already exist.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Get rules for a deployment gate returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
// there is a valid "deployment_gate" in the system
8+
let deployment_gate_data_id = std::env::var("DEPLOYMENT_GATE_DATA_ID").unwrap();
9+
let mut configuration = datadog::Configuration::new();
10+
configuration.set_unstable_operation_enabled("v2.GetDeploymentGateRules", true);
11+
let api = DeploymentGatesAPI::with_config(configuration);
12+
let resp = api
13+
.get_deployment_gate_rules(deployment_gate_data_id.clone())
14+
.await;
15+
if let Ok(value) = resp {
16+
println!("{:#?}", value);
17+
} else {
18+
println!("{:#?}", resp.unwrap_err());
19+
}
20+
}

src/datadog/configuration.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ impl Default for Configuration {
179179
("v2.delete_deployment_gate".to_owned(), false),
180180
("v2.delete_deployment_rule".to_owned(), false),
181181
("v2.get_deployment_gate".to_owned(), false),
182+
("v2.get_deployment_gate_rules".to_owned(), false),
182183
("v2.get_deployment_rule".to_owned(), false),
183184
("v2.update_deployment_gate".to_owned(), false),
184185
("v2.update_deployment_rule".to_owned(), false),

src/datadogV2/api/api_deployment_gates.rs

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ pub enum GetDeploymentGateError {
6464
UnknownValue(serde_json::Value),
6565
}
6666

67+
/// GetDeploymentGateRulesError is a struct for typed errors of method [`DeploymentGatesAPI::get_deployment_gate_rules`]
68+
#[derive(Debug, Clone, Serialize, Deserialize)]
69+
#[serde(untagged)]
70+
pub enum GetDeploymentGateRulesError {
71+
HTTPCDGatesBadRequestResponse(crate::datadogV2::model::HTTPCDGatesBadRequestResponse),
72+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
73+
HTTPCIAppErrors(crate::datadogV2::model::HTTPCIAppErrors),
74+
UnknownValue(serde_json::Value),
75+
}
76+
6777
/// GetDeploymentRuleError is a struct for typed errors of method [`DeploymentGatesAPI::get_deployment_rule`]
6878
#[derive(Debug, Clone, Serialize, Deserialize)]
6979
#[serde(untagged)]
@@ -807,6 +817,123 @@ impl DeploymentGatesAPI {
807817
}
808818
}
809819

820+
/// Endpoint to get rules for a deployment gate.
821+
pub async fn get_deployment_gate_rules(
822+
&self,
823+
gate_id: String,
824+
) -> Result<
825+
crate::datadogV2::model::DeploymentGateRulesResponse,
826+
datadog::Error<GetDeploymentGateRulesError>,
827+
> {
828+
match self.get_deployment_gate_rules_with_http_info(gate_id).await {
829+
Ok(response_content) => {
830+
if let Some(e) = response_content.entity {
831+
Ok(e)
832+
} else {
833+
Err(datadog::Error::Serde(serde::de::Error::custom(
834+
"response content was None",
835+
)))
836+
}
837+
}
838+
Err(err) => Err(err),
839+
}
840+
}
841+
842+
/// Endpoint to get rules for a deployment gate.
843+
pub async fn get_deployment_gate_rules_with_http_info(
844+
&self,
845+
gate_id: String,
846+
) -> Result<
847+
datadog::ResponseContent<crate::datadogV2::model::DeploymentGateRulesResponse>,
848+
datadog::Error<GetDeploymentGateRulesError>,
849+
> {
850+
let local_configuration = &self.config;
851+
let operation_id = "v2.get_deployment_gate_rules";
852+
if local_configuration.is_unstable_operation_enabled(operation_id) {
853+
warn!("Using unstable operation {operation_id}");
854+
} else {
855+
let local_error = datadog::UnstableOperationDisabledError {
856+
msg: "Operation 'v2.get_deployment_gate_rules' is not enabled".to_string(),
857+
};
858+
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
859+
}
860+
861+
let local_client = &self.client;
862+
863+
let local_uri_str = format!(
864+
"{}/api/v2/deployment_gates/{gate_id}/rules",
865+
local_configuration.get_operation_host(operation_id),
866+
gate_id = datadog::urlencode(gate_id)
867+
);
868+
let mut local_req_builder =
869+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
870+
871+
// build headers
872+
let mut headers = HeaderMap::new();
873+
headers.insert("Accept", HeaderValue::from_static("application/json"));
874+
875+
// build user agent
876+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
877+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
878+
Err(e) => {
879+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
880+
headers.insert(
881+
reqwest::header::USER_AGENT,
882+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
883+
)
884+
}
885+
};
886+
887+
// build auth
888+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
889+
headers.insert(
890+
"DD-API-KEY",
891+
HeaderValue::from_str(local_key.key.as_str())
892+
.expect("failed to parse DD-API-KEY header"),
893+
);
894+
};
895+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
896+
headers.insert(
897+
"DD-APPLICATION-KEY",
898+
HeaderValue::from_str(local_key.key.as_str())
899+
.expect("failed to parse DD-APPLICATION-KEY header"),
900+
);
901+
};
902+
903+
local_req_builder = local_req_builder.headers(headers);
904+
let local_req = local_req_builder.build()?;
905+
log::debug!("request content: {:?}", local_req.body());
906+
let local_resp = local_client.execute(local_req).await?;
907+
908+
let local_status = local_resp.status();
909+
let local_content = local_resp.text().await?;
910+
log::debug!("response content: {}", local_content);
911+
912+
if !local_status.is_client_error() && !local_status.is_server_error() {
913+
match serde_json::from_str::<crate::datadogV2::model::DeploymentGateRulesResponse>(
914+
&local_content,
915+
) {
916+
Ok(e) => {
917+
return Ok(datadog::ResponseContent {
918+
status: local_status,
919+
content: local_content,
920+
entity: Some(e),
921+
})
922+
}
923+
Err(e) => return Err(datadog::Error::Serde(e)),
924+
};
925+
} else {
926+
let local_entity: Option<GetDeploymentGateRulesError> =
927+
serde_json::from_str(&local_content).ok();
928+
let local_error = datadog::ResponseContent {
929+
status: local_status,
930+
content: local_content,
931+
entity: local_entity,
932+
};
933+
Err(datadog::Error::ResponseError(local_error))
934+
}
935+
}
936+
810937
/// Endpoint to get a deployment rule.
811938
pub async fn get_deployment_rule(
812939
&self,

src/datadogV2/model/mod.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,32 +2178,34 @@ pub mod model_deployment_gate_response_data_attributes_updated_by;
21782178
pub use self::model_deployment_gate_response_data_attributes_updated_by::DeploymentGateResponseDataAttributesUpdatedBy;
21792179
pub mod model_httpcd_gates_bad_request_response;
21802180
pub use self::model_httpcd_gates_bad_request_response::HTTPCDGatesBadRequestResponse;
2181-
pub mod model_create_deployment_rule_params;
2182-
pub use self::model_create_deployment_rule_params::CreateDeploymentRuleParams;
2183-
pub mod model_create_deployment_rule_params_data;
2184-
pub use self::model_create_deployment_rule_params_data::CreateDeploymentRuleParamsData;
2185-
pub mod model_create_deployment_rule_params_data_attributes;
2186-
pub use self::model_create_deployment_rule_params_data_attributes::CreateDeploymentRuleParamsDataAttributes;
2187-
pub mod model_deployment_rule_options_faulty_deployment_detection;
2188-
pub use self::model_deployment_rule_options_faulty_deployment_detection::DeploymentRuleOptionsFaultyDeploymentDetection;
2189-
pub mod model_deployment_rule_options_monitor;
2190-
pub use self::model_deployment_rule_options_monitor::DeploymentRuleOptionsMonitor;
2191-
pub mod model_deployment_rules_options;
2192-
pub use self::model_deployment_rules_options::DeploymentRulesOptions;
2193-
pub mod model_deployment_rule_data_type;
2194-
pub use self::model_deployment_rule_data_type::DeploymentRuleDataType;
2195-
pub mod model_deployment_rule_response;
2196-
pub use self::model_deployment_rule_response::DeploymentRuleResponse;
2181+
pub mod model_deployment_gate_rules_response;
2182+
pub use self::model_deployment_gate_rules_response::DeploymentGateRulesResponse;
21972183
pub mod model_deployment_rule_response_data;
21982184
pub use self::model_deployment_rule_response_data::DeploymentRuleResponseData;
21992185
pub mod model_deployment_rule_response_data_attributes;
22002186
pub use self::model_deployment_rule_response_data_attributes::DeploymentRuleResponseDataAttributes;
22012187
pub mod model_deployment_rule_response_data_attributes_created_by;
22022188
pub use self::model_deployment_rule_response_data_attributes_created_by::DeploymentRuleResponseDataAttributesCreatedBy;
2189+
pub mod model_deployment_rule_options_faulty_deployment_detection;
2190+
pub use self::model_deployment_rule_options_faulty_deployment_detection::DeploymentRuleOptionsFaultyDeploymentDetection;
2191+
pub mod model_deployment_rule_options_monitor;
2192+
pub use self::model_deployment_rule_options_monitor::DeploymentRuleOptionsMonitor;
2193+
pub mod model_deployment_rules_options;
2194+
pub use self::model_deployment_rules_options::DeploymentRulesOptions;
22032195
pub mod model_deployment_rule_response_data_attributes_type;
22042196
pub use self::model_deployment_rule_response_data_attributes_type::DeploymentRuleResponseDataAttributesType;
22052197
pub mod model_deployment_rule_response_data_attributes_updated_by;
22062198
pub use self::model_deployment_rule_response_data_attributes_updated_by::DeploymentRuleResponseDataAttributesUpdatedBy;
2199+
pub mod model_deployment_rule_data_type;
2200+
pub use self::model_deployment_rule_data_type::DeploymentRuleDataType;
2201+
pub mod model_create_deployment_rule_params;
2202+
pub use self::model_create_deployment_rule_params::CreateDeploymentRuleParams;
2203+
pub mod model_create_deployment_rule_params_data;
2204+
pub use self::model_create_deployment_rule_params_data::CreateDeploymentRuleParamsData;
2205+
pub mod model_create_deployment_rule_params_data_attributes;
2206+
pub use self::model_create_deployment_rule_params_data_attributes::CreateDeploymentRuleParamsDataAttributes;
2207+
pub mod model_deployment_rule_response;
2208+
pub use self::model_deployment_rule_response::DeploymentRuleResponse;
22072209
pub mod model_httpcd_gates_not_found_response;
22082210
pub use self::model_httpcd_gates_not_found_response::HTTPCDGatesNotFoundResponse;
22092211
pub mod model_httpcd_rules_not_found_response;
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
use serde::de::{Error, MapAccess, Visitor};
5+
use serde::{Deserialize, Deserializer, Serialize};
6+
use serde_with::skip_serializing_none;
7+
use std::fmt::{self, Formatter};
8+
9+
/// Response for a deployment gate rules.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct DeploymentGateRulesResponse {
14+
#[serde(rename = "data")]
15+
pub data: Option<Vec<crate::datadogV2::model::DeploymentRuleResponseData>>,
16+
#[serde(flatten)]
17+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
18+
#[serde(skip)]
19+
#[serde(default)]
20+
pub(crate) _unparsed: bool,
21+
}
22+
23+
impl DeploymentGateRulesResponse {
24+
pub fn new() -> DeploymentGateRulesResponse {
25+
DeploymentGateRulesResponse {
26+
data: None,
27+
additional_properties: std::collections::BTreeMap::new(),
28+
_unparsed: false,
29+
}
30+
}
31+
32+
pub fn data(mut self, value: Vec<crate::datadogV2::model::DeploymentRuleResponseData>) -> Self {
33+
self.data = Some(value);
34+
self
35+
}
36+
37+
pub fn additional_properties(
38+
mut self,
39+
value: std::collections::BTreeMap<String, serde_json::Value>,
40+
) -> Self {
41+
self.additional_properties = value;
42+
self
43+
}
44+
}
45+
46+
impl Default for DeploymentGateRulesResponse {
47+
fn default() -> Self {
48+
Self::new()
49+
}
50+
}
51+
52+
impl<'de> Deserialize<'de> for DeploymentGateRulesResponse {
53+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
54+
where
55+
D: Deserializer<'de>,
56+
{
57+
struct DeploymentGateRulesResponseVisitor;
58+
impl<'a> Visitor<'a> for DeploymentGateRulesResponseVisitor {
59+
type Value = DeploymentGateRulesResponse;
60+
61+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
62+
f.write_str("a mapping")
63+
}
64+
65+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
66+
where
67+
M: MapAccess<'a>,
68+
{
69+
let mut data: Option<Vec<crate::datadogV2::model::DeploymentRuleResponseData>> =
70+
None;
71+
let mut additional_properties: std::collections::BTreeMap<
72+
String,
73+
serde_json::Value,
74+
> = std::collections::BTreeMap::new();
75+
let mut _unparsed = false;
76+
77+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
78+
match k.as_str() {
79+
"data" => {
80+
if v.is_null() {
81+
continue;
82+
}
83+
data = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
84+
}
85+
&_ => {
86+
if let Ok(value) = serde_json::from_value(v.clone()) {
87+
additional_properties.insert(k, value);
88+
}
89+
}
90+
}
91+
}
92+
93+
let content = DeploymentGateRulesResponse {
94+
data,
95+
additional_properties,
96+
_unparsed,
97+
};
98+
99+
Ok(content)
100+
}
101+
}
102+
103+
deserializer.deserialize_any(DeploymentGateRulesResponseVisitor)
104+
}
105+
}

0 commit comments

Comments
 (0)