Skip to content

Commit af1b13b

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add DELETE user-binding endpoint to Microsoft Teams Integration spec (#1743)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent d2228ef commit af1b13b

6 files changed

Lines changed: 202 additions & 0 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,13 @@ components:
10121012
required: true
10131013
schema:
10141014
type: string
1015+
MicrosoftTeamsTenantIDPathParameter:
1016+
description: Your tenant id.
1017+
in: path
1018+
name: tenant_id
1019+
required: true
1020+
schema:
1021+
type: string
10151022
MicrosoftTeamsTenantIDQueryParameter:
10161023
description: Your tenant id.
10171024
in: query
@@ -134956,6 +134963,26 @@ paths:
134956134963
tags:
134957134964
- Microsoft Teams Integration
134958134965
x-codegen-request-body-name: body
134966+
/api/v2/integration/ms-teams/configuration/user-binding/{tenant_id}:
134967+
delete:
134968+
description: Delete the user binding for a given tenant from the Datadog Microsoft Teams integration.
134969+
operationId: DeleteMSTeamsUserBinding
134970+
parameters:
134971+
- $ref: "#/components/parameters/MicrosoftTeamsTenantIDPathParameter"
134972+
responses:
134973+
"204":
134974+
description: No Content
134975+
"400":
134976+
$ref: "#/components/responses/BadRequestResponse"
134977+
"403":
134978+
$ref: "#/components/responses/ForbiddenResponse"
134979+
"412":
134980+
$ref: "#/components/responses/PreconditionFailedResponse"
134981+
"429":
134982+
$ref: "#/components/responses/TooManyRequestsResponse"
134983+
summary: Delete user binding
134984+
tags:
134985+
- Microsoft Teams Integration
134959134986
/api/v2/integration/ms-teams/configuration/workflows-webhook-handles:
134960134987
get:
134961134988
description: Get a list of all Workflows webhook handles from the Datadog Microsoft Teams integration.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Delete user binding returns "No Content" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_microsoft_teams_integration::MicrosoftTeamsIntegrationAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let configuration = datadog::Configuration::new();
8+
let api = MicrosoftTeamsIntegrationAPI::with_config(configuration);
9+
let resp = api
10+
.delete_ms_teams_user_binding("tenant_id".to_string())
11+
.await;
12+
if let Ok(value) = resp {
13+
println!("{:#?}", value);
14+
} else {
15+
println!("{:#?}", resp.unwrap_err());
16+
}
17+
}

src/datadogV2/api/api_microsoft_teams_integration.rs

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ pub enum CreateWorkflowsWebhookHandleError {
6565
UnknownValue(serde_json::Value),
6666
}
6767

68+
/// DeleteMSTeamsUserBindingError is a struct for typed errors of method [`MicrosoftTeamsIntegrationAPI::delete_ms_teams_user_binding`]
69+
#[derive(Debug, Clone, Serialize, Deserialize)]
70+
#[serde(untagged)]
71+
pub enum DeleteMSTeamsUserBindingError {
72+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
73+
UnknownValue(serde_json::Value),
74+
}
75+
6876
/// DeleteTenantBasedHandleError is a struct for typed errors of method [`MicrosoftTeamsIntegrationAPI::delete_tenant_based_handle`]
6977
#[derive(Debug, Clone, Serialize, Deserialize)]
7078
#[serde(untagged)]
@@ -529,6 +537,97 @@ impl MicrosoftTeamsIntegrationAPI {
529537
}
530538
}
531539

540+
/// Delete the user binding for a given tenant from the Datadog Microsoft Teams integration.
541+
pub async fn delete_ms_teams_user_binding(
542+
&self,
543+
tenant_id: String,
544+
) -> Result<(), datadog::Error<DeleteMSTeamsUserBindingError>> {
545+
match self
546+
.delete_ms_teams_user_binding_with_http_info(tenant_id)
547+
.await
548+
{
549+
Ok(_) => Ok(()),
550+
Err(err) => Err(err),
551+
}
552+
}
553+
554+
/// Delete the user binding for a given tenant from the Datadog Microsoft Teams integration.
555+
pub async fn delete_ms_teams_user_binding_with_http_info(
556+
&self,
557+
tenant_id: String,
558+
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteMSTeamsUserBindingError>> {
559+
let local_configuration = &self.config;
560+
let operation_id = "v2.delete_ms_teams_user_binding";
561+
562+
let local_client = &self.client;
563+
564+
let local_uri_str = format!(
565+
"{}/api/v2/integration/ms-teams/configuration/user-binding/{tenant_id}",
566+
local_configuration.get_operation_host(operation_id),
567+
tenant_id = datadog::urlencode(tenant_id)
568+
);
569+
let mut local_req_builder =
570+
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
571+
572+
// build headers
573+
let mut headers = HeaderMap::new();
574+
headers.insert("Accept", HeaderValue::from_static("*/*"));
575+
576+
// build user agent
577+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
578+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
579+
Err(e) => {
580+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
581+
headers.insert(
582+
reqwest::header::USER_AGENT,
583+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
584+
)
585+
}
586+
};
587+
588+
// build auth
589+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
590+
headers.insert(
591+
"DD-API-KEY",
592+
HeaderValue::from_str(local_key.key.as_str())
593+
.expect("failed to parse DD-API-KEY header"),
594+
);
595+
};
596+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
597+
headers.insert(
598+
"DD-APPLICATION-KEY",
599+
HeaderValue::from_str(local_key.key.as_str())
600+
.expect("failed to parse DD-APPLICATION-KEY header"),
601+
);
602+
};
603+
604+
local_req_builder = local_req_builder.headers(headers);
605+
let local_req = local_req_builder.build()?;
606+
log::debug!("request content: {:?}", local_req.body());
607+
let local_resp = local_client.execute(local_req).await?;
608+
609+
let local_status = local_resp.status();
610+
let local_content = local_resp.text().await?;
611+
log::debug!("response content: {}", local_content);
612+
613+
if !local_status.is_client_error() && !local_status.is_server_error() {
614+
Ok(datadog::ResponseContent {
615+
status: local_status,
616+
content: local_content,
617+
entity: None,
618+
})
619+
} else {
620+
let local_entity: Option<DeleteMSTeamsUserBindingError> =
621+
serde_json::from_str(&local_content).ok();
622+
let local_error = datadog::ResponseContent {
623+
status: local_status,
624+
content: local_content,
625+
entity: local_entity,
626+
};
627+
Err(datadog::Error::ResponseError(local_error))
628+
}
629+
}
630+
532631
/// Delete a tenant-based handle from the Datadog Microsoft Teams integration.
533632
pub async fn delete_tenant_based_handle(
534633
&self,

tests/scenarios/features/v2/microsoft_teams_integration.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,27 @@ Feature: Microsoft Teams Integration
146146
When the request is sent
147147
Then the response status is 204 OK
148148

149+
@generated @skip @team:DataDog/chat-integrations
150+
Scenario: Delete user binding returns "Bad Request" response
151+
Given new "DeleteMSTeamsUserBinding" request
152+
And request contains "tenant_id" parameter from "REPLACE.ME"
153+
When the request is sent
154+
Then the response status is 400 Bad Request
155+
156+
@generated @skip @team:DataDog/chat-integrations
157+
Scenario: Delete user binding returns "Failed Precondition" response
158+
Given new "DeleteMSTeamsUserBinding" request
159+
And request contains "tenant_id" parameter from "REPLACE.ME"
160+
When the request is sent
161+
Then the response status is 412 Failed Precondition
162+
163+
@generated @skip @team:DataDog/chat-integrations
164+
Scenario: Delete user binding returns "No Content" response
165+
Given new "DeleteMSTeamsUserBinding" request
166+
And request contains "tenant_id" parameter from "REPLACE.ME"
167+
When the request is sent
168+
Then the response status is 204 No Content
169+
149170
@team:DataDog/chat-integrations
150171
Scenario: Delete workflow webhook handle returns "OK" response
151172
Given there is a valid "workflows_webhook_handle" in the system

tests/scenarios/features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,6 +3529,12 @@
35293529
"type": "idempotent"
35303530
}
35313531
},
3532+
"DeleteMSTeamsUserBinding": {
3533+
"tag": "Microsoft Teams Integration",
3534+
"undo": {
3535+
"type": "idempotent"
3536+
}
3537+
},
35323538
"ListWorkflowsWebhookHandles": {
35333539
"tag": "Microsoft Teams Integration",
35343540
"undo": {

tests/scenarios/function_mappings.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5017,6 +5017,10 @@ pub fn collect_function_calls(world: &mut DatadogWorld) {
50175017
"v2.UpdateTenantBasedHandle".into(),
50185018
test_v2_update_tenant_based_handle,
50195019
);
5020+
world.function_mappings.insert(
5021+
"v2.DeleteMSTeamsUserBinding".into(),
5022+
test_v2_delete_ms_teams_user_binding,
5023+
);
50205024
world.function_mappings.insert(
50215025
"v2.ListWorkflowsWebhookHandles".into(),
50225026
test_v2_list_workflows_webhook_handles,
@@ -38549,6 +38553,34 @@ fn test_v2_update_tenant_based_handle(
3854938553
world.response.code = response.status.as_u16();
3855038554
}
3855138555

38556+
fn test_v2_delete_ms_teams_user_binding(
38557+
world: &mut DatadogWorld,
38558+
_parameters: &HashMap<String, Value>,
38559+
) {
38560+
let api = world
38561+
.api_instances
38562+
.v2_api_microsoft_teams_integration
38563+
.as_ref()
38564+
.expect("api instance not found");
38565+
let tenant_id = serde_json::from_value(_parameters.get("tenant_id").unwrap().clone()).unwrap();
38566+
let response = match block_on(api.delete_ms_teams_user_binding_with_http_info(tenant_id)) {
38567+
Ok(response) => response,
38568+
Err(error) => {
38569+
return match error {
38570+
Error::ResponseError(e) => {
38571+
world.response.code = e.status.as_u16();
38572+
if let Some(entity) = e.entity {
38573+
world.response.object = serde_json::to_value(entity).unwrap();
38574+
}
38575+
}
38576+
_ => panic!("error parsing response: {error}"),
38577+
};
38578+
}
38579+
};
38580+
world.response.object = serde_json::to_value(response.entity).unwrap();
38581+
world.response.code = response.status.as_u16();
38582+
}
38583+
3855238584
fn test_v2_list_workflows_webhook_handles(
3855338585
world: &mut DatadogWorld,
3855438586
_parameters: &HashMap<String, Value>,

0 commit comments

Comments
 (0)