diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 9bceb7154..382f53915 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -52016,6 +52016,205 @@ components: required: - data type: object + TeamHierarchyLink: + description: Team hierarchy link + properties: + attributes: + $ref: '#/components/schemas/TeamHierarchyLinkAttributes' + id: + description: The team hierarchy link's identifier + example: b8626d7e-cedd-11eb-abf5-da7ad0900001 + type: string + relationships: + $ref: '#/components/schemas/TeamHierarchyLinkRelationships' + type: + $ref: '#/components/schemas/TeamHierarchyLinkType' + required: + - attributes + - id + - type + type: object + TeamHierarchyLinkAttributes: + description: Team hierarchy link attributes + properties: + created_at: + description: Timestamp when the team hierarchy link was created + example: '' + format: date-time + type: string + provisioned_by: + description: The provisioner of the team hierarchy link + example: system + type: string + required: + - provisioned_by + - created_at + type: object + TeamHierarchyLinkCreate: + description: Team hierarchy link creation + properties: + relationships: + $ref: '#/components/schemas/TeamHierarchyLinkCreateRelationships' + type: + $ref: '#/components/schemas/TeamHierarchyLinkType' + required: + - relationships + - type + type: object + TeamHierarchyLinkCreateRelationships: + description: Team hierarchy link creation relationships + properties: + parent_team: + $ref: '#/components/schemas/TeamHierarchyLinkCreateTeamRelationship' + sub_team: + $ref: '#/components/schemas/TeamHierarchyLinkCreateTeamRelationship' + required: + - parent_team + - sub_team + type: object + TeamHierarchyLinkCreateRequest: + description: Request to create a team hierarchy link + properties: + data: + $ref: '#/components/schemas/TeamHierarchyLinkCreate' + required: + - data + type: object + TeamHierarchyLinkCreateTeam: + description: Team reference for hierarchy link creation + properties: + id: + description: The team's identifier + example: 692e8073-12c4-4c71-8408-5090bd44c9c8 + type: string + type: + $ref: '#/components/schemas/TeamType' + required: + - id + - type + type: object + TeamHierarchyLinkCreateTeamRelationship: + description: Team relationship for hierarchy link creation + properties: + data: + $ref: '#/components/schemas/TeamHierarchyLinkCreateTeam' + required: + - data + type: object + TeamHierarchyLinkRelationships: + description: Team hierarchy link relationships + properties: + parent_team: + $ref: '#/components/schemas/TeamHierarchyLinkTeamRelationship' + sub_team: + $ref: '#/components/schemas/TeamHierarchyLinkTeamRelationship' + required: + - parent_team + - sub_team + type: object + TeamHierarchyLinkResponse: + description: Team hierarchy link response + properties: + data: + $ref: '#/components/schemas/TeamHierarchyLink' + included: + description: Included teams + items: + $ref: '#/components/schemas/TeamHierarchyLinkTeam' + type: array + type: object + TeamHierarchyLinkTeam: + description: Team information in hierarchy link context + properties: + attributes: + $ref: '#/components/schemas/TeamHierarchyLinkTeamAttributes' + id: + description: The team's identifier + example: 692e8073-12c4-4c71-8408-5090bd44c9c8 + type: string + type: + $ref: '#/components/schemas/TeamType' + required: + - id + - type + - attributes + type: object + TeamHierarchyLinkTeamAttributes: + description: Team attributes in hierarchy link context + properties: + avatar: + description: The team's avatar + nullable: true + type: string + banner: + description: The team's banner + format: int64 + type: integer + handle: + description: The team's handle + example: team-handle + type: string + is_managed: + description: Whether the team is managed + type: boolean + is_open_membership: + description: Whether the team has open membership + type: boolean + link_count: + description: The number of links for the team + format: int64 + type: integer + name: + description: The team's name + example: Team Name + type: string + summary: + description: The team's summary + nullable: true + type: string + user_count: + description: The number of users in the team + format: int64 + type: integer + required: + - handle + - name + type: object + TeamHierarchyLinkTeamRelationship: + description: Team hierarchy link team relationship + properties: + data: + $ref: '#/components/schemas/TeamHierarchyLinkTeam' + required: + - data + type: object + TeamHierarchyLinkType: + default: team_hierarchy_links + description: Team hierarchy link type + enum: + - team_hierarchy_links + example: team_hierarchy_links + type: string + x-enum-varnames: + - TEAM_HIERARCHY_LINKS + TeamHierarchyLinksResponse: + description: Team hierarchy links response + properties: + data: + description: Team hierarchy links response data + items: + $ref: '#/components/schemas/TeamHierarchyLink' + type: array + included: + description: Included teams + items: + $ref: '#/components/schemas/TeamHierarchyLinkTeam' + type: array + links: + $ref: '#/components/schemas/TeamsHierarchyLinksResponseLinks' + meta: + $ref: '#/components/schemas/TeamsHierarchyLinksResponseMeta' + type: object TeamIncluded: description: Included resources related to the team oneOf: @@ -52895,6 +53094,70 @@ components: - LINK_COUNT - TEAM_LINKS - USER_TEAM_PERMISSIONS + TeamsHierarchyLinksResponseLinks: + description: Teams hierarchy links response links. + properties: + first: + description: Link to the first page. + nullable: true + type: string + last: + description: Link to the last page. + nullable: true + type: string + next: + description: Link to the next page. + nullable: true + type: string + prev: + description: Link to the previous page. + nullable: true + type: string + self: + description: Link to the current object. + type: string + type: object + TeamsHierarchyLinksResponseMeta: + description: Team hierarchy links response metadata. + properties: + page: + $ref: '#/components/schemas/TeamsHierarchyLinksResponseMetaPage' + type: object + TeamsHierarchyLinksResponseMetaPage: + description: Teams hierarchy links response page metadata. + properties: + first_number: + description: First page number. + format: int64 + type: integer + last_number: + description: Last page number. + format: int64 + type: integer + next_number: + description: Next page number. + format: int64 + type: integer + number: + description: Page number. + format: int64 + type: integer + prev_number: + description: Previous page number. + format: int64 + type: integer + size: + description: Page size. + format: int64 + type: integer + total: + description: Total number of results. + format: int64 + type: integer + type: + description: Offset type. + type: string + type: object TeamsResponse: description: Response with multiple teams properties: @@ -81999,6 +82262,170 @@ paths: permissions: - teams_read - teams_manage + /api/v2/team-hierarchy-links: + get: + description: Get all team hierarchy links that match the provided filters. + operationId: GetTeamHierarchyLinks + parameters: + - $ref: '#/components/parameters/PageNumber' + - $ref: '#/components/parameters/PageSize' + - description: Filter by parent team ID + in: query + name: filter[parent_team] + required: false + schema: + type: string + - description: Filter by sub team ID + in: query + name: filter[sub_team] + required: false + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamHierarchyLinksResponse' + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: Get team hierarchy links + tags: + - Teams + x-pagination: + limitParam: page[size] + pageParam: page[number] + resultsPath: data + x-permission: + operator: OR + permissions: + - teams_read + post: + description: Create a new team hierarchy link between a parent team and a sub + team. + operationId: AddTeamHierarchyLink + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TeamHierarchyLinkCreateRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamHierarchyLinkResponse' + description: CREATED + '403': + $ref: '#/components/responses/ForbiddenResponse' + '409': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Conflict + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + - teams_manage + summary: Create a team hierarchy link + tags: + - Teams + x-permission: + operator: AND + permissions: + - teams_read + - teams_manage + /api/v2/team-hierarchy-links/{link_id}: + delete: + description: Remove a team hierarchy link by the given link_id. + operationId: RemoveTeamHierarchyLink + parameters: + - description: The team hierarchy link's identifier + in: path + name: link_id + required: true + schema: + type: string + responses: + '204': + description: No Content + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + - teams_manage + summary: Remove a team hierarchy link + tags: + - Teams + x-permission: + operator: AND + permissions: + - teams_read + - teams_manage + get: + description: Get a single team hierarchy link for the given link_id. + operationId: GetTeamHierarchyLink + parameters: + - description: The team hierarchy link's identifier + in: path + name: link_id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamHierarchyLinkResponse' + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: Get a team hierarchy link + tags: + - Teams + x-permission: + operator: OR + permissions: + - teams_read /api/v2/team/connections: delete: description: Delete multiple team connections. @@ -82273,7 +82700,13 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/team/{super_team_id}/member_teams: get: - description: Get all member teams. + deprecated: true + description: 'Get all member teams. + + + **Note**: This API is deprecated. For team hierarchy relationships (parent-child + + teams), use the team hierarchy links API: `GET /api/v2/team-hierarchy-links`.' operationId: ListMemberTeams parameters: - description: None @@ -82326,14 +82759,20 @@ paths: operator: OR permissions: - teams_read + x-sunset: '2026-06-01' x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' post: + deprecated: true description: 'Add a member team. Adds the team given by the `id` in the body as a member team of the super - team.' + team. + + + **Note**: This API is deprecated. For creating team hierarchy links, use the + team hierarchy links API: `POST /api/v2/team-hierarchy-links`.' operationId: AddMemberTeam parameters: - description: None @@ -82373,12 +82812,18 @@ paths: operator: OR permissions: - teams_read + x-sunset: '2026-06-01' x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/team/{super_team_id}/member_teams/{member_team_id}: delete: - description: Remove a super team's member team identified by `member_team_id`. + deprecated: true + description: 'Remove a super team''s member team identified by `member_team_id`. + + + **Note**: This API is deprecated. For deleting team hierarchy links, use the + team hierarchy links API: `DELETE /api/v2/team-hierarchy-links/{link_id}`.' operationId: RemoveMemberTeam parameters: - description: None @@ -82418,6 +82863,7 @@ paths: operator: OR permissions: - teams_read + x-sunset: '2026-06-01' x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' diff --git a/examples/v2_teams_AddTeamHierarchyLink.rs b/examples/v2_teams_AddTeamHierarchyLink.rs new file mode 100644 index 000000000..af134fbb6 --- /dev/null +++ b/examples/v2_teams_AddTeamHierarchyLink.rs @@ -0,0 +1,35 @@ +// Create a team hierarchy link returns "CREATED" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreate; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateRelationships; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateRequest; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateTeam; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkType; +use datadog_api_client::datadogV2::model::TeamType; + +#[tokio::main] +async fn main() { + let body = TeamHierarchyLinkCreateRequest::new(TeamHierarchyLinkCreate::new( + TeamHierarchyLinkCreateRelationships::new( + TeamHierarchyLinkCreateTeamRelationship::new(TeamHierarchyLinkCreateTeam::new( + "692e8073-12c4-4c71-8408-5090bd44c9c8".to_string(), + TeamType::TEAM, + )), + TeamHierarchyLinkCreateTeamRelationship::new(TeamHierarchyLinkCreateTeam::new( + "692e8073-12c4-4c71-8408-5090bd44c9c8".to_string(), + TeamType::TEAM, + )), + ), + TeamHierarchyLinkType::TEAM_HIERARCHY_LINKS, + )); + let configuration = datadog::Configuration::new(); + let api = TeamsAPI::with_config(configuration); + let resp = api.add_team_hierarchy_link(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_teams_GetTeamHierarchyLink.rs b/examples/v2_teams_GetTeamHierarchyLink.rs new file mode 100644 index 000000000..90ff2744b --- /dev/null +++ b/examples/v2_teams_GetTeamHierarchyLink.rs @@ -0,0 +1,15 @@ +// Get a team hierarchy link returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = TeamsAPI::with_config(configuration); + let resp = api.get_team_hierarchy_link("link_id".to_string()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_teams_GetTeamHierarchyLinks.rs b/examples/v2_teams_GetTeamHierarchyLinks.rs new file mode 100644 index 000000000..4c307a580 --- /dev/null +++ b/examples/v2_teams_GetTeamHierarchyLinks.rs @@ -0,0 +1,18 @@ +// Get team hierarchy links returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::GetTeamHierarchyLinksOptionalParams; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = TeamsAPI::with_config(configuration); + let resp = api + .get_team_hierarchy_links(GetTeamHierarchyLinksOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_teams_GetTeamHierarchyLinks_3360757486.rs b/examples/v2_teams_GetTeamHierarchyLinks_3360757486.rs new file mode 100644 index 000000000..9fd20f69b --- /dev/null +++ b/examples/v2_teams_GetTeamHierarchyLinks_3360757486.rs @@ -0,0 +1,22 @@ +// Get team hierarchy links returns "OK" response with pagination +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::GetTeamHierarchyLinksOptionalParams; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; +use futures_util::pin_mut; +use futures_util::stream::StreamExt; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = TeamsAPI::with_config(configuration); + let response = api + .get_team_hierarchy_links_with_pagination(GetTeamHierarchyLinksOptionalParams::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/examples/v2_teams_RemoveTeamHierarchyLink.rs b/examples/v2_teams_RemoveTeamHierarchyLink.rs new file mode 100644 index 000000000..3c39d115f --- /dev/null +++ b/examples/v2_teams_RemoveTeamHierarchyLink.rs @@ -0,0 +1,15 @@ +// Remove a team hierarchy link returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = TeamsAPI::with_config(configuration); + let resp = api.remove_team_hierarchy_link("link_id".to_string()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_teams.rs b/src/datadogV2/api/api_teams.rs index edad90efc..315cd9adf 100644 --- a/src/datadogV2/api/api_teams.rs +++ b/src/datadogV2/api/api_teams.rs @@ -13,6 +13,43 @@ use reqwest::header::{HeaderMap, HeaderValue}; use serde::{Deserialize, Serialize}; use std::io::Write; +/// GetTeamHierarchyLinksOptionalParams is a struct for passing parameters to the method [`TeamsAPI::get_team_hierarchy_links`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct GetTeamHierarchyLinksOptionalParams { + /// Specific page number to return. + pub page_number: Option, + /// Size for a given page. The maximum allowed value is 100. + pub page_size: Option, + /// Filter by parent team ID + pub filter_parent_team: Option, + /// Filter by sub team ID + pub filter_sub_team: Option, +} + +impl GetTeamHierarchyLinksOptionalParams { + /// Specific page number to return. + pub fn page_number(mut self, value: i64) -> Self { + self.page_number = Some(value); + self + } + /// 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 + } + /// Filter by parent team ID + pub fn filter_parent_team(mut self, value: String) -> Self { + self.filter_parent_team = Some(value); + self + } + /// Filter by sub team ID + pub fn filter_sub_team(mut self, value: String) -> Self { + self.filter_sub_team = Some(value); + self + } +} + /// GetTeamMembershipsOptionalParams is a struct for passing parameters to the method [`TeamsAPI::get_team_memberships`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -146,6 +183,14 @@ pub enum AddMemberTeamError { UnknownValue(serde_json::Value), } +/// AddTeamHierarchyLinkError is a struct for typed errors of method [`TeamsAPI::add_team_hierarchy_link`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddTeamHierarchyLinkError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// CreateTeamError is a struct for typed errors of method [`TeamsAPI::create_team`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -202,6 +247,22 @@ pub enum GetTeamError { UnknownValue(serde_json::Value), } +/// GetTeamHierarchyLinkError is a struct for typed errors of method [`TeamsAPI::get_team_hierarchy_link`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTeamHierarchyLinkError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetTeamHierarchyLinksError is a struct for typed errors of method [`TeamsAPI::get_team_hierarchy_links`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTeamHierarchyLinksError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetTeamLinkError is a struct for typed errors of method [`TeamsAPI::get_team_link`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -274,6 +335,14 @@ pub enum RemoveMemberTeamError { UnknownValue(serde_json::Value), } +/// RemoveTeamHierarchyLinkError is a struct for typed errors of method [`TeamsAPI::remove_team_hierarchy_link`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RemoveTeamHierarchyLinkError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// SyncTeamsError is a struct for typed errors of method [`TeamsAPI::sync_teams`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -381,6 +450,8 @@ impl TeamsAPI { /// Add a member team. /// Adds the team given by the `id` in the body as a member team of the super team. + /// + /// **Note**: This API is deprecated. For creating team hierarchy links, use the team hierarchy links API: `POST /api/v2/team-hierarchy-links`. pub async fn add_member_team( &self, super_team_id: String, @@ -397,6 +468,8 @@ impl TeamsAPI { /// Add a member team. /// Adds the team given by the `id` in the body as a member team of the super team. + /// + /// **Note**: This API is deprecated. For creating team hierarchy links, use the team hierarchy links API: `POST /api/v2/team-hierarchy-links`. pub async fn add_member_team_with_http_info( &self, super_team_id: String, @@ -528,6 +601,160 @@ impl TeamsAPI { } } + /// Create a new team hierarchy link between a parent team and a sub team. + pub async fn add_team_hierarchy_link( + &self, + body: crate::datadogV2::model::TeamHierarchyLinkCreateRequest, + ) -> Result< + crate::datadogV2::model::TeamHierarchyLinkResponse, + datadog::Error, + > { + match self.add_team_hierarchy_link_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 a new team hierarchy link between a parent team and a sub team. + pub async fn add_team_hierarchy_link_with_http_info( + &self, + body: crate::datadogV2::model::TeamHierarchyLinkCreateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.add_team_hierarchy_link"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team-hierarchy-links", + 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)) + } + } + /// Create a new team. /// User IDs passed through the `users` relationship field are added to the team. pub async fn create_team( @@ -1364,6 +1591,283 @@ impl TeamsAPI { } } + /// Get a single team hierarchy link for the given link_id. + pub async fn get_team_hierarchy_link( + &self, + link_id: String, + ) -> Result< + crate::datadogV2::model::TeamHierarchyLinkResponse, + datadog::Error, + > { + match self.get_team_hierarchy_link_with_http_info(link_id).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), + } + } + + /// Get a single team hierarchy link for the given link_id. + pub async fn get_team_hierarchy_link_with_http_info( + &self, + link_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_team_hierarchy_link"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team-hierarchy-links/{link_id}", + local_configuration.get_operation_host(operation_id), + link_id = datadog::urlencode(link_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // 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)) + } + } + + /// Get all team hierarchy links that match the provided filters. + pub async fn get_team_hierarchy_links( + &self, + params: GetTeamHierarchyLinksOptionalParams, + ) -> Result< + crate::datadogV2::model::TeamHierarchyLinksResponse, + datadog::Error, + > { + match self.get_team_hierarchy_links_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 get_team_hierarchy_links_with_pagination( + &self, + mut params: GetTeamHierarchyLinksOptionalParams, + ) -> impl Stream< + Item = Result< + crate::datadogV2::model::TeamHierarchyLink, + 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.get_team_hierarchy_links(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); + } + } + } + + /// Get all team hierarchy links that match the provided filters. + pub async fn get_team_hierarchy_links_with_http_info( + &self, + params: GetTeamHierarchyLinksOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_team_hierarchy_links"; + + // unbox and build optional parameters + let page_number = params.page_number; + let page_size = params.page_size; + let filter_parent_team = params.filter_parent_team; + let filter_sub_team = params.filter_sub_team; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team-hierarchy-links", + 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_number { + local_req_builder = + local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); + }; + 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) = filter_parent_team { + local_req_builder = + local_req_builder.query(&[("filter[parent_team]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_sub_team { + local_req_builder = + local_req_builder.query(&[("filter[sub_team]", &local_query_param.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)) + } + } + /// Get a single link for a team. pub async fn get_team_link( &self, @@ -2079,6 +2583,9 @@ impl TeamsAPI { } /// Get all member teams. + /// + /// **Note**: This API is deprecated. For team hierarchy relationships (parent-child + /// teams), use the team hierarchy links API: `GET /api/v2/team-hierarchy-links`. pub async fn list_member_teams( &self, super_team_id: String, @@ -2137,6 +2644,9 @@ impl TeamsAPI { } /// Get all member teams. + /// + /// **Note**: This API is deprecated. For team hierarchy relationships (parent-child + /// teams), use the team hierarchy links API: `GET /api/v2/team-hierarchy-links`. pub async fn list_member_teams_with_http_info( &self, super_team_id: String, @@ -2439,6 +2949,8 @@ impl TeamsAPI { } /// Remove a super team's member team identified by `member_team_id`. + /// + /// **Note**: This API is deprecated. For deleting team hierarchy links, use the team hierarchy links API: `DELETE /api/v2/team-hierarchy-links/{link_id}`. pub async fn remove_member_team( &self, super_team_id: String, @@ -2454,6 +2966,8 @@ impl TeamsAPI { } /// Remove a super team's member team identified by `member_team_id`. + /// + /// **Note**: This API is deprecated. For deleting team hierarchy links, use the team hierarchy links API: `DELETE /api/v2/team-hierarchy-links/{link_id}`. pub async fn remove_member_team_with_http_info( &self, super_team_id: String, @@ -2540,6 +3054,97 @@ impl TeamsAPI { } } + /// Remove a team hierarchy link by the given link_id. + pub async fn remove_team_hierarchy_link( + &self, + link_id: String, + ) -> Result<(), datadog::Error> { + match self + .remove_team_hierarchy_link_with_http_info(link_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Remove a team hierarchy link by the given link_id. + pub async fn remove_team_hierarchy_link_with_http_info( + &self, + link_id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.remove_team_hierarchy_link"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team-hierarchy-links/{link_id}", + local_configuration.get_operation_host(operation_id), + link_id = datadog::urlencode(link_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("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"), + ); + }; + + 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)) + } + } + /// This endpoint attempts to link your existing Datadog teams with GitHub teams by matching their names. /// It evaluates all current Datadog teams and compares them against teams in the GitHub organization /// connected to your Datadog account, based on Datadog Team handle and GitHub Team slug diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 19b16a61f..bebc94179 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -6656,6 +6656,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_hierarchy_links_response; +pub use self::model_team_hierarchy_links_response::TeamHierarchyLinksResponse; +pub mod model_team_hierarchy_link; +pub use self::model_team_hierarchy_link::TeamHierarchyLink; +pub mod model_team_hierarchy_link_attributes; +pub use self::model_team_hierarchy_link_attributes::TeamHierarchyLinkAttributes; +pub mod model_team_hierarchy_link_relationships; +pub use self::model_team_hierarchy_link_relationships::TeamHierarchyLinkRelationships; +pub mod model_team_hierarchy_link_team_relationship; +pub use self::model_team_hierarchy_link_team_relationship::TeamHierarchyLinkTeamRelationship; +pub mod model_team_hierarchy_link_team; +pub use self::model_team_hierarchy_link_team::TeamHierarchyLinkTeam; +pub mod model_team_hierarchy_link_team_attributes; +pub use self::model_team_hierarchy_link_team_attributes::TeamHierarchyLinkTeamAttributes; +pub mod model_team_hierarchy_link_type; +pub use self::model_team_hierarchy_link_type::TeamHierarchyLinkType; +pub mod model_teams_hierarchy_links_response_links; +pub use self::model_teams_hierarchy_links_response_links::TeamsHierarchyLinksResponseLinks; +pub mod model_teams_hierarchy_links_response_meta; +pub use self::model_teams_hierarchy_links_response_meta::TeamsHierarchyLinksResponseMeta; +pub mod model_teams_hierarchy_links_response_meta_page; +pub use self::model_teams_hierarchy_links_response_meta_page::TeamsHierarchyLinksResponseMetaPage; +pub mod model_team_hierarchy_link_create_request; +pub use self::model_team_hierarchy_link_create_request::TeamHierarchyLinkCreateRequest; +pub mod model_team_hierarchy_link_create; +pub use self::model_team_hierarchy_link_create::TeamHierarchyLinkCreate; +pub mod model_team_hierarchy_link_create_relationships; +pub use self::model_team_hierarchy_link_create_relationships::TeamHierarchyLinkCreateRelationships; +pub mod model_team_hierarchy_link_create_team_relationship; +pub use self::model_team_hierarchy_link_create_team_relationship::TeamHierarchyLinkCreateTeamRelationship; +pub mod model_team_hierarchy_link_create_team; +pub use self::model_team_hierarchy_link_create_team::TeamHierarchyLinkCreateTeam; +pub mod model_team_hierarchy_link_response; +pub use self::model_team_hierarchy_link_response::TeamHierarchyLinkResponse; 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; diff --git a/src/datadogV2/model/model_team_hierarchy_link.rs b/src/datadogV2/model/model_team_hierarchy_link.rs new file mode 100644 index 000000000..5b43cb0a5 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link.rs @@ -0,0 +1,148 @@ +// 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}; + +/// Team hierarchy link +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLink { + /// Team hierarchy link attributes + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::TeamHierarchyLinkAttributes, + /// The team hierarchy link's identifier + #[serde(rename = "id")] + pub id: String, + /// Team hierarchy link relationships + #[serde(rename = "relationships")] + pub relationships: Option, + /// Team hierarchy link type + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamHierarchyLinkType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLink { + pub fn new( + attributes: crate::datadogV2::model::TeamHierarchyLinkAttributes, + id: String, + type_: crate::datadogV2::model::TeamHierarchyLinkType, + ) -> TeamHierarchyLink { + TeamHierarchyLink { + attributes, + id, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::TeamHierarchyLinkRelationships, + ) -> 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 TeamHierarchyLink { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkVisitor { + type Value = TeamHierarchyLink; + + 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::TeamHierarchyLinkRelationships, + > = 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" => { + 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::TeamHierarchyLinkType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamHierarchyLink { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_attributes.rs b/src/datadogV2/model/model_team_hierarchy_link_attributes.rs new file mode 100644 index 000000000..df885885c --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_attributes.rs @@ -0,0 +1,107 @@ +// 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}; + +/// Team hierarchy link attributes +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkAttributes { + /// Timestamp when the team hierarchy link was created + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// The provisioner of the team hierarchy link + #[serde(rename = "provisioned_by")] + pub provisioned_by: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkAttributes { + pub fn new( + created_at: chrono::DateTime, + provisioned_by: String, + ) -> TeamHierarchyLinkAttributes { + TeamHierarchyLinkAttributes { + created_at, + provisioned_by, + 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 TeamHierarchyLinkAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkAttributesVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkAttributesVisitor { + type Value = TeamHierarchyLinkAttributes; + + 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 created_at: Option> = None; + let mut provisioned_by: 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() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "provisioned_by" => { + provisioned_by = + 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 created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let provisioned_by = + provisioned_by.ok_or_else(|| M::Error::missing_field("provisioned_by"))?; + + let content = TeamHierarchyLinkAttributes { + created_at, + provisioned_by, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_create.rs b/src/datadogV2/model/model_team_hierarchy_link_create.rs new file mode 100644 index 000000000..c698e45ac --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_create.rs @@ -0,0 +1,117 @@ +// 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}; + +/// Team hierarchy link creation +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkCreate { + /// Team hierarchy link creation relationships + #[serde(rename = "relationships")] + pub relationships: crate::datadogV2::model::TeamHierarchyLinkCreateRelationships, + /// Team hierarchy link type + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamHierarchyLinkType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkCreate { + pub fn new( + relationships: crate::datadogV2::model::TeamHierarchyLinkCreateRelationships, + type_: crate::datadogV2::model::TeamHierarchyLinkType, + ) -> TeamHierarchyLinkCreate { + TeamHierarchyLinkCreate { + relationships, + 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 TeamHierarchyLinkCreate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkCreateVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkCreateVisitor { + type Value = TeamHierarchyLinkCreate; + + 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 relationships: Option< + crate::datadogV2::model::TeamHierarchyLinkCreateRelationships, + > = 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() { + "relationships" => { + 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::TeamHierarchyLinkType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let relationships = + relationships.ok_or_else(|| M::Error::missing_field("relationships"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamHierarchyLinkCreate { + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkCreateVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_create_relationships.rs b/src/datadogV2/model/model_team_hierarchy_link_create_relationships.rs new file mode 100644 index 000000000..1bd0b740a --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_create_relationships.rs @@ -0,0 +1,111 @@ +// 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}; + +/// Team hierarchy link creation relationships +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkCreateRelationships { + /// Team relationship for hierarchy link creation + #[serde(rename = "parent_team")] + pub parent_team: crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + /// Team relationship for hierarchy link creation + #[serde(rename = "sub_team")] + pub sub_team: crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkCreateRelationships { + pub fn new( + parent_team: crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + sub_team: crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + ) -> TeamHierarchyLinkCreateRelationships { + TeamHierarchyLinkCreateRelationships { + parent_team, + sub_team, + 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 TeamHierarchyLinkCreateRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkCreateRelationshipsVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkCreateRelationshipsVisitor { + type Value = TeamHierarchyLinkCreateRelationships; + + 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 parent_team: Option< + crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + > = None; + let mut sub_team: Option< + crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + > = 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() { + "parent_team" => { + parent_team = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sub_team" => { + sub_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 parent_team = + parent_team.ok_or_else(|| M::Error::missing_field("parent_team"))?; + let sub_team = sub_team.ok_or_else(|| M::Error::missing_field("sub_team"))?; + + let content = TeamHierarchyLinkCreateRelationships { + parent_team, + sub_team, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkCreateRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_create_request.rs b/src/datadogV2/model/model_team_hierarchy_link_create_request.rs new file mode 100644 index 000000000..6c483ec07 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_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 to create a team hierarchy link +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkCreateRequest { + /// Team hierarchy link creation + #[serde(rename = "data")] + pub data: crate::datadogV2::model::TeamHierarchyLinkCreate, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkCreateRequest { + pub fn new( + data: crate::datadogV2::model::TeamHierarchyLinkCreate, + ) -> TeamHierarchyLinkCreateRequest { + TeamHierarchyLinkCreateRequest { + 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 TeamHierarchyLinkCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkCreateRequestVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkCreateRequestVisitor { + type Value = TeamHierarchyLinkCreateRequest; + + 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 = TeamHierarchyLinkCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_create_team.rs b/src/datadogV2/model/model_team_hierarchy_link_create_team.rs new file mode 100644 index 000000000..0836cbc84 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_create_team.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}; + +/// Team reference for hierarchy link creation +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkCreateTeam { + /// The team's identifier + #[serde(rename = "id")] + pub id: String, + /// Team type + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkCreateTeam { + pub fn new( + id: String, + type_: crate::datadogV2::model::TeamType, + ) -> TeamHierarchyLinkCreateTeam { + TeamHierarchyLinkCreateTeam { + 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 TeamHierarchyLinkCreateTeam { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkCreateTeamVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkCreateTeamVisitor { + type Value = TeamHierarchyLinkCreateTeam; + + 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::TeamType::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 = TeamHierarchyLinkCreateTeam { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkCreateTeamVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_create_team_relationship.rs b/src/datadogV2/model/model_team_hierarchy_link_create_team_relationship.rs new file mode 100644 index 000000000..a488d8d07 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_create_team_relationship.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}; + +/// Team relationship for hierarchy link creation +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkCreateTeamRelationship { + /// Team reference for hierarchy link creation + #[serde(rename = "data")] + pub data: crate::datadogV2::model::TeamHierarchyLinkCreateTeam, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkCreateTeamRelationship { + pub fn new( + data: crate::datadogV2::model::TeamHierarchyLinkCreateTeam, + ) -> TeamHierarchyLinkCreateTeamRelationship { + TeamHierarchyLinkCreateTeamRelationship { + 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 TeamHierarchyLinkCreateTeamRelationship { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkCreateTeamRelationshipVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkCreateTeamRelationshipVisitor { + type Value = TeamHierarchyLinkCreateTeamRelationship; + + 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 = TeamHierarchyLinkCreateTeamRelationship { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkCreateTeamRelationshipVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_relationships.rs b/src/datadogV2/model/model_team_hierarchy_link_relationships.rs new file mode 100644 index 000000000..0e9ffaf4a --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_relationships.rs @@ -0,0 +1,111 @@ +// 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}; + +/// Team hierarchy link relationships +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkRelationships { + /// Team hierarchy link team relationship + #[serde(rename = "parent_team")] + pub parent_team: crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + /// Team hierarchy link team relationship + #[serde(rename = "sub_team")] + pub sub_team: crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkRelationships { + pub fn new( + parent_team: crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + sub_team: crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + ) -> TeamHierarchyLinkRelationships { + TeamHierarchyLinkRelationships { + parent_team, + sub_team, + 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 TeamHierarchyLinkRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkRelationshipsVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkRelationshipsVisitor { + type Value = TeamHierarchyLinkRelationships; + + 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 parent_team: Option< + crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + > = None; + let mut sub_team: Option< + crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + > = 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() { + "parent_team" => { + parent_team = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sub_team" => { + sub_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 parent_team = + parent_team.ok_or_else(|| M::Error::missing_field("parent_team"))?; + let sub_team = sub_team.ok_or_else(|| M::Error::missing_field("sub_team"))?; + + let content = TeamHierarchyLinkRelationships { + parent_team, + sub_team, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_response.rs b/src/datadogV2/model/model_team_hierarchy_link_response.rs new file mode 100644 index 000000000..79e03be34 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_response.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}; + +/// Team hierarchy link response +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkResponse { + /// Team hierarchy link + #[serde(rename = "data")] + pub data: Option, + /// Included teams + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkResponse { + pub fn new() -> TeamHierarchyLinkResponse { + TeamHierarchyLinkResponse { + data: None, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::TeamHierarchyLink) -> Self { + self.data = Some(value); + self + } + + pub fn included(mut self, value: Vec) -> Self { + self.included = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamHierarchyLinkResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkResponseVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkResponseVisitor { + type Value = TeamHierarchyLinkResponse; + + 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 included: 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)?); + } + "included" => { + if v.is_null() { + continue; + } + included = 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 = TeamHierarchyLinkResponse { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_team.rs b/src/datadogV2/model/model_team_hierarchy_link_team.rs new file mode 100644 index 000000000..0f9c11084 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_team.rs @@ -0,0 +1,126 @@ +// 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}; + +/// Team information in hierarchy link context +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkTeam { + /// Team attributes in hierarchy link context + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::TeamHierarchyLinkTeamAttributes, + /// The team's identifier + #[serde(rename = "id")] + pub id: String, + /// Team type + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkTeam { + pub fn new( + attributes: crate::datadogV2::model::TeamHierarchyLinkTeamAttributes, + id: String, + type_: crate::datadogV2::model::TeamType, + ) -> TeamHierarchyLinkTeam { + TeamHierarchyLinkTeam { + attributes, + 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 TeamHierarchyLinkTeam { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkTeamVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkTeamVisitor { + type Value = TeamHierarchyLinkTeam; + + 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< + crate::datadogV2::model::TeamHierarchyLinkTeamAttributes, + > = None; + 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() { + "attributes" => { + 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)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamHierarchyLinkTeam { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkTeamVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_team_attributes.rs b/src/datadogV2/model/model_team_hierarchy_link_team_attributes.rs new file mode 100644 index 000000000..24b3adf4b --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_team_attributes.rs @@ -0,0 +1,220 @@ +// 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}; + +/// Team attributes in hierarchy link context +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkTeamAttributes { + /// The team's avatar + #[serde(rename = "avatar", default, with = "::serde_with::rust::double_option")] + pub avatar: Option>, + /// The team's banner + #[serde(rename = "banner")] + pub banner: Option, + /// The team's handle + #[serde(rename = "handle")] + pub handle: String, + /// Whether the team is managed + #[serde(rename = "is_managed")] + pub is_managed: Option, + /// Whether the team has open membership + #[serde(rename = "is_open_membership")] + pub is_open_membership: Option, + /// The number of links for the team + #[serde(rename = "link_count")] + pub link_count: Option, + /// The team's name + #[serde(rename = "name")] + pub name: String, + /// The team's summary + #[serde( + rename = "summary", + default, + with = "::serde_with::rust::double_option" + )] + pub summary: Option>, + /// The number of users in the team + #[serde(rename = "user_count")] + pub user_count: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkTeamAttributes { + pub fn new(handle: String, name: String) -> TeamHierarchyLinkTeamAttributes { + TeamHierarchyLinkTeamAttributes { + avatar: None, + banner: None, + handle, + is_managed: None, + is_open_membership: None, + link_count: None, + name, + summary: None, + user_count: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn avatar(mut self, value: Option) -> Self { + self.avatar = Some(value); + self + } + + pub fn banner(mut self, value: i64) -> Self { + self.banner = Some(value); + self + } + + pub fn is_managed(mut self, value: bool) -> Self { + self.is_managed = Some(value); + self + } + + pub fn is_open_membership(mut self, value: bool) -> Self { + self.is_open_membership = Some(value); + self + } + + pub fn link_count(mut self, value: i64) -> Self { + self.link_count = Some(value); + self + } + + pub fn summary(mut self, value: Option) -> Self { + self.summary = Some(value); + self + } + + pub fn user_count(mut self, value: i64) -> Self { + self.user_count = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkTeamAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkTeamAttributesVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkTeamAttributesVisitor { + type Value = TeamHierarchyLinkTeamAttributes; + + 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 avatar: Option> = None; + let mut banner: Option = None; + let mut handle: Option = None; + let mut is_managed: Option = None; + let mut is_open_membership: Option = None; + let mut link_count: Option = None; + let mut name: Option = None; + let mut summary: Option> = None; + let mut user_count: 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() { + "avatar" => { + avatar = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "banner" => { + if v.is_null() { + continue; + } + banner = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "handle" => { + handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_managed" => { + if v.is_null() { + continue; + } + is_managed = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_open_membership" => { + if v.is_null() { + continue; + } + is_open_membership = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "link_count" => { + if v.is_null() { + continue; + } + link_count = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "summary" => { + summary = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_count" => { + if v.is_null() { + continue; + } + user_count = 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 handle = handle.ok_or_else(|| M::Error::missing_field("handle"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = TeamHierarchyLinkTeamAttributes { + avatar, + banner, + handle, + is_managed, + is_open_membership, + link_count, + name, + summary, + user_count, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkTeamAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_team_relationship.rs b/src/datadogV2/model/model_team_hierarchy_link_team_relationship.rs new file mode 100644 index 000000000..2bb13e044 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_team_relationship.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}; + +/// Team hierarchy link team relationship +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkTeamRelationship { + /// Team information in hierarchy link context + #[serde(rename = "data")] + pub data: crate::datadogV2::model::TeamHierarchyLinkTeam, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkTeamRelationship { + pub fn new( + data: crate::datadogV2::model::TeamHierarchyLinkTeam, + ) -> TeamHierarchyLinkTeamRelationship { + TeamHierarchyLinkTeamRelationship { + 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 TeamHierarchyLinkTeamRelationship { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkTeamRelationshipVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkTeamRelationshipVisitor { + type Value = TeamHierarchyLinkTeamRelationship; + + 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 = TeamHierarchyLinkTeamRelationship { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkTeamRelationshipVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_type.rs b/src/datadogV2/model/model_team_hierarchy_link_type.rs new file mode 100644 index 000000000..845d2f52e --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_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 TeamHierarchyLinkType { + TEAM_HIERARCHY_LINKS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TeamHierarchyLinkType { + fn to_string(&self) -> String { + match self { + Self::TEAM_HIERARCHY_LINKS => String::from("team_hierarchy_links"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TeamHierarchyLinkType { + 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 TeamHierarchyLinkType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "team_hierarchy_links" => Self::TEAM_HIERARCHY_LINKS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_links_response.rs b/src/datadogV2/model/model_team_hierarchy_links_response.rs new file mode 100644 index 000000000..e608b037e --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_links_response.rs @@ -0,0 +1,162 @@ +// 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}; + +/// Team hierarchy links response +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinksResponse { + /// Team hierarchy links response data + #[serde(rename = "data")] + pub data: Option>, + /// Included teams + #[serde(rename = "included")] + pub included: Option>, + /// Teams hierarchy links response links. + #[serde(rename = "links")] + pub links: Option, + /// Team hierarchy links 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 TeamHierarchyLinksResponse { + pub fn new() -> TeamHierarchyLinksResponse { + TeamHierarchyLinksResponse { + data: None, + included: None, + links: 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 included(mut self, value: Vec) -> Self { + self.included = Some(value); + self + } + + pub fn links( + mut self, + value: crate::datadogV2::model::TeamsHierarchyLinksResponseLinks, + ) -> Self { + self.links = Some(value); + self + } + + pub fn meta(mut self, value: crate::datadogV2::model::TeamsHierarchyLinksResponseMeta) -> 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 TeamHierarchyLinksResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinksResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinksResponseVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinksResponseVisitor { + type Value = TeamHierarchyLinksResponse; + + 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 included: Option> = + None; + let mut links: 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)?); + } + "included" => { + if v.is_null() { + continue; + } + included = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "links" => { + if v.is_null() { + continue; + } + links = 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 = TeamHierarchyLinksResponse { + data, + included, + links, + meta, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinksResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_teams_hierarchy_links_response_links.rs b/src/datadogV2/model/model_teams_hierarchy_links_response_links.rs new file mode 100644 index 000000000..04d713f2a --- /dev/null +++ b/src/datadogV2/model/model_teams_hierarchy_links_response_links.rs @@ -0,0 +1,161 @@ +// 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}; + +/// Teams hierarchy links response links. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamsHierarchyLinksResponseLinks { + /// Link to the first page. + #[serde(rename = "first", default, with = "::serde_with::rust::double_option")] + pub first: Option>, + /// Link to the last page. + #[serde(rename = "last", default, with = "::serde_with::rust::double_option")] + pub last: Option>, + /// Link to the next page. + #[serde(rename = "next", default, with = "::serde_with::rust::double_option")] + pub next: Option>, + /// Link to the previous page. + #[serde(rename = "prev", default, with = "::serde_with::rust::double_option")] + pub prev: Option>, + /// Link to the current object. + #[serde(rename = "self")] + pub self_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamsHierarchyLinksResponseLinks { + pub fn new() -> TeamsHierarchyLinksResponseLinks { + TeamsHierarchyLinksResponseLinks { + first: None, + last: None, + next: None, + prev: None, + self_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn first(mut self, value: Option) -> Self { + self.first = Some(value); + self + } + + pub fn last(mut self, value: Option) -> Self { + self.last = Some(value); + self + } + + pub fn next(mut self, value: Option) -> Self { + self.next = Some(value); + self + } + + pub fn prev(mut self, value: Option) -> Self { + self.prev = Some(value); + self + } + + pub fn self_(mut self, value: String) -> Self { + self.self_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamsHierarchyLinksResponseLinks { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamsHierarchyLinksResponseLinks { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamsHierarchyLinksResponseLinksVisitor; + impl<'a> Visitor<'a> for TeamsHierarchyLinksResponseLinksVisitor { + type Value = TeamsHierarchyLinksResponseLinks; + + 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: Option> = None; + let mut last: Option> = None; + let mut next: Option> = None; + let mut prev: Option> = None; + let mut self_: 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" => { + first = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last" => { + last = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "next" => { + next = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "prev" => { + prev = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "self" => { + if v.is_null() { + continue; + } + self_ = 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 = TeamsHierarchyLinksResponseLinks { + first, + last, + next, + prev, + self_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamsHierarchyLinksResponseLinksVisitor) + } +} diff --git a/src/datadogV2/model/model_teams_hierarchy_links_response_meta.rs b/src/datadogV2/model/model_teams_hierarchy_links_response_meta.rs new file mode 100644 index 000000000..fd12d2f59 --- /dev/null +++ b/src/datadogV2/model/model_teams_hierarchy_links_response_meta.rs @@ -0,0 +1,109 @@ +// 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}; + +/// Team hierarchy links response metadata. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamsHierarchyLinksResponseMeta { + /// Teams hierarchy links response page metadata. + #[serde(rename = "page")] + pub page: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamsHierarchyLinksResponseMeta { + pub fn new() -> TeamsHierarchyLinksResponseMeta { + TeamsHierarchyLinksResponseMeta { + page: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn page( + mut self, + value: crate::datadogV2::model::TeamsHierarchyLinksResponseMetaPage, + ) -> 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 TeamsHierarchyLinksResponseMeta { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamsHierarchyLinksResponseMeta { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamsHierarchyLinksResponseMetaVisitor; + impl<'a> Visitor<'a> for TeamsHierarchyLinksResponseMetaVisitor { + type Value = TeamsHierarchyLinksResponseMeta; + + 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 = TeamsHierarchyLinksResponseMeta { + page, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamsHierarchyLinksResponseMetaVisitor) + } +} diff --git a/src/datadogV2/model/model_teams_hierarchy_links_response_meta_page.rs b/src/datadogV2/model/model_teams_hierarchy_links_response_meta_page.rs new file mode 100644 index 000000000..9b44c790a --- /dev/null +++ b/src/datadogV2/model/model_teams_hierarchy_links_response_meta_page.rs @@ -0,0 +1,228 @@ +// 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}; + +/// Teams hierarchy links response page metadata. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamsHierarchyLinksResponseMetaPage { + /// First page number. + #[serde(rename = "first_number")] + pub first_number: Option, + /// Last page number. + #[serde(rename = "last_number")] + pub last_number: Option, + /// Next page number. + #[serde(rename = "next_number")] + pub next_number: Option, + /// Page number. + #[serde(rename = "number")] + pub number: Option, + /// Previous page number. + #[serde(rename = "prev_number")] + pub prev_number: Option, + /// Page size. + #[serde(rename = "size")] + pub size: Option, + /// Total number of results. + #[serde(rename = "total")] + pub total: Option, + /// Offset type. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamsHierarchyLinksResponseMetaPage { + pub fn new() -> TeamsHierarchyLinksResponseMetaPage { + TeamsHierarchyLinksResponseMetaPage { + 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: i64) -> 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: i64) -> 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 TeamsHierarchyLinksResponseMetaPage { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamsHierarchyLinksResponseMetaPage { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamsHierarchyLinksResponseMetaPageVisitor; + impl<'a> Visitor<'a> for TeamsHierarchyLinksResponseMetaPageVisitor { + type Value = TeamsHierarchyLinksResponseMetaPage; + + 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" => { + if v.is_null() { + continue; + } + 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" => { + if v.is_null() { + continue; + } + 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 = TeamsHierarchyLinksResponseMetaPage { + first_number, + last_number, + next_number, + number, + prev_number, + size, + total, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamsHierarchyLinksResponseMetaPageVisitor) + } +} diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 198c7af1b..52692e0bc 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -1169,6 +1169,18 @@ "tag": "Teams", "operationId": "CreateTeam" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"team_hierarchy_links\",\n \"attributes\": {\n \"created_at\": \"2025-07-16T19:56:30.033205Z\",\n \"provisioned_by\": \"\"\n },\n \"relationships\": {\n \"parent_team\": {\n \"data\": {\n \"id\": \"9f3bae64-7d3b-4f27-8768-9ecb66ddd15f\",\n \"type\": \"team\"\n }\n },\n \"sub_team\": {\n \"data\": {\n \"id\": \"053b5ece-bca2-420a-b303-e07919e979b1\",\n \"type\": \"team\"\n }\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"team_hierarchy_link\" in the system", + "key": "team_hierarchy_link", + "tag": "Teams", + "operationId": "AddTeamHierarchyLink" + }, { "source": "data.data[0]", "step": "there is a valid \"team_connection\" in the system", diff --git a/tests/scenarios/features/v2/teams.feature b/tests/scenarios/features/v2/teams.feature index bf11bd031..460c9aeaf 100644 --- a/tests/scenarios/features/v2/teams.feature +++ b/tests/scenarios/features/v2/teams.feature @@ -43,6 +43,20 @@ Feature: Teams When the request is sent Then the response status is 200 Represents a user's association to a team + @generated @skip @team:DataDog/aaa-omg + Scenario: Create a team hierarchy link returns "CREATED" response + Given new "AddTeamHierarchyLink" request + And body with value {"data": {"relationships": {"parent_team": {"data": {"id": "692e8073-12c4-4c71-8408-5090bd44c9c8", "type": "team"}}, "sub_team": {"data": {"id": "692e8073-12c4-4c71-8408-5090bd44c9c8", "type": "team"}}}, "type": "team_hierarchy_links"}} + When the request is sent + Then the response status is 201 CREATED + + @generated @skip @team:DataDog/aaa-omg + Scenario: Create a team hierarchy link returns "Conflict" response + Given new "AddTeamHierarchyLink" request + And body with value {"data": {"relationships": {"parent_team": {"data": {"id": "692e8073-12c4-4c71-8408-5090bd44c9c8", "type": "team"}}, "sub_team": {"data": {"id": "692e8073-12c4-4c71-8408-5090bd44c9c8", "type": "team"}}}, "type": "team_hierarchy_links"}} + When the request is sent + Then the response status is 409 Conflict + @team:DataDog/aaa-omg Scenario: Create a team link returns "API error response." response Given new "CreateTeamLink" request @@ -96,6 +110,20 @@ Feature: Teams And the response "data.attributes.visible_modules" is equal to ["m1","m2"] And the response "data.attributes.hidden_modules" is equal to ["m3"] + @generated @skip @team:DataDog/aaa-omg + Scenario: Get a team hierarchy link returns "API error response." response + Given new "GetTeamHierarchyLink" request + And request contains "link_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 API error response. + + @generated @skip @team:DataDog/aaa-omg + Scenario: Get a team hierarchy link returns "OK" response + Given new "GetTeamHierarchyLink" request + And request contains "link_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/aaa-omg Scenario: Get a team link returns "API error response." response Given new "GetTeamLink" request @@ -211,6 +239,18 @@ Feature: Teams When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/aaa-omg + Scenario: Get team hierarchy links returns "OK" response + Given new "GetTeamHierarchyLinks" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/aaa-omg @with-pagination + Scenario: Get team hierarchy links returns "OK" response with pagination + Given new "GetTeamHierarchyLinks" request + When the request with pagination is sent + Then the response status is 200 OK + @team:DataDog/aaa-omg Scenario: Get team memberships returns "API error response." response Given new "GetTeamMemberships" request @@ -293,6 +333,20 @@ Feature: Teams When the request is sent Then the response status is 204 No Content + @generated @skip @team:DataDog/aaa-omg + Scenario: Remove a team hierarchy link returns "API error response." response + Given new "RemoveTeamHierarchyLink" request + And request contains "link_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 API error response. + + @generated @skip @team:DataDog/aaa-omg + Scenario: Remove a team hierarchy link returns "No Content" response + Given new "RemoveTeamHierarchyLink" request + And request contains "link_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + @team:DataDog/aaa-omg Scenario: Remove a team link returns "API error response." response Given new "DeleteTeamLink" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 3799e64e6..f037e95f0 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -4345,6 +4345,37 @@ "type": "unsafe" } }, + "GetTeamHierarchyLinks": { + "tag": "Teams", + "undo": { + "type": "safe" + } + }, + "AddTeamHierarchyLink": { + "tag": "Teams", + "undo": { + "operationId": "RemoveTeamHierarchyLink", + "parameters": [ + { + "name": "link_id", + "source": "response" + } + ], + "type": "unsafe" + } + }, + "RemoveTeamHierarchyLink": { + "tag": "Teams", + "undo": { + "type": "idempotent" + } + }, + "GetTeamHierarchyLink": { + "tag": "Teams", + "undo": { + "type": "safe" + } + }, "DeleteTeamConnections": { "tag": "Team Connections", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 4f9cae93a..433bc6787 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -4253,6 +4253,26 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.CreateTeam".into(), test_v2_create_team); + world.function_mappings.insert( + "v2.GetTeamHierarchyLinks".into(), + test_v2_get_team_hierarchy_links, + ); + world.function_mappings.insert( + "v2.GetTeamHierarchyLinksWithPagination".into(), + test_v2_get_team_hierarchy_links_with_pagination, + ); + world.function_mappings.insert( + "v2.AddTeamHierarchyLink".into(), + test_v2_add_team_hierarchy_link, + ); + world.function_mappings.insert( + "v2.RemoveTeamHierarchyLink".into(), + test_v2_remove_team_hierarchy_link, + ); + world.function_mappings.insert( + "v2.GetTeamHierarchyLink".into(), + test_v2_get_team_hierarchy_link, + ); world .function_mappings .insert("v2.GetTeamSync".into(), test_v2_get_team_sync); @@ -32726,6 +32746,181 @@ fn test_v2_create_team(world: &mut DatadogWorld, _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_teams + .as_ref() + .expect("api instance not found"); + let page_number = _parameters + .get("page[number]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_size = _parameters + .get("page[size]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_parent_team = _parameters + .get("filter[parent_team]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_sub_team = _parameters + .get("filter[sub_team]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_teams::GetTeamHierarchyLinksOptionalParams::default(); + params.page_number = page_number; + params.page_size = page_size; + params.filter_parent_team = filter_parent_team; + params.filter_sub_team = filter_sub_team; + let response = match block_on(api.get_team_hierarchy_links_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_get_team_hierarchy_links_with_pagination( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_teams + .as_ref() + .expect("api instance not found"); + let page_number = _parameters + .get("page[number]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_size = _parameters + .get("page[size]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_parent_team = _parameters + .get("filter[parent_team]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_sub_team = _parameters + .get("filter[sub_team]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_teams::GetTeamHierarchyLinksOptionalParams::default(); + params.page_number = page_number; + params.page_size = page_size; + params.filter_parent_team = filter_parent_team; + params.filter_sub_team = filter_sub_team; + let response = api.get_team_hierarchy_links_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_add_team_hierarchy_link(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_teams + .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.add_team_hierarchy_link_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_remove_team_hierarchy_link( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_teams + .as_ref() + .expect("api instance not found"); + let link_id = serde_json::from_value(_parameters.get("link_id").unwrap().clone()).unwrap(); + let response = match block_on(api.remove_team_hierarchy_link_with_http_info(link_id)) { + 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_get_team_hierarchy_link(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_teams + .as_ref() + .expect("api instance not found"); + let link_id = serde_json::from_value(_parameters.get("link_id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_team_hierarchy_link_with_http_info(link_id)) { + 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_get_team_sync(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances