Skip to content

Commit c3493a3

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit b1982e5 of spec repo
1 parent bdbff03 commit c3493a3

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
@@ -86535,6 +86543,37 @@ components:
8653586543
required:
8653686544
- slackTrigger
8653786545
type: object
86546+
SlackUserBindingData:
86547+
description: Slack team ID data from a response.
86548+
properties:
86549+
id:
86550+
description: The Slack team ID.
86551+
example: "T01234567"
86552+
type: string
86553+
type:
86554+
$ref: "#/components/schemas/SlackUserBindingType"
86555+
type: object
86556+
SlackUserBindingType:
86557+
default: team_id
86558+
description: Slack user binding resource type.
86559+
enum:
86560+
- team_id
86561+
example: team_id
86562+
type: string
86563+
x-enum-varnames:
86564+
- TEAM_ID
86565+
SlackUserBindingsResponse:
86566+
description: Response with a list of Slack user bindings.
86567+
properties:
86568+
data:
86569+
description: An array of Slack user bindings.
86570+
example: [{"id": "T01234567", "type": "team_id"}, {"id": "T09876543", "type": "team_id"}]
86571+
items:
86572+
$ref: "#/components/schemas/SlackUserBindingData"
86573+
type: array
86574+
required:
86575+
- data
86576+
type: object
8653886577
SloDataSource:
8653986578
default: slo
8654086579
description: A data source for SLO queries.
@@ -132237,6 +132276,36 @@ paths:
132237132276
summary: List ServiceNow users
132238132277
tags:
132239132278
- ServiceNow Integration
132279+
/api/v2/integration/slack/user-bindings:
132280+
get:
132281+
description: List all Slack user bindings for a given Datadog user from the Datadog Slack integration.
132282+
operationId: ListSlackUserBindings
132283+
parameters:
132284+
- $ref: "#/components/parameters/SlackUserUuidQueryParameter"
132285+
responses:
132286+
"200":
132287+
content:
132288+
application/json:
132289+
examples:
132290+
default:
132291+
value:
132292+
data:
132293+
- id: T01234567
132294+
type: team_id
132295+
- id: T09876543
132296+
type: team_id
132297+
schema:
132298+
$ref: "#/components/schemas/SlackUserBindingsResponse"
132299+
description: OK
132300+
"400":
132301+
$ref: "#/components/responses/BadRequestResponse"
132302+
"403":
132303+
$ref: "#/components/responses/ForbiddenResponse"
132304+
"429":
132305+
$ref: "#/components/responses/TooManyRequestsResponse"
132306+
summary: List Slack user bindings
132307+
tags:
132308+
- Slack Integration
132240132309
/api/v2/integration/statuspage/account:
132241132310
delete:
132242132311
description: Delete the Statuspage account configured for your organization.
@@ -181539,6 +181608,13 @@ tags:
181539181608
name: Service Level Objectives
181540181609
- description: Manage your ServiceNow Integration. ServiceNow is a cloud-based platform that helps organizations manage digital workflows for enterprise operations.
181541181610
name: ServiceNow Integration
181611+
- description: |-
181612+
Configure your [Datadog Slack integration](https://docs.datadoghq.com/integrations/slack/)
181613+
directly through the Datadog API.
181614+
externalDocs:
181615+
description: For more information about the Datadog Slack integration, see the integration page.
181616+
url: https://docs.datadoghq.com/integrations/slack/
181617+
name: Slack Integration
181542181618
- description: |-
181543181619
API to create, update, retrieve, and delete Software Catalog entities.
181544181620
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
@@ -108,6 +108,7 @@ pub mod api_service_accounts;
108108
pub mod api_service_definition;
109109
pub mod api_service_level_objectives;
110110
pub mod api_service_now_integration;
111+
pub mod api_slack_integration;
111112
pub mod api_software_catalog;
112113
pub mod api_spa;
113114
pub mod api_spans;

src/datadogV2/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ pub use self::api::api_service_accounts;
109109
pub use self::api::api_service_definition;
110110
pub use self::api::api_service_level_objectives;
111111
pub use self::api::api_service_now_integration;
112+
pub use self::api::api_slack_integration;
112113
pub use self::api::api_software_catalog;
113114
pub use self::api::api_spa;
114115
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
@@ -4962,6 +4962,12 @@ pub mod model_service_now_user_attributes;
49624962
pub use self::model_service_now_user_attributes::ServiceNowUserAttributes;
49634963
pub mod model_service_now_user_type;
49644964
pub use self::model_service_now_user_type::ServiceNowUserType;
4965+
pub mod model_slack_user_bindings_response;
4966+
pub use self::model_slack_user_bindings_response::SlackUserBindingsResponse;
4967+
pub mod model_slack_user_binding_data;
4968+
pub use self::model_slack_user_binding_data::SlackUserBindingData;
4969+
pub mod model_slack_user_binding_type;
4970+
pub use self::model_slack_user_binding_type::SlackUserBindingType;
49654971
pub mod model_statuspage_account_response;
49664972
pub use self::model_statuspage_account_response::StatuspageAccountResponse;
49674973
pub mod model_statuspage_account_response_data;

0 commit comments

Comments
 (0)