Skip to content

Commit 7a4096d

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 849304a of spec repo
1 parent e72bde0 commit 7a4096d

File tree

14 files changed

+852
-0
lines changed

14 files changed

+852
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51062,6 +51062,49 @@ components:
5106251062
$ref: '#/components/schemas/ServiceDefinitionData'
5106351063
type: array
5106451064
type: object
51065+
ServiceList:
51066+
properties:
51067+
data:
51068+
$ref: '#/components/schemas/ServiceListData'
51069+
type: object
51070+
ServiceListData:
51071+
properties:
51072+
attributes:
51073+
$ref: '#/components/schemas/ServiceListDataAttributes'
51074+
id:
51075+
type: string
51076+
type:
51077+
$ref: '#/components/schemas/ServiceListDataType'
51078+
required:
51079+
- type
51080+
type: object
51081+
ServiceListDataAttributes:
51082+
properties:
51083+
metadata:
51084+
items:
51085+
$ref: '#/components/schemas/ServiceListDataAttributesMetadataItems'
51086+
type: array
51087+
services:
51088+
items:
51089+
type: string
51090+
type: array
51091+
type: object
51092+
ServiceListDataAttributesMetadataItems:
51093+
properties:
51094+
isTraced:
51095+
type: boolean
51096+
isUsm:
51097+
type: boolean
51098+
type: object
51099+
ServiceListDataType:
51100+
default: services_list
51101+
description: Services list resource type.
51102+
enum:
51103+
- services_list
51104+
example: services_list
51105+
type: string
51106+
x-enum-varnames:
51107+
- SERVICES_LIST
5106551108
ServiceNowBasicAuth:
5106651109
description: The definition of the `ServiceNowBasicAuth` object.
5106751110
properties:
@@ -61255,6 +61298,26 @@ paths:
6125561298
permissions:
6125661299
- apm_retention_filter_write
6125761300
- apm_pipelines_write
61301+
/api/v2/apm/services:
61302+
get:
61303+
operationId: GetServiceList
61304+
responses:
61305+
'200':
61306+
content:
61307+
application/json:
61308+
schema:
61309+
$ref: '#/components/schemas/ServiceList'
61310+
description: OK
61311+
'429':
61312+
$ref: '#/components/responses/TooManyRequestsResponse'
61313+
security:
61314+
- apiKeyAuth: []
61315+
appKeyAuth: []
61316+
- AuthZ:
61317+
- apm_read
61318+
summary: Get service list
61319+
tags:
61320+
- APM
6125861321
/api/v2/app-builder/apps:
6125961322
delete:
6126061323
description: Delete multiple apps in a single request from a list of app IDs.
@@ -87993,6 +88056,9 @@ servers:
8799388056
tags:
8799488057
- description: Configure your API endpoints through the Datadog API.
8799588058
name: API Management
88059+
- description: Observe, troubleshoot, and improve cloud-scale applications with all
88060+
telemetry in context
88061+
name: APM
8799688062
- description: Manage configuration of [APM retention filters](https://app.datadoghq.com/apm/traces/retention-filters)
8799788063
for your organization. You need an API and application key with Admin rights to
8799888064
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/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/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;

src/datadogV2/model/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,16 @@ pub mod model_retention_filter_update_data;
900900
pub use self::model_retention_filter_update_data::RetentionFilterUpdateData;
901901
pub mod model_retention_filter_update_attributes;
902902
pub use self::model_retention_filter_update_attributes::RetentionFilterUpdateAttributes;
903+
pub mod model_service_list;
904+
pub use self::model_service_list::ServiceList;
905+
pub mod model_service_list_data;
906+
pub use self::model_service_list_data::ServiceListData;
907+
pub mod model_service_list_data_attributes;
908+
pub use self::model_service_list_data_attributes::ServiceListDataAttributes;
909+
pub mod model_service_list_data_attributes_metadata_items;
910+
pub use self::model_service_list_data_attributes_metadata_items::ServiceListDataAttributesMetadataItems;
911+
pub mod model_service_list_data_type;
912+
pub use self::model_service_list_data_type::ServiceListDataType;
903913
pub mod model_delete_apps_request;
904914
pub use self::model_delete_apps_request::DeleteAppsRequest;
905915
pub mod model_delete_apps_request_data_items;

0 commit comments

Comments
 (0)