From 48a0ec2d38cd916bd6dd05df43e3bf827b8a735b Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 22 Jul 2024 13:55:22 +0000 Subject: [PATCH] Regenerate client from commit 127470a2 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 243 ++++++++++++ api/datadogV2/api_workflow_automation.go | 351 ++++++++++++++++++ api/datadogV2/doc.go | 4 + .../model_workflow_instance_create_meta.go | 102 +++++ .../model_workflow_instance_create_request.go | 111 ++++++ ...model_workflow_instance_create_response.go | 111 ++++++ ..._workflow_instance_create_response_data.go | 102 +++++ .../model_workflow_instance_list_item.go | 111 ++++++ ..._workflow_instance_list_item_attributes.go | 102 +++++ .../model_workflow_list_instances_response.go | 102 +++++ ...odel_worklflow_cancel_instance_response.go | 111 ++++++ ...worklflow_cancel_instance_response_data.go | 102 +++++ .../model_worklflow_get_instance_response.go | 111 ++++++ ...el_worklflow_get_instance_response_data.go | 111 ++++++ ...w_get_instance_response_data_attributes.go | 102 +++++ .../CancelWorkflowInstance.go | 29 ++ .../CreateWorkflowInstance.go | 32 ++ .../GetWorkflowInstance.go | 29 ++ .../ListWorkflowInstances.go | 29 ++ tests/scenarios/api_mappings.go | 1 + tests/scenarios/features/v2/undo.json | 26 ++ .../features/v2/workflow_automation.feature | 87 +++++ 23 files changed, 2113 insertions(+), 4 deletions(-) create mode 100644 api/datadogV2/api_workflow_automation.go create mode 100644 api/datadogV2/model_workflow_instance_create_meta.go create mode 100644 api/datadogV2/model_workflow_instance_create_request.go create mode 100644 api/datadogV2/model_workflow_instance_create_response.go create mode 100644 api/datadogV2/model_workflow_instance_create_response_data.go create mode 100644 api/datadogV2/model_workflow_instance_list_item.go create mode 100644 api/datadogV2/model_workflow_instance_list_item_attributes.go create mode 100644 api/datadogV2/model_workflow_list_instances_response.go create mode 100644 api/datadogV2/model_worklflow_cancel_instance_response.go create mode 100644 api/datadogV2/model_worklflow_cancel_instance_response_data.go create mode 100644 api/datadogV2/model_worklflow_get_instance_response.go create mode 100644 api/datadogV2/model_worklflow_get_instance_response_data.go create mode 100644 api/datadogV2/model_worklflow_get_instance_response_data_attributes.go create mode 100644 examples/v2/workflow-automation/CancelWorkflowInstance.go create mode 100644 examples/v2/workflow-automation/CreateWorkflowInstance.go create mode 100644 examples/v2/workflow-automation/GetWorkflowInstance.go create mode 100644 examples/v2/workflow-automation/ListWorkflowInstances.go create mode 100644 tests/scenarios/features/v2/workflow_automation.feature diff --git a/.apigentools-info b/.apigentools-info index 1569a5cab53..06f6d9fc1b5 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-07-19 19:37:58.750999", - "spec_repo_commit": "a3f2b7d2" + "regenerated": "2024-07-22 13:53:42.056015", + "spec_repo_commit": "127470a2" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-07-19 19:37:58.775987", - "spec_repo_commit": "a3f2b7d2" + "regenerated": "2024-07-22 13:53:42.074370", + "spec_repo_commit": "127470a2" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 1d17a211ade..1ac97c58ad0 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -351,6 +351,13 @@ components: required: true schema: type: string + InstanceId: + description: The ID of the workflow instance. + in: path + name: instance_id + required: true + schema: + type: string MetricID: description: The name of the log-based metric. in: path @@ -536,6 +543,13 @@ components: schema: example: 00000000-0000-9999-0000-000000000000 type: string + WorkflowId: + description: The ID of the workflow. + in: path + name: workflow_id + required: true + schema: + type: string requestBodies: {} responses: BadRequestResponse: @@ -23587,6 +23601,88 @@ components: - PAST_SIX_MONTHS - PAST_ONE_YEAR - ALERT + WorkflowInstanceCreateMeta: + description: Additional information for creating a workflow instance. + properties: + payload: + additionalProperties: {} + description: The input parameters to the workflow. + type: object + type: object + WorkflowInstanceCreateRequest: + description: Request used to create a workflow instance. + properties: + meta: + $ref: '#/components/schemas/WorkflowInstanceCreateMeta' + type: object + WorkflowInstanceCreateResponse: + description: Response returned upon successful workflow instance creation. + properties: + data: + $ref: '#/components/schemas/WorkflowInstanceCreateResponseData' + type: object + WorkflowInstanceCreateResponseData: + description: Data about the created workflow instance. + properties: + id: + description: The ID of the workflow execution. It can be used to fetch the + execution status. + type: string + type: object + WorkflowInstanceListItem: + description: An item in the workflow instances list. + properties: + attributes: + $ref: '#/components/schemas/WorkflowInstanceListItemAttributes' + type: object + WorkflowInstanceListItemAttributes: + description: Attributes for an instance in an instance list. + properties: + id: + description: The id of the instance. + type: string + type: object + WorkflowListInstancesResponse: + description: Response returned when listing workflow instances. + properties: + data: + description: A list of workflow instances. + items: + $ref: '#/components/schemas/WorkflowInstanceListItem' + type: array + type: object + WorklflowCancelInstanceResponse: + description: Information about the canceled instance. + properties: + data: + $ref: '#/components/schemas/WorklflowCancelInstanceResponseData' + type: object + WorklflowCancelInstanceResponseData: + description: Data about the canceled instance. + properties: + id: + description: The id of the canceled instance + type: string + type: object + WorklflowGetInstanceResponse: + description: The state of the given workflow instance. + properties: + data: + $ref: '#/components/schemas/WorklflowGetInstanceResponseData' + type: object + WorklflowGetInstanceResponseData: + description: The data of the instance response. + properties: + attributes: + $ref: '#/components/schemas/WorklflowGetInstanceResponseDataAttributes' + type: object + WorklflowGetInstanceResponseDataAttributes: + description: The attributes of the instance response data. + properties: + id: + description: The id of the instance. + type: string + type: object securitySchemes: AuthZ: description: This API uses OAuth 2 with the implicit grant flow. @@ -37476,6 +37572,148 @@ paths: summary: Get user memberships tags: - Teams + /api/v2/workflows/{workflow_id}/instances: + get: + description: List all instances of a given workflow. + operationId: ListWorkflowInstances + parameters: + - $ref: '#/components/parameters/WorkflowId' + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/PageNumber' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/WorkflowListInstancesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List workflow instances + tags: + - Workflow Automation + post: + description: Execute the given workflow + operationId: CreateWorkflowInstance + parameters: + - $ref: '#/components/parameters/WorkflowId' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/WorkflowInstanceCreateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/WorkflowInstanceCreateResponse' + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Execute a workflow + tags: + - Workflow Automation + x-codegen-request-body-name: body + /api/v2/workflows/{workflow_id}/instances/{instance_id}: + get: + description: Get a specific execution of a given workflow. + operationId: GetWorkflowInstance + parameters: + - $ref: '#/components/parameters/WorkflowId' + - $ref: '#/components/parameters/InstanceId' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/WorklflowGetInstanceResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get a workflow instance + tags: + - Workflow Automation + /api/v2/workflows/{workflow_id}/instances/{instance_id}/cancel: + put: + description: Cancels a specific execution of a given workflow. + operationId: CancelWorkflowInstance + parameters: + - $ref: '#/components/parameters/WorkflowId' + - $ref: '#/components/parameters/InstanceId' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/WorklflowCancelInstanceResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Cancel a workflow instance + tags: + - Workflow Automation security: - apiKeyAuth: [] appKeyAuth: [] @@ -37847,4 +38085,9 @@ tags: externalDocs: url: https://docs.datadoghq.com/account_management/users name: Users +- description: Automate your teams operational processes with Datadog Workflow Automation. + externalDocs: + description: Find out more at + url: https://docs.datadoghq.com/service_management/workflows/ + name: Workflow Automation x-group-parameters: true diff --git a/api/datadogV2/api_workflow_automation.go b/api/datadogV2/api_workflow_automation.go new file mode 100644 index 00000000000..eb517204a53 --- /dev/null +++ b/api/datadogV2/api_workflow_automation.go @@ -0,0 +1,351 @@ +// 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 ( + _context "context" + _nethttp "net/http" + _neturl "net/url" + "strings" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorkflowAutomationApi service type +type WorkflowAutomationApi datadog.Service + +// CancelWorkflowInstance Cancel a workflow instance. +// Cancels a specific execution of a given workflow. +func (a *WorkflowAutomationApi) CancelWorkflowInstance(ctx _context.Context, workflowId string, instanceId string) (WorklflowCancelInstanceResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue WorklflowCancelInstanceResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.WorkflowAutomationApi.CancelWorkflowInstance") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/workflows/{workflow_id}/instances/{instance_id}/cancel" + localVarPath = strings.Replace(localVarPath, "{"+"workflow_id"+"}", _neturl.PathEscape(datadog.ParameterToString(workflowId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"instance_id"+"}", _neturl.PathEscape(datadog.ParameterToString(instanceId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// CreateWorkflowInstance Execute a workflow. +// Execute the given workflow +func (a *WorkflowAutomationApi) CreateWorkflowInstance(ctx _context.Context, workflowId string, body WorkflowInstanceCreateRequest) (WorkflowInstanceCreateResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue WorkflowInstanceCreateResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.WorkflowAutomationApi.CreateWorkflowInstance") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/workflows/{workflow_id}/instances" + localVarPath = strings.Replace(localVarPath, "{"+"workflow_id"+"}", _neturl.PathEscape(datadog.ParameterToString(workflowId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || 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 +} + +// GetWorkflowInstance Get a workflow instance. +// Get a specific execution of a given workflow. +func (a *WorkflowAutomationApi) GetWorkflowInstance(ctx _context.Context, workflowId string, instanceId string) (WorklflowGetInstanceResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue WorklflowGetInstanceResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.WorkflowAutomationApi.GetWorkflowInstance") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/workflows/{workflow_id}/instances/{instance_id}" + localVarPath = strings.Replace(localVarPath, "{"+"workflow_id"+"}", _neturl.PathEscape(datadog.ParameterToString(workflowId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"instance_id"+"}", _neturl.PathEscape(datadog.ParameterToString(instanceId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListWorkflowInstancesOptionalParameters holds optional parameters for ListWorkflowInstances. +type ListWorkflowInstancesOptionalParameters struct { + PageSize *int64 + PageNumber *int64 +} + +// NewListWorkflowInstancesOptionalParameters creates an empty struct for parameters. +func NewListWorkflowInstancesOptionalParameters() *ListWorkflowInstancesOptionalParameters { + this := ListWorkflowInstancesOptionalParameters{} + return &this +} + +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *ListWorkflowInstancesOptionalParameters) WithPageSize(pageSize int64) *ListWorkflowInstancesOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageNumber sets the corresponding parameter name and returns the struct. +func (r *ListWorkflowInstancesOptionalParameters) WithPageNumber(pageNumber int64) *ListWorkflowInstancesOptionalParameters { + r.PageNumber = &pageNumber + return r +} + +// ListWorkflowInstances List workflow instances. +// List all instances of a given workflow. +func (a *WorkflowAutomationApi) ListWorkflowInstances(ctx _context.Context, workflowId string, o ...ListWorkflowInstancesOptionalParameters) (WorkflowListInstancesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue WorkflowListInstancesResponse + optionalParams ListWorkflowInstancesOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListWorkflowInstancesOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.WorkflowAutomationApi.ListWorkflowInstances") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/workflows/{workflow_id}/instances" + localVarPath = strings.Replace(localVarPath, "{"+"workflow_id"+"}", _neturl.PathEscape(datadog.ParameterToString(workflowId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.PageSize != nil { + localVarQueryParams.Add("page[size]", datadog.ParameterToString(*optionalParams.PageSize, "")) + } + if optionalParams.PageNumber != nil { + localVarQueryParams.Add("page[number]", datadog.ParameterToString(*optionalParams.PageNumber, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || 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 +} + +// NewWorkflowAutomationApi Returns NewWorkflowAutomationApi. +func NewWorkflowAutomationApi(client *datadog.APIClient) *WorkflowAutomationApi { + return &WorkflowAutomationApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 29bf482d5ad..d5db9041c76 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -347,4 +347,8 @@ // - [UsersApi.ListUsers] // - [UsersApi.SendInvitations] // - [UsersApi.UpdateUser] +// - [WorkflowAutomationApi.CancelWorkflowInstance] +// - [WorkflowAutomationApi.CreateWorkflowInstance] +// - [WorkflowAutomationApi.GetWorkflowInstance] +// - [WorkflowAutomationApi.ListWorkflowInstances] package datadogV2 diff --git a/api/datadogV2/model_workflow_instance_create_meta.go b/api/datadogV2/model_workflow_instance_create_meta.go new file mode 100644 index 00000000000..2f356cfb582 --- /dev/null +++ b/api/datadogV2/model_workflow_instance_create_meta.go @@ -0,0 +1,102 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorkflowInstanceCreateMeta Additional information for creating a workflow instance. +type WorkflowInstanceCreateMeta struct { + // The input parameters to the workflow. + Payload map[string]interface{} `json:"payload,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorkflowInstanceCreateMeta instantiates a new WorkflowInstanceCreateMeta 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 NewWorkflowInstanceCreateMeta() *WorkflowInstanceCreateMeta { + this := WorkflowInstanceCreateMeta{} + return &this +} + +// NewWorkflowInstanceCreateMetaWithDefaults instantiates a new WorkflowInstanceCreateMeta 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 NewWorkflowInstanceCreateMetaWithDefaults() *WorkflowInstanceCreateMeta { + this := WorkflowInstanceCreateMeta{} + return &this +} + +// GetPayload returns the Payload field value if set, zero value otherwise. +func (o *WorkflowInstanceCreateMeta) GetPayload() map[string]interface{} { + if o == nil || o.Payload == nil { + var ret map[string]interface{} + return ret + } + return o.Payload +} + +// GetPayloadOk returns a tuple with the Payload field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowInstanceCreateMeta) GetPayloadOk() (*map[string]interface{}, bool) { + if o == nil || o.Payload == nil { + return nil, false + } + return &o.Payload, true +} + +// HasPayload returns a boolean if a field has been set. +func (o *WorkflowInstanceCreateMeta) HasPayload() bool { + return o != nil && o.Payload != nil +} + +// SetPayload gets a reference to the given map[string]interface{} and assigns it to the Payload field. +func (o *WorkflowInstanceCreateMeta) SetPayload(v map[string]interface{}) { + o.Payload = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorkflowInstanceCreateMeta) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Payload != nil { + toSerialize["payload"] = o.Payload + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorkflowInstanceCreateMeta) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Payload map[string]interface{} `json:"payload,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"payload"}) + } else { + return err + } + o.Payload = all.Payload + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_workflow_instance_create_request.go b/api/datadogV2/model_workflow_instance_create_request.go new file mode 100644 index 00000000000..3f43d31673e --- /dev/null +++ b/api/datadogV2/model_workflow_instance_create_request.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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorkflowInstanceCreateRequest Request used to create a workflow instance. +type WorkflowInstanceCreateRequest struct { + // Additional information for creating a workflow instance. + Meta *WorkflowInstanceCreateMeta `json:"meta,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorkflowInstanceCreateRequest instantiates a new WorkflowInstanceCreateRequest 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 NewWorkflowInstanceCreateRequest() *WorkflowInstanceCreateRequest { + this := WorkflowInstanceCreateRequest{} + return &this +} + +// NewWorkflowInstanceCreateRequestWithDefaults instantiates a new WorkflowInstanceCreateRequest 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 NewWorkflowInstanceCreateRequestWithDefaults() *WorkflowInstanceCreateRequest { + this := WorkflowInstanceCreateRequest{} + return &this +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *WorkflowInstanceCreateRequest) GetMeta() WorkflowInstanceCreateMeta { + if o == nil || o.Meta == nil { + var ret WorkflowInstanceCreateMeta + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowInstanceCreateRequest) GetMetaOk() (*WorkflowInstanceCreateMeta, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *WorkflowInstanceCreateRequest) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given WorkflowInstanceCreateMeta and assigns it to the Meta field. +func (o *WorkflowInstanceCreateRequest) SetMeta(v WorkflowInstanceCreateMeta) { + o.Meta = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorkflowInstanceCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorkflowInstanceCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Meta *WorkflowInstanceCreateMeta `json:"meta,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"meta"}) + } else { + return err + } + + hasInvalidField := false + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Meta = all.Meta + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_workflow_instance_create_response.go b/api/datadogV2/model_workflow_instance_create_response.go new file mode 100644 index 00000000000..99c0d4bb8c9 --- /dev/null +++ b/api/datadogV2/model_workflow_instance_create_response.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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorkflowInstanceCreateResponse Response returned upon successful workflow instance creation. +type WorkflowInstanceCreateResponse struct { + // Data about the created workflow instance. + Data *WorkflowInstanceCreateResponseData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorkflowInstanceCreateResponse instantiates a new WorkflowInstanceCreateResponse 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 NewWorkflowInstanceCreateResponse() *WorkflowInstanceCreateResponse { + this := WorkflowInstanceCreateResponse{} + return &this +} + +// NewWorkflowInstanceCreateResponseWithDefaults instantiates a new WorkflowInstanceCreateResponse 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 NewWorkflowInstanceCreateResponseWithDefaults() *WorkflowInstanceCreateResponse { + this := WorkflowInstanceCreateResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *WorkflowInstanceCreateResponse) GetData() WorkflowInstanceCreateResponseData { + if o == nil || o.Data == nil { + var ret WorkflowInstanceCreateResponseData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowInstanceCreateResponse) GetDataOk() (*WorkflowInstanceCreateResponseData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *WorkflowInstanceCreateResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given WorkflowInstanceCreateResponseData and assigns it to the Data field. +func (o *WorkflowInstanceCreateResponse) SetData(v WorkflowInstanceCreateResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorkflowInstanceCreateResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorkflowInstanceCreateResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *WorkflowInstanceCreateResponseData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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 != nil && 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_workflow_instance_create_response_data.go b/api/datadogV2/model_workflow_instance_create_response_data.go new file mode 100644 index 00000000000..2ea52d0b808 --- /dev/null +++ b/api/datadogV2/model_workflow_instance_create_response_data.go @@ -0,0 +1,102 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorkflowInstanceCreateResponseData Data about the created workflow instance. +type WorkflowInstanceCreateResponseData struct { + // The ID of the workflow execution. It can be used to fetch the execution status. + Id *string `json:"id,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorkflowInstanceCreateResponseData instantiates a new WorkflowInstanceCreateResponseData 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 NewWorkflowInstanceCreateResponseData() *WorkflowInstanceCreateResponseData { + this := WorkflowInstanceCreateResponseData{} + return &this +} + +// NewWorkflowInstanceCreateResponseDataWithDefaults instantiates a new WorkflowInstanceCreateResponseData 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 NewWorkflowInstanceCreateResponseDataWithDefaults() *WorkflowInstanceCreateResponseData { + this := WorkflowInstanceCreateResponseData{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *WorkflowInstanceCreateResponseData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowInstanceCreateResponseData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *WorkflowInstanceCreateResponseData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *WorkflowInstanceCreateResponseData) SetId(v string) { + o.Id = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorkflowInstanceCreateResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorkflowInstanceCreateResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id"}) + } else { + return err + } + o.Id = all.Id + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_workflow_instance_list_item.go b/api/datadogV2/model_workflow_instance_list_item.go new file mode 100644 index 00000000000..cdc8bc22c3c --- /dev/null +++ b/api/datadogV2/model_workflow_instance_list_item.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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorkflowInstanceListItem An item in the workflow instances list. +type WorkflowInstanceListItem struct { + // Attributes for an instance in an instance list. + Attributes *WorkflowInstanceListItemAttributes `json:"attributes,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorkflowInstanceListItem instantiates a new WorkflowInstanceListItem 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 NewWorkflowInstanceListItem() *WorkflowInstanceListItem { + this := WorkflowInstanceListItem{} + return &this +} + +// NewWorkflowInstanceListItemWithDefaults instantiates a new WorkflowInstanceListItem 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 NewWorkflowInstanceListItemWithDefaults() *WorkflowInstanceListItem { + this := WorkflowInstanceListItem{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *WorkflowInstanceListItem) GetAttributes() WorkflowInstanceListItemAttributes { + if o == nil || o.Attributes == nil { + var ret WorkflowInstanceListItemAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowInstanceListItem) GetAttributesOk() (*WorkflowInstanceListItemAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *WorkflowInstanceListItem) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given WorkflowInstanceListItemAttributes and assigns it to the Attributes field. +func (o *WorkflowInstanceListItem) SetAttributes(v WorkflowInstanceListItemAttributes) { + o.Attributes = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorkflowInstanceListItem) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorkflowInstanceListItem) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *WorkflowInstanceListItemAttributes `json:"attributes,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_workflow_instance_list_item_attributes.go b/api/datadogV2/model_workflow_instance_list_item_attributes.go new file mode 100644 index 00000000000..2bbfc43f401 --- /dev/null +++ b/api/datadogV2/model_workflow_instance_list_item_attributes.go @@ -0,0 +1,102 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorkflowInstanceListItemAttributes Attributes for an instance in an instance list. +type WorkflowInstanceListItemAttributes struct { + // The id of the instance. + Id *string `json:"id,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorkflowInstanceListItemAttributes instantiates a new WorkflowInstanceListItemAttributes 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 NewWorkflowInstanceListItemAttributes() *WorkflowInstanceListItemAttributes { + this := WorkflowInstanceListItemAttributes{} + return &this +} + +// NewWorkflowInstanceListItemAttributesWithDefaults instantiates a new WorkflowInstanceListItemAttributes 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 NewWorkflowInstanceListItemAttributesWithDefaults() *WorkflowInstanceListItemAttributes { + this := WorkflowInstanceListItemAttributes{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *WorkflowInstanceListItemAttributes) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowInstanceListItemAttributes) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *WorkflowInstanceListItemAttributes) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *WorkflowInstanceListItemAttributes) SetId(v string) { + o.Id = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorkflowInstanceListItemAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorkflowInstanceListItemAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id"}) + } else { + return err + } + o.Id = all.Id + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_workflow_list_instances_response.go b/api/datadogV2/model_workflow_list_instances_response.go new file mode 100644 index 00000000000..326be830bfe --- /dev/null +++ b/api/datadogV2/model_workflow_list_instances_response.go @@ -0,0 +1,102 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorkflowListInstancesResponse Response returned when listing workflow instances. +type WorkflowListInstancesResponse struct { + // A list of workflow instances. + Data []WorkflowInstanceListItem `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorkflowListInstancesResponse instantiates a new WorkflowListInstancesResponse 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 NewWorkflowListInstancesResponse() *WorkflowListInstancesResponse { + this := WorkflowListInstancesResponse{} + return &this +} + +// NewWorkflowListInstancesResponseWithDefaults instantiates a new WorkflowListInstancesResponse 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 NewWorkflowListInstancesResponseWithDefaults() *WorkflowListInstancesResponse { + this := WorkflowListInstancesResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *WorkflowListInstancesResponse) GetData() []WorkflowInstanceListItem { + if o == nil || o.Data == nil { + var ret []WorkflowInstanceListItem + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowListInstancesResponse) GetDataOk() (*[]WorkflowInstanceListItem, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return &o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *WorkflowListInstancesResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []WorkflowInstanceListItem and assigns it to the Data field. +func (o *WorkflowListInstancesResponse) SetData(v []WorkflowInstanceListItem) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorkflowListInstancesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorkflowListInstancesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []WorkflowInstanceListItem `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_worklflow_cancel_instance_response.go b/api/datadogV2/model_worklflow_cancel_instance_response.go new file mode 100644 index 00000000000..d38678d8998 --- /dev/null +++ b/api/datadogV2/model_worklflow_cancel_instance_response.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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorklflowCancelInstanceResponse Information about the canceled instance. +type WorklflowCancelInstanceResponse struct { + // Data about the canceled instance. + Data *WorklflowCancelInstanceResponseData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorklflowCancelInstanceResponse instantiates a new WorklflowCancelInstanceResponse 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 NewWorklflowCancelInstanceResponse() *WorklflowCancelInstanceResponse { + this := WorklflowCancelInstanceResponse{} + return &this +} + +// NewWorklflowCancelInstanceResponseWithDefaults instantiates a new WorklflowCancelInstanceResponse 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 NewWorklflowCancelInstanceResponseWithDefaults() *WorklflowCancelInstanceResponse { + this := WorklflowCancelInstanceResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *WorklflowCancelInstanceResponse) GetData() WorklflowCancelInstanceResponseData { + if o == nil || o.Data == nil { + var ret WorklflowCancelInstanceResponseData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorklflowCancelInstanceResponse) GetDataOk() (*WorklflowCancelInstanceResponseData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *WorklflowCancelInstanceResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given WorklflowCancelInstanceResponseData and assigns it to the Data field. +func (o *WorklflowCancelInstanceResponse) SetData(v WorklflowCancelInstanceResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorklflowCancelInstanceResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorklflowCancelInstanceResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *WorklflowCancelInstanceResponseData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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 != nil && 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_worklflow_cancel_instance_response_data.go b/api/datadogV2/model_worklflow_cancel_instance_response_data.go new file mode 100644 index 00000000000..54a3eaf3abd --- /dev/null +++ b/api/datadogV2/model_worklflow_cancel_instance_response_data.go @@ -0,0 +1,102 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorklflowCancelInstanceResponseData Data about the canceled instance. +type WorklflowCancelInstanceResponseData struct { + // The id of the canceled instance + Id *string `json:"id,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorklflowCancelInstanceResponseData instantiates a new WorklflowCancelInstanceResponseData 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 NewWorklflowCancelInstanceResponseData() *WorklflowCancelInstanceResponseData { + this := WorklflowCancelInstanceResponseData{} + return &this +} + +// NewWorklflowCancelInstanceResponseDataWithDefaults instantiates a new WorklflowCancelInstanceResponseData 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 NewWorklflowCancelInstanceResponseDataWithDefaults() *WorklflowCancelInstanceResponseData { + this := WorklflowCancelInstanceResponseData{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *WorklflowCancelInstanceResponseData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorklflowCancelInstanceResponseData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *WorklflowCancelInstanceResponseData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *WorklflowCancelInstanceResponseData) SetId(v string) { + o.Id = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorklflowCancelInstanceResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorklflowCancelInstanceResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id"}) + } else { + return err + } + o.Id = all.Id + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_worklflow_get_instance_response.go b/api/datadogV2/model_worklflow_get_instance_response.go new file mode 100644 index 00000000000..f324b81ca7e --- /dev/null +++ b/api/datadogV2/model_worklflow_get_instance_response.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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorklflowGetInstanceResponse The state of the given workflow instance. +type WorklflowGetInstanceResponse struct { + // The data of the instance response. + Data *WorklflowGetInstanceResponseData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorklflowGetInstanceResponse instantiates a new WorklflowGetInstanceResponse 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 NewWorklflowGetInstanceResponse() *WorklflowGetInstanceResponse { + this := WorklflowGetInstanceResponse{} + return &this +} + +// NewWorklflowGetInstanceResponseWithDefaults instantiates a new WorklflowGetInstanceResponse 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 NewWorklflowGetInstanceResponseWithDefaults() *WorklflowGetInstanceResponse { + this := WorklflowGetInstanceResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *WorklflowGetInstanceResponse) GetData() WorklflowGetInstanceResponseData { + if o == nil || o.Data == nil { + var ret WorklflowGetInstanceResponseData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorklflowGetInstanceResponse) GetDataOk() (*WorklflowGetInstanceResponseData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *WorklflowGetInstanceResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given WorklflowGetInstanceResponseData and assigns it to the Data field. +func (o *WorklflowGetInstanceResponse) SetData(v WorklflowGetInstanceResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorklflowGetInstanceResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorklflowGetInstanceResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *WorklflowGetInstanceResponseData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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 != nil && 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_worklflow_get_instance_response_data.go b/api/datadogV2/model_worklflow_get_instance_response_data.go new file mode 100644 index 00000000000..fef695fccd7 --- /dev/null +++ b/api/datadogV2/model_worklflow_get_instance_response_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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorklflowGetInstanceResponseData The data of the instance response. +type WorklflowGetInstanceResponseData struct { + // The attributes of the instance response data. + Attributes *WorklflowGetInstanceResponseDataAttributes `json:"attributes,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorklflowGetInstanceResponseData instantiates a new WorklflowGetInstanceResponseData 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 NewWorklflowGetInstanceResponseData() *WorklflowGetInstanceResponseData { + this := WorklflowGetInstanceResponseData{} + return &this +} + +// NewWorklflowGetInstanceResponseDataWithDefaults instantiates a new WorklflowGetInstanceResponseData 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 NewWorklflowGetInstanceResponseDataWithDefaults() *WorklflowGetInstanceResponseData { + this := WorklflowGetInstanceResponseData{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *WorklflowGetInstanceResponseData) GetAttributes() WorklflowGetInstanceResponseDataAttributes { + if o == nil || o.Attributes == nil { + var ret WorklflowGetInstanceResponseDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorklflowGetInstanceResponseData) GetAttributesOk() (*WorklflowGetInstanceResponseDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *WorklflowGetInstanceResponseData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given WorklflowGetInstanceResponseDataAttributes and assigns it to the Attributes field. +func (o *WorklflowGetInstanceResponseData) SetAttributes(v WorklflowGetInstanceResponseDataAttributes) { + o.Attributes = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorklflowGetInstanceResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorklflowGetInstanceResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *WorklflowGetInstanceResponseDataAttributes `json:"attributes,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_worklflow_get_instance_response_data_attributes.go b/api/datadogV2/model_worklflow_get_instance_response_data_attributes.go new file mode 100644 index 00000000000..ab4f731cd5e --- /dev/null +++ b/api/datadogV2/model_worklflow_get_instance_response_data_attributes.go @@ -0,0 +1,102 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WorklflowGetInstanceResponseDataAttributes The attributes of the instance response data. +type WorklflowGetInstanceResponseDataAttributes struct { + // The id of the instance. + Id *string `json:"id,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewWorklflowGetInstanceResponseDataAttributes instantiates a new WorklflowGetInstanceResponseDataAttributes 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 NewWorklflowGetInstanceResponseDataAttributes() *WorklflowGetInstanceResponseDataAttributes { + this := WorklflowGetInstanceResponseDataAttributes{} + return &this +} + +// NewWorklflowGetInstanceResponseDataAttributesWithDefaults instantiates a new WorklflowGetInstanceResponseDataAttributes 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 NewWorklflowGetInstanceResponseDataAttributesWithDefaults() *WorklflowGetInstanceResponseDataAttributes { + this := WorklflowGetInstanceResponseDataAttributes{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *WorklflowGetInstanceResponseDataAttributes) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorklflowGetInstanceResponseDataAttributes) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *WorklflowGetInstanceResponseDataAttributes) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *WorklflowGetInstanceResponseDataAttributes) SetId(v string) { + o.Id = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o WorklflowGetInstanceResponseDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *WorklflowGetInstanceResponseDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id"}) + } else { + return err + } + o.Id = all.Id + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/workflow-automation/CancelWorkflowInstance.go b/examples/v2/workflow-automation/CancelWorkflowInstance.go new file mode 100644 index 00000000000..7959395a9fe --- /dev/null +++ b/examples/v2/workflow-automation/CancelWorkflowInstance.go @@ -0,0 +1,29 @@ +// Cancel a workflow instance 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewWorkflowAutomationApi(apiClient) + resp, r, err := api.CancelWorkflowInstance(ctx, "workflow_id", "instance_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `WorkflowAutomationApi.CancelWorkflowInstance`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `WorkflowAutomationApi.CancelWorkflowInstance`:\n%s\n", responseContent) +} diff --git a/examples/v2/workflow-automation/CreateWorkflowInstance.go b/examples/v2/workflow-automation/CreateWorkflowInstance.go new file mode 100644 index 00000000000..109343f16e5 --- /dev/null +++ b/examples/v2/workflow-automation/CreateWorkflowInstance.go @@ -0,0 +1,32 @@ +// Execute a workflow 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.WorkflowInstanceCreateRequest{ + Meta: &datadogV2.WorkflowInstanceCreateMeta{}, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewWorkflowAutomationApi(apiClient) + resp, r, err := api.CreateWorkflowInstance(ctx, "workflow_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `WorkflowAutomationApi.CreateWorkflowInstance`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `WorkflowAutomationApi.CreateWorkflowInstance`:\n%s\n", responseContent) +} diff --git a/examples/v2/workflow-automation/GetWorkflowInstance.go b/examples/v2/workflow-automation/GetWorkflowInstance.go new file mode 100644 index 00000000000..6a0e601e67b --- /dev/null +++ b/examples/v2/workflow-automation/GetWorkflowInstance.go @@ -0,0 +1,29 @@ +// Get a workflow instance 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewWorkflowAutomationApi(apiClient) + resp, r, err := api.GetWorkflowInstance(ctx, "workflow_id", "instance_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `WorkflowAutomationApi.GetWorkflowInstance`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `WorkflowAutomationApi.GetWorkflowInstance`:\n%s\n", responseContent) +} diff --git a/examples/v2/workflow-automation/ListWorkflowInstances.go b/examples/v2/workflow-automation/ListWorkflowInstances.go new file mode 100644 index 00000000000..25d5261193e --- /dev/null +++ b/examples/v2/workflow-automation/ListWorkflowInstances.go @@ -0,0 +1,29 @@ +// List workflow instances 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewWorkflowAutomationApi(apiClient) + resp, r, err := api.ListWorkflowInstances(ctx, "workflow_id", *datadogV2.NewListWorkflowInstancesOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `WorkflowAutomationApi.ListWorkflowInstances`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `WorkflowAutomationApi.ListWorkflowInstances`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 2972e942363..f3833fa4683 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -95,5 +95,6 @@ var apiMappings = map[string]map[string]reflect.Value{ "TeamsApi": reflect.ValueOf(datadogV2.NewTeamsApi), "IncidentTeamsApi": reflect.ValueOf(datadogV2.NewIncidentTeamsApi), "UsersApi": reflect.ValueOf(datadogV2.NewUsersApi), + "WorkflowAutomationApi": reflect.ValueOf(datadogV2.NewWorkflowAutomationApi), }, } \ No newline at end of file diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 170f9c4e65a..7d1c0d7107a 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2406,5 +2406,31 @@ "undo": { "type": "safe" } + }, + "ListWorkflowInstances": { + "tag": "Workflow Automation", + "undo": { + "type": "safe" + } + }, + "CreateWorkflowInstance": { + "tag": "Workflow Automation", + "undo": { + "operationId": "TODO", + "parameters": [], + "type": "unsafe" + } + }, + "GetWorkflowInstance": { + "tag": "Workflow Automation", + "undo": { + "type": "safe" + } + }, + "CancelWorkflowInstance": { + "tag": "Workflow Automation", + "undo": { + "type": "safe" + } } } diff --git a/tests/scenarios/features/v2/workflow_automation.feature b/tests/scenarios/features/v2/workflow_automation.feature new file mode 100644 index 00000000000..f8fe951158f --- /dev/null +++ b/tests/scenarios/features/v2/workflow_automation.feature @@ -0,0 +1,87 @@ +@endpoint(workflow-automation) @endpoint(workflow-automation-v2) +Feature: Workflow Automation + Automate your teams operational processes with Datadog Workflow + Automation. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "WorkflowAutomation" API + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: Cancel a workflow instance returns "Bad Request" response + Given new "CancelWorkflowInstance" request + And request contains "workflow_id" parameter from "REPLACE.ME" + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: Cancel a workflow instance returns "Not Found" response + Given new "CancelWorkflowInstance" request + And request contains "workflow_id" parameter from "REPLACE.ME" + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: Cancel a workflow instance returns "OK" response + Given new "CancelWorkflowInstance" request + And request contains "workflow_id" parameter from "REPLACE.ME" + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: Execute a workflow returns "Bad Request" response + Given new "CreateWorkflowInstance" request + And request contains "workflow_id" parameter from "REPLACE.ME" + And body with value {"meta": {}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: Execute a workflow returns "Created" response + Given new "CreateWorkflowInstance" request + And request contains "workflow_id" parameter from "REPLACE.ME" + And body with value {"meta": {}} + When the request is sent + Then the response status is 200 Created + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: Get a workflow instance returns "Bad Request" response + Given new "GetWorkflowInstance" request + And request contains "workflow_id" parameter from "REPLACE.ME" + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: Get a workflow instance returns "Not Found" response + Given new "GetWorkflowInstance" request + And request contains "workflow_id" parameter from "REPLACE.ME" + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: Get a workflow instance returns "OK" response + Given new "GetWorkflowInstance" request + And request contains "workflow_id" parameter from "REPLACE.ME" + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: List workflow instances returns "Bad Request" response + Given new "ListWorkflowInstances" request + And request contains "workflow_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: List workflow instances returns "OK" response + Given new "ListWorkflowInstances" request + And request contains "workflow_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK