Skip to content
Open
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
81 changes: 81 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17075,6 +17075,12 @@ components:
required:
- id
type: object
DeploymentGateRulesResponse:
description: Response for a deployment gate rules.
properties:
data:
$ref: '#/components/schemas/ListDeploymentRuleResponseData'
type: object
DeploymentMetadata:
description: Metadata object containing the publication creation information.
properties:
Expand Down Expand Up @@ -30199,6 +30205,37 @@ components:
type: string
x-enum-varnames:
- LIST_CONNECTIONS_RESPONSE
ListDeploymentRuleResponseData:
description: Data for a list of deployment rules.
properties:
attributes:
$ref: '#/components/schemas/ListDeploymentRulesResponseDataAttributes'
id:
description: Unique identifier of the deployment rule.
example: 1111-2222-3333-4444-555566667777
type: string
type:
$ref: '#/components/schemas/ListDeploymentRulesDataType'
required:
- type
- attributes
- id
type: object
ListDeploymentRulesDataType:
description: List deployment rule resource type.
enum:
- list_deployment_rules
example: list_deployment_rules
type: string
x-enum-varnames:
- LIST_DEPLOYMENT_RULES
ListDeploymentRulesResponseDataAttributes:
properties:
rules:
items:
$ref: '#/components/schemas/DeploymentRuleResponseDataAttributes'
type: array
type: object
ListDevicesResponse:
description: List devices response.
properties:
Expand Down Expand Up @@ -66236,6 +66273,50 @@ paths:

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/deployment_gates/{gate_id}/rules:
get:
description: Endpoint to get rules for a deployment gate.
operationId: GetDeploymentGateRules
parameters:
- description: The ID of the deployment gate.
in: path
name: gate_id
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/DeploymentGateRulesResponse'
description: OK
'400':
$ref: '#/components/responses/HTTPCDGatesBadRequestResponse'
'401':
$ref: '#/components/responses/UnauthorizedResponse'
'403':
$ref: '#/components/responses/ForbiddenResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
'500':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPCIAppErrors'
description: Internal Server Error
security:
- apiKeyAuth: []
appKeyAuth: []
summary: Get rules for a deployment gate
tags:
- Deployment Gates
x-permission:
operator: OR
permissions:
- deployment_gates_read
x-unstable: '**Note**: This endpoint is in preview and may be subject to change.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
post:
description: Endpoint to create a deployment rule. A gate for the rule must
already exist.
Expand Down
20 changes: 20 additions & 0 deletions examples/v2_deployment-gates_GetDeploymentGateRules.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Get rules for a deployment gate returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI;

#[tokio::main]
async fn main() {
// there is a valid "deployment_gate" in the system
let deployment_gate_data_id = std::env::var("DEPLOYMENT_GATE_DATA_ID").unwrap();
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.GetDeploymentGateRules", true);
let api = DeploymentGatesAPI::with_config(configuration);
let resp = api
.get_deployment_gate_rules(deployment_gate_data_id.clone())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
1 change: 1 addition & 0 deletions src/datadog/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl Default for Configuration {
("v2.delete_deployment_gate".to_owned(), false),
("v2.delete_deployment_rule".to_owned(), false),
("v2.get_deployment_gate".to_owned(), false),
("v2.get_deployment_gate_rules".to_owned(), false),
("v2.get_deployment_rule".to_owned(), false),
("v2.update_deployment_gate".to_owned(), false),
("v2.update_deployment_rule".to_owned(), false),
Expand Down
127 changes: 127 additions & 0 deletions src/datadogV2/api/api_deployment_gates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ pub enum GetDeploymentGateError {
UnknownValue(serde_json::Value),
}

/// GetDeploymentGateRulesError is a struct for typed errors of method [`DeploymentGatesAPI::get_deployment_gate_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDeploymentGateRulesError {
HTTPCDGatesBadRequestResponse(crate::datadogV2::model::HTTPCDGatesBadRequestResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
HTTPCIAppErrors(crate::datadogV2::model::HTTPCIAppErrors),
UnknownValue(serde_json::Value),
}

/// GetDeploymentRuleError is a struct for typed errors of method [`DeploymentGatesAPI::get_deployment_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -807,6 +817,123 @@ impl DeploymentGatesAPI {
}
}

/// Endpoint to get rules for a deployment gate.
pub async fn get_deployment_gate_rules(
&self,
gate_id: String,
) -> Result<
crate::datadogV2::model::DeploymentGateRulesResponse,
datadog::Error<GetDeploymentGateRulesError>,
> {
match self.get_deployment_gate_rules_with_http_info(gate_id).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}

/// Endpoint to get rules for a deployment gate.
pub async fn get_deployment_gate_rules_with_http_info(
&self,
gate_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::DeploymentGateRulesResponse>,
datadog::Error<GetDeploymentGateRulesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_deployment_gate_rules";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_deployment_gate_rules' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}

let local_client = &self.client;

let local_uri_str = format!(
"{}/api/v2/deployment_gates/{gate_id}/rules",
local_configuration.get_operation_host(operation_id),
gate_id = datadog::urlencode(gate_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());

// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));

// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};

// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};

local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;

let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);

if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::DeploymentGateRulesResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetDeploymentGateRulesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}

/// Endpoint to get a deployment rule.
pub async fn get_deployment_rule(
&self,
Expand Down
36 changes: 22 additions & 14 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2210,32 +2210,40 @@ pub mod model_deployment_gate_response_data_attributes_updated_by;
pub use self::model_deployment_gate_response_data_attributes_updated_by::DeploymentGateResponseDataAttributesUpdatedBy;
pub mod model_httpcd_gates_bad_request_response;
pub use self::model_httpcd_gates_bad_request_response::HTTPCDGatesBadRequestResponse;
pub mod model_create_deployment_rule_params;
pub use self::model_create_deployment_rule_params::CreateDeploymentRuleParams;
pub mod model_create_deployment_rule_params_data;
pub use self::model_create_deployment_rule_params_data::CreateDeploymentRuleParamsData;
pub mod model_create_deployment_rule_params_data_attributes;
pub use self::model_create_deployment_rule_params_data_attributes::CreateDeploymentRuleParamsDataAttributes;
pub mod model_deployment_gate_rules_response;
pub use self::model_deployment_gate_rules_response::DeploymentGateRulesResponse;
pub mod model_list_deployment_rule_response_data;
pub use self::model_list_deployment_rule_response_data::ListDeploymentRuleResponseData;
pub mod model_list_deployment_rules_response_data_attributes;
pub use self::model_list_deployment_rules_response_data_attributes::ListDeploymentRulesResponseDataAttributes;
pub mod model_deployment_rule_response_data_attributes;
pub use self::model_deployment_rule_response_data_attributes::DeploymentRuleResponseDataAttributes;
pub mod model_deployment_rule_response_data_attributes_created_by;
pub use self::model_deployment_rule_response_data_attributes_created_by::DeploymentRuleResponseDataAttributesCreatedBy;
pub mod model_deployment_rule_options_faulty_deployment_detection;
pub use self::model_deployment_rule_options_faulty_deployment_detection::DeploymentRuleOptionsFaultyDeploymentDetection;
pub mod model_deployment_rule_options_monitor;
pub use self::model_deployment_rule_options_monitor::DeploymentRuleOptionsMonitor;
pub mod model_deployment_rules_options;
pub use self::model_deployment_rules_options::DeploymentRulesOptions;
pub mod model_deployment_rule_response_data_attributes_type;
pub use self::model_deployment_rule_response_data_attributes_type::DeploymentRuleResponseDataAttributesType;
pub mod model_deployment_rule_response_data_attributes_updated_by;
pub use self::model_deployment_rule_response_data_attributes_updated_by::DeploymentRuleResponseDataAttributesUpdatedBy;
pub mod model_list_deployment_rules_data_type;
pub use self::model_list_deployment_rules_data_type::ListDeploymentRulesDataType;
pub mod model_create_deployment_rule_params;
pub use self::model_create_deployment_rule_params::CreateDeploymentRuleParams;
pub mod model_create_deployment_rule_params_data;
pub use self::model_create_deployment_rule_params_data::CreateDeploymentRuleParamsData;
pub mod model_create_deployment_rule_params_data_attributes;
pub use self::model_create_deployment_rule_params_data_attributes::CreateDeploymentRuleParamsDataAttributes;
pub mod model_deployment_rule_data_type;
pub use self::model_deployment_rule_data_type::DeploymentRuleDataType;
pub mod model_deployment_rule_response;
pub use self::model_deployment_rule_response::DeploymentRuleResponse;
pub mod model_deployment_rule_response_data;
pub use self::model_deployment_rule_response_data::DeploymentRuleResponseData;
pub mod model_deployment_rule_response_data_attributes;
pub use self::model_deployment_rule_response_data_attributes::DeploymentRuleResponseDataAttributes;
pub mod model_deployment_rule_response_data_attributes_created_by;
pub use self::model_deployment_rule_response_data_attributes_created_by::DeploymentRuleResponseDataAttributesCreatedBy;
pub mod model_deployment_rule_response_data_attributes_type;
pub use self::model_deployment_rule_response_data_attributes_type::DeploymentRuleResponseDataAttributesType;
pub mod model_deployment_rule_response_data_attributes_updated_by;
pub use self::model_deployment_rule_response_data_attributes_updated_by::DeploymentRuleResponseDataAttributesUpdatedBy;
pub mod model_httpcd_gates_not_found_response;
pub use self::model_httpcd_gates_not_found_response::HTTPCDGatesNotFoundResponse;
pub mod model_httpcd_rules_not_found_response;
Expand Down
Loading
Loading