diff --git a/.apigentools-info b/.apigentools-info index 0df7ff2236eb..951df7abc9d9 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2022-09-29 08:29:20.464180", - "spec_repo_commit": "26eb8e8a" + "regenerated": "2022-09-29 15:48:28.744007", + "spec_repo_commit": "e57e3c55" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2022-09-29 08:29:20.475854", - "spec_repo_commit": "26eb8e8a" + "regenerated": "2022-09-29 15:48:28.756807", + "spec_repo_commit": "e57e3c55" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index a0ac7e9a3d2c..7633bb9d6101 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -145,6 +145,26 @@ components: required: true schema: type: string + 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 @@ -2114,6 +2134,243 @@ 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' + type: object + 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' + 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. + enum: + - incident_attachments + example: incident_attachments + type: string + x-enum-varnames: + - INCIDENT_ATTACHMENTS + IncidentAttachmentUpdateAttributes: + description: Incident attachment attributes. + oneOf: + - $ref: '#/components/schemas/IncidentAttachmentPostmortemAttributes' + - $ref: '#/components/schemas/IncidentAttachmentLinkAttributes' + type: object + 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.' + 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. + 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' + type: object IncidentCreateAttributes: description: The incident's attributes for a create request. properties: @@ -2278,9 +2535,11 @@ components: description: Object related to an incident. enum: - users + - attachments type: string x-enum-varnames: - USERS + - ATTACHMENTS IncidentResponse: description: Response with an incident. properties: @@ -2355,10 +2614,6 @@ components: $ref: '#/components/schemas/IncidentNotificationHandle' nullable: true type: array - postmortem_id: - description: The UUID of the postmortem object attached to the incident. - example: 00000000-0000-0000-7890-000000000000 - type: string public_id: description: The monotonically increasing integer ID for the incident. example: 1 @@ -2423,6 +2678,7 @@ components: description: An object related to an incident that is included in the response. oneOf: - $ref: '#/components/schemas/User' + - $ref: '#/components/schemas/IncidentAttachmentData' type: object IncidentResponseMeta: description: The metadata object containing pagination metadata. @@ -2454,6 +2710,8 @@ components: IncidentResponseRelationships: description: The incident's relationships from a response. properties: + attachments: + $ref: '#/components/schemas/RelationshipToIncidentAttachment' commander_user: $ref: '#/components/schemas/NullableRelationshipToUser' created_by_user: @@ -2462,8 +2720,6 @@ components: $ref: '#/components/schemas/RelationshipToIncidentIntegrationMetadatas' last_modified_by_user: $ref: '#/components/schemas/RelationshipToUser' - postmortem: - $ref: '#/components/schemas/RelationshipToIncidentPostmortem' type: object IncidentServiceCreateAttributes: description: The incident service's attributes for a create request. @@ -2934,7 +3190,6 @@ components: customer_impacted: false detected: '2020-04-14T00:00:00+00:00' modified: '2020-09-17T14:16:58.696424+00:00' - postmortem_id: 00000000-0000-bbbb-0000-000000000000 public_id: 1 resolved: null severity: SEV-1 @@ -2945,6 +3200,12 @@ components: title: Example Incident id: 00000000-aaaa-0000-0000-000000000000 relationships: + attachments: + data: + - id: 00000000-9999-0000-0000-000000000000 + type: incident_attachments + - id: 00000000-1234-0000-0000-000000000000 + type: incident_attachments commander_user: data: id: 00000000-0000-0000-cccc-000000000000 @@ -2963,10 +3224,6 @@ components: data: id: 00000000-0000-0000-cccc-000000000000 type: users - postmortem: - data: - id: 00000000-9999-0000-0000-000000000000 - type: incident_postmortems type: incidents - attributes: created: '2020-04-21T15:34:08.627205+00:00' @@ -2978,7 +3235,6 @@ components: customer_impacted: false detected: '2020-04-14T00:00:00+00:00' modified: '2020-09-17T14:16:58.696424+00:00' - postmortem_id: 00000000-6006-0000-0000-000000000000 public_id: 2 resolved: null severity: SEV-5 @@ -2989,6 +3245,10 @@ components: title: Example Incident 2 id: 00000000-1111-0000-0000-000000000000 relationships: + attachments: + data: + - id: 00000000-9999-0000-0000-000000000000 + type: incident_attachments commander_user: data: id: 00000000-aaaa-0000-0000-000000000000 @@ -3007,10 +3267,6 @@ components: data: id: 00000000-aaaa-0000-0000-000000000000 type: users - postmortem: - data: - id: 00000000-6006-0000-0000-000000000000 - type: incident_postmortems type: incidents items: $ref: '#/components/schemas/IncidentResponseData' @@ -6197,6 +6453,30 @@ components: from the other indexes type: string type: object + RelationshipToIncidentAttachment: + description: A relationship reference for attachments. + properties: + data: + description: An array of incident attachments. + items: + $ref: '#/components/schemas/RelationshipToIncidentAttachmentData' + type: array + required: + - data + type: object + RelationshipToIncidentAttachmentData: + description: The attachment relationship data. + properties: + id: + description: A unique identifier that represents the attachment. + example: 00000000-0000-abcd-1000-000000000000 + type: string + type: + $ref: '#/components/schemas/IncidentAttachmentType' + required: + - id + - type + type: object RelationshipToIncidentIntegrationMetadataData: description: A relationship reference for an integration metadata object. example: @@ -9786,6 +10066,80 @@ paths: x-unstable: '**Note**: This endpoint is in public beta. 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. + operationId: ListIncidentAttachments + parameters: + - $ref: '#/components/parameters/IncidentIDPathParameter' + - $ref: '#/components/parameters/IncidentAttachmentIncludeQueryParameter' + - $ref: '#/components/parameters/IncidentAttachmentFilterQueryParameter' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentAttachmentsResponse' + 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' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_read + summary: Get a list of attachments + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: The bulk update endpoint for creating, updating, and deleting attachments + for a given incident. + operationId: UpdateIncidentAttachments + parameters: + - $ref: '#/components/parameters/IncidentIDPathParameter' + - $ref: '#/components/parameters/IncidentAttachmentIncludeQueryParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentAttachmentUpdateRequest' + description: Incident Attachment Payload. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentAttachmentUpdateResponse' + 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 + tags: + - Incidents + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/integration/opsgenie/services: get: description: Get a list of all services from the Datadog Opsgenie integration. diff --git a/cassettes/features/v2/incidents/Create-an-incident-attachment-returns-OK-response.frozen b/cassettes/features/v2/incidents/Create-an-incident-attachment-returns-OK-response.frozen new file mode 100644 index 000000000000..669d401faa81 --- /dev/null +++ b/cassettes/features/v2/incidents/Create-an-incident-attachment-returns-OK-response.frozen @@ -0,0 +1 @@ +2022-09-26T21:17:23.851Z \ No newline at end of file diff --git a/cassettes/features/v2/incidents/Create-an-incident-attachment-returns-OK-response.yml b/cassettes/features/v2/incidents/Create-an-incident-attachment-returns-OK-response.yml new file mode 100644 index 000000000000..965c8899532d --- /dev/null +++ b/cassettes/features/v2/incidents/Create-an-incident-attachment-returns-OK-response.yml @@ -0,0 +1,68 @@ +http_interactions: +- recorded_at: Mon, 26 Sep 2022 21:17:23 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"customer_impacted":false,"title":"Test-Create_an_incident_attachment_returns_OK_response-1664227043"},"type":"incidents"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/incidents + response: + body: + encoding: UTF-8 + string: '{"data":{"type":"incidents","id":"96fe3f0e-ee19-5e91-8eb8-324c9b4af1cf","attributes":{"public_id":106581,"title":"Test-Create_an_incident_attachment_returns_OK_response-1664227043","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":"2022-09-26T21:17:24.154561+00:00","modified":"2022-09-26T21:17:24.154561+00:00","commander":null,"detected":"2022-09-26T21:17:24.145418+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,"fields":{"severity":{"type":"dropdown","value":"UNKNOWN"},"detection_method":{"type":"dropdown","value":"unknown"},"root_cause":{"type":"textbox","value":null},"teams":{"type":"autocomplete","value":null},"state":{"type":"dropdown","value":"active"},"services":{"type":"autocomplete","value":null},"summary":{"type":"textbox","value":null}},"field_analytics":null,"severity":"UNKNOWN","state":"active","non_datadog_creator":null,"visibility":"organization"},"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":"4148ead2-da45-548e-b6be-8e319bafc425"},{"type":"user_defined_field","id":"66b62f59-48f6-5fee-969a-0886b1db6dcd"},{"type":"user_defined_field","id":"299616f7-8acd-5403-886b-991656d6b982"},{"type":"user_defined_field","id":"ad2b9456-eaec-5bbd-9bae-e502d74e23f8"},{"type":"user_defined_field","id":"d8a54f16-8b2a-5ab4-87b8-5f0fa575c83e"},{"type":"user_defined_field","id":"623af0a5-f30c-577e-8146-09b8324bdb2d"},{"type":"user_defined_field","id":"ccfc9e6c-f586-58e5-b502-03c466c72e6f"}]},"integrations":{"data":[]},"attachments":{"data":[]},"responders":{"data":[]},"impacts":{"data":[]}}}} + + ' + headers: + Content-Type: + - application/json + status: + code: 201 + message: Created +- recorded_at: Mon, 26 Sep 2022 21:17:23 GMT + request: + body: + encoding: UTF-8 + string: '{"data":[{"attributes":{"attachment":{"documentUrl":"https://www.example.com/doc","title":"Test-Create_an_incident_attachment_returns_OK_response-1664227043"},"attachment_type":"link"},"type":"incident_attachments"}]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: PATCH + uri: https://api.datadoghq.com/api/v2/incidents/96fe3f0e-ee19-5e91-8eb8-324c9b4af1cf/attachments + response: + body: + encoding: UTF-8 + string: '{"data":[{"type":"incident_attachments","id":"fead2659-92bf-543d-beca-0b90fb42c5df","attributes":{"modified":"2022-09-26T21:17:24.650927+00:00","attachment_type":"link","attachment":{"documentUrl":"https://www.example.com/doc","title":"Test-Create_an_incident_attachment_returns_OK_response-1664227043"}},"relationships":{"last_modified_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}}}]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Mon, 26 Sep 2022 21:17:23 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/incidents/96fe3f0e-ee19-5e91-8eb8-324c9b4af1cf + response: + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/incidents/Get-incident-attachments-returns-OK-response.frozen b/cassettes/features/v2/incidents/Get-incident-attachments-returns-OK-response.frozen new file mode 100644 index 000000000000..76ad9d14349f --- /dev/null +++ b/cassettes/features/v2/incidents/Get-incident-attachments-returns-OK-response.frozen @@ -0,0 +1 @@ +2022-09-26T21:17:25.250Z \ No newline at end of file diff --git a/cassettes/features/v2/incidents/Get-incident-attachments-returns-OK-response.yml b/cassettes/features/v2/incidents/Get-incident-attachments-returns-OK-response.yml new file mode 100644 index 000000000000..99680c57e623 --- /dev/null +++ b/cassettes/features/v2/incidents/Get-incident-attachments-returns-OK-response.yml @@ -0,0 +1,91 @@ +http_interactions: +- recorded_at: Mon, 26 Sep 2022 21:17:25 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"customer_impacted":false,"title":"Test-Get_incident_attachments_returns_OK_response-1664227045"},"type":"incidents"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/incidents + response: + body: + encoding: UTF-8 + string: '{"data":{"type":"incidents","id":"762590df-8e28-5b77-8282-a51ec6aff95f","attributes":{"public_id":106582,"title":"Test-Get_incident_attachments_returns_OK_response-1664227045","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":"2022-09-26T21:17:25.438704+00:00","modified":"2022-09-26T21:17:25.438704+00:00","commander":null,"detected":"2022-09-26T21:17:25.429904+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,"fields":{"severity":{"type":"dropdown","value":"UNKNOWN"},"detection_method":{"type":"dropdown","value":"unknown"},"root_cause":{"type":"textbox","value":null},"teams":{"type":"autocomplete","value":null},"state":{"type":"dropdown","value":"active"},"services":{"type":"autocomplete","value":null},"summary":{"type":"textbox","value":null}},"field_analytics":null,"severity":"UNKNOWN","state":"active","non_datadog_creator":null,"visibility":"organization"},"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":"4148ead2-da45-548e-b6be-8e319bafc425"},{"type":"user_defined_field","id":"66b62f59-48f6-5fee-969a-0886b1db6dcd"},{"type":"user_defined_field","id":"299616f7-8acd-5403-886b-991656d6b982"},{"type":"user_defined_field","id":"ad2b9456-eaec-5bbd-9bae-e502d74e23f8"},{"type":"user_defined_field","id":"d8a54f16-8b2a-5ab4-87b8-5f0fa575c83e"},{"type":"user_defined_field","id":"623af0a5-f30c-577e-8146-09b8324bdb2d"},{"type":"user_defined_field","id":"ccfc9e6c-f586-58e5-b502-03c466c72e6f"}]},"integrations":{"data":[]},"attachments":{"data":[]},"responders":{"data":[]},"impacts":{"data":[]}}}} + + ' + headers: + Content-Type: + - application/json + status: + code: 201 + message: Created +- recorded_at: Mon, 26 Sep 2022 21:17:25 GMT + request: + body: + encoding: UTF-8 + string: '{"data":[{"attributes":{"attachment":{"documentUrl":"https://www.example.com/doc","title":"Important + Doc"},"attachment_type":"link"},"type":"incident_attachments"}]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: PATCH + uri: https://api.datadoghq.com/api/v2/incidents/762590df-8e28-5b77-8282-a51ec6aff95f/attachments + response: + body: + encoding: UTF-8 + string: '{"data":[{"type":"incident_attachments","id":"c383d7df-3f44-571c-922a-4668ce53a8ad","attributes":{"modified":"2022-09-26T21:17:25.906466+00:00","attachment_type":"link","attachment":{"documentUrl":"https://www.example.com/doc","title":"Important + Doc"}},"relationships":{"last_modified_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}}}]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Mon, 26 Sep 2022 21:17:25 GMT + request: + body: null + headers: + Accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/incidents/762590df-8e28-5b77-8282-a51ec6aff95f/attachments + response: + body: + encoding: UTF-8 + string: '{"data":[{"type":"incident_attachments","id":"c383d7df-3f44-571c-922a-4668ce53a8ad","attributes":{"modified":"2022-09-26T21:17:25.906466+00:00","attachment_type":"link","attachment":{"documentUrl":"https://www.example.com/doc","title":"Important + Doc"}},"relationships":{"last_modified_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}}}]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Mon, 26 Sep 2022 21:17:25 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/incidents/762590df-8e28-5b77-8282-a51ec6aff95f + response: + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/examples/v2/incidents/ListIncidentAttachments.rb b/examples/v2/incidents/ListIncidentAttachments.rb new file mode 100644 index 000000000000..a7902913480b --- /dev/null +++ b/examples/v2/incidents/ListIncidentAttachments.rb @@ -0,0 +1,8 @@ +# Get a list of attachments returns "OK" response + +require "datadog_api_client" +DatadogAPIClient::V2.configure do |config| + config.unstable_operations["v2.list_incident_attachments".to_sym] = true +end +api_instance = DatadogAPIClient::V2::IncidentsAPI.new +p api_instance.list_incident_attachments("incident_id") diff --git a/examples/v2/incidents/ListIncidentAttachments_2457735435.rb b/examples/v2/incidents/ListIncidentAttachments_2457735435.rb new file mode 100644 index 000000000000..a3d18aaf1fb4 --- /dev/null +++ b/examples/v2/incidents/ListIncidentAttachments_2457735435.rb @@ -0,0 +1,11 @@ +# Get incident attachments returns "OK" response + +require "datadog_api_client" +DatadogAPIClient::V2.configure do |config| + config.unstable_operations["v2.list_incident_attachments".to_sym] = true +end +api_instance = DatadogAPIClient::V2::IncidentsAPI.new + +# there is a valid "incident" in the system +INCIDENT_DATA_ID = ENV["INCIDENT_DATA_ID"] +p api_instance.list_incident_attachments(INCIDENT_DATA_ID) diff --git a/examples/v2/incidents/UpdateIncidentAttachments.rb b/examples/v2/incidents/UpdateIncidentAttachments.rb new file mode 100644 index 000000000000..2b5d7bdc54e0 --- /dev/null +++ b/examples/v2/incidents/UpdateIncidentAttachments.rb @@ -0,0 +1,38 @@ +# Create, update, and delete incident attachments returns "OK" response + +require "datadog_api_client" +DatadogAPIClient::V2.configure do |config| + config.unstable_operations["v2.update_incident_attachments".to_sym] = true +end +api_instance = DatadogAPIClient::V2::IncidentsAPI.new + +body = DatadogAPIClient::V2::IncidentAttachmentUpdateRequest.new({ + data: [ + DatadogAPIClient::V2::IncidentAttachmentUpdateData.new({ + attributes: DatadogAPIClient::V2::IncidentAttachmentPostmortemAttributes.new({ + attachment: DatadogAPIClient::V2::IncidentAttachmentsPostmortemAttributesAttachmentObject.new({ + document_url: "https://app.datadoghq.com/notebook/123", + title: "Postmortem IR-123", + }), + attachment_type: DatadogAPIClient::V2::IncidentAttachmentPostmortemAttachmentType::POSTMORTEM, + }), + id: "00000000-abcd-0002-0000-000000000000", + type: DatadogAPIClient::V2::IncidentAttachmentType::INCIDENT_ATTACHMENTS, + }), + DatadogAPIClient::V2::IncidentAttachmentUpdateData.new({ + attributes: DatadogAPIClient::V2::IncidentAttachmentLinkAttributes.new({ + attachment: DatadogAPIClient::V2::IncidentAttachmentLinkAttributesAttachmentObject.new({ + document_url: "https://www.example.com/webstore-failure-runbook", + title: "Runbook for webstore service failures", + }), + attachment_type: DatadogAPIClient::V2::IncidentAttachmentLinkAttachmentType::LINK, + }), + type: DatadogAPIClient::V2::IncidentAttachmentType::INCIDENT_ATTACHMENTS, + }), + DatadogAPIClient::V2::IncidentAttachmentUpdateData.new({ + id: "00000000-abcd-0003-0000-000000000000", + type: DatadogAPIClient::V2::IncidentAttachmentType::INCIDENT_ATTACHMENTS, + }), + ], +}) +p api_instance.update_incident_attachments("incident_id", body) diff --git a/examples/v2/incidents/UpdateIncidentAttachments_3881702075.rb b/examples/v2/incidents/UpdateIncidentAttachments_3881702075.rb new file mode 100644 index 000000000000..b6dfcf6ec0c7 --- /dev/null +++ b/examples/v2/incidents/UpdateIncidentAttachments_3881702075.rb @@ -0,0 +1,26 @@ +# Create an incident attachment returns "OK" response + +require "datadog_api_client" +DatadogAPIClient::V2.configure do |config| + config.unstable_operations["v2.update_incident_attachments".to_sym] = true +end +api_instance = DatadogAPIClient::V2::IncidentsAPI.new + +# there is a valid "incident" in the system +INCIDENT_DATA_ID = ENV["INCIDENT_DATA_ID"] + +body = DatadogAPIClient::V2::IncidentAttachmentUpdateRequest.new({ + data: [ + DatadogAPIClient::V2::IncidentAttachmentUpdateData.new({ + type: DatadogAPIClient::V2::IncidentAttachmentType::INCIDENT_ATTACHMENTS, + attributes: DatadogAPIClient::V2::IncidentAttachmentLinkAttributes.new({ + attachment_type: DatadogAPIClient::V2::IncidentAttachmentLinkAttachmentType::LINK, + attachment: DatadogAPIClient::V2::IncidentAttachmentLinkAttributesAttachmentObject.new({ + document_url: "https://www.example.com/doc", + title: "Example-Create_an_incident_attachment_returns_OK_response", + }), + }), + }), + ], +}) +p api_instance.update_incident_attachments(INCIDENT_DATA_ID, body) diff --git a/features/v2/given.json b/features/v2/given.json index 0a3a34949a36..ae5daeae6999 100644 --- a/features/v2/given.json +++ b/features/v2/given.json @@ -79,6 +79,22 @@ "tag": "Incidents", "operationId": "CreateIncident" }, + { + "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" + }, { "parameters": [ { diff --git a/features/v2/incidents.feature b/features/v2/incidents.feature index 0ff512cc1571..592f80801819 100644 --- a/features/v2/incidents.feature +++ b/features/v2/incidents.feature @@ -18,6 +18,17 @@ 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 + @generated @skip @team:DataDog/incident-app Scenario: Create an incident returns "Bad Request" response Given operation "CreateIncident" enabled @@ -44,6 +55,33 @@ 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 an existing incident returns "Bad Request" response Given operation "DeleteIncident" enabled @@ -69,6 +107,30 @@ Feature: Incidents When the request is sent Then the response status is 204 OK + @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 incidents returns "Bad Request" response Given operation "ListIncidents" enabled @@ -100,6 +162,17 @@ Feature: Incidents Then the response status is 200 OK And the response has 3 items + @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 + @generated @skip @team:DataDog/incident-app Scenario: Get the details of an incident returns "Bad Request" response Given operation "GetIncident" enabled diff --git a/features/v2/undo.json b/features/v2/undo.json index 1e42d9388dd8..80a6729cdffb 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -219,6 +219,18 @@ "type": "idempotent" } }, + "ListIncidentAttachments": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "UpdateIncidentAttachments": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, "ListOpsgenieServices": { "tag": "Opsgenie Integration", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index c5f71ffaa229..67d7936cab5a 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -182,8 +182,10 @@ def initialize "v2.create_incident": false, "v2.delete_incident": false, "v2.get_incident": false, + "v2.list_incident_attachments": false, "v2.list_incidents": false, "v2.update_incident": false, + "v2.update_incident_attachments": false, "v2.create_incident_service": false, "v2.delete_incident_service": false, "v2.get_incident_service": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 78a6a564bb54..b789bffd60c8 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -866,6 +866,24 @@ def overrides "v2.http_log_errors" => "HTTPLogErrors", "v2.http_log_item" => "HTTPLogItem", "v2.idp_metadata_form_data" => "IdPMetadataFormData", + "v2.incident_attachment_attachment_type" => "IncidentAttachmentAttachmentType", + "v2.incident_attachment_attributes" => "IncidentAttachmentAttributes", + "v2.incident_attachment_data" => "IncidentAttachmentData", + "v2.incident_attachment_link_attachment_type" => "IncidentAttachmentLinkAttachmentType", + "v2.incident_attachment_link_attributes" => "IncidentAttachmentLinkAttributes", + "v2.incident_attachment_link_attributes_attachment_object" => "IncidentAttachmentLinkAttributesAttachmentObject", + "v2.incident_attachment_postmortem_attachment_type" => "IncidentAttachmentPostmortemAttachmentType", + "v2.incident_attachment_postmortem_attributes" => "IncidentAttachmentPostmortemAttributes", + "v2.incident_attachment_related_object" => "IncidentAttachmentRelatedObject", + "v2.incident_attachment_relationships" => "IncidentAttachmentRelationships", + "v2.incident_attachments_postmortem_attributes_attachment_object" => "IncidentAttachmentsPostmortemAttributesAttachmentObject", + "v2.incident_attachments_response" => "IncidentAttachmentsResponse", + "v2.incident_attachments_response_included_item" => "IncidentAttachmentsResponseIncludedItem", + "v2.incident_attachment_type" => "IncidentAttachmentType", + "v2.incident_attachment_update_attributes" => "IncidentAttachmentUpdateAttributes", + "v2.incident_attachment_update_data" => "IncidentAttachmentUpdateData", + "v2.incident_attachment_update_request" => "IncidentAttachmentUpdateRequest", + "v2.incident_attachment_update_response" => "IncidentAttachmentUpdateResponse", "v2.incident_create_attributes" => "IncidentCreateAttributes", "v2.incident_create_data" => "IncidentCreateData", "v2.incident_create_relationships" => "IncidentCreateRelationships", @@ -1088,6 +1106,8 @@ def overrides "v2.process_summary_attributes" => "ProcessSummaryAttributes", "v2.process_summary_type" => "ProcessSummaryType", "v2.query_sort_order" => "QuerySortOrder", + "v2.relationship_to_incident_attachment" => "RelationshipToIncidentAttachment", + "v2.relationship_to_incident_attachment_data" => "RelationshipToIncidentAttachmentData", "v2.relationship_to_incident_integration_metadata_data" => "RelationshipToIncidentIntegrationMetadataData", "v2.relationship_to_incident_integration_metadatas" => "RelationshipToIncidentIntegrationMetadatas", "v2.relationship_to_incident_postmortem" => "RelationshipToIncidentPostmortem", diff --git a/lib/datadog_api_client/v2/api/incident_services_api.rb b/lib/datadog_api_client/v2/api/incident_services_api.rb index 72a68ef85456..5821add760e1 100644 --- a/lib/datadog_api_client/v2/api/incident_services_api.rb +++ b/lib/datadog_api_client/v2/api/incident_services_api.rb @@ -199,7 +199,7 @@ def get_incident_service_with_http_info(service_id, opts = {}) if @api_client.config.client_side_validation && service_id.nil? fail ArgumentError, "Missing the required parameter 'service_id' when calling IncidentServicesAPI.get_incident_service" end - allowable_values = ['users'] + allowable_values = ['users', 'attachments'] if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include']) fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}" end @@ -274,7 +274,7 @@ def list_incident_services_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: IncidentServicesAPI.list_incident_services ...' end - allowable_values = ['users'] + allowable_values = ['users', 'attachments'] if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include']) fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}" end diff --git a/lib/datadog_api_client/v2/api/incident_teams_api.rb b/lib/datadog_api_client/v2/api/incident_teams_api.rb index a6b0f4b5b2c0..18e09b780525 100644 --- a/lib/datadog_api_client/v2/api/incident_teams_api.rb +++ b/lib/datadog_api_client/v2/api/incident_teams_api.rb @@ -199,7 +199,7 @@ def get_incident_team_with_http_info(team_id, opts = {}) if @api_client.config.client_side_validation && team_id.nil? fail ArgumentError, "Missing the required parameter 'team_id' when calling IncidentTeamsAPI.get_incident_team" end - allowable_values = ['users'] + allowable_values = ['users', 'attachments'] if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include']) fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}" end @@ -274,7 +274,7 @@ def list_incident_teams_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: IncidentTeamsAPI.list_incident_teams ...' end - allowable_values = ['users'] + allowable_values = ['users', 'attachments'] if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include']) fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}" end diff --git a/lib/datadog_api_client/v2/api/incidents_api.rb b/lib/datadog_api_client/v2/api/incidents_api.rb index d1dc6075d120..c2d6549300d8 100644 --- a/lib/datadog_api_client/v2/api/incidents_api.rb +++ b/lib/datadog_api_client/v2/api/incidents_api.rb @@ -240,6 +240,81 @@ def get_incident_with_http_info(incident_id, opts = {}) return data, status_code, headers end + # Get a list of attachments. + # + # @see #list_incident_attachments_with_http_info + def list_incident_attachments(incident_id, opts = {}) + data, _status_code, _headers = list_incident_attachments_with_http_info(incident_id, opts) + data + end + + # Get a list of attachments. + # + # Get all attachments for a given incident. + # + # @param incident_id [String] The UUID of the incident. + # @param opts [Hash] the optional parameters + # @option opts [Array] :include Specifies which types of related objects are included in the response. + # @option opts [Array] :filter_attachment_type Specifies which types of attachments are included in the response. + # @return [Array<(IncidentAttachmentsResponse, Integer, Hash)>] IncidentAttachmentsResponse data, response status code and response headers + def list_incident_attachments_with_http_info(incident_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.list_incident_attachments".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_incident_attachments") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_incident_attachments")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: IncidentsAPI.list_incident_attachments ...' + end + # verify the required parameter 'incident_id' is set + if @api_client.config.client_side_validation && incident_id.nil? + fail ArgumentError, "Missing the required parameter 'incident_id' when calling IncidentsAPI.list_incident_attachments" + end + # resource path + local_var_path = '/api/v2/incidents/{incident_id}/attachments'.sub('{incident_id}', CGI.escape(incident_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil? + query_params[:'filter[attachment_type]'] = @api_client.build_collection_param(opts[:'filter_attachment_type'], :csv) if !opts[:'filter_attachment_type'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'IncidentAttachmentsResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_incident_attachments, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: IncidentsAPI#list_incident_attachments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get a list of incidents. # # @see #list_incidents_with_http_info @@ -412,5 +487,85 @@ def update_incident_with_http_info(incident_id, body, opts = {}) end return data, status_code, headers end + + # Create, update, and delete incident attachments. + # + # @see #update_incident_attachments_with_http_info + def update_incident_attachments(incident_id, body, opts = {}) + data, _status_code, _headers = update_incident_attachments_with_http_info(incident_id, body, opts) + data + end + + # Create, update, and delete incident attachments. + # + # The bulk update endpoint for creating, updating, and deleting attachments for a given incident. + # + # @param incident_id [String] The UUID of the incident. + # @param body [IncidentAttachmentUpdateRequest] Incident Attachment Payload. + # @param opts [Hash] the optional parameters + # @option opts [Array] :include Specifies which types of related objects are included in the response. + # @return [Array<(IncidentAttachmentUpdateResponse, Integer, Hash)>] IncidentAttachmentUpdateResponse data, response status code and response headers + def update_incident_attachments_with_http_info(incident_id, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.update_incident_attachments".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.update_incident_attachments") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.update_incident_attachments")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: IncidentsAPI.update_incident_attachments ...' + end + # verify the required parameter 'incident_id' is set + if @api_client.config.client_side_validation && incident_id.nil? + fail ArgumentError, "Missing the required parameter 'incident_id' when calling IncidentsAPI.update_incident_attachments" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling IncidentsAPI.update_incident_attachments" + end + # resource path + local_var_path = '/api/v2/incidents/{incident_id}/attachments'.sub('{incident_id}', CGI.escape(incident_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'IncidentAttachmentUpdateResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :update_incident_attachments, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Patch, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: IncidentsAPI#update_incident_attachments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_attachment_type.rb b/lib/datadog_api_client/v2/models/incident_attachment_attachment_type.rb new file mode 100644 index 000000000000..3ca77a601429 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_attachment_type.rb @@ -0,0 +1,27 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The type of the incident attachment attributes. + class IncidentAttachmentAttachmentType + include BaseEnumModel + + LINK = "link".freeze + POSTMORTEM = "postmortem".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_attributes.rb b/lib/datadog_api_client/v2/models/incident_attachment_attributes.rb new file mode 100644 index 000000000000..29cd868f461a --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_attributes.rb @@ -0,0 +1,63 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The attributes object for an attachment. + module IncidentAttachmentAttributes + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'IncidentAttachmentPostmortemAttributes', + :'IncidentAttachmentLinkAttributes' + ] + end + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_data.rb b/lib/datadog_api_client/v2/models/incident_attachment_data.rb new file mode 100644 index 000000000000..01d5c659d087 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_data.rb @@ -0,0 +1,187 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A single incident attachment. + class IncidentAttachmentData + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # The attributes object for an attachment. + attr_accessor :attributes + + # A unique identifier that represents the incident attachment. + attr_accessor :id + + # The incident attachment's relationships. + attr_accessor :relationships + + # The incident attachment resource type. + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'relationships' => :'relationships', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'IncidentAttachmentAttributes', + :'id' => :'String', + :'relationships' => :'IncidentAttachmentRelationships', + :'type' => :'IncidentAttachmentType' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::IncidentAttachmentData` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::IncidentAttachmentData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'relationships') + self.relationships = attributes[:'relationships'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'incident_attachments' + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @id.nil? + return false if @relationships.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param relationships [Object] Object to be assigned + # @!visibility private + def relationships=(relationships) + if relationships.nil? + fail ArgumentError, 'invalid value for "relationships", relationships cannot be nil.' + end + @relationships = relationships + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + relationships == o.relationships && + type == o.type + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, relationships, type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_link_attachment_type.rb b/lib/datadog_api_client/v2/models/incident_attachment_link_attachment_type.rb new file mode 100644 index 000000000000..19fcf5991c17 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_link_attachment_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The type of link attachment attributes. + class IncidentAttachmentLinkAttachmentType + include BaseEnumModel + + LINK = "link".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_link_attributes.rb b/lib/datadog_api_client/v2/models/incident_attachment_link_attributes.rb new file mode 100644 index 000000000000..8121e46f49a1 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_link_attributes.rb @@ -0,0 +1,145 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The attributes object for a link attachment. + class IncidentAttachmentLinkAttributes + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # The link attachment. + attr_accessor :attachment + + # The type of link attachment attributes. + attr_accessor :attachment_type + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attachment' => :'attachment', + :'attachment_type' => :'attachment_type' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attachment' => :'IncidentAttachmentLinkAttributesAttachmentObject', + :'attachment_type' => :'IncidentAttachmentLinkAttachmentType' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::IncidentAttachmentLinkAttributes` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::IncidentAttachmentLinkAttributes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'attachment') + self.attachment = attributes[:'attachment'] + end + + if attributes.key?(:'attachment_type') + self.attachment_type = attributes[:'attachment_type'] + else + self.attachment_type = 'link' + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attachment.nil? + return false if @attachment_type.nil? + true + end + + # Custom attribute writer method with validation + # @param attachment [Object] Object to be assigned + # @!visibility private + def attachment=(attachment) + if attachment.nil? + fail ArgumentError, 'invalid value for "attachment", attachment cannot be nil.' + end + @attachment = attachment + end + + # Custom attribute writer method with validation + # @param attachment_type [Object] Object to be assigned + # @!visibility private + def attachment_type=(attachment_type) + if attachment_type.nil? + fail ArgumentError, 'invalid value for "attachment_type", attachment_type cannot be nil.' + end + @attachment_type = attachment_type + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attachment == o.attachment && + attachment_type == o.attachment_type + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attachment, attachment_type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_link_attributes_attachment_object.rb b/lib/datadog_api_client/v2/models/incident_attachment_link_attributes_attachment_object.rb new file mode 100644 index 000000000000..dcf02ba1927a --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_link_attributes_attachment_object.rb @@ -0,0 +1,143 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The link attachment. + class IncidentAttachmentLinkAttributesAttachmentObject + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # The URL of this link attachment. + attr_accessor :document_url + + # The title of this link attachment. + attr_accessor :title + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'document_url' => :'documentUrl', + :'title' => :'title' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'document_url' => :'String', + :'title' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::IncidentAttachmentLinkAttributesAttachmentObject` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::IncidentAttachmentLinkAttributesAttachmentObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'document_url') + self.document_url = attributes[:'document_url'] + end + + if attributes.key?(:'title') + self.title = attributes[:'title'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @document_url.nil? + return false if @title.nil? + true + end + + # Custom attribute writer method with validation + # @param document_url [Object] Object to be assigned + # @!visibility private + def document_url=(document_url) + if document_url.nil? + fail ArgumentError, 'invalid value for "document_url", document_url cannot be nil.' + end + @document_url = document_url + end + + # Custom attribute writer method with validation + # @param title [Object] Object to be assigned + # @!visibility private + def title=(title) + if title.nil? + fail ArgumentError, 'invalid value for "title", title cannot be nil.' + end + @title = title + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + document_url == o.document_url && + title == o.title + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [document_url, title].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_postmortem_attachment_type.rb b/lib/datadog_api_client/v2/models/incident_attachment_postmortem_attachment_type.rb new file mode 100644 index 000000000000..eac29de0add9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_postmortem_attachment_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The type of postmortem attachment attributes. + class IncidentAttachmentPostmortemAttachmentType + include BaseEnumModel + + POSTMORTEM = "postmortem".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_postmortem_attributes.rb b/lib/datadog_api_client/v2/models/incident_attachment_postmortem_attributes.rb new file mode 100644 index 000000000000..fdd09088f773 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_postmortem_attributes.rb @@ -0,0 +1,145 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The attributes object for a postmortem attachment. + class IncidentAttachmentPostmortemAttributes + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # The postmortem attachment. + attr_accessor :attachment + + # The type of postmortem attachment attributes. + attr_accessor :attachment_type + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attachment' => :'attachment', + :'attachment_type' => :'attachment_type' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attachment' => :'IncidentAttachmentsPostmortemAttributesAttachmentObject', + :'attachment_type' => :'IncidentAttachmentPostmortemAttachmentType' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::IncidentAttachmentPostmortemAttributes` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::IncidentAttachmentPostmortemAttributes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'attachment') + self.attachment = attributes[:'attachment'] + end + + if attributes.key?(:'attachment_type') + self.attachment_type = attributes[:'attachment_type'] + else + self.attachment_type = 'postmortem' + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attachment.nil? + return false if @attachment_type.nil? + true + end + + # Custom attribute writer method with validation + # @param attachment [Object] Object to be assigned + # @!visibility private + def attachment=(attachment) + if attachment.nil? + fail ArgumentError, 'invalid value for "attachment", attachment cannot be nil.' + end + @attachment = attachment + end + + # Custom attribute writer method with validation + # @param attachment_type [Object] Object to be assigned + # @!visibility private + def attachment_type=(attachment_type) + if attachment_type.nil? + fail ArgumentError, 'invalid value for "attachment_type", attachment_type cannot be nil.' + end + @attachment_type = attachment_type + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attachment == o.attachment && + attachment_type == o.attachment_type + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attachment, attachment_type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_related_object.rb b/lib/datadog_api_client/v2/models/incident_attachment_related_object.rb new file mode 100644 index 000000000000..fe0201af5238 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_related_object.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The object related to an incident attachment. + class IncidentAttachmentRelatedObject + include BaseEnumModel + + USERS = "users".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_relationships.rb b/lib/datadog_api_client/v2/models/incident_attachment_relationships.rb new file mode 100644 index 000000000000..287989443ffb --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_relationships.rb @@ -0,0 +1,111 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The incident attachment's relationships. + class IncidentAttachmentRelationships + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Relationship to user. + attr_accessor :last_modified_by_user + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'last_modified_by_user' => :'last_modified_by_user' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'last_modified_by_user' => :'RelationshipToUser' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::IncidentAttachmentRelationships` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::IncidentAttachmentRelationships`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'last_modified_by_user') + self.last_modified_by_user = attributes[:'last_modified_by_user'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + last_modified_by_user == o.last_modified_by_user + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [last_modified_by_user].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_type.rb b/lib/datadog_api_client/v2/models/incident_attachment_type.rb new file mode 100644 index 000000000000..aacbd24c110b --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The incident attachment resource type. + class IncidentAttachmentType + include BaseEnumModel + + INCIDENT_ATTACHMENTS = "incident_attachments".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_update_attributes.rb b/lib/datadog_api_client/v2/models/incident_attachment_update_attributes.rb new file mode 100644 index 000000000000..ccd80b4b0406 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_update_attributes.rb @@ -0,0 +1,63 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Incident attachment attributes. + module IncidentAttachmentUpdateAttributes + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'IncidentAttachmentPostmortemAttributes', + :'IncidentAttachmentLinkAttributes' + ] + end + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_update_data.rb b/lib/datadog_api_client/v2/models/incident_attachment_update_data.rb new file mode 100644 index 000000000000..80d41517c0d6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_update_data.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A single incident attachment. + class IncidentAttachmentUpdateData + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Incident attachment attributes. + attr_accessor :attributes + + # A unique identifier that represents the incident attachment. + attr_accessor :id + + # The incident attachment resource type. + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'IncidentAttachmentUpdateAttributes', + :'id' => :'String', + :'type' => :'IncidentAttachmentType' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::IncidentAttachmentUpdateData` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::IncidentAttachmentUpdateData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'incident_attachments' + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + type == o.type + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_update_request.rb b/lib/datadog_api_client/v2/models/incident_attachment_update_request.rb new file mode 100644 index 000000000000..2bac93f14646 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_update_request.rb @@ -0,0 +1,127 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The update request for an incident's attachments. + class IncidentAttachmentUpdateRequest + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # 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. + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::IncidentAttachmentUpdateRequest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::IncidentAttachmentUpdateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachment_update_response.rb b/lib/datadog_api_client/v2/models/incident_attachment_update_response.rb new file mode 100644 index 000000000000..342c79c7ea4d --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachment_update_response.rb @@ -0,0 +1,137 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The response object containing the created or updated incident attachments. + class IncidentAttachmentUpdateResponse + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # An array of incident attachments. Only the attachments that were created or updated by the request are + # returned. + attr_accessor :data + + # Included related resources that the user requested. + attr_accessor :included + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'included' => :'included' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'included' => :'Array' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::IncidentAttachmentUpdateResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::IncidentAttachmentUpdateResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'included') + if (value = attributes[:'included']).is_a?(Array) + self.included = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + included == o.included + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, included].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachments_postmortem_attributes_attachment_object.rb b/lib/datadog_api_client/v2/models/incident_attachments_postmortem_attributes_attachment_object.rb new file mode 100644 index 000000000000..46a2b3caa36d --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachments_postmortem_attributes_attachment_object.rb @@ -0,0 +1,143 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The postmortem attachment. + class IncidentAttachmentsPostmortemAttributesAttachmentObject + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # The URL of this notebook attachment. + attr_accessor :document_url + + # The title of this postmortem attachment. + attr_accessor :title + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'document_url' => :'documentUrl', + :'title' => :'title' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'document_url' => :'String', + :'title' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::IncidentAttachmentsPostmortemAttributesAttachmentObject` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::IncidentAttachmentsPostmortemAttributesAttachmentObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'document_url') + self.document_url = attributes[:'document_url'] + end + + if attributes.key?(:'title') + self.title = attributes[:'title'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @document_url.nil? + return false if @title.nil? + true + end + + # Custom attribute writer method with validation + # @param document_url [Object] Object to be assigned + # @!visibility private + def document_url=(document_url) + if document_url.nil? + fail ArgumentError, 'invalid value for "document_url", document_url cannot be nil.' + end + @document_url = document_url + end + + # Custom attribute writer method with validation + # @param title [Object] Object to be assigned + # @!visibility private + def title=(title) + if title.nil? + fail ArgumentError, 'invalid value for "title", title cannot be nil.' + end + @title = title + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + document_url == o.document_url && + title == o.title + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [document_url, title].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachments_response.rb b/lib/datadog_api_client/v2/models/incident_attachments_response.rb new file mode 100644 index 000000000000..1995245b1369 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachments_response.rb @@ -0,0 +1,136 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The response object containing an incident's attachments. + class IncidentAttachmentsResponse + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # An array of incident attachments. + attr_accessor :data + + # Included related resources that the user requested. + attr_accessor :included + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'included' => :'included' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'included' => :'Array' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::IncidentAttachmentsResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::IncidentAttachmentsResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'included') + if (value = attributes[:'included']).is_a?(Array) + self.included = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + included == o.included + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, included].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_attachments_response_included_item.rb b/lib/datadog_api_client/v2/models/incident_attachments_response_included_item.rb new file mode 100644 index 000000000000..849fad459df3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_attachments_response_included_item.rb @@ -0,0 +1,62 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # An object related to an attachment that is included in the response. + module IncidentAttachmentsResponseIncludedItem + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'User' + ] + end + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_related_object.rb b/lib/datadog_api_client/v2/models/incident_related_object.rb index ab759483dd2c..eb12578f530a 100644 --- a/lib/datadog_api_client/v2/models/incident_related_object.rb +++ b/lib/datadog_api_client/v2/models/incident_related_object.rb @@ -22,5 +22,6 @@ class IncidentRelatedObject include BaseEnumModel USERS = "users".freeze + ATTACHMENTS = "attachments".freeze end end diff --git a/lib/datadog_api_client/v2/models/incident_response_attributes.rb b/lib/datadog_api_client/v2/models/incident_response_attributes.rb index 3822acd6f679..0d9ef40b8402 100644 --- a/lib/datadog_api_client/v2/models/incident_response_attributes.rb +++ b/lib/datadog_api_client/v2/models/incident_response_attributes.rb @@ -56,9 +56,6 @@ class IncidentResponseAttributes # Notification handles that will be notified of the incident during update. attr_accessor :notification_handles - # The UUID of the postmortem object attached to the incident. - attr_accessor :postmortem_id - # The monotonically increasing integer ID for the incident. attr_accessor :public_id @@ -95,7 +92,6 @@ def self.attribute_map :'fields' => :'fields', :'modified' => :'modified', :'notification_handles' => :'notification_handles', - :'postmortem_id' => :'postmortem_id', :'public_id' => :'public_id', :'resolved' => :'resolved', :'time_to_detect' => :'time_to_detect', @@ -126,7 +122,6 @@ def self.openapi_types :'fields' => :'Hash', :'modified' => :'Time', :'notification_handles' => :'Array', - :'postmortem_id' => :'String', :'public_id' => :'Integer', :'resolved' => :'Time', :'time_to_detect' => :'Integer', @@ -208,10 +203,6 @@ def initialize(attributes = {}) end end - if attributes.key?(:'postmortem_id') - self.postmortem_id = attributes[:'postmortem_id'] - end - if attributes.key?(:'public_id') self.public_id = attributes[:'public_id'] end @@ -275,7 +266,6 @@ def ==(o) fields == o.fields && modified == o.modified && notification_handles == o.notification_handles && - postmortem_id == o.postmortem_id && public_id == o.public_id && resolved == o.resolved && time_to_detect == o.time_to_detect && @@ -296,7 +286,7 @@ def eql?(o) # @return [Integer] Hash code # @!visibility private def hash - [created, customer_impact_duration, customer_impact_end, customer_impact_scope, customer_impact_start, customer_impacted, detected, fields, modified, notification_handles, postmortem_id, public_id, resolved, time_to_detect, time_to_internal_response, time_to_repair, time_to_resolve, title].hash + [created, customer_impact_duration, customer_impact_end, customer_impact_scope, customer_impact_start, customer_impacted, detected, fields, modified, notification_handles, public_id, resolved, time_to_detect, time_to_internal_response, time_to_repair, time_to_resolve, title].hash end end end diff --git a/lib/datadog_api_client/v2/models/incident_response_included_item.rb b/lib/datadog_api_client/v2/models/incident_response_included_item.rb index daa1360b971b..d4da4f239415 100644 --- a/lib/datadog_api_client/v2/models/incident_response_included_item.rb +++ b/lib/datadog_api_client/v2/models/incident_response_included_item.rb @@ -26,7 +26,8 @@ class << self # List of class defined in oneOf (OpenAPI v3) def openapi_one_of [ - :'User' + :'User', + :'IncidentAttachmentData' ] end # Builds the object diff --git a/lib/datadog_api_client/v2/models/incident_response_relationships.rb b/lib/datadog_api_client/v2/models/incident_response_relationships.rb index dff89fef9eea..fcb85f382e09 100644 --- a/lib/datadog_api_client/v2/models/incident_response_relationships.rb +++ b/lib/datadog_api_client/v2/models/incident_response_relationships.rb @@ -25,6 +25,9 @@ class IncidentResponseRelationships # @!visibility private attr_accessor :_unparsed + # A relationship reference for attachments. + attr_accessor :attachments + # Relationship to user. attr_accessor :commander_user @@ -37,18 +40,15 @@ class IncidentResponseRelationships # Relationship to user. attr_accessor :last_modified_by_user - # A relationship reference for postmortems. - attr_accessor :postmortem - # Attribute mapping from ruby-style variable name to JSON key. # @!visibility private def self.attribute_map { + :'attachments' => :'attachments', :'commander_user' => :'commander_user', :'created_by_user' => :'created_by_user', :'integrations' => :'integrations', - :'last_modified_by_user' => :'last_modified_by_user', - :'postmortem' => :'postmortem' + :'last_modified_by_user' => :'last_modified_by_user' } end @@ -62,11 +62,11 @@ def self.acceptable_attributes # @!visibility private def self.openapi_types { + :'attachments' => :'RelationshipToIncidentAttachment', :'commander_user' => :'NullableRelationshipToUser', :'created_by_user' => :'RelationshipToUser', :'integrations' => :'RelationshipToIncidentIntegrationMetadatas', - :'last_modified_by_user' => :'RelationshipToUser', - :'postmortem' => :'RelationshipToIncidentPostmortem' + :'last_modified_by_user' => :'RelationshipToUser' } end @@ -93,6 +93,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'attachments') + self.attachments = attributes[:'attachments'] + end + if attributes.key?(:'commander_user') self.commander_user = attributes[:'commander_user'] end @@ -108,10 +112,6 @@ def initialize(attributes = {}) if attributes.key?(:'last_modified_by_user') self.last_modified_by_user = attributes[:'last_modified_by_user'] end - - if attributes.key?(:'postmortem') - self.postmortem = attributes[:'postmortem'] - end end # Check to see if the all the properties in the model are valid @@ -127,11 +127,11 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + attachments == o.attachments && commander_user == o.commander_user && created_by_user == o.created_by_user && integrations == o.integrations && - last_modified_by_user == o.last_modified_by_user && - postmortem == o.postmortem + last_modified_by_user == o.last_modified_by_user end # @see the `==` method @@ -145,7 +145,7 @@ def eql?(o) # @return [Integer] Hash code # @!visibility private def hash - [commander_user, created_by_user, integrations, last_modified_by_user, postmortem].hash + [attachments, commander_user, created_by_user, integrations, last_modified_by_user].hash end end end diff --git a/lib/datadog_api_client/v2/models/relationship_to_incident_attachment.rb b/lib/datadog_api_client/v2/models/relationship_to_incident_attachment.rb new file mode 100644 index 000000000000..4cbce2c17845 --- /dev/null +++ b/lib/datadog_api_client/v2/models/relationship_to_incident_attachment.rb @@ -0,0 +1,124 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A relationship reference for attachments. + class RelationshipToIncidentAttachment + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # An array of incident attachments. + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::RelationshipToIncidentAttachment` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::RelationshipToIncidentAttachment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/relationship_to_incident_attachment_data.rb b/lib/datadog_api_client/v2/models/relationship_to_incident_attachment_data.rb new file mode 100644 index 000000000000..f618f584ccd5 --- /dev/null +++ b/lib/datadog_api_client/v2/models/relationship_to_incident_attachment_data.rb @@ -0,0 +1,145 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The attachment relationship data. + class RelationshipToIncidentAttachmentData + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # A unique identifier that represents the attachment. + attr_accessor :id + + # The incident attachment resource type. + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'id' => :'id', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'id' => :'String', + :'type' => :'IncidentAttachmentType' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::RelationshipToIncidentAttachmentData` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::RelationshipToIncidentAttachmentData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'incident_attachments' + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + type == o.type + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [id, type].hash + end + end +end