Skip to content

Commit ce07a18

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add GET /api/v2/apm/services endpoint to public documentation (#1073)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent bc24f0e commit ce07a18

17 files changed

+854
-40
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51360,6 +51360,49 @@ components:
5136051360
$ref: '#/components/schemas/ServiceDefinitionData'
5136151361
type: array
5136251362
type: object
51363+
ServiceList:
51364+
properties:
51365+
data:
51366+
$ref: '#/components/schemas/ServiceListData'
51367+
type: object
51368+
ServiceListData:
51369+
properties:
51370+
attributes:
51371+
$ref: '#/components/schemas/ServiceListDataAttributes'
51372+
id:
51373+
type: string
51374+
type:
51375+
$ref: '#/components/schemas/ServiceListDataType'
51376+
required:
51377+
- type
51378+
type: object
51379+
ServiceListDataAttributes:
51380+
properties:
51381+
metadata:
51382+
items:
51383+
$ref: '#/components/schemas/ServiceListDataAttributesMetadataItems'
51384+
type: array
51385+
services:
51386+
items:
51387+
type: string
51388+
type: array
51389+
type: object
51390+
ServiceListDataAttributesMetadataItems:
51391+
properties:
51392+
isTraced:
51393+
type: boolean
51394+
isUsm:
51395+
type: boolean
51396+
type: object
51397+
ServiceListDataType:
51398+
default: services_list
51399+
description: Services list resource type.
51400+
enum:
51401+
- services_list
51402+
example: services_list
51403+
type: string
51404+
x-enum-varnames:
51405+
- SERVICES_LIST
5136351406
ServiceNowBasicAuth:
5136451407
description: The definition of the `ServiceNowBasicAuth` object.
5136551408
properties:
@@ -61622,6 +61665,26 @@ paths:
6162261665
permissions:
6162361666
- apm_retention_filter_write
6162461667
- apm_pipelines_write
61668+
/api/v2/apm/services:
61669+
get:
61670+
operationId: GetServiceList
61671+
responses:
61672+
'200':
61673+
content:
61674+
application/json:
61675+
schema:
61676+
$ref: '#/components/schemas/ServiceList'
61677+
description: OK
61678+
'429':
61679+
$ref: '#/components/responses/TooManyRequestsResponse'
61680+
security:
61681+
- apiKeyAuth: []
61682+
appKeyAuth: []
61683+
- AuthZ:
61684+
- apm_read
61685+
summary: Get service list
61686+
tags:
61687+
- APM
6162561688
/api/v2/app-builder/apps:
6162661689
delete:
6162761690
description: Delete multiple apps in a single request from a list of app IDs.
@@ -69355,9 +69418,6 @@ paths:
6935569418
operator: OR
6935669419
permissions:
6935769420
- incident_read
69358-
x-unstable: '**Note**: This endpoint is in Preview.
69359-
69360-
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6936169421
post:
6936269422
description: Create an impact for an incident.
6936369423
operationId: CreateIncidentImpact
@@ -69401,9 +69461,6 @@ paths:
6940169461
operator: OR
6940269462
permissions:
6940369463
- incident_write
69404-
x-unstable: '**Note**: This endpoint is in Preview.
69405-
69406-
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6940769464
/api/v2/incidents/{incident_id}/impacts/{impact_id}:
6940869465
delete:
6940969466
description: Delete an incident impact.
@@ -69434,9 +69491,6 @@ paths:
6943469491
operator: OR
6943569492
permissions:
6943669493
- incident_write
69437-
x-unstable: '**Note**: This endpoint is in Preview.
69438-
69439-
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6944069494
/api/v2/incidents/{incident_id}/relationships/integrations:
6944169495
get:
6944269496
description: Get all integration metadata for an incident.
@@ -88607,6 +88661,9 @@ servers:
8860788661
tags:
8860888662
- description: Configure your API endpoints through the Datadog API.
8860988663
name: API Management
88664+
- description: Observe, troubleshoot, and improve cloud-scale applications with all
88665+
telemetry in context
88666+
name: APM
8861088667
- description: Manage configuration of [APM retention filters](https://app.datadoghq.com/apm/traces/retention-filters)
8861188668
for your organization. You need an API and application key with Admin rights to
8861288669
interact with this endpoint. See [retention filters](https://docs.datadoghq.com/tracing/trace_pipeline/trace_retention/#retention-filters)

examples/v2_apm_GetServiceList.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Get service list returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_apm::APMAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let configuration = datadog::Configuration::new();
8+
let api = APMAPI::with_config(configuration);
9+
let resp = api.get_service_list().await;
10+
if let Ok(value) = resp {
11+
println!("{:#?}", value);
12+
} else {
13+
println!("{:#?}", resp.unwrap_err());
14+
}
15+
}

src/datadog/configuration.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,12 @@ impl Default for Configuration {
188188
("v2.update_deployment_gate".to_owned(), false),
189189
("v2.update_deployment_rule".to_owned(), false),
190190
("v2.create_incident".to_owned(), false),
191-
("v2.create_incident_impact".to_owned(), false),
192191
("v2.create_incident_integration".to_owned(), false),
193192
("v2.create_incident_notification_rule".to_owned(), false),
194193
("v2.create_incident_notification_template".to_owned(), false),
195194
("v2.create_incident_todo".to_owned(), false),
196195
("v2.create_incident_type".to_owned(), false),
197196
("v2.delete_incident".to_owned(), false),
198-
("v2.delete_incident_impact".to_owned(), false),
199197
("v2.delete_incident_integration".to_owned(), false),
200198
("v2.delete_incident_notification_rule".to_owned(), false),
201199
("v2.delete_incident_notification_template".to_owned(), false),
@@ -208,7 +206,6 @@ impl Default for Configuration {
208206
("v2.get_incident_todo".to_owned(), false),
209207
("v2.get_incident_type".to_owned(), false),
210208
("v2.list_incident_attachments".to_owned(), false),
211-
("v2.list_incident_impacts".to_owned(), false),
212209
("v2.list_incident_integrations".to_owned(), false),
213210
("v2.list_incident_notification_rules".to_owned(), false),
214211
("v2.list_incident_notification_templates".to_owned(), false),

src/datadogV2/api/api_apm.rs

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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 crate::datadog;
5+
use reqwest::header::{HeaderMap, HeaderValue};
6+
use serde::{Deserialize, Serialize};
7+
8+
/// GetServiceListError is a struct for typed errors of method [`APMAPI::get_service_list`]
9+
#[derive(Debug, Clone, Serialize, Deserialize)]
10+
#[serde(untagged)]
11+
pub enum GetServiceListError {
12+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
13+
UnknownValue(serde_json::Value),
14+
}
15+
16+
/// Observe, troubleshoot, and improve cloud-scale applications with all telemetry in context
17+
#[derive(Debug, Clone)]
18+
pub struct APMAPI {
19+
config: datadog::Configuration,
20+
client: reqwest_middleware::ClientWithMiddleware,
21+
}
22+
23+
impl Default for APMAPI {
24+
fn default() -> Self {
25+
Self::with_config(datadog::Configuration::default())
26+
}
27+
}
28+
29+
impl APMAPI {
30+
pub fn new() -> Self {
31+
Self::default()
32+
}
33+
pub fn with_config(config: datadog::Configuration) -> Self {
34+
let mut reqwest_client_builder = reqwest::Client::builder();
35+
36+
if let Some(proxy_url) = &config.proxy_url {
37+
let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
38+
reqwest_client_builder = reqwest_client_builder.proxy(proxy);
39+
}
40+
41+
let mut middleware_client_builder =
42+
reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
43+
44+
if config.enable_retry {
45+
struct RetryableStatus;
46+
impl reqwest_retry::RetryableStrategy for RetryableStatus {
47+
fn handle(
48+
&self,
49+
res: &Result<reqwest::Response, reqwest_middleware::Error>,
50+
) -> Option<reqwest_retry::Retryable> {
51+
match res {
52+
Ok(success) => reqwest_retry::default_on_request_success(success),
53+
Err(_) => None,
54+
}
55+
}
56+
}
57+
let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
58+
.build_with_max_retries(config.max_retries);
59+
60+
let retry_middleware =
61+
reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
62+
backoff_policy,
63+
RetryableStatus,
64+
);
65+
66+
middleware_client_builder = middleware_client_builder.with(retry_middleware);
67+
}
68+
69+
let client = middleware_client_builder.build();
70+
71+
Self { config, client }
72+
}
73+
74+
pub fn with_client_and_config(
75+
config: datadog::Configuration,
76+
client: reqwest_middleware::ClientWithMiddleware,
77+
) -> Self {
78+
Self { config, client }
79+
}
80+
81+
pub async fn get_service_list(
82+
&self,
83+
) -> Result<crate::datadogV2::model::ServiceList, datadog::Error<GetServiceListError>> {
84+
match self.get_service_list_with_http_info().await {
85+
Ok(response_content) => {
86+
if let Some(e) = response_content.entity {
87+
Ok(e)
88+
} else {
89+
Err(datadog::Error::Serde(serde::de::Error::custom(
90+
"response content was None",
91+
)))
92+
}
93+
}
94+
Err(err) => Err(err),
95+
}
96+
}
97+
98+
pub async fn get_service_list_with_http_info(
99+
&self,
100+
) -> Result<
101+
datadog::ResponseContent<crate::datadogV2::model::ServiceList>,
102+
datadog::Error<GetServiceListError>,
103+
> {
104+
let local_configuration = &self.config;
105+
let operation_id = "v2.get_service_list";
106+
107+
let local_client = &self.client;
108+
109+
let local_uri_str = format!(
110+
"{}/api/v2/apm/services",
111+
local_configuration.get_operation_host(operation_id)
112+
);
113+
let mut local_req_builder =
114+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
115+
116+
// build headers
117+
let mut headers = HeaderMap::new();
118+
headers.insert("Accept", HeaderValue::from_static("application/json"));
119+
120+
// build user agent
121+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
122+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
123+
Err(e) => {
124+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
125+
headers.insert(
126+
reqwest::header::USER_AGENT,
127+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
128+
)
129+
}
130+
};
131+
132+
// build auth
133+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
134+
headers.insert(
135+
"DD-API-KEY",
136+
HeaderValue::from_str(local_key.key.as_str())
137+
.expect("failed to parse DD-API-KEY header"),
138+
);
139+
};
140+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
141+
headers.insert(
142+
"DD-APPLICATION-KEY",
143+
HeaderValue::from_str(local_key.key.as_str())
144+
.expect("failed to parse DD-APPLICATION-KEY header"),
145+
);
146+
};
147+
148+
local_req_builder = local_req_builder.headers(headers);
149+
let local_req = local_req_builder.build()?;
150+
log::debug!("request content: {:?}", local_req.body());
151+
let local_resp = local_client.execute(local_req).await?;
152+
153+
let local_status = local_resp.status();
154+
let local_content = local_resp.text().await?;
155+
log::debug!("response content: {}", local_content);
156+
157+
if !local_status.is_client_error() && !local_status.is_server_error() {
158+
match serde_json::from_str::<crate::datadogV2::model::ServiceList>(&local_content) {
159+
Ok(e) => {
160+
return Ok(datadog::ResponseContent {
161+
status: local_status,
162+
content: local_content,
163+
entity: Some(e),
164+
})
165+
}
166+
Err(e) => return Err(datadog::Error::Serde(e)),
167+
};
168+
} else {
169+
let local_entity: Option<GetServiceListError> =
170+
serde_json::from_str(&local_content).ok();
171+
let local_error = datadog::ResponseContent {
172+
status: local_status,
173+
content: local_content,
174+
entity: local_entity,
175+
};
176+
Err(datadog::Error::ResponseError(local_error))
177+
}
178+
}
179+
}

src/datadogV2/api/api_incidents.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -901,14 +901,6 @@ impl IncidentsAPI {
901901
> {
902902
let local_configuration = &self.config;
903903
let operation_id = "v2.create_incident_impact";
904-
if local_configuration.is_unstable_operation_enabled(operation_id) {
905-
warn!("Using unstable operation {operation_id}");
906-
} else {
907-
let local_error = datadog::UnstableOperationDisabledError {
908-
msg: "Operation 'v2.create_incident_impact' is not enabled".to_string(),
909-
};
910-
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
911-
}
912904

913905
// unbox and build optional parameters
914906
let include = params.include;
@@ -1995,14 +1987,6 @@ impl IncidentsAPI {
19951987
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteIncidentImpactError>> {
19961988
let local_configuration = &self.config;
19971989
let operation_id = "v2.delete_incident_impact";
1998-
if local_configuration.is_unstable_operation_enabled(operation_id) {
1999-
warn!("Using unstable operation {operation_id}");
2000-
} else {
2001-
let local_error = datadog::UnstableOperationDisabledError {
2002-
msg: "Operation 'v2.delete_incident_impact' is not enabled".to_string(),
2003-
};
2004-
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2005-
}
20061990

20071991
let local_client = &self.client;
20081992

@@ -3537,14 +3521,6 @@ impl IncidentsAPI {
35373521
> {
35383522
let local_configuration = &self.config;
35393523
let operation_id = "v2.list_incident_impacts";
3540-
if local_configuration.is_unstable_operation_enabled(operation_id) {
3541-
warn!("Using unstable operation {operation_id}");
3542-
} else {
3543-
let local_error = datadog::UnstableOperationDisabledError {
3544-
msg: "Operation 'v2.list_incident_impacts' is not enabled".to_string(),
3545-
};
3546-
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3547-
}
35483524

35493525
// unbox and build optional parameters
35503526
let include = params.include;

src/datadogV2/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub mod api_action_connection;
66
pub mod api_actions_datastores;
77
pub mod api_agentless_scanning;
88
pub mod api_api_management;
9+
pub mod api_apm;
910
pub mod api_apm_retention_filters;
1011
pub mod api_app_builder;
1112
pub mod api_application_security;

src/datadogV2/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub use self::api::api_action_connection;
77
pub use self::api::api_actions_datastores;
88
pub use self::api::api_agentless_scanning;
99
pub use self::api::api_api_management;
10+
pub use self::api::api_apm;
1011
pub use self::api::api_apm_retention_filters;
1112
pub use self::api::api_app_builder;
1213
pub use self::api::api_application_security;

0 commit comments

Comments
 (0)