diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index cfbcb7286..5fbf15ba4 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -178,6 +178,15 @@ components: required: true schema: type: string + AttachmentIncludeQueryParameter: + description: 'Resource to include in the response. Supported value: `last_modified_by_user`.' + explode: false + in: query + name: include + required: false + schema: + example: last_modified_by_user + type: string AuthNMappingID: description: The UUID of the AuthN Mapping. in: path @@ -458,26 +467,6 @@ components: items: $ref: '#/components/schemas/GetIssueIncludeQueryParameterItem' type: array - IncidentAttachmentFilterQueryParameter: - description: Specifies which types of attachments are included in the response. - explode: false - in: query - name: filter[attachment_type] - required: false - schema: - items: - $ref: '#/components/schemas/IncidentAttachmentAttachmentType' - type: array - IncidentAttachmentIncludeQueryParameter: - description: Specifies which types of related objects are included in the response. - explode: false - in: query - name: include - required: false - schema: - items: - $ref: '#/components/schemas/IncidentAttachmentRelatedObject' - type: array IncidentIDPathParameter: description: The UUID of the incident. in: path @@ -5358,6 +5347,124 @@ components: - findings - project type: object + Attachment: + properties: + data: + $ref: '#/components/schemas/AttachmentData' + included: + items: + $ref: '#/components/schemas/AttachmentIncluded' + type: array + type: object + AttachmentArray: + properties: + data: + example: + - attributes: + attachment: + documentUrl: https://app.datadoghq.com/notebook/123/Postmortem-IR-123 + title: Postmortem IR-123 + attachment_type: postmortem + modified: '2025-01-01T01:01:01.000000001Z' + id: 00000000-abcd-0002-0000-000000000000 + relationships: + last_modified_by_user: + data: + id: 00000000-0000-0000-cccc-000000000000 + type: users + type: incident_attachments + items: + $ref: '#/components/schemas/AttachmentData' + type: array + included: + items: + $ref: '#/components/schemas/AttachmentIncluded' + type: array + required: + - data + type: object + AttachmentData: + example: + attributes: + attachment: + documentUrl: https://app.datadoghq.com/notebook/123/Postmortem-IR-123 + title: Postmortem IR-123 + attachment_type: postmortem + modified: '2025-01-01T01:01:01.000000001Z' + id: 00000000-abcd-0002-0000-000000000000 + relationships: + last_modified_by_user: + data: + id: 00000000-0000-0000-cccc-000000000000 + type: users + type: incident_attachments + properties: + attributes: + $ref: '#/components/schemas/AttachmentDataAttributes' + id: + example: 00000000-abcd-0002-0000-000000000000 + type: string + relationships: + $ref: '#/components/schemas/AttachmentDataRelationships' + type: + $ref: '#/components/schemas/IncidentAttachmentType' + required: + - type + - attributes + - relationships + - id + type: object + AttachmentDataAttributes: + properties: + attachment: + $ref: '#/components/schemas/AttachmentDataAttributesAttachment' + attachment_type: + $ref: '#/components/schemas/AttachmentDataAttributesAttachmentType' + modified: + format: date-time + type: string + type: object + AttachmentDataAttributesAttachment: + properties: + documentUrl: + type: string + title: + type: string + type: object + AttachmentDataAttributesAttachmentType: + enum: + - postmortem + - link + type: string + x-enum-varnames: + - POSTMORTEM + - LINK + AttachmentDataRelationships: + properties: + last_modified_by_user: + $ref: '#/components/schemas/AttachmentDataRelationshipsLastModifiedByUser' + type: object + AttachmentDataRelationshipsLastModifiedByUser: + properties: + data: + $ref: '#/components/schemas/AttachmentDataRelationshipsLastModifiedByUserData' + required: + - data + type: object + AttachmentDataRelationshipsLastModifiedByUserData: + properties: + id: + example: '' + type: string + type: + $ref: '#/components/schemas/UserType' + required: + - type + - id + type: object + AttachmentIncluded: + oneOf: + - $ref: '#/components/schemas/User140420082644000' AuditLogsEvent: description: Object description of an Audit Logs event after it is processed and stored by Datadog. @@ -12894,6 +13001,45 @@ components: required: - type type: object + CreateAttachmentRequest: + example: + data: + attributes: + attachment: + documentUrl: https://app.datadoghq.com/notebook/123/Postmortem-IR-123 + title: Postmortem-IR-123 + attachment_type: postmortem + id: 00000000-0000-0000-0000-000000000000 + type: incident_attachments + properties: + data: + $ref: '#/components/schemas/CreateAttachmentRequestData' + type: object + CreateAttachmentRequestData: + properties: + attributes: + $ref: '#/components/schemas/CreateAttachmentRequestDataAttributes' + id: + type: string + type: + $ref: '#/components/schemas/IncidentAttachmentType' + required: + - type + type: object + CreateAttachmentRequestDataAttributes: + properties: + attachment: + $ref: '#/components/schemas/CreateAttachmentRequestDataAttributesAttachment' + attachment_type: + $ref: '#/components/schemas/AttachmentDataAttributesAttachmentType' + type: object + CreateAttachmentRequestDataAttributesAttachment: + properties: + documentUrl: + type: string + title: + type: string + type: object CreateCaseRequestArray: description: List of requests to create cases for security findings. properties: @@ -25665,126 +25811,6 @@ components: type: string x-mimetype: application/xml type: object - IncidentAttachmentAttachmentType: - description: The type of the incident attachment attributes. - enum: - - link - - postmortem - example: link - type: string - x-enum-varnames: - - LINK - - POSTMORTEM - IncidentAttachmentAttributes: - description: The attributes object for an attachment. - oneOf: - - $ref: '#/components/schemas/IncidentAttachmentPostmortemAttributes' - - $ref: '#/components/schemas/IncidentAttachmentLinkAttributes' - IncidentAttachmentData: - description: A single incident attachment. - example: - attributes: - attachment: - documentUrl: '' - title: Postmortem IR-123 - attachment_type: postmortem - id: 00000000-abcd-0002-0000-000000000000 - relationships: - last_modified_by_user: - data: - id: 00000000-0000-0000-cccc-000000000000 - type: users - type: incident_attachments - properties: - attributes: - $ref: '#/components/schemas/IncidentAttachmentAttributes' - id: - description: A unique identifier that represents the incident attachment. - example: 00000000-abcd-0001-0000-000000000000 - type: string - relationships: - $ref: '#/components/schemas/IncidentAttachmentRelationships' - type: - $ref: '#/components/schemas/IncidentAttachmentType' - required: - - type - - attributes - - id - - relationships - type: object - IncidentAttachmentLinkAttachmentType: - default: link - description: The type of link attachment attributes. - enum: - - link - example: link - type: string - x-enum-varnames: - - LINK - IncidentAttachmentLinkAttributes: - description: The attributes object for a link attachment. - properties: - attachment: - $ref: '#/components/schemas/IncidentAttachmentLinkAttributesAttachmentObject' - attachment_type: - $ref: '#/components/schemas/IncidentAttachmentLinkAttachmentType' - modified: - description: Timestamp when the incident attachment link was last modified. - format: date-time - readOnly: true - type: string - required: - - attachment_type - - attachment - type: object - IncidentAttachmentLinkAttributesAttachmentObject: - description: The link attachment. - properties: - documentUrl: - description: The URL of this link attachment. - example: https://www.example.com/webstore-failure-runbook - type: string - title: - description: The title of this link attachment. - example: Runbook for webstore service failures - type: string - required: - - documentUrl - - title - type: object - IncidentAttachmentPostmortemAttachmentType: - default: postmortem - description: The type of postmortem attachment attributes. - enum: - - postmortem - example: postmortem - type: string - x-enum-varnames: - - POSTMORTEM - IncidentAttachmentPostmortemAttributes: - description: The attributes object for a postmortem attachment. - properties: - attachment: - $ref: '#/components/schemas/IncidentAttachmentsPostmortemAttributesAttachmentObject' - attachment_type: - $ref: '#/components/schemas/IncidentAttachmentPostmortemAttachmentType' - required: - - attachment_type - - attachment - type: object - IncidentAttachmentRelatedObject: - description: The object related to an incident attachment. - enum: - - users - type: string - x-enum-varnames: - - USERS - IncidentAttachmentRelationships: - description: The incident attachment's relationships. - properties: - last_modified_by_user: - $ref: '#/components/schemas/RelationshipToUser' - type: object IncidentAttachmentType: default: incident_attachments description: The incident attachment resource type. @@ -25794,142 +25820,6 @@ components: type: string x-enum-varnames: - INCIDENT_ATTACHMENTS - IncidentAttachmentUpdateAttributes: - description: Incident attachment attributes. - oneOf: - - $ref: '#/components/schemas/IncidentAttachmentPostmortemAttributes' - - $ref: '#/components/schemas/IncidentAttachmentLinkAttributes' - IncidentAttachmentUpdateData: - description: A single incident attachment. - properties: - attributes: - $ref: '#/components/schemas/IncidentAttachmentUpdateAttributes' - id: - description: A unique identifier that represents the incident attachment. - example: 00000000-abcd-0001-0000-000000000000 - type: string - type: - $ref: '#/components/schemas/IncidentAttachmentType' - required: - - type - type: object - IncidentAttachmentUpdateRequest: - description: The update request for an incident's attachments. - properties: - data: - description: 'An array of incident attachments. An attachment object without - an "id" key indicates that you want to - - create that attachment. An attachment object without an "attributes" key - indicates that you want to - - delete that attachment. An attachment object with both the "id" key and - a populated "attributes" object - - indicates that you want to update that attachment.' - example: - - attributes: - attachment: - documentUrl: https://app.datadoghq.com/notebook/123 - title: Postmortem IR-123 - attachment_type: postmortem - id: 00000000-abcd-0002-0000-000000000000 - type: incident_attachments - - attributes: - attachment: - documentUrl: https://www.example.com/webstore-failure-runbook - title: Runbook for webstore service failures - attachment_type: link - type: incident_attachments - - id: 00000000-abcd-0003-0000-000000000000 - type: incident_attachments - items: - $ref: '#/components/schemas/IncidentAttachmentUpdateData' - type: array - required: - - data - type: object - IncidentAttachmentUpdateResponse: - description: The response object containing the created or updated incident - attachments. - properties: - data: - description: 'An array of incident attachments. Only the attachments that - were created or updated by the request are - - returned.' - example: - - attributes: - attachment: - documentUrl: '' - title: Postmortem IR-123 - attachment_type: postmortem - id: 00000000-abcd-0002-0000-000000000000 - relationships: - last_modified_by_user: - data: - id: 00000000-0000-0000-cccc-000000000000 - type: users - type: incident_attachments - items: - $ref: '#/components/schemas/IncidentAttachmentData' - type: array - included: - description: Included related resources that the user requested. - items: - $ref: '#/components/schemas/IncidentAttachmentsResponseIncludedItem' - type: array - required: - - data - type: object - IncidentAttachmentsPostmortemAttributesAttachmentObject: - description: The postmortem attachment. - properties: - documentUrl: - description: The URL of this notebook attachment. - example: https://app.datadoghq.com/notebook/123 - type: string - title: - description: The title of this postmortem attachment. - example: Postmortem IR-123 - type: string - required: - - documentUrl - - title - type: object - IncidentAttachmentsResponse: - description: The response object containing an incident's attachments. - properties: - data: - description: An array of incident attachments. - example: - - attributes: - attachment: - documentUrl: '' - title: Postmortem IR-123 - attachment_type: postmortem - id: 00000000-abcd-0002-0000-000000000000 - relationships: - last_modified_by_user: - data: - id: 00000000-0000-0000-cccc-000000000000 - type: users - type: incident_attachments - items: - $ref: '#/components/schemas/IncidentAttachmentData' - type: array - included: - description: Included related resources that the user requested. - items: - $ref: '#/components/schemas/IncidentAttachmentsResponseIncludedItem' - type: array - required: - - data - type: object - IncidentAttachmentsResponseIncludedItem: - description: An object related to an attachment that is included in the response. - oneOf: - - $ref: '#/components/schemas/User' IncidentCreateAttributes: description: The incident's attributes for a create request. properties: @@ -27200,7 +27090,7 @@ components: description: An object related to an incident that is included in the response. oneOf: - $ref: '#/components/schemas/IncidentUserData' - - $ref: '#/components/schemas/IncidentAttachmentData' + - $ref: '#/components/schemas/AttachmentData' IncidentResponseMeta: description: The metadata object containing pagination metadata. properties: @@ -40203,6 +40093,41 @@ components: $ref: '#/components/schemas/ApplicationKeyResponseIncludedItem' type: array type: object + PatchAttachmentRequest: + example: + data: + attributes: + attachment: + documentUrl: https://app.datadoghq.com/notebook/124/Postmortem-IR-124 + title: Postmortem-IR-124 + type: incident_attachments + properties: + data: + $ref: '#/components/schemas/PatchAttachmentRequestData' + type: object + PatchAttachmentRequestData: + properties: + attributes: + $ref: '#/components/schemas/PatchAttachmentRequestDataAttributes' + id: + type: string + type: + $ref: '#/components/schemas/IncidentAttachmentType' + required: + - type + type: object + PatchAttachmentRequestDataAttributes: + properties: + attachment: + $ref: '#/components/schemas/PatchAttachmentRequestDataAttributesAttachment' + type: object + PatchAttachmentRequestDataAttributesAttachment: + properties: + documentUrl: + type: string + title: + type: string + type: object PatchIncidentNotificationTemplateRequest: description: Update request for a notification template. properties: @@ -56984,6 +56909,17 @@ components: type: $ref: '#/components/schemas/UsersType' type: object + User140420082644000: + properties: + attributes: + $ref: '#/components/schemas/UserAttributes' + id: + type: string + type: + $ref: '#/components/schemas/UserType' + required: + - type + type: object UserAttributes: description: Attributes of user object returned by the API. properties: @@ -57434,6 +57370,15 @@ components: meta: $ref: '#/components/schemas/TeamsResponseMeta' type: object + UserType: + default: users + description: Users resource type. + enum: + - users + example: users + type: string + x-enum-varnames: + - USERS UserUpdateAttributes: description: Attributes of the edited user. properties: @@ -68712,8 +68657,7 @@ paths: security: - apiKeyAuth: [] appKeyAuth: [] - - AuthZ: - - incident_notification_settings_read + - AuthZ: [] summary: List incident notification rules tags: - Incidents @@ -68912,8 +68856,7 @@ paths: security: - apiKeyAuth: [] appKeyAuth: [] - - AuthZ: - - incident_settings_read + - AuthZ: [] summary: List incident notification templates tags: - Incidents @@ -69028,7 +68971,8 @@ paths: - apiKeyAuth: [] appKeyAuth: [] - AuthZ: - - incident_settings_read + - incident_read + - incident_write summary: Get incident notification template tags: - Incidents @@ -69118,6 +69062,7 @@ paths: x-permission: operator: OR permissions: + - incident_settings_read - incident_read x-unstable: '**Note**: This endpoint is in public beta. @@ -69159,7 +69104,7 @@ paths: - Incidents x-codegen-request-body-name: body x-permission: - operator: OR + operator: AND permissions: - incident_settings_write x-unstable: '**Note**: This endpoint is in public beta. @@ -69449,80 +69394,166 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/incidents/{incident_id}/attachments: get: - description: Get all attachments for a given incident. + description: List incident attachments. operationId: ListIncidentAttachments parameters: - $ref: '#/components/parameters/IncidentIDPathParameter' - - $ref: '#/components/parameters/IncidentAttachmentIncludeQueryParameter' - - $ref: '#/components/parameters/IncidentAttachmentFilterQueryParameter' + - description: Filter attachments by type. Supported values are `1` (`postmortem`) + and `2` (`link`). + in: query + name: filter[attachment_type] + schema: + example: '1' + type: string + - $ref: '#/components/parameters/AttachmentIncludeQueryParameter' responses: '200': content: application/json: schema: - $ref: '#/components/schemas/IncidentAttachmentsResponse' + $ref: '#/components/schemas/AttachmentArray' description: OK '400': $ref: '#/components/responses/BadRequestResponse' - '401': - $ref: '#/components/responses/UnauthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List incident attachments + tags: + - Incidents + x-permission: + operator: OR + permissions: + - incident_read + x-unstable: '**Note**: This endpoint is in Preview. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create an incident attachment. + operationId: CreateIncidentAttachment + parameters: + - $ref: '#/components/parameters/IncidentIDPathParameter' + - $ref: '#/components/parameters/AttachmentIncludeQueryParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateAttachmentRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/Attachment' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_write + summary: Create incident attachment + tags: + - Incidents + x-permission: + operator: AND + permissions: + - incident_write + x-unstable: '**Note**: This endpoint is in Preview. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/incidents/{incident_id}/attachments/{attachment_id}: + delete: + operationId: DeleteIncidentAttachment + parameters: + - $ref: '#/components/parameters/IncidentIDPathParameter' + - description: The ID of the attachment. + in: path + name: attachment_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000002 + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/BadRequestResponse' '403': $ref: '#/components/responses/ForbiddenResponse' '404': $ref: '#/components/responses/NotFoundResponse' '429': $ref: '#/components/responses/TooManyRequestsResponse' - summary: Get a list of attachments + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_write + summary: Delete incident attachment tags: - Incidents x-permission: - operator: OR + operator: AND permissions: - - incident_read - x-unstable: '**Note**: This endpoint is in public beta. + - incident_write + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' patch: - deprecated: true - description: The bulk update endpoint for creating, updating, and deleting attachments - for a given incident. - operationId: UpdateIncidentAttachments + operationId: UpdateIncidentAttachment parameters: - $ref: '#/components/parameters/IncidentIDPathParameter' - - $ref: '#/components/parameters/IncidentAttachmentIncludeQueryParameter' + - description: The ID of the attachment. + in: path + name: attachment_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000002 + - $ref: '#/components/parameters/AttachmentIncludeQueryParameter' requestBody: content: application/json: schema: - $ref: '#/components/schemas/IncidentAttachmentUpdateRequest' - description: Incident Attachment Payload. + $ref: '#/components/schemas/PatchAttachmentRequest' required: true responses: '200': content: application/json: schema: - $ref: '#/components/schemas/IncidentAttachmentUpdateResponse' + $ref: '#/components/schemas/Attachment' description: OK '400': $ref: '#/components/responses/BadRequestResponse' - '401': - $ref: '#/components/responses/UnauthorizedResponse' '403': $ref: '#/components/responses/ForbiddenResponse' '404': $ref: '#/components/responses/NotFoundResponse' '429': $ref: '#/components/responses/TooManyRequestsResponse' - summary: Create, update, and delete incident attachments + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_write + summary: Update incident attachment tags: - Incidents - x-codegen-request-body-name: body x-permission: - operator: OR + operator: AND permissions: - incident_write - x-unstable: '**Note**: This endpoint is deprecated.' + x-unstable: '**Note**: This endpoint is in Preview. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/incidents/{incident_id}/impacts: get: description: Get all impacts for an incident. diff --git a/examples/v2_incidents_CreateIncidentAttachment.rs b/examples/v2_incidents_CreateIncidentAttachment.rs new file mode 100644 index 000000000..5b79d8a98 --- /dev/null +++ b/examples/v2_incidents_CreateIncidentAttachment.rs @@ -0,0 +1,45 @@ +// Create incident attachment returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::CreateIncidentAttachmentOptionalParams; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use datadog_api_client::datadogV2::model::AttachmentDataAttributesAttachmentType; +use datadog_api_client::datadogV2::model::CreateAttachmentRequest; +use datadog_api_client::datadogV2::model::CreateAttachmentRequestData; +use datadog_api_client::datadogV2::model::CreateAttachmentRequestDataAttributes; +use datadog_api_client::datadogV2::model::CreateAttachmentRequestDataAttributesAttachment; +use datadog_api_client::datadogV2::model::IncidentAttachmentType; + +#[tokio::main] +async fn main() { + let body = CreateAttachmentRequest::new().data( + CreateAttachmentRequestData::new(IncidentAttachmentType::INCIDENT_ATTACHMENTS) + .attributes( + CreateAttachmentRequestDataAttributes::new() + .attachment( + CreateAttachmentRequestDataAttributesAttachment::new() + .document_url( + "https://app.datadoghq.com/notebook/123/Postmortem-IR-123" + .to_string(), + ) + .title("Postmortem-IR-123".to_string()), + ) + .attachment_type(AttachmentDataAttributesAttachmentType::POSTMORTEM), + ) + .id("00000000-0000-0000-0000-000000000000".to_string()), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateIncidentAttachment", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .create_incident_attachment( + "incident_id".to_string(), + body, + CreateIncidentAttachmentOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_DeleteIncidentAttachment.rs b/examples/v2_incidents_DeleteIncidentAttachment.rs new file mode 100644 index 000000000..b63c818d9 --- /dev/null +++ b/examples/v2_incidents_DeleteIncidentAttachment.rs @@ -0,0 +1,22 @@ +// Delete incident attachment returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use serde_json::Value; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteIncidentAttachment", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .delete_incident_attachment( + "incident_id".to_string(), + Value::from("00000000-0000-0000-0000-000000000002"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_ListIncidentAttachments.rs b/examples/v2_incidents_ListIncidentAttachments.rs index 2cedca5f6..4b87227cf 100644 --- a/examples/v2_incidents_ListIncidentAttachments.rs +++ b/examples/v2_incidents_ListIncidentAttachments.rs @@ -1,4 +1,4 @@ -// Get a list of attachments returns "OK" response +// List incident attachments returns "OK" response use datadog_api_client::datadog; use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; use datadog_api_client::datadogV2::api_incidents::ListIncidentAttachmentsOptionalParams; diff --git a/examples/v2_incidents_ListIncidentAttachments_2457735435.rs b/examples/v2_incidents_ListIncidentAttachments_2457735435.rs deleted file mode 100644 index 8ced7b70c..000000000 --- a/examples/v2_incidents_ListIncidentAttachments_2457735435.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Get incident attachments returns "OK" response -use datadog_api_client::datadog; -use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; -use datadog_api_client::datadogV2::api_incidents::ListIncidentAttachmentsOptionalParams; - -#[tokio::main] -async fn main() { - // there is a valid "incident" in the system - let incident_data_id = std::env::var("INCIDENT_DATA_ID").unwrap(); - let mut configuration = datadog::Configuration::new(); - configuration.set_unstable_operation_enabled("v2.ListIncidentAttachments", true); - let api = IncidentsAPI::with_config(configuration); - let resp = api - .list_incident_attachments( - incident_data_id.clone(), - ListIncidentAttachmentsOptionalParams::default(), - ) - .await; - if let Ok(value) = resp { - println!("{:#?}", value); - } else { - println!("{:#?}", resp.unwrap_err()); - } -} diff --git a/examples/v2_incidents_UpdateIncidentAttachment.rs b/examples/v2_incidents_UpdateIncidentAttachment.rs new file mode 100644 index 000000000..d4034da2e --- /dev/null +++ b/examples/v2_incidents_UpdateIncidentAttachment.rs @@ -0,0 +1,41 @@ +// Update incident attachment returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use datadog_api_client::datadogV2::api_incidents::UpdateIncidentAttachmentOptionalParams; +use datadog_api_client::datadogV2::model::IncidentAttachmentType; +use datadog_api_client::datadogV2::model::PatchAttachmentRequest; +use datadog_api_client::datadogV2::model::PatchAttachmentRequestData; +use datadog_api_client::datadogV2::model::PatchAttachmentRequestDataAttributes; +use datadog_api_client::datadogV2::model::PatchAttachmentRequestDataAttributesAttachment; +use serde_json::Value; + +#[tokio::main] +async fn main() { + let body = PatchAttachmentRequest::new().data( + PatchAttachmentRequestData::new(IncidentAttachmentType::INCIDENT_ATTACHMENTS).attributes( + PatchAttachmentRequestDataAttributes::new().attachment( + PatchAttachmentRequestDataAttributesAttachment::new() + .document_url( + "https://app.datadoghq.com/notebook/124/Postmortem-IR-124".to_string(), + ) + .title("Postmortem-IR-124".to_string()), + ), + ), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateIncidentAttachment", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .update_incident_attachment( + "incident_id".to_string(), + Value::from("00000000-0000-0000-0000-000000000002"), + body, + UpdateIncidentAttachmentOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_UpdateIncidentAttachments.rs b/examples/v2_incidents_UpdateIncidentAttachments.rs deleted file mode 100644 index f4577da9c..000000000 --- a/examples/v2_incidents_UpdateIncidentAttachments.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Create, update, and delete incident attachments returns "OK" response -use datadog_api_client::datadog; -use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; -use datadog_api_client::datadogV2::api_incidents::UpdateIncidentAttachmentsOptionalParams; -use datadog_api_client::datadogV2::model::IncidentAttachmentLinkAttachmentType; -use datadog_api_client::datadogV2::model::IncidentAttachmentLinkAttributes; -use datadog_api_client::datadogV2::model::IncidentAttachmentLinkAttributesAttachmentObject; -use datadog_api_client::datadogV2::model::IncidentAttachmentPostmortemAttachmentType; -use datadog_api_client::datadogV2::model::IncidentAttachmentPostmortemAttributes; -use datadog_api_client::datadogV2::model::IncidentAttachmentType; -use datadog_api_client::datadogV2::model::IncidentAttachmentUpdateAttributes; -use datadog_api_client::datadogV2::model::IncidentAttachmentUpdateData; -use datadog_api_client::datadogV2::model::IncidentAttachmentUpdateRequest; -use datadog_api_client::datadogV2::model::IncidentAttachmentsPostmortemAttributesAttachmentObject; - -#[tokio::main] -async fn main() { - let body = IncidentAttachmentUpdateRequest::new(vec![ - IncidentAttachmentUpdateData::new(IncidentAttachmentType::INCIDENT_ATTACHMENTS) - .attributes( - IncidentAttachmentUpdateAttributes::IncidentAttachmentPostmortemAttributes( - Box::new(IncidentAttachmentPostmortemAttributes::new( - IncidentAttachmentsPostmortemAttributesAttachmentObject::new( - "https://app.datadoghq.com/notebook/123".to_string(), - "Postmortem IR-123".to_string(), - ), - IncidentAttachmentPostmortemAttachmentType::POSTMORTEM, - )), - ), - ) - .id("00000000-abcd-0002-0000-000000000000".to_string()), - IncidentAttachmentUpdateData::new(IncidentAttachmentType::INCIDENT_ATTACHMENTS).attributes( - IncidentAttachmentUpdateAttributes::IncidentAttachmentLinkAttributes(Box::new( - IncidentAttachmentLinkAttributes::new( - IncidentAttachmentLinkAttributesAttachmentObject::new( - "https://www.example.com/webstore-failure-runbook".to_string(), - "Runbook for webstore service failures".to_string(), - ), - IncidentAttachmentLinkAttachmentType::LINK, - ), - )), - ), - IncidentAttachmentUpdateData::new(IncidentAttachmentType::INCIDENT_ATTACHMENTS) - .id("00000000-abcd-0003-0000-000000000000".to_string()), - ]); - let mut configuration = datadog::Configuration::new(); - configuration.set_unstable_operation_enabled("v2.UpdateIncidentAttachments", true); - let api = IncidentsAPI::with_config(configuration); - let resp = api - .update_incident_attachments( - "incident_id".to_string(), - body, - UpdateIncidentAttachmentsOptionalParams::default(), - ) - .await; - if let Ok(value) = resp { - println!("{:#?}", value); - } else { - println!("{:#?}", resp.unwrap_err()); - } -} diff --git a/examples/v2_incidents_UpdateIncidentAttachments_3881702075.rs b/examples/v2_incidents_UpdateIncidentAttachments_3881702075.rs deleted file mode 100644 index 7c15570b9..000000000 --- a/examples/v2_incidents_UpdateIncidentAttachments_3881702075.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Create an incident attachment returns "OK" response -use datadog_api_client::datadog; -use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; -use datadog_api_client::datadogV2::api_incidents::UpdateIncidentAttachmentsOptionalParams; -use datadog_api_client::datadogV2::model::IncidentAttachmentLinkAttachmentType; -use datadog_api_client::datadogV2::model::IncidentAttachmentLinkAttributes; -use datadog_api_client::datadogV2::model::IncidentAttachmentLinkAttributesAttachmentObject; -use datadog_api_client::datadogV2::model::IncidentAttachmentType; -use datadog_api_client::datadogV2::model::IncidentAttachmentUpdateAttributes; -use datadog_api_client::datadogV2::model::IncidentAttachmentUpdateData; -use datadog_api_client::datadogV2::model::IncidentAttachmentUpdateRequest; - -#[tokio::main] -async fn main() { - // there is a valid "incident" in the system - let incident_data_id = std::env::var("INCIDENT_DATA_ID").unwrap(); - let body = IncidentAttachmentUpdateRequest::new(vec![IncidentAttachmentUpdateData::new( - IncidentAttachmentType::INCIDENT_ATTACHMENTS, - ) - .attributes( - IncidentAttachmentUpdateAttributes::IncidentAttachmentLinkAttributes(Box::new( - IncidentAttachmentLinkAttributes::new( - IncidentAttachmentLinkAttributesAttachmentObject::new( - "https://www.example.com/doc".to_string(), - "Example-Incident".to_string(), - ), - IncidentAttachmentLinkAttachmentType::LINK, - ), - )), - )]); - let mut configuration = datadog::Configuration::new(); - configuration.set_unstable_operation_enabled("v2.UpdateIncidentAttachments", true); - let api = IncidentsAPI::with_config(configuration); - let resp = api - .update_incident_attachments( - incident_data_id.clone(), - body, - UpdateIncidentAttachmentsOptionalParams::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 9ab48f163..2eab236e9 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -188,12 +188,14 @@ impl Default for Configuration { ("v2.update_deployment_gate".to_owned(), false), ("v2.update_deployment_rule".to_owned(), false), ("v2.create_incident".to_owned(), false), + ("v2.create_incident_attachment".to_owned(), false), ("v2.create_incident_integration".to_owned(), false), ("v2.create_incident_notification_rule".to_owned(), false), ("v2.create_incident_notification_template".to_owned(), false), ("v2.create_incident_todo".to_owned(), false), ("v2.create_incident_type".to_owned(), false), ("v2.delete_incident".to_owned(), false), + ("v2.delete_incident_attachment".to_owned(), false), ("v2.delete_incident_integration".to_owned(), false), ("v2.delete_incident_notification_rule".to_owned(), false), ("v2.delete_incident_notification_template".to_owned(), false), @@ -214,7 +216,7 @@ impl Default for Configuration { ("v2.list_incident_types".to_owned(), false), ("v2.search_incidents".to_owned(), false), ("v2.update_incident".to_owned(), false), - ("v2.update_incident_attachments".to_owned(), false), + ("v2.update_incident_attachment".to_owned(), false), ("v2.update_incident_integration".to_owned(), false), ("v2.update_incident_notification_rule".to_owned(), false), ("v2.update_incident_notification_template".to_owned(), false), diff --git a/src/datadogV2/api/api_incidents.rs b/src/datadogV2/api/api_incidents.rs index 63919f46d..c72f6b1f9 100644 --- a/src/datadogV2/api/api_incidents.rs +++ b/src/datadogV2/api/api_incidents.rs @@ -13,6 +13,22 @@ use reqwest::header::{HeaderMap, HeaderValue}; use serde::{Deserialize, Serialize}; use std::io::Write; +/// CreateIncidentAttachmentOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::create_incident_attachment`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct CreateIncidentAttachmentOptionalParams { + /// Resource to include in the response. Supported value: `last_modified_by_user`. + pub include: Option, +} + +impl CreateIncidentAttachmentOptionalParams { + /// Resource to include in the response. Supported value: `last_modified_by_user`. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// CreateIncidentImpactOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::create_incident_impact`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -116,28 +132,21 @@ impl GetIncidentNotificationTemplateOptionalParams { #[non_exhaustive] #[derive(Clone, Default, Debug)] pub struct ListIncidentAttachmentsOptionalParams { - /// Specifies which types of related objects are included in the response. - pub include: Option>, - /// Specifies which types of attachments are included in the response. - pub filter_attachment_type: - Option>, + /// Filter attachments by type. Supported values are `1` (`postmortem`) and `2` (`link`). + pub filter_attachment_type: Option, + /// Resource to include in the response. Supported value: `last_modified_by_user`. + pub include: Option, } impl ListIncidentAttachmentsOptionalParams { - /// Specifies which types of related objects are included in the response. - pub fn include( - mut self, - value: Vec, - ) -> Self { - self.include = Some(value); + /// Filter attachments by type. Supported values are `1` (`postmortem`) and `2` (`link`). + pub fn filter_attachment_type(mut self, value: String) -> Self { + self.filter_attachment_type = Some(value); self } - /// Specifies which types of attachments are included in the response. - pub fn filter_attachment_type( - mut self, - value: Vec, - ) -> Self { - self.filter_attachment_type = Some(value); + /// Resource to include in the response. Supported value: `last_modified_by_user`. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); self } } @@ -299,20 +308,17 @@ impl UpdateIncidentOptionalParams { } } -/// UpdateIncidentAttachmentsOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::update_incident_attachments`] +/// UpdateIncidentAttachmentOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::update_incident_attachment`] #[non_exhaustive] #[derive(Clone, Default, Debug)] -pub struct UpdateIncidentAttachmentsOptionalParams { - /// Specifies which types of related objects are included in the response. - pub include: Option>, +pub struct UpdateIncidentAttachmentOptionalParams { + /// Resource to include in the response. Supported value: `last_modified_by_user`. + pub include: Option, } -impl UpdateIncidentAttachmentsOptionalParams { - /// Specifies which types of related objects are included in the response. - pub fn include( - mut self, - value: Vec, - ) -> Self { +impl UpdateIncidentAttachmentOptionalParams { + /// Resource to include in the response. Supported value: `last_modified_by_user`. + pub fn include(mut self, value: String) -> Self { self.include = Some(value); self } @@ -358,6 +364,14 @@ pub enum CreateIncidentError { UnknownValue(serde_json::Value), } +/// CreateIncidentAttachmentError is a struct for typed errors of method [`IncidentsAPI::create_incident_attachment`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateIncidentAttachmentError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// CreateIncidentImpactError is a struct for typed errors of method [`IncidentsAPI::create_incident_impact`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -414,6 +428,14 @@ pub enum DeleteIncidentError { UnknownValue(serde_json::Value), } +/// DeleteIncidentAttachmentError is a struct for typed errors of method [`IncidentsAPI::delete_incident_attachment`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteIncidentAttachmentError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// DeleteIncidentImpactError is a struct for typed errors of method [`IncidentsAPI::delete_incident_impact`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -590,10 +612,10 @@ pub enum UpdateIncidentError { UnknownValue(serde_json::Value), } -/// UpdateIncidentAttachmentsError is a struct for typed errors of method [`IncidentsAPI::update_incident_attachments`] +/// UpdateIncidentAttachmentError is a struct for typed errors of method [`IncidentsAPI::update_incident_attachment`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateIncidentAttachmentsError { +pub enum UpdateIncidentAttachmentError { APIErrorResponse(crate::datadogV2::model::APIErrorResponse), UnknownValue(serde_json::Value), } @@ -862,6 +884,180 @@ impl IncidentsAPI { } } + /// Create an incident attachment. + pub async fn create_incident_attachment( + &self, + incident_id: String, + body: crate::datadogV2::model::CreateAttachmentRequest, + params: CreateIncidentAttachmentOptionalParams, + ) -> Result> + { + match self + .create_incident_attachment_with_http_info(incident_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), + } + } + + /// Create an incident attachment. + pub async fn create_incident_attachment_with_http_info( + &self, + incident_id: String, + body: crate::datadogV2::model::CreateAttachmentRequest, + params: CreateIncidentAttachmentOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_incident_attachment"; + 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_attachment' 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/{incident_id}/attachments", + local_configuration.get_operation_host(operation_id), + incident_id = datadog::urlencode(incident_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)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Create an impact for an incident. pub async fn create_incident_impact( &self, @@ -1964,6 +2160,106 @@ impl IncidentsAPI { } } + pub async fn delete_incident_attachment( + &self, + incident_id: String, + attachment_id: serde_json::Value, + ) -> Result<(), datadog::Error> { + match self + .delete_incident_attachment_with_http_info(incident_id, attachment_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + pub async fn delete_incident_attachment_with_http_info( + &self, + incident_id: String, + attachment_id: serde_json::Value, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_incident_attachment"; + 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_attachment' 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/{incident_id}/attachments/{attachment_id}", + local_configuration.get_operation_host(operation_id), + incident_id = datadog::urlencode(incident_id), + attachment_id = attachment_id + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Delete an incident impact. pub async fn delete_incident_impact( &self, @@ -3335,13 +3631,13 @@ impl IncidentsAPI { } } - /// Get all attachments for a given incident. + /// List incident attachments. pub async fn list_incident_attachments( &self, incident_id: String, params: ListIncidentAttachmentsOptionalParams, ) -> Result< - crate::datadogV2::model::IncidentAttachmentsResponse, + crate::datadogV2::model::AttachmentArray, datadog::Error, > { match self @@ -3361,13 +3657,13 @@ impl IncidentsAPI { } } - /// Get all attachments for a given incident. + /// List incident attachments. pub async fn list_incident_attachments_with_http_info( &self, incident_id: String, params: ListIncidentAttachmentsOptionalParams, ) -> Result< - datadog::ResponseContent, + datadog::ResponseContent, datadog::Error, > { let local_configuration = &self.config; @@ -3382,8 +3678,8 @@ impl IncidentsAPI { } // unbox and build optional parameters - let include = params.include; let filter_attachment_type = params.filter_attachment_type; + let include = params.include; let local_client = &self.client; @@ -3395,27 +3691,13 @@ impl IncidentsAPI { let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - if let Some(ref local) = include { - local_req_builder = local_req_builder.query(&[( - "include", - &local - .iter() - .map(|p| p.to_string()) - .collect::>() - .join(",") - .to_string(), - )]); + if let Some(ref local_query_param) = filter_attachment_type { + local_req_builder = local_req_builder + .query(&[("filter[attachment_type]", &local_query_param.to_string())]); }; - if let Some(ref local) = filter_attachment_type { - local_req_builder = local_req_builder.query(&[( - "filter[attachment_type]", - &local - .iter() - .map(|p| p.to_string()) - .collect::>() - .join(",") - .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 @@ -3460,9 +3742,7 @@ impl IncidentsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -4771,18 +5051,16 @@ impl IncidentsAPI { } } - /// The bulk update endpoint for creating, updating, and deleting attachments for a given incident. - pub async fn update_incident_attachments( + pub async fn update_incident_attachment( &self, incident_id: String, - body: crate::datadogV2::model::IncidentAttachmentUpdateRequest, - params: UpdateIncidentAttachmentsOptionalParams, - ) -> Result< - crate::datadogV2::model::IncidentAttachmentUpdateResponse, - datadog::Error, - > { + attachment_id: serde_json::Value, + body: crate::datadogV2::model::PatchAttachmentRequest, + params: UpdateIncidentAttachmentOptionalParams, + ) -> Result> + { match self - .update_incident_attachments_with_http_info(incident_id, body, params) + .update_incident_attachment_with_http_info(incident_id, attachment_id, body, params) .await { Ok(response_content) => { @@ -4798,23 +5076,23 @@ impl IncidentsAPI { } } - /// The bulk update endpoint for creating, updating, and deleting attachments for a given incident. - pub async fn update_incident_attachments_with_http_info( + pub async fn update_incident_attachment_with_http_info( &self, incident_id: String, - body: crate::datadogV2::model::IncidentAttachmentUpdateRequest, - params: UpdateIncidentAttachmentsOptionalParams, + attachment_id: serde_json::Value, + body: crate::datadogV2::model::PatchAttachmentRequest, + params: UpdateIncidentAttachmentOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.update_incident_attachments"; + let operation_id = "v2.update_incident_attachment"; 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_attachments' is not enabled".to_string(), + msg: "Operation 'v2.update_incident_attachment' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } @@ -4825,23 +5103,17 @@ impl IncidentsAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/incidents/{incident_id}/attachments", + "{}/api/v2/incidents/{incident_id}/attachments/{attachment_id}", local_configuration.get_operation_host(operation_id), - incident_id = datadog::urlencode(incident_id) + incident_id = datadog::urlencode(incident_id), + attachment_id = attachment_id ); let mut local_req_builder = local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); - if let Some(ref local) = include { - local_req_builder = local_req_builder.query(&[( - "include", - &local - .iter() - .map(|p| p.to_string()) - .collect::>() - .join(",") - .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 @@ -4932,9 +5204,7 @@ impl IncidentsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -4945,7 +5215,7 @@ impl IncidentsAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index e63dfc686..0f3e44d99 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2700,24 +2700,22 @@ pub mod model_incident_user_data; pub use self::model_incident_user_data::IncidentUserData; pub mod model_incident_user_attributes; pub use self::model_incident_user_attributes::IncidentUserAttributes; -pub mod model_incident_attachment_data; -pub use self::model_incident_attachment_data::IncidentAttachmentData; -pub mod model_incident_attachment_postmortem_attributes; -pub use self::model_incident_attachment_postmortem_attributes::IncidentAttachmentPostmortemAttributes; -pub mod model_incident_attachments_postmortem_attributes_attachment_object; -pub use self::model_incident_attachments_postmortem_attributes_attachment_object::IncidentAttachmentsPostmortemAttributesAttachmentObject; -pub mod model_incident_attachment_postmortem_attachment_type; -pub use self::model_incident_attachment_postmortem_attachment_type::IncidentAttachmentPostmortemAttachmentType; -pub mod model_incident_attachment_link_attributes; -pub use self::model_incident_attachment_link_attributes::IncidentAttachmentLinkAttributes; -pub mod model_incident_attachment_link_attributes_attachment_object; -pub use self::model_incident_attachment_link_attributes_attachment_object::IncidentAttachmentLinkAttributesAttachmentObject; -pub mod model_incident_attachment_link_attachment_type; -pub use self::model_incident_attachment_link_attachment_type::IncidentAttachmentLinkAttachmentType; -pub mod model_incident_attachment_attributes; -pub use self::model_incident_attachment_attributes::IncidentAttachmentAttributes; -pub mod model_incident_attachment_relationships; -pub use self::model_incident_attachment_relationships::IncidentAttachmentRelationships; +pub mod model_attachment_data; +pub use self::model_attachment_data::AttachmentData; +pub mod model_attachment_data_attributes; +pub use self::model_attachment_data_attributes::AttachmentDataAttributes; +pub mod model_attachment_data_attributes_attachment; +pub use self::model_attachment_data_attributes_attachment::AttachmentDataAttributesAttachment; +pub mod model_attachment_data_attributes_attachment_type; +pub use self::model_attachment_data_attributes_attachment_type::AttachmentDataAttributesAttachmentType; +pub mod model_attachment_data_relationships; +pub use self::model_attachment_data_relationships::AttachmentDataRelationships; +pub mod model_attachment_data_relationships_last_modified_by_user; +pub use self::model_attachment_data_relationships_last_modified_by_user::AttachmentDataRelationshipsLastModifiedByUser; +pub mod model_attachment_data_relationships_last_modified_by_user_data; +pub use self::model_attachment_data_relationships_last_modified_by_user_data::AttachmentDataRelationshipsLastModifiedByUserData; +pub mod model_user_type; +pub use self::model_user_type::UserType; pub mod model_incident_response_included_item; pub use self::model_incident_response_included_item::IncidentResponseIncludedItem; pub mod model_incident_response_meta; @@ -2894,22 +2892,30 @@ pub mod model_relationship_to_incident_postmortem_data; pub use self::model_relationship_to_incident_postmortem_data::RelationshipToIncidentPostmortemData; pub mod model_incident_postmortem_type; pub use self::model_incident_postmortem_type::IncidentPostmortemType; -pub mod model_incident_attachment_related_object; -pub use self::model_incident_attachment_related_object::IncidentAttachmentRelatedObject; -pub mod model_incident_attachment_attachment_type; -pub use self::model_incident_attachment_attachment_type::IncidentAttachmentAttachmentType; -pub mod model_incident_attachments_response; -pub use self::model_incident_attachments_response::IncidentAttachmentsResponse; -pub mod model_incident_attachments_response_included_item; -pub use self::model_incident_attachments_response_included_item::IncidentAttachmentsResponseIncludedItem; -pub mod model_incident_attachment_update_request; -pub use self::model_incident_attachment_update_request::IncidentAttachmentUpdateRequest; -pub mod model_incident_attachment_update_data; -pub use self::model_incident_attachment_update_data::IncidentAttachmentUpdateData; -pub mod model_incident_attachment_update_attributes; -pub use self::model_incident_attachment_update_attributes::IncidentAttachmentUpdateAttributes; -pub mod model_incident_attachment_update_response; -pub use self::model_incident_attachment_update_response::IncidentAttachmentUpdateResponse; +pub mod model_attachment_array; +pub use self::model_attachment_array::AttachmentArray; +pub mod model_user140420082644000; +pub use self::model_user140420082644000::User140420082644000; +pub mod model_attachment_included; +pub use self::model_attachment_included::AttachmentIncluded; +pub mod model_create_attachment_request; +pub use self::model_create_attachment_request::CreateAttachmentRequest; +pub mod model_create_attachment_request_data; +pub use self::model_create_attachment_request_data::CreateAttachmentRequestData; +pub mod model_create_attachment_request_data_attributes; +pub use self::model_create_attachment_request_data_attributes::CreateAttachmentRequestDataAttributes; +pub mod model_create_attachment_request_data_attributes_attachment; +pub use self::model_create_attachment_request_data_attributes_attachment::CreateAttachmentRequestDataAttributesAttachment; +pub mod model_attachment; +pub use self::model_attachment::Attachment; +pub mod model_patch_attachment_request; +pub use self::model_patch_attachment_request::PatchAttachmentRequest; +pub mod model_patch_attachment_request_data; +pub use self::model_patch_attachment_request_data::PatchAttachmentRequestData; +pub mod model_patch_attachment_request_data_attributes; +pub use self::model_patch_attachment_request_data_attributes::PatchAttachmentRequestDataAttributes; +pub mod model_patch_attachment_request_data_attributes_attachment; +pub use self::model_patch_attachment_request_data_attributes_attachment::PatchAttachmentRequestDataAttributesAttachment; pub mod model_incident_impact_related_object; pub use self::model_incident_impact_related_object::IncidentImpactRelatedObject; pub mod model_incident_impacts_response; diff --git a/src/datadogV2/model/model_incident_attachment_update_response.rs b/src/datadogV2/model/model_attachment.rs similarity index 64% rename from src/datadogV2/model/model_incident_attachment_update_response.rs rename to src/datadogV2/model/model_attachment.rs index c00a21788..4a2f44b87 100644 --- a/src/datadogV2/model/model_incident_attachment_update_response.rs +++ b/src/datadogV2/model/model_attachment.rs @@ -6,18 +6,14 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// The response object containing the created or updated incident attachments. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct IncidentAttachmentUpdateResponse { - /// An array of incident attachments. Only the attachments that were created or updated by the request are - /// returned. +pub struct Attachment { #[serde(rename = "data")] - pub data: Vec, - /// Included related resources that the user requested. + pub data: Option, #[serde(rename = "included")] - pub included: Option>, + pub included: Option>, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -25,22 +21,22 @@ pub struct IncidentAttachmentUpdateResponse { pub(crate) _unparsed: bool, } -impl IncidentAttachmentUpdateResponse { - pub fn new( - data: Vec, - ) -> IncidentAttachmentUpdateResponse { - IncidentAttachmentUpdateResponse { - data, +impl Attachment { + pub fn new() -> Attachment { + Attachment { + data: None, included: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } - pub fn included( - mut self, - value: Vec, - ) -> Self { + pub fn data(mut self, value: crate::datadogV2::model::AttachmentData) -> Self { + self.data = Some(value); + self + } + + pub fn included(mut self, value: Vec) -> Self { self.included = Some(value); self } @@ -54,14 +50,20 @@ impl IncidentAttachmentUpdateResponse { } } -impl<'de> Deserialize<'de> for IncidentAttachmentUpdateResponse { +impl Default for Attachment { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for Attachment { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct IncidentAttachmentUpdateResponseVisitor; - impl<'a> Visitor<'a> for IncidentAttachmentUpdateResponseVisitor { - type Value = IncidentAttachmentUpdateResponse; + struct AttachmentVisitor; + impl<'a> Visitor<'a> for AttachmentVisitor { + type Value = Attachment; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -71,10 +73,8 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateResponse { where M: MapAccess<'a>, { - let mut data: Option> = None; - let mut included: Option< - Vec, - > = None; + let mut data: Option = None; + let mut included: Option> = None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -84,6 +84,9 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateResponse { while let Some((k, v)) = map.next_entry::()? { match k.as_str() { "data" => { + if v.is_null() { + continue; + } data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } "included" => { @@ -99,9 +102,8 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateResponse { } } } - let data = data.ok_or_else(|| M::Error::missing_field("data"))?; - let content = IncidentAttachmentUpdateResponse { + let content = Attachment { data, included, additional_properties, @@ -112,6 +114,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateResponse { } } - deserializer.deserialize_any(IncidentAttachmentUpdateResponseVisitor) + deserializer.deserialize_any(AttachmentVisitor) } } diff --git a/src/datadogV2/model/model_incident_attachments_response.rs b/src/datadogV2/model/model_attachment_array.rs similarity index 70% rename from src/datadogV2/model/model_incident_attachments_response.rs rename to src/datadogV2/model/model_attachment_array.rs index c46f46d7d..27151b7e3 100644 --- a/src/datadogV2/model/model_incident_attachments_response.rs +++ b/src/datadogV2/model/model_attachment_array.rs @@ -6,17 +6,14 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// The response object containing an incident's attachments. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct IncidentAttachmentsResponse { - /// An array of incident attachments. +pub struct AttachmentArray { #[serde(rename = "data")] - pub data: Vec, - /// Included related resources that the user requested. + pub data: Vec, #[serde(rename = "included")] - pub included: Option>, + pub included: Option>, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -24,11 +21,9 @@ pub struct IncidentAttachmentsResponse { pub(crate) _unparsed: bool, } -impl IncidentAttachmentsResponse { - pub fn new( - data: Vec, - ) -> IncidentAttachmentsResponse { - IncidentAttachmentsResponse { +impl AttachmentArray { + pub fn new(data: Vec) -> AttachmentArray { + AttachmentArray { data, included: None, additional_properties: std::collections::BTreeMap::new(), @@ -36,10 +31,7 @@ impl IncidentAttachmentsResponse { } } - pub fn included( - mut self, - value: Vec, - ) -> Self { + pub fn included(mut self, value: Vec) -> Self { self.included = Some(value); self } @@ -53,14 +45,14 @@ impl IncidentAttachmentsResponse { } } -impl<'de> Deserialize<'de> for IncidentAttachmentsResponse { +impl<'de> Deserialize<'de> for AttachmentArray { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct IncidentAttachmentsResponseVisitor; - impl<'a> Visitor<'a> for IncidentAttachmentsResponseVisitor { - type Value = IncidentAttachmentsResponse; + struct AttachmentArrayVisitor; + impl<'a> Visitor<'a> for AttachmentArrayVisitor { + type Value = AttachmentArray; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -70,10 +62,8 @@ impl<'de> Deserialize<'de> for IncidentAttachmentsResponse { where M: MapAccess<'a>, { - let mut data: Option> = None; - let mut included: Option< - Vec, - > = None; + let mut data: Option> = None; + let mut included: Option> = None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -100,7 +90,7 @@ impl<'de> Deserialize<'de> for IncidentAttachmentsResponse { } let data = data.ok_or_else(|| M::Error::missing_field("data"))?; - let content = IncidentAttachmentsResponse { + let content = AttachmentArray { data, included, additional_properties, @@ -111,6 +101,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentsResponse { } } - deserializer.deserialize_any(IncidentAttachmentsResponseVisitor) + deserializer.deserialize_any(AttachmentArrayVisitor) } } diff --git a/src/datadogV2/model/model_incident_attachment_data.rs b/src/datadogV2/model/model_attachment_data.rs similarity index 74% rename from src/datadogV2/model/model_incident_attachment_data.rs rename to src/datadogV2/model/model_attachment_data.rs index 9a7907bfd..c283a9a3d 100644 --- a/src/datadogV2/model/model_incident_attachment_data.rs +++ b/src/datadogV2/model/model_attachment_data.rs @@ -6,20 +6,16 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// A single incident attachment. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct IncidentAttachmentData { - /// The attributes object for an attachment. +pub struct AttachmentData { #[serde(rename = "attributes")] - pub attributes: crate::datadogV2::model::IncidentAttachmentAttributes, - /// A unique identifier that represents the incident attachment. + pub attributes: crate::datadogV2::model::AttachmentDataAttributes, #[serde(rename = "id")] pub id: String, - /// The incident attachment's relationships. #[serde(rename = "relationships")] - pub relationships: crate::datadogV2::model::IncidentAttachmentRelationships, + pub relationships: crate::datadogV2::model::AttachmentDataRelationships, /// The incident attachment resource type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::IncidentAttachmentType, @@ -30,14 +26,14 @@ pub struct IncidentAttachmentData { pub(crate) _unparsed: bool, } -impl IncidentAttachmentData { +impl AttachmentData { pub fn new( - attributes: crate::datadogV2::model::IncidentAttachmentAttributes, + attributes: crate::datadogV2::model::AttachmentDataAttributes, id: String, - relationships: crate::datadogV2::model::IncidentAttachmentRelationships, + relationships: crate::datadogV2::model::AttachmentDataRelationships, type_: crate::datadogV2::model::IncidentAttachmentType, - ) -> IncidentAttachmentData { - IncidentAttachmentData { + ) -> AttachmentData { + AttachmentData { attributes, id, relationships, @@ -56,14 +52,14 @@ impl IncidentAttachmentData { } } -impl<'de> Deserialize<'de> for IncidentAttachmentData { +impl<'de> Deserialize<'de> for AttachmentData { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct IncidentAttachmentDataVisitor; - impl<'a> Visitor<'a> for IncidentAttachmentDataVisitor { - type Value = IncidentAttachmentData; + struct AttachmentDataVisitor; + impl<'a> Visitor<'a> for AttachmentDataVisitor { + type Value = AttachmentData; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -73,11 +69,11 @@ impl<'de> Deserialize<'de> for IncidentAttachmentData { where M: MapAccess<'a>, { - let mut attributes: Option = + let mut attributes: Option = None; let mut id: Option = None; let mut relationships: Option< - crate::datadogV2::model::IncidentAttachmentRelationships, + crate::datadogV2::model::AttachmentDataRelationships, > = None; let mut type_: Option = None; let mut additional_properties: std::collections::BTreeMap< @@ -90,14 +86,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentData { match k.as_str() { "attributes" => { attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); - if let Some(ref _attributes) = attributes { - match _attributes { - crate::datadogV2::model::IncidentAttachmentAttributes::UnparsedObject(_attributes) => { - _unparsed = true; - }, - _ => {} - } - } } "id" => { id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); @@ -130,7 +118,7 @@ impl<'de> Deserialize<'de> for IncidentAttachmentData { relationships.ok_or_else(|| M::Error::missing_field("relationships"))?; let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; - let content = IncidentAttachmentData { + let content = AttachmentData { attributes, id, relationships, @@ -143,6 +131,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentData { } } - deserializer.deserialize_any(IncidentAttachmentDataVisitor) + deserializer.deserialize_any(AttachmentDataVisitor) } } diff --git a/src/datadogV2/model/model_incident_attachment_link_attributes.rs b/src/datadogV2/model/model_attachment_data_attributes.rs similarity index 68% rename from src/datadogV2/model/model_incident_attachment_link_attributes.rs rename to src/datadogV2/model/model_attachment_data_attributes.rs index 46de41fc4..d4dd33a8e 100644 --- a/src/datadogV2/model/model_incident_attachment_link_attributes.rs +++ b/src/datadogV2/model/model_attachment_data_attributes.rs @@ -6,18 +6,14 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// The attributes object for a link attachment. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct IncidentAttachmentLinkAttributes { - /// The link attachment. +pub struct AttachmentDataAttributes { #[serde(rename = "attachment")] - pub attachment: crate::datadogV2::model::IncidentAttachmentLinkAttributesAttachmentObject, - /// The type of link attachment attributes. + pub attachment: Option, #[serde(rename = "attachment_type")] - pub attachment_type: crate::datadogV2::model::IncidentAttachmentLinkAttachmentType, - /// Timestamp when the incident attachment link was last modified. + pub attachment_type: Option, #[serde(rename = "modified")] pub modified: Option>, #[serde(flatten)] @@ -27,20 +23,33 @@ pub struct IncidentAttachmentLinkAttributes { pub(crate) _unparsed: bool, } -impl IncidentAttachmentLinkAttributes { - pub fn new( - attachment: crate::datadogV2::model::IncidentAttachmentLinkAttributesAttachmentObject, - attachment_type: crate::datadogV2::model::IncidentAttachmentLinkAttachmentType, - ) -> IncidentAttachmentLinkAttributes { - IncidentAttachmentLinkAttributes { - attachment, - attachment_type, +impl AttachmentDataAttributes { + pub fn new() -> AttachmentDataAttributes { + AttachmentDataAttributes { + attachment: None, + attachment_type: None, modified: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + pub fn attachment( + mut self, + value: crate::datadogV2::model::AttachmentDataAttributesAttachment, + ) -> Self { + self.attachment = Some(value); + self + } + + pub fn attachment_type( + mut self, + value: crate::datadogV2::model::AttachmentDataAttributesAttachmentType, + ) -> Self { + self.attachment_type = Some(value); + self + } + pub fn modified(mut self, value: chrono::DateTime) -> Self { self.modified = Some(value); self @@ -55,14 +64,20 @@ impl IncidentAttachmentLinkAttributes { } } -impl<'de> Deserialize<'de> for IncidentAttachmentLinkAttributes { +impl Default for AttachmentDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AttachmentDataAttributes { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct IncidentAttachmentLinkAttributesVisitor; - impl<'a> Visitor<'a> for IncidentAttachmentLinkAttributesVisitor { - type Value = IncidentAttachmentLinkAttributes; + struct AttachmentDataAttributesVisitor; + impl<'a> Visitor<'a> for AttachmentDataAttributesVisitor { + type Value = AttachmentDataAttributes; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -73,10 +88,10 @@ impl<'de> Deserialize<'de> for IncidentAttachmentLinkAttributes { M: MapAccess<'a>, { let mut attachment: Option< - crate::datadogV2::model::IncidentAttachmentLinkAttributesAttachmentObject, + crate::datadogV2::model::AttachmentDataAttributesAttachment, > = None; let mut attachment_type: Option< - crate::datadogV2::model::IncidentAttachmentLinkAttachmentType, + crate::datadogV2::model::AttachmentDataAttributesAttachmentType, > = None; let mut modified: Option> = None; let mut additional_properties: std::collections::BTreeMap< @@ -88,14 +103,20 @@ impl<'de> Deserialize<'de> for IncidentAttachmentLinkAttributes { while let Some((k, v)) = map.next_entry::()? { match k.as_str() { "attachment" => { + if v.is_null() { + continue; + } attachment = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } "attachment_type" => { + if v.is_null() { + continue; + } attachment_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _attachment_type) = attachment_type { match _attachment_type { - crate::datadogV2::model::IncidentAttachmentLinkAttachmentType::UnparsedObject(_attachment_type) => { + crate::datadogV2::model::AttachmentDataAttributesAttachmentType::UnparsedObject(_attachment_type) => { _unparsed = true; }, _ => {} @@ -115,11 +136,8 @@ impl<'de> Deserialize<'de> for IncidentAttachmentLinkAttributes { } } } - let attachment = attachment.ok_or_else(|| M::Error::missing_field("attachment"))?; - let attachment_type = - attachment_type.ok_or_else(|| M::Error::missing_field("attachment_type"))?; - let content = IncidentAttachmentLinkAttributes { + let content = AttachmentDataAttributes { attachment, attachment_type, modified, @@ -131,6 +149,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentLinkAttributes { } } - deserializer.deserialize_any(IncidentAttachmentLinkAttributesVisitor) + deserializer.deserialize_any(AttachmentDataAttributesVisitor) } } diff --git a/src/datadogV2/model/model_incident_attachments_postmortem_attributes_attachment_object.rs b/src/datadogV2/model/model_attachment_data_attributes_attachment.rs similarity index 68% rename from src/datadogV2/model/model_incident_attachments_postmortem_attributes_attachment_object.rs rename to src/datadogV2/model/model_attachment_data_attributes_attachment.rs index 14d6b719e..341d6646e 100644 --- a/src/datadogV2/model/model_incident_attachments_postmortem_attributes_attachment_object.rs +++ b/src/datadogV2/model/model_attachment_data_attributes_attachment.rs @@ -6,17 +6,14 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// The postmortem attachment. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct IncidentAttachmentsPostmortemAttributesAttachmentObject { - /// The URL of this notebook attachment. +pub struct AttachmentDataAttributesAttachment { #[serde(rename = "documentUrl")] - pub document_url: String, - /// The title of this postmortem attachment. + pub document_url: Option, #[serde(rename = "title")] - pub title: String, + pub title: Option, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -24,19 +21,26 @@ pub struct IncidentAttachmentsPostmortemAttributesAttachmentObject { pub(crate) _unparsed: bool, } -impl IncidentAttachmentsPostmortemAttributesAttachmentObject { - pub fn new( - document_url: String, - title: String, - ) -> IncidentAttachmentsPostmortemAttributesAttachmentObject { - IncidentAttachmentsPostmortemAttributesAttachmentObject { - document_url, - title, +impl AttachmentDataAttributesAttachment { + pub fn new() -> AttachmentDataAttributesAttachment { + AttachmentDataAttributesAttachment { + document_url: None, + title: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + pub fn document_url(mut self, value: String) -> Self { + self.document_url = Some(value); + self + } + + pub fn title(mut self, value: String) -> Self { + self.title = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -46,14 +50,20 @@ impl IncidentAttachmentsPostmortemAttributesAttachmentObject { } } -impl<'de> Deserialize<'de> for IncidentAttachmentsPostmortemAttributesAttachmentObject { +impl Default for AttachmentDataAttributesAttachment { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AttachmentDataAttributesAttachment { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct IncidentAttachmentsPostmortemAttributesAttachmentObjectVisitor; - impl<'a> Visitor<'a> for IncidentAttachmentsPostmortemAttributesAttachmentObjectVisitor { - type Value = IncidentAttachmentsPostmortemAttributesAttachmentObject; + struct AttachmentDataAttributesAttachmentVisitor; + impl<'a> Visitor<'a> for AttachmentDataAttributesAttachmentVisitor { + type Value = AttachmentDataAttributesAttachment; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -74,10 +84,16 @@ impl<'de> Deserialize<'de> for IncidentAttachmentsPostmortemAttributesAttachment while let Some((k, v)) = map.next_entry::()? { match k.as_str() { "documentUrl" => { + if v.is_null() { + continue; + } document_url = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } "title" => { + if v.is_null() { + continue; + } title = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } &_ => { @@ -87,11 +103,8 @@ impl<'de> Deserialize<'de> for IncidentAttachmentsPostmortemAttributesAttachment } } } - let document_url = - document_url.ok_or_else(|| M::Error::missing_field("document_url"))?; - let title = title.ok_or_else(|| M::Error::missing_field("title"))?; - let content = IncidentAttachmentsPostmortemAttributesAttachmentObject { + let content = AttachmentDataAttributesAttachment { document_url, title, additional_properties, @@ -102,6 +115,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentsPostmortemAttributesAttachment } } - deserializer.deserialize_any(IncidentAttachmentsPostmortemAttributesAttachmentObjectVisitor) + deserializer.deserialize_any(AttachmentDataAttributesAttachmentVisitor) } } diff --git a/src/datadogV2/model/model_incident_attachment_attachment_type.rs b/src/datadogV2/model/model_attachment_data_attributes_attachment_type.rs similarity index 85% rename from src/datadogV2/model/model_incident_attachment_attachment_type.rs rename to src/datadogV2/model/model_attachment_data_attributes_attachment_type.rs index 750608422..b7e653e16 100644 --- a/src/datadogV2/model/model_incident_attachment_attachment_type.rs +++ b/src/datadogV2/model/model_attachment_data_attributes_attachment_type.rs @@ -6,23 +6,23 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[non_exhaustive] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum IncidentAttachmentAttachmentType { - LINK, +pub enum AttachmentDataAttributesAttachmentType { POSTMORTEM, + LINK, UnparsedObject(crate::datadog::UnparsedObject), } -impl ToString for IncidentAttachmentAttachmentType { +impl ToString for AttachmentDataAttributesAttachmentType { fn to_string(&self) -> String { match self { - Self::LINK => String::from("link"), Self::POSTMORTEM => String::from("postmortem"), + Self::LINK => String::from("link"), Self::UnparsedObject(v) => v.value.to_string(), } } } -impl Serialize for IncidentAttachmentAttachmentType { +impl Serialize for AttachmentDataAttributesAttachmentType { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -34,15 +34,15 @@ impl Serialize for IncidentAttachmentAttachmentType { } } -impl<'de> Deserialize<'de> for IncidentAttachmentAttachmentType { +impl<'de> Deserialize<'de> for AttachmentDataAttributesAttachmentType { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { let s: String = String::deserialize(deserializer)?; Ok(match s.as_str() { - "link" => Self::LINK, "postmortem" => Self::POSTMORTEM, + "link" => Self::LINK, _ => Self::UnparsedObject(crate::datadog::UnparsedObject { value: serde_json::Value::String(s.into()), }), diff --git a/src/datadogV2/model/model_incident_attachment_relationships.rs b/src/datadogV2/model/model_attachment_data_relationships.rs similarity index 74% rename from src/datadogV2/model/model_incident_attachment_relationships.rs rename to src/datadogV2/model/model_attachment_data_relationships.rs index 0ffde2f1f..82011d3fd 100644 --- a/src/datadogV2/model/model_incident_attachment_relationships.rs +++ b/src/datadogV2/model/model_attachment_data_relationships.rs @@ -6,14 +6,13 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// The incident attachment's relationships. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct IncidentAttachmentRelationships { - /// Relationship to user. +pub struct AttachmentDataRelationships { #[serde(rename = "last_modified_by_user")] - pub last_modified_by_user: Option, + pub last_modified_by_user: + Option, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -21,9 +20,9 @@ pub struct IncidentAttachmentRelationships { pub(crate) _unparsed: bool, } -impl IncidentAttachmentRelationships { - pub fn new() -> IncidentAttachmentRelationships { - IncidentAttachmentRelationships { +impl AttachmentDataRelationships { + pub fn new() -> AttachmentDataRelationships { + AttachmentDataRelationships { last_modified_by_user: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, @@ -32,7 +31,7 @@ impl IncidentAttachmentRelationships { pub fn last_modified_by_user( mut self, - value: crate::datadogV2::model::RelationshipToUser, + value: crate::datadogV2::model::AttachmentDataRelationshipsLastModifiedByUser, ) -> Self { self.last_modified_by_user = Some(value); self @@ -47,20 +46,20 @@ impl IncidentAttachmentRelationships { } } -impl Default for IncidentAttachmentRelationships { +impl Default for AttachmentDataRelationships { fn default() -> Self { Self::new() } } -impl<'de> Deserialize<'de> for IncidentAttachmentRelationships { +impl<'de> Deserialize<'de> for AttachmentDataRelationships { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct IncidentAttachmentRelationshipsVisitor; - impl<'a> Visitor<'a> for IncidentAttachmentRelationshipsVisitor { - type Value = IncidentAttachmentRelationships; + struct AttachmentDataRelationshipsVisitor; + impl<'a> Visitor<'a> for AttachmentDataRelationshipsVisitor { + type Value = AttachmentDataRelationships; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -70,8 +69,9 @@ impl<'de> Deserialize<'de> for IncidentAttachmentRelationships { where M: MapAccess<'a>, { - let mut last_modified_by_user: Option = - None; + let mut last_modified_by_user: Option< + crate::datadogV2::model::AttachmentDataRelationshipsLastModifiedByUser, + > = None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -95,7 +95,7 @@ impl<'de> Deserialize<'de> for IncidentAttachmentRelationships { } } - let content = IncidentAttachmentRelationships { + let content = AttachmentDataRelationships { last_modified_by_user, additional_properties, _unparsed, @@ -105,6 +105,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentRelationships { } } - deserializer.deserialize_any(IncidentAttachmentRelationshipsVisitor) + deserializer.deserialize_any(AttachmentDataRelationshipsVisitor) } } diff --git a/src/datadogV2/model/model_incident_attachment_update_request.rs b/src/datadogV2/model/model_attachment_data_relationships_last_modified_by_user.rs similarity index 66% rename from src/datadogV2/model/model_incident_attachment_update_request.rs rename to src/datadogV2/model/model_attachment_data_relationships_last_modified_by_user.rs index 315e58ca7..f125eb2ee 100644 --- a/src/datadogV2/model/model_incident_attachment_update_request.rs +++ b/src/datadogV2/model/model_attachment_data_relationships_last_modified_by_user.rs @@ -6,17 +6,12 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// The update request for an incident's attachments. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct IncidentAttachmentUpdateRequest { - /// An array of incident attachments. An attachment object without an "id" key indicates that you want to - /// create that attachment. An attachment object without an "attributes" key indicates that you want to - /// delete that attachment. An attachment object with both the "id" key and a populated "attributes" object - /// indicates that you want to update that attachment. +pub struct AttachmentDataRelationshipsLastModifiedByUser { #[serde(rename = "data")] - pub data: Vec, + pub data: crate::datadogV2::model::AttachmentDataRelationshipsLastModifiedByUserData, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -24,11 +19,11 @@ pub struct IncidentAttachmentUpdateRequest { pub(crate) _unparsed: bool, } -impl IncidentAttachmentUpdateRequest { +impl AttachmentDataRelationshipsLastModifiedByUser { pub fn new( - data: Vec, - ) -> IncidentAttachmentUpdateRequest { - IncidentAttachmentUpdateRequest { + data: crate::datadogV2::model::AttachmentDataRelationshipsLastModifiedByUserData, + ) -> AttachmentDataRelationshipsLastModifiedByUser { + AttachmentDataRelationshipsLastModifiedByUser { data, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, @@ -44,14 +39,14 @@ impl IncidentAttachmentUpdateRequest { } } -impl<'de> Deserialize<'de> for IncidentAttachmentUpdateRequest { +impl<'de> Deserialize<'de> for AttachmentDataRelationshipsLastModifiedByUser { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct IncidentAttachmentUpdateRequestVisitor; - impl<'a> Visitor<'a> for IncidentAttachmentUpdateRequestVisitor { - type Value = IncidentAttachmentUpdateRequest; + struct AttachmentDataRelationshipsLastModifiedByUserVisitor; + impl<'a> Visitor<'a> for AttachmentDataRelationshipsLastModifiedByUserVisitor { + type Value = AttachmentDataRelationshipsLastModifiedByUser; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -61,8 +56,9 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateRequest { where M: MapAccess<'a>, { - let mut data: Option> = - None; + let mut data: Option< + crate::datadogV2::model::AttachmentDataRelationshipsLastModifiedByUserData, + > = None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -83,7 +79,7 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateRequest { } let data = data.ok_or_else(|| M::Error::missing_field("data"))?; - let content = IncidentAttachmentUpdateRequest { + let content = AttachmentDataRelationshipsLastModifiedByUser { data, additional_properties, _unparsed, @@ -93,6 +89,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateRequest { } } - deserializer.deserialize_any(IncidentAttachmentUpdateRequestVisitor) + deserializer.deserialize_any(AttachmentDataRelationshipsLastModifiedByUserVisitor) } } diff --git a/src/datadogV2/model/model_attachment_data_relationships_last_modified_by_user_data.rs b/src/datadogV2/model/model_attachment_data_relationships_last_modified_by_user_data.rs new file mode 100644 index 000000000..a3cb68ad3 --- /dev/null +++ b/src/datadogV2/model/model_attachment_data_relationships_last_modified_by_user_data.rs @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AttachmentDataRelationshipsLastModifiedByUserData { + #[serde(rename = "id")] + pub id: String, + /// Users resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::UserType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AttachmentDataRelationshipsLastModifiedByUserData { + pub fn new( + id: String, + type_: crate::datadogV2::model::UserType, + ) -> AttachmentDataRelationshipsLastModifiedByUserData { + AttachmentDataRelationshipsLastModifiedByUserData { + 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 AttachmentDataRelationshipsLastModifiedByUserData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AttachmentDataRelationshipsLastModifiedByUserDataVisitor; + impl<'a> Visitor<'a> for AttachmentDataRelationshipsLastModifiedByUserDataVisitor { + type Value = AttachmentDataRelationshipsLastModifiedByUserData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::UserType::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 = AttachmentDataRelationshipsLastModifiedByUserData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AttachmentDataRelationshipsLastModifiedByUserDataVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_attachments_response_included_item.rs b/src/datadogV2/model/model_attachment_included.rs similarity index 64% rename from src/datadogV2/model/model_incident_attachments_response_included_item.rs rename to src/datadogV2/model/model_attachment_included.rs index 3085d863b..79ab9e473 100644 --- a/src/datadogV2/model/model_incident_attachments_response_included_item.rs +++ b/src/datadogV2/model/model_attachment_included.rs @@ -3,29 +3,29 @@ // Copyright 2019-Present Datadog, Inc. use serde::{Deserialize, Deserializer, Serialize}; -/// An object related to an attachment that is included in the response. #[non_exhaustive] #[derive(Clone, Debug, PartialEq, Serialize)] #[serde(untagged)] -pub enum IncidentAttachmentsResponseIncludedItem { - User(Box), +pub enum AttachmentIncluded { + User140420082644000(Box), UnparsedObject(crate::datadog::UnparsedObject), } -impl<'de> Deserialize<'de> for IncidentAttachmentsResponseIncludedItem { +impl<'de> Deserialize<'de> for AttachmentIncluded { 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 let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { if !_v._unparsed { - return Ok(IncidentAttachmentsResponseIncludedItem::User(_v)); + return Ok(AttachmentIncluded::User140420082644000(_v)); } } - return Ok(IncidentAttachmentsResponseIncludedItem::UnparsedObject( + return Ok(AttachmentIncluded::UnparsedObject( crate::datadog::UnparsedObject { value }, )); } diff --git a/src/datadogV2/model/model_create_attachment_request.rs b/src/datadogV2/model/model_create_attachment_request.rs new file mode 100644 index 000000000..cf550f18f --- /dev/null +++ b/src/datadogV2/model/model_create_attachment_request.rs @@ -0,0 +1,103 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateAttachmentRequest { + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateAttachmentRequest { + pub fn new() -> CreateAttachmentRequest { + CreateAttachmentRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::CreateAttachmentRequestData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateAttachmentRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateAttachmentRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateAttachmentRequestVisitor; + impl<'a> Visitor<'a> for CreateAttachmentRequestVisitor { + type Value = CreateAttachmentRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateAttachmentRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateAttachmentRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_attachment_update_data.rs b/src/datadogV2/model/model_create_attachment_request_data.rs similarity index 75% rename from src/datadogV2/model/model_incident_attachment_update_data.rs rename to src/datadogV2/model/model_create_attachment_request_data.rs index c559bea85..f079229c3 100644 --- a/src/datadogV2/model/model_incident_attachment_update_data.rs +++ b/src/datadogV2/model/model_create_attachment_request_data.rs @@ -6,15 +6,12 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// A single incident attachment. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct IncidentAttachmentUpdateData { - /// Incident attachment attributes. +pub struct CreateAttachmentRequestData { #[serde(rename = "attributes")] - pub attributes: Option, - /// A unique identifier that represents the incident attachment. + pub attributes: Option, #[serde(rename = "id")] pub id: Option, /// The incident attachment resource type. @@ -27,11 +24,11 @@ pub struct IncidentAttachmentUpdateData { pub(crate) _unparsed: bool, } -impl IncidentAttachmentUpdateData { +impl CreateAttachmentRequestData { pub fn new( type_: crate::datadogV2::model::IncidentAttachmentType, - ) -> IncidentAttachmentUpdateData { - IncidentAttachmentUpdateData { + ) -> CreateAttachmentRequestData { + CreateAttachmentRequestData { attributes: None, id: None, type_, @@ -42,7 +39,7 @@ impl IncidentAttachmentUpdateData { pub fn attributes( mut self, - value: crate::datadogV2::model::IncidentAttachmentUpdateAttributes, + value: crate::datadogV2::model::CreateAttachmentRequestDataAttributes, ) -> Self { self.attributes = Some(value); self @@ -62,14 +59,14 @@ impl IncidentAttachmentUpdateData { } } -impl<'de> Deserialize<'de> for IncidentAttachmentUpdateData { +impl<'de> Deserialize<'de> for CreateAttachmentRequestData { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct IncidentAttachmentUpdateDataVisitor; - impl<'a> Visitor<'a> for IncidentAttachmentUpdateDataVisitor { - type Value = IncidentAttachmentUpdateData; + struct CreateAttachmentRequestDataVisitor; + impl<'a> Visitor<'a> for CreateAttachmentRequestDataVisitor { + type Value = CreateAttachmentRequestData; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -80,7 +77,7 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateData { M: MapAccess<'a>, { let mut attributes: Option< - crate::datadogV2::model::IncidentAttachmentUpdateAttributes, + crate::datadogV2::model::CreateAttachmentRequestDataAttributes, > = None; let mut id: Option = None; let mut type_: Option = None; @@ -97,14 +94,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateData { continue; } attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); - if let Some(ref _attributes) = attributes { - match _attributes { - crate::datadogV2::model::IncidentAttachmentUpdateAttributes::UnparsedObject(_attributes) => { - _unparsed = true; - }, - _ => {} - } - } } "id" => { if v.is_null() { @@ -132,7 +121,7 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateData { } let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; - let content = IncidentAttachmentUpdateData { + let content = CreateAttachmentRequestData { attributes, id, type_, @@ -144,6 +133,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentUpdateData { } } - deserializer.deserialize_any(IncidentAttachmentUpdateDataVisitor) + deserializer.deserialize_any(CreateAttachmentRequestDataVisitor) } } diff --git a/src/datadogV2/model/model_incident_attachment_postmortem_attributes.rs b/src/datadogV2/model/model_create_attachment_request_data_attributes.rs similarity index 60% rename from src/datadogV2/model/model_incident_attachment_postmortem_attributes.rs rename to src/datadogV2/model/model_create_attachment_request_data_attributes.rs index a6e39e8d8..fa66f26ac 100644 --- a/src/datadogV2/model/model_incident_attachment_postmortem_attributes.rs +++ b/src/datadogV2/model/model_create_attachment_request_data_attributes.rs @@ -6,18 +6,15 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// The attributes object for a postmortem attachment. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct IncidentAttachmentPostmortemAttributes { - /// The postmortem attachment. +pub struct CreateAttachmentRequestDataAttributes { #[serde(rename = "attachment")] pub attachment: - crate::datadogV2::model::IncidentAttachmentsPostmortemAttributesAttachmentObject, - /// The type of postmortem attachment attributes. + Option, #[serde(rename = "attachment_type")] - pub attachment_type: crate::datadogV2::model::IncidentAttachmentPostmortemAttachmentType, + pub attachment_type: Option, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -25,19 +22,32 @@ pub struct IncidentAttachmentPostmortemAttributes { pub(crate) _unparsed: bool, } -impl IncidentAttachmentPostmortemAttributes { - pub fn new( - attachment: crate::datadogV2::model::IncidentAttachmentsPostmortemAttributesAttachmentObject, - attachment_type: crate::datadogV2::model::IncidentAttachmentPostmortemAttachmentType, - ) -> IncidentAttachmentPostmortemAttributes { - IncidentAttachmentPostmortemAttributes { - attachment, - attachment_type, +impl CreateAttachmentRequestDataAttributes { + pub fn new() -> CreateAttachmentRequestDataAttributes { + CreateAttachmentRequestDataAttributes { + attachment: None, + attachment_type: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + pub fn attachment( + mut self, + value: crate::datadogV2::model::CreateAttachmentRequestDataAttributesAttachment, + ) -> Self { + self.attachment = Some(value); + self + } + + pub fn attachment_type( + mut self, + value: crate::datadogV2::model::AttachmentDataAttributesAttachmentType, + ) -> Self { + self.attachment_type = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -47,14 +57,20 @@ impl IncidentAttachmentPostmortemAttributes { } } -impl<'de> Deserialize<'de> for IncidentAttachmentPostmortemAttributes { +impl Default for CreateAttachmentRequestDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateAttachmentRequestDataAttributes { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct IncidentAttachmentPostmortemAttributesVisitor; - impl<'a> Visitor<'a> for IncidentAttachmentPostmortemAttributesVisitor { - type Value = IncidentAttachmentPostmortemAttributes; + struct CreateAttachmentRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateAttachmentRequestDataAttributesVisitor { + type Value = CreateAttachmentRequestDataAttributes; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -64,9 +80,11 @@ impl<'de> Deserialize<'de> for IncidentAttachmentPostmortemAttributes { where M: MapAccess<'a>, { - let mut attachment: Option = None; + let mut attachment: Option< + crate::datadogV2::model::CreateAttachmentRequestDataAttributesAttachment, + > = None; let mut attachment_type: Option< - crate::datadogV2::model::IncidentAttachmentPostmortemAttachmentType, + crate::datadogV2::model::AttachmentDataAttributesAttachmentType, > = None; let mut additional_properties: std::collections::BTreeMap< String, @@ -77,14 +95,20 @@ impl<'de> Deserialize<'de> for IncidentAttachmentPostmortemAttributes { while let Some((k, v)) = map.next_entry::()? { match k.as_str() { "attachment" => { + if v.is_null() { + continue; + } attachment = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } "attachment_type" => { + if v.is_null() { + continue; + } attachment_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _attachment_type) = attachment_type { match _attachment_type { - crate::datadogV2::model::IncidentAttachmentPostmortemAttachmentType::UnparsedObject(_attachment_type) => { + crate::datadogV2::model::AttachmentDataAttributesAttachmentType::UnparsedObject(_attachment_type) => { _unparsed = true; }, _ => {} @@ -98,11 +122,8 @@ impl<'de> Deserialize<'de> for IncidentAttachmentPostmortemAttributes { } } } - let attachment = attachment.ok_or_else(|| M::Error::missing_field("attachment"))?; - let attachment_type = - attachment_type.ok_or_else(|| M::Error::missing_field("attachment_type"))?; - let content = IncidentAttachmentPostmortemAttributes { + let content = CreateAttachmentRequestDataAttributes { attachment, attachment_type, additional_properties, @@ -113,6 +134,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentPostmortemAttributes { } } - deserializer.deserialize_any(IncidentAttachmentPostmortemAttributesVisitor) + deserializer.deserialize_any(CreateAttachmentRequestDataAttributesVisitor) } } diff --git a/src/datadogV2/model/model_create_attachment_request_data_attributes_attachment.rs b/src/datadogV2/model/model_create_attachment_request_data_attributes_attachment.rs new file mode 100644 index 000000000..f82e1c36d --- /dev/null +++ b/src/datadogV2/model/model_create_attachment_request_data_attributes_attachment.rs @@ -0,0 +1,120 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateAttachmentRequestDataAttributesAttachment { + #[serde(rename = "documentUrl")] + pub document_url: Option, + #[serde(rename = "title")] + pub title: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateAttachmentRequestDataAttributesAttachment { + pub fn new() -> CreateAttachmentRequestDataAttributesAttachment { + CreateAttachmentRequestDataAttributesAttachment { + document_url: None, + title: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn document_url(mut self, value: String) -> Self { + self.document_url = Some(value); + self + } + + pub fn title(mut self, value: String) -> Self { + self.title = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateAttachmentRequestDataAttributesAttachment { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateAttachmentRequestDataAttributesAttachment { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateAttachmentRequestDataAttributesAttachmentVisitor; + impl<'a> Visitor<'a> for CreateAttachmentRequestDataAttributesAttachmentVisitor { + type Value = CreateAttachmentRequestDataAttributesAttachment; + + 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 document_url: Option = None; + let mut title: 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() { + "documentUrl" => { + if v.is_null() { + continue; + } + document_url = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "title" => { + if v.is_null() { + continue; + } + title = 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 = CreateAttachmentRequestDataAttributesAttachment { + document_url, + title, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateAttachmentRequestDataAttributesAttachmentVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_attachment_attributes.rs b/src/datadogV2/model/model_incident_attachment_attributes.rs deleted file mode 100644 index cdc45d11d..000000000 --- a/src/datadogV2/model/model_incident_attachment_attributes.rs +++ /dev/null @@ -1,49 +0,0 @@ -// 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}; - -/// The attributes object for an attachment. -#[non_exhaustive] -#[derive(Clone, Debug, PartialEq, Serialize)] -#[serde(untagged)] -pub enum IncidentAttachmentAttributes { - IncidentAttachmentPostmortemAttributes( - Box, - ), - IncidentAttachmentLinkAttributes( - Box, - ), - UnparsedObject(crate::datadog::UnparsedObject), -} - -impl<'de> Deserialize<'de> for IncidentAttachmentAttributes { - 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::< - Box, - >(value.clone()) - { - if !_v._unparsed { - return Ok( - IncidentAttachmentAttributes::IncidentAttachmentPostmortemAttributes(_v), - ); - } - } - if let Ok(_v) = serde_json::from_value::< - Box, - >(value.clone()) - { - if !_v._unparsed { - return Ok(IncidentAttachmentAttributes::IncidentAttachmentLinkAttributes(_v)); - } - } - - return Ok(IncidentAttachmentAttributes::UnparsedObject( - crate::datadog::UnparsedObject { value }, - )); - } -} diff --git a/src/datadogV2/model/model_incident_attachment_link_attachment_type.rs b/src/datadogV2/model/model_incident_attachment_link_attachment_type.rs deleted file mode 100644 index 26052f06e..000000000 --- a/src/datadogV2/model/model_incident_attachment_link_attachment_type.rs +++ /dev/null @@ -1,48 +0,0 @@ -// 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 IncidentAttachmentLinkAttachmentType { - LINK, - UnparsedObject(crate::datadog::UnparsedObject), -} - -impl ToString for IncidentAttachmentLinkAttachmentType { - fn to_string(&self) -> String { - match self { - Self::LINK => String::from("link"), - Self::UnparsedObject(v) => v.value.to_string(), - } - } -} - -impl Serialize for IncidentAttachmentLinkAttachmentType { - 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 IncidentAttachmentLinkAttachmentType { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let s: String = String::deserialize(deserializer)?; - Ok(match s.as_str() { - "link" => Self::LINK, - _ => Self::UnparsedObject(crate::datadog::UnparsedObject { - value: serde_json::Value::String(s.into()), - }), - }) - } -} diff --git a/src/datadogV2/model/model_incident_attachment_postmortem_attachment_type.rs b/src/datadogV2/model/model_incident_attachment_postmortem_attachment_type.rs deleted file mode 100644 index da78706f0..000000000 --- a/src/datadogV2/model/model_incident_attachment_postmortem_attachment_type.rs +++ /dev/null @@ -1,48 +0,0 @@ -// 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 IncidentAttachmentPostmortemAttachmentType { - POSTMORTEM, - UnparsedObject(crate::datadog::UnparsedObject), -} - -impl ToString for IncidentAttachmentPostmortemAttachmentType { - fn to_string(&self) -> String { - match self { - Self::POSTMORTEM => String::from("postmortem"), - Self::UnparsedObject(v) => v.value.to_string(), - } - } -} - -impl Serialize for IncidentAttachmentPostmortemAttachmentType { - 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 IncidentAttachmentPostmortemAttachmentType { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let s: String = String::deserialize(deserializer)?; - Ok(match s.as_str() { - "postmortem" => Self::POSTMORTEM, - _ => Self::UnparsedObject(crate::datadog::UnparsedObject { - value: serde_json::Value::String(s.into()), - }), - }) - } -} diff --git a/src/datadogV2/model/model_incident_attachment_update_attributes.rs b/src/datadogV2/model/model_incident_attachment_update_attributes.rs deleted file mode 100644 index 3b5c1c5bd..000000000 --- a/src/datadogV2/model/model_incident_attachment_update_attributes.rs +++ /dev/null @@ -1,51 +0,0 @@ -// 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}; - -/// Incident attachment attributes. -#[non_exhaustive] -#[derive(Clone, Debug, PartialEq, Serialize)] -#[serde(untagged)] -pub enum IncidentAttachmentUpdateAttributes { - IncidentAttachmentPostmortemAttributes( - Box, - ), - IncidentAttachmentLinkAttributes( - Box, - ), - UnparsedObject(crate::datadog::UnparsedObject), -} - -impl<'de> Deserialize<'de> for IncidentAttachmentUpdateAttributes { - 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::< - Box, - >(value.clone()) - { - if !_v._unparsed { - return Ok( - IncidentAttachmentUpdateAttributes::IncidentAttachmentPostmortemAttributes(_v), - ); - } - } - if let Ok(_v) = serde_json::from_value::< - Box, - >(value.clone()) - { - if !_v._unparsed { - return Ok( - IncidentAttachmentUpdateAttributes::IncidentAttachmentLinkAttributes(_v), - ); - } - } - - return Ok(IncidentAttachmentUpdateAttributes::UnparsedObject( - crate::datadog::UnparsedObject { value }, - )); - } -} diff --git a/src/datadogV2/model/model_incident_response_included_item.rs b/src/datadogV2/model/model_incident_response_included_item.rs index 62b0fd236..1b253404b 100644 --- a/src/datadogV2/model/model_incident_response_included_item.rs +++ b/src/datadogV2/model/model_incident_response_included_item.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Deserializer, Serialize}; #[serde(untagged)] pub enum IncidentResponseIncludedItem { IncidentUserData(Box), - IncidentAttachmentData(Box), + AttachmentData(Box), UnparsedObject(crate::datadog::UnparsedObject), } @@ -26,11 +26,11 @@ impl<'de> Deserialize<'de> for IncidentResponseIncludedItem { return Ok(IncidentResponseIncludedItem::IncidentUserData(_v)); } } - if let Ok(_v) = serde_json::from_value::>( - value.clone(), - ) { + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { if !_v._unparsed { - return Ok(IncidentResponseIncludedItem::IncidentAttachmentData(_v)); + return Ok(IncidentResponseIncludedItem::AttachmentData(_v)); } } diff --git a/src/datadogV2/model/model_patch_attachment_request.rs b/src/datadogV2/model/model_patch_attachment_request.rs new file mode 100644 index 000000000..feba8cc12 --- /dev/null +++ b/src/datadogV2/model/model_patch_attachment_request.rs @@ -0,0 +1,103 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchAttachmentRequest { + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchAttachmentRequest { + pub fn new() -> PatchAttachmentRequest { + PatchAttachmentRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::PatchAttachmentRequestData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchAttachmentRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchAttachmentRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchAttachmentRequestVisitor; + impl<'a> Visitor<'a> for PatchAttachmentRequestVisitor { + type Value = PatchAttachmentRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchAttachmentRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchAttachmentRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_attachment_request_data.rs b/src/datadogV2/model/model_patch_attachment_request_data.rs new file mode 100644 index 000000000..e39e57a57 --- /dev/null +++ b/src/datadogV2/model/model_patch_attachment_request_data.rs @@ -0,0 +1,138 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchAttachmentRequestData { + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(rename = "id")] + pub id: Option, + /// The incident attachment resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentAttachmentType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchAttachmentRequestData { + pub fn new( + type_: crate::datadogV2::model::IncidentAttachmentType, + ) -> PatchAttachmentRequestData { + PatchAttachmentRequestData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::PatchAttachmentRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchAttachmentRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchAttachmentRequestDataVisitor; + impl<'a> Visitor<'a> for PatchAttachmentRequestDataVisitor { + type Value = PatchAttachmentRequestData; + + 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::PatchAttachmentRequestDataAttributes, + > = 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" => { + if v.is_null() { + continue; + } + 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::IncidentAttachmentType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PatchAttachmentRequestData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchAttachmentRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_attachment_request_data_attributes.rs b/src/datadogV2/model/model_patch_attachment_request_data_attributes.rs new file mode 100644 index 000000000..668e0aa27 --- /dev/null +++ b/src/datadogV2/model/model_patch_attachment_request_data_attributes.rs @@ -0,0 +1,108 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchAttachmentRequestDataAttributes { + #[serde(rename = "attachment")] + pub attachment: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchAttachmentRequestDataAttributes { + pub fn new() -> PatchAttachmentRequestDataAttributes { + PatchAttachmentRequestDataAttributes { + attachment: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attachment( + mut self, + value: crate::datadogV2::model::PatchAttachmentRequestDataAttributesAttachment, + ) -> Self { + self.attachment = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchAttachmentRequestDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchAttachmentRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchAttachmentRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for PatchAttachmentRequestDataAttributesVisitor { + type Value = PatchAttachmentRequestDataAttributes; + + 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 attachment: Option< + crate::datadogV2::model::PatchAttachmentRequestDataAttributesAttachment, + > = 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() { + "attachment" => { + if v.is_null() { + continue; + } + attachment = 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 = PatchAttachmentRequestDataAttributes { + attachment, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchAttachmentRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_attachment_link_attributes_attachment_object.rs b/src/datadogV2/model/model_patch_attachment_request_data_attributes_attachment.rs similarity index 66% rename from src/datadogV2/model/model_incident_attachment_link_attributes_attachment_object.rs rename to src/datadogV2/model/model_patch_attachment_request_data_attributes_attachment.rs index d7a4e539d..9cf19b54b 100644 --- a/src/datadogV2/model/model_incident_attachment_link_attributes_attachment_object.rs +++ b/src/datadogV2/model/model_patch_attachment_request_data_attributes_attachment.rs @@ -6,17 +6,14 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// The link attachment. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct IncidentAttachmentLinkAttributesAttachmentObject { - /// The URL of this link attachment. +pub struct PatchAttachmentRequestDataAttributesAttachment { #[serde(rename = "documentUrl")] - pub document_url: String, - /// The title of this link attachment. + pub document_url: Option, #[serde(rename = "title")] - pub title: String, + pub title: Option, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -24,19 +21,26 @@ pub struct IncidentAttachmentLinkAttributesAttachmentObject { pub(crate) _unparsed: bool, } -impl IncidentAttachmentLinkAttributesAttachmentObject { - pub fn new( - document_url: String, - title: String, - ) -> IncidentAttachmentLinkAttributesAttachmentObject { - IncidentAttachmentLinkAttributesAttachmentObject { - document_url, - title, +impl PatchAttachmentRequestDataAttributesAttachment { + pub fn new() -> PatchAttachmentRequestDataAttributesAttachment { + PatchAttachmentRequestDataAttributesAttachment { + document_url: None, + title: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + pub fn document_url(mut self, value: String) -> Self { + self.document_url = Some(value); + self + } + + pub fn title(mut self, value: String) -> Self { + self.title = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -46,14 +50,20 @@ impl IncidentAttachmentLinkAttributesAttachmentObject { } } -impl<'de> Deserialize<'de> for IncidentAttachmentLinkAttributesAttachmentObject { +impl Default for PatchAttachmentRequestDataAttributesAttachment { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchAttachmentRequestDataAttributesAttachment { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct IncidentAttachmentLinkAttributesAttachmentObjectVisitor; - impl<'a> Visitor<'a> for IncidentAttachmentLinkAttributesAttachmentObjectVisitor { - type Value = IncidentAttachmentLinkAttributesAttachmentObject; + struct PatchAttachmentRequestDataAttributesAttachmentVisitor; + impl<'a> Visitor<'a> for PatchAttachmentRequestDataAttributesAttachmentVisitor { + type Value = PatchAttachmentRequestDataAttributesAttachment; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -74,10 +84,16 @@ impl<'de> Deserialize<'de> for IncidentAttachmentLinkAttributesAttachmentObject while let Some((k, v)) = map.next_entry::()? { match k.as_str() { "documentUrl" => { + if v.is_null() { + continue; + } document_url = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } "title" => { + if v.is_null() { + continue; + } title = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } &_ => { @@ -87,11 +103,8 @@ impl<'de> Deserialize<'de> for IncidentAttachmentLinkAttributesAttachmentObject } } } - let document_url = - document_url.ok_or_else(|| M::Error::missing_field("document_url"))?; - let title = title.ok_or_else(|| M::Error::missing_field("title"))?; - let content = IncidentAttachmentLinkAttributesAttachmentObject { + let content = PatchAttachmentRequestDataAttributesAttachment { document_url, title, additional_properties, @@ -102,6 +115,6 @@ impl<'de> Deserialize<'de> for IncidentAttachmentLinkAttributesAttachmentObject } } - deserializer.deserialize_any(IncidentAttachmentLinkAttributesAttachmentObjectVisitor) + deserializer.deserialize_any(PatchAttachmentRequestDataAttributesAttachmentVisitor) } } diff --git a/src/datadogV2/model/model_user140420082644000.rs b/src/datadogV2/model/model_user140420082644000.rs new file mode 100644 index 000000000..1abaece04 --- /dev/null +++ b/src/datadogV2/model/model_user140420082644000.rs @@ -0,0 +1,132 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct User140420082644000 { + /// Attributes of user object returned by the API. + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(rename = "id")] + pub id: Option, + /// Users resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::UserType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl User140420082644000 { + pub fn new(type_: crate::datadogV2::model::UserType) -> User140420082644000 { + User140420082644000 { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes(mut self, value: crate::datadogV2::model::UserAttributes) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for User140420082644000 { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct User140420082644000Visitor; + impl<'a> Visitor<'a> for User140420082644000Visitor { + type Value = User140420082644000; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut id: Option = None; + let mut 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" => { + if v.is_null() { + continue; + } + 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::UserType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = User140420082644000 { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(User140420082644000Visitor) + } +} diff --git a/src/datadogV2/model/model_incident_attachment_related_object.rs b/src/datadogV2/model/model_user_type.rs similarity index 85% rename from src/datadogV2/model/model_incident_attachment_related_object.rs rename to src/datadogV2/model/model_user_type.rs index 48b14ba48..e0a85dbcf 100644 --- a/src/datadogV2/model/model_incident_attachment_related_object.rs +++ b/src/datadogV2/model/model_user_type.rs @@ -6,12 +6,12 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[non_exhaustive] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum IncidentAttachmentRelatedObject { +pub enum UserType { USERS, UnparsedObject(crate::datadog::UnparsedObject), } -impl ToString for IncidentAttachmentRelatedObject { +impl ToString for UserType { fn to_string(&self) -> String { match self { Self::USERS => String::from("users"), @@ -20,7 +20,7 @@ impl ToString for IncidentAttachmentRelatedObject { } } -impl Serialize for IncidentAttachmentRelatedObject { +impl Serialize for UserType { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -32,7 +32,7 @@ impl Serialize for IncidentAttachmentRelatedObject { } } -impl<'de> Deserialize<'de> for IncidentAttachmentRelatedObject { +impl<'de> Deserialize<'de> for UserType { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, diff --git a/tests/scenarios/cassettes/v2/incidents/Create-an-incident-attachment-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/incidents/Create-an-incident-attachment-returns-OK-response.frozen deleted file mode 100644 index a19a831fa..000000000 --- a/tests/scenarios/cassettes/v2/incidents/Create-an-incident-attachment-returns-OK-response.frozen +++ /dev/null @@ -1 +0,0 @@ -2024-11-04T19:02:17.223Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/incidents/Create-an-incident-attachment-returns-OK-response.json b/tests/scenarios/cassettes/v2/incidents/Create-an-incident-attachment-returns-OK-response.json deleted file mode 100644 index 060095390..000000000 --- a/tests/scenarios/cassettes/v2/incidents/Create-an-incident-attachment-returns-OK-response.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "http_interactions": [ - { - "request": { - "body": { - "string": "{\"data\":{\"attributes\":{\"customer_impacted\":false,\"title\":\"Test-Create_an_incident_attachment_returns_OK_response-1730746937\"},\"type\":\"incidents\"}}", - "encoding": null - }, - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ] - }, - "method": "post", - "uri": "https://api.datadoghq.com/api/v2/incidents" - }, - "response": { - "body": { - "string": "{\"data\":{\"type\":\"incidents\",\"id\":\"de4affc2-0412-5ed3-9d20-7f71b21ad305\",\"attributes\":{\"public_id\":250835,\"incident_type_uuid\":\"41d2e10b-4108-4736-92d7-791d00ea0702\",\"title\":\"Test-Create_an_incident_attachment_returns_OK_response-1730746937\",\"resolved\":null,\"customer_impact_scope\":null,\"customer_impact_start\":null,\"customer_impact_end\":null,\"customer_impacted\":false,\"notification_handles\":null,\"last_modified_by\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"uuid\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"name\":null,\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\"}}},\"last_modified_by_uuid\":null,\"created\":\"2024-11-04T19:02:17.394588+00:00\",\"modified\":\"2024-11-04T19:02:17.394588+00:00\",\"commander\":null,\"detected\":\"2024-11-04T19:02:17.385480+00:00\",\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"uuid\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"name\":null,\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\"}}},\"created_by_uuid\":null,\"creation_idempotency_key\":null,\"customer_impact_duration\":0,\"time_to_detect\":0,\"time_to_repair\":0,\"time_to_internal_response\":0,\"time_to_resolve\":0,\"archived\":null,\"fields\":{\"severity\":{\"type\":\"dropdown\",\"value\":\"UNKNOWN\"},\"state\":{\"type\":\"dropdown\",\"value\":\"active\"},\"detection_method\":{\"type\":\"dropdown\",\"value\":\"unknown\"},\"root_cause\":{\"type\":\"textbox\",\"value\":null},\"summary\":{\"type\":\"textbox\",\"value\":null},\"services\":{\"type\":\"autocomplete\",\"value\":null},\"teams\":{\"type\":\"autocomplete\",\"value\":null}},\"field_analytics\":null,\"severity\":\"UNKNOWN\",\"state\":\"active\",\"non_datadog_creator\":null,\"visibility\":\"organization\",\"case_id\":null},\"relationships\":{\"created_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}},\"last_modified_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}},\"commander_user\":{\"data\":null},\"user_defined_fields\":{\"data\":[{\"type\":\"user_defined_field\",\"id\":\"33457d2a-570c-5567-b4af-979a2a8f1164\"},{\"type\":\"user_defined_field\",\"id\":\"d003693c-bee9-5420-8d46-859269c20914\"},{\"type\":\"user_defined_field\",\"id\":\"1ddff6f6-cb1f-51a0-9d81-dc18ef52cc9d\"},{\"type\":\"user_defined_field\",\"id\":\"6bc9d32b-c2cd-591e-9b7a-74c886a5ddcf\"},{\"type\":\"user_defined_field\",\"id\":\"95c53547-2ba3-5d8a-9c3b-cf245bc0c629\"},{\"type\":\"user_defined_field\",\"id\":\"39044b03-cee4-555f-b1e0-3eb3aa759a86\"},{\"type\":\"user_defined_field\",\"id\":\"3cbe9e60-d794-532c-acc0-73641f782813\"}]},\"integrations\":{\"data\":[]},\"attachments\":{\"data\":[]},\"responders\":{\"data\":[]},\"impacts\":{\"data\":[]}}}}\n", - "encoding": null - }, - "headers": { - "Content-Type": [ - "application/json" - ] - }, - "status": { - "code": 201, - "message": "Created" - } - }, - "recorded_at": "Mon, 04 Nov 2024 19:02:17 GMT" - }, - { - "request": { - "body": { - "string": "{\"data\":[{\"attributes\":{\"attachment\":{\"documentUrl\":\"https://www.example.com/doc\",\"title\":\"Test-Create_an_incident_attachment_returns_OK_response-1730746937\"},\"attachment_type\":\"link\"},\"type\":\"incident_attachments\"}]}", - "encoding": null - }, - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ] - }, - "method": "patch", - "uri": "https://api.datadoghq.com/api/v2/incidents/de4affc2-0412-5ed3-9d20-7f71b21ad305/attachments" - }, - "response": { - "body": { - "string": "{\"data\":[{\"type\":\"incident_attachments\",\"id\":\"233c12d5-547a-5638-97e6-6c9d1c456cb7\",\"attributes\":{\"modified\":\"2024-11-04T19:02:17.844501+00:00\",\"attachment_type\":\"link\",\"attachment\":{\"title\":\"Test-Create_an_incident_attachment_returns_OK_response-1730746937\",\"documentUrl\":\"https://www.example.com/doc\"}},\"relationships\":{\"last_modified_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}}}}]}\n", - "encoding": null - }, - "headers": { - "Content-Type": [ - "application/json" - ] - }, - "status": { - "code": 200, - "message": "OK" - } - }, - "recorded_at": "Mon, 04 Nov 2024 19:02:17 GMT" - }, - { - "request": { - "body": "", - "headers": { - "Accept": [ - "*/*" - ] - }, - "method": "delete", - "uri": "https://api.datadoghq.com/api/v2/incidents/de4affc2-0412-5ed3-9d20-7f71b21ad305" - }, - "response": { - "body": { - "string": "", - "encoding": null - }, - "headers": { - "Content-Type": [ - "text/html; charset=utf-8" - ] - }, - "status": { - "code": 204, - "message": "No Content" - } - }, - "recorded_at": "Mon, 04 Nov 2024 19:02:17 GMT" - } - ], - "recorded_with": "VCR 6.0.0" -} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/incidents/Get-incident-attachments-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/incidents/Get-incident-attachments-returns-OK-response.frozen deleted file mode 100644 index 65913c025..000000000 --- a/tests/scenarios/cassettes/v2/incidents/Get-incident-attachments-returns-OK-response.frozen +++ /dev/null @@ -1 +0,0 @@ -2024-11-04T19:02:25.584Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/incidents/Get-incident-attachments-returns-OK-response.json b/tests/scenarios/cassettes/v2/incidents/Get-incident-attachments-returns-OK-response.json deleted file mode 100644 index 18df98530..000000000 --- a/tests/scenarios/cassettes/v2/incidents/Get-incident-attachments-returns-OK-response.json +++ /dev/null @@ -1,129 +0,0 @@ -{ - "http_interactions": [ - { - "request": { - "body": { - "string": "{\"data\":{\"attributes\":{\"customer_impacted\":false,\"title\":\"Test-Get_incident_attachments_returns_OK_response-1730746945\"},\"type\":\"incidents\"}}", - "encoding": null - }, - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ] - }, - "method": "post", - "uri": "https://api.datadoghq.com/api/v2/incidents" - }, - "response": { - "body": { - "string": "{\"data\":{\"type\":\"incidents\",\"id\":\"1512832c-c4e5-569d-a970-d4797f22745a\",\"attributes\":{\"public_id\":250842,\"incident_type_uuid\":\"41d2e10b-4108-4736-92d7-791d00ea0702\",\"title\":\"Test-Get_incident_attachments_returns_OK_response-1730746945\",\"resolved\":null,\"customer_impact_scope\":null,\"customer_impact_start\":null,\"customer_impact_end\":null,\"customer_impacted\":false,\"notification_handles\":null,\"last_modified_by\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"uuid\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"name\":null,\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\"}}},\"last_modified_by_uuid\":null,\"created\":\"2024-11-04T19:02:25.768523+00:00\",\"modified\":\"2024-11-04T19:02:25.768523+00:00\",\"commander\":null,\"detected\":\"2024-11-04T19:02:25.756116+00:00\",\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"uuid\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"name\":null,\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\"}}},\"created_by_uuid\":null,\"creation_idempotency_key\":null,\"customer_impact_duration\":0,\"time_to_detect\":0,\"time_to_repair\":0,\"time_to_internal_response\":0,\"time_to_resolve\":0,\"archived\":null,\"fields\":{\"severity\":{\"type\":\"dropdown\",\"value\":\"UNKNOWN\"},\"state\":{\"type\":\"dropdown\",\"value\":\"active\"},\"detection_method\":{\"type\":\"dropdown\",\"value\":\"unknown\"},\"root_cause\":{\"type\":\"textbox\",\"value\":null},\"summary\":{\"type\":\"textbox\",\"value\":null},\"services\":{\"type\":\"autocomplete\",\"value\":null},\"teams\":{\"type\":\"autocomplete\",\"value\":null}},\"field_analytics\":null,\"severity\":\"UNKNOWN\",\"state\":\"active\",\"non_datadog_creator\":null,\"visibility\":\"organization\",\"case_id\":null},\"relationships\":{\"created_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}},\"last_modified_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}},\"commander_user\":{\"data\":null},\"user_defined_fields\":{\"data\":[{\"type\":\"user_defined_field\",\"id\":\"33457d2a-570c-5567-b4af-979a2a8f1164\"},{\"type\":\"user_defined_field\",\"id\":\"d003693c-bee9-5420-8d46-859269c20914\"},{\"type\":\"user_defined_field\",\"id\":\"1ddff6f6-cb1f-51a0-9d81-dc18ef52cc9d\"},{\"type\":\"user_defined_field\",\"id\":\"6bc9d32b-c2cd-591e-9b7a-74c886a5ddcf\"},{\"type\":\"user_defined_field\",\"id\":\"95c53547-2ba3-5d8a-9c3b-cf245bc0c629\"},{\"type\":\"user_defined_field\",\"id\":\"39044b03-cee4-555f-b1e0-3eb3aa759a86\"},{\"type\":\"user_defined_field\",\"id\":\"3cbe9e60-d794-532c-acc0-73641f782813\"}]},\"integrations\":{\"data\":[]},\"attachments\":{\"data\":[]},\"responders\":{\"data\":[]},\"impacts\":{\"data\":[]}}}}\n", - "encoding": null - }, - "headers": { - "Content-Type": [ - "application/json" - ] - }, - "status": { - "code": 201, - "message": "Created" - } - }, - "recorded_at": "Mon, 04 Nov 2024 19:02:25 GMT" - }, - { - "request": { - "body": { - "string": "{\"data\":[{\"attributes\":{\"attachment\":{\"documentUrl\":\"https://www.example.com/doc\",\"title\":\"Important Doc\"},\"attachment_type\":\"link\"},\"type\":\"incident_attachments\"}]}", - "encoding": null - }, - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ] - }, - "method": "patch", - "uri": "https://api.datadoghq.com/api/v2/incidents/1512832c-c4e5-569d-a970-d4797f22745a/attachments" - }, - "response": { - "body": { - "string": "{\"data\":[{\"type\":\"incident_attachments\",\"id\":\"ad6ccc2d-9653-5824-be41-729d3f49a153\",\"attributes\":{\"modified\":\"2024-11-04T19:02:26.146487+00:00\",\"attachment_type\":\"link\",\"attachment\":{\"title\":\"Important Doc\",\"documentUrl\":\"https://www.example.com/doc\"}},\"relationships\":{\"last_modified_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}}}}]}\n", - "encoding": null - }, - "headers": { - "Content-Type": [ - "application/json" - ] - }, - "status": { - "code": 200, - "message": "OK" - } - }, - "recorded_at": "Mon, 04 Nov 2024 19:02:25 GMT" - }, - { - "request": { - "body": "", - "headers": { - "Accept": [ - "application/json" - ] - }, - "method": "get", - "uri": "https://api.datadoghq.com/api/v2/incidents/1512832c-c4e5-569d-a970-d4797f22745a/attachments" - }, - "response": { - "body": { - "string": "{\"data\":[{\"type\":\"incident_attachments\",\"id\":\"ad6ccc2d-9653-5824-be41-729d3f49a153\",\"attributes\":{\"modified\":\"2024-11-04T19:02:26.146487+00:00\",\"attachment_type\":\"link\",\"attachment\":{\"title\":\"Important Doc\",\"documentUrl\":\"https://www.example.com/doc\"}},\"relationships\":{\"last_modified_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}}}}]}\n", - "encoding": null - }, - "headers": { - "Content-Type": [ - "application/json" - ] - }, - "status": { - "code": 200, - "message": "OK" - } - }, - "recorded_at": "Mon, 04 Nov 2024 19:02:25 GMT" - }, - { - "request": { - "body": "", - "headers": { - "Accept": [ - "*/*" - ] - }, - "method": "delete", - "uri": "https://api.datadoghq.com/api/v2/incidents/1512832c-c4e5-569d-a970-d4797f22745a" - }, - "response": { - "body": { - "string": "", - "encoding": null - }, - "headers": { - "Content-Type": [ - "text/html; charset=utf-8" - ] - }, - "status": { - "code": 204, - "message": "No Content" - } - }, - "recorded_at": "Mon, 04 Nov 2024 19:02:25 GMT" - } - ], - "recorded_with": "VCR 6.0.0" -} \ No newline at end of file diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 5e9aa4d3b..1d3d16d80 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -447,22 +447,6 @@ "tag": "Incidents", "operationId": "CreateIncidentType" }, - { - "parameters": [ - { - "name": "incident_id", - "source": "incident.data.id" - }, - { - "name": "body", - "value": "{\n \"data\": [\n {\n \"attributes\": {\n \"attachment_type\": \"link\",\n \"attachment\": {\n \"documentUrl\": \"https://www.example.com/doc\",\n \"title\": \"Important Doc\"\n }\n },\n \"type\": \"incident_attachments\"\n }\n ]\n}" - } - ], - "step": "the \"incident\" has an \"incident_attachment\"", - "key": "incident_attachment", - "tag": "Incidents", - "operationId": "UpdateIncidentAttachments" - }, { "operationId": "CreateIncidentImpact", "parameters": [ diff --git a/tests/scenarios/features/v2/incidents.feature b/tests/scenarios/features/v2/incidents.feature index 12ab3e2f5..a101f5f4a 100644 --- a/tests/scenarios/features/v2/incidents.feature +++ b/tests/scenarios/features/v2/incidents.feature @@ -21,20 +21,6 @@ Feature: Incidents When the request is sent Then the response status is 200 OK - @team:DataDog/incident-app - Scenario: Create an incident attachment returns "OK" response - Given operation "UpdateIncidentAttachments" enabled - And there is a valid "incident" in the system - And new "UpdateIncidentAttachments" request - And request contains "incident_id" parameter from "incident.data.id" - And body with value {"data": [{"type": "incident_attachments", "attributes": {"attachment_type": "link", "attachment": {"documentUrl": "https://www.example.com/doc", "title": "{{unique}}"}}}]} - When the request is sent - Then the response status is 200 OK - And the response "data" has length 1 - And the response "data[0].type" is equal to "incident_attachments" - And the response "data[0].attributes.attachment_type" is equal to "link" - And the response "data[0].attributes.attachment.documentUrl" is equal to "https://www.example.com/doc" - @skip @team:DataDog/incident-app Scenario: Create an incident impact returns "Bad Request" response Given operation "CreateIncidentImpact" enabled @@ -200,6 +186,24 @@ Feature: Incidents When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app + Scenario: Create incident attachment returns "Bad Request" response + Given operation "CreateIncidentAttachment" enabled + And new "CreateIncidentAttachment" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"attachment": {"documentUrl": "https://app.datadoghq.com/notebook/123/Postmortem-IR-123", "title": "Postmortem-IR-123"}, "attachment_type": "postmortem"}, "id": "00000000-0000-0000-0000-000000000000", "type": "incident_attachments"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Create incident attachment returns "Created" response + Given operation "CreateIncidentAttachment" enabled + And new "CreateIncidentAttachment" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"attachment": {"documentUrl": "https://app.datadoghq.com/notebook/123/Postmortem-IR-123", "title": "Postmortem-IR-123"}, "attachment_type": "postmortem"}, "id": "00000000-0000-0000-0000-000000000000", "type": "incident_attachments"}} + When the request is sent + Then the response status is 201 Created + @team:Datadog/incident-app Scenario: Create incident notification rule returns "Bad Request" response Given operation "CreateIncidentNotificationRule" enabled @@ -249,33 +253,6 @@ Feature: Incidents When the request is sent Then the response status is 404 Not Found - @generated @skip @team:DataDog/incident-app - Scenario: Create, update, and delete incident attachments returns "Bad Request" response - Given operation "UpdateIncidentAttachments" enabled - And new "UpdateIncidentAttachments" request - And request contains "incident_id" parameter from "REPLACE.ME" - And body with value {"data": [{"attributes": {"attachment": {"documentUrl": "https://app.datadoghq.com/notebook/123", "title": "Postmortem IR-123"}, "attachment_type": "postmortem"}, "id": "00000000-abcd-0002-0000-000000000000", "type": "incident_attachments"}, {"attributes": {"attachment": {"documentUrl": "https://www.example.com/webstore-failure-runbook", "title": "Runbook for webstore service failures"}, "attachment_type": "link"}, "type": "incident_attachments"}, {"id": "00000000-abcd-0003-0000-000000000000", "type": "incident_attachments"}]} - When the request is sent - Then the response status is 400 Bad Request - - @generated @skip @team:DataDog/incident-app - Scenario: Create, update, and delete incident attachments returns "Not Found" response - Given operation "UpdateIncidentAttachments" enabled - And new "UpdateIncidentAttachments" request - And request contains "incident_id" parameter from "REPLACE.ME" - And body with value {"data": [{"attributes": {"attachment": {"documentUrl": "https://app.datadoghq.com/notebook/123", "title": "Postmortem IR-123"}, "attachment_type": "postmortem"}, "id": "00000000-abcd-0002-0000-000000000000", "type": "incident_attachments"}, {"attributes": {"attachment": {"documentUrl": "https://www.example.com/webstore-failure-runbook", "title": "Runbook for webstore service failures"}, "attachment_type": "link"}, "type": "incident_attachments"}, {"id": "00000000-abcd-0003-0000-000000000000", "type": "incident_attachments"}]} - When the request is sent - Then the response status is 404 Not Found - - @generated @skip @team:DataDog/incident-app - Scenario: Create, update, and delete incident attachments returns "OK" response - Given operation "UpdateIncidentAttachments" enabled - And new "UpdateIncidentAttachments" request - And request contains "incident_id" parameter from "REPLACE.ME" - And body with value {"data": [{"attributes": {"attachment": {"documentUrl": "https://app.datadoghq.com/notebook/123", "title": "Postmortem IR-123"}, "attachment_type": "postmortem"}, "id": "00000000-abcd-0002-0000-000000000000", "type": "incident_attachments"}, {"attributes": {"attachment": {"documentUrl": "https://www.example.com/webstore-failure-runbook", "title": "Runbook for webstore service failures"}, "attachment_type": "link"}, "type": "incident_attachments"}, {"id": "00000000-abcd-0003-0000-000000000000", "type": "incident_attachments"}]} - When the request is sent - Then the response status is 200 OK - @generated @skip @team:Datadog/incident-app Scenario: Delete a notification template returns "Bad Request" response Given operation "DeleteIncidentNotificationTemplate" enabled @@ -452,6 +429,33 @@ Feature: Incidents When the request is sent Then the response status is 204 OK + @generated @skip @team:DataDog/incident-app + Scenario: Delete incident attachment returns "Bad Request" response + Given operation "DeleteIncidentAttachment" enabled + And new "DeleteIncidentAttachment" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "attachment_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 incident attachment returns "No Content" response + Given operation "DeleteIncidentAttachment" enabled + And new "DeleteIncidentAttachment" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "attachment_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 incident attachment returns "Not Found" response + Given operation "DeleteIncidentAttachment" enabled + And new "DeleteIncidentAttachment" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "attachment_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @team:Datadog/incident-app Scenario: Delete incident notification rule returns "No Content" response Given there is a valid "incident_type" in the system @@ -536,30 +540,6 @@ Feature: Incidents And the response "data[0].attributes.assignees" has length 2 And the response "data[0].attributes.content" is equal to "Follow up with customer about the impact they saw." - @generated @skip @team:DataDog/incident-app - Scenario: Get a list of attachments returns "Bad Request" response - Given operation "ListIncidentAttachments" enabled - And new "ListIncidentAttachments" request - And request contains "incident_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 a list of attachments returns "Not Found" response - Given operation "ListIncidentAttachments" enabled - And new "ListIncidentAttachments" request - And request contains "incident_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 a list of attachments returns "OK" response - Given operation "ListIncidentAttachments" enabled - And new "ListIncidentAttachments" request - And request contains "incident_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 a list of incident types returns "Bad Request" response Given operation "ListIncidentTypes" enabled @@ -630,20 +610,6 @@ Feature: Incidents When the request is sent Then the response status is 200 OK - @team:DataDog/incident-app - Scenario: Get incident attachments returns "OK" response - Given operation "ListIncidentAttachments" enabled - And there is a valid "incident" in the system - And the "incident" has an "incident_attachment" - And new "ListIncidentAttachments" request - And request contains "incident_id" parameter from "incident.data.id" - When the request is sent - Then the response status is 200 OK - And the response "data" has length 1 - And the response "data[0].type" is equal to "incident_attachments" - And the response "data[0].attributes.attachment_type" is equal to "link" - And the response "data[0].attributes.attachment.documentUrl" is equal to "https://www.example.com/doc" - @generated @skip @team:DataDog/incident-app Scenario: Get incident integration metadata details returns "Bad Request" response Given operation "GetIncidentIntegration" enabled @@ -827,6 +793,22 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: List incident attachments returns "Bad Request" response + Given operation "ListIncidentAttachments" enabled + And new "ListIncidentAttachments" request + And request contains "incident_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: List incident attachments returns "OK" response + Given operation "ListIncidentAttachments" enabled + And new "ListIncidentAttachments" request + And request contains "incident_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:Datadog/incident-app Scenario: List incident notification rules returns "Bad Request" response Given operation "ListIncidentNotificationRules" enabled @@ -1073,6 +1055,36 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: Update incident attachment returns "Bad Request" response + Given operation "UpdateIncidentAttachment" enabled + And new "UpdateIncidentAttachment" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "attachment_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"attachment": {"documentUrl": "https://app.datadoghq.com/notebook/124/Postmortem-IR-124", "title": "Postmortem-IR-124"}}, "type": "incident_attachments"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Update incident attachment returns "Not Found" response + Given operation "UpdateIncidentAttachment" enabled + And new "UpdateIncidentAttachment" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "attachment_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"attachment": {"documentUrl": "https://app.datadoghq.com/notebook/124/Postmortem-IR-124", "title": "Postmortem-IR-124"}}, "type": "incident_attachments"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/incident-app + Scenario: Update incident attachment returns "OK" response + Given operation "UpdateIncidentAttachment" enabled + And new "UpdateIncidentAttachment" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "attachment_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"attachment": {"documentUrl": "https://app.datadoghq.com/notebook/124/Postmortem-IR-124", "title": "Postmortem-IR-124"}}, "type": "incident_attachments"}} + When the request is sent + Then the response status is 200 OK + @team:Datadog/incident-app Scenario: Update incident notification rule returns "Bad Request" response Given operation "UpdateIncidentNotificationRule" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index e0f0b98d0..f59f66d6e 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1717,7 +1717,30 @@ "type": "safe" } }, - "UpdateIncidentAttachments": { + "CreateIncidentAttachment": { + "tag": "Incidents", + "undo": { + "operationId": "DeleteIncidentAttachment", + "parameters": [ + { + "name": "incident_id", + "source": "" + }, + { + "name": "attachment_id", + "source": "" + } + ], + "type": "unsafe" + } + }, + "DeleteIncidentAttachment": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "UpdateIncidentAttachment": { "tag": "Incidents", "undo": { "type": "idempotent" diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 0c30294c8..e1c8de486 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -3127,8 +3127,16 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { test_v2_list_incident_attachments, ); world.function_mappings.insert( - "v2.UpdateIncidentAttachments".into(), - test_v2_update_incident_attachments, + "v2.CreateIncidentAttachment".into(), + test_v2_create_incident_attachment, + ); + world.function_mappings.insert( + "v2.DeleteIncidentAttachment".into(), + test_v2_delete_incident_attachment, + ); + world.function_mappings.insert( + "v2.UpdateIncidentAttachment".into(), + test_v2_update_incident_attachment, ); world.function_mappings.insert( "v2.ListIncidentImpacts".into(), @@ -23359,15 +23367,15 @@ fn test_v2_list_incident_attachments( .expect("api instance not found"); let incident_id = serde_json::from_value(_parameters.get("incident_id").unwrap().clone()).unwrap(); - let include = _parameters - .get("include") - .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); let filter_attachment_type = _parameters .get("filter[attachment_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::ListIncidentAttachmentsOptionalParams::default(); - params.include = include; params.filter_attachment_type = filter_attachment_type; + params.include = include; let response = match block_on(api.list_incident_attachments_with_http_info(incident_id, params)) { Ok(response) => response, @@ -23387,7 +23395,7 @@ fn test_v2_list_incident_attachments( world.response.code = response.status.as_u16(); } -fn test_v2_update_incident_attachments( +fn test_v2_create_incident_attachment( world: &mut DatadogWorld, _parameters: &HashMap, ) { @@ -23402,10 +23410,42 @@ fn test_v2_update_incident_attachments( let include = _parameters .get("include") .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); - let mut params = datadogV2::api_incidents::UpdateIncidentAttachmentsOptionalParams::default(); + let mut params = datadogV2::api_incidents::CreateIncidentAttachmentOptionalParams::default(); params.include = include; let response = - match block_on(api.update_incident_attachments_with_http_info(incident_id, body, params)) { + match block_on(api.create_incident_attachment_with_http_info(incident_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_delete_incident_attachment( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let incident_id = + serde_json::from_value(_parameters.get("incident_id").unwrap().clone()).unwrap(); + let attachment_id = + serde_json::from_value(_parameters.get("attachment_id").unwrap().clone()).unwrap(); + let response = + match block_on(api.delete_incident_attachment_with_http_info(incident_id, attachment_id)) { Ok(response) => response, Err(error) => { return match error { @@ -23423,6 +23463,48 @@ fn test_v2_update_incident_attachments( world.response.code = response.status.as_u16(); } +fn test_v2_update_incident_attachment( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let incident_id = + serde_json::from_value(_parameters.get("incident_id").unwrap().clone()).unwrap(); + let attachment_id = + serde_json::from_value(_parameters.get("attachment_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::UpdateIncidentAttachmentOptionalParams::default(); + params.include = include; + let response = match block_on(api.update_incident_attachment_with_http_info( + incident_id, + attachment_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_list_incident_impacts(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances