Skip to content
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
75 changes: 66 additions & 9 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51339,6 +51339,49 @@ components:
$ref: '#/components/schemas/ServiceDefinitionData'
type: array
type: object
ServiceList:
properties:
data:
$ref: '#/components/schemas/ServiceListData'
type: object
ServiceListData:
properties:
attributes:
$ref: '#/components/schemas/ServiceListDataAttributes'
id:
type: string
type:
$ref: '#/components/schemas/ServiceListDataType'
required:
- type
type: object
ServiceListDataAttributes:
properties:
metadata:
items:
$ref: '#/components/schemas/ServiceListDataAttributesMetadataItems'
type: array
services:
items:
type: string
type: array
type: object
ServiceListDataAttributesMetadataItems:
properties:
isTraced:
type: boolean
isUsm:
type: boolean
type: object
ServiceListDataType:
default: services_list
description: Services list resource type.
enum:
- services_list
example: services_list
type: string
x-enum-varnames:
- SERVICES_LIST
ServiceNowBasicAuth:
description: The definition of the `ServiceNowBasicAuth` object.
properties:
Expand Down Expand Up @@ -61601,6 +61644,26 @@ paths:
permissions:
- apm_retention_filter_write
- apm_pipelines_write
/api/v2/apm/services:
get:
operationId: GetServiceList
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/ServiceList'
description: OK
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- apm_read
summary: Get service list
tags:
- APM
/api/v2/app-builder/apps:
delete:
description: Delete multiple apps in a single request from a list of app IDs.
Expand Down Expand Up @@ -69334,9 +69397,6 @@ paths:
operator: OR
permissions:
- incident_read
x-unstable: '**Note**: This endpoint is in Preview.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
post:
description: Create an impact for an incident.
operationId: CreateIncidentImpact
Expand Down Expand Up @@ -69380,9 +69440,6 @@ paths:
operator: OR
permissions:
- incident_write
x-unstable: '**Note**: This endpoint is in Preview.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/incidents/{incident_id}/impacts/{impact_id}:
delete:
description: Delete an incident impact.
Expand Down Expand Up @@ -69413,9 +69470,6 @@ paths:
operator: OR
permissions:
- incident_write
x-unstable: '**Note**: This endpoint is in Preview.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/incidents/{incident_id}/relationships/integrations:
get:
description: Get all integration metadata for an incident.
Expand Down Expand Up @@ -88586,6 +88640,9 @@ servers:
tags:
- description: Configure your API endpoints through the Datadog API.
name: API Management
- description: Observe, troubleshoot, and improve cloud-scale applications with all
telemetry in context
name: APM
- description: Manage configuration of [APM retention filters](https://app.datadoghq.com/apm/traces/retention-filters)
for your organization. You need an API and application key with Admin rights to
interact with this endpoint. See [retention filters](https://docs.datadoghq.com/tracing/trace_pipeline/trace_retention/#retention-filters)
Expand Down
15 changes: 15 additions & 0 deletions examples/v2_apm_GetServiceList.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Get service list returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_apm::APMAPI;

#[tokio::main]
async fn main() {
let configuration = datadog::Configuration::new();
let api = APMAPI::with_config(configuration);
let resp = api.get_service_list().await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
3 changes: 0 additions & 3 deletions src/datadog/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,12 @@ impl Default for Configuration {
("v2.update_deployment_gate".to_owned(), false),
("v2.update_deployment_rule".to_owned(), false),
("v2.create_incident".to_owned(), false),
("v2.create_incident_impact".to_owned(), false),
("v2.create_incident_integration".to_owned(), false),
("v2.create_incident_notification_rule".to_owned(), false),
("v2.create_incident_notification_template".to_owned(), false),
("v2.create_incident_todo".to_owned(), false),
("v2.create_incident_type".to_owned(), false),
("v2.delete_incident".to_owned(), false),
("v2.delete_incident_impact".to_owned(), false),
("v2.delete_incident_integration".to_owned(), false),
("v2.delete_incident_notification_rule".to_owned(), false),
("v2.delete_incident_notification_template".to_owned(), false),
Expand All @@ -208,7 +206,6 @@ impl Default for Configuration {
("v2.get_incident_todo".to_owned(), false),
("v2.get_incident_type".to_owned(), false),
("v2.list_incident_attachments".to_owned(), false),
("v2.list_incident_impacts".to_owned(), false),
("v2.list_incident_integrations".to_owned(), false),
("v2.list_incident_notification_rules".to_owned(), false),
("v2.list_incident_notification_templates".to_owned(), false),
Expand Down
179 changes: 179 additions & 0 deletions src/datadogV2/api/api_apm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
// 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 crate::datadog;
use reqwest::header::{HeaderMap, HeaderValue};
use serde::{Deserialize, Serialize};

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

/// Observe, troubleshoot, and improve cloud-scale applications with all telemetry in context
#[derive(Debug, Clone)]
pub struct APMAPI {
config: datadog::Configuration,
client: reqwest_middleware::ClientWithMiddleware,
}

impl Default for APMAPI {
fn default() -> Self {
Self::with_config(datadog::Configuration::default())
}
}

impl APMAPI {
pub fn new() -> Self {
Self::default()
}
pub fn with_config(config: datadog::Configuration) -> Self {
let mut reqwest_client_builder = reqwest::Client::builder();

if let Some(proxy_url) = &config.proxy_url {
let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
reqwest_client_builder = reqwest_client_builder.proxy(proxy);
}

let mut middleware_client_builder =
reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());

if config.enable_retry {
struct RetryableStatus;
impl reqwest_retry::RetryableStrategy for RetryableStatus {
fn handle(
&self,
res: &Result<reqwest::Response, reqwest_middleware::Error>,
) -> Option<reqwest_retry::Retryable> {
match res {
Ok(success) => reqwest_retry::default_on_request_success(success),
Err(_) => None,
}
}
}
let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
.build_with_max_retries(config.max_retries);

let retry_middleware =
reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
backoff_policy,
RetryableStatus,
);

middleware_client_builder = middleware_client_builder.with(retry_middleware);
}

let client = middleware_client_builder.build();

Self { config, client }
}

pub fn with_client_and_config(
config: datadog::Configuration,
client: reqwest_middleware::ClientWithMiddleware,
) -> Self {
Self { config, client }
}

pub async fn get_service_list(
&self,
) -> Result<crate::datadogV2::model::ServiceList, datadog::Error<GetServiceListError>> {
match self.get_service_list_with_http_info().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),
}
}

pub async fn get_service_list_with_http_info(
&self,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::ServiceList>,
datadog::Error<GetServiceListError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_service_list";

let local_client = &self.client;

let local_uri_str = format!(
"{}/api/v2/apm/services",
local_configuration.get_operation_host(operation_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::ServiceList>(&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<GetServiceListError> =
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))
}
}
}
24 changes: 0 additions & 24 deletions src/datadogV2/api/api_incidents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,14 +901,6 @@ impl IncidentsAPI {
> {
let local_configuration = &self.config;
let operation_id = "v2.create_incident_impact";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.create_incident_impact' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}

// unbox and build optional parameters
let include = params.include;
Expand Down Expand Up @@ -1995,14 +1987,6 @@ impl IncidentsAPI {
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteIncidentImpactError>> {
let local_configuration = &self.config;
let operation_id = "v2.delete_incident_impact";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.delete_incident_impact' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}

let local_client = &self.client;

Expand Down Expand Up @@ -3537,14 +3521,6 @@ impl IncidentsAPI {
> {
let local_configuration = &self.config;
let operation_id = "v2.list_incident_impacts";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_incident_impacts' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}

// unbox and build optional parameters
let include = params.include;
Expand Down
1 change: 1 addition & 0 deletions src/datadogV2/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod api_action_connection;
pub mod api_actions_datastores;
pub mod api_agentless_scanning;
pub mod api_api_management;
pub mod api_apm;
pub mod api_apm_retention_filters;
pub mod api_app_builder;
pub mod api_application_security;
Expand Down
1 change: 1 addition & 0 deletions src/datadogV2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub use self::api::api_action_connection;
pub use self::api::api_actions_datastores;
pub use self::api::api_agentless_scanning;
pub use self::api::api_api_management;
pub use self::api::api_apm;
pub use self::api::api_apm_retention_filters;
pub use self::api::api_app_builder;
pub use self::api::api_application_security;
Expand Down
Loading