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
72 changes: 70 additions & 2 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54693,6 +54693,40 @@ paths:
tags:
- DORA Metrics
x-codegen-request-body-name: body
/api/v2/dora/deployment/{deployment_id}:
delete:
description: Use this API endpoint to delete a deployment event.
operationId: DeleteDORADeployment
parameters:
- description: The ID of the deployment event to delete.
in: path
name: deployment_id
required: true
schema:
type: string
responses:
'202':
description: Accepted
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Bad Request
'403':
$ref: '#/components/responses/NotAuthorizedResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
- appKeyAuth: []
summary: Delete a deployment event
tags:
- DORA Metrics
x-permission:
operator: OR
permissions:
- dora_metrics_write
/api/v2/dora/deployments:
post:
description: Use this API endpoint to get a list of deployment events.
Expand Down Expand Up @@ -54816,6 +54850,40 @@ paths:
tags:
- DORA Metrics
x-codegen-request-body-name: body
/api/v2/dora/failure/{failure_id}:
delete:
description: Use this API endpoint to delete a failure event.
operationId: DeleteDORAFailure
parameters:
- description: The ID of the failure event to delete.
in: path
name: failure_id
required: true
schema:
type: string
responses:
'202':
description: Accepted
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Bad Request
'403':
$ref: '#/components/responses/NotAuthorizedResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
- appKeyAuth: []
summary: Delete a failure event
tags:
- DORA Metrics
x-permission:
operator: OR
permissions:
- dora_metrics_write
/api/v2/dora/failures:
post:
description: Use this API endpoint to get a list of failure events.
Expand Down Expand Up @@ -73317,8 +73385,8 @@ tags:
See the [Container Monitoring page](https://docs.datadoghq.com/containers/) for
more information.
name: Containers
- description: 'Search or send events for DORA Metrics to measure and improve your
software delivery performance. See the [DORA Metrics page](https://docs.datadoghq.com/dora_metrics/)
- description: 'Search, send, or delete events for DORA Metrics to measure and improve
your software delivery performance. See the [DORA Metrics page](https://docs.datadoghq.com/dora_metrics/)
for more information.


Expand Down
15 changes: 15 additions & 0 deletions examples/v2_dora-metrics_DeleteDORADeployment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Delete a deployment event returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_dora_metrics::DORAMetricsAPI;

#[tokio::main]
async fn main() {
let configuration = datadog::Configuration::new();
let api = DORAMetricsAPI::with_config(configuration);
let resp = api.delete_dora_deployment("NO_VALUE".to_string()).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
15 changes: 15 additions & 0 deletions examples/v2_dora-metrics_DeleteDORAFailure.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Delete a failure event returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_dora_metrics::DORAMetricsAPI;

#[tokio::main]
async fn main() {
let configuration = datadog::Configuration::new();
let api = DORAMetricsAPI::with_config(configuration);
let resp = api.delete_dora_failure("NO_VALUE".to_string()).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
199 changes: 198 additions & 1 deletion src/datadogV2/api/api_dora_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ pub enum CreateDORAIncidentError {
UnknownValue(serde_json::Value),
}

/// DeleteDORADeploymentError is a struct for typed errors of method [`DORAMetricsAPI::delete_dora_deployment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteDORADeploymentError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}

/// DeleteDORAFailureError is a struct for typed errors of method [`DORAMetricsAPI::delete_dora_failure`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteDORAFailureError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}

/// GetDORADeploymentError is a struct for typed errors of method [`DORAMetricsAPI::get_dora_deployment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -73,7 +91,7 @@ pub enum ListDORAFailuresError {
UnknownValue(serde_json::Value),
}

/// Search or send events for DORA Metrics to measure and improve your software delivery performance. See the [DORA Metrics page](<https://docs.datadoghq.com/dora_metrics/>) for more information.
/// Search, send, or delete events for DORA Metrics to measure and improve your software delivery performance. See the [DORA Metrics page](<https://docs.datadoghq.com/dora_metrics/>) for more information.
///
/// **Note**: DORA Metrics are not available in the US1-FED site.
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -607,6 +625,185 @@ impl DORAMetricsAPI {
}
}

/// Use this API endpoint to delete a deployment event.
pub async fn delete_dora_deployment(
&self,
deployment_id: String,
) -> Result<(), datadog::Error<DeleteDORADeploymentError>> {
match self
.delete_dora_deployment_with_http_info(deployment_id)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}

/// Use this API endpoint to delete a deployment event.
pub async fn delete_dora_deployment_with_http_info(
&self,
deployment_id: String,
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteDORADeploymentError>> {
let local_configuration = &self.config;
let operation_id = "v2.delete_dora_deployment";

let local_client = &self.client;

let local_uri_str = format!(
"{}/api/v2/dora/deployment/{deployment_id}",
local_configuration.get_operation_host(operation_id),
deployment_id = datadog::urlencode(deployment_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());

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

// 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() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeleteDORADeploymentError> =
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))
}
}

/// Use this API endpoint to delete a failure event.
pub async fn delete_dora_failure(
&self,
failure_id: String,
) -> Result<(), datadog::Error<DeleteDORAFailureError>> {
match self.delete_dora_failure_with_http_info(failure_id).await {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}

/// Use this API endpoint to delete a failure event.
pub async fn delete_dora_failure_with_http_info(
&self,
failure_id: String,
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteDORAFailureError>> {
let local_configuration = &self.config;
let operation_id = "v2.delete_dora_failure";

let local_client = &self.client;

let local_uri_str = format!(
"{}/api/v2/dora/failure/{failure_id}",
local_configuration.get_operation_host(operation_id),
failure_id = datadog::urlencode(failure_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());

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

// 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() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeleteDORAFailureError> =
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))
}
}

/// Use this API endpoint to get a deployment event.
pub async fn get_dora_deployment(
&self,
Expand Down
35 changes: 33 additions & 2 deletions tests/scenarios/features/v2/dora_metrics.feature
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
@endpoint(dora-metrics) @endpoint(dora-metrics-v2)
Feature: DORA Metrics
Search or send events for DORA Metrics to measure and improve your
software delivery performance. See the [DORA Metrics
Search, send, or delete events for DORA Metrics to measure and improve
your software delivery performance. See the [DORA Metrics
page](https://docs.datadoghq.com/dora_metrics/) for more information.
**Note**: DORA Metrics are not available in the US1-FED site.

Background:
Given a valid "apiKeyAuth" key in the system
And an instance of "DORAMetrics" API

@skip @team:DataDog/ci-app-backend
Scenario: Delete a deployment event returns "Accepted" response
Given new "DeleteDORADeployment" request
And a valid "appKeyAuth" key in the system
And request contains "deployment_id" parameter with value "NO_VALUE"
When the request is sent
Then the response status is 202 Accepted

@skip @team:DataDog/ci-app-backend
Scenario: Delete a deployment event returns "Bad Request" response
Given new "DeleteDORADeployment" request
And request contains "deployment_id" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 400 Bad Request

@skip @team:DataDog/ci-app-backend
Scenario: Delete a failure event returns "Accepted" response
Given new "DeleteDORAFailure" request
And a valid "appKeyAuth" key in the system
And request contains "failure_id" parameter with value "NO_VALUE"
When the request is sent
Then the response status is 202 Accepted

@skip @team:DataDog/ci-app-backend
Scenario: Delete a failure event returns "Bad Request" response
Given new "DeleteDORAFailure" request
And a valid "appKeyAuth" key in the system
And request contains "failure_id" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/ci-app-backend
Scenario: Get a deployment event returns "Bad Request" response
Given new "GetDORADeployment" request
Expand Down
Loading