Skip to content

Commit 8e1a64c

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit fc1fa35 of spec repo
1 parent 3b45b54 commit 8e1a64c

12 files changed

Lines changed: 647 additions & 0 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,14 @@ components:
17721772
required: false
17731773
schema:
17741774
type: boolean
1775+
SlackUserUuidQueryParameter:
1776+
description: The UUID of the Datadog user to list Slack bindings for.
1777+
in: query
1778+
name: user_uuid
1779+
required: true
1780+
schema:
1781+
format: uuid
1782+
type: string
17751783
SloID:
17761784
description: The ID of the SLO.
17771785
in: path
@@ -88673,6 +88681,37 @@ components:
8867388681
required:
8867488682
- slackTrigger
8867588683
type: object
88684+
SlackUserBindingData:
88685+
description: Slack team ID data from a response.
88686+
properties:
88687+
id:
88688+
description: The Slack team ID.
88689+
example: "T01234567"
88690+
type: string
88691+
type:
88692+
$ref: "#/components/schemas/SlackUserBindingType"
88693+
type: object
88694+
SlackUserBindingType:
88695+
default: team_id
88696+
description: Slack user binding resource type.
88697+
enum:
88698+
- team_id
88699+
example: team_id
88700+
type: string
88701+
x-enum-varnames:
88702+
- TEAM_ID
88703+
SlackUserBindingsResponse:
88704+
description: Response with a list of Slack user bindings.
88705+
properties:
88706+
data:
88707+
description: An array of Slack user bindings.
88708+
example: [{"id": "T01234567", "type": "team_id"}, {"id": "T09876543", "type": "team_id"}]
88709+
items:
88710+
$ref: "#/components/schemas/SlackUserBindingData"
88711+
type: array
88712+
required:
88713+
- data
88714+
type: object
8867688715
SloDataSource:
8867788716
default: slo
8867888717
description: A data source for SLO queries.
@@ -135946,6 +135985,36 @@ paths:
135946135985
summary: List ServiceNow users
135947135986
tags:
135948135987
- ServiceNow Integration
135988+
/api/v2/integration/slack/user-bindings:
135989+
get:
135990+
description: List all Slack user bindings for a given Datadog user from the Datadog Slack integration.
135991+
operationId: ListSlackUserBindings
135992+
parameters:
135993+
- $ref: "#/components/parameters/SlackUserUuidQueryParameter"
135994+
responses:
135995+
"200":
135996+
content:
135997+
application/json:
135998+
examples:
135999+
default:
136000+
value:
136001+
data:
136002+
- id: T01234567
136003+
type: team_id
136004+
- id: T09876543
136005+
type: team_id
136006+
schema:
136007+
$ref: "#/components/schemas/SlackUserBindingsResponse"
136008+
description: OK
136009+
"400":
136010+
$ref: "#/components/responses/BadRequestResponse"
136011+
"403":
136012+
$ref: "#/components/responses/ForbiddenResponse"
136013+
"429":
136014+
$ref: "#/components/responses/TooManyRequestsResponse"
136015+
summary: List Slack user bindings
136016+
tags:
136017+
- Slack Integration
135949136018
/api/v2/integration/statuspage/account:
135950136019
delete:
135951136020
description: Delete the Statuspage account configured for your organization.
@@ -185814,6 +185883,13 @@ tags:
185814185883
name: Service Level Objectives
185815185884
- description: Manage your ServiceNow Integration. ServiceNow is a cloud-based platform that helps organizations manage digital workflows for enterprise operations.
185816185885
name: ServiceNow Integration
185886+
- description: |-
185887+
Configure your [Datadog Slack integration](https://docs.datadoghq.com/integrations/slack/)
185888+
directly through the Datadog API.
185889+
externalDocs:
185890+
description: For more information about the Datadog Slack integration, see the integration page.
185891+
url: https://docs.datadoghq.com/integrations/slack/
185892+
name: Slack Integration
185817185893
- description: |-
185818185894
API to create, update, retrieve, and delete Software Catalog entities.
185819185895
externalDocs:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// List Slack user bindings returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_slack_integration::SlackIntegrationAPI;
4+
use uuid::Uuid;
5+
6+
#[tokio::main]
7+
async fn main() {
8+
let configuration = datadog::Configuration::new();
9+
let api = SlackIntegrationAPI::with_config(configuration);
10+
let resp = api
11+
.list_slack_user_bindings(
12+
Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"),
13+
)
14+
.await;
15+
if let Ok(value) = resp {
16+
println!("{:#?}", value);
17+
} else {
18+
println!("{:#?}", resp.unwrap_err());
19+
}
20+
}
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
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+
/// ListSlackUserBindingsError is a struct for typed errors of method [`SlackIntegrationAPI::list_slack_user_bindings`]
9+
#[derive(Debug, Clone, Serialize, Deserialize)]
10+
#[serde(untagged)]
11+
pub enum ListSlackUserBindingsError {
12+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
13+
UnknownValue(serde_json::Value),
14+
}
15+
16+
/// Configure your [Datadog Slack integration](<https://docs.datadoghq.com/integrations/slack/>)
17+
/// directly through the Datadog API.
18+
#[derive(Debug, Clone)]
19+
pub struct SlackIntegrationAPI {
20+
config: datadog::Configuration,
21+
client: reqwest_middleware::ClientWithMiddleware,
22+
}
23+
24+
impl Default for SlackIntegrationAPI {
25+
fn default() -> Self {
26+
Self::with_config(datadog::Configuration::default())
27+
}
28+
}
29+
30+
impl SlackIntegrationAPI {
31+
pub fn new() -> Self {
32+
Self::default()
33+
}
34+
pub fn with_config(config: datadog::Configuration) -> Self {
35+
let reqwest_client_builder = {
36+
let builder = reqwest::Client::builder();
37+
#[cfg(not(target_arch = "wasm32"))]
38+
let builder = if let Some(proxy_url) = &config.proxy_url {
39+
builder.proxy(reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL"))
40+
} else {
41+
builder
42+
};
43+
builder
44+
};
45+
46+
let middleware_client_builder = {
47+
let builder =
48+
reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
49+
#[cfg(feature = "retry")]
50+
let builder = if config.enable_retry {
51+
struct RetryableStatus;
52+
impl reqwest_retry::RetryableStrategy for RetryableStatus {
53+
fn handle(
54+
&self,
55+
res: &Result<reqwest::Response, reqwest_middleware::Error>,
56+
) -> Option<reqwest_retry::Retryable> {
57+
match res {
58+
Ok(success) => reqwest_retry::default_on_request_success(success),
59+
Err(_) => None,
60+
}
61+
}
62+
}
63+
let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
64+
.build_with_max_retries(config.max_retries);
65+
66+
let retry_middleware =
67+
reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
68+
backoff_policy,
69+
RetryableStatus,
70+
);
71+
72+
builder.with(retry_middleware)
73+
} else {
74+
builder
75+
};
76+
builder
77+
};
78+
79+
let client = middleware_client_builder.build();
80+
81+
Self { config, client }
82+
}
83+
84+
pub fn with_client_and_config(
85+
config: datadog::Configuration,
86+
client: reqwest_middleware::ClientWithMiddleware,
87+
) -> Self {
88+
Self { config, client }
89+
}
90+
91+
/// List all Slack user bindings for a given Datadog user from the Datadog Slack integration.
92+
pub async fn list_slack_user_bindings(
93+
&self,
94+
user_uuid: uuid::Uuid,
95+
) -> Result<
96+
crate::datadogV2::model::SlackUserBindingsResponse,
97+
datadog::Error<ListSlackUserBindingsError>,
98+
> {
99+
match self
100+
.list_slack_user_bindings_with_http_info(user_uuid)
101+
.await
102+
{
103+
Ok(response_content) => {
104+
if let Some(e) = response_content.entity {
105+
Ok(e)
106+
} else {
107+
Err(datadog::Error::Serde(serde::de::Error::custom(
108+
"response content was None",
109+
)))
110+
}
111+
}
112+
Err(err) => Err(err),
113+
}
114+
}
115+
116+
/// List all Slack user bindings for a given Datadog user from the Datadog Slack integration.
117+
pub async fn list_slack_user_bindings_with_http_info(
118+
&self,
119+
user_uuid: uuid::Uuid,
120+
) -> Result<
121+
datadog::ResponseContent<crate::datadogV2::model::SlackUserBindingsResponse>,
122+
datadog::Error<ListSlackUserBindingsError>,
123+
> {
124+
let local_configuration = &self.config;
125+
let operation_id = "v2.list_slack_user_bindings";
126+
127+
let local_client = &self.client;
128+
129+
let local_uri_str = format!(
130+
"{}/api/v2/integration/slack/user-bindings",
131+
local_configuration.get_operation_host(operation_id)
132+
);
133+
let mut local_req_builder =
134+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
135+
136+
local_req_builder = local_req_builder.query(&[("user_uuid", &user_uuid.to_string())]);
137+
138+
// build headers
139+
let mut headers = HeaderMap::new();
140+
headers.insert("Accept", HeaderValue::from_static("application/json"));
141+
142+
// build user agent
143+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
144+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
145+
Err(e) => {
146+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
147+
headers.insert(
148+
reqwest::header::USER_AGENT,
149+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
150+
)
151+
}
152+
};
153+
154+
// build auth
155+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
156+
headers.insert(
157+
"DD-API-KEY",
158+
HeaderValue::from_str(local_key.key.as_str())
159+
.expect("failed to parse DD-API-KEY header"),
160+
);
161+
};
162+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
163+
headers.insert(
164+
"DD-APPLICATION-KEY",
165+
HeaderValue::from_str(local_key.key.as_str())
166+
.expect("failed to parse DD-APPLICATION-KEY header"),
167+
);
168+
};
169+
170+
local_req_builder = local_req_builder.headers(headers);
171+
let local_req = local_req_builder.build()?;
172+
log::debug!("request content: {:?}", local_req.body());
173+
let local_resp = local_client.execute(local_req).await?;
174+
175+
let local_status = local_resp.status();
176+
let local_content = local_resp.text().await?;
177+
log::debug!("response content: {}", local_content);
178+
179+
if !local_status.is_client_error() && !local_status.is_server_error() {
180+
match serde_json::from_str::<crate::datadogV2::model::SlackUserBindingsResponse>(
181+
&local_content,
182+
) {
183+
Ok(e) => {
184+
return Ok(datadog::ResponseContent {
185+
status: local_status,
186+
content: local_content,
187+
entity: Some(e),
188+
})
189+
}
190+
Err(e) => return Err(datadog::Error::Serde(e)),
191+
};
192+
} else {
193+
let local_entity: Option<ListSlackUserBindingsError> =
194+
serde_json::from_str(&local_content).ok();
195+
let local_error = datadog::ResponseContent {
196+
status: local_status,
197+
content: local_content,
198+
entity: local_entity,
199+
};
200+
Err(datadog::Error::ResponseError(local_error))
201+
}
202+
}
203+
}

src/datadogV2/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub mod api_service_accounts;
113113
pub mod api_service_definition;
114114
pub mod api_service_level_objectives;
115115
pub mod api_service_now_integration;
116+
pub mod api_slack_integration;
116117
pub mod api_software_catalog;
117118
pub mod api_spa;
118119
pub mod api_spans;

src/datadogV2/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ pub use self::api::api_service_accounts;
114114
pub use self::api::api_service_definition;
115115
pub use self::api::api_service_level_objectives;
116116
pub use self::api::api_service_now_integration;
117+
pub use self::api::api_slack_integration;
117118
pub use self::api::api_software_catalog;
118119
pub use self::api::api_spa;
119120
pub use self::api::api_spans;

src/datadogV2/model/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5144,6 +5144,12 @@ pub mod model_service_now_user_attributes;
51445144
pub use self::model_service_now_user_attributes::ServiceNowUserAttributes;
51455145
pub mod model_service_now_user_type;
51465146
pub use self::model_service_now_user_type::ServiceNowUserType;
5147+
pub mod model_slack_user_bindings_response;
5148+
pub use self::model_slack_user_bindings_response::SlackUserBindingsResponse;
5149+
pub mod model_slack_user_binding_data;
5150+
pub use self::model_slack_user_binding_data::SlackUserBindingData;
5151+
pub mod model_slack_user_binding_type;
5152+
pub use self::model_slack_user_binding_type::SlackUserBindingType;
51475153
pub mod model_statuspage_account_response;
51485154
pub use self::model_statuspage_account_response::StatuspageAccountResponse;
51495155
pub mod model_statuspage_account_response_data;

0 commit comments

Comments
 (0)