diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index e301432aca7..181237b18fc 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -29490,6 +29490,27 @@ components: x-enum-varnames: - USERS - ATTACHMENTS + IncidentRelationshipData: + description: Incident relationship data + properties: + id: + description: Incident identifier + example: 00000000-0000-0000-0000-000000000000 + type: string + type: + $ref: '#/components/schemas/IncidentResourceType' + required: + - type + - id + type: object + IncidentResourceType: + description: Incident resource type + enum: + - incidents + example: incidents + type: string + x-enum-varnames: + - INCIDENTS IncidentRespondersType: description: The incident responders type. enum: @@ -32389,6 +32410,87 @@ components: $ref: '#/components/schemas/Case3rdPartyTicketStatus' readOnly: true type: object + JiraIssueCreateAttributes: + description: Jira issue creation attributes + properties: + fields: + additionalProperties: {} + description: Additional Jira fields + example: {} + type: object + issue_type_id: + description: Jira issue type ID + example: '10001' + type: string + jira_account_id: + description: Jira account ID + example: '1234' + type: string + project_id: + description: Jira project ID + example: '5678' + type: string + required: + - jira_account_id + - project_id + - issue_type_id + type: object + JiraIssueCreateData: + description: Jira issue creation data + properties: + attributes: + $ref: '#/components/schemas/JiraIssueCreateAttributes' + type: + $ref: '#/components/schemas/JiraIssueResourceType' + required: + - type + - attributes + type: object + JiraIssueCreateRequest: + description: Jira issue creation request + properties: + data: + $ref: '#/components/schemas/JiraIssueCreateData' + required: + - data + type: object + JiraIssueLinkAttributes: + description: Jira issue link attributes + properties: + jira_issue_url: + description: URL of the Jira issue + example: https://jira.example.com/browse/PROJ-123 + type: string + required: + - jira_issue_url + type: object + JiraIssueLinkData: + description: Jira issue link data + properties: + attributes: + $ref: '#/components/schemas/JiraIssueLinkAttributes' + type: + $ref: '#/components/schemas/JiraIssueResourceType' + required: + - type + - attributes + type: object + JiraIssueLinkRequest: + description: Jira issue link request + properties: + data: + $ref: '#/components/schemas/JiraIssueLinkData' + required: + - data + type: object + JiraIssueResourceType: + description: Jira issue resource type + enum: + - issues + example: issues + type: string + x-enum-varnames: + - ISSUES JiraIssueResult: description: Jira issue information properties: @@ -37818,6 +37920,30 @@ components: meta: $ref: '#/components/schemas/MonthlyCostAttributionMeta' type: object + NotebookCreateData: + description: Notebook creation data + properties: + type: + $ref: '#/components/schemas/NotebookResourceType' + required: + - type + type: object + NotebookCreateRequest: + description: Notebook creation request + properties: + data: + $ref: '#/components/schemas/NotebookCreateData' + required: + - data + type: object + NotebookResourceType: + description: Notebook resource type + enum: + - notebook + example: notebook + type: string + x-enum-varnames: + - NOTEBOOK NotebookTriggerWrapper: description: Schema for a Notebook-based trigger. properties: @@ -47880,6 +48006,14 @@ components: - id - type type: object + RelationshipToIncidentRequest: + description: Relationship to incident request + properties: + data: + $ref: '#/components/schemas/IncidentRelationshipData' + required: + - data + type: object RelationshipToIncidentResponderData: description: Relationship to impact object. properties: @@ -58088,6 +58222,47 @@ components: $ref: '#/components/schemas/Case3rdPartyTicketStatus' readOnly: true type: object + ServiceNowTicketCreateAttributes: + description: ServiceNow ticket creation attributes + properties: + assignment_group: + description: ServiceNow assignment group + example: IT Support + type: string + instance_name: + description: ServiceNow instance name + example: my-instance + type: string + required: + - instance_name + type: object + ServiceNowTicketCreateData: + description: ServiceNow ticket creation data + properties: + attributes: + $ref: '#/components/schemas/ServiceNowTicketCreateAttributes' + type: + $ref: '#/components/schemas/ServiceNowTicketResourceType' + required: + - type + - attributes + type: object + ServiceNowTicketCreateRequest: + description: ServiceNow ticket creation request + properties: + data: + $ref: '#/components/schemas/ServiceNowTicketCreateData' + required: + - data + type: object + ServiceNowTicketResourceType: + description: ServiceNow ticket resource type + enum: + - tickets + example: tickets + type: string + x-enum-varnames: + - TICKETS ServiceNowTicketResult: description: ServiceNow ticket information properties: @@ -72542,6 +72717,382 @@ paths: summary: Update case priority tags: - Case Management + /api/v2/cases/{case_id}/relationships/incidents: + post: + description: Link an incident to a case + operationId: LinkIncident + parameters: + - $ref: '#/components/parameters/CaseIDPathParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RelationshipToIncidentRequest' + description: Incident link request + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/CaseResponse' + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cases_write + summary: Link incident to case + tags: + - Case Management + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/cases/{case_id}/relationships/jira_issues: + delete: + description: Remove the link between a Jira issue and a case + operationId: UnlinkJiraIssue + parameters: + - $ref: '#/components/parameters/CaseIDPathParameter' + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cases_write + summary: Remove Jira issue link from case + tags: + - Case Management + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: Link an existing Jira issue to a case + operationId: LinkJiraIssueToCase + parameters: + - $ref: '#/components/parameters/CaseIDPathParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/JiraIssueLinkRequest' + description: Jira issue link request + required: true + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '409': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Conflict + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cases_write + summary: Link existing Jira issue to case + tags: + - Case Management + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create a new Jira issue and link it to a case + operationId: CreateCaseJiraIssue + parameters: + - $ref: '#/components/parameters/CaseIDPathParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/JiraIssueCreateRequest' + description: Jira issue creation request + required: true + responses: + '202': + description: Accepted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cases_write + summary: Create Jira issue for case + tags: + - Case Management + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/cases/{case_id}/relationships/notebook: + post: + description: Create a new investigation notebook and link it to a case + operationId: CreateCaseNotebook + parameters: + - $ref: '#/components/parameters/CaseIDPathParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/NotebookCreateRequest' + description: Notebook creation request + required: true + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cases_write + summary: Create investigation notebook for case + tags: + - Case Management + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/cases/{case_id}/relationships/project: + patch: + description: Update the project associated with a case + operationId: MoveCaseToProject + parameters: + - $ref: '#/components/parameters/CaseIDPathParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectRelationship' + description: Project update request + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CaseResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cases_write + summary: Update case project + tags: + - Case Management + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/cases/{case_id}/relationships/servicenow_tickets: + post: + description: Create a new ServiceNow incident ticket and link it to a case + operationId: CreateCaseServiceNowTicket + parameters: + - $ref: '#/components/parameters/CaseIDPathParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowTicketCreateRequest' + description: ServiceNow ticket creation request + required: true + responses: + '202': + description: Accepted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cases_write + summary: Create ServiceNow ticket for case + tags: + - Case Management + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/cases/{case_id}/status: post: description: Update case status diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 6e36cfe4464..fcfbdfb3b9b 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -672,6 +672,13 @@ func NewConfiguration() *Configuration { "v2.GetOpenAPI": false, "v2.ListAPIs": false, "v2.UpdateOpenAPI": false, + "v2.CreateCaseJiraIssue": false, + "v2.CreateCaseNotebook": false, + "v2.CreateCaseServiceNowTicket": false, + "v2.LinkIncident": false, + "v2.LinkJiraIssueToCase": false, + "v2.MoveCaseToProject": false, + "v2.UnlinkJiraIssue": false, "v2.ActivateContentPack": false, "v2.CancelThreatHuntingJob": false, "v2.ConvertJobResultToSignal": false, diff --git a/api/datadogV2/api_case_management.go b/api/datadogV2/api_case_management.go index be1224fe85c..e0edd89f805 100644 --- a/api/datadogV2/api_case_management.go +++ b/api/datadogV2/api_case_management.go @@ -6,6 +6,8 @@ package datadogV2 import ( _context "context" + _fmt "fmt" + _log "log" _nethttp "net/http" _neturl "net/url" @@ -338,6 +340,273 @@ func (a *CaseManagementApi) CreateCase(ctx _context.Context, body CaseCreateRequ return localVarReturnValue, localVarHTTPResponse, nil } +// CreateCaseJiraIssue Create Jira issue for case. +// Create a new Jira issue and link it to a case +func (a *CaseManagementApi) CreateCaseJiraIssue(ctx _context.Context, caseId string, body JiraIssueCreateRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + ) + + operationId := "v2.CreateCaseJiraIssue" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CaseManagementApi.CreateCaseJiraIssue") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/cases/{case_id}/relationships/jira_issues" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{case_id}", _neturl.PathEscape(datadog.ParameterToString(caseId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if 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 +} + +// CreateCaseNotebook Create investigation notebook for case. +// Create a new investigation notebook and link it to a case +func (a *CaseManagementApi) CreateCaseNotebook(ctx _context.Context, caseId string, body NotebookCreateRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + ) + + operationId := "v2.CreateCaseNotebook" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CaseManagementApi.CreateCaseNotebook") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/cases/{case_id}/relationships/notebook" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{case_id}", _neturl.PathEscape(datadog.ParameterToString(caseId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if 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 +} + +// CreateCaseServiceNowTicket Create ServiceNow ticket for case. +// Create a new ServiceNow incident ticket and link it to a case +func (a *CaseManagementApi) CreateCaseServiceNowTicket(ctx _context.Context, caseId string, body ServiceNowTicketCreateRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + ) + + operationId := "v2.CreateCaseServiceNowTicket" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CaseManagementApi.CreateCaseServiceNowTicket") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/cases/{case_id}/relationships/servicenow_tickets" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{case_id}", _neturl.PathEscape(datadog.ParameterToString(caseId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if 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 +} + // CreateProject Create a project. // Create a project. func (a *CaseManagementApi) CreateProject(ctx _context.Context, body ProjectCreateRequest) (ProjectResponse, *_nethttp.Response, error) { @@ -1095,36 +1364,323 @@ func (a *CaseManagementApi) GetProjects(ctx _context.Context) (ProjectsResponse, return localVarReturnValue, localVarHTTPResponse, nil } -// SearchCasesOptionalParameters holds optional parameters for SearchCases. -type SearchCasesOptionalParameters struct { - PageSize *int64 - PageNumber *int64 - SortField *CaseSortableField - Filter *string - SortAsc *bool -} +// LinkIncident Link incident to case. +// Link an incident to a case +func (a *CaseManagementApi) LinkIncident(ctx _context.Context, caseId string, body RelationshipToIncidentRequest) (CaseResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue CaseResponse + ) -// NewSearchCasesOptionalParameters creates an empty struct for parameters. -func NewSearchCasesOptionalParameters() *SearchCasesOptionalParameters { - this := SearchCasesOptionalParameters{} - return &this -} + operationId := "v2.LinkIncident" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } -// WithPageSize sets the corresponding parameter name and returns the struct. -func (r *SearchCasesOptionalParameters) WithPageSize(pageSize int64) *SearchCasesOptionalParameters { - r.PageSize = &pageSize - return r -} + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CaseManagementApi.LinkIncident") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } -// WithPageNumber sets the corresponding parameter name and returns the struct. -func (r *SearchCasesOptionalParameters) WithPageNumber(pageNumber int64) *SearchCasesOptionalParameters { - r.PageNumber = &pageNumber - return r -} + localVarPath := localBasePath + "/api/v2/cases/{case_id}/relationships/incidents" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{case_id}", _neturl.PathEscape(datadog.ParameterToString(caseId, ""))) -// WithSortField sets the corresponding parameter name and returns the struct. -func (r *SearchCasesOptionalParameters) WithSortField(sortField CaseSortableField) *SearchCasesOptionalParameters { - r.SortField = &sortField + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 { + var v JSONAPIErrorResponse + 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 + } + if 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 +} + +// LinkJiraIssueToCase Link existing Jira issue to case. +// Link an existing Jira issue to a case +func (a *CaseManagementApi) LinkJiraIssueToCase(ctx _context.Context, caseId string, body JiraIssueLinkRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + ) + + operationId := "v2.LinkJiraIssueToCase" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CaseManagementApi.LinkJiraIssueToCase") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/cases/{case_id}/relationships/jira_issues" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{case_id}", _neturl.PathEscape(datadog.ParameterToString(caseId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 == 409 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if 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 +} + +// MoveCaseToProject Update case project. +// Update the project associated with a case +func (a *CaseManagementApi) MoveCaseToProject(ctx _context.Context, caseId string, body ProjectRelationship) (CaseResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue CaseResponse + ) + + operationId := "v2.MoveCaseToProject" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CaseManagementApi.MoveCaseToProject") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/cases/{case_id}/relationships/project" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{case_id}", _neturl.PathEscape(datadog.ParameterToString(caseId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 { + var v JSONAPIErrorResponse + 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 + } + if 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 +} + +// SearchCasesOptionalParameters holds optional parameters for SearchCases. +type SearchCasesOptionalParameters struct { + PageSize *int64 + PageNumber *int64 + SortField *CaseSortableField + Filter *string + SortAsc *bool +} + +// NewSearchCasesOptionalParameters creates an empty struct for parameters. +func NewSearchCasesOptionalParameters() *SearchCasesOptionalParameters { + this := SearchCasesOptionalParameters{} + return &this +} + +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *SearchCasesOptionalParameters) WithPageSize(pageSize int64) *SearchCasesOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageNumber sets the corresponding parameter name and returns the struct. +func (r *SearchCasesOptionalParameters) WithPageNumber(pageNumber int64) *SearchCasesOptionalParameters { + r.PageNumber = &pageNumber + return r +} + +// WithSortField sets the corresponding parameter name and returns the struct. +func (r *SearchCasesOptionalParameters) WithSortField(sortField CaseSortableField) *SearchCasesOptionalParameters { + r.SortField = &sortField return r } @@ -1450,6 +2006,92 @@ func (a *CaseManagementApi) UnassignCase(ctx _context.Context, caseId string, bo return localVarReturnValue, localVarHTTPResponse, nil } +// UnlinkJiraIssue Remove Jira issue link from case. +// Remove the link between a Jira issue and a case +func (a *CaseManagementApi) UnlinkJiraIssue(ctx _context.Context, caseId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.UnlinkJiraIssue" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CaseManagementApi.UnlinkJiraIssue") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/cases/{case_id}/relationships/jira_issues" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{case_id}", _neturl.PathEscape(datadog.ParameterToString(caseId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if 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 +} + // UpdateAttributes Update case attributes. // Update case attributes func (a *CaseManagementApi) UpdateAttributes(ctx _context.Context, caseId string, body CaseUpdateAttributesRequest) (CaseResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 20575dc737a..067088af561 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -123,6 +123,9 @@ // - [CaseManagementApi.AssignCase] // - [CaseManagementApi.CommentCase] // - [CaseManagementApi.CreateCase] +// - [CaseManagementApi.CreateCaseJiraIssue] +// - [CaseManagementApi.CreateCaseNotebook] +// - [CaseManagementApi.CreateCaseServiceNowTicket] // - [CaseManagementApi.CreateProject] // - [CaseManagementApi.CreateProjectNotificationRule] // - [CaseManagementApi.DeleteCaseComment] @@ -133,9 +136,13 @@ // - [CaseManagementApi.GetProject] // - [CaseManagementApi.GetProjectNotificationRules] // - [CaseManagementApi.GetProjects] +// - [CaseManagementApi.LinkIncident] +// - [CaseManagementApi.LinkJiraIssueToCase] +// - [CaseManagementApi.MoveCaseToProject] // - [CaseManagementApi.SearchCases] // - [CaseManagementApi.UnarchiveCase] // - [CaseManagementApi.UnassignCase] +// - [CaseManagementApi.UnlinkJiraIssue] // - [CaseManagementApi.UpdateAttributes] // - [CaseManagementApi.UpdateCaseCustomAttribute] // - [CaseManagementApi.UpdateCaseDescription] diff --git a/api/datadogV2/model_incident_relationship_data.go b/api/datadogV2/model_incident_relationship_data.go new file mode 100644 index 00000000000..6a7d376d2cb --- /dev/null +++ b/api/datadogV2/model_incident_relationship_data.go @@ -0,0 +1,143 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentRelationshipData Incident relationship data +type IncidentRelationshipData struct { + // Incident identifier + Id string `json:"id"` + // Incident resource type + Type IncidentResourceType `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{} `json:"-"` +} + +// NewIncidentRelationshipData instantiates a new IncidentRelationshipData 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 NewIncidentRelationshipData(id string, typeVar IncidentResourceType) *IncidentRelationshipData { + this := IncidentRelationshipData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewIncidentRelationshipDataWithDefaults instantiates a new IncidentRelationshipData 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 NewIncidentRelationshipDataWithDefaults() *IncidentRelationshipData { + this := IncidentRelationshipData{} + return &this +} + +// GetId returns the Id field value. +func (o *IncidentRelationshipData) 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 *IncidentRelationshipData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *IncidentRelationshipData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *IncidentRelationshipData) GetType() IncidentResourceType { + if o == nil { + var ret IncidentResourceType + 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 *IncidentRelationshipData) GetTypeOk() (*IncidentResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *IncidentRelationshipData) SetType(v IncidentResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentRelationshipData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentRelationshipData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *IncidentResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_resource_type.go b/api/datadogV2/model_incident_resource_type.go new file mode 100644 index 00000000000..ae65615ff1a --- /dev/null +++ b/api/datadogV2/model_incident_resource_type.go @@ -0,0 +1,64 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentResourceType Incident resource type +type IncidentResourceType string + +// List of IncidentResourceType. +const ( + INCIDENTRESOURCETYPE_INCIDENTS IncidentResourceType = "incidents" +) + +var allowedIncidentResourceTypeEnumValues = []IncidentResourceType{ + INCIDENTRESOURCETYPE_INCIDENTS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *IncidentResourceType) GetAllowedValues() []IncidentResourceType { + return allowedIncidentResourceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *IncidentResourceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = IncidentResourceType(value) + return nil +} + +// NewIncidentResourceTypeFromValue returns a pointer to a valid IncidentResourceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewIncidentResourceTypeFromValue(v string) (*IncidentResourceType, error) { + ev := IncidentResourceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for IncidentResourceType: valid values are %v", v, allowedIncidentResourceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v IncidentResourceType) IsValid() bool { + for _, existing := range allowedIncidentResourceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to IncidentResourceType value. +func (v IncidentResourceType) Ptr() *IncidentResourceType { + return &v +} diff --git a/api/datadogV2/model_jira_issue_create_attributes.go b/api/datadogV2/model_jira_issue_create_attributes.go new file mode 100644 index 00000000000..bad20c805f6 --- /dev/null +++ b/api/datadogV2/model_jira_issue_create_attributes.go @@ -0,0 +1,200 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JiraIssueCreateAttributes Jira issue creation attributes +type JiraIssueCreateAttributes struct { + // Additional Jira fields + Fields map[string]interface{} `json:"fields,omitempty"` + // Jira issue type ID + IssueTypeId string `json:"issue_type_id"` + // Jira account ID + JiraAccountId string `json:"jira_account_id"` + // Jira project ID + ProjectId string `json:"project_id"` + // 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{} `json:"-"` +} + +// NewJiraIssueCreateAttributes instantiates a new JiraIssueCreateAttributes 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 NewJiraIssueCreateAttributes(issueTypeId string, jiraAccountId string, projectId string) *JiraIssueCreateAttributes { + this := JiraIssueCreateAttributes{} + this.IssueTypeId = issueTypeId + this.JiraAccountId = jiraAccountId + this.ProjectId = projectId + return &this +} + +// NewJiraIssueCreateAttributesWithDefaults instantiates a new JiraIssueCreateAttributes 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 NewJiraIssueCreateAttributesWithDefaults() *JiraIssueCreateAttributes { + this := JiraIssueCreateAttributes{} + return &this +} + +// GetFields returns the Fields field value if set, zero value otherwise. +func (o *JiraIssueCreateAttributes) GetFields() map[string]interface{} { + if o == nil || o.Fields == nil { + var ret map[string]interface{} + return ret + } + return o.Fields +} + +// GetFieldsOk returns a tuple with the Fields field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JiraIssueCreateAttributes) GetFieldsOk() (*map[string]interface{}, bool) { + if o == nil || o.Fields == nil { + return nil, false + } + return &o.Fields, true +} + +// HasFields returns a boolean if a field has been set. +func (o *JiraIssueCreateAttributes) HasFields() bool { + return o != nil && o.Fields != nil +} + +// SetFields gets a reference to the given map[string]interface{} and assigns it to the Fields field. +func (o *JiraIssueCreateAttributes) SetFields(v map[string]interface{}) { + o.Fields = v +} + +// GetIssueTypeId returns the IssueTypeId field value. +func (o *JiraIssueCreateAttributes) GetIssueTypeId() string { + if o == nil { + var ret string + return ret + } + return o.IssueTypeId +} + +// GetIssueTypeIdOk returns a tuple with the IssueTypeId field value +// and a boolean to check if the value has been set. +func (o *JiraIssueCreateAttributes) GetIssueTypeIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.IssueTypeId, true +} + +// SetIssueTypeId sets field value. +func (o *JiraIssueCreateAttributes) SetIssueTypeId(v string) { + o.IssueTypeId = v +} + +// GetJiraAccountId returns the JiraAccountId field value. +func (o *JiraIssueCreateAttributes) GetJiraAccountId() string { + if o == nil { + var ret string + return ret + } + return o.JiraAccountId +} + +// GetJiraAccountIdOk returns a tuple with the JiraAccountId field value +// and a boolean to check if the value has been set. +func (o *JiraIssueCreateAttributes) GetJiraAccountIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.JiraAccountId, true +} + +// SetJiraAccountId sets field value. +func (o *JiraIssueCreateAttributes) SetJiraAccountId(v string) { + o.JiraAccountId = v +} + +// GetProjectId returns the ProjectId field value. +func (o *JiraIssueCreateAttributes) GetProjectId() string { + if o == nil { + var ret string + return ret + } + return o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value +// and a boolean to check if the value has been set. +func (o *JiraIssueCreateAttributes) GetProjectIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ProjectId, true +} + +// SetProjectId sets field value. +func (o *JiraIssueCreateAttributes) SetProjectId(v string) { + o.ProjectId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JiraIssueCreateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Fields != nil { + toSerialize["fields"] = o.Fields + } + toSerialize["issue_type_id"] = o.IssueTypeId + toSerialize["jira_account_id"] = o.JiraAccountId + toSerialize["project_id"] = o.ProjectId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JiraIssueCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Fields map[string]interface{} `json:"fields,omitempty"` + IssueTypeId *string `json:"issue_type_id"` + JiraAccountId *string `json:"jira_account_id"` + ProjectId *string `json:"project_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.IssueTypeId == nil { + return fmt.Errorf("required field issue_type_id missing") + } + if all.JiraAccountId == nil { + return fmt.Errorf("required field jira_account_id missing") + } + if all.ProjectId == nil { + return fmt.Errorf("required field project_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"fields", "issue_type_id", "jira_account_id", "project_id"}) + } else { + return err + } + o.Fields = all.Fields + o.IssueTypeId = *all.IssueTypeId + o.JiraAccountId = *all.JiraAccountId + o.ProjectId = *all.ProjectId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_jira_issue_create_data.go b/api/datadogV2/model_jira_issue_create_data.go new file mode 100644 index 00000000000..ede2d44b7a5 --- /dev/null +++ b/api/datadogV2/model_jira_issue_create_data.go @@ -0,0 +1,146 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JiraIssueCreateData Jira issue creation data +type JiraIssueCreateData struct { + // Jira issue creation attributes + Attributes JiraIssueCreateAttributes `json:"attributes"` + // Jira issue resource type + Type JiraIssueResourceType `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{} `json:"-"` +} + +// NewJiraIssueCreateData instantiates a new JiraIssueCreateData 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 NewJiraIssueCreateData(attributes JiraIssueCreateAttributes, typeVar JiraIssueResourceType) *JiraIssueCreateData { + this := JiraIssueCreateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewJiraIssueCreateDataWithDefaults instantiates a new JiraIssueCreateData 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 NewJiraIssueCreateDataWithDefaults() *JiraIssueCreateData { + this := JiraIssueCreateData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *JiraIssueCreateData) GetAttributes() JiraIssueCreateAttributes { + if o == nil { + var ret JiraIssueCreateAttributes + 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 *JiraIssueCreateData) GetAttributesOk() (*JiraIssueCreateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *JiraIssueCreateData) SetAttributes(v JiraIssueCreateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *JiraIssueCreateData) GetType() JiraIssueResourceType { + if o == nil { + var ret JiraIssueResourceType + 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 *JiraIssueCreateData) GetTypeOk() (*JiraIssueResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *JiraIssueCreateData) SetType(v JiraIssueResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JiraIssueCreateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JiraIssueCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *JiraIssueCreateAttributes `json:"attributes"` + Type *JiraIssueResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_jira_issue_create_request.go b/api/datadogV2/model_jira_issue_create_request.go new file mode 100644 index 00000000000..ac07bce074a --- /dev/null +++ b/api/datadogV2/model_jira_issue_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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JiraIssueCreateRequest Jira issue creation request +type JiraIssueCreateRequest struct { + // Jira issue creation data + Data JiraIssueCreateData `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{} `json:"-"` +} + +// NewJiraIssueCreateRequest instantiates a new JiraIssueCreateRequest 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 NewJiraIssueCreateRequest(data JiraIssueCreateData) *JiraIssueCreateRequest { + this := JiraIssueCreateRequest{} + this.Data = data + return &this +} + +// NewJiraIssueCreateRequestWithDefaults instantiates a new JiraIssueCreateRequest 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 NewJiraIssueCreateRequestWithDefaults() *JiraIssueCreateRequest { + this := JiraIssueCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *JiraIssueCreateRequest) GetData() JiraIssueCreateData { + if o == nil { + var ret JiraIssueCreateData + 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 *JiraIssueCreateRequest) GetDataOk() (*JiraIssueCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *JiraIssueCreateRequest) SetData(v JiraIssueCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JiraIssueCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JiraIssueCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *JiraIssueCreateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_jira_issue_link_attributes.go b/api/datadogV2/model_jira_issue_link_attributes.go new file mode 100644 index 00000000000..7500b1d5725 --- /dev/null +++ b/api/datadogV2/model_jira_issue_link_attributes.go @@ -0,0 +1,101 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JiraIssueLinkAttributes Jira issue link attributes +type JiraIssueLinkAttributes struct { + // URL of the Jira issue + JiraIssueUrl string `json:"jira_issue_url"` + // 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{} `json:"-"` +} + +// NewJiraIssueLinkAttributes instantiates a new JiraIssueLinkAttributes 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 NewJiraIssueLinkAttributes(jiraIssueUrl string) *JiraIssueLinkAttributes { + this := JiraIssueLinkAttributes{} + this.JiraIssueUrl = jiraIssueUrl + return &this +} + +// NewJiraIssueLinkAttributesWithDefaults instantiates a new JiraIssueLinkAttributes 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 NewJiraIssueLinkAttributesWithDefaults() *JiraIssueLinkAttributes { + this := JiraIssueLinkAttributes{} + return &this +} + +// GetJiraIssueUrl returns the JiraIssueUrl field value. +func (o *JiraIssueLinkAttributes) GetJiraIssueUrl() string { + if o == nil { + var ret string + return ret + } + return o.JiraIssueUrl +} + +// GetJiraIssueUrlOk returns a tuple with the JiraIssueUrl field value +// and a boolean to check if the value has been set. +func (o *JiraIssueLinkAttributes) GetJiraIssueUrlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.JiraIssueUrl, true +} + +// SetJiraIssueUrl sets field value. +func (o *JiraIssueLinkAttributes) SetJiraIssueUrl(v string) { + o.JiraIssueUrl = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JiraIssueLinkAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["jira_issue_url"] = o.JiraIssueUrl + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JiraIssueLinkAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + JiraIssueUrl *string `json:"jira_issue_url"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.JiraIssueUrl == nil { + return fmt.Errorf("required field jira_issue_url missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"jira_issue_url"}) + } else { + return err + } + o.JiraIssueUrl = *all.JiraIssueUrl + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_jira_issue_link_data.go b/api/datadogV2/model_jira_issue_link_data.go new file mode 100644 index 00000000000..49ecca2fc73 --- /dev/null +++ b/api/datadogV2/model_jira_issue_link_data.go @@ -0,0 +1,146 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JiraIssueLinkData Jira issue link data +type JiraIssueLinkData struct { + // Jira issue link attributes + Attributes JiraIssueLinkAttributes `json:"attributes"` + // Jira issue resource type + Type JiraIssueResourceType `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{} `json:"-"` +} + +// NewJiraIssueLinkData instantiates a new JiraIssueLinkData 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 NewJiraIssueLinkData(attributes JiraIssueLinkAttributes, typeVar JiraIssueResourceType) *JiraIssueLinkData { + this := JiraIssueLinkData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewJiraIssueLinkDataWithDefaults instantiates a new JiraIssueLinkData 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 NewJiraIssueLinkDataWithDefaults() *JiraIssueLinkData { + this := JiraIssueLinkData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *JiraIssueLinkData) GetAttributes() JiraIssueLinkAttributes { + if o == nil { + var ret JiraIssueLinkAttributes + 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 *JiraIssueLinkData) GetAttributesOk() (*JiraIssueLinkAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *JiraIssueLinkData) SetAttributes(v JiraIssueLinkAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *JiraIssueLinkData) GetType() JiraIssueResourceType { + if o == nil { + var ret JiraIssueResourceType + 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 *JiraIssueLinkData) GetTypeOk() (*JiraIssueResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *JiraIssueLinkData) SetType(v JiraIssueResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JiraIssueLinkData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JiraIssueLinkData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *JiraIssueLinkAttributes `json:"attributes"` + Type *JiraIssueResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_jira_issue_link_request.go b/api/datadogV2/model_jira_issue_link_request.go new file mode 100644 index 00000000000..bd32d68ecb7 --- /dev/null +++ b/api/datadogV2/model_jira_issue_link_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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JiraIssueLinkRequest Jira issue link request +type JiraIssueLinkRequest struct { + // Jira issue link data + Data JiraIssueLinkData `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{} `json:"-"` +} + +// NewJiraIssueLinkRequest instantiates a new JiraIssueLinkRequest 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 NewJiraIssueLinkRequest(data JiraIssueLinkData) *JiraIssueLinkRequest { + this := JiraIssueLinkRequest{} + this.Data = data + return &this +} + +// NewJiraIssueLinkRequestWithDefaults instantiates a new JiraIssueLinkRequest 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 NewJiraIssueLinkRequestWithDefaults() *JiraIssueLinkRequest { + this := JiraIssueLinkRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *JiraIssueLinkRequest) GetData() JiraIssueLinkData { + if o == nil { + var ret JiraIssueLinkData + 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 *JiraIssueLinkRequest) GetDataOk() (*JiraIssueLinkData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *JiraIssueLinkRequest) SetData(v JiraIssueLinkData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JiraIssueLinkRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JiraIssueLinkRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *JiraIssueLinkData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_jira_issue_resource_type.go b/api/datadogV2/model_jira_issue_resource_type.go new file mode 100644 index 00000000000..a3337da30d6 --- /dev/null +++ b/api/datadogV2/model_jira_issue_resource_type.go @@ -0,0 +1,64 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JiraIssueResourceType Jira issue resource type +type JiraIssueResourceType string + +// List of JiraIssueResourceType. +const ( + JIRAISSUERESOURCETYPE_ISSUES JiraIssueResourceType = "issues" +) + +var allowedJiraIssueResourceTypeEnumValues = []JiraIssueResourceType{ + JIRAISSUERESOURCETYPE_ISSUES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *JiraIssueResourceType) GetAllowedValues() []JiraIssueResourceType { + return allowedJiraIssueResourceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *JiraIssueResourceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = JiraIssueResourceType(value) + return nil +} + +// NewJiraIssueResourceTypeFromValue returns a pointer to a valid JiraIssueResourceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewJiraIssueResourceTypeFromValue(v string) (*JiraIssueResourceType, error) { + ev := JiraIssueResourceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for JiraIssueResourceType: valid values are %v", v, allowedJiraIssueResourceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v JiraIssueResourceType) IsValid() bool { + for _, existing := range allowedJiraIssueResourceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to JiraIssueResourceType value. +func (v JiraIssueResourceType) Ptr() *JiraIssueResourceType { + return &v +} diff --git a/api/datadogV2/model_notebook_create_data.go b/api/datadogV2/model_notebook_create_data.go new file mode 100644 index 00000000000..9e17b093277 --- /dev/null +++ b/api/datadogV2/model_notebook_create_data.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// NotebookCreateData Notebook creation data +type NotebookCreateData struct { + // Notebook resource type + Type NotebookResourceType `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{} `json:"-"` +} + +// NewNotebookCreateData instantiates a new NotebookCreateData 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 NewNotebookCreateData(typeVar NotebookResourceType) *NotebookCreateData { + this := NotebookCreateData{} + this.Type = typeVar + return &this +} + +// NewNotebookCreateDataWithDefaults instantiates a new NotebookCreateData 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 NewNotebookCreateDataWithDefaults() *NotebookCreateData { + this := NotebookCreateData{} + return &this +} + +// GetType returns the Type field value. +func (o *NotebookCreateData) GetType() NotebookResourceType { + if o == nil { + var ret NotebookResourceType + 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 *NotebookCreateData) GetTypeOk() (*NotebookResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *NotebookCreateData) SetType(v NotebookResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o NotebookCreateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *NotebookCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Type *NotebookResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"type"}) + } else { + return err + } + + hasInvalidField := false + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_notebook_create_request.go b/api/datadogV2/model_notebook_create_request.go new file mode 100644 index 00000000000..19ffeb217a9 --- /dev/null +++ b/api/datadogV2/model_notebook_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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// NotebookCreateRequest Notebook creation request +type NotebookCreateRequest struct { + // Notebook creation data + Data NotebookCreateData `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{} `json:"-"` +} + +// NewNotebookCreateRequest instantiates a new NotebookCreateRequest 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 NewNotebookCreateRequest(data NotebookCreateData) *NotebookCreateRequest { + this := NotebookCreateRequest{} + this.Data = data + return &this +} + +// NewNotebookCreateRequestWithDefaults instantiates a new NotebookCreateRequest 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 NewNotebookCreateRequestWithDefaults() *NotebookCreateRequest { + this := NotebookCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *NotebookCreateRequest) GetData() NotebookCreateData { + if o == nil { + var ret NotebookCreateData + 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 *NotebookCreateRequest) GetDataOk() (*NotebookCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *NotebookCreateRequest) SetData(v NotebookCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o NotebookCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *NotebookCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *NotebookCreateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_notebook_resource_type.go b/api/datadogV2/model_notebook_resource_type.go new file mode 100644 index 00000000000..0f8f93deac9 --- /dev/null +++ b/api/datadogV2/model_notebook_resource_type.go @@ -0,0 +1,64 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// NotebookResourceType Notebook resource type +type NotebookResourceType string + +// List of NotebookResourceType. +const ( + NOTEBOOKRESOURCETYPE_NOTEBOOK NotebookResourceType = "notebook" +) + +var allowedNotebookResourceTypeEnumValues = []NotebookResourceType{ + NOTEBOOKRESOURCETYPE_NOTEBOOK, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *NotebookResourceType) GetAllowedValues() []NotebookResourceType { + return allowedNotebookResourceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *NotebookResourceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = NotebookResourceType(value) + return nil +} + +// NewNotebookResourceTypeFromValue returns a pointer to a valid NotebookResourceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewNotebookResourceTypeFromValue(v string) (*NotebookResourceType, error) { + ev := NotebookResourceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for NotebookResourceType: valid values are %v", v, allowedNotebookResourceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v NotebookResourceType) IsValid() bool { + for _, existing := range allowedNotebookResourceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to NotebookResourceType value. +func (v NotebookResourceType) Ptr() *NotebookResourceType { + return &v +} diff --git a/api/datadogV2/model_relationship_to_incident_request.go b/api/datadogV2/model_relationship_to_incident_request.go new file mode 100644 index 00000000000..0cca52c09e0 --- /dev/null +++ b/api/datadogV2/model_relationship_to_incident_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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RelationshipToIncidentRequest Relationship to incident request +type RelationshipToIncidentRequest struct { + // Incident relationship data + Data IncidentRelationshipData `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{} `json:"-"` +} + +// NewRelationshipToIncidentRequest instantiates a new RelationshipToIncidentRequest 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 NewRelationshipToIncidentRequest(data IncidentRelationshipData) *RelationshipToIncidentRequest { + this := RelationshipToIncidentRequest{} + this.Data = data + return &this +} + +// NewRelationshipToIncidentRequestWithDefaults instantiates a new RelationshipToIncidentRequest 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 NewRelationshipToIncidentRequestWithDefaults() *RelationshipToIncidentRequest { + this := RelationshipToIncidentRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *RelationshipToIncidentRequest) GetData() IncidentRelationshipData { + if o == nil { + var ret IncidentRelationshipData + 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 *RelationshipToIncidentRequest) GetDataOk() (*IncidentRelationshipData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *RelationshipToIncidentRequest) SetData(v IncidentRelationshipData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RelationshipToIncidentRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RelationshipToIncidentRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *IncidentRelationshipData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_service_now_ticket_create_attributes.go b/api/datadogV2/model_service_now_ticket_create_attributes.go new file mode 100644 index 00000000000..78d7cb6bb78 --- /dev/null +++ b/api/datadogV2/model_service_now_ticket_create_attributes.go @@ -0,0 +1,136 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ServiceNowTicketCreateAttributes ServiceNow ticket creation attributes +type ServiceNowTicketCreateAttributes struct { + // ServiceNow assignment group + AssignmentGroup *string `json:"assignment_group,omitempty"` + // ServiceNow instance name + InstanceName string `json:"instance_name"` + // 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{} `json:"-"` +} + +// NewServiceNowTicketCreateAttributes instantiates a new ServiceNowTicketCreateAttributes 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 NewServiceNowTicketCreateAttributes(instanceName string) *ServiceNowTicketCreateAttributes { + this := ServiceNowTicketCreateAttributes{} + this.InstanceName = instanceName + return &this +} + +// NewServiceNowTicketCreateAttributesWithDefaults instantiates a new ServiceNowTicketCreateAttributes 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 NewServiceNowTicketCreateAttributesWithDefaults() *ServiceNowTicketCreateAttributes { + this := ServiceNowTicketCreateAttributes{} + return &this +} + +// GetAssignmentGroup returns the AssignmentGroup field value if set, zero value otherwise. +func (o *ServiceNowTicketCreateAttributes) GetAssignmentGroup() string { + if o == nil || o.AssignmentGroup == nil { + var ret string + return ret + } + return *o.AssignmentGroup +} + +// GetAssignmentGroupOk returns a tuple with the AssignmentGroup field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTicketCreateAttributes) GetAssignmentGroupOk() (*string, bool) { + if o == nil || o.AssignmentGroup == nil { + return nil, false + } + return o.AssignmentGroup, true +} + +// HasAssignmentGroup returns a boolean if a field has been set. +func (o *ServiceNowTicketCreateAttributes) HasAssignmentGroup() bool { + return o != nil && o.AssignmentGroup != nil +} + +// SetAssignmentGroup gets a reference to the given string and assigns it to the AssignmentGroup field. +func (o *ServiceNowTicketCreateAttributes) SetAssignmentGroup(v string) { + o.AssignmentGroup = &v +} + +// GetInstanceName returns the InstanceName field value. +func (o *ServiceNowTicketCreateAttributes) GetInstanceName() string { + if o == nil { + var ret string + return ret + } + return o.InstanceName +} + +// GetInstanceNameOk returns a tuple with the InstanceName field value +// and a boolean to check if the value has been set. +func (o *ServiceNowTicketCreateAttributes) GetInstanceNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.InstanceName, true +} + +// SetInstanceName sets field value. +func (o *ServiceNowTicketCreateAttributes) SetInstanceName(v string) { + o.InstanceName = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTicketCreateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AssignmentGroup != nil { + toSerialize["assignment_group"] = o.AssignmentGroup + } + toSerialize["instance_name"] = o.InstanceName + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceNowTicketCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AssignmentGroup *string `json:"assignment_group,omitempty"` + InstanceName *string `json:"instance_name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.InstanceName == nil { + return fmt.Errorf("required field instance_name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"assignment_group", "instance_name"}) + } else { + return err + } + o.AssignmentGroup = all.AssignmentGroup + o.InstanceName = *all.InstanceName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_service_now_ticket_create_data.go b/api/datadogV2/model_service_now_ticket_create_data.go new file mode 100644 index 00000000000..943556f3a7e --- /dev/null +++ b/api/datadogV2/model_service_now_ticket_create_data.go @@ -0,0 +1,146 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ServiceNowTicketCreateData ServiceNow ticket creation data +type ServiceNowTicketCreateData struct { + // ServiceNow ticket creation attributes + Attributes ServiceNowTicketCreateAttributes `json:"attributes"` + // ServiceNow ticket resource type + Type ServiceNowTicketResourceType `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{} `json:"-"` +} + +// NewServiceNowTicketCreateData instantiates a new ServiceNowTicketCreateData 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 NewServiceNowTicketCreateData(attributes ServiceNowTicketCreateAttributes, typeVar ServiceNowTicketResourceType) *ServiceNowTicketCreateData { + this := ServiceNowTicketCreateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewServiceNowTicketCreateDataWithDefaults instantiates a new ServiceNowTicketCreateData 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 NewServiceNowTicketCreateDataWithDefaults() *ServiceNowTicketCreateData { + this := ServiceNowTicketCreateData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ServiceNowTicketCreateData) GetAttributes() ServiceNowTicketCreateAttributes { + if o == nil { + var ret ServiceNowTicketCreateAttributes + 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 *ServiceNowTicketCreateData) GetAttributesOk() (*ServiceNowTicketCreateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ServiceNowTicketCreateData) SetAttributes(v ServiceNowTicketCreateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ServiceNowTicketCreateData) GetType() ServiceNowTicketResourceType { + if o == nil { + var ret ServiceNowTicketResourceType + 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 *ServiceNowTicketCreateData) GetTypeOk() (*ServiceNowTicketResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ServiceNowTicketCreateData) SetType(v ServiceNowTicketResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTicketCreateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceNowTicketCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ServiceNowTicketCreateAttributes `json:"attributes"` + Type *ServiceNowTicketResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_service_now_ticket_create_request.go b/api/datadogV2/model_service_now_ticket_create_request.go new file mode 100644 index 00000000000..c9b89cb2d06 --- /dev/null +++ b/api/datadogV2/model_service_now_ticket_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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ServiceNowTicketCreateRequest ServiceNow ticket creation request +type ServiceNowTicketCreateRequest struct { + // ServiceNow ticket creation data + Data ServiceNowTicketCreateData `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{} `json:"-"` +} + +// NewServiceNowTicketCreateRequest instantiates a new ServiceNowTicketCreateRequest 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 NewServiceNowTicketCreateRequest(data ServiceNowTicketCreateData) *ServiceNowTicketCreateRequest { + this := ServiceNowTicketCreateRequest{} + this.Data = data + return &this +} + +// NewServiceNowTicketCreateRequestWithDefaults instantiates a new ServiceNowTicketCreateRequest 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 NewServiceNowTicketCreateRequestWithDefaults() *ServiceNowTicketCreateRequest { + this := ServiceNowTicketCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ServiceNowTicketCreateRequest) GetData() ServiceNowTicketCreateData { + if o == nil { + var ret ServiceNowTicketCreateData + 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 *ServiceNowTicketCreateRequest) GetDataOk() (*ServiceNowTicketCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ServiceNowTicketCreateRequest) SetData(v ServiceNowTicketCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTicketCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceNowTicketCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ServiceNowTicketCreateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_service_now_ticket_resource_type.go b/api/datadogV2/model_service_now_ticket_resource_type.go new file mode 100644 index 00000000000..703543c0784 --- /dev/null +++ b/api/datadogV2/model_service_now_ticket_resource_type.go @@ -0,0 +1,64 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ServiceNowTicketResourceType ServiceNow ticket resource type +type ServiceNowTicketResourceType string + +// List of ServiceNowTicketResourceType. +const ( + SERVICENOWTICKETRESOURCETYPE_TICKETS ServiceNowTicketResourceType = "tickets" +) + +var allowedServiceNowTicketResourceTypeEnumValues = []ServiceNowTicketResourceType{ + SERVICENOWTICKETRESOURCETYPE_TICKETS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ServiceNowTicketResourceType) GetAllowedValues() []ServiceNowTicketResourceType { + return allowedServiceNowTicketResourceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ServiceNowTicketResourceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ServiceNowTicketResourceType(value) + return nil +} + +// NewServiceNowTicketResourceTypeFromValue returns a pointer to a valid ServiceNowTicketResourceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewServiceNowTicketResourceTypeFromValue(v string) (*ServiceNowTicketResourceType, error) { + ev := ServiceNowTicketResourceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ServiceNowTicketResourceType: valid values are %v", v, allowedServiceNowTicketResourceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ServiceNowTicketResourceType) IsValid() bool { + for _, existing := range allowedServiceNowTicketResourceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ServiceNowTicketResourceType value. +func (v ServiceNowTicketResourceType) Ptr() *ServiceNowTicketResourceType { + return &v +} diff --git a/examples/v2/case-management/CreateCaseJiraIssue.go b/examples/v2/case-management/CreateCaseJiraIssue.go new file mode 100644 index 00000000000..c3d6afed297 --- /dev/null +++ b/examples/v2/case-management/CreateCaseJiraIssue.go @@ -0,0 +1,37 @@ +// Create Jira issue for case returns "Accepted" 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() { + body := datadogV2.JiraIssueCreateRequest{ + Data: datadogV2.JiraIssueCreateData{ + Attributes: datadogV2.JiraIssueCreateAttributes{ + Fields: map[string]interface{}{}, + IssueTypeId: "10001", + JiraAccountId: "1234", + ProjectId: "5678", + }, + Type: datadogV2.JIRAISSUERESOURCETYPE_ISSUES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateCaseJiraIssue", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCaseManagementApi(apiClient) + r, err := api.CreateCaseJiraIssue(ctx, "case_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementApi.CreateCaseJiraIssue`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/case-management/CreateCaseNotebook.go b/examples/v2/case-management/CreateCaseNotebook.go new file mode 100644 index 00000000000..ae8de7fc6bf --- /dev/null +++ b/examples/v2/case-management/CreateCaseNotebook.go @@ -0,0 +1,31 @@ +// Create investigation notebook for case returns "No Content" 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() { + body := datadogV2.NotebookCreateRequest{ + Data: datadogV2.NotebookCreateData{ + Type: datadogV2.NOTEBOOKRESOURCETYPE_NOTEBOOK, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateCaseNotebook", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCaseManagementApi(apiClient) + r, err := api.CreateCaseNotebook(ctx, "case_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementApi.CreateCaseNotebook`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/case-management/CreateCaseServiceNowTicket.go b/examples/v2/case-management/CreateCaseServiceNowTicket.go new file mode 100644 index 00000000000..6b3ccc651a8 --- /dev/null +++ b/examples/v2/case-management/CreateCaseServiceNowTicket.go @@ -0,0 +1,35 @@ +// Create ServiceNow ticket for case returns "Accepted" 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() { + body := datadogV2.ServiceNowTicketCreateRequest{ + Data: datadogV2.ServiceNowTicketCreateData{ + Attributes: datadogV2.ServiceNowTicketCreateAttributes{ + AssignmentGroup: datadog.PtrString("IT Support"), + InstanceName: "my-instance", + }, + Type: datadogV2.SERVICENOWTICKETRESOURCETYPE_TICKETS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateCaseServiceNowTicket", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCaseManagementApi(apiClient) + r, err := api.CreateCaseServiceNowTicket(ctx, "case_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementApi.CreateCaseServiceNowTicket`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/case-management/LinkIncident.go b/examples/v2/case-management/LinkIncident.go new file mode 100644 index 00000000000..f128e21dcdf --- /dev/null +++ b/examples/v2/case-management/LinkIncident.go @@ -0,0 +1,36 @@ +// Link incident to case 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() { + body := datadogV2.RelationshipToIncidentRequest{ + Data: datadogV2.IncidentRelationshipData{ + Id: "00000000-0000-0000-0000-000000000000", + Type: datadogV2.INCIDENTRESOURCETYPE_INCIDENTS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.LinkIncident", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCaseManagementApi(apiClient) + resp, r, err := api.LinkIncident(ctx, "case_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementApi.LinkIncident`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `CaseManagementApi.LinkIncident`:\n%s\n", responseContent) +} diff --git a/examples/v2/case-management/LinkJiraIssueToCase.go b/examples/v2/case-management/LinkJiraIssueToCase.go new file mode 100644 index 00000000000..b9ca8414843 --- /dev/null +++ b/examples/v2/case-management/LinkJiraIssueToCase.go @@ -0,0 +1,34 @@ +// Link existing Jira issue to case returns "No Content" 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() { + body := datadogV2.JiraIssueLinkRequest{ + Data: datadogV2.JiraIssueLinkData{ + Attributes: datadogV2.JiraIssueLinkAttributes{ + JiraIssueUrl: "https://jira.example.com/browse/PROJ-123", + }, + Type: datadogV2.JIRAISSUERESOURCETYPE_ISSUES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.LinkJiraIssueToCase", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCaseManagementApi(apiClient) + r, err := api.LinkJiraIssueToCase(ctx, "case_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementApi.LinkJiraIssueToCase`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/case-management/MoveCaseToProject.go b/examples/v2/case-management/MoveCaseToProject.go new file mode 100644 index 00000000000..835a44a9728 --- /dev/null +++ b/examples/v2/case-management/MoveCaseToProject.go @@ -0,0 +1,36 @@ +// Update case project 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() { + body := datadogV2.ProjectRelationship{ + Data: datadogV2.ProjectRelationshipData{ + Id: "e555e290-ed65-49bd-ae18-8acbfcf18db7", + Type: datadogV2.PROJECTRESOURCETYPE_PROJECT, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.MoveCaseToProject", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCaseManagementApi(apiClient) + resp, r, err := api.MoveCaseToProject(ctx, "case_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementApi.MoveCaseToProject`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `CaseManagementApi.MoveCaseToProject`:\n%s\n", responseContent) +} diff --git a/examples/v2/case-management/UnlinkJiraIssue.go b/examples/v2/case-management/UnlinkJiraIssue.go new file mode 100644 index 00000000000..1c324fee87c --- /dev/null +++ b/examples/v2/case-management/UnlinkJiraIssue.go @@ -0,0 +1,26 @@ +// Remove Jira issue link from case returns "No Content" 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UnlinkJiraIssue", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCaseManagementApi(apiClient) + r, err := api.UnlinkJiraIssue(ctx, "case_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementApi.UnlinkJiraIssue`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/tests/scenarios/features/v2/case_management.feature b/tests/scenarios/features/v2/case_management.feature index 7e26a5815f2..56d8f9ed68e 100644 --- a/tests/scenarios/features/v2/case_management.feature +++ b/tests/scenarios/features/v2/case_management.feature @@ -90,6 +90,60 @@ Feature: Case Management When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/case-management + Scenario: Create Jira issue for case returns "Accepted" response + Given operation "CreateCaseJiraIssue" enabled + And new "CreateCaseJiraIssue" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"fields": {}, "issue_type_id": "10001", "jira_account_id": "1234", "project_id": "5678"}, "type": "issues"}} + When the request is sent + Then the response status is 202 Accepted + + @generated @skip @team:DataDog/case-management + Scenario: Create Jira issue for case returns "Bad Request" response + Given operation "CreateCaseJiraIssue" enabled + And new "CreateCaseJiraIssue" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"fields": {}, "issue_type_id": "10001", "jira_account_id": "1234", "project_id": "5678"}, "type": "issues"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/case-management + Scenario: Create Jira issue for case returns "Not Found" response + Given operation "CreateCaseJiraIssue" enabled + And new "CreateCaseJiraIssue" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"fields": {}, "issue_type_id": "10001", "jira_account_id": "1234", "project_id": "5678"}, "type": "issues"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/case-management + Scenario: Create ServiceNow ticket for case returns "Accepted" response + Given operation "CreateCaseServiceNowTicket" enabled + And new "CreateCaseServiceNowTicket" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"assignment_group": "IT Support", "instance_name": "my-instance"}, "type": "tickets"}} + When the request is sent + Then the response status is 202 Accepted + + @generated @skip @team:DataDog/case-management + Scenario: Create ServiceNow ticket for case returns "Bad Request" response + Given operation "CreateCaseServiceNowTicket" enabled + And new "CreateCaseServiceNowTicket" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"assignment_group": "IT Support", "instance_name": "my-instance"}, "type": "tickets"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/case-management + Scenario: Create ServiceNow ticket for case returns "Not Found" response + Given operation "CreateCaseServiceNowTicket" enabled + And new "CreateCaseServiceNowTicket" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"assignment_group": "IT Support", "instance_name": "my-instance"}, "type": "tickets"}} + When the request is sent + Then the response status is 404 Not Found + @team:DataDog/case-management Scenario: Create a case returns "Bad Request" response Given new "CreateCase" request @@ -161,6 +215,33 @@ Feature: Case Management When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/case-management + Scenario: Create investigation notebook for case returns "Bad Request" response + Given operation "CreateCaseNotebook" enabled + And new "CreateCaseNotebook" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"type": "notebook"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/case-management + Scenario: Create investigation notebook for case returns "No Content" response + Given operation "CreateCaseNotebook" enabled + And new "CreateCaseNotebook" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"type": "notebook"}} + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/case-management + Scenario: Create investigation notebook for case returns "Not Found" response + Given operation "CreateCaseNotebook" enabled + And new "CreateCaseNotebook" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"type": "notebook"}} + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/case-management Scenario: Delete a notification rule returns "API error response" response Given new "DeleteProjectNotificationRule" request @@ -308,6 +389,93 @@ Feature: Case Management When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/case-management + Scenario: Link existing Jira issue to case returns "Bad Request" response + Given operation "LinkJiraIssueToCase" enabled + And new "LinkJiraIssueToCase" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"jira_issue_url": "https://jira.example.com/browse/PROJ-123"}, "type": "issues"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/case-management + Scenario: Link existing Jira issue to case returns "Conflict" response + Given operation "LinkJiraIssueToCase" enabled + And new "LinkJiraIssueToCase" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"jira_issue_url": "https://jira.example.com/browse/PROJ-123"}, "type": "issues"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/case-management + Scenario: Link existing Jira issue to case returns "No Content" response + Given operation "LinkJiraIssueToCase" enabled + And new "LinkJiraIssueToCase" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"jira_issue_url": "https://jira.example.com/browse/PROJ-123"}, "type": "issues"}} + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/case-management + Scenario: Link existing Jira issue to case returns "Not Found" response + Given operation "LinkJiraIssueToCase" enabled + And new "LinkJiraIssueToCase" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"jira_issue_url": "https://jira.example.com/browse/PROJ-123"}, "type": "issues"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/case-management + Scenario: Link incident to case returns "Bad Request" response + Given operation "LinkIncident" enabled + And new "LinkIncident" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"id": "00000000-0000-0000-0000-000000000000", "type": "incidents"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/case-management + Scenario: Link incident to case returns "Created" response + Given operation "LinkIncident" enabled + And new "LinkIncident" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"id": "00000000-0000-0000-0000-000000000000", "type": "incidents"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/case-management + Scenario: Link incident to case returns "Not Found" response + Given operation "LinkIncident" enabled + And new "LinkIncident" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"id": "00000000-0000-0000-0000-000000000000", "type": "incidents"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/case-management + Scenario: Remove Jira issue link from case returns "Bad Request" response + Given operation "UnlinkJiraIssue" enabled + And new "UnlinkJiraIssue" request + And request contains "case_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/case-management + Scenario: Remove Jira issue link from case returns "No Content" response + Given operation "UnlinkJiraIssue" enabled + And new "UnlinkJiraIssue" request + And request contains "case_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/case-management + Scenario: Remove Jira issue link from case returns "Not Found" response + Given operation "UnlinkJiraIssue" enabled + And new "UnlinkJiraIssue" request + And request contains "case_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/case-management Scenario: Remove a project returns "API error response" response Given new "DeleteProject" request @@ -564,6 +732,33 @@ Feature: Case Management Then the response status is 200 OK And the response "data.attributes.priority" is equal to "P3" + @generated @skip @team:DataDog/case-management + Scenario: Update case project returns "Bad Request" response + Given operation "MoveCaseToProject" enabled + And new "MoveCaseToProject" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"id": "e555e290-ed65-49bd-ae18-8acbfcf18db7", "type": "project"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/case-management + Scenario: Update case project returns "Not Found" response + Given operation "MoveCaseToProject" enabled + And new "MoveCaseToProject" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"id": "e555e290-ed65-49bd-ae18-8acbfcf18db7", "type": "project"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/case-management + Scenario: Update case project returns "OK" response + Given operation "MoveCaseToProject" enabled + And new "MoveCaseToProject" request + And request contains "case_id" parameter from "REPLACE.ME" + And body with value {"data": {"id": "e555e290-ed65-49bd-ae18-8acbfcf18db7", "type": "project"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/case-management Scenario: Update case status returns "Bad Request" response Given new "UpdateStatus" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index c77dfee3356..5727d36b956 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -836,6 +836,56 @@ "type": "idempotent" } }, + "LinkIncident": { + "tag": "Case Management", + "undo": { + "operationId": "TODO", + "parameters": [], + "type": "unsafe" + } + }, + "UnlinkJiraIssue": { + "tag": "Case Management", + "undo": { + "type": "idempotent" + } + }, + "LinkJiraIssueToCase": { + "tag": "Case Management", + "undo": { + "type": "idempotent" + } + }, + "CreateCaseJiraIssue": { + "tag": "Case Management", + "undo": { + "operationId": "TODO", + "parameters": [], + "type": "unsafe" + } + }, + "CreateCaseNotebook": { + "tag": "Case Management", + "undo": { + "operationId": "TODO", + "parameters": [], + "type": "unsafe" + } + }, + "MoveCaseToProject": { + "tag": "Case Management", + "undo": { + "type": "idempotent" + } + }, + "CreateCaseServiceNowTicket": { + "tag": "Case Management", + "undo": { + "operationId": "TODO", + "parameters": [], + "type": "unsafe" + } + }, "UpdateStatus": { "tag": "Case Management", "undo": {