diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index fa9ffba15..2d6b6c945 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -861,6 +861,15 @@ components: schema: example: "00000000-0000-0000-0000-000000000000" type: string + IncidentUserDefinedRoleIDPathParameter: + description: The UUID of the incident user-defined role. + in: path + name: role_id + required: true + schema: + example: "00000000-0000-0000-0000-000000000002" + format: uuid + type: string Include: description: Include relationship data. explode: true @@ -47808,6 +47817,229 @@ components: - display_name - value type: object + IncidentUserDefinedRoleDataAttributesRequest: + description: Attributes for creating an incident user-defined role. + properties: + description: + description: A description of the user-defined role. + example: "The technical lead for the incident." + nullable: true + type: string + name: + description: The name of the user-defined role. + example: "Tech Lead" + type: string + policy: + $ref: "#/components/schemas/IncidentUserDefinedRolePolicy" + required: + - name + - policy + type: object + IncidentUserDefinedRoleDataAttributesResponse: + description: Attributes of an incident user-defined role. + properties: + created: + description: Timestamp when the role was created. + example: "2024-01-01T00:00:00.000Z" + format: date-time + type: string + description: + description: A description of the user-defined role. + example: "The technical lead for the incident." + nullable: true + type: string + modified: + description: Timestamp when the role was last modified. + example: "2024-01-01T00:00:00.000Z" + format: date-time + type: string + name: + description: The name of the user-defined role. + example: "Tech Lead" + type: string + policy: + $ref: "#/components/schemas/IncidentUserDefinedRolePolicy" + required: + - name + - policy + - created + - modified + type: object + IncidentUserDefinedRoleDataRequest: + description: Data for creating an incident user-defined role. + properties: + attributes: + $ref: "#/components/schemas/IncidentUserDefinedRoleDataAttributesRequest" + relationships: + $ref: "#/components/schemas/IncidentUserDefinedRoleRelationshipsRequest" + type: + $ref: "#/components/schemas/IncidentUserDefinedRoleType" + required: + - type + - attributes + - relationships + type: object + IncidentUserDefinedRoleDataResponse: + description: Data for an incident user-defined role response. + properties: + attributes: + $ref: "#/components/schemas/IncidentUserDefinedRoleDataAttributesResponse" + id: + description: The ID of the user-defined role. + example: "00000000-0000-0000-0000-000000000002" + format: uuid + type: string + relationships: + $ref: "#/components/schemas/IncidentUserDefinedRoleRelationshipsResponse" + type: + $ref: "#/components/schemas/IncidentUserDefinedRoleType" + required: + - id + - type + - attributes + type: object + IncidentUserDefinedRoleIncidentTypeRelationship: + description: Relationship to an incident type for a user-defined role. + properties: + data: + $ref: "#/components/schemas/IncidentUserDefinedRoleIncidentTypeRelationshipData" + required: + - data + type: object + IncidentUserDefinedRoleIncidentTypeRelationshipData: + description: Data for the incident type relationship of a user-defined role. + properties: + id: + description: The ID of the incident type. + example: "00000000-0000-0000-0000-000000000001" + format: uuid + type: string + type: + description: The type of the resource. + example: "incident_types" + type: string + required: + - id + - type + type: object + IncidentUserDefinedRoleIncludedItem: + description: A single included resource in a user-defined role response. + oneOf: + - $ref: "#/components/schemas/IncidentUserData" + - $ref: "#/components/schemas/IncidentTypeObject" + IncidentUserDefinedRoleIncludedResponse: + description: Included resources for an incident user-defined role response. + items: + $ref: "#/components/schemas/IncidentUserDefinedRoleIncludedItem" + type: array + IncidentUserDefinedRolePatchDataAttributesRequest: + description: Attributes for updating an incident user-defined role. + properties: + description: + description: A description of the user-defined role. + example: "The technical lead for the incident." + nullable: true + type: string + name: + description: The name of the user-defined role. + example: "Tech Lead" + type: string + policy: + $ref: "#/components/schemas/IncidentUserDefinedRolePolicy" + type: object + IncidentUserDefinedRolePatchDataRequest: + description: Data for updating an incident user-defined role. + properties: + attributes: + $ref: "#/components/schemas/IncidentUserDefinedRolePatchDataAttributesRequest" + id: + description: The ID of the user-defined role to update. + example: "00000000-0000-0000-0000-000000000002" + format: uuid + type: string + type: + $ref: "#/components/schemas/IncidentUserDefinedRoleType" + required: + - id + - type + type: object + IncidentUserDefinedRolePatchRequest: + description: Request for updating an incident user-defined role. + properties: + data: + $ref: "#/components/schemas/IncidentUserDefinedRolePatchDataRequest" + required: + - data + type: object + IncidentUserDefinedRolePolicy: + description: Policy configuration for a user-defined role. + properties: + is_single: + description: Whether this role can only be assigned to one responder at a time. + example: true + type: boolean + required: + - is_single + type: object + IncidentUserDefinedRoleRelationshipsRequest: + description: Relationships for creating a user-defined role. + properties: + incident_type: + $ref: "#/components/schemas/IncidentUserDefinedRoleIncidentTypeRelationship" + required: + - incident_type + type: object + IncidentUserDefinedRoleRelationshipsResponse: + description: Relationships of a user-defined role response. + properties: + created_by_user: + $ref: "#/components/schemas/RelationshipToUser" + incident_type: + $ref: "#/components/schemas/IncidentUserDefinedRoleIncidentTypeRelationship" + last_modified_by_user: + $ref: "#/components/schemas/RelationshipToUser" + type: object + IncidentUserDefinedRoleRequest: + description: Request for creating an incident user-defined role. + properties: + data: + $ref: "#/components/schemas/IncidentUserDefinedRoleDataRequest" + required: + - data + type: object + IncidentUserDefinedRoleResponse: + description: Response with a single incident user-defined role. + properties: + data: + $ref: "#/components/schemas/IncidentUserDefinedRoleDataResponse" + included: + $ref: "#/components/schemas/IncidentUserDefinedRoleIncludedResponse" + required: + - data + type: object + IncidentUserDefinedRoleType: + description: Incident user-defined role resource type. + enum: + - incident_user_defined_roles + example: incident_user_defined_roles + type: string + x-enum-varnames: + - INCIDENT_USER_DEFINED_ROLES + IncidentUserDefinedRolesDataResponse: + description: List of incident user-defined role data objects. + items: + $ref: "#/components/schemas/IncidentUserDefinedRoleDataResponse" + type: array + IncidentUserDefinedRolesResponse: + description: Response with a list of incident user-defined roles. + properties: + data: + $ref: "#/components/schemas/IncidentUserDefinedRolesDataResponse" + included: + $ref: "#/components/schemas/IncidentUserDefinedRoleIncludedResponse" + required: + - data + type: object IncidentsResponse: description: Response with a list of incidents. properties: @@ -140592,6 +140824,303 @@ paths: x-unstable: |- **Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/incidents/config/user-defined-roles: + get: + description: List all user-defined roles for incidents. + operationId: ListIncidentUserDefinedRoles + parameters: + - description: Filter roles by incident type UUID. + in: query + name: filter[incident-type] + required: false + schema: + example: "00000000-0000-0000-0000-000000000001" + format: uuid + type: string + - description: Comma-separated list of related resources to include in the response. + in: query + name: include + required: false + schema: + example: "created_by_user,last_modified_by_user,incident_type" + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + created: "2024-01-01T00:00:00.000Z" + description: "The technical lead for the incident." + modified: "2024-01-01T00:00:00.000Z" + name: "Tech Lead" + policy: + is_single: true + id: "00000000-0000-0000-0000-000000000002" + type: incident_user_defined_roles + schema: + $ref: "#/components/schemas/IncidentUserDefinedRolesResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_settings_read + summary: List incident user-defined roles + tags: + - Incidents + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + post: + description: Create a new user-defined role for incidents. + operationId: CreateIncidentUserDefinedRole + parameters: + - description: Comma-separated list of related resources to include in the response. + in: query + name: include + required: false + schema: + example: "created_by_user,last_modified_by_user,incident_type" + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + description: "The technical lead for the incident." + name: "Tech Lead" + policy: + is_single: true + relationships: + incident_type: + data: + id: "00000000-0000-0000-0000-000000000001" + type: incident_types + type: incident_user_defined_roles + schema: + $ref: "#/components/schemas/IncidentUserDefinedRoleRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + created: "2024-01-01T00:00:00.000Z" + description: "The technical lead for the incident." + modified: "2024-01-01T00:00:00.000Z" + name: "Tech Lead" + policy: + is_single: true + id: "00000000-0000-0000-0000-000000000002" + type: incident_user_defined_roles + schema: + $ref: "#/components/schemas/IncidentUserDefinedRoleResponse" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_settings_write + summary: Create an incident user-defined role + tags: + - Incidents + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/incidents/config/user-defined-roles/{role_id}: + delete: + description: Delete an existing user-defined role for incidents. + operationId: DeleteIncidentUserDefinedRole + parameters: + - $ref: "#/components/parameters/IncidentUserDefinedRoleIDPathParameter" + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_settings_write + summary: Delete an incident user-defined role + tags: + - Incidents + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + get: + description: Retrieve a single user-defined role for incidents. + operationId: GetIncidentUserDefinedRole + parameters: + - $ref: "#/components/parameters/IncidentUserDefinedRoleIDPathParameter" + - description: Comma-separated list of related resources to include in the response. + in: query + name: include + required: false + schema: + example: "created_by_user,last_modified_by_user,incident_type" + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created: "2024-01-01T00:00:00.000Z" + description: "The technical lead for the incident." + modified: "2024-01-01T00:00:00.000Z" + name: "Tech Lead" + policy: + is_single: true + id: "00000000-0000-0000-0000-000000000002" + type: incident_user_defined_roles + schema: + $ref: "#/components/schemas/IncidentUserDefinedRoleResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_settings_read + summary: Get an incident user-defined role + tags: + - Incidents + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + patch: + description: Update an existing user-defined role for incidents. + operationId: UpdateIncidentUserDefinedRole + parameters: + - $ref: "#/components/parameters/IncidentUserDefinedRoleIDPathParameter" + - description: Comma-separated list of related resources to include in the response. + in: query + name: include + required: false + schema: + example: "created_by_user,last_modified_by_user,incident_type" + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + name: "Updated Tech Lead" + id: "00000000-0000-0000-0000-000000000002" + type: incident_user_defined_roles + schema: + $ref: "#/components/schemas/IncidentUserDefinedRolePatchRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created: "2024-01-01T00:00:00.000Z" + modified: "2024-01-02T00:00:00.000Z" + name: "Updated Tech Lead" + policy: + is_single: true + id: "00000000-0000-0000-0000-000000000002" + type: incident_user_defined_roles + schema: + $ref: "#/components/schemas/IncidentUserDefinedRoleResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_settings_write + summary: Update an incident user-defined role + tags: + - Incidents + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/incidents/import: post: description: |- diff --git a/examples/v2_incidents_CreateIncidentUserDefinedRole.rs b/examples/v2_incidents_CreateIncidentUserDefinedRole.rs new file mode 100644 index 000000000..94f38d6de --- /dev/null +++ b/examples/v2_incidents_CreateIncidentUserDefinedRole.rs @@ -0,0 +1,47 @@ +// Create an incident user-defined role returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::CreateIncidentUserDefinedRoleOptionalParams; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRoleDataAttributesRequest; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRoleDataRequest; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRoleIncidentTypeRelationship; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRoleIncidentTypeRelationshipData; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRolePolicy; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRoleRelationshipsRequest; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRoleRequest; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRoleType; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = IncidentUserDefinedRoleRequest::new(IncidentUserDefinedRoleDataRequest::new( + IncidentUserDefinedRoleDataAttributesRequest::new( + "Tech Lead".to_string(), + IncidentUserDefinedRolePolicy::new(true), + ) + .description(Some("The technical lead for the incident.".to_string())), + IncidentUserDefinedRoleRelationshipsRequest::new( + IncidentUserDefinedRoleIncidentTypeRelationship::new( + IncidentUserDefinedRoleIncidentTypeRelationshipData::new( + Uuid::parse_str("00000000-0000-0000-0000-000000000001").expect("invalid UUID"), + "incident_types".to_string(), + ), + ), + ), + IncidentUserDefinedRoleType::INCIDENT_USER_DEFINED_ROLES, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateIncidentUserDefinedRole", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .create_incident_user_defined_role( + body, + CreateIncidentUserDefinedRoleOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_DeleteIncidentUserDefinedRole.rs b/examples/v2_incidents_DeleteIncidentUserDefinedRole.rs new file mode 100644 index 000000000..67cda87e7 --- /dev/null +++ b/examples/v2_incidents_DeleteIncidentUserDefinedRole.rs @@ -0,0 +1,21 @@ +// Delete an incident user-defined role returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteIncidentUserDefinedRole", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .delete_incident_user_defined_role( + Uuid::parse_str("00000000-0000-0000-0000-000000000002").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_GetIncidentUserDefinedRole.rs b/examples/v2_incidents_GetIncidentUserDefinedRole.rs new file mode 100644 index 000000000..fae6663a7 --- /dev/null +++ b/examples/v2_incidents_GetIncidentUserDefinedRole.rs @@ -0,0 +1,23 @@ +// Get an incident user-defined role returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::GetIncidentUserDefinedRoleOptionalParams; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetIncidentUserDefinedRole", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .get_incident_user_defined_role( + Uuid::parse_str("00000000-0000-0000-0000-000000000002").expect("invalid UUID"), + GetIncidentUserDefinedRoleOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_ListIncidentUserDefinedRoles.rs b/examples/v2_incidents_ListIncidentUserDefinedRoles.rs new file mode 100644 index 000000000..5505b9f25 --- /dev/null +++ b/examples/v2_incidents_ListIncidentUserDefinedRoles.rs @@ -0,0 +1,19 @@ +// List incident user-defined roles returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use datadog_api_client::datadogV2::api_incidents::ListIncidentUserDefinedRolesOptionalParams; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListIncidentUserDefinedRoles", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .list_incident_user_defined_roles(ListIncidentUserDefinedRolesOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_UpdateIncidentUserDefinedRole.rs b/examples/v2_incidents_UpdateIncidentUserDefinedRole.rs new file mode 100644 index 000000000..cfb9d8743 --- /dev/null +++ b/examples/v2_incidents_UpdateIncidentUserDefinedRole.rs @@ -0,0 +1,41 @@ +// Update an incident user-defined role returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use datadog_api_client::datadogV2::api_incidents::UpdateIncidentUserDefinedRoleOptionalParams; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRolePatchDataAttributesRequest; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRolePatchDataRequest; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRolePatchRequest; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRolePolicy; +use datadog_api_client::datadogV2::model::IncidentUserDefinedRoleType; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = IncidentUserDefinedRolePatchRequest::new( + IncidentUserDefinedRolePatchDataRequest::new( + Uuid::parse_str("00000000-0000-0000-0000-000000000002").expect("invalid UUID"), + IncidentUserDefinedRoleType::INCIDENT_USER_DEFINED_ROLES, + ) + .attributes( + IncidentUserDefinedRolePatchDataAttributesRequest::new() + .description(Some("The technical lead for the incident.".to_string())) + .name("Tech Lead".to_string()) + .policy(IncidentUserDefinedRolePolicy::new(true)), + ), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateIncidentUserDefinedRole", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .update_incident_user_defined_role( + Uuid::parse_str("00000000-0000-0000-0000-000000000002").expect("invalid UUID"), + body, + UpdateIncidentUserDefinedRoleOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index 8237bbda4..7d27a5f6c 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -596,6 +596,7 @@ impl Default for Configuration { ("v2.create_incident_todo".to_owned(), false), ("v2.create_incident_type".to_owned(), false), ("v2.create_incident_user_defined_field".to_owned(), false), + ("v2.create_incident_user_defined_role".to_owned(), false), ("v2.delete_global_incident_handle".to_owned(), false), ("v2.delete_incident".to_owned(), false), ("v2.delete_incident_attachment".to_owned(), false), @@ -606,6 +607,7 @@ impl Default for Configuration { ("v2.delete_incident_todo".to_owned(), false), ("v2.delete_incident_type".to_owned(), false), ("v2.delete_incident_user_defined_field".to_owned(), false), + ("v2.delete_incident_user_defined_role".to_owned(), false), ("v2.get_global_incident_settings".to_owned(), false), ("v2.get_incident".to_owned(), false), ("v2.get_incident_integration".to_owned(), false), @@ -615,6 +617,7 @@ impl Default for Configuration { ("v2.get_incident_todo".to_owned(), false), ("v2.get_incident_type".to_owned(), false), ("v2.get_incident_user_defined_field".to_owned(), false), + ("v2.get_incident_user_defined_role".to_owned(), false), ("v2.import_incident".to_owned(), false), ("v2.list_global_incident_handles".to_owned(), false), ("v2.list_incident_attachments".to_owned(), false), @@ -626,6 +629,7 @@ impl Default for Configuration { ("v2.list_incident_todos".to_owned(), false), ("v2.list_incident_types".to_owned(), false), ("v2.list_incident_user_defined_fields".to_owned(), false), + ("v2.list_incident_user_defined_roles".to_owned(), false), ("v2.search_incidents".to_owned(), false), ("v2.update_global_incident_handle".to_owned(), false), ("v2.update_global_incident_settings".to_owned(), false), @@ -638,6 +642,7 @@ impl Default for Configuration { ("v2.update_incident_todo".to_owned(), false), ("v2.update_incident_type".to_owned(), false), ("v2.update_incident_user_defined_field".to_owned(), false), + ("v2.update_incident_user_defined_role".to_owned(), false), ("v2.create_aws_account_ccm_config".to_owned(), false), ("v2.delete_aws_account_ccm_config".to_owned(), false), ("v2.get_aws_account_ccm_config".to_owned(), false), diff --git a/src/datadogV2/api/api_incidents.rs b/src/datadogV2/api/api_incidents.rs index 4481da069..fc149e92e 100644 --- a/src/datadogV2/api/api_incidents.rs +++ b/src/datadogV2/api/api_incidents.rs @@ -80,6 +80,22 @@ impl CreateIncidentUserDefinedFieldOptionalParams { } } +/// CreateIncidentUserDefinedRoleOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::create_incident_user_defined_role`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct CreateIncidentUserDefinedRoleOptionalParams { + /// Comma-separated list of related resources to include in the response. + pub include: Option, +} + +impl CreateIncidentUserDefinedRoleOptionalParams { + /// Comma-separated list of related resources to include in the response. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// DeleteIncidentNotificationRuleOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::delete_incident_notification_rule`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -176,6 +192,22 @@ impl GetIncidentUserDefinedFieldOptionalParams { } } +/// GetIncidentUserDefinedRoleOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::get_incident_user_defined_role`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct GetIncidentUserDefinedRoleOptionalParams { + /// Comma-separated list of related resources to include in the response. + pub include: Option, +} + +impl GetIncidentUserDefinedRoleOptionalParams { + /// Comma-separated list of related resources to include in the response. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// ImportIncidentOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::import_incident`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -352,6 +384,29 @@ impl ListIncidentUserDefinedFieldsOptionalParams { } } +/// ListIncidentUserDefinedRolesOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incident_user_defined_roles`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListIncidentUserDefinedRolesOptionalParams { + /// Filter roles by incident type UUID. + pub filter_incident_type: Option, + /// Comma-separated list of related resources to include in the response. + pub include: Option, +} + +impl ListIncidentUserDefinedRolesOptionalParams { + /// Filter roles by incident type UUID. + pub fn filter_incident_type(mut self, value: uuid::Uuid) -> Self { + self.filter_incident_type = Some(value); + self + } + /// Comma-separated list of related resources to include in the response. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// ListIncidentsOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incidents`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -515,6 +570,22 @@ impl UpdateIncidentUserDefinedFieldOptionalParams { } } +/// UpdateIncidentUserDefinedRoleOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::update_incident_user_defined_role`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct UpdateIncidentUserDefinedRoleOptionalParams { + /// Comma-separated list of related resources to include in the response. + pub include: Option, +} + +impl UpdateIncidentUserDefinedRoleOptionalParams { + /// Comma-separated list of related resources to include in the response. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// CreateGlobalIncidentHandleError is a struct for typed errors of method [`IncidentsAPI::create_global_incident_handle`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -615,6 +686,15 @@ pub enum CreateIncidentUserDefinedFieldError { UnknownValue(serde_json::Value), } +/// CreateIncidentUserDefinedRoleError is a struct for typed errors of method [`IncidentsAPI::create_incident_user_defined_role`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateIncidentUserDefinedRoleError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// DeleteGlobalIncidentHandleError is a struct for typed errors of method [`IncidentsAPI::delete_global_incident_handle`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -706,6 +786,15 @@ pub enum DeleteIncidentUserDefinedFieldError { UnknownValue(serde_json::Value), } +/// DeleteIncidentUserDefinedRoleError is a struct for typed errors of method [`IncidentsAPI::delete_incident_user_defined_role`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteIncidentUserDefinedRoleError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetGlobalIncidentSettingsError is a struct for typed errors of method [`IncidentsAPI::get_global_incident_settings`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -781,6 +870,15 @@ pub enum GetIncidentUserDefinedFieldError { UnknownValue(serde_json::Value), } +/// GetIncidentUserDefinedRoleError is a struct for typed errors of method [`IncidentsAPI::get_incident_user_defined_role`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetIncidentUserDefinedRoleError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ImportIncidentError is a struct for typed errors of method [`IncidentsAPI::import_incident`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -872,6 +970,15 @@ pub enum ListIncidentUserDefinedFieldsError { UnknownValue(serde_json::Value), } +/// ListIncidentUserDefinedRolesError is a struct for typed errors of method [`IncidentsAPI::list_incident_user_defined_roles`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListIncidentUserDefinedRolesError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListIncidentsError is a struct for typed errors of method [`IncidentsAPI::list_incidents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -980,6 +1087,15 @@ pub enum UpdateIncidentUserDefinedFieldError { UnknownValue(serde_json::Value), } +/// UpdateIncidentUserDefinedRoleError is a struct for typed errors of method [`IncidentsAPI::update_incident_user_defined_role`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateIncidentUserDefinedRoleError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// Manage incident response, as well as associated attachments, metadata, and todos. See the [Incident Management page]() for more information. #[derive(Debug, Clone)] pub struct IncidentsAPI { @@ -3096,6 +3212,182 @@ impl IncidentsAPI { } } + /// Create a new user-defined role for incidents. + pub async fn create_incident_user_defined_role( + &self, + body: crate::datadogV2::model::IncidentUserDefinedRoleRequest, + params: CreateIncidentUserDefinedRoleOptionalParams, + ) -> Result< + crate::datadogV2::model::IncidentUserDefinedRoleResponse, + datadog::Error, + > { + match self + .create_incident_user_defined_role_with_http_info(body, 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), + } + } + + /// Create a new user-defined role for incidents. + pub async fn create_incident_user_defined_role_with_http_info( + &self, + body: crate::datadogV2::model::IncidentUserDefinedRoleRequest, + params: CreateIncidentUserDefinedRoleOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_incident_user_defined_role"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_incident_user_defined_role' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/incidents/config/user-defined-roles", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + + // 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)), + } + } + #[cfg(feature = "zstd")] + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Delete a global incident handle. pub async fn delete_global_incident_handle( &self, @@ -4205,21 +4497,121 @@ impl IncidentsAPI { } } - /// Retrieve global incident settings for the organization. - pub async fn get_global_incident_settings( + /// Delete an existing user-defined role for incidents. + pub async fn delete_incident_user_defined_role( &self, - ) -> Result< - crate::datadogV2::model::GlobalIncidentSettingsResponse, - datadog::Error, - > { - match self.get_global_incident_settings_with_http_info().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", - ))) + role_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self + .delete_incident_user_defined_role_with_http_info(role_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete an existing user-defined role for incidents. + pub async fn delete_incident_user_defined_role_with_http_info( + &self, + role_id: uuid::Uuid, + ) -> Result, datadog::Error> + { + let local_configuration = &self.config; + let operation_id = "v2.delete_incident_user_defined_role"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_incident_user_defined_role' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/incidents/config/user-defined-roles/{role_id}", + local_configuration.get_operation_host(operation_id), + role_id = datadog::urlencode(role_id.to_string()) + ); + 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)) + } + } + + /// Retrieve global incident settings for the organization. + pub async fn get_global_incident_settings( + &self, + ) -> Result< + crate::datadogV2::model::GlobalIncidentSettingsResponse, + datadog::Error, + > { + match self.get_global_incident_settings_with_http_info().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), @@ -5321,6 +5713,136 @@ impl IncidentsAPI { } } + /// Retrieve a single user-defined role for incidents. + pub async fn get_incident_user_defined_role( + &self, + role_id: uuid::Uuid, + params: GetIncidentUserDefinedRoleOptionalParams, + ) -> Result< + crate::datadogV2::model::IncidentUserDefinedRoleResponse, + datadog::Error, + > { + match self + .get_incident_user_defined_role_with_http_info(role_id, 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), + } + } + + /// Retrieve a single user-defined role for incidents. + pub async fn get_incident_user_defined_role_with_http_info( + &self, + role_id: uuid::Uuid, + params: GetIncidentUserDefinedRoleOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_incident_user_defined_role"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_incident_user_defined_role' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/incidents/config/user-defined-roles/{role_id}", + local_configuration.get_operation_host(operation_id), + role_id = datadog::urlencode(role_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &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)) + } + } + /// Import an incident from an external system. This endpoint allows you to create incidents with /// historical data such as custom timestamps for detection, declaration, and resolution. /// Imported incidents do not execute integrations or notification rules. @@ -6779,6 +7301,138 @@ impl IncidentsAPI { } } + /// List all user-defined roles for incidents. + pub async fn list_incident_user_defined_roles( + &self, + params: ListIncidentUserDefinedRolesOptionalParams, + ) -> Result< + crate::datadogV2::model::IncidentUserDefinedRolesResponse, + datadog::Error, + > { + match self + .list_incident_user_defined_roles_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), + } + } + + /// List all user-defined roles for incidents. + pub async fn list_incident_user_defined_roles_with_http_info( + &self, + params: ListIncidentUserDefinedRolesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_incident_user_defined_roles"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_incident_user_defined_roles' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let filter_incident_type = params.filter_incident_type; + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/incidents/config/user-defined-roles", + 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) = filter_incident_type { + local_req_builder = local_req_builder + .query(&[("filter[incident-type]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &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 all incidents for the user's organization. pub async fn list_incidents( &self, @@ -9053,4 +9707,183 @@ impl IncidentsAPI { Err(datadog::Error::ResponseError(local_error)) } } + + /// Update an existing user-defined role for incidents. + pub async fn update_incident_user_defined_role( + &self, + role_id: uuid::Uuid, + body: crate::datadogV2::model::IncidentUserDefinedRolePatchRequest, + params: UpdateIncidentUserDefinedRoleOptionalParams, + ) -> Result< + crate::datadogV2::model::IncidentUserDefinedRoleResponse, + datadog::Error, + > { + match self + .update_incident_user_defined_role_with_http_info(role_id, body, 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), + } + } + + /// Update an existing user-defined role for incidents. + pub async fn update_incident_user_defined_role_with_http_info( + &self, + role_id: uuid::Uuid, + body: crate::datadogV2::model::IncidentUserDefinedRolePatchRequest, + params: UpdateIncidentUserDefinedRoleOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_incident_user_defined_role"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.update_incident_user_defined_role' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/incidents/config/user-defined-roles/{role_id}", + local_configuration.get_operation_host(operation_id), + role_id = datadog::urlencode(role_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + + // 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)), + } + } + #[cfg(feature = "zstd")] + "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)) + } + } } diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 9e8c535d6..74cc86729 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -4636,6 +4636,40 @@ pub mod model_incident_user_defined_field_update_data; pub use self::model_incident_user_defined_field_update_data::IncidentUserDefinedFieldUpdateData; pub mod model_incident_user_defined_field_attributes_update_request; pub use self::model_incident_user_defined_field_attributes_update_request::IncidentUserDefinedFieldAttributesUpdateRequest; +pub mod model_incident_user_defined_roles_response; +pub use self::model_incident_user_defined_roles_response::IncidentUserDefinedRolesResponse; +pub mod model_incident_user_defined_role_data_response; +pub use self::model_incident_user_defined_role_data_response::IncidentUserDefinedRoleDataResponse; +pub mod model_incident_user_defined_role_data_attributes_response; +pub use self::model_incident_user_defined_role_data_attributes_response::IncidentUserDefinedRoleDataAttributesResponse; +pub mod model_incident_user_defined_role_policy; +pub use self::model_incident_user_defined_role_policy::IncidentUserDefinedRolePolicy; +pub mod model_incident_user_defined_role_relationships_response; +pub use self::model_incident_user_defined_role_relationships_response::IncidentUserDefinedRoleRelationshipsResponse; +pub mod model_incident_user_defined_role_incident_type_relationship; +pub use self::model_incident_user_defined_role_incident_type_relationship::IncidentUserDefinedRoleIncidentTypeRelationship; +pub mod model_incident_user_defined_role_incident_type_relationship_data; +pub use self::model_incident_user_defined_role_incident_type_relationship_data::IncidentUserDefinedRoleIncidentTypeRelationshipData; +pub mod model_incident_user_defined_role_type; +pub use self::model_incident_user_defined_role_type::IncidentUserDefinedRoleType; +pub mod model_incident_user_defined_role_included_item; +pub use self::model_incident_user_defined_role_included_item::IncidentUserDefinedRoleIncludedItem; +pub mod model_incident_user_defined_role_request; +pub use self::model_incident_user_defined_role_request::IncidentUserDefinedRoleRequest; +pub mod model_incident_user_defined_role_data_request; +pub use self::model_incident_user_defined_role_data_request::IncidentUserDefinedRoleDataRequest; +pub mod model_incident_user_defined_role_data_attributes_request; +pub use self::model_incident_user_defined_role_data_attributes_request::IncidentUserDefinedRoleDataAttributesRequest; +pub mod model_incident_user_defined_role_relationships_request; +pub use self::model_incident_user_defined_role_relationships_request::IncidentUserDefinedRoleRelationshipsRequest; +pub mod model_incident_user_defined_role_response; +pub use self::model_incident_user_defined_role_response::IncidentUserDefinedRoleResponse; +pub mod model_incident_user_defined_role_patch_request; +pub use self::model_incident_user_defined_role_patch_request::IncidentUserDefinedRolePatchRequest; +pub mod model_incident_user_defined_role_patch_data_request; +pub use self::model_incident_user_defined_role_patch_data_request::IncidentUserDefinedRolePatchDataRequest; +pub mod model_incident_user_defined_role_patch_data_attributes_request; +pub use self::model_incident_user_defined_role_patch_data_attributes_request::IncidentUserDefinedRolePatchDataAttributesRequest; pub mod model_incident_import_related_object; pub use self::model_incident_import_related_object::IncidentImportRelatedObject; pub mod model_incident_import_request; diff --git a/src/datadogV2/model/model_incident_user_defined_role_data_attributes_request.rs b/src/datadogV2/model/model_incident_user_defined_role_data_attributes_request.rs new file mode 100644 index 000000000..0b3391843 --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_data_attributes_request.rs @@ -0,0 +1,125 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for creating an incident user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRoleDataAttributesRequest { + /// A description of the user-defined role. + #[serde( + rename = "description", + default, + with = "::serde_with::rust::double_option" + )] + pub description: Option>, + /// The name of the user-defined role. + #[serde(rename = "name")] + pub name: String, + /// Policy configuration for a user-defined role. + #[serde(rename = "policy")] + pub policy: crate::datadogV2::model::IncidentUserDefinedRolePolicy, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRoleDataAttributesRequest { + pub fn new( + name: String, + policy: crate::datadogV2::model::IncidentUserDefinedRolePolicy, + ) -> IncidentUserDefinedRoleDataAttributesRequest { + IncidentUserDefinedRoleDataAttributesRequest { + description: None, + name, + policy, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: Option) -> Self { + self.description = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for IncidentUserDefinedRoleDataAttributesRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRoleDataAttributesRequestVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRoleDataAttributesRequestVisitor { + type Value = IncidentUserDefinedRoleDataAttributesRequest; + + 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 description: Option> = None; + let mut name: Option = None; + let mut policy: 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() { + "description" => { + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "policy" => { + policy = 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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let policy = policy.ok_or_else(|| M::Error::missing_field("policy"))?; + + let content = IncidentUserDefinedRoleDataAttributesRequest { + description, + name, + policy, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRoleDataAttributesRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_data_attributes_response.rs b/src/datadogV2/model/model_incident_user_defined_role_data_attributes_response.rs new file mode 100644 index 000000000..cf6613db3 --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_data_attributes_response.rs @@ -0,0 +1,147 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of an incident user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRoleDataAttributesResponse { + /// Timestamp when the role was created. + #[serde(rename = "created")] + pub created: chrono::DateTime, + /// A description of the user-defined role. + #[serde( + rename = "description", + default, + with = "::serde_with::rust::double_option" + )] + pub description: Option>, + /// Timestamp when the role was last modified. + #[serde(rename = "modified")] + pub modified: chrono::DateTime, + /// The name of the user-defined role. + #[serde(rename = "name")] + pub name: String, + /// Policy configuration for a user-defined role. + #[serde(rename = "policy")] + pub policy: crate::datadogV2::model::IncidentUserDefinedRolePolicy, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRoleDataAttributesResponse { + pub fn new( + created: chrono::DateTime, + modified: chrono::DateTime, + name: String, + policy: crate::datadogV2::model::IncidentUserDefinedRolePolicy, + ) -> IncidentUserDefinedRoleDataAttributesResponse { + IncidentUserDefinedRoleDataAttributesResponse { + created, + description: None, + modified, + name, + policy, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: Option) -> Self { + self.description = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for IncidentUserDefinedRoleDataAttributesResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRoleDataAttributesResponseVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRoleDataAttributesResponseVisitor { + type Value = IncidentUserDefinedRoleDataAttributesResponse; + + 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: Option> = None; + let mut description: Option> = None; + let mut modified: Option> = None; + let mut name: Option = None; + let mut policy: 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" => { + created = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "description" => { + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified" => { + modified = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "policy" => { + policy = 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 = created.ok_or_else(|| M::Error::missing_field("created"))?; + let modified = modified.ok_or_else(|| M::Error::missing_field("modified"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let policy = policy.ok_or_else(|| M::Error::missing_field("policy"))?; + + let content = IncidentUserDefinedRoleDataAttributesResponse { + created, + description, + modified, + name, + policy, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRoleDataAttributesResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_data_request.rs b/src/datadogV2/model/model_incident_user_defined_role_data_request.rs new file mode 100644 index 000000000..4f53110ec --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_data_request.rs @@ -0,0 +1,130 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data for creating an incident user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRoleDataRequest { + /// Attributes for creating an incident user-defined role. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::IncidentUserDefinedRoleDataAttributesRequest, + /// Relationships for creating a user-defined role. + #[serde(rename = "relationships")] + pub relationships: crate::datadogV2::model::IncidentUserDefinedRoleRelationshipsRequest, + /// Incident user-defined role resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentUserDefinedRoleType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRoleDataRequest { + pub fn new( + attributes: crate::datadogV2::model::IncidentUserDefinedRoleDataAttributesRequest, + relationships: crate::datadogV2::model::IncidentUserDefinedRoleRelationshipsRequest, + type_: crate::datadogV2::model::IncidentUserDefinedRoleType, + ) -> IncidentUserDefinedRoleDataRequest { + IncidentUserDefinedRoleDataRequest { + attributes, + 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 IncidentUserDefinedRoleDataRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRoleDataRequestVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRoleDataRequestVisitor { + type Value = IncidentUserDefinedRoleDataRequest; + + 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::IncidentUserDefinedRoleDataAttributesRequest, + > = None; + let mut relationships: Option< + crate::datadogV2::model::IncidentUserDefinedRoleRelationshipsRequest, + > = 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)?); + } + "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::IncidentUserDefinedRoleType::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 relationships = + relationships.ok_or_else(|| M::Error::missing_field("relationships"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = IncidentUserDefinedRoleDataRequest { + attributes, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRoleDataRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_data_response.rs b/src/datadogV2/model/model_incident_user_defined_role_data_response.rs new file mode 100644 index 000000000..1d7f5f74c --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_data_response.rs @@ -0,0 +1,150 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data for an incident user-defined role response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRoleDataResponse { + /// Attributes of an incident user-defined role. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::IncidentUserDefinedRoleDataAttributesResponse, + /// The ID of the user-defined role. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Relationships of a user-defined role response. + #[serde(rename = "relationships")] + pub relationships: + Option, + /// Incident user-defined role resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentUserDefinedRoleType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRoleDataResponse { + pub fn new( + attributes: crate::datadogV2::model::IncidentUserDefinedRoleDataAttributesResponse, + id: uuid::Uuid, + type_: crate::datadogV2::model::IncidentUserDefinedRoleType, + ) -> IncidentUserDefinedRoleDataResponse { + IncidentUserDefinedRoleDataResponse { + attributes, + id, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::IncidentUserDefinedRoleRelationshipsResponse, + ) -> 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 IncidentUserDefinedRoleDataResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRoleDataResponseVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRoleDataResponseVisitor { + type Value = IncidentUserDefinedRoleDataResponse; + + 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::IncidentUserDefinedRoleDataAttributesResponse, + > = None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::IncidentUserDefinedRoleRelationshipsResponse, + > = 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::IncidentUserDefinedRoleType::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 = IncidentUserDefinedRoleDataResponse { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRoleDataResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_incident_type_relationship.rs b/src/datadogV2/model/model_incident_user_defined_role_incident_type_relationship.rs new file mode 100644 index 000000000..be9cb799f --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_incident_type_relationship.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Relationship to an incident type for a user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRoleIncidentTypeRelationship { + /// Data for the incident type relationship of a user-defined role. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IncidentUserDefinedRoleIncidentTypeRelationshipData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRoleIncidentTypeRelationship { + pub fn new( + data: crate::datadogV2::model::IncidentUserDefinedRoleIncidentTypeRelationshipData, + ) -> IncidentUserDefinedRoleIncidentTypeRelationship { + IncidentUserDefinedRoleIncidentTypeRelationship { + 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 IncidentUserDefinedRoleIncidentTypeRelationship { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRoleIncidentTypeRelationshipVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRoleIncidentTypeRelationshipVisitor { + type Value = IncidentUserDefinedRoleIncidentTypeRelationship; + + 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< + crate::datadogV2::model::IncidentUserDefinedRoleIncidentTypeRelationshipData, + > = 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 = IncidentUserDefinedRoleIncidentTypeRelationship { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRoleIncidentTypeRelationshipVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_incident_type_relationship_data.rs b/src/datadogV2/model/model_incident_user_defined_role_incident_type_relationship_data.rs new file mode 100644 index 000000000..a9c94207d --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_incident_type_relationship_data.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data for the incident type relationship of a user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRoleIncidentTypeRelationshipData { + /// The ID of the incident type. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The type of the resource. + #[serde(rename = "type")] + pub type_: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRoleIncidentTypeRelationshipData { + pub fn new( + id: uuid::Uuid, + type_: String, + ) -> IncidentUserDefinedRoleIncidentTypeRelationshipData { + IncidentUserDefinedRoleIncidentTypeRelationshipData { + 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 IncidentUserDefinedRoleIncidentTypeRelationshipData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRoleIncidentTypeRelationshipDataVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRoleIncidentTypeRelationshipDataVisitor { + type Value = IncidentUserDefinedRoleIncidentTypeRelationshipData; + + 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 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 = IncidentUserDefinedRoleIncidentTypeRelationshipData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRoleIncidentTypeRelationshipDataVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_included_item.rs b/src/datadogV2/model/model_incident_user_defined_role_included_item.rs new file mode 100644 index 000000000..dc6099414 --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_included_item.rs @@ -0,0 +1,41 @@ +// 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}; + +/// A single included resource in a user-defined role response. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum IncidentUserDefinedRoleIncludedItem { + IncidentUserData(Box), + IncidentTypeObject(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for IncidentUserDefinedRoleIncludedItem { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(IncidentUserDefinedRoleIncludedItem::IncidentUserData(_v)); + } + } + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(IncidentUserDefinedRoleIncludedItem::IncidentTypeObject(_v)); + } + } + + return Ok(IncidentUserDefinedRoleIncludedItem::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_patch_data_attributes_request.rs b/src/datadogV2/model/model_incident_user_defined_role_patch_data_attributes_request.rs new file mode 100644 index 000000000..819a9ac5b --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_patch_data_attributes_request.rs @@ -0,0 +1,142 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for updating an incident user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRolePatchDataAttributesRequest { + /// A description of the user-defined role. + #[serde( + rename = "description", + default, + with = "::serde_with::rust::double_option" + )] + pub description: Option>, + /// The name of the user-defined role. + #[serde(rename = "name")] + pub name: Option, + /// Policy configuration for a user-defined role. + #[serde(rename = "policy")] + pub policy: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRolePatchDataAttributesRequest { + pub fn new() -> IncidentUserDefinedRolePatchDataAttributesRequest { + IncidentUserDefinedRolePatchDataAttributesRequest { + description: None, + name: None, + policy: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: Option) -> Self { + self.description = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn policy(mut self, value: crate::datadogV2::model::IncidentUserDefinedRolePolicy) -> Self { + self.policy = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for IncidentUserDefinedRolePatchDataAttributesRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for IncidentUserDefinedRolePatchDataAttributesRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRolePatchDataAttributesRequestVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRolePatchDataAttributesRequestVisitor { + type Value = IncidentUserDefinedRolePatchDataAttributesRequest; + + 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 description: Option> = None; + let mut name: Option = None; + let mut policy: 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() { + "description" => { + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "policy" => { + if v.is_null() { + continue; + } + policy = 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 = IncidentUserDefinedRolePatchDataAttributesRequest { + description, + name, + policy, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRolePatchDataAttributesRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_patch_data_request.rs b/src/datadogV2/model/model_incident_user_defined_role_patch_data_request.rs new file mode 100644 index 000000000..bcffde4b5 --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_patch_data_request.rs @@ -0,0 +1,136 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data for updating an incident user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRolePatchDataRequest { + /// Attributes for updating an incident user-defined role. + #[serde(rename = "attributes")] + pub attributes: + Option, + /// The ID of the user-defined role to update. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Incident user-defined role resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentUserDefinedRoleType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRolePatchDataRequest { + pub fn new( + id: uuid::Uuid, + type_: crate::datadogV2::model::IncidentUserDefinedRoleType, + ) -> IncidentUserDefinedRolePatchDataRequest { + IncidentUserDefinedRolePatchDataRequest { + attributes: None, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::IncidentUserDefinedRolePatchDataAttributesRequest, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for IncidentUserDefinedRolePatchDataRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRolePatchDataRequestVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRolePatchDataRequestVisitor { + type Value = IncidentUserDefinedRolePatchDataRequest; + + 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::IncidentUserDefinedRolePatchDataAttributesRequest, + > = 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" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::IncidentUserDefinedRoleType::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 = IncidentUserDefinedRolePatchDataRequest { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRolePatchDataRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_patch_request.rs b/src/datadogV2/model/model_incident_user_defined_role_patch_request.rs new file mode 100644 index 000000000..3c29036b0 --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_patch_request.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request for updating an incident user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRolePatchRequest { + /// Data for updating an incident user-defined role. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IncidentUserDefinedRolePatchDataRequest, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRolePatchRequest { + pub fn new( + data: crate::datadogV2::model::IncidentUserDefinedRolePatchDataRequest, + ) -> IncidentUserDefinedRolePatchRequest { + IncidentUserDefinedRolePatchRequest { + 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 IncidentUserDefinedRolePatchRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRolePatchRequestVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRolePatchRequestVisitor { + type Value = IncidentUserDefinedRolePatchRequest; + + 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< + crate::datadogV2::model::IncidentUserDefinedRolePatchDataRequest, + > = 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 = IncidentUserDefinedRolePatchRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRolePatchRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_policy.rs b/src/datadogV2/model/model_incident_user_defined_role_policy.rs new file mode 100644 index 000000000..e121b1377 --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_policy.rs @@ -0,0 +1,92 @@ +// 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}; + +/// Policy configuration for a user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRolePolicy { + /// Whether this role can only be assigned to one responder at a time. + #[serde(rename = "is_single")] + pub is_single: bool, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRolePolicy { + pub fn new(is_single: bool) -> IncidentUserDefinedRolePolicy { + IncidentUserDefinedRolePolicy { + is_single, + 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 IncidentUserDefinedRolePolicy { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRolePolicyVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRolePolicyVisitor { + type Value = IncidentUserDefinedRolePolicy; + + 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 is_single: 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() { + "is_single" => { + is_single = 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 is_single = is_single.ok_or_else(|| M::Error::missing_field("is_single"))?; + + let content = IncidentUserDefinedRolePolicy { + is_single, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRolePolicyVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_relationships_request.rs b/src/datadogV2/model/model_incident_user_defined_role_relationships_request.rs new file mode 100644 index 000000000..871a3734e --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_relationships_request.rs @@ -0,0 +1,98 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Relationships for creating a user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRoleRelationshipsRequest { + /// Relationship to an incident type for a user-defined role. + #[serde(rename = "incident_type")] + pub incident_type: crate::datadogV2::model::IncidentUserDefinedRoleIncidentTypeRelationship, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRoleRelationshipsRequest { + pub fn new( + incident_type: crate::datadogV2::model::IncidentUserDefinedRoleIncidentTypeRelationship, + ) -> IncidentUserDefinedRoleRelationshipsRequest { + IncidentUserDefinedRoleRelationshipsRequest { + incident_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 IncidentUserDefinedRoleRelationshipsRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRoleRelationshipsRequestVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRoleRelationshipsRequestVisitor { + type Value = IncidentUserDefinedRoleRelationshipsRequest; + + 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 incident_type: Option< + crate::datadogV2::model::IncidentUserDefinedRoleIncidentTypeRelationship, + > = 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() { + "incident_type" => { + incident_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 incident_type = + incident_type.ok_or_else(|| M::Error::missing_field("incident_type"))?; + + let content = IncidentUserDefinedRoleRelationshipsRequest { + incident_type, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRoleRelationshipsRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_relationships_response.rs b/src/datadogV2/model/model_incident_user_defined_role_relationships_response.rs new file mode 100644 index 000000000..65e37a92b --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_relationships_response.rs @@ -0,0 +1,152 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Relationships of a user-defined role response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRoleRelationshipsResponse { + /// Relationship to user. + #[serde(rename = "created_by_user")] + pub created_by_user: Option, + /// Relationship to an incident type for a user-defined role. + #[serde(rename = "incident_type")] + pub incident_type: + Option, + /// Relationship to user. + #[serde(rename = "last_modified_by_user")] + pub last_modified_by_user: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRoleRelationshipsResponse { + pub fn new() -> IncidentUserDefinedRoleRelationshipsResponse { + IncidentUserDefinedRoleRelationshipsResponse { + created_by_user: None, + incident_type: None, + last_modified_by_user: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn created_by_user(mut self, value: crate::datadogV2::model::RelationshipToUser) -> Self { + self.created_by_user = Some(value); + self + } + + pub fn incident_type( + mut self, + value: crate::datadogV2::model::IncidentUserDefinedRoleIncidentTypeRelationship, + ) -> Self { + self.incident_type = Some(value); + self + } + + pub fn last_modified_by_user( + mut self, + value: crate::datadogV2::model::RelationshipToUser, + ) -> Self { + self.last_modified_by_user = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for IncidentUserDefinedRoleRelationshipsResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for IncidentUserDefinedRoleRelationshipsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRoleRelationshipsResponseVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRoleRelationshipsResponseVisitor { + type Value = IncidentUserDefinedRoleRelationshipsResponse; + + 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_by_user: Option = None; + let mut incident_type: Option< + crate::datadogV2::model::IncidentUserDefinedRoleIncidentTypeRelationship, + > = None; + let mut last_modified_by_user: 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_by_user" => { + if v.is_null() { + continue; + } + created_by_user = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "incident_type" => { + if v.is_null() { + continue; + } + incident_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last_modified_by_user" => { + if v.is_null() { + continue; + } + last_modified_by_user = + 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 = IncidentUserDefinedRoleRelationshipsResponse { + created_by_user, + incident_type, + last_modified_by_user, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRoleRelationshipsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_request.rs b/src/datadogV2/model/model_incident_user_defined_role_request.rs new file mode 100644 index 000000000..8501017a5 --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_request.rs @@ -0,0 +1,95 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request for creating an incident user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRoleRequest { + /// Data for creating an incident user-defined role. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IncidentUserDefinedRoleDataRequest, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRoleRequest { + pub fn new( + data: crate::datadogV2::model::IncidentUserDefinedRoleDataRequest, + ) -> IncidentUserDefinedRoleRequest { + IncidentUserDefinedRoleRequest { + 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 IncidentUserDefinedRoleRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRoleRequestVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRoleRequestVisitor { + type Value = IncidentUserDefinedRoleRequest; + + 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 = IncidentUserDefinedRoleRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRoleRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_response.rs b/src/datadogV2/model/model_incident_user_defined_role_response.rs new file mode 100644 index 000000000..b2332971f --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_response.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}; + +/// Response with a single incident user-defined role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRoleResponse { + /// Data for an incident user-defined role response. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IncidentUserDefinedRoleDataResponse, + /// Included resources for an incident user-defined role response. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRoleResponse { + pub fn new( + data: crate::datadogV2::model::IncidentUserDefinedRoleDataResponse, + ) -> IncidentUserDefinedRoleResponse { + IncidentUserDefinedRoleResponse { + data, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + 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<'de> Deserialize<'de> for IncidentUserDefinedRoleResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRoleResponseVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRoleResponseVisitor { + type Value = IncidentUserDefinedRoleResponse; + + 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< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "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 data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = IncidentUserDefinedRoleResponse { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRoleResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_role_type.rs b/src/datadogV2/model/model_incident_user_defined_role_type.rs new file mode 100644 index 000000000..2384c3afe --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_role_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 IncidentUserDefinedRoleType { + INCIDENT_USER_DEFINED_ROLES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for IncidentUserDefinedRoleType { + fn to_string(&self) -> String { + match self { + Self::INCIDENT_USER_DEFINED_ROLES => String::from("incident_user_defined_roles"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for IncidentUserDefinedRoleType { + 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 IncidentUserDefinedRoleType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "incident_user_defined_roles" => Self::INCIDENT_USER_DEFINED_ROLES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_incident_user_defined_roles_response.rs b/src/datadogV2/model/model_incident_user_defined_roles_response.rs new file mode 100644 index 000000000..f3e38d851 --- /dev/null +++ b/src/datadogV2/model/model_incident_user_defined_roles_response.rs @@ -0,0 +1,118 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response with a list of incident user-defined roles. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentUserDefinedRolesResponse { + /// List of incident user-defined role data objects. + #[serde(rename = "data")] + pub data: Vec, + /// Included resources for an incident user-defined role response. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentUserDefinedRolesResponse { + pub fn new( + data: Vec, + ) -> IncidentUserDefinedRolesResponse { + IncidentUserDefinedRolesResponse { + data, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + 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<'de> Deserialize<'de> for IncidentUserDefinedRolesResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentUserDefinedRolesResponseVisitor; + impl<'a> Visitor<'a> for IncidentUserDefinedRolesResponseVisitor { + type Value = IncidentUserDefinedRolesResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + Vec, + > = None; + let mut included: Option< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "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 data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = IncidentUserDefinedRolesResponse { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentUserDefinedRolesResponseVisitor) + } +} diff --git a/tests/scenarios/features/v2/incidents.feature b/tests/scenarios/features/v2/incidents.feature index 62c70d5c5..1b993a1ff 100644 --- a/tests/scenarios/features/v2/incidents.feature +++ b/tests/scenarios/features/v2/incidents.feature @@ -210,6 +210,22 @@ Feature: Incidents When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app + Scenario: Create an incident user-defined role returns "Bad Request" response + Given operation "CreateIncidentUserDefinedRole" enabled + And new "CreateIncidentUserDefinedRole" request + And body with value {"data": {"attributes": {"description": "The technical lead for the incident.", "name": "Tech Lead", "policy": {"is_single": true}}, "relationships": {"incident_type": {"data": {"id": "00000000-0000-0000-0000-000000000001", "type": "incident_types"}}}, "type": "incident_user_defined_roles"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Create an incident user-defined role returns "Created" response + Given operation "CreateIncidentUserDefinedRole" enabled + And new "CreateIncidentUserDefinedRole" request + And body with value {"data": {"attributes": {"description": "The technical lead for the incident.", "name": "Tech Lead", "policy": {"is_single": true}}, "relationships": {"incident_type": {"data": {"id": "00000000-0000-0000-0000-000000000001", "type": "incident_types"}}}, "type": "incident_user_defined_roles"}} + When the request is sent + Then the response status is 201 Created + @generated @skip @team:DataDog/incident-app Scenario: Create global incident handle returns "Bad Request" response Given operation "CreateGlobalIncidentHandle" enabled @@ -530,6 +546,30 @@ Feature: Incidents When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app + Scenario: Delete an incident user-defined role returns "Bad Request" response + Given operation "DeleteIncidentUserDefinedRole" enabled + And new "DeleteIncidentUserDefinedRole" request + And request contains "role_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Delete an incident user-defined role returns "No Content" response + Given operation "DeleteIncidentUserDefinedRole" enabled + And new "DeleteIncidentUserDefinedRole" request + And request contains "role_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/incident-app + Scenario: Delete an incident user-defined role returns "Not Found" response + Given operation "DeleteIncidentUserDefinedRole" enabled + And new "DeleteIncidentUserDefinedRole" request + And request contains "role_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app Scenario: Delete global incident handle returns "Bad Request" response Given operation "DeleteGlobalIncidentHandle" enabled @@ -781,6 +821,30 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: Get an incident user-defined role returns "Bad Request" response + Given operation "GetIncidentUserDefinedRole" enabled + And new "GetIncidentUserDefinedRole" request + And request contains "role_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Get an incident user-defined role returns "Not Found" response + Given operation "GetIncidentUserDefinedRole" enabled + And new "GetIncidentUserDefinedRole" request + And request contains "role_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/incident-app + Scenario: Get an incident user-defined role returns "OK" response + Given operation "GetIncidentUserDefinedRole" enabled + And new "GetIncidentUserDefinedRole" request + And request contains "role_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app Scenario: Get global incident settings returns "Bad Request" response Given operation "GetGlobalIncidentSettings" enabled @@ -1108,6 +1172,20 @@ Feature: Incidents Then the response status is 200 OK And the response "data" has length 0 + @generated @skip @team:DataDog/incident-app + Scenario: List incident user-defined roles returns "Bad Request" response + Given operation "ListIncidentUserDefinedRoles" enabled + And new "ListIncidentUserDefinedRoles" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: List incident user-defined roles returns "OK" response + Given operation "ListIncidentUserDefinedRoles" enabled + And new "ListIncidentUserDefinedRoles" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app Scenario: List postmortem templates returns "Bad Request" response Given operation "ListIncidentPostmortemTemplates" enabled @@ -1348,6 +1426,33 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: Update an incident user-defined role returns "Bad Request" response + Given operation "UpdateIncidentUserDefinedRole" enabled + And new "UpdateIncidentUserDefinedRole" request + And request contains "role_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "The technical lead for the incident.", "name": "Tech Lead", "policy": {"is_single": true}}, "id": "00000000-0000-0000-0000-000000000002", "type": "incident_user_defined_roles"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Update an incident user-defined role returns "Not Found" response + Given operation "UpdateIncidentUserDefinedRole" enabled + And new "UpdateIncidentUserDefinedRole" request + And request contains "role_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "The technical lead for the incident.", "name": "Tech Lead", "policy": {"is_single": true}}, "id": "00000000-0000-0000-0000-000000000002", "type": "incident_user_defined_roles"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/incident-app + Scenario: Update an incident user-defined role returns "OK" response + Given operation "UpdateIncidentUserDefinedRole" enabled + And new "UpdateIncidentUserDefinedRole" request + And request contains "role_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "The technical lead for the incident.", "name": "Tech Lead", "policy": {"is_single": true}}, "id": "00000000-0000-0000-0000-000000000002", "type": "incident_user_defined_roles"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app Scenario: Update global incident handle returns "Bad Request" response Given operation "UpdateGlobalIncidentHandle" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index cbfa3f207..034389914 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -3115,6 +3115,43 @@ "type": "idempotent" } }, + "ListIncidentUserDefinedRoles": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "CreateIncidentUserDefinedRole": { + "tag": "Incidents", + "undo": { + "operationId": "DeleteIncidentUserDefinedRole", + "parameters": [ + { + "name": "role_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteIncidentUserDefinedRole": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "GetIncidentUserDefinedRole": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "UpdateIncidentUserDefinedRole": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, "ImportIncident": { "tag": "Incidents", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 6a3273dce..6c59880c3 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -5082,6 +5082,26 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.UpdateIncidentUserDefinedField".into(), test_v2_update_incident_user_defined_field, ); + world.function_mappings.insert( + "v2.ListIncidentUserDefinedRoles".into(), + test_v2_list_incident_user_defined_roles, + ); + world.function_mappings.insert( + "v2.CreateIncidentUserDefinedRole".into(), + test_v2_create_incident_user_defined_role, + ); + world.function_mappings.insert( + "v2.DeleteIncidentUserDefinedRole".into(), + test_v2_delete_incident_user_defined_role, + ); + world.function_mappings.insert( + "v2.GetIncidentUserDefinedRole".into(), + test_v2_get_incident_user_defined_role, + ); + world.function_mappings.insert( + "v2.UpdateIncidentUserDefinedRole".into(), + test_v2_update_incident_user_defined_role, + ); world .function_mappings .insert("v2.ImportIncident".into(), test_v2_import_incident); @@ -39015,6 +39035,177 @@ fn test_v2_update_incident_user_defined_field( world.response.code = response.status.as_u16(); } +fn test_v2_list_incident_user_defined_roles( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let filter_incident_type = _parameters + .get("filter[incident-type]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_incidents::ListIncidentUserDefinedRolesOptionalParams::default(); + params.filter_incident_type = filter_incident_type; + params.include = include; + let response = match block_on(api.list_incident_user_defined_roles_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_create_incident_user_defined_role( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_incidents::CreateIncidentUserDefinedRoleOptionalParams::default(); + params.include = include; + let response = + match block_on(api.create_incident_user_defined_role_with_http_info(body, 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_delete_incident_user_defined_role( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let role_id = serde_json::from_value(_parameters.get("role_id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_incident_user_defined_role_with_http_info(role_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_incident_user_defined_role( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let role_id = serde_json::from_value(_parameters.get("role_id").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_incidents::GetIncidentUserDefinedRoleOptionalParams::default(); + params.include = include; + let response = + match block_on(api.get_incident_user_defined_role_with_http_info(role_id, 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_update_incident_user_defined_role( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let role_id = serde_json::from_value(_parameters.get("role_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_incidents::UpdateIncidentUserDefinedRoleOptionalParams::default(); + params.include = include; + let response = + match block_on(api.update_incident_user_defined_role_with_http_info(role_id, body, 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_import_incident(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances