From 44796e969c58646ea7ba9ea92ebfed51cb7ed2bd Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 12 Nov 2025 18:33:10 +0000 Subject: [PATCH] Regenerate client from commit 46eb50c of spec repo --- .generator/schemas/v2/openapi.yaml | 369 ++++++++++ ..._team-connections_CreateTeamConnections.rs | 48 ++ ..._team-connections_DeleteTeamConnections.rs | 23 + ...v2_team-connections_ListTeamConnections.rs | 19 + ...nections_ListTeamConnections_1473516764.rs | 23 + ...nections_ListTeamConnections_2418873869.rs | 23 + src/datadog/configuration.rs | 3 + src/datadogV2/api/api_team_connections.rs | 672 ++++++++++++++++++ src/datadogV2/api/mod.rs | 1 + src/datadogV2/mod.rs | 1 + src/datadogV2/model/mod.rs | 34 + .../model/model_connected_team_ref.rs | 105 +++ .../model/model_connected_team_ref_data.rs | 113 +++ .../model_connected_team_ref_data_type.rs | 48 ++ .../model_connections_page_pagination.rs | 230 ++++++ .../model/model_connections_response_meta.rs | 105 +++ src/datadogV2/model/model_team_connection.rs | 153 ++++ .../model/model_team_connection_attributes.rs | 122 ++++ .../model_team_connection_create_data.rs | 143 ++++ .../model_team_connection_create_request.rs | 94 +++ .../model_team_connection_delete_request.rs | 96 +++ ...eam_connection_delete_request_data_item.rs | 115 +++ .../model_team_connection_relationships.rs | 123 ++++ .../model/model_team_connection_type.rs | 48 ++ .../model/model_team_connections_response.rs | 122 ++++ src/datadogV2/model/model_team_ref.rs | 105 +++ src/datadogV2/model/model_team_ref_data.rs | 112 +++ .../model/model_team_ref_data_type.rs | 48 ++ tests/scenarios/features/v2/given.json | 7 + .../features/v2/team_connections.feature | 93 +++ tests/scenarios/features/v2/undo.json | 19 + tests/scenarios/function_mappings.rs | 185 +++++ 32 files changed, 3402 insertions(+) create mode 100644 examples/v2_team-connections_CreateTeamConnections.rs create mode 100644 examples/v2_team-connections_DeleteTeamConnections.rs create mode 100644 examples/v2_team-connections_ListTeamConnections.rs create mode 100644 examples/v2_team-connections_ListTeamConnections_1473516764.rs create mode 100644 examples/v2_team-connections_ListTeamConnections_2418873869.rs create mode 100644 src/datadogV2/api/api_team_connections.rs create mode 100644 src/datadogV2/model/model_connected_team_ref.rs create mode 100644 src/datadogV2/model/model_connected_team_ref_data.rs create mode 100644 src/datadogV2/model/model_connected_team_ref_data_type.rs create mode 100644 src/datadogV2/model/model_connections_page_pagination.rs create mode 100644 src/datadogV2/model/model_connections_response_meta.rs create mode 100644 src/datadogV2/model/model_team_connection.rs create mode 100644 src/datadogV2/model/model_team_connection_attributes.rs create mode 100644 src/datadogV2/model/model_team_connection_create_data.rs create mode 100644 src/datadogV2/model/model_team_connection_create_request.rs create mode 100644 src/datadogV2/model/model_team_connection_delete_request.rs create mode 100644 src/datadogV2/model/model_team_connection_delete_request_data_item.rs create mode 100644 src/datadogV2/model/model_team_connection_relationships.rs create mode 100644 src/datadogV2/model/model_team_connection_type.rs create mode 100644 src/datadogV2/model/model_team_connections_response.rs create mode 100644 src/datadogV2/model/model_team_ref.rs create mode 100644 src/datadogV2/model/model_team_ref_data.rs create mode 100644 src/datadogV2/model/model_team_ref_data_type.rs create mode 100644 tests/scenarios/features/v2/team_connections.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 922424a28..cb64b3bf5 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -11515,6 +11515,35 @@ components: $ref: '#/components/schemas/ConfluentResourceResponseData' type: array type: object + ConnectedTeamRef: + description: Reference to a team from an external system. + properties: + data: + $ref: '#/components/schemas/ConnectedTeamRefData' + type: object + ConnectedTeamRefData: + description: Reference to connected external team. + properties: + id: + description: The connected team ID as it is referenced throughout the Datadog + ecosystem. + example: '@GitHubOrg/team-handle' + type: string + type: + $ref: '#/components/schemas/ConnectedTeamRefDataType' + required: + - id + - type + type: object + ConnectedTeamRefDataType: + default: github_team + description: External team resource type. + enum: + - github_team + example: github_team + type: string + x-enum-varnames: + - GITHUB_TEAM Connection: description: The definition of `Connection` object. properties: @@ -11579,6 +11608,50 @@ components: - label - tags type: object + ConnectionsPagePagination: + description: Page-based pagination metadata. + properties: + first_number: + description: The first page number. + format: int64 + type: integer + last_number: + description: The last page number. + format: int64 + type: integer + next_number: + description: The next page number. + format: int64 + nullable: true + type: integer + number: + description: The current page number. + format: int64 + type: integer + prev_number: + description: The previous page number. + format: int64 + nullable: true + type: integer + size: + description: The page size. + format: int64 + type: integer + total: + description: Total connections matching request. + format: int64 + type: integer + type: + description: Pagination type. + example: number_size + type: string + type: object + ConnectionsResponseMeta: + description: Connections response metadata. + properties: + page: + $ref: '#/components/schemas/ConnectionsPagePagination' + type: object Container: description: Container object. properties: @@ -51345,6 +51418,111 @@ components: - handle - name type: object + TeamConnection: + description: A relationship between a Datadog team and a team from another external + system. + properties: + attributes: + $ref: '#/components/schemas/TeamConnectionAttributes' + id: + description: The unique identifier of the team connection. + example: 12345678-1234-5678-9abc-123456789012 + type: string + relationships: + $ref: '#/components/schemas/TeamConnectionRelationships' + type: + $ref: '#/components/schemas/TeamConnectionType' + required: + - id + - type + type: object + TeamConnectionAttributes: + description: Attributes of the team connection. + properties: + managed_by: + description: The entity that manages this team connection. + example: github_sync + type: string + source: + description: The name of the external source. + example: github + type: string + type: object + TeamConnectionCreateData: + description: Data for creating a team connection. + properties: + attributes: + $ref: '#/components/schemas/TeamConnectionAttributes' + relationships: + $ref: '#/components/schemas/TeamConnectionRelationships' + type: + $ref: '#/components/schemas/TeamConnectionType' + required: + - type + type: object + TeamConnectionCreateRequest: + description: Request for creating team connections. + properties: + data: + description: Array of team connections to create. + items: + $ref: '#/components/schemas/TeamConnectionCreateData' + type: array + required: + - data + type: object + TeamConnectionDeleteRequest: + description: Request for deleting team connections. + properties: + data: + description: Array of team connection IDs to delete. + items: + $ref: '#/components/schemas/TeamConnectionDeleteRequestDataItem' + type: array + required: + - data + type: object + TeamConnectionDeleteRequestDataItem: + description: A collection of connection ids to delete. + properties: + id: + description: The unique identifier of the team connection to delete. + example: 12345678-1234-5678-9abc-123456789012 + type: string + type: + $ref: '#/components/schemas/TeamConnectionType' + required: + - id + - type + type: object + TeamConnectionRelationships: + description: Relationships of the team connection. + properties: + connected_team: + $ref: '#/components/schemas/ConnectedTeamRef' + team: + $ref: '#/components/schemas/TeamRef' + type: object + TeamConnectionType: + default: team_connection + description: Team connection resource type. + enum: + - team_connection + example: team_connection + type: string + x-enum-varnames: + - TEAM_CONNECTION + TeamConnectionsResponse: + description: Response containing information about multiple team connections. + properties: + data: + description: Array of team connections. + items: + $ref: '#/components/schemas/TeamConnection' + type: array + meta: + $ref: '#/components/schemas/ConnectionsResponseMeta' + type: object TeamCreate: description: Team create properties: @@ -51762,6 +51940,34 @@ components: $ref: '#/components/schemas/TeamPermissionSetting' type: array type: object + TeamRef: + description: Reference to a Datadog team. + properties: + data: + $ref: '#/components/schemas/TeamRefData' + type: object + TeamRefData: + description: Reference to a Datadog team. + properties: + id: + description: The Datadog team ID. + example: 87654321-4321-8765-dcba-210987654321 + type: string + type: + $ref: '#/components/schemas/TeamRefDataType' + required: + - id + - type + type: object + TeamRefDataType: + default: team + description: Datadog team resource type. + enum: + - team + example: team + type: string + x-enum-varnames: + - TEAM TeamReference: description: Provides a reference to a team, including ID, type, and basic attributes/relationships. properties: @@ -80787,6 +80993,166 @@ paths: permissions: - teams_read - teams_manage + /api/v2/team/connections: + delete: + description: Delete multiple team connections. + operationId: DeleteTeamConnections + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TeamConnectionDeleteRequest' + required: true + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: Delete team connections + tags: + - Team Connections + x-permission: + operator: OR + permissions: + - teams_read + x-unstable: '**Note**: This endpoint is in Preview. To request access, fill + out this [form](https://www.datadoghq.com/product-preview/github-integration-for-teams/). + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Returns all team connections. + operationId: ListTeamConnections + parameters: + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/PageNumber' + - description: Filter team connections by external source systems. + explode: false + in: query + name: filter[sources] + required: false + schema: + items: + example: github + type: string + type: array + style: form + - description: Filter team connections by Datadog team IDs. + explode: false + in: query + name: filter[team_ids] + required: false + schema: + items: + example: 12345678-1234-5678-9abc-123456789012 + type: string + type: array + style: form + - description: Filter team connections by connected team IDs from external systems. + explode: false + in: query + name: filter[connected_team_ids] + required: false + schema: + items: + example: '@MyGitHubAccount/my-team-name' + type: string + type: array + style: form + - description: Filter team connections by connection IDs. + explode: false + in: query + name: filter[connection_ids] + required: false + schema: + items: + example: 12345678-1234-5678-9abc-123456789012 + type: string + type: array + style: form + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamConnectionsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: List team connections + tags: + - Team Connections + x-pagination: + limitParam: page[size] + pageParam: page[number] + resultsPath: data + x-permission: + operator: OR + permissions: + - teams_read + x-unstable: '**Note**: This endpoint is in Preview. To request access, fill + out this [form](https://www.datadoghq.com/product-preview/github-integration-for-teams/). + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create multiple team connections. + operationId: CreateTeamConnections + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TeamConnectionCreateRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamConnectionsResponse' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: Create team connections + tags: + - Team Connections + x-permission: + operator: OR + permissions: + - teams_read + x-unstable: '**Note**: This endpoint is in Preview. To request access, fill + out this [form](https://www.datadoghq.com/product-preview/github-integration-for-teams/). + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/team/sync: post: description: 'This endpoint attempts to link your existing Datadog teams with @@ -83992,6 +84358,9 @@ tags: use Datadog\u2019s API to\nmanage both test types programmatically.\n\nFor more information about Synthetics, see the [Synthetics overview](https://docs.datadoghq.com/synthetics/)." name: Synthetics +- description: View and manage relationships between Datadog teams and teams from + external sources, such as GitHub. + name: Team Connections - description: View and manage teams within Datadog. See the [Teams page](https://docs.datadoghq.com/account_management/teams/) for more information. name: Teams diff --git a/examples/v2_team-connections_CreateTeamConnections.rs b/examples/v2_team-connections_CreateTeamConnections.rs new file mode 100644 index 000000000..48ded5f69 --- /dev/null +++ b/examples/v2_team-connections_CreateTeamConnections.rs @@ -0,0 +1,48 @@ +// Create team connections returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_team_connections::TeamConnectionsAPI; +use datadog_api_client::datadogV2::model::ConnectedTeamRef; +use datadog_api_client::datadogV2::model::ConnectedTeamRefData; +use datadog_api_client::datadogV2::model::ConnectedTeamRefDataType; +use datadog_api_client::datadogV2::model::TeamConnectionAttributes; +use datadog_api_client::datadogV2::model::TeamConnectionCreateData; +use datadog_api_client::datadogV2::model::TeamConnectionCreateRequest; +use datadog_api_client::datadogV2::model::TeamConnectionRelationships; +use datadog_api_client::datadogV2::model::TeamConnectionType; +use datadog_api_client::datadogV2::model::TeamRef; +use datadog_api_client::datadogV2::model::TeamRefData; +use datadog_api_client::datadogV2::model::TeamRefDataType; + +#[tokio::main] +async fn main() { + // there is a valid "dd_team" in the system + let dd_team_data_id = std::env::var("DD_TEAM_DATA_ID").unwrap(); + let body = TeamConnectionCreateRequest::new(vec![TeamConnectionCreateData::new( + TeamConnectionType::TEAM_CONNECTION, + ) + .attributes( + TeamConnectionAttributes::new() + .managed_by("datadog".to_string()) + .source("github".to_string()), + ) + .relationships( + TeamConnectionRelationships::new() + .connected_team(ConnectedTeamRef::new().data(ConnectedTeamRefData::new( + "@MyGitHubAccount/my-team-name".to_string(), + ConnectedTeamRefDataType::GITHUB_TEAM, + ))) + .team(TeamRef::new().data(TeamRefData::new( + dd_team_data_id.clone(), + TeamRefDataType::TEAM, + ))), + )]); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateTeamConnections", true); + let api = TeamConnectionsAPI::with_config(configuration); + let resp = api.create_team_connections(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_team-connections_DeleteTeamConnections.rs b/examples/v2_team-connections_DeleteTeamConnections.rs new file mode 100644 index 000000000..3501fff29 --- /dev/null +++ b/examples/v2_team-connections_DeleteTeamConnections.rs @@ -0,0 +1,23 @@ +// Delete team connections returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_team_connections::TeamConnectionsAPI; +use datadog_api_client::datadogV2::model::TeamConnectionDeleteRequest; +use datadog_api_client::datadogV2::model::TeamConnectionDeleteRequestDataItem; +use datadog_api_client::datadogV2::model::TeamConnectionType; + +#[tokio::main] +async fn main() { + let body = TeamConnectionDeleteRequest::new(vec![TeamConnectionDeleteRequestDataItem::new( + "12345678-1234-5678-9abc-123456789012".to_string(), + TeamConnectionType::TEAM_CONNECTION, + )]); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteTeamConnections", true); + let api = TeamConnectionsAPI::with_config(configuration); + let resp = api.delete_team_connections(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_team-connections_ListTeamConnections.rs b/examples/v2_team-connections_ListTeamConnections.rs new file mode 100644 index 000000000..612f87f27 --- /dev/null +++ b/examples/v2_team-connections_ListTeamConnections.rs @@ -0,0 +1,19 @@ +// List team connections returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_team_connections::ListTeamConnectionsOptionalParams; +use datadog_api_client::datadogV2::api_team_connections::TeamConnectionsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListTeamConnections", true); + let api = TeamConnectionsAPI::with_config(configuration); + let resp = api + .list_team_connections(ListTeamConnectionsOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_team-connections_ListTeamConnections_1473516764.rs b/examples/v2_team-connections_ListTeamConnections_1473516764.rs new file mode 100644 index 000000000..b8702075a --- /dev/null +++ b/examples/v2_team-connections_ListTeamConnections_1473516764.rs @@ -0,0 +1,23 @@ +// List team connections with filters returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_team_connections::ListTeamConnectionsOptionalParams; +use datadog_api_client::datadogV2::api_team_connections::TeamConnectionsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListTeamConnections", true); + let api = TeamConnectionsAPI::with_config(configuration); + let resp = api + .list_team_connections( + ListTeamConnectionsOptionalParams::default() + .filter_sources(vec!["github".to_string()]) + .page_size(10), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_team-connections_ListTeamConnections_2418873869.rs b/examples/v2_team-connections_ListTeamConnections_2418873869.rs new file mode 100644 index 000000000..09f385143 --- /dev/null +++ b/examples/v2_team-connections_ListTeamConnections_2418873869.rs @@ -0,0 +1,23 @@ +// List team connections returns "OK" response with pagination +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_team_connections::ListTeamConnectionsOptionalParams; +use datadog_api_client::datadogV2::api_team_connections::TeamConnectionsAPI; +use futures_util::pin_mut; +use futures_util::stream::StreamExt; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListTeamConnections", true); + let api = TeamConnectionsAPI::with_config(configuration); + let response = + api.list_team_connections_with_pagination(ListTeamConnectionsOptionalParams::default()); + pin_mut!(response); + while let Some(resp) = response.next().await { + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } + } +} diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index d9bcdc3d1..47202ecab 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -259,6 +259,9 @@ impl Default for Configuration { ("v2.list_member_teams".to_owned(), false), ("v2.remove_member_team".to_owned(), false), ("v2.sync_teams".to_owned(), false), + ("v2.create_team_connections".to_owned(), false), + ("v2.delete_team_connections".to_owned(), false), + ("v2.list_team_connections".to_owned(), false), ("v2.create_incident_team".to_owned(), false), ("v2.delete_incident_team".to_owned(), false), ("v2.get_incident_team".to_owned(), false), diff --git a/src/datadogV2/api/api_team_connections.rs b/src/datadogV2/api/api_team_connections.rs new file mode 100644 index 000000000..1e4813db4 --- /dev/null +++ b/src/datadogV2/api/api_team_connections.rs @@ -0,0 +1,672 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use crate::datadog; +use async_stream::try_stream; +use flate2::{ + write::{GzEncoder, ZlibEncoder}, + Compression, +}; +use futures_core::stream::Stream; +use log::warn; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// ListTeamConnectionsOptionalParams is a struct for passing parameters to the method [`TeamConnectionsAPI::list_team_connections`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListTeamConnectionsOptionalParams { + /// Size for a given page. The maximum allowed value is 100. + pub page_size: Option, + /// Specific page number to return. + pub page_number: Option, + /// Filter team connections by external source systems. + pub filter_sources: Option>, + /// Filter team connections by Datadog team IDs. + pub filter_team_ids: Option>, + /// Filter team connections by connected team IDs from external systems. + pub filter_connected_team_ids: Option>, + /// Filter team connections by connection IDs. + pub filter_connection_ids: Option>, +} + +impl ListTeamConnectionsOptionalParams { + /// Size for a given page. The maximum allowed value is 100. + pub fn page_size(mut self, value: i64) -> Self { + self.page_size = Some(value); + self + } + /// Specific page number to return. + pub fn page_number(mut self, value: i64) -> Self { + self.page_number = Some(value); + self + } + /// Filter team connections by external source systems. + pub fn filter_sources(mut self, value: Vec) -> Self { + self.filter_sources = Some(value); + self + } + /// Filter team connections by Datadog team IDs. + pub fn filter_team_ids(mut self, value: Vec) -> Self { + self.filter_team_ids = Some(value); + self + } + /// Filter team connections by connected team IDs from external systems. + pub fn filter_connected_team_ids(mut self, value: Vec) -> Self { + self.filter_connected_team_ids = Some(value); + self + } + /// Filter team connections by connection IDs. + pub fn filter_connection_ids(mut self, value: Vec) -> Self { + self.filter_connection_ids = Some(value); + self + } +} + +/// CreateTeamConnectionsError is a struct for typed errors of method [`TeamConnectionsAPI::create_team_connections`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateTeamConnectionsError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteTeamConnectionsError is a struct for typed errors of method [`TeamConnectionsAPI::delete_team_connections`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteTeamConnectionsError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListTeamConnectionsError is a struct for typed errors of method [`TeamConnectionsAPI::list_team_connections`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListTeamConnectionsError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// View and manage relationships between Datadog teams and teams from external sources, such as GitHub. +#[derive(Debug, Clone)] +pub struct TeamConnectionsAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for TeamConnectionsAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl TeamConnectionsAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let mut reqwest_client_builder = reqwest::Client::builder(); + + if let Some(proxy_url) = &config.proxy_url { + let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL"); + reqwest_client_builder = reqwest_client_builder.proxy(proxy); + } + + let mut middleware_client_builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + + if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + middleware_client_builder = middleware_client_builder.with(retry_middleware); + } + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + /// Create multiple team connections. + pub async fn create_team_connections( + &self, + body: crate::datadogV2::model::TeamConnectionCreateRequest, + ) -> Result< + crate::datadogV2::model::TeamConnectionsResponse, + datadog::Error, + > { + match self.create_team_connections_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create multiple team connections. + pub async fn create_team_connections_with_http_info( + &self, + body: crate::datadogV2::model::TeamConnectionCreateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_team_connections"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_team_connections' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team/connections", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Delete multiple team connections. + pub async fn delete_team_connections( + &self, + body: crate::datadogV2::model::TeamConnectionDeleteRequest, + ) -> Result<(), datadog::Error> { + match self.delete_team_connections_with_http_info(body).await { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete multiple team connections. + pub async fn delete_team_connections_with_http_info( + &self, + body: crate::datadogV2::model::TeamConnectionDeleteRequest, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_team_connections"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_team_connections' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team/connections", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Returns all team connections. + pub async fn list_team_connections( + &self, + params: ListTeamConnectionsOptionalParams, + ) -> Result< + crate::datadogV2::model::TeamConnectionsResponse, + datadog::Error, + > { + match self.list_team_connections_with_http_info(params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub fn list_team_connections_with_pagination( + &self, + mut params: ListTeamConnectionsOptionalParams, + ) -> impl Stream< + Item = Result< + crate::datadogV2::model::TeamConnection, + datadog::Error, + >, + > + '_ { + try_stream! { + let mut page_size: i64 = 10; + if params.page_size.is_none() { + params.page_size = Some(page_size); + } else { + page_size = params.page_size.unwrap().clone(); + } + if params.page_number.is_none() { + params.page_number = Some(0); + } + loop { + let resp = self.list_team_connections(params.clone()).await?; + let Some(data) = resp.data else { break }; + + let r = data; + let count = r.len(); + for team in r { + yield team; + } + + if count < page_size as usize { + break; + } + params.page_number = Some(params.page_number.unwrap() + 1); + } + } + } + + /// Returns all team connections. + pub async fn list_team_connections_with_http_info( + &self, + params: ListTeamConnectionsOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_team_connections"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_team_connections' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let page_size = params.page_size; + let page_number = params.page_number; + let filter_sources = params.filter_sources; + let filter_team_ids = params.filter_team_ids; + let filter_connected_team_ids = params.filter_connected_team_ids; + let filter_connection_ids = params.filter_connection_ids; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team/connections", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_size { + local_req_builder = + local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_number { + local_req_builder = + local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); + }; + if let Some(ref local) = filter_sources { + local_req_builder = local_req_builder.query(&[( + "filter[sources]", + &local + .iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]); + }; + if let Some(ref local) = filter_team_ids { + local_req_builder = local_req_builder.query(&[( + "filter[team_ids]", + &local + .iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]); + }; + if let Some(ref local) = filter_connected_team_ids { + local_req_builder = local_req_builder.query(&[( + "filter[connected_team_ids]", + &local + .iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]); + }; + if let Some(ref local) = filter_connection_ids { + local_req_builder = local_req_builder.query(&[( + "filter[connection_ids]", + &local + .iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index 4b5c3f8a1..9f04d6ed6 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -79,6 +79,7 @@ pub mod api_spans; pub mod api_spans_metrics; pub mod api_static_analysis; pub mod api_synthetics; +pub mod api_team_connections; pub mod api_teams; pub mod api_test_optimization; pub mod api_usage_metering; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index 3ffbd102c..4a2411941 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -80,6 +80,7 @@ pub use self::api::api_spans; pub use self::api::api_spans_metrics; pub use self::api::api_static_analysis; pub use self::api::api_synthetics; +pub use self::api::api_team_connections; pub use self::api::api_teams; pub use self::api::api_test_optimization; pub use self::api::api_usage_metering; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 89c1e2523..b6c7891bb 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -6596,6 +6596,40 @@ pub mod model_team_create_relationships; pub use self::model_team_create_relationships::TeamCreateRelationships; pub mod model_team_response; pub use self::model_team_response::TeamResponse; +pub mod model_team_connection_delete_request; +pub use self::model_team_connection_delete_request::TeamConnectionDeleteRequest; +pub mod model_team_connection_delete_request_data_item; +pub use self::model_team_connection_delete_request_data_item::TeamConnectionDeleteRequestDataItem; +pub mod model_team_connection_type; +pub use self::model_team_connection_type::TeamConnectionType; +pub mod model_team_connections_response; +pub use self::model_team_connections_response::TeamConnectionsResponse; +pub mod model_team_connection; +pub use self::model_team_connection::TeamConnection; +pub mod model_team_connection_attributes; +pub use self::model_team_connection_attributes::TeamConnectionAttributes; +pub mod model_team_connection_relationships; +pub use self::model_team_connection_relationships::TeamConnectionRelationships; +pub mod model_connected_team_ref; +pub use self::model_connected_team_ref::ConnectedTeamRef; +pub mod model_connected_team_ref_data; +pub use self::model_connected_team_ref_data::ConnectedTeamRefData; +pub mod model_connected_team_ref_data_type; +pub use self::model_connected_team_ref_data_type::ConnectedTeamRefDataType; +pub mod model_team_ref; +pub use self::model_team_ref::TeamRef; +pub mod model_team_ref_data; +pub use self::model_team_ref_data::TeamRefData; +pub mod model_team_ref_data_type; +pub use self::model_team_ref_data_type::TeamRefDataType; +pub mod model_connections_response_meta; +pub use self::model_connections_response_meta::ConnectionsResponseMeta; +pub mod model_connections_page_pagination; +pub use self::model_connections_page_pagination::ConnectionsPagePagination; +pub mod model_team_connection_create_request; +pub use self::model_team_connection_create_request::TeamConnectionCreateRequest; +pub mod model_team_connection_create_data; +pub use self::model_team_connection_create_data::TeamConnectionCreateData; pub mod model_team_sync_request; pub use self::model_team_sync_request::TeamSyncRequest; pub mod model_team_sync_data; diff --git a/src/datadogV2/model/model_connected_team_ref.rs b/src/datadogV2/model/model_connected_team_ref.rs new file mode 100644 index 000000000..9e78fbe38 --- /dev/null +++ b/src/datadogV2/model/model_connected_team_ref.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Reference to a team from an external system. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ConnectedTeamRef { + /// Reference to connected external team. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ConnectedTeamRef { + pub fn new() -> ConnectedTeamRef { + ConnectedTeamRef { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::ConnectedTeamRefData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ConnectedTeamRef { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ConnectedTeamRef { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ConnectedTeamRefVisitor; + impl<'a> Visitor<'a> for ConnectedTeamRefVisitor { + type Value = ConnectedTeamRef; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ConnectedTeamRef { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ConnectedTeamRefVisitor) + } +} diff --git a/src/datadogV2/model/model_connected_team_ref_data.rs b/src/datadogV2/model/model_connected_team_ref_data.rs new file mode 100644 index 000000000..633990e21 --- /dev/null +++ b/src/datadogV2/model/model_connected_team_ref_data.rs @@ -0,0 +1,113 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Reference to connected external team. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ConnectedTeamRefData { + /// The connected team ID as it is referenced throughout the Datadog ecosystem. + #[serde(rename = "id")] + pub id: String, + /// External team resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ConnectedTeamRefDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ConnectedTeamRefData { + pub fn new( + id: String, + type_: crate::datadogV2::model::ConnectedTeamRefDataType, + ) -> ConnectedTeamRefData { + ConnectedTeamRefData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ConnectedTeamRefData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ConnectedTeamRefDataVisitor; + impl<'a> Visitor<'a> for ConnectedTeamRefDataVisitor { + type Value = ConnectedTeamRefData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ConnectedTeamRefDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ConnectedTeamRefData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ConnectedTeamRefDataVisitor) + } +} diff --git a/src/datadogV2/model/model_connected_team_ref_data_type.rs b/src/datadogV2/model/model_connected_team_ref_data_type.rs new file mode 100644 index 000000000..353ef7d77 --- /dev/null +++ b/src/datadogV2/model/model_connected_team_ref_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ConnectedTeamRefDataType { + GITHUB_TEAM, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ConnectedTeamRefDataType { + fn to_string(&self) -> String { + match self { + Self::GITHUB_TEAM => String::from("github_team"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ConnectedTeamRefDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ConnectedTeamRefDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "github_team" => Self::GITHUB_TEAM, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_connections_page_pagination.rs b/src/datadogV2/model/model_connections_page_pagination.rs new file mode 100644 index 000000000..9b9f48156 --- /dev/null +++ b/src/datadogV2/model/model_connections_page_pagination.rs @@ -0,0 +1,230 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Page-based pagination metadata. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ConnectionsPagePagination { + /// The first page number. + #[serde(rename = "first_number")] + pub first_number: Option, + /// The last page number. + #[serde(rename = "last_number")] + pub last_number: Option, + /// The next page number. + #[serde( + rename = "next_number", + default, + with = "::serde_with::rust::double_option" + )] + pub next_number: Option>, + /// The current page number. + #[serde(rename = "number")] + pub number: Option, + /// The previous page number. + #[serde( + rename = "prev_number", + default, + with = "::serde_with::rust::double_option" + )] + pub prev_number: Option>, + /// The page size. + #[serde(rename = "size")] + pub size: Option, + /// Total connections matching request. + #[serde(rename = "total")] + pub total: Option, + /// Pagination type. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ConnectionsPagePagination { + pub fn new() -> ConnectionsPagePagination { + ConnectionsPagePagination { + first_number: None, + last_number: None, + next_number: None, + number: None, + prev_number: None, + size: None, + total: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn first_number(mut self, value: i64) -> Self { + self.first_number = Some(value); + self + } + + pub fn last_number(mut self, value: i64) -> Self { + self.last_number = Some(value); + self + } + + pub fn next_number(mut self, value: Option) -> Self { + self.next_number = Some(value); + self + } + + pub fn number(mut self, value: i64) -> Self { + self.number = Some(value); + self + } + + pub fn prev_number(mut self, value: Option) -> Self { + self.prev_number = Some(value); + self + } + + pub fn size(mut self, value: i64) -> Self { + self.size = Some(value); + self + } + + pub fn total(mut self, value: i64) -> Self { + self.total = Some(value); + self + } + + pub fn type_(mut self, value: String) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ConnectionsPagePagination { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ConnectionsPagePagination { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ConnectionsPagePaginationVisitor; + impl<'a> Visitor<'a> for ConnectionsPagePaginationVisitor { + type Value = ConnectionsPagePagination; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut first_number: Option = None; + let mut last_number: Option = None; + let mut next_number: Option> = None; + let mut number: Option = None; + let mut prev_number: Option> = None; + let mut size: Option = None; + let mut total: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "first_number" => { + if v.is_null() { + continue; + } + first_number = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last_number" => { + if v.is_null() { + continue; + } + last_number = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "next_number" => { + next_number = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "number" => { + if v.is_null() { + continue; + } + number = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "prev_number" => { + prev_number = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "size" => { + if v.is_null() { + continue; + } + size = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total" => { + if v.is_null() { + continue; + } + total = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ConnectionsPagePagination { + first_number, + last_number, + next_number, + number, + prev_number, + size, + total, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ConnectionsPagePaginationVisitor) + } +} diff --git a/src/datadogV2/model/model_connections_response_meta.rs b/src/datadogV2/model/model_connections_response_meta.rs new file mode 100644 index 000000000..bc4a1b56e --- /dev/null +++ b/src/datadogV2/model/model_connections_response_meta.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Connections response metadata. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ConnectionsResponseMeta { + /// Page-based pagination metadata. + #[serde(rename = "page")] + pub page: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ConnectionsResponseMeta { + pub fn new() -> ConnectionsResponseMeta { + ConnectionsResponseMeta { + page: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn page(mut self, value: crate::datadogV2::model::ConnectionsPagePagination) -> Self { + self.page = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ConnectionsResponseMeta { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ConnectionsResponseMeta { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ConnectionsResponseMetaVisitor; + impl<'a> Visitor<'a> for ConnectionsResponseMetaVisitor { + type Value = ConnectionsResponseMeta; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut page: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "page" => { + if v.is_null() { + continue; + } + page = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ConnectionsResponseMeta { + page, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ConnectionsResponseMetaVisitor) + } +} diff --git a/src/datadogV2/model/model_team_connection.rs b/src/datadogV2/model/model_team_connection.rs new file mode 100644 index 000000000..44ce91bfb --- /dev/null +++ b/src/datadogV2/model/model_team_connection.rs @@ -0,0 +1,153 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A relationship between a Datadog team and a team from another external system. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamConnection { + /// Attributes of the team connection. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The unique identifier of the team connection. + #[serde(rename = "id")] + pub id: String, + /// Relationships of the team connection. + #[serde(rename = "relationships")] + pub relationships: Option, + /// Team connection resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamConnectionType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamConnection { + pub fn new(id: String, type_: crate::datadogV2::model::TeamConnectionType) -> TeamConnection { + TeamConnection { + attributes: None, + id, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes(mut self, value: crate::datadogV2::model::TeamConnectionAttributes) -> Self { + self.attributes = Some(value); + self + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::TeamConnectionRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamConnection { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamConnectionVisitor; + impl<'a> Visitor<'a> for TeamConnectionVisitor { + type Value = TeamConnection; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::TeamConnectionRelationships, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamConnectionType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamConnection { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamConnectionVisitor) + } +} diff --git a/src/datadogV2/model/model_team_connection_attributes.rs b/src/datadogV2/model/model_team_connection_attributes.rs new file mode 100644 index 000000000..64ba24b04 --- /dev/null +++ b/src/datadogV2/model/model_team_connection_attributes.rs @@ -0,0 +1,122 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the team connection. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamConnectionAttributes { + /// The entity that manages this team connection. + #[serde(rename = "managed_by")] + pub managed_by: Option, + /// The name of the external source. + #[serde(rename = "source")] + pub source: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamConnectionAttributes { + pub fn new() -> TeamConnectionAttributes { + TeamConnectionAttributes { + managed_by: None, + source: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn managed_by(mut self, value: String) -> Self { + self.managed_by = Some(value); + self + } + + pub fn source(mut self, value: String) -> Self { + self.source = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamConnectionAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamConnectionAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamConnectionAttributesVisitor; + impl<'a> Visitor<'a> for TeamConnectionAttributesVisitor { + type Value = TeamConnectionAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut managed_by: Option = None; + let mut source: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "managed_by" => { + if v.is_null() { + continue; + } + managed_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "source" => { + if v.is_null() { + continue; + } + source = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamConnectionAttributes { + managed_by, + source, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamConnectionAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_team_connection_create_data.rs b/src/datadogV2/model/model_team_connection_create_data.rs new file mode 100644 index 000000000..78d0974e1 --- /dev/null +++ b/src/datadogV2/model/model_team_connection_create_data.rs @@ -0,0 +1,143 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data for creating a team connection. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamConnectionCreateData { + /// Attributes of the team connection. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Relationships of the team connection. + #[serde(rename = "relationships")] + pub relationships: Option, + /// Team connection resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamConnectionType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamConnectionCreateData { + pub fn new(type_: crate::datadogV2::model::TeamConnectionType) -> TeamConnectionCreateData { + TeamConnectionCreateData { + attributes: None, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes(mut self, value: crate::datadogV2::model::TeamConnectionAttributes) -> Self { + self.attributes = Some(value); + self + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::TeamConnectionRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamConnectionCreateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamConnectionCreateDataVisitor; + impl<'a> Visitor<'a> for TeamConnectionCreateDataVisitor { + type Value = TeamConnectionCreateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut relationships: Option< + crate::datadogV2::model::TeamConnectionRelationships, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamConnectionType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamConnectionCreateData { + attributes, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamConnectionCreateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_team_connection_create_request.rs b/src/datadogV2/model/model_team_connection_create_request.rs new file mode 100644 index 000000000..f76a04fdc --- /dev/null +++ b/src/datadogV2/model/model_team_connection_create_request.rs @@ -0,0 +1,94 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request for creating team connections. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamConnectionCreateRequest { + /// Array of team connections to create. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamConnectionCreateRequest { + pub fn new( + data: Vec, + ) -> TeamConnectionCreateRequest { + TeamConnectionCreateRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamConnectionCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamConnectionCreateRequestVisitor; + impl<'a> Visitor<'a> for TeamConnectionCreateRequestVisitor { + type Value = TeamConnectionCreateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = TeamConnectionCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamConnectionCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_team_connection_delete_request.rs b/src/datadogV2/model/model_team_connection_delete_request.rs new file mode 100644 index 000000000..998c806ac --- /dev/null +++ b/src/datadogV2/model/model_team_connection_delete_request.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request for deleting team connections. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamConnectionDeleteRequest { + /// Array of team connection IDs to delete. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamConnectionDeleteRequest { + pub fn new( + data: Vec, + ) -> TeamConnectionDeleteRequest { + TeamConnectionDeleteRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamConnectionDeleteRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamConnectionDeleteRequestVisitor; + impl<'a> Visitor<'a> for TeamConnectionDeleteRequestVisitor { + type Value = TeamConnectionDeleteRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = TeamConnectionDeleteRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamConnectionDeleteRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_team_connection_delete_request_data_item.rs b/src/datadogV2/model/model_team_connection_delete_request_data_item.rs new file mode 100644 index 000000000..3ca73a42d --- /dev/null +++ b/src/datadogV2/model/model_team_connection_delete_request_data_item.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A collection of connection ids to delete. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamConnectionDeleteRequestDataItem { + /// The unique identifier of the team connection to delete. + #[serde(rename = "id")] + pub id: String, + /// Team connection resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamConnectionType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamConnectionDeleteRequestDataItem { + pub fn new( + id: String, + type_: crate::datadogV2::model::TeamConnectionType, + ) -> TeamConnectionDeleteRequestDataItem { + TeamConnectionDeleteRequestDataItem { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamConnectionDeleteRequestDataItem { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamConnectionDeleteRequestDataItemVisitor; + impl<'a> Visitor<'a> for TeamConnectionDeleteRequestDataItemVisitor { + type Value = TeamConnectionDeleteRequestDataItem; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamConnectionType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamConnectionDeleteRequestDataItem { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamConnectionDeleteRequestDataItemVisitor) + } +} diff --git a/src/datadogV2/model/model_team_connection_relationships.rs b/src/datadogV2/model/model_team_connection_relationships.rs new file mode 100644 index 000000000..b434cdbad --- /dev/null +++ b/src/datadogV2/model/model_team_connection_relationships.rs @@ -0,0 +1,123 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Relationships of the team connection. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamConnectionRelationships { + /// Reference to a team from an external system. + #[serde(rename = "connected_team")] + pub connected_team: Option, + /// Reference to a Datadog team. + #[serde(rename = "team")] + pub team: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamConnectionRelationships { + pub fn new() -> TeamConnectionRelationships { + TeamConnectionRelationships { + connected_team: None, + team: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn connected_team(mut self, value: crate::datadogV2::model::ConnectedTeamRef) -> Self { + self.connected_team = Some(value); + self + } + + pub fn team(mut self, value: crate::datadogV2::model::TeamRef) -> Self { + self.team = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamConnectionRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamConnectionRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamConnectionRelationshipsVisitor; + impl<'a> Visitor<'a> for TeamConnectionRelationshipsVisitor { + type Value = TeamConnectionRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut connected_team: Option = None; + let mut team: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "connected_team" => { + if v.is_null() { + continue; + } + connected_team = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "team" => { + if v.is_null() { + continue; + } + team = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamConnectionRelationships { + connected_team, + team, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamConnectionRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_team_connection_type.rs b/src/datadogV2/model/model_team_connection_type.rs new file mode 100644 index 000000000..7c3b1f107 --- /dev/null +++ b/src/datadogV2/model/model_team_connection_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum TeamConnectionType { + TEAM_CONNECTION, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TeamConnectionType { + fn to_string(&self) -> String { + match self { + Self::TEAM_CONNECTION => String::from("team_connection"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TeamConnectionType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for TeamConnectionType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "team_connection" => Self::TEAM_CONNECTION, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_team_connections_response.rs b/src/datadogV2/model/model_team_connections_response.rs new file mode 100644 index 000000000..453d74e9d --- /dev/null +++ b/src/datadogV2/model/model_team_connections_response.rs @@ -0,0 +1,122 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing information about multiple team connections. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamConnectionsResponse { + /// Array of team connections. + #[serde(rename = "data")] + pub data: Option>, + /// Connections response metadata. + #[serde(rename = "meta")] + pub meta: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamConnectionsResponse { + pub fn new() -> TeamConnectionsResponse { + TeamConnectionsResponse { + data: None, + meta: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: Vec) -> Self { + self.data = Some(value); + self + } + + pub fn meta(mut self, value: crate::datadogV2::model::ConnectionsResponseMeta) -> Self { + self.meta = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamConnectionsResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamConnectionsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamConnectionsResponseVisitor; + impl<'a> Visitor<'a> for TeamConnectionsResponseVisitor { + type Value = TeamConnectionsResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut meta: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "meta" => { + if v.is_null() { + continue; + } + meta = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamConnectionsResponse { + data, + meta, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamConnectionsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_team_ref.rs b/src/datadogV2/model/model_team_ref.rs new file mode 100644 index 000000000..acf045b3d --- /dev/null +++ b/src/datadogV2/model/model_team_ref.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Reference to a Datadog team. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamRef { + /// Reference to a Datadog team. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamRef { + pub fn new() -> TeamRef { + TeamRef { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::TeamRefData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamRef { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamRef { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamRefVisitor; + impl<'a> Visitor<'a> for TeamRefVisitor { + type Value = TeamRef; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamRef { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamRefVisitor) + } +} diff --git a/src/datadogV2/model/model_team_ref_data.rs b/src/datadogV2/model/model_team_ref_data.rs new file mode 100644 index 000000000..f1aa745bd --- /dev/null +++ b/src/datadogV2/model/model_team_ref_data.rs @@ -0,0 +1,112 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Reference to a Datadog team. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamRefData { + /// The Datadog team ID. + #[serde(rename = "id")] + pub id: String, + /// Datadog team resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamRefDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamRefData { + pub fn new(id: String, type_: crate::datadogV2::model::TeamRefDataType) -> TeamRefData { + TeamRefData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamRefData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamRefDataVisitor; + impl<'a> Visitor<'a> for TeamRefDataVisitor { + type Value = TeamRefData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamRefDataType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamRefData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamRefDataVisitor) + } +} diff --git a/src/datadogV2/model/model_team_ref_data_type.rs b/src/datadogV2/model/model_team_ref_data_type.rs new file mode 100644 index 000000000..6bdf42ee9 --- /dev/null +++ b/src/datadogV2/model/model_team_ref_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum TeamRefDataType { + TEAM, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TeamRefDataType { + fn to_string(&self) -> String { + match self { + Self::TEAM => String::from("team"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TeamRefDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for TeamRefDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "team" => Self::TEAM, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 12852be0f..b67e2d5ad 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -1141,6 +1141,13 @@ "tag": "Teams", "operationId": "CreateTeam" }, + { + "source": "data.data[0]", + "step": "there is a valid \"team_connection\" in the system", + "key": "team_connection", + "tag": "Team Connections", + "operationId": "CreateTeamConnections" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/team_connections.feature b/tests/scenarios/features/v2/team_connections.feature new file mode 100644 index 000000000..7bbce889e --- /dev/null +++ b/tests/scenarios/features/v2/team_connections.feature @@ -0,0 +1,93 @@ +@endpoint(team-connections) @endpoint(team-connections-v2) +Feature: Team Connections + View and manage relationships between Datadog teams and teams from + external sources, such as GitHub. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "TeamConnections" API + + @skip @team:DataDog/aaa-omg + Scenario: Create team connections returns "Bad Request" response + Given operation "CreateTeamConnections" enabled + And new "CreateTeamConnections" request + And body with value {"data": [{"attributes": {"source": "github"}, "relationships": {"connected_team": {"data": {"id": "@MyGitHubAccount/my-team-name", "type": "github_team"}}, "team": {"data": {"type": "team"}}}, "type": "team_connection"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-omg + Scenario: Create team connections returns "Conflict" response + Given operation "CreateTeamConnections" enabled + And new "CreateTeamConnections" request + And body with value {"data": [{"attributes": {"managed_by": "github_sync", "source": "github"}, "relationships": {"connected_team": {"data": {"id": "@GitHubOrg/team-handle", "type": "github_team"}}, "team": {"data": {"id": "87654321-4321-8765-dcba-210987654321", "type": "team"}}}, "type": "team_connection"}]} + When the request is sent + Then the response status is 409 Conflict + + @skip @team:DataDog/aaa-omg + Scenario: Create team connections returns "Created" response + Given operation "CreateTeamConnections" enabled + And new "CreateTeamConnections" request + And there is a valid "dd_team" in the system + And body with value {"data": [{"type": "team_connection", "attributes": {"source": "github", "managed_by": "datadog"}, "relationships": {"team": {"data": {"id": "{{ dd_team.data.id }}", "type": "team"}}, "connected_team": {"data": {"id": "@MyGitHubAccount/my-team-name", "type": "github_team"}}}}]} + When the request is sent + Then the response status is 201 Created + And the response "data.data[0].attributes.source" is equal to "github" + And the response "data.data[0].attributes.managed_by" is equal to "datadog" + And the response "data.data[0].relationships.team.data.id" is equal to "{{ dd_team.data.id }}" + And the response "data.data[0].relationships.connected_team.data.id" is equal to "@MyGitHubAccount/my-team-name" + And the response "data.data[0].type" is equal to "team_connection" + + @skip @team:DataDog/aaa-omg + Scenario: Delete team connections returns "Bad Request" response + Given operation "DeleteTeamConnections" enabled + And new "DeleteTeamConnections" request + And body with value {"data": [{"type": "team_connection"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-omg + Scenario: Delete team connections returns "No Content" response + Given operation "DeleteTeamConnections" enabled + And new "DeleteTeamConnections" request + And body with value {"data": [{"id": "12345678-1234-5678-9abc-123456789012", "type": "team_connection"}]} + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/aaa-omg + Scenario: Delete team connections returns "Not Found" response + Given operation "DeleteTeamConnections" enabled + And new "DeleteTeamConnections" request + And body with value {"data": [{"id": "12345678-1234-5678-9abc-123456789012", "type": "team_connection"}]} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/aaa-omg + Scenario: List team connections returns "Bad Request" response + Given operation "ListTeamConnections" enabled + And new "ListTeamConnections" request + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/aaa-omg + Scenario: List team connections returns "OK" response + Given operation "ListTeamConnections" enabled + And new "ListTeamConnections" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/aaa-omg @with-pagination + Scenario: List team connections returns "OK" response with pagination + Given operation "ListTeamConnections" enabled + And new "ListTeamConnections" request + When the request with pagination is sent + Then the response status is 200 OK + + @skip @team:DataDog/aaa-omg + Scenario: List team connections with filters returns "OK" response + Given operation "ListTeamConnections" enabled + And new "ListTeamConnections" request + And request contains "filter[sources]" parameter with value ["github"] + And request contains "page[size]" parameter with value 10 + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index cd8c18bf0..d25ca0a4d 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -4268,6 +4268,25 @@ "type": "unsafe" } }, + "DeleteTeamConnections": { + "tag": "Team Connections", + "undo": { + "type": "idempotent" + } + }, + "ListTeamConnections": { + "tag": "Team Connections", + "undo": { + "type": "safe" + } + }, + "CreateTeamConnections": { + "tag": "Team Connections", + "undo": { + "operationId": "DeleteTeamConnections", + "type": "unsafe" + } + }, "SyncTeams": { "tag": "Teams", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 3d8f1bae5..e04382cb2 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -149,6 +149,7 @@ pub struct ApiInstances { pub v2_api_static_analysis: Option, pub v2_api_synthetics: Option, pub v2_api_teams: Option, + pub v2_api_team_connections: Option, pub v2_api_incident_teams: Option, pub v2_api_test_optimization: Option, pub v2_api_users: Option, @@ -953,6 +954,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { world.http_client.as_ref().unwrap().clone(), )); } + "TeamConnections" => { + world.api_instances.v2_api_team_connections = Some( + datadogV2::api_team_connections::TeamConnectionsAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + ), + ); + } "IncidentTeams" => { world.api_instances.v2_api_incident_teams = Some( datadogV2::api_incident_teams::IncidentTeamsAPI::with_client_and_config( @@ -4275,6 +4284,22 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.GetUserMemberships".into(), test_v2_get_user_memberships); + world.function_mappings.insert( + "v2.DeleteTeamConnections".into(), + test_v2_delete_team_connections, + ); + world.function_mappings.insert( + "v2.ListTeamConnections".into(), + test_v2_list_team_connections, + ); + world.function_mappings.insert( + "v2.ListTeamConnectionsWithPagination".into(), + test_v2_list_team_connections_with_pagination, + ); + world.function_mappings.insert( + "v2.CreateTeamConnections".into(), + test_v2_create_team_connections, + ); world .function_mappings .insert("v2.ListIncidentTeams".into(), test_v2_list_incident_teams); @@ -33090,6 +33115,166 @@ fn test_v2_get_user_memberships(world: &mut DatadogWorld, _parameters: &HashMap< world.response.code = response.status.as_u16(); } +fn test_v2_delete_team_connections(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_team_connections + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_team_connections_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_list_team_connections(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_team_connections + .as_ref() + .expect("api instance not found"); + let page_size = _parameters + .get("page[size]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_number = _parameters + .get("page[number]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_sources = _parameters + .get("filter[sources]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_team_ids = _parameters + .get("filter[team_ids]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_connected_team_ids = _parameters + .get("filter[connected_team_ids]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_connection_ids = _parameters + .get("filter[connection_ids]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_team_connections::ListTeamConnectionsOptionalParams::default(); + params.page_size = page_size; + params.page_number = page_number; + params.filter_sources = filter_sources; + params.filter_team_ids = filter_team_ids; + params.filter_connected_team_ids = filter_connected_team_ids; + params.filter_connection_ids = filter_connection_ids; + let response = match block_on(api.list_team_connections_with_http_info(params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} +fn test_v2_list_team_connections_with_pagination( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_team_connections + .as_ref() + .expect("api instance not found"); + let page_size = _parameters + .get("page[size]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_number = _parameters + .get("page[number]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_sources = _parameters + .get("filter[sources]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_team_ids = _parameters + .get("filter[team_ids]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_connected_team_ids = _parameters + .get("filter[connected_team_ids]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_connection_ids = _parameters + .get("filter[connection_ids]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_team_connections::ListTeamConnectionsOptionalParams::default(); + params.page_size = page_size; + params.page_number = page_number; + params.filter_sources = filter_sources; + params.filter_team_ids = filter_team_ids; + params.filter_connected_team_ids = filter_connected_team_ids; + params.filter_connection_ids = filter_connection_ids; + let response = api.list_team_connections_with_pagination(params); + let mut result = Vec::new(); + + block_on(async { + pin_mut!(response); + + while let Some(resp) = response.next().await { + match resp { + Ok(response) => { + result.push(response); + } + Err(error) => { + return match error { + Error::ResponseError(e) => { + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {}", error), + }; + } + } + } + }); + world.response.object = serde_json::to_value(result).unwrap(); + world.response.code = 200; +} + +fn test_v2_create_team_connections(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_team_connections + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_team_connections_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_list_incident_teams(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances