From 5e157b52e16c0d088ecce9cd815c1ccc472f31ed Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Mon, 6 Mar 2023 20:51:31 +0000 Subject: [PATCH] Add support for Incident Integration Metadata APIs (#1887) Co-authored-by: ci.datadog-api-spec --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 400 +++++++++++++++++- api/datadog/configuration.go | 5 + api/datadogV2/api_incidents.go | 389 +++++++++++++++++ api/datadogV2/doc.go | 5 + ...ncident_integration_metadata_attributes.go | 209 +++++++++ ...cident_integration_metadata_create_data.go | 153 +++++++ ...ent_integration_metadata_create_request.go | 110 +++++ ...dent_integration_metadata_list_response.go | 180 ++++++++ ..._incident_integration_metadata_metadata.go | 155 +++++++ ...ncident_integration_metadata_patch_data.go | 153 +++++++ ...dent_integration_metadata_patch_request.go | 110 +++++ ..._incident_integration_metadata_response.go | 145 +++++++ ...dent_integration_metadata_response_data.go | 188 ++++++++ ...gration_metadata_response_included_item.go | 123 ++++++ api/datadogV2/model_incident_update_data.go | 2 +- .../model_jira_integration_metadata.go | 103 +++++ ...l_jira_integration_metadata_issues_item.go | 241 +++++++++++ ...nship_to_incident_integration_metadatas.go | 2 +- .../model_slack_integration_metadata.go | 103 +++++ ...slack_integration_metadata_channel_item.go | 204 +++++++++ .../v2/incidents/CreateIncidentIntegration.go | 53 +++ .../v2/incidents/DeleteIncidentIntegration.go | 32 ++ .../v2/incidents/GetIncidentIntegration.go | 36 ++ .../v2/incidents/ListIncidentIntegrations.go | 33 ++ .../v2/incidents/UpdateIncidentIntegration.go | 56 +++ ...n_metadata_returns_CREATED_response.freeze | 1 + ...ion_metadata_returns_CREATED_response.yaml | 76 ++++ ...ration_metadata_returns_OK_response.freeze | 1 + ...egration_metadata_returns_OK_response.yaml | 92 ++++ ...ration_metadata_returns_OK_response.freeze | 1 + ...egration_metadata_returns_OK_response.yaml | 94 ++++ ...etadata_details_returns_OK_response.freeze | 1 + ..._metadata_details_returns_OK_response.yaml | 94 ++++ ...ration_metadata_returns_OK_response.freeze | 1 + ...egration_metadata_returns_OK_response.yaml | 97 +++++ tests/scenarios/features/v2/given.json | 16 + tests/scenarios/features/v2/incidents.feature | 149 +++++++ tests/scenarios/features/v2/undo.json | 41 ++ 39 files changed, 3854 insertions(+), 8 deletions(-) create mode 100644 api/datadogV2/model_incident_integration_metadata_attributes.go create mode 100644 api/datadogV2/model_incident_integration_metadata_create_data.go create mode 100644 api/datadogV2/model_incident_integration_metadata_create_request.go create mode 100644 api/datadogV2/model_incident_integration_metadata_list_response.go create mode 100644 api/datadogV2/model_incident_integration_metadata_metadata.go create mode 100644 api/datadogV2/model_incident_integration_metadata_patch_data.go create mode 100644 api/datadogV2/model_incident_integration_metadata_patch_request.go create mode 100644 api/datadogV2/model_incident_integration_metadata_response.go create mode 100644 api/datadogV2/model_incident_integration_metadata_response_data.go create mode 100644 api/datadogV2/model_incident_integration_metadata_response_included_item.go create mode 100644 api/datadogV2/model_jira_integration_metadata.go create mode 100644 api/datadogV2/model_jira_integration_metadata_issues_item.go create mode 100644 api/datadogV2/model_slack_integration_metadata.go create mode 100644 api/datadogV2/model_slack_integration_metadata_channel_item.go create mode 100644 examples/v2/incidents/CreateIncidentIntegration.go create mode 100644 examples/v2/incidents/DeleteIncidentIntegration.go create mode 100644 examples/v2/incidents/GetIncidentIntegration.go create mode 100644 examples/v2/incidents/ListIncidentIntegrations.go create mode 100644 examples/v2/incidents/UpdateIncidentIntegration.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_an_incident_integration_metadata_returns_CREATED_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_an_incident_integration_metadata_returns_CREATED_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_an_incident_integration_metadata_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_an_incident_integration_metadata_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_a_list_of_an_incidents_integration_metadata_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_a_list_of_an_incidents_integration_metadata_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_incident_integration_metadata_details_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_incident_integration_metadata_details_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_an_existing_incident_integration_metadata_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_an_existing_incident_integration_metadata_returns_OK_response.yaml diff --git a/.apigentools-info b/.apigentools-info index e8e687226b3..a6af5c8d186 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-03-03 14:44:26.649720", - "spec_repo_commit": "52f78f82" + "regenerated": "2023-03-06 17:22:48.284545", + "spec_repo_commit": "5248c0df" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-03-03 14:44:26.662001", - "spec_repo_commit": "52f78f82" + "regenerated": "2023-03-06 17:22:48.297155", + "spec_repo_commit": "5248c0df" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 8b4befe6ab4..28bf6944d5d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -211,6 +211,13 @@ components: items: $ref: '#/components/schemas/IncidentRelatedObject' type: array + IncidentIntegrationMetadataIDPathParameter: + description: The UUID of the incident integration metadata. + in: path + name: integration_metadata_id + required: true + schema: + type: string IncidentSearchIncludeQueryParameter: description: Specifies which types of related objects should be included in the response. @@ -4347,6 +4354,137 @@ components: - TEXTARRAY - METRICTAG - AUTOCOMPLETE + IncidentIntegrationMetadataAttributes: + description: Incident integration metadata's attributes for a create request. + properties: + incident_id: + description: UUID of the incident this integration metadata is connected + to. + example: 00000000-aaaa-0000-0000-000000000000 + type: string + integration_type: + description: 'A number indicating the type of integration this metadata + is for. 1 indicates Slack; + + 8 indicates Jira.' + example: 1 + format: int32 + maximum: 9 + type: integer + metadata: + $ref: '#/components/schemas/IncidentIntegrationMetadataMetadata' + status: + description: 'A number indicating the status of this integration metadata. + 0 indicates unknown; + + 1 indicates pending; 2 indicates complete; 3 indicates manually created; + + 4 indicates manually updated; 5 indicates failed.' + format: int32 + maximum: 5 + type: integer + required: + - integration_type + - metadata + type: object + IncidentIntegrationMetadataCreateData: + description: Incident integration metadata data for a create request. + properties: + attributes: + $ref: '#/components/schemas/IncidentIntegrationMetadataAttributes' + type: + $ref: '#/components/schemas/IncidentIntegrationMetadataType' + required: + - type + - attributes + type: object + IncidentIntegrationMetadataCreateRequest: + description: Create request for an incident integration metadata. + properties: + data: + $ref: '#/components/schemas/IncidentIntegrationMetadataCreateData' + required: + - data + type: object + IncidentIntegrationMetadataListResponse: + description: Response with a list of incident integration metadata. + properties: + data: + description: An array of incident integration metadata. + items: + $ref: '#/components/schemas/IncidentIntegrationMetadataResponseData' + type: array + included: + description: Included related resources that the user requested. + items: + $ref: '#/components/schemas/IncidentIntegrationMetadataResponseIncludedItem' + readOnly: true + type: array + meta: + $ref: '#/components/schemas/IncidentResponseMeta' + required: + - data + type: object + IncidentIntegrationMetadataMetadata: + description: Incident integration metadata's metadata attribute. + oneOf: + - $ref: '#/components/schemas/SlackIntegrationMetadata' + - $ref: '#/components/schemas/JiraIntegrationMetadata' + type: object + IncidentIntegrationMetadataPatchData: + description: Incident integration metadata data for a patch request. + properties: + attributes: + $ref: '#/components/schemas/IncidentIntegrationMetadataAttributes' + type: + $ref: '#/components/schemas/IncidentIntegrationMetadataType' + required: + - type + - attributes + type: object + IncidentIntegrationMetadataPatchRequest: + description: Patch request for an incident integration metadata. + properties: + data: + $ref: '#/components/schemas/IncidentIntegrationMetadataPatchData' + required: + - data + type: object + IncidentIntegrationMetadataResponse: + description: Response with an incident integration metadata. + properties: + data: + $ref: '#/components/schemas/IncidentIntegrationMetadataResponseData' + included: + description: Included related resources that the user requested. + items: + $ref: '#/components/schemas/IncidentIntegrationMetadataResponseIncludedItem' + readOnly: true + type: array + required: + - data + type: object + IncidentIntegrationMetadataResponseData: + description: Incident integration metadata from a response. + properties: + attributes: + $ref: '#/components/schemas/IncidentIntegrationMetadataAttributes' + id: + description: The incident integration metadata's ID. + example: 00000000-0000-0000-1234-000000000000 + type: string + type: + $ref: '#/components/schemas/IncidentIntegrationMetadataType' + required: + - id + - type + type: object + IncidentIntegrationMetadataResponseIncludedItem: + description: An object related to an incident integration metadata that is included + in the response. + oneOf: + - $ref: '#/components/schemas/User' + type: object IncidentIntegrationMetadataType: default: incident_integrations description: Integration metadata resource type. @@ -5201,7 +5339,7 @@ components: attributes: $ref: '#/components/schemas/IncidentUpdateAttributes' id: - description: The team's ID. + description: The incident's ID. example: 00000000-0000-0000-4567-000000000000 type: string relationships: @@ -5348,6 +5486,45 @@ components: type: string type: array type: object + JiraIntegrationMetadata: + description: Incident integration metadata for the Jira integration. + properties: + issues: + description: Array of Jira issues in this integration metadata. + example: [] + items: + $ref: '#/components/schemas/JiraIntegrationMetadataIssuesItem' + type: array + required: + - issues + type: object + JiraIntegrationMetadataIssuesItem: + description: Item in the Jira integration metadata issue array. + properties: + account: + description: URL of issue's Jira account. + example: https://example.atlassian.net + type: string + issue_key: + description: Jira issue's issue key. + example: PROJ-123 + type: string + issuetype_id: + description: Jira issue's issue type. + example: '1000' + type: string + project_key: + description: Jira issue's project keys. + example: PROJ + type: string + redirect_url: + description: URL redirecting to the Jira issue. + example: https://example.atlassian.net/browse/PROJ-123 + type: string + required: + - project_key + - account + type: object ListApplicationKeysResponse: description: Response for a list of application keys. properties: @@ -8965,7 +9142,7 @@ components: type: incident_integrations properties: data: - description: The integration metadata relationship array + description: Integration metadata relationship array example: - id: 00000000-abcd-0003-0000-000000000000 type: incident_integrations @@ -12131,6 +12308,42 @@ components: $ref: '#/components/schemas/ServiceDefinitionData' type: array type: object + SlackIntegrationMetadata: + description: Incident integration metadata for the Slack integration. + properties: + channels: + description: Array of Slack channels in this integration metadata. + example: [] + items: + $ref: '#/components/schemas/SlackIntegrationMetadataChannelItem' + type: array + required: + - channels + type: object + SlackIntegrationMetadataChannelItem: + description: Item in the Slack integration metadata channel array. + properties: + channel_id: + description: Slack channel ID. + example: C0123456789 + type: string + channel_name: + description: Name of the Slack channel. + example: '#example-channel-name' + type: string + redirect_url: + description: URL redirecting to the Slack channel. + example: https://slack.com/app_redirect?channel=C0123456789&team=T01234567 + type: string + team_id: + description: Slack team ID. + example: T01234567 + type: string + required: + - channel_id + - channel_name + - redirect_url + type: object TagsEventAttribute: description: Array of tags associated with your event. example: @@ -14477,6 +14690,189 @@ 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}/relationships/integrations: + get: + description: Get all integration metadata for an incident. + operationId: ListIncidentIntegrations + parameters: + - $ref: '#/components/parameters/IncidentIDPathParameter' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentIntegrationMetadataListResponse' + 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 an incident's integration metadata + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create an incident integration metadata. + operationId: CreateIncidentIntegration + parameters: + - $ref: '#/components/parameters/IncidentIDPathParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentIntegrationMetadataCreateRequest' + description: Incident integration metadata payload. + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentIntegrationMetadataResponse' + description: CREATED + '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_write + summary: Create an incident integration metadata + 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/incidents/{incident_id}/relationships/integrations/{integration_metadata_id}: + delete: + description: Delete an incident integration metadata. + operationId: DeleteIncidentIntegration + parameters: + - $ref: '#/components/parameters/IncidentIDPathParameter' + - $ref: '#/components/parameters/IncidentIntegrationMetadataIDPathParameter' + responses: + '204': + 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_write + summary: Delete an incident integration metadata + 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/).' + get: + description: Get incident integration metadata details. + operationId: GetIncidentIntegration + parameters: + - $ref: '#/components/parameters/IncidentIDPathParameter' + - $ref: '#/components/parameters/IncidentIntegrationMetadataIDPathParameter' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentIntegrationMetadataResponse' + 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 incident integration metadata details + 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: Update an existing incident integration metadata. + operationId: UpdateIncidentIntegration + parameters: + - $ref: '#/components/parameters/IncidentIDPathParameter' + - $ref: '#/components/parameters/IncidentIntegrationMetadataIDPathParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentIntegrationMetadataPatchRequest' + description: Incident integration metadata payload. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentIntegrationMetadataResponse' + 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_write + summary: Update an existing incident integration metadata + 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/api/datadog/configuration.go b/api/datadog/configuration.go index 9bf7b9e8ff0..448376d2f24 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -362,13 +362,18 @@ func NewConfiguration() *Configuration { "v2.ListEvents": false, "v2.SearchEvents": false, "v2.CreateIncident": false, + "v2.CreateIncidentIntegration": false, "v2.DeleteIncident": false, + "v2.DeleteIncidentIntegration": false, "v2.GetIncident": false, + "v2.GetIncidentIntegration": false, "v2.ListIncidentAttachments": false, + "v2.ListIncidentIntegrations": false, "v2.ListIncidents": false, "v2.SearchIncidents": false, "v2.UpdateIncident": false, "v2.UpdateIncidentAttachments": false, + "v2.UpdateIncidentIntegration": false, "v2.QueryScalarData": false, "v2.QueryTimeseriesData": false, "v2.CreateIncidentService": false, diff --git a/api/datadogV2/api_incidents.go b/api/datadogV2/api_incidents.go index 35965c92f45..6d17c1be2bb 100644 --- a/api/datadogV2/api_incidents.go +++ b/api/datadogV2/api_incidents.go @@ -98,6 +98,87 @@ func (a *IncidentsApi) CreateIncident(ctx _context.Context, body IncidentCreateR return localVarReturnValue, localVarHTTPResponse, nil } +// CreateIncidentIntegration Create an incident integration metadata. +// Create an incident integration metadata. +func (a *IncidentsApi) CreateIncidentIntegration(ctx _context.Context, incidentId string, body IncidentIntegrationMetadataCreateRequest) (IncidentIntegrationMetadataResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue IncidentIntegrationMetadataResponse + ) + + operationId := "v2.CreateIncidentIntegration" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.CreateIncidentIntegration") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/{incident_id}/relationships/integrations" + localVarPath = strings.Replace(localVarPath, "{"+"incident_id"+"}", _neturl.PathEscape(datadog.ParameterToString(incidentId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // DeleteIncident Delete an existing incident. // Deletes an existing incident from the users organization. func (a *IncidentsApi) DeleteIncident(ctx _context.Context, incidentId string) (*_nethttp.Response, error) { @@ -166,6 +247,75 @@ func (a *IncidentsApi) DeleteIncident(ctx _context.Context, incidentId string) ( return localVarHTTPResponse, nil } +// DeleteIncidentIntegration Delete an incident integration metadata. +// Delete an incident integration metadata. +func (a *IncidentsApi) DeleteIncidentIntegration(ctx _context.Context, incidentId string, integrationMetadataId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.DeleteIncidentIntegration" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.DeleteIncidentIntegration") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/{incident_id}/relationships/integrations/{integration_metadata_id}" + localVarPath = strings.Replace(localVarPath, "{"+"incident_id"+"}", _neturl.PathEscape(datadog.ParameterToString(incidentId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"integration_metadata_id"+"}", _neturl.PathEscape(datadog.ParameterToString(integrationMetadataId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // GetIncidentOptionalParameters holds optional parameters for GetIncident. type GetIncidentOptionalParameters struct { Include *[]IncidentRelatedObject @@ -272,6 +422,85 @@ func (a *IncidentsApi) GetIncident(ctx _context.Context, incidentId string, o .. return localVarReturnValue, localVarHTTPResponse, nil } +// GetIncidentIntegration Get incident integration metadata details. +// Get incident integration metadata details. +func (a *IncidentsApi) GetIncidentIntegration(ctx _context.Context, incidentId string, integrationMetadataId string) (IncidentIntegrationMetadataResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue IncidentIntegrationMetadataResponse + ) + + operationId := "v2.GetIncidentIntegration" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.GetIncidentIntegration") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/{incident_id}/relationships/integrations/{integration_metadata_id}" + localVarPath = strings.Replace(localVarPath, "{"+"incident_id"+"}", _neturl.PathEscape(datadog.ParameterToString(incidentId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"integration_metadata_id"+"}", _neturl.PathEscape(datadog.ParameterToString(integrationMetadataId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // ListIncidentAttachmentsOptionalParameters holds optional parameters for ListIncidentAttachments. type ListIncidentAttachmentsOptionalParameters struct { Include *[]IncidentAttachmentRelatedObject @@ -388,6 +617,84 @@ func (a *IncidentsApi) ListIncidentAttachments(ctx _context.Context, incidentId return localVarReturnValue, localVarHTTPResponse, nil } +// ListIncidentIntegrations Get a list of an incident's integration metadata. +// Get all integration metadata for an incident. +func (a *IncidentsApi) ListIncidentIntegrations(ctx _context.Context, incidentId string) (IncidentIntegrationMetadataListResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue IncidentIntegrationMetadataListResponse + ) + + operationId := "v2.ListIncidentIntegrations" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.ListIncidentIntegrations") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/{incident_id}/relationships/integrations" + localVarPath = strings.Replace(localVarPath, "{"+"incident_id"+"}", _neturl.PathEscape(datadog.ParameterToString(incidentId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // ListIncidentsOptionalParameters holds optional parameters for ListIncidents. type ListIncidentsOptionalParameters struct { Include *[]IncidentRelatedObject @@ -897,6 +1204,88 @@ func (a *IncidentsApi) UpdateIncidentAttachments(ctx _context.Context, incidentI return localVarReturnValue, localVarHTTPResponse, nil } +// UpdateIncidentIntegration Update an existing incident integration metadata. +// Update an existing incident integration metadata. +func (a *IncidentsApi) UpdateIncidentIntegration(ctx _context.Context, incidentId string, integrationMetadataId string, body IncidentIntegrationMetadataPatchRequest) (IncidentIntegrationMetadataResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue IncidentIntegrationMetadataResponse + ) + + operationId := "v2.UpdateIncidentIntegration" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.UpdateIncidentIntegration") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/{incident_id}/relationships/integrations/{integration_metadata_id}" + localVarPath = strings.Replace(localVarPath, "{"+"incident_id"+"}", _neturl.PathEscape(datadog.ParameterToString(incidentId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"integration_metadata_id"+"}", _neturl.PathEscape(datadog.ParameterToString(integrationMetadataId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // NewIncidentsApi Returns NewIncidentsApi. func NewIncidentsApi(client *datadog.APIClient) *IncidentsApi { return &IncidentsApi{ diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 5c9bda82e49..4002afb5a3b 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -66,13 +66,18 @@ // - [IncidentTeamsApi.ListIncidentTeams] // - [IncidentTeamsApi.UpdateIncidentTeam] // - [IncidentsApi.CreateIncident] +// - [IncidentsApi.CreateIncidentIntegration] // - [IncidentsApi.DeleteIncident] +// - [IncidentsApi.DeleteIncidentIntegration] // - [IncidentsApi.GetIncident] +// - [IncidentsApi.GetIncidentIntegration] // - [IncidentsApi.ListIncidentAttachments] +// - [IncidentsApi.ListIncidentIntegrations] // - [IncidentsApi.ListIncidents] // - [IncidentsApi.SearchIncidents] // - [IncidentsApi.UpdateIncident] // - [IncidentsApi.UpdateIncidentAttachments] +// - [IncidentsApi.UpdateIncidentIntegration] // - [KeyManagementApi.CreateAPIKey] // - [KeyManagementApi.CreateCurrentUserApplicationKey] // - [KeyManagementApi.DeleteAPIKey] diff --git a/api/datadogV2/model_incident_integration_metadata_attributes.go b/api/datadogV2/model_incident_integration_metadata_attributes.go new file mode 100644 index 00000000000..8b12a6147e0 --- /dev/null +++ b/api/datadogV2/model_incident_integration_metadata_attributes.go @@ -0,0 +1,209 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// IncidentIntegrationMetadataAttributes Incident integration metadata's attributes for a create request. +type IncidentIntegrationMetadataAttributes struct { + // UUID of the incident this integration metadata is connected to. + IncidentId *string `json:"incident_id,omitempty"` + // A number indicating the type of integration this metadata is for. 1 indicates Slack; + // 8 indicates Jira. + IntegrationType int32 `json:"integration_type"` + // Incident integration metadata's metadata attribute. + Metadata IncidentIntegrationMetadataMetadata `json:"metadata"` + // A number indicating the status of this integration metadata. 0 indicates unknown; + // 1 indicates pending; 2 indicates complete; 3 indicates manually created; + // 4 indicates manually updated; 5 indicates failed. + Status *int32 `json:"status,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewIncidentIntegrationMetadataAttributes instantiates a new IncidentIntegrationMetadataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentIntegrationMetadataAttributes(integrationType int32, metadata IncidentIntegrationMetadataMetadata) *IncidentIntegrationMetadataAttributes { + this := IncidentIntegrationMetadataAttributes{} + this.IntegrationType = integrationType + this.Metadata = metadata + return &this +} + +// NewIncidentIntegrationMetadataAttributesWithDefaults instantiates a new IncidentIntegrationMetadataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentIntegrationMetadataAttributesWithDefaults() *IncidentIntegrationMetadataAttributes { + this := IncidentIntegrationMetadataAttributes{} + return &this +} + +// GetIncidentId returns the IncidentId field value if set, zero value otherwise. +func (o *IncidentIntegrationMetadataAttributes) GetIncidentId() string { + if o == nil || o.IncidentId == nil { + var ret string + return ret + } + return *o.IncidentId +} + +// GetIncidentIdOk returns a tuple with the IncidentId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataAttributes) GetIncidentIdOk() (*string, bool) { + if o == nil || o.IncidentId == nil { + return nil, false + } + return o.IncidentId, true +} + +// HasIncidentId returns a boolean if a field has been set. +func (o *IncidentIntegrationMetadataAttributes) HasIncidentId() bool { + return o != nil && o.IncidentId != nil +} + +// SetIncidentId gets a reference to the given string and assigns it to the IncidentId field. +func (o *IncidentIntegrationMetadataAttributes) SetIncidentId(v string) { + o.IncidentId = &v +} + +// GetIntegrationType returns the IntegrationType field value. +func (o *IncidentIntegrationMetadataAttributes) GetIntegrationType() int32 { + if o == nil { + var ret int32 + return ret + } + return o.IntegrationType +} + +// GetIntegrationTypeOk returns a tuple with the IntegrationType field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataAttributes) GetIntegrationTypeOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.IntegrationType, true +} + +// SetIntegrationType sets field value. +func (o *IncidentIntegrationMetadataAttributes) SetIntegrationType(v int32) { + o.IntegrationType = v +} + +// GetMetadata returns the Metadata field value. +func (o *IncidentIntegrationMetadataAttributes) GetMetadata() IncidentIntegrationMetadataMetadata { + if o == nil { + var ret IncidentIntegrationMetadataMetadata + return ret + } + return o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataAttributes) GetMetadataOk() (*IncidentIntegrationMetadataMetadata, bool) { + if o == nil { + return nil, false + } + return &o.Metadata, true +} + +// SetMetadata sets field value. +func (o *IncidentIntegrationMetadataAttributes) SetMetadata(v IncidentIntegrationMetadataMetadata) { + o.Metadata = v +} + +// GetStatus returns the Status field value if set, zero value otherwise. +func (o *IncidentIntegrationMetadataAttributes) GetStatus() int32 { + if o == nil || o.Status == nil { + var ret int32 + return ret + } + return *o.Status +} + +// GetStatusOk returns a tuple with the Status field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataAttributes) GetStatusOk() (*int32, bool) { + if o == nil || o.Status == nil { + return nil, false + } + return o.Status, true +} + +// HasStatus returns a boolean if a field has been set. +func (o *IncidentIntegrationMetadataAttributes) HasStatus() bool { + return o != nil && o.Status != nil +} + +// SetStatus gets a reference to the given int32 and assigns it to the Status field. +func (o *IncidentIntegrationMetadataAttributes) SetStatus(v int32) { + o.Status = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentIntegrationMetadataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.IncidentId != nil { + toSerialize["incident_id"] = o.IncidentId + } + toSerialize["integration_type"] = o.IntegrationType + toSerialize["metadata"] = o.Metadata + if o.Status != nil { + toSerialize["status"] = o.Status + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentIntegrationMetadataAttributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + IntegrationType *int32 `json:"integration_type"` + Metadata *IncidentIntegrationMetadataMetadata `json:"metadata"` + }{} + all := struct { + IncidentId *string `json:"incident_id,omitempty"` + IntegrationType int32 `json:"integration_type"` + Metadata IncidentIntegrationMetadataMetadata `json:"metadata"` + Status *int32 `json:"status,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.IntegrationType == nil { + return fmt.Errorf("required field integration_type missing") + } + if required.Metadata == nil { + return fmt.Errorf("required field metadata missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.IncidentId = all.IncidentId + o.IntegrationType = all.IntegrationType + o.Metadata = all.Metadata + o.Status = all.Status + return nil +} diff --git a/api/datadogV2/model_incident_integration_metadata_create_data.go b/api/datadogV2/model_incident_integration_metadata_create_data.go new file mode 100644 index 00000000000..be34a89148e --- /dev/null +++ b/api/datadogV2/model_incident_integration_metadata_create_data.go @@ -0,0 +1,153 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// IncidentIntegrationMetadataCreateData Incident integration metadata data for a create request. +type IncidentIntegrationMetadataCreateData struct { + // Incident integration metadata's attributes for a create request. + Attributes IncidentIntegrationMetadataAttributes `json:"attributes"` + // Integration metadata resource type. + Type IncidentIntegrationMetadataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewIncidentIntegrationMetadataCreateData instantiates a new IncidentIntegrationMetadataCreateData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentIntegrationMetadataCreateData(attributes IncidentIntegrationMetadataAttributes, typeVar IncidentIntegrationMetadataType) *IncidentIntegrationMetadataCreateData { + this := IncidentIntegrationMetadataCreateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewIncidentIntegrationMetadataCreateDataWithDefaults instantiates a new IncidentIntegrationMetadataCreateData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentIntegrationMetadataCreateDataWithDefaults() *IncidentIntegrationMetadataCreateData { + this := IncidentIntegrationMetadataCreateData{} + var typeVar IncidentIntegrationMetadataType = INCIDENTINTEGRATIONMETADATATYPE_INCIDENT_INTEGRATIONS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *IncidentIntegrationMetadataCreateData) GetAttributes() IncidentIntegrationMetadataAttributes { + if o == nil { + var ret IncidentIntegrationMetadataAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataCreateData) GetAttributesOk() (*IncidentIntegrationMetadataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *IncidentIntegrationMetadataCreateData) SetAttributes(v IncidentIntegrationMetadataAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *IncidentIntegrationMetadataCreateData) GetType() IncidentIntegrationMetadataType { + if o == nil { + var ret IncidentIntegrationMetadataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataCreateData) GetTypeOk() (*IncidentIntegrationMetadataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *IncidentIntegrationMetadataCreateData) SetType(v IncidentIntegrationMetadataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentIntegrationMetadataCreateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentIntegrationMetadataCreateData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Attributes *IncidentIntegrationMetadataAttributes `json:"attributes"` + Type *IncidentIntegrationMetadataType `json:"type"` + }{} + all := struct { + Attributes IncidentIntegrationMetadataAttributes `json:"attributes"` + Type IncidentIntegrationMetadataType `json:"type"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if required.Type == nil { + return fmt.Errorf("required field type missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_incident_integration_metadata_create_request.go b/api/datadogV2/model_incident_integration_metadata_create_request.go new file mode 100644 index 00000000000..c60c366d0de --- /dev/null +++ b/api/datadogV2/model_incident_integration_metadata_create_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// IncidentIntegrationMetadataCreateRequest Create request for an incident integration metadata. +type IncidentIntegrationMetadataCreateRequest struct { + // Incident integration metadata data for a create request. + Data IncidentIntegrationMetadataCreateData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewIncidentIntegrationMetadataCreateRequest instantiates a new IncidentIntegrationMetadataCreateRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentIntegrationMetadataCreateRequest(data IncidentIntegrationMetadataCreateData) *IncidentIntegrationMetadataCreateRequest { + this := IncidentIntegrationMetadataCreateRequest{} + this.Data = data + return &this +} + +// NewIncidentIntegrationMetadataCreateRequestWithDefaults instantiates a new IncidentIntegrationMetadataCreateRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentIntegrationMetadataCreateRequestWithDefaults() *IncidentIntegrationMetadataCreateRequest { + this := IncidentIntegrationMetadataCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentIntegrationMetadataCreateRequest) GetData() IncidentIntegrationMetadataCreateData { + if o == nil { + var ret IncidentIntegrationMetadataCreateData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataCreateRequest) GetDataOk() (*IncidentIntegrationMetadataCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentIntegrationMetadataCreateRequest) SetData(v IncidentIntegrationMetadataCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentIntegrationMetadataCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentIntegrationMetadataCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Data *IncidentIntegrationMetadataCreateData `json:"data"` + }{} + all := struct { + Data IncidentIntegrationMetadataCreateData `json:"data"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Data == nil { + return fmt.Errorf("required field data missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + return nil +} diff --git a/api/datadogV2/model_incident_integration_metadata_list_response.go b/api/datadogV2/model_incident_integration_metadata_list_response.go new file mode 100644 index 00000000000..333a821edab --- /dev/null +++ b/api/datadogV2/model_incident_integration_metadata_list_response.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// IncidentIntegrationMetadataListResponse Response with a list of incident integration metadata. +type IncidentIntegrationMetadataListResponse struct { + // An array of incident integration metadata. + Data []IncidentIntegrationMetadataResponseData `json:"data"` + // Included related resources that the user requested. + Included []IncidentIntegrationMetadataResponseIncludedItem `json:"included,omitempty"` + // The metadata object containing pagination metadata. + Meta *IncidentResponseMeta `json:"meta,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewIncidentIntegrationMetadataListResponse instantiates a new IncidentIntegrationMetadataListResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentIntegrationMetadataListResponse(data []IncidentIntegrationMetadataResponseData) *IncidentIntegrationMetadataListResponse { + this := IncidentIntegrationMetadataListResponse{} + this.Data = data + return &this +} + +// NewIncidentIntegrationMetadataListResponseWithDefaults instantiates a new IncidentIntegrationMetadataListResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentIntegrationMetadataListResponseWithDefaults() *IncidentIntegrationMetadataListResponse { + this := IncidentIntegrationMetadataListResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentIntegrationMetadataListResponse) GetData() []IncidentIntegrationMetadataResponseData { + if o == nil { + var ret []IncidentIntegrationMetadataResponseData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataListResponse) GetDataOk() (*[]IncidentIntegrationMetadataResponseData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentIntegrationMetadataListResponse) SetData(v []IncidentIntegrationMetadataResponseData) { + o.Data = v +} + +// GetIncluded returns the Included field value if set, zero value otherwise. +func (o *IncidentIntegrationMetadataListResponse) GetIncluded() []IncidentIntegrationMetadataResponseIncludedItem { + if o == nil || o.Included == nil { + var ret []IncidentIntegrationMetadataResponseIncludedItem + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataListResponse) GetIncludedOk() (*[]IncidentIntegrationMetadataResponseIncludedItem, bool) { + if o == nil || o.Included == nil { + return nil, false + } + return &o.Included, true +} + +// HasIncluded returns a boolean if a field has been set. +func (o *IncidentIntegrationMetadataListResponse) HasIncluded() bool { + return o != nil && o.Included != nil +} + +// SetIncluded gets a reference to the given []IncidentIntegrationMetadataResponseIncludedItem and assigns it to the Included field. +func (o *IncidentIntegrationMetadataListResponse) SetIncluded(v []IncidentIntegrationMetadataResponseIncludedItem) { + o.Included = v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *IncidentIntegrationMetadataListResponse) GetMeta() IncidentResponseMeta { + if o == nil || o.Meta == nil { + var ret IncidentResponseMeta + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataListResponse) GetMetaOk() (*IncidentResponseMeta, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *IncidentIntegrationMetadataListResponse) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given IncidentResponseMeta and assigns it to the Meta field. +func (o *IncidentIntegrationMetadataListResponse) SetMeta(v IncidentResponseMeta) { + o.Meta = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentIntegrationMetadataListResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + if o.Included != nil { + toSerialize["included"] = o.Included + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentIntegrationMetadataListResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Data *[]IncidentIntegrationMetadataResponseData `json:"data"` + }{} + all := struct { + Data []IncidentIntegrationMetadataResponseData `json:"data"` + Included []IncidentIntegrationMetadataResponseIncludedItem `json:"included,omitempty"` + Meta *IncidentResponseMeta `json:"meta,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Data == nil { + return fmt.Errorf("required field data missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Data = all.Data + o.Included = all.Included + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Meta = all.Meta + return nil +} diff --git a/api/datadogV2/model_incident_integration_metadata_metadata.go b/api/datadogV2/model_incident_integration_metadata_metadata.go new file mode 100644 index 00000000000..31611678de9 --- /dev/null +++ b/api/datadogV2/model_incident_integration_metadata_metadata.go @@ -0,0 +1,155 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// IncidentIntegrationMetadataMetadata - Incident integration metadata's metadata attribute. +type IncidentIntegrationMetadataMetadata struct { + SlackIntegrationMetadata *SlackIntegrationMetadata + JiraIntegrationMetadata *JiraIntegrationMetadata + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// SlackIntegrationMetadataAsIncidentIntegrationMetadataMetadata is a convenience function that returns SlackIntegrationMetadata wrapped in IncidentIntegrationMetadataMetadata. +func SlackIntegrationMetadataAsIncidentIntegrationMetadataMetadata(v *SlackIntegrationMetadata) IncidentIntegrationMetadataMetadata { + return IncidentIntegrationMetadataMetadata{SlackIntegrationMetadata: v} +} + +// JiraIntegrationMetadataAsIncidentIntegrationMetadataMetadata is a convenience function that returns JiraIntegrationMetadata wrapped in IncidentIntegrationMetadataMetadata. +func JiraIntegrationMetadataAsIncidentIntegrationMetadataMetadata(v *JiraIntegrationMetadata) IncidentIntegrationMetadataMetadata { + return IncidentIntegrationMetadataMetadata{JiraIntegrationMetadata: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *IncidentIntegrationMetadataMetadata) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into SlackIntegrationMetadata + err = json.Unmarshal(data, &obj.SlackIntegrationMetadata) + if err == nil { + if obj.SlackIntegrationMetadata != nil && obj.SlackIntegrationMetadata.UnparsedObject == nil { + jsonSlackIntegrationMetadata, _ := json.Marshal(obj.SlackIntegrationMetadata) + if string(jsonSlackIntegrationMetadata) == "{}" { // empty struct + obj.SlackIntegrationMetadata = nil + } else { + match++ + } + } else { + obj.SlackIntegrationMetadata = nil + } + } else { + obj.SlackIntegrationMetadata = nil + } + + // try to unmarshal data into JiraIntegrationMetadata + err = json.Unmarshal(data, &obj.JiraIntegrationMetadata) + if err == nil { + if obj.JiraIntegrationMetadata != nil && obj.JiraIntegrationMetadata.UnparsedObject == nil { + jsonJiraIntegrationMetadata, _ := json.Marshal(obj.JiraIntegrationMetadata) + if string(jsonJiraIntegrationMetadata) == "{}" { // empty struct + obj.JiraIntegrationMetadata = nil + } else { + match++ + } + } else { + obj.JiraIntegrationMetadata = nil + } + } else { + obj.JiraIntegrationMetadata = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.SlackIntegrationMetadata = nil + obj.JiraIntegrationMetadata = nil + return json.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj IncidentIntegrationMetadataMetadata) MarshalJSON() ([]byte, error) { + if obj.SlackIntegrationMetadata != nil { + return json.Marshal(&obj.SlackIntegrationMetadata) + } + + if obj.JiraIntegrationMetadata != nil { + return json.Marshal(&obj.JiraIntegrationMetadata) + } + + if obj.UnparsedObject != nil { + return json.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *IncidentIntegrationMetadataMetadata) GetActualInstance() interface{} { + if obj.SlackIntegrationMetadata != nil { + return obj.SlackIntegrationMetadata + } + + if obj.JiraIntegrationMetadata != nil { + return obj.JiraIntegrationMetadata + } + + // all schemas are nil + return nil +} + +// NullableIncidentIntegrationMetadataMetadata handles when a null is used for IncidentIntegrationMetadataMetadata. +type NullableIncidentIntegrationMetadataMetadata struct { + value *IncidentIntegrationMetadataMetadata + isSet bool +} + +// Get returns the associated value. +func (v NullableIncidentIntegrationMetadataMetadata) Get() *IncidentIntegrationMetadataMetadata { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableIncidentIntegrationMetadataMetadata) Set(val *IncidentIntegrationMetadataMetadata) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableIncidentIntegrationMetadataMetadata) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag/ +func (v *NullableIncidentIntegrationMetadataMetadata) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableIncidentIntegrationMetadataMetadata initializes the struct as if Set has been called. +func NewNullableIncidentIntegrationMetadataMetadata(val *IncidentIntegrationMetadataMetadata) *NullableIncidentIntegrationMetadataMetadata { + return &NullableIncidentIntegrationMetadataMetadata{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableIncidentIntegrationMetadataMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableIncidentIntegrationMetadataMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + + // this object is nullable so check if the payload is null or empty string + if string(src) == "" || string(src) == "{}" { + return nil + } + + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_incident_integration_metadata_patch_data.go b/api/datadogV2/model_incident_integration_metadata_patch_data.go new file mode 100644 index 00000000000..d655f909a82 --- /dev/null +++ b/api/datadogV2/model_incident_integration_metadata_patch_data.go @@ -0,0 +1,153 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// IncidentIntegrationMetadataPatchData Incident integration metadata data for a patch request. +type IncidentIntegrationMetadataPatchData struct { + // Incident integration metadata's attributes for a create request. + Attributes IncidentIntegrationMetadataAttributes `json:"attributes"` + // Integration metadata resource type. + Type IncidentIntegrationMetadataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewIncidentIntegrationMetadataPatchData instantiates a new IncidentIntegrationMetadataPatchData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentIntegrationMetadataPatchData(attributes IncidentIntegrationMetadataAttributes, typeVar IncidentIntegrationMetadataType) *IncidentIntegrationMetadataPatchData { + this := IncidentIntegrationMetadataPatchData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewIncidentIntegrationMetadataPatchDataWithDefaults instantiates a new IncidentIntegrationMetadataPatchData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentIntegrationMetadataPatchDataWithDefaults() *IncidentIntegrationMetadataPatchData { + this := IncidentIntegrationMetadataPatchData{} + var typeVar IncidentIntegrationMetadataType = INCIDENTINTEGRATIONMETADATATYPE_INCIDENT_INTEGRATIONS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *IncidentIntegrationMetadataPatchData) GetAttributes() IncidentIntegrationMetadataAttributes { + if o == nil { + var ret IncidentIntegrationMetadataAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataPatchData) GetAttributesOk() (*IncidentIntegrationMetadataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *IncidentIntegrationMetadataPatchData) SetAttributes(v IncidentIntegrationMetadataAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *IncidentIntegrationMetadataPatchData) GetType() IncidentIntegrationMetadataType { + if o == nil { + var ret IncidentIntegrationMetadataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataPatchData) GetTypeOk() (*IncidentIntegrationMetadataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *IncidentIntegrationMetadataPatchData) SetType(v IncidentIntegrationMetadataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentIntegrationMetadataPatchData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentIntegrationMetadataPatchData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Attributes *IncidentIntegrationMetadataAttributes `json:"attributes"` + Type *IncidentIntegrationMetadataType `json:"type"` + }{} + all := struct { + Attributes IncidentIntegrationMetadataAttributes `json:"attributes"` + Type IncidentIntegrationMetadataType `json:"type"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if required.Type == nil { + return fmt.Errorf("required field type missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_incident_integration_metadata_patch_request.go b/api/datadogV2/model_incident_integration_metadata_patch_request.go new file mode 100644 index 00000000000..9e7f98edd13 --- /dev/null +++ b/api/datadogV2/model_incident_integration_metadata_patch_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// IncidentIntegrationMetadataPatchRequest Patch request for an incident integration metadata. +type IncidentIntegrationMetadataPatchRequest struct { + // Incident integration metadata data for a patch request. + Data IncidentIntegrationMetadataPatchData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewIncidentIntegrationMetadataPatchRequest instantiates a new IncidentIntegrationMetadataPatchRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentIntegrationMetadataPatchRequest(data IncidentIntegrationMetadataPatchData) *IncidentIntegrationMetadataPatchRequest { + this := IncidentIntegrationMetadataPatchRequest{} + this.Data = data + return &this +} + +// NewIncidentIntegrationMetadataPatchRequestWithDefaults instantiates a new IncidentIntegrationMetadataPatchRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentIntegrationMetadataPatchRequestWithDefaults() *IncidentIntegrationMetadataPatchRequest { + this := IncidentIntegrationMetadataPatchRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentIntegrationMetadataPatchRequest) GetData() IncidentIntegrationMetadataPatchData { + if o == nil { + var ret IncidentIntegrationMetadataPatchData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataPatchRequest) GetDataOk() (*IncidentIntegrationMetadataPatchData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentIntegrationMetadataPatchRequest) SetData(v IncidentIntegrationMetadataPatchData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentIntegrationMetadataPatchRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentIntegrationMetadataPatchRequest) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Data *IncidentIntegrationMetadataPatchData `json:"data"` + }{} + all := struct { + Data IncidentIntegrationMetadataPatchData `json:"data"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Data == nil { + return fmt.Errorf("required field data missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + return nil +} diff --git a/api/datadogV2/model_incident_integration_metadata_response.go b/api/datadogV2/model_incident_integration_metadata_response.go new file mode 100644 index 00000000000..27bd0bbd0db --- /dev/null +++ b/api/datadogV2/model_incident_integration_metadata_response.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// IncidentIntegrationMetadataResponse Response with an incident integration metadata. +type IncidentIntegrationMetadataResponse struct { + // Incident integration metadata from a response. + Data IncidentIntegrationMetadataResponseData `json:"data"` + // Included related resources that the user requested. + Included []IncidentIntegrationMetadataResponseIncludedItem `json:"included,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewIncidentIntegrationMetadataResponse instantiates a new IncidentIntegrationMetadataResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentIntegrationMetadataResponse(data IncidentIntegrationMetadataResponseData) *IncidentIntegrationMetadataResponse { + this := IncidentIntegrationMetadataResponse{} + this.Data = data + return &this +} + +// NewIncidentIntegrationMetadataResponseWithDefaults instantiates a new IncidentIntegrationMetadataResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentIntegrationMetadataResponseWithDefaults() *IncidentIntegrationMetadataResponse { + this := IncidentIntegrationMetadataResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentIntegrationMetadataResponse) GetData() IncidentIntegrationMetadataResponseData { + if o == nil { + var ret IncidentIntegrationMetadataResponseData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataResponse) GetDataOk() (*IncidentIntegrationMetadataResponseData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentIntegrationMetadataResponse) SetData(v IncidentIntegrationMetadataResponseData) { + o.Data = v +} + +// GetIncluded returns the Included field value if set, zero value otherwise. +func (o *IncidentIntegrationMetadataResponse) GetIncluded() []IncidentIntegrationMetadataResponseIncludedItem { + if o == nil || o.Included == nil { + var ret []IncidentIntegrationMetadataResponseIncludedItem + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataResponse) GetIncludedOk() (*[]IncidentIntegrationMetadataResponseIncludedItem, bool) { + if o == nil || o.Included == nil { + return nil, false + } + return &o.Included, true +} + +// HasIncluded returns a boolean if a field has been set. +func (o *IncidentIntegrationMetadataResponse) HasIncluded() bool { + return o != nil && o.Included != nil +} + +// SetIncluded gets a reference to the given []IncidentIntegrationMetadataResponseIncludedItem and assigns it to the Included field. +func (o *IncidentIntegrationMetadataResponse) SetIncluded(v []IncidentIntegrationMetadataResponseIncludedItem) { + o.Included = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentIntegrationMetadataResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + if o.Included != nil { + toSerialize["included"] = o.Included + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentIntegrationMetadataResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Data *IncidentIntegrationMetadataResponseData `json:"data"` + }{} + all := struct { + Data IncidentIntegrationMetadataResponseData `json:"data"` + Included []IncidentIntegrationMetadataResponseIncludedItem `json:"included,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Data == nil { + return fmt.Errorf("required field data missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + o.Included = all.Included + return nil +} diff --git a/api/datadogV2/model_incident_integration_metadata_response_data.go b/api/datadogV2/model_incident_integration_metadata_response_data.go new file mode 100644 index 00000000000..c96bd4d7c64 --- /dev/null +++ b/api/datadogV2/model_incident_integration_metadata_response_data.go @@ -0,0 +1,188 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// IncidentIntegrationMetadataResponseData Incident integration metadata from a response. +type IncidentIntegrationMetadataResponseData struct { + // Incident integration metadata's attributes for a create request. + Attributes *IncidentIntegrationMetadataAttributes `json:"attributes,omitempty"` + // The incident integration metadata's ID. + Id string `json:"id"` + // Integration metadata resource type. + Type IncidentIntegrationMetadataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewIncidentIntegrationMetadataResponseData instantiates a new IncidentIntegrationMetadataResponseData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentIntegrationMetadataResponseData(id string, typeVar IncidentIntegrationMetadataType) *IncidentIntegrationMetadataResponseData { + this := IncidentIntegrationMetadataResponseData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewIncidentIntegrationMetadataResponseDataWithDefaults instantiates a new IncidentIntegrationMetadataResponseData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentIntegrationMetadataResponseDataWithDefaults() *IncidentIntegrationMetadataResponseData { + this := IncidentIntegrationMetadataResponseData{} + var typeVar IncidentIntegrationMetadataType = INCIDENTINTEGRATIONMETADATATYPE_INCIDENT_INTEGRATIONS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *IncidentIntegrationMetadataResponseData) GetAttributes() IncidentIntegrationMetadataAttributes { + if o == nil || o.Attributes == nil { + var ret IncidentIntegrationMetadataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataResponseData) GetAttributesOk() (*IncidentIntegrationMetadataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *IncidentIntegrationMetadataResponseData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given IncidentIntegrationMetadataAttributes and assigns it to the Attributes field. +func (o *IncidentIntegrationMetadataResponseData) SetAttributes(v IncidentIntegrationMetadataAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value. +func (o *IncidentIntegrationMetadataResponseData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *IncidentIntegrationMetadataResponseData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *IncidentIntegrationMetadataResponseData) GetType() IncidentIntegrationMetadataType { + if o == nil { + var ret IncidentIntegrationMetadataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *IncidentIntegrationMetadataResponseData) GetTypeOk() (*IncidentIntegrationMetadataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *IncidentIntegrationMetadataResponseData) SetType(v IncidentIntegrationMetadataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentIntegrationMetadataResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentIntegrationMetadataResponseData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Id *string `json:"id"` + Type *IncidentIntegrationMetadataType `json:"type"` + }{} + all := struct { + Attributes *IncidentIntegrationMetadataAttributes `json:"attributes,omitempty"` + Id string `json:"id"` + Type IncidentIntegrationMetadataType `json:"type"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Id == nil { + return fmt.Errorf("required field id missing") + } + if required.Type == nil { + return fmt.Errorf("required field type missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Id = all.Id + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_incident_integration_metadata_response_included_item.go b/api/datadogV2/model_incident_integration_metadata_response_included_item.go new file mode 100644 index 00000000000..c903e352c5c --- /dev/null +++ b/api/datadogV2/model_incident_integration_metadata_response_included_item.go @@ -0,0 +1,123 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// IncidentIntegrationMetadataResponseIncludedItem - An object related to an incident integration metadata that is included in the response. +type IncidentIntegrationMetadataResponseIncludedItem struct { + User *User + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// UserAsIncidentIntegrationMetadataResponseIncludedItem is a convenience function that returns User wrapped in IncidentIntegrationMetadataResponseIncludedItem. +func UserAsIncidentIntegrationMetadataResponseIncludedItem(v *User) IncidentIntegrationMetadataResponseIncludedItem { + return IncidentIntegrationMetadataResponseIncludedItem{User: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *IncidentIntegrationMetadataResponseIncludedItem) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into User + err = json.Unmarshal(data, &obj.User) + if err == nil { + if obj.User != nil && obj.User.UnparsedObject == nil { + jsonUser, _ := json.Marshal(obj.User) + if string(jsonUser) == "{}" { // empty struct + obj.User = nil + } else { + match++ + } + } else { + obj.User = nil + } + } else { + obj.User = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.User = nil + return json.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj IncidentIntegrationMetadataResponseIncludedItem) MarshalJSON() ([]byte, error) { + if obj.User != nil { + return json.Marshal(&obj.User) + } + + if obj.UnparsedObject != nil { + return json.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *IncidentIntegrationMetadataResponseIncludedItem) GetActualInstance() interface{} { + if obj.User != nil { + return obj.User + } + + // all schemas are nil + return nil +} + +// NullableIncidentIntegrationMetadataResponseIncludedItem handles when a null is used for IncidentIntegrationMetadataResponseIncludedItem. +type NullableIncidentIntegrationMetadataResponseIncludedItem struct { + value *IncidentIntegrationMetadataResponseIncludedItem + isSet bool +} + +// Get returns the associated value. +func (v NullableIncidentIntegrationMetadataResponseIncludedItem) Get() *IncidentIntegrationMetadataResponseIncludedItem { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableIncidentIntegrationMetadataResponseIncludedItem) Set(val *IncidentIntegrationMetadataResponseIncludedItem) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableIncidentIntegrationMetadataResponseIncludedItem) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag/ +func (v *NullableIncidentIntegrationMetadataResponseIncludedItem) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableIncidentIntegrationMetadataResponseIncludedItem initializes the struct as if Set has been called. +func NewNullableIncidentIntegrationMetadataResponseIncludedItem(val *IncidentIntegrationMetadataResponseIncludedItem) *NullableIncidentIntegrationMetadataResponseIncludedItem { + return &NullableIncidentIntegrationMetadataResponseIncludedItem{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableIncidentIntegrationMetadataResponseIncludedItem) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableIncidentIntegrationMetadataResponseIncludedItem) UnmarshalJSON(src []byte) error { + v.isSet = true + + // this object is nullable so check if the payload is null or empty string + if string(src) == "" || string(src) == "{}" { + return nil + } + + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_incident_update_data.go b/api/datadogV2/model_incident_update_data.go index 766a11db9f3..d21d79a92b2 100644 --- a/api/datadogV2/model_incident_update_data.go +++ b/api/datadogV2/model_incident_update_data.go @@ -13,7 +13,7 @@ import ( type IncidentUpdateData struct { // The incident's attributes for an update request. Attributes *IncidentUpdateAttributes `json:"attributes,omitempty"` - // The team's ID. + // The incident's ID. Id string `json:"id"` // The incident's relationships for an update request. Relationships *IncidentUpdateRelationships `json:"relationships,omitempty"` diff --git a/api/datadogV2/model_jira_integration_metadata.go b/api/datadogV2/model_jira_integration_metadata.go new file mode 100644 index 00000000000..1f28380eac0 --- /dev/null +++ b/api/datadogV2/model_jira_integration_metadata.go @@ -0,0 +1,103 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// JiraIntegrationMetadata Incident integration metadata for the Jira integration. +type JiraIntegrationMetadata struct { + // Array of Jira issues in this integration metadata. + Issues []JiraIntegrationMetadataIssuesItem `json:"issues"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewJiraIntegrationMetadata instantiates a new JiraIntegrationMetadata object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewJiraIntegrationMetadata(issues []JiraIntegrationMetadataIssuesItem) *JiraIntegrationMetadata { + this := JiraIntegrationMetadata{} + this.Issues = issues + return &this +} + +// NewJiraIntegrationMetadataWithDefaults instantiates a new JiraIntegrationMetadata object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewJiraIntegrationMetadataWithDefaults() *JiraIntegrationMetadata { + this := JiraIntegrationMetadata{} + return &this +} + +// GetIssues returns the Issues field value. +func (o *JiraIntegrationMetadata) GetIssues() []JiraIntegrationMetadataIssuesItem { + if o == nil { + var ret []JiraIntegrationMetadataIssuesItem + return ret + } + return o.Issues +} + +// GetIssuesOk returns a tuple with the Issues field value +// and a boolean to check if the value has been set. +func (o *JiraIntegrationMetadata) GetIssuesOk() (*[]JiraIntegrationMetadataIssuesItem, bool) { + if o == nil { + return nil, false + } + return &o.Issues, true +} + +// SetIssues sets field value. +func (o *JiraIntegrationMetadata) SetIssues(v []JiraIntegrationMetadataIssuesItem) { + o.Issues = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JiraIntegrationMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["issues"] = o.Issues + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JiraIntegrationMetadata) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Issues *[]JiraIntegrationMetadataIssuesItem `json:"issues"` + }{} + all := struct { + Issues []JiraIntegrationMetadataIssuesItem `json:"issues"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Issues == nil { + return fmt.Errorf("required field issues missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Issues = all.Issues + return nil +} diff --git a/api/datadogV2/model_jira_integration_metadata_issues_item.go b/api/datadogV2/model_jira_integration_metadata_issues_item.go new file mode 100644 index 00000000000..60d96757cd4 --- /dev/null +++ b/api/datadogV2/model_jira_integration_metadata_issues_item.go @@ -0,0 +1,241 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// JiraIntegrationMetadataIssuesItem Item in the Jira integration metadata issue array. +type JiraIntegrationMetadataIssuesItem struct { + // URL of issue's Jira account. + Account string `json:"account"` + // Jira issue's issue key. + IssueKey *string `json:"issue_key,omitempty"` + // Jira issue's issue type. + IssuetypeId *string `json:"issuetype_id,omitempty"` + // Jira issue's project keys. + ProjectKey string `json:"project_key"` + // URL redirecting to the Jira issue. + RedirectUrl *string `json:"redirect_url,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewJiraIntegrationMetadataIssuesItem instantiates a new JiraIntegrationMetadataIssuesItem object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewJiraIntegrationMetadataIssuesItem(account string, projectKey string) *JiraIntegrationMetadataIssuesItem { + this := JiraIntegrationMetadataIssuesItem{} + this.Account = account + this.ProjectKey = projectKey + return &this +} + +// NewJiraIntegrationMetadataIssuesItemWithDefaults instantiates a new JiraIntegrationMetadataIssuesItem object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewJiraIntegrationMetadataIssuesItemWithDefaults() *JiraIntegrationMetadataIssuesItem { + this := JiraIntegrationMetadataIssuesItem{} + return &this +} + +// GetAccount returns the Account field value. +func (o *JiraIntegrationMetadataIssuesItem) GetAccount() string { + if o == nil { + var ret string + return ret + } + return o.Account +} + +// GetAccountOk returns a tuple with the Account field value +// and a boolean to check if the value has been set. +func (o *JiraIntegrationMetadataIssuesItem) GetAccountOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Account, true +} + +// SetAccount sets field value. +func (o *JiraIntegrationMetadataIssuesItem) SetAccount(v string) { + o.Account = v +} + +// GetIssueKey returns the IssueKey field value if set, zero value otherwise. +func (o *JiraIntegrationMetadataIssuesItem) GetIssueKey() string { + if o == nil || o.IssueKey == nil { + var ret string + return ret + } + return *o.IssueKey +} + +// GetIssueKeyOk returns a tuple with the IssueKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JiraIntegrationMetadataIssuesItem) GetIssueKeyOk() (*string, bool) { + if o == nil || o.IssueKey == nil { + return nil, false + } + return o.IssueKey, true +} + +// HasIssueKey returns a boolean if a field has been set. +func (o *JiraIntegrationMetadataIssuesItem) HasIssueKey() bool { + return o != nil && o.IssueKey != nil +} + +// SetIssueKey gets a reference to the given string and assigns it to the IssueKey field. +func (o *JiraIntegrationMetadataIssuesItem) SetIssueKey(v string) { + o.IssueKey = &v +} + +// GetIssuetypeId returns the IssuetypeId field value if set, zero value otherwise. +func (o *JiraIntegrationMetadataIssuesItem) GetIssuetypeId() string { + if o == nil || o.IssuetypeId == nil { + var ret string + return ret + } + return *o.IssuetypeId +} + +// GetIssuetypeIdOk returns a tuple with the IssuetypeId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JiraIntegrationMetadataIssuesItem) GetIssuetypeIdOk() (*string, bool) { + if o == nil || o.IssuetypeId == nil { + return nil, false + } + return o.IssuetypeId, true +} + +// HasIssuetypeId returns a boolean if a field has been set. +func (o *JiraIntegrationMetadataIssuesItem) HasIssuetypeId() bool { + return o != nil && o.IssuetypeId != nil +} + +// SetIssuetypeId gets a reference to the given string and assigns it to the IssuetypeId field. +func (o *JiraIntegrationMetadataIssuesItem) SetIssuetypeId(v string) { + o.IssuetypeId = &v +} + +// GetProjectKey returns the ProjectKey field value. +func (o *JiraIntegrationMetadataIssuesItem) GetProjectKey() string { + if o == nil { + var ret string + return ret + } + return o.ProjectKey +} + +// GetProjectKeyOk returns a tuple with the ProjectKey field value +// and a boolean to check if the value has been set. +func (o *JiraIntegrationMetadataIssuesItem) GetProjectKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ProjectKey, true +} + +// SetProjectKey sets field value. +func (o *JiraIntegrationMetadataIssuesItem) SetProjectKey(v string) { + o.ProjectKey = v +} + +// GetRedirectUrl returns the RedirectUrl field value if set, zero value otherwise. +func (o *JiraIntegrationMetadataIssuesItem) GetRedirectUrl() string { + if o == nil || o.RedirectUrl == nil { + var ret string + return ret + } + return *o.RedirectUrl +} + +// GetRedirectUrlOk returns a tuple with the RedirectUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JiraIntegrationMetadataIssuesItem) GetRedirectUrlOk() (*string, bool) { + if o == nil || o.RedirectUrl == nil { + return nil, false + } + return o.RedirectUrl, true +} + +// HasRedirectUrl returns a boolean if a field has been set. +func (o *JiraIntegrationMetadataIssuesItem) HasRedirectUrl() bool { + return o != nil && o.RedirectUrl != nil +} + +// SetRedirectUrl gets a reference to the given string and assigns it to the RedirectUrl field. +func (o *JiraIntegrationMetadataIssuesItem) SetRedirectUrl(v string) { + o.RedirectUrl = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JiraIntegrationMetadataIssuesItem) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["account"] = o.Account + if o.IssueKey != nil { + toSerialize["issue_key"] = o.IssueKey + } + if o.IssuetypeId != nil { + toSerialize["issuetype_id"] = o.IssuetypeId + } + toSerialize["project_key"] = o.ProjectKey + if o.RedirectUrl != nil { + toSerialize["redirect_url"] = o.RedirectUrl + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JiraIntegrationMetadataIssuesItem) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Account *string `json:"account"` + ProjectKey *string `json:"project_key"` + }{} + all := struct { + Account string `json:"account"` + IssueKey *string `json:"issue_key,omitempty"` + IssuetypeId *string `json:"issuetype_id,omitempty"` + ProjectKey string `json:"project_key"` + RedirectUrl *string `json:"redirect_url,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Account == nil { + return fmt.Errorf("required field account missing") + } + if required.ProjectKey == nil { + return fmt.Errorf("required field project_key missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Account = all.Account + o.IssueKey = all.IssueKey + o.IssuetypeId = all.IssuetypeId + o.ProjectKey = all.ProjectKey + o.RedirectUrl = all.RedirectUrl + return nil +} diff --git a/api/datadogV2/model_relationship_to_incident_integration_metadatas.go b/api/datadogV2/model_relationship_to_incident_integration_metadatas.go index c22dc7d7ebd..7b0e46f3ff2 100644 --- a/api/datadogV2/model_relationship_to_incident_integration_metadatas.go +++ b/api/datadogV2/model_relationship_to_incident_integration_metadatas.go @@ -11,7 +11,7 @@ import ( // RelationshipToIncidentIntegrationMetadatas A relationship reference for multiple integration metadata objects. type RelationshipToIncidentIntegrationMetadatas struct { - // The integration metadata relationship array + // Integration metadata relationship array Data []RelationshipToIncidentIntegrationMetadataData `json:"data"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct UnparsedObject map[string]interface{} `json:"-"` diff --git a/api/datadogV2/model_slack_integration_metadata.go b/api/datadogV2/model_slack_integration_metadata.go new file mode 100644 index 00000000000..c0b72687040 --- /dev/null +++ b/api/datadogV2/model_slack_integration_metadata.go @@ -0,0 +1,103 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// SlackIntegrationMetadata Incident integration metadata for the Slack integration. +type SlackIntegrationMetadata struct { + // Array of Slack channels in this integration metadata. + Channels []SlackIntegrationMetadataChannelItem `json:"channels"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewSlackIntegrationMetadata instantiates a new SlackIntegrationMetadata object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSlackIntegrationMetadata(channels []SlackIntegrationMetadataChannelItem) *SlackIntegrationMetadata { + this := SlackIntegrationMetadata{} + this.Channels = channels + return &this +} + +// NewSlackIntegrationMetadataWithDefaults instantiates a new SlackIntegrationMetadata object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewSlackIntegrationMetadataWithDefaults() *SlackIntegrationMetadata { + this := SlackIntegrationMetadata{} + return &this +} + +// GetChannels returns the Channels field value. +func (o *SlackIntegrationMetadata) GetChannels() []SlackIntegrationMetadataChannelItem { + if o == nil { + var ret []SlackIntegrationMetadataChannelItem + return ret + } + return o.Channels +} + +// GetChannelsOk returns a tuple with the Channels field value +// and a boolean to check if the value has been set. +func (o *SlackIntegrationMetadata) GetChannelsOk() (*[]SlackIntegrationMetadataChannelItem, bool) { + if o == nil { + return nil, false + } + return &o.Channels, true +} + +// SetChannels sets field value. +func (o *SlackIntegrationMetadata) SetChannels(v []SlackIntegrationMetadataChannelItem) { + o.Channels = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SlackIntegrationMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["channels"] = o.Channels + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SlackIntegrationMetadata) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Channels *[]SlackIntegrationMetadataChannelItem `json:"channels"` + }{} + all := struct { + Channels []SlackIntegrationMetadataChannelItem `json:"channels"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Channels == nil { + return fmt.Errorf("required field channels missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Channels = all.Channels + return nil +} diff --git a/api/datadogV2/model_slack_integration_metadata_channel_item.go b/api/datadogV2/model_slack_integration_metadata_channel_item.go new file mode 100644 index 00000000000..f7a8a2540c0 --- /dev/null +++ b/api/datadogV2/model_slack_integration_metadata_channel_item.go @@ -0,0 +1,204 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// SlackIntegrationMetadataChannelItem Item in the Slack integration metadata channel array. +type SlackIntegrationMetadataChannelItem struct { + // Slack channel ID. + ChannelId string `json:"channel_id"` + // Name of the Slack channel. + ChannelName string `json:"channel_name"` + // URL redirecting to the Slack channel. + RedirectUrl string `json:"redirect_url"` + // Slack team ID. + TeamId *string `json:"team_id,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewSlackIntegrationMetadataChannelItem instantiates a new SlackIntegrationMetadataChannelItem object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSlackIntegrationMetadataChannelItem(channelId string, channelName string, redirectUrl string) *SlackIntegrationMetadataChannelItem { + this := SlackIntegrationMetadataChannelItem{} + this.ChannelId = channelId + this.ChannelName = channelName + this.RedirectUrl = redirectUrl + return &this +} + +// NewSlackIntegrationMetadataChannelItemWithDefaults instantiates a new SlackIntegrationMetadataChannelItem object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewSlackIntegrationMetadataChannelItemWithDefaults() *SlackIntegrationMetadataChannelItem { + this := SlackIntegrationMetadataChannelItem{} + return &this +} + +// GetChannelId returns the ChannelId field value. +func (o *SlackIntegrationMetadataChannelItem) GetChannelId() string { + if o == nil { + var ret string + return ret + } + return o.ChannelId +} + +// GetChannelIdOk returns a tuple with the ChannelId field value +// and a boolean to check if the value has been set. +func (o *SlackIntegrationMetadataChannelItem) GetChannelIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ChannelId, true +} + +// SetChannelId sets field value. +func (o *SlackIntegrationMetadataChannelItem) SetChannelId(v string) { + o.ChannelId = v +} + +// GetChannelName returns the ChannelName field value. +func (o *SlackIntegrationMetadataChannelItem) GetChannelName() string { + if o == nil { + var ret string + return ret + } + return o.ChannelName +} + +// GetChannelNameOk returns a tuple with the ChannelName field value +// and a boolean to check if the value has been set. +func (o *SlackIntegrationMetadataChannelItem) GetChannelNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ChannelName, true +} + +// SetChannelName sets field value. +func (o *SlackIntegrationMetadataChannelItem) SetChannelName(v string) { + o.ChannelName = v +} + +// GetRedirectUrl returns the RedirectUrl field value. +func (o *SlackIntegrationMetadataChannelItem) GetRedirectUrl() string { + if o == nil { + var ret string + return ret + } + return o.RedirectUrl +} + +// GetRedirectUrlOk returns a tuple with the RedirectUrl field value +// and a boolean to check if the value has been set. +func (o *SlackIntegrationMetadataChannelItem) GetRedirectUrlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RedirectUrl, true +} + +// SetRedirectUrl sets field value. +func (o *SlackIntegrationMetadataChannelItem) SetRedirectUrl(v string) { + o.RedirectUrl = v +} + +// GetTeamId returns the TeamId field value if set, zero value otherwise. +func (o *SlackIntegrationMetadataChannelItem) GetTeamId() string { + if o == nil || o.TeamId == nil { + var ret string + return ret + } + return *o.TeamId +} + +// GetTeamIdOk returns a tuple with the TeamId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SlackIntegrationMetadataChannelItem) GetTeamIdOk() (*string, bool) { + if o == nil || o.TeamId == nil { + return nil, false + } + return o.TeamId, true +} + +// HasTeamId returns a boolean if a field has been set. +func (o *SlackIntegrationMetadataChannelItem) HasTeamId() bool { + return o != nil && o.TeamId != nil +} + +// SetTeamId gets a reference to the given string and assigns it to the TeamId field. +func (o *SlackIntegrationMetadataChannelItem) SetTeamId(v string) { + o.TeamId = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SlackIntegrationMetadataChannelItem) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["channel_id"] = o.ChannelId + toSerialize["channel_name"] = o.ChannelName + toSerialize["redirect_url"] = o.RedirectUrl + if o.TeamId != nil { + toSerialize["team_id"] = o.TeamId + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SlackIntegrationMetadataChannelItem) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + ChannelId *string `json:"channel_id"` + ChannelName *string `json:"channel_name"` + RedirectUrl *string `json:"redirect_url"` + }{} + all := struct { + ChannelId string `json:"channel_id"` + ChannelName string `json:"channel_name"` + RedirectUrl string `json:"redirect_url"` + TeamId *string `json:"team_id,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.ChannelId == nil { + return fmt.Errorf("required field channel_id missing") + } + if required.ChannelName == nil { + return fmt.Errorf("required field channel_name missing") + } + if required.RedirectUrl == nil { + return fmt.Errorf("required field redirect_url missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.ChannelId = all.ChannelId + o.ChannelName = all.ChannelName + o.RedirectUrl = all.RedirectUrl + o.TeamId = all.TeamId + return nil +} diff --git a/examples/v2/incidents/CreateIncidentIntegration.go b/examples/v2/incidents/CreateIncidentIntegration.go new file mode 100644 index 00000000000..03257c14ec2 --- /dev/null +++ b/examples/v2/incidents/CreateIncidentIntegration.go @@ -0,0 +1,53 @@ +// Create an incident integration metadata returns "CREATED" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "incident" in the system + IncidentDataID := os.Getenv("INCIDENT_DATA_ID") + + body := datadogV2.IncidentIntegrationMetadataCreateRequest{ + Data: datadogV2.IncidentIntegrationMetadataCreateData{ + Attributes: datadogV2.IncidentIntegrationMetadataAttributes{ + IncidentId: datadog.PtrString(IncidentDataID), + IntegrationType: 1, + Metadata: datadogV2.IncidentIntegrationMetadataMetadata{ + SlackIntegrationMetadata: &datadogV2.SlackIntegrationMetadata{ + Channels: []datadogV2.SlackIntegrationMetadataChannelItem{ + { + ChannelId: "C0123456789", + ChannelName: "#new-channel", + TeamId: datadog.PtrString("T01234567"), + RedirectUrl: "https://slack.com/app_redirect?channel=C0123456789&team=T01234567", + }, + }, + }}, + }, + Type: datadogV2.INCIDENTINTEGRATIONMETADATATYPE_INCIDENT_INTEGRATIONS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateIncidentIntegration", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.CreateIncidentIntegration(ctx, IncidentDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.CreateIncidentIntegration`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.CreateIncidentIntegration`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/DeleteIncidentIntegration.go b/examples/v2/incidents/DeleteIncidentIntegration.go new file mode 100644 index 00000000000..d570462a919 --- /dev/null +++ b/examples/v2/incidents/DeleteIncidentIntegration.go @@ -0,0 +1,32 @@ +// Delete an incident integration metadata returns "OK" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "incident" in the system + IncidentDataID := os.Getenv("INCIDENT_DATA_ID") + + // the "incident" has an "incident_integration_metadata" + IncidentIntegrationMetadataDataID := os.Getenv("INCIDENT_INTEGRATION_METADATA_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.DeleteIncidentIntegration", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + r, err := api.DeleteIncidentIntegration(ctx, IncidentDataID, IncidentIntegrationMetadataDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.DeleteIncidentIntegration`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/incidents/GetIncidentIntegration.go b/examples/v2/incidents/GetIncidentIntegration.go new file mode 100644 index 00000000000..ff5d79c3c6c --- /dev/null +++ b/examples/v2/incidents/GetIncidentIntegration.go @@ -0,0 +1,36 @@ +// Get incident integration metadata details returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "incident" in the system + IncidentDataID := os.Getenv("INCIDENT_DATA_ID") + + // the "incident" has an "incident_integration_metadata" + IncidentIntegrationMetadataDataID := os.Getenv("INCIDENT_INTEGRATION_METADATA_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetIncidentIntegration", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.GetIncidentIntegration(ctx, IncidentDataID, IncidentIntegrationMetadataDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.GetIncidentIntegration`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.GetIncidentIntegration`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/ListIncidentIntegrations.go b/examples/v2/incidents/ListIncidentIntegrations.go new file mode 100644 index 00000000000..05f7422b8b3 --- /dev/null +++ b/examples/v2/incidents/ListIncidentIntegrations.go @@ -0,0 +1,33 @@ +// Get a list of an incident's integration metadata returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "incident" in the system + IncidentDataID := os.Getenv("INCIDENT_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListIncidentIntegrations", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.ListIncidentIntegrations(ctx, IncidentDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.ListIncidentIntegrations`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.ListIncidentIntegrations`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/UpdateIncidentIntegration.go b/examples/v2/incidents/UpdateIncidentIntegration.go new file mode 100644 index 00000000000..18640264600 --- /dev/null +++ b/examples/v2/incidents/UpdateIncidentIntegration.go @@ -0,0 +1,56 @@ +// Update an existing incident integration metadata returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "incident" in the system + IncidentDataID := os.Getenv("INCIDENT_DATA_ID") + + // the "incident" has an "incident_integration_metadata" + IncidentIntegrationMetadataDataID := os.Getenv("INCIDENT_INTEGRATION_METADATA_DATA_ID") + + body := datadogV2.IncidentIntegrationMetadataPatchRequest{ + Data: datadogV2.IncidentIntegrationMetadataPatchData{ + Attributes: datadogV2.IncidentIntegrationMetadataAttributes{ + IncidentId: datadog.PtrString(IncidentDataID), + IntegrationType: 1, + Metadata: datadogV2.IncidentIntegrationMetadataMetadata{ + SlackIntegrationMetadata: &datadogV2.SlackIntegrationMetadata{ + Channels: []datadogV2.SlackIntegrationMetadataChannelItem{ + { + ChannelId: "C0123456789", + ChannelName: "#updated-channel-name", + TeamId: datadog.PtrString("T01234567"), + RedirectUrl: "https://slack.com/app_redirect?channel=C0123456789&team=T01234567", + }, + }, + }}, + }, + Type: datadogV2.INCIDENTINTEGRATIONMETADATATYPE_INCIDENT_INTEGRATIONS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpdateIncidentIntegration", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.UpdateIncidentIntegration(ctx, IncidentDataID, IncidentIntegrationMetadataDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.UpdateIncidentIntegration`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.UpdateIncidentIntegration`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_an_incident_integration_metadata_returns_CREATED_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_an_incident_integration_metadata_returns_CREATED_response.freeze new file mode 100644 index 00000000000..51810a54c9b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_an_incident_integration_metadata_returns_CREATED_response.freeze @@ -0,0 +1 @@ +2023-03-02T08:30:38.031Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_an_incident_integration_metadata_returns_CREATED_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_an_incident_integration_metadata_returns_CREATED_response.yaml new file mode 100644 index 00000000000..dbfcba2ff1a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_an_incident_integration_metadata_returns_CREATED_response.yaml @@ -0,0 +1,76 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"customer_impacted":false,"title":"Test-Create_an_incident_integration_metadata_returns_CREATED_response-1677745838"},"type":"incidents"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/incidents + response: + body: '{"data":{"type":"incidents","id":"c1c3c52e-a1a6-52b3-9dcd-65d04496033f","attributes":{"public_id":124034,"title":"Test-Create_an_incident_integration_metadata_returns_CREATED_response-1677745838","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":"2023-03-02T08:30:38.468135+00:00","modified":"2023-03-02T08:30:38.468135+00:00","commander":null,"detected":"2023-03-02T08:30:38.458636+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"},"state":{"type":"dropdown","value":"active"},"root_cause":{"type":"textbox","value":null},"detection_method":{"type":"dropdown","value":"unknown"},"services":{"type":"autocomplete","value":null},"teams":{"type":"autocomplete","value":null},"summary":{"type":"textbox","value":null}},"field_analytics":null,"severity":"UNKNOWN","state":"active","non_datadog_creator":null,"visibility":"organization","case_id":null},"relationships":{"created_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},"last_modified_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},"commander_user":{"data":null},"user_defined_fields":{"data":[{"type":"user_defined_field","id":"ad2b9456-eaec-5bbd-9bae-e502d74e23f8"},{"type":"user_defined_field","id":"299616f7-8acd-5403-886b-991656d6b982"},{"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":"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":[]}}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"incident_id":"c1c3c52e-a1a6-52b3-9dcd-65d04496033f","integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#new-channel","redirect_url":"https://slack.com/app_redirect?channel=C0123456789\u0026team=T01234567","team_id":"T01234567"}]}},"type":"incident_integrations"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/incidents/c1c3c52e-a1a6-52b3-9dcd-65d04496033f/relationships/integrations + response: + body: '{"data":{"type":"incident_integrations","id":"b841d498-4840-5388-98af-9f6cc30307f1","attributes":{"created":"2023-03-02T08:30:39.110755+00:00","modified":"2023-03-02T08:30:39.110755+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":"3ad549bf-eba0-11e9-a77a-0705486660d0","incident_id":"c1c3c52e-a1a6-52b3-9dcd-65d04496033f","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":"3ad549bf-eba0-11e9-a77a-0705486660d0","status":3,"integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#new-channel","redirect_url":"https://slack.com/app_redirect?channel=C0123456789&team=T01234567","team_id":"T01234567"}]}},"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"}}}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/c1c3c52e-a1a6-52b3-9dcd-65d04496033f/relationships/integrations/b841d498-4840-5388-98af-9f6cc30307f1 + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/c1c3c52e-a1a6-52b3-9dcd-65d04496033f + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_an_incident_integration_metadata_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_an_incident_integration_metadata_returns_OK_response.freeze new file mode 100644 index 00000000000..56155f272fc --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_an_incident_integration_metadata_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-02-24T19:28:01.343Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_an_incident_integration_metadata_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_an_incident_integration_metadata_returns_OK_response.yaml new file mode 100644 index 00000000000..379a8aa3c99 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_an_incident_integration_metadata_returns_OK_response.yaml @@ -0,0 +1,92 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"customer_impacted":false,"title":"Test-Delete_an_incident_integration_metadata_returns_OK_response-1677266881"},"type":"incidents"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/incidents + response: + body: '{"data":{"type":"incidents","id":"312a9af4-0bed-524e-9243-a9de9492506a","attributes":{"public_id":123329,"title":"Test-Delete_an_incident_integration_metadata_returns_OK_response-1677266881","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":"2023-02-24T19:28:01.563619+00:00","modified":"2023-02-24T19:28:01.563619+00:00","commander":null,"detected":"2023-02-24T19:28:01.554591+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"},"state":{"type":"dropdown","value":"active"},"root_cause":{"type":"textbox","value":null},"detection_method":{"type":"dropdown","value":"unknown"},"services":{"type":"autocomplete","value":null},"teams":{"type":"autocomplete","value":null},"summary":{"type":"textbox","value":null}},"field_analytics":null,"severity":"UNKNOWN","state":"active","non_datadog_creator":null,"visibility":"organization","case_id":null},"relationships":{"created_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},"last_modified_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},"commander_user":{"data":null},"user_defined_fields":{"data":[{"type":"user_defined_field","id":"ad2b9456-eaec-5bbd-9bae-e502d74e23f8"},{"type":"user_defined_field","id":"299616f7-8acd-5403-886b-991656d6b982"},{"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":"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":[]}}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"incident_id":"312a9af4-0bed-524e-9243-a9de9492506a","integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#example-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789\u0026team=T01234567","team_id":"T01234567"}]},"status":2},"type":"incident_integrations"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/incidents/312a9af4-0bed-524e-9243-a9de9492506a/relationships/integrations + response: + body: '{"data":{"type":"incident_integrations","id":"74bd2fb0-e385-5564-85db-7d8de4966f36","attributes":{"created":"2023-02-24T19:28:01.991274+00:00","modified":"2023-02-24T19:28:01.991274+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":"3ad549bf-eba0-11e9-a77a-0705486660d0","incident_id":"312a9af4-0bed-524e-9243-a9de9492506a","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":"3ad549bf-eba0-11e9-a77a-0705486660d0","status":3,"integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#example-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789&team=T01234567","team_id":"T01234567"}]}},"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"}}}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/312a9af4-0bed-524e-9243-a9de9492506a/relationships/integrations/74bd2fb0-e385-5564-85db-7d8de4966f36 + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/312a9af4-0bed-524e-9243-a9de9492506a/relationships/integrations/74bd2fb0-e385-5564-85db-7d8de4966f36 + response: + body: '{"errors":["74bd2fb0-e385-5564-85db-7d8de4966f36 not found"]}' + code: 404 + duration: '' + headers: + Content-Type: + - application/json + status: 404 Not Found +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/312a9af4-0bed-524e-9243-a9de9492506a + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_a_list_of_an_incidents_integration_metadata_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_a_list_of_an_incidents_integration_metadata_returns_OK_response.freeze new file mode 100644 index 00000000000..c443743357a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_a_list_of_an_incidents_integration_metadata_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-02-28T08:31:00.439Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_a_list_of_an_incidents_integration_metadata_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_a_list_of_an_incidents_integration_metadata_returns_OK_response.yaml new file mode 100644 index 00000000000..27398af44be --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_a_list_of_an_incidents_integration_metadata_returns_OK_response.yaml @@ -0,0 +1,94 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"customer_impacted":false,"title":"Test-Get_a_list_of_an_incident_s_integration_metadata_returns_OK_response-1677573060"},"type":"incidents"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/incidents + response: + body: '{"data":{"type":"incidents","id":"ef6f2ac8-25ee-5771-903c-8fbea1b0ff8a","attributes":{"public_id":123751,"title":"Test-Get_a_list_of_an_incident_s_integration_metadata_returns_OK_response-1677573060","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":"2023-02-28T08:31:00.888846+00:00","modified":"2023-02-28T08:31:00.888846+00:00","commander":null,"detected":"2023-02-28T08:31:00.879554+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"},"state":{"type":"dropdown","value":"active"},"root_cause":{"type":"textbox","value":null},"detection_method":{"type":"dropdown","value":"unknown"},"services":{"type":"autocomplete","value":null},"teams":{"type":"autocomplete","value":null},"summary":{"type":"textbox","value":null}},"field_analytics":null,"severity":"UNKNOWN","state":"active","non_datadog_creator":null,"visibility":"organization","case_id":null},"relationships":{"created_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},"last_modified_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},"commander_user":{"data":null},"user_defined_fields":{"data":[{"type":"user_defined_field","id":"ad2b9456-eaec-5bbd-9bae-e502d74e23f8"},{"type":"user_defined_field","id":"299616f7-8acd-5403-886b-991656d6b982"},{"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":"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":[]}}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"incident_id":"ef6f2ac8-25ee-5771-903c-8fbea1b0ff8a","integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#example-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789\u0026team=T01234567","team_id":"T01234567"}]},"status":2},"type":"incident_integrations"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/incidents/ef6f2ac8-25ee-5771-903c-8fbea1b0ff8a/relationships/integrations + response: + body: '{"data":{"type":"incident_integrations","id":"52ba8c74-a1c2-56ef-8c72-8ea578719072","attributes":{"created":"2023-02-28T08:31:01.472130+00:00","modified":"2023-02-28T08:31:01.472130+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":"3ad549bf-eba0-11e9-a77a-0705486660d0","incident_id":"ef6f2ac8-25ee-5771-903c-8fbea1b0ff8a","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":"3ad549bf-eba0-11e9-a77a-0705486660d0","status":3,"integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#example-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789&team=T01234567","team_id":"T01234567"}]}},"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"}}}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/incidents/ef6f2ac8-25ee-5771-903c-8fbea1b0ff8a/relationships/integrations + response: + body: '{"data":[{"type":"incident_integrations","id":"52ba8c74-a1c2-56ef-8c72-8ea578719072","attributes":{"created":"2023-02-28T08:31:01.472130+00:00","modified":"2023-02-28T08:31:01.472130+00:00","created_by_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","incident_id":"ef6f2ac8-25ee-5771-903c-8fbea1b0ff8a","last_modified_by_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","status":3,"integration_type":1,"metadata":{"channels":[{"team_id":"T01234567","channel_id":"C0123456789","channel_name":"#example-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789&team=T01234567"}]}},"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"}}}}],"meta":{"pagination":{"offset":0,"next_offset":1,"size":1}}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/ef6f2ac8-25ee-5771-903c-8fbea1b0ff8a/relationships/integrations/52ba8c74-a1c2-56ef-8c72-8ea578719072 + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/ef6f2ac8-25ee-5771-903c-8fbea1b0ff8a + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_incident_integration_metadata_details_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_incident_integration_metadata_details_returns_OK_response.freeze new file mode 100644 index 00000000000..5f7c73fad68 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_incident_integration_metadata_details_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-02-24T19:28:03.052Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_incident_integration_metadata_details_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_incident_integration_metadata_details_returns_OK_response.yaml new file mode 100644 index 00000000000..a462e47ae9b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_incident_integration_metadata_details_returns_OK_response.yaml @@ -0,0 +1,94 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"customer_impacted":false,"title":"Test-Get_incident_integration_metadata_details_returns_OK_response-1677266883"},"type":"incidents"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/incidents + response: + body: '{"data":{"type":"incidents","id":"57400630-f287-5c30-8cb8-0ecabb3d44b9","attributes":{"public_id":123330,"title":"Test-Get_incident_integration_metadata_details_returns_OK_response-1677266883","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":"2023-02-24T19:28:03.236100+00:00","modified":"2023-02-24T19:28:03.236100+00:00","commander":null,"detected":"2023-02-24T19:28:03.228113+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"},"state":{"type":"dropdown","value":"active"},"root_cause":{"type":"textbox","value":null},"detection_method":{"type":"dropdown","value":"unknown"},"services":{"type":"autocomplete","value":null},"teams":{"type":"autocomplete","value":null},"summary":{"type":"textbox","value":null}},"field_analytics":null,"severity":"UNKNOWN","state":"active","non_datadog_creator":null,"visibility":"organization","case_id":null},"relationships":{"created_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},"last_modified_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},"commander_user":{"data":null},"user_defined_fields":{"data":[{"type":"user_defined_field","id":"ad2b9456-eaec-5bbd-9bae-e502d74e23f8"},{"type":"user_defined_field","id":"299616f7-8acd-5403-886b-991656d6b982"},{"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":"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":[]}}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"incident_id":"57400630-f287-5c30-8cb8-0ecabb3d44b9","integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#example-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789\u0026team=T01234567","team_id":"T01234567"}]},"status":2},"type":"incident_integrations"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/incidents/57400630-f287-5c30-8cb8-0ecabb3d44b9/relationships/integrations + response: + body: '{"data":{"type":"incident_integrations","id":"6e654fe0-d3db-56c9-937c-861a9f9ce19e","attributes":{"created":"2023-02-24T19:28:03.731346+00:00","modified":"2023-02-24T19:28:03.731346+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":"3ad549bf-eba0-11e9-a77a-0705486660d0","incident_id":"57400630-f287-5c30-8cb8-0ecabb3d44b9","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":"3ad549bf-eba0-11e9-a77a-0705486660d0","status":3,"integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#example-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789&team=T01234567","team_id":"T01234567"}]}},"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"}}}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/incidents/57400630-f287-5c30-8cb8-0ecabb3d44b9/relationships/integrations/6e654fe0-d3db-56c9-937c-861a9f9ce19e + response: + body: '{"data":{"type":"incident_integrations","id":"6e654fe0-d3db-56c9-937c-861a9f9ce19e","attributes":{"created":"2023-02-24T19:28:03.731346+00:00","modified":"2023-02-24T19:28:03.731346+00:00","created_by_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","incident_id":"57400630-f287-5c30-8cb8-0ecabb3d44b9","last_modified_by_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","status":3,"integration_type":1,"metadata":{"channels":[{"team_id":"T01234567","channel_id":"C0123456789","channel_name":"#example-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789&team=T01234567"}]}},"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"}}}}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/57400630-f287-5c30-8cb8-0ecabb3d44b9/relationships/integrations/6e654fe0-d3db-56c9-937c-861a9f9ce19e + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/57400630-f287-5c30-8cb8-0ecabb3d44b9 + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_an_existing_incident_integration_metadata_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_an_existing_incident_integration_metadata_returns_OK_response.freeze new file mode 100644 index 00000000000..b5b717cfa76 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_an_existing_incident_integration_metadata_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-03-02T08:30:18.771Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_an_existing_incident_integration_metadata_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_an_existing_incident_integration_metadata_returns_OK_response.yaml new file mode 100644 index 00000000000..71db3384dc5 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_an_existing_incident_integration_metadata_returns_OK_response.yaml @@ -0,0 +1,97 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"customer_impacted":false,"title":"Test-Update_an_existing_incident_integration_metadata_returns_OK_response-1677745818"},"type":"incidents"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/incidents + response: + body: '{"data":{"type":"incidents","id":"3291404a-284f-5ef5-b012-16aa4bcbb677","attributes":{"public_id":124033,"title":"Test-Update_an_existing_incident_integration_metadata_returns_OK_response-1677745818","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":"2023-03-02T08:30:19.354738+00:00","modified":"2023-03-02T08:30:19.354738+00:00","commander":null,"detected":"2023-03-02T08:30:19.344778+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"},"state":{"type":"dropdown","value":"active"},"root_cause":{"type":"textbox","value":null},"detection_method":{"type":"dropdown","value":"unknown"},"services":{"type":"autocomplete","value":null},"teams":{"type":"autocomplete","value":null},"summary":{"type":"textbox","value":null}},"field_analytics":null,"severity":"UNKNOWN","state":"active","non_datadog_creator":null,"visibility":"organization","case_id":null},"relationships":{"created_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},"last_modified_by_user":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},"commander_user":{"data":null},"user_defined_fields":{"data":[{"type":"user_defined_field","id":"ad2b9456-eaec-5bbd-9bae-e502d74e23f8"},{"type":"user_defined_field","id":"299616f7-8acd-5403-886b-991656d6b982"},{"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":"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":[]}}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"incident_id":"3291404a-284f-5ef5-b012-16aa4bcbb677","integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#example-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789\u0026team=T01234567","team_id":"T01234567"}]},"status":2},"type":"incident_integrations"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/incidents/3291404a-284f-5ef5-b012-16aa4bcbb677/relationships/integrations + response: + body: '{"data":{"type":"incident_integrations","id":"7c127cf5-9381-5a41-a83d-4b0190c8cd6a","attributes":{"created":"2023-03-02T08:30:20.051847+00:00","modified":"2023-03-02T08:30:20.051847+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":"3ad549bf-eba0-11e9-a77a-0705486660d0","incident_id":"3291404a-284f-5ef5-b012-16aa4bcbb677","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":"3ad549bf-eba0-11e9-a77a-0705486660d0","status":3,"integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#example-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789&team=T01234567","team_id":"T01234567"}]}},"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"}}}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"incident_id":"3291404a-284f-5ef5-b012-16aa4bcbb677","integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#updated-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789\u0026team=T01234567","team_id":"T01234567"}]}},"type":"incident_integrations"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: PATCH + url: https://api.datadoghq.com/api/v2/incidents/3291404a-284f-5ef5-b012-16aa4bcbb677/relationships/integrations/7c127cf5-9381-5a41-a83d-4b0190c8cd6a + response: + body: '{"data":{"type":"incident_integrations","id":"7c127cf5-9381-5a41-a83d-4b0190c8cd6a","attributes":{"created":"2023-03-02T08:30:20.051847+00:00","modified":"2023-03-02T08:30:20.597056+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":"3ad549bf-eba0-11e9-a77a-0705486660d0","incident_id":"3291404a-284f-5ef5-b012-16aa4bcbb677","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":"3ad549bf-eba0-11e9-a77a-0705486660d0","status":4,"integration_type":1,"metadata":{"channels":[{"channel_id":"C0123456789","channel_name":"#updated-channel-name","redirect_url":"https://slack.com/app_redirect?channel=C0123456789&team=T01234567","team_id":"T01234567"}]}},"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"}}}}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/3291404a-284f-5ef5-b012-16aa4bcbb677/relationships/integrations/7c127cf5-9381-5a41-a83d-4b0190c8cd6a + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/3291404a-284f-5ef5-b012-16aa4bcbb677 + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index a1507110282..17620e9575e 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -95,6 +95,22 @@ "tag": "Incidents", "operationId": "UpdateIncidentAttachments" }, + { + "parameters": [ + { + "name": "incident_id", + "source": "incident.data.id" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"integration_type\": 1,\n \"incident_id\": \"{{ incident.data.id }}\",\n \"status\": 2,\n \"metadata\": {\n \"channels\": [\n {\n \"channel_id\": \"C0123456789\",\n \"team_id\": \"T01234567\",\n \"channel_name\": \"#example-channel-name\",\n \"redirect_url\": \"https://slack.com/app_redirect?channel=C0123456789&team=T01234567\"\n }\n ]\n }\n },\n \"type\": \"incident_integrations\"\n }\n}" + } + ], + "step": "the \"incident\" has an \"incident_integration_metadata\"", + "key": "incident_integration_metadata", + "tag": "Incidents", + "operationId": "CreateIncidentIntegration" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/incidents.feature b/tests/scenarios/features/v2/incidents.feature index 1b8b2ea8993..5146d464318 100644 --- a/tests/scenarios/features/v2/incidents.feature +++ b/tests/scenarios/features/v2/incidents.feature @@ -32,6 +32,37 @@ Feature: Incidents And the response "data[0].attributes.attachment_type" is equal to "link" And the response "data[0].attributes.attachment.documentUrl" is equal to "https://www.example.com/doc" + @generated @skip @team:DataDog/incident-app + Scenario: Create an incident integration metadata returns "Bad Request" response + Given operation "CreateIncidentIntegration" enabled + And new "CreateIncidentIntegration" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"incident_id": "00000000-aaaa-0000-0000-000000000000", "integration_type": 1, "metadata": {"channels": []}}, "type": "incident_integrations"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/incident-app + Scenario: Create an incident integration metadata returns "CREATED" response + Given operation "CreateIncidentIntegration" enabled + And new "CreateIncidentIntegration" request + And there is a valid "incident" in the system + And request contains "incident_id" parameter from "incident.data.id" + And body with value {"data": {"attributes": {"incident_id": "{{ incident.data.id }}", "integration_type": 1, "metadata": {"channels": [{"channel_id": "C0123456789", "channel_name": "#new-channel", "team_id": "T01234567", "redirect_url": "https://slack.com/app_redirect?channel=C0123456789&team=T01234567"}]}}, "type": "incident_integrations"}} + When the request is sent + Then the response status is 201 CREATED + And the response "data.type" is equal to "incident_integrations" + And the response "data.attributes.metadata.channels" has length 1 + And the response "data.attributes.metadata.channels[0].channel_name" is equal to "#new-channel" + + @generated @skip @team:DataDog/incident-app + Scenario: Create an incident integration metadata returns "Not Found" response + Given operation "CreateIncidentIntegration" enabled + And new "CreateIncidentIntegration" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"incident_id": "00000000-aaaa-0000-0000-000000000000", "integration_type": 1, "metadata": {"channels": []}}, "type": "incident_integrations"}} + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app Scenario: Create an incident returns "Bad Request" response Given operation "CreateIncident" enabled @@ -111,6 +142,62 @@ Feature: Incidents When the request is sent Then the response status is 204 OK + @generated @skip @team:DataDog/incident-app + Scenario: Delete an incident integration metadata returns "Bad Request" response + Given operation "DeleteIncidentIntegration" enabled + And new "DeleteIncidentIntegration" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "integration_metadata_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Delete an incident integration metadata returns "Not Found" response + Given operation "DeleteIncidentIntegration" enabled + And new "DeleteIncidentIntegration" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "integration_metadata_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/incident-app + Scenario: Delete an incident integration metadata returns "OK" response + Given operation "DeleteIncidentIntegration" enabled + And new "DeleteIncidentIntegration" request + And there is a valid "incident" in the system + And request contains "incident_id" parameter from "incident.data.id" + And the "incident" has an "incident_integration_metadata" + And request contains "integration_metadata_id" parameter from "incident_integration_metadata.data.id" + When the request is sent + Then the response status is 204 OK + + @generated @skip @team:DataDog/incident-app + Scenario: Get a list of an incident's integration metadata returns "Bad Request" response + Given operation "ListIncidentIntegrations" enabled + And new "ListIncidentIntegrations" 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 an incident's integration metadata returns "Not Found" response + Given operation "ListIncidentIntegrations" enabled + And new "ListIncidentIntegrations" request + And request contains "incident_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/incident-app + Scenario: Get a list of an incident's integration metadata returns "OK" response + Given operation "ListIncidentIntegrations" enabled + And new "ListIncidentIntegrations" request + And there is a valid "incident" in the system + And request contains "incident_id" parameter from "incident.data.id" + And the "incident" has an "incident_integration_metadata" + When the request is sent + Then the response status is 200 OK + And the response "data[0].attributes.metadata.channels[0].channel_name" is equal to "#example-channel-name" + @generated @skip @team:DataDog/incident-app Scenario: Get a list of attachments returns "Bad Request" response Given operation "ListIncidentAttachments" enabled @@ -181,6 +268,35 @@ Feature: Incidents And the response "data[0].attributes.attachment_type" is equal to "link" And the response "data[0].attributes.attachment.documentUrl" is equal to "https://www.example.com/doc" + @generated @skip @team:DataDog/incident-app + Scenario: Get incident integration metadata details returns "Bad Request" response + Given operation "GetIncidentIntegration" enabled + And new "GetIncidentIntegration" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "integration_metadata_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 incident integration metadata details returns "Not Found" response + Given operation "GetIncidentIntegration" enabled + And new "GetIncidentIntegration" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "integration_metadata_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/incident-app + Scenario: Get incident integration metadata details returns "OK" response + Given operation "GetIncidentIntegration" enabled + And new "GetIncidentIntegration" request + And there is a valid "incident" in the system + And request contains "incident_id" parameter from "incident.data.id" + And the "incident" has an "incident_integration_metadata" + And request contains "integration_metadata_id" parameter from "incident_integration_metadata.data.id" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app Scenario: Get the details of an incident returns "Bad Request" response Given operation "GetIncident" enabled @@ -245,6 +361,39 @@ Feature: Incidents And the response "data.type" is equal to "incidents_search_results" And the response "data.attributes.incidents[0].data.type" is equal to "incidents" + @generated @skip @team:DataDog/incident-app + Scenario: Update an existing incident integration metadata returns "Bad Request" response + Given operation "UpdateIncidentIntegration" enabled + And new "UpdateIncidentIntegration" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "integration_metadata_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"incident_id": "00000000-aaaa-0000-0000-000000000000", "integration_type": 1, "metadata": {"channels": []}}, "type": "incident_integrations"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Update an existing incident integration metadata returns "Not Found" response + Given operation "UpdateIncidentIntegration" enabled + And new "UpdateIncidentIntegration" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "integration_metadata_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"incident_id": "00000000-aaaa-0000-0000-000000000000", "integration_type": 1, "metadata": {"channels": []}}, "type": "incident_integrations"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/incident-app + Scenario: Update an existing incident integration metadata returns "OK" response + Given operation "UpdateIncidentIntegration" enabled + And new "UpdateIncidentIntegration" request + And there is a valid "incident" in the system + And request contains "incident_id" parameter from "incident.data.id" + And the "incident" has an "incident_integration_metadata" + And request contains "integration_metadata_id" parameter from "incident_integration_metadata.data.id" + And body with value {"data": {"attributes": {"incident_id": "{{ incident.data.id }}", "integration_type": 1, "metadata": {"channels": [{"channel_id": "C0123456789", "channel_name": "#updated-channel-name", "team_id": "T01234567", "redirect_url": "https://slack.com/app_redirect?channel=C0123456789&team=T01234567"}]}}, "type": "incident_integrations"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.metadata.channels[0].channel_name" is equal to "#updated-channel-name" + @generated @skip @team:DataDog/incident-app Scenario: Update an existing incident returns "Bad Request" response Given operation "UpdateIncident" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index e4a5021518d..2ae185f7f21 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -273,6 +273,47 @@ "type": "idempotent" } }, + "ListIncidentIntegrations": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "CreateIncidentIntegration": { + "tag": "Incidents", + "undo": { + "operationId": "DeleteIncidentIntegration", + "parameters": [ + { + "name": "incident_id", + "source": "data.attributes.incident_id" + }, + { + "name": "integration_metadata_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteIncidentIntegration": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "GetIncidentIntegration": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "UpdateIncidentIntegration": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, "ListOpsgenieServices": { "tag": "Opsgenie Integration", "undo": {