diff --git a/.apigentools-info b/.apigentools-info index d3dcaf90d84..4ac7e2e43ea 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-06 18:09:28.866098", - "spec_repo_commit": "c020103f" + "regenerated": "2025-01-06 22:10:31.604705", + "spec_repo_commit": "697c3843" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-06 18:09:28.881917", - "spec_repo_commit": "c020103f" + "regenerated": "2025-01-06 22:10:31.620125", + "spec_repo_commit": "697c3843" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 295728842fb..c5fbd0e0a3c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -206,6 +206,13 @@ components: required: true schema: type: string + ConnectionId: + description: The ID of the action connection + in: path + name: connection_id + required: true + schema: + type: string CustomDestinationId: description: The ID of the custom destination. in: path @@ -1209,6 +1216,64 @@ components: required: - data type: object + AWSAssumeRole: + description: The definition of `AWSAssumeRole` object. + properties: + account_id: + description: AWS account the connection is created for + example: '111222333444' + pattern: ^\d{12}$ + type: string + external_id: + description: External ID used to scope which connection can be used to assume + the role + example: 33a1011635c44b38a064cf14e82e1d8f + readOnly: true + type: string + principal_id: + description: AWS account that will assume the role + example: '123456789012' + readOnly: true + type: string + role: + description: Role to assume + example: my-role + type: string + type: + $ref: '#/components/schemas/AWSAssumeRoleType' + required: + - type + - account_id + - role + type: object + AWSAssumeRoleType: + description: The definition of `AWSAssumeRoleType` object. + enum: + - AWSAssumeRole + example: AWSAssumeRole + type: string + x-enum-varnames: + - AWSASSUMEROLE + AWSAssumeRoleUpdate: + description: The definition of `AWSAssumeRoleUpdate` object. + properties: + account_id: + description: AWS account the connection is created for + example: '111222333444' + pattern: ^\d{12}$ + type: string + generate_new_external_id: + description: The `AWSAssumeRoleUpdate` `generate_new_external_id`. + type: boolean + role: + description: Role to assume + example: my-role + type: string + type: + $ref: '#/components/schemas/AWSAssumeRoleType' + required: + - type + type: object AWSAuthConfig: description: AWS Authentication config. oneOf: @@ -1247,6 +1312,43 @@ components: required: - role_name type: object + AWSCredentials: + description: The definition of `AWSCredentials` object. + oneOf: + - $ref: '#/components/schemas/AWSAssumeRole' + AWSCredentialsUpdate: + description: The definition of `AWSCredentialsUpdate` object. + oneOf: + - $ref: '#/components/schemas/AWSAssumeRoleUpdate' + AWSIntegration: + description: The definition of `AWSIntegration` object. + properties: + credentials: + $ref: '#/components/schemas/AWSCredentials' + type: + $ref: '#/components/schemas/AWSIntegrationType' + required: + - type + - credentials + type: object + AWSIntegrationType: + description: The definition of `AWSIntegrationType` object. + enum: + - AWS + example: AWS + type: string + x-enum-varnames: + - AWS + AWSIntegrationUpdate: + description: The definition of `AWSIntegrationUpdate` object. + properties: + credentials: + $ref: '#/components/schemas/AWSCredentialsUpdate' + type: + $ref: '#/components/schemas/AWSIntegrationType' + required: + - type + type: object AWSLambdaForwarderConfig: description: 'Log Autosubscription configuration for Datadog Forwarder Lambda functions. Automatically set up triggers for existing @@ -1560,6 +1662,73 @@ components: xray_services: $ref: '#/components/schemas/XRayServicesList' type: object + ActionConnectionAttributes: + description: The definition of `ActionConnectionAttributes` object. + properties: + integration: + $ref: '#/components/schemas/ActionConnectionIntegration' + name: + description: Name of the connection + example: My AWS Connection + type: string + required: + - name + - integration + type: object + ActionConnectionAttributesUpdate: + description: The definition of `ActionConnectionAttributesUpdate` object. + properties: + integration: + $ref: '#/components/schemas/ActionConnectionIntegrationUpdate' + name: + description: Name of the connection + example: My AWS Connection + type: string + type: object + ActionConnectionData: + description: Data related to the connection. + properties: + attributes: + $ref: '#/components/schemas/ActionConnectionAttributes' + id: + description: The connection identifier + readOnly: true + type: string + type: + $ref: '#/components/schemas/ActionConnectionDataType' + required: + - type + - attributes + type: object + ActionConnectionDataType: + description: The definition of `ActionConnectionDataType` object. + enum: + - action_connection + example: action_connection + type: string + x-enum-varnames: + - ACTION_CONNECTION + ActionConnectionDataUpdate: + description: Data related to the connection update. + properties: + attributes: + $ref: '#/components/schemas/ActionConnectionAttributesUpdate' + type: + $ref: '#/components/schemas/ActionConnectionDataType' + required: + - type + - attributes + type: object + ActionConnectionIntegration: + description: The definition of `ActionConnectionIntegration` object. + oneOf: + - $ref: '#/components/schemas/AWSIntegration' + - $ref: '#/components/schemas/HTTPIntegration' + ActionConnectionIntegrationUpdate: + description: The definition of `ActionConnectionIntegrationUpdate` object. + oneOf: + - $ref: '#/components/schemas/AWSIntegrationUpdate' + - $ref: '#/components/schemas/HTTPIntegrationUpdate' ActiveBillingDimensionsAttributes: description: List of active billing dimensions. properties: @@ -6968,6 +7137,20 @@ components: type: string x-enum-varnames: - COST_BY_ORG + CreateActionConnectionRequest: + description: Request used to create an action connection. + properties: + data: + $ref: '#/components/schemas/ActionConnectionData' + required: + - data + type: object + CreateActionConnectionResponse: + description: The response for a created connection + properties: + data: + $ref: '#/components/schemas/ActionConnectionData' + type: object CreateAppRequest: description: The definition of `CreateAppRequest` object. example: @@ -12178,6 +12361,12 @@ components: type: string x-enum-varnames: - GCP_SERVICE_ACCOUNT + GetActionConnectionResponse: + description: The response for found connection + properties: + data: + $ref: '#/components/schemas/ActionConnectionData' + type: object GetAppResponse: description: The definition of `GetAppResponse` object. properties: @@ -12472,6 +12661,18 @@ components: example: env:production type: string type: array + HTTPBody: + description: The definition of `HTTPBody` object. + properties: + content: + description: Serialized body content + example: '{"some-json": "with-value"}' + type: string + content_type: + description: Content type of the body + example: application/json + type: string + type: object HTTPCIAppError: description: List of errors. properties: @@ -12497,6 +12698,88 @@ components: $ref: '#/components/schemas/HTTPCIAppError' type: array type: object + HTTPCredentials: + description: The definition of `HTTPCredentials` object. + oneOf: + - $ref: '#/components/schemas/HTTPTokenAuth' + HTTPCredentialsUpdate: + description: The definition of `HTTPCredentialsUpdate` object. + oneOf: + - $ref: '#/components/schemas/HTTPTokenAuthUpdate' + HTTPHeader: + description: The definition of `HTTPHeader` object. + properties: + name: + description: The `HTTPHeader` `name`. + example: MyHttpHeader + pattern: ^[A-Za-z][A-Za-z\\d\\-\\_]*$ + type: string + value: + description: The `HTTPHeader` `value`. + example: Some header value + type: string + required: + - name + - value + type: object + HTTPHeaderUpdate: + description: The definition of `HTTPHeaderUpdate` object. + properties: + deleted: + description: Should the header be deleted. + type: boolean + name: + description: The `HTTPHeaderUpdate` `name`. + example: MyHttpHeader + pattern: ^[A-Za-z][A-Za-z\\d\\-\\_]*$ + type: string + value: + description: The `HTTPHeaderUpdate` `value`. + example: Updated Header Value + type: string + required: + - name + type: object + HTTPIntegration: + description: The definition of `HTTPIntegration` object. + properties: + base_url: + description: Base HTTP url for the integration + example: http://datadoghq.com + pattern: url + type: string + credentials: + $ref: '#/components/schemas/HTTPCredentials' + type: + $ref: '#/components/schemas/HTTPIntegrationType' + required: + - type + - base_url + - credentials + type: object + HTTPIntegrationType: + description: The definition of `HTTPIntegrationType` object. + enum: + - HTTP + example: HTTP + type: string + x-enum-varnames: + - HTTP + HTTPIntegrationUpdate: + description: The definition of `HTTPIntegrationUpdate` object. + properties: + base_url: + description: Base HTTP url for the integration + example: http://datadoghq.com + pattern: url + type: string + credentials: + $ref: '#/components/schemas/HTTPCredentialsUpdate' + type: + $ref: '#/components/schemas/HTTPIntegrationType' + required: + - type + type: object HTTPLog: description: Structured log message. items: @@ -12573,6 +12856,105 @@ components: required: - message type: object + HTTPToken: + description: The definition of `HTTPToken` object. + properties: + name: + description: The `HTTPToken` `name`. + example: MyToken + pattern: ^[A-Za-z][A-Za-z\\d]*$ + type: string + type: + $ref: '#/components/schemas/TokenType' + value: + description: The `HTTPToken` `value`. + example: Some Token Value + type: string + required: + - name + - value + - type + type: object + HTTPTokenAuth: + description: The definition of `HTTPTokenAuth` object. + properties: + body: + $ref: '#/components/schemas/HTTPBody' + headers: + description: The `HTTPTokenAuth` `headers`. + items: + $ref: '#/components/schemas/HTTPHeader' + type: array + tokens: + description: The `HTTPTokenAuth` `tokens`. + items: + $ref: '#/components/schemas/HTTPToken' + type: array + type: + $ref: '#/components/schemas/HTTPTokenAuthType' + url_parameters: + description: The `HTTPTokenAuth` `url_parameters`. + items: + $ref: '#/components/schemas/UrlParam' + type: array + required: + - type + type: object + HTTPTokenAuthType: + description: The definition of `HTTPTokenAuthType` object. + enum: + - HTTPTokenAuth + example: HTTPTokenAuth + type: string + x-enum-varnames: + - HTTPTOKENAUTH + HTTPTokenAuthUpdate: + description: The definition of `HTTPTokenAuthUpdate` object. + properties: + body: + $ref: '#/components/schemas/HTTPBody' + headers: + description: The `HTTPTokenAuthUpdate` `headers`. + items: + $ref: '#/components/schemas/HTTPHeaderUpdate' + type: array + tokens: + description: The `HTTPTokenAuthUpdate` `tokens`. + items: + $ref: '#/components/schemas/HTTPTokenUpdate' + type: array + type: + $ref: '#/components/schemas/HTTPTokenAuthType' + url_parameters: + description: The `HTTPTokenAuthUpdate` `url_parameters`. + items: + $ref: '#/components/schemas/UrlParamUpdate' + type: array + required: + - type + type: object + HTTPTokenUpdate: + description: The definition of `HTTPTokenUpdate` object. + properties: + deleted: + description: Should the header be deleted. + type: boolean + name: + description: The `HTTPToken` `name`. + example: MyToken + pattern: ^[A-Za-z][A-Za-z\\d]*$ + type: string + type: + $ref: '#/components/schemas/TokenType' + value: + description: The `HTTPToken` `value`. + example: Some Token Value + type: string + required: + - name + - type + - value + type: object HistoricalJobDataType: description: Type of payload. enum: @@ -28659,6 +29041,19 @@ components: items: $ref: '#/components/schemas/TimeseriesResponseValues' type: array + TokenName: + description: Name for tokens. + example: MyTokenName + pattern: ^[A-Za-z][A-Za-z\\d]*$ + type: string + TokenType: + description: The definition of `TokenType` object. + enum: + - SECRET + example: SECRET + type: string + x-enum-varnames: + - SECRET Unit: description: Object containing the metric unit family, scale factor, name, and short name. @@ -28687,6 +29082,20 @@ components: example: min type: string type: object + UpdateActionConnectionRequest: + description: Request used to update an action connection. + properties: + data: + $ref: '#/components/schemas/ActionConnectionDataUpdate' + required: + - data + type: object + UpdateActionConnectionResponse: + description: The response for an updated connection. + properties: + data: + $ref: '#/components/schemas/ActionConnectionData' + type: object UpdateAppRequest: description: The definition of `UpdateAppRequest` object. example: @@ -28957,6 +29366,36 @@ components: description: Upsert entity response included item. oneOf: - $ref: '#/components/schemas/EntityResponseIncludedSchema' + UrlParam: + description: The definition of `UrlParam` object. + properties: + name: + $ref: '#/components/schemas/TokenName' + example: MyUrlParameter + value: + description: The `UrlParam` `value`. + example: Some Url Parameter value + type: string + required: + - name + - value + type: object + UrlParamUpdate: + description: The definition of `UrlParamUpdate` object. + properties: + deleted: + description: Should the header be deleted. + type: boolean + name: + $ref: '#/components/schemas/TokenName' + example: MyUrlParameter + value: + description: The `UrlParamUpdate` `value`. + example: Some Url Parameter value + type: string + required: + - name + type: object UsageApplicationSecurityMonitoringResponse: description: Application Security Monitoring usage response. properties: @@ -30198,6 +30637,163 @@ info: version: '1.0' openapi: 3.0.0 paths: + /api/v2/actions/connections: + post: + description: Create a new Action Connection + operationId: CreateActionConnection + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateActionConnectionRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/CreateActionConnectionResponse' + description: Successfully created Action Connection + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Too Many Request + summary: Create a new Action Connection + tags: + - Action Connection + /api/v2/actions/connections/{connection_id}: + delete: + description: Delete an existing Action Connection + operationId: DeleteActionConnection + parameters: + - $ref: '#/components/parameters/ConnectionId' + responses: + '204': + description: The resource was deleted successfully. + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Too Many Request + summary: Delete an existing Action Connection + tags: + - Action Connection + x-permission: + operator: OR + permissions: + - connection_write + get: + description: Get an existing Action Connection + operationId: GetActionConnection + parameters: + - $ref: '#/components/parameters/ConnectionId' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GetActionConnectionResponse' + description: Successfully get Action Connection + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Too Many Request + summary: Get an existing Action Connection + tags: + - Action Connection + patch: + description: Update an existing Action Connection + operationId: UpdateActionConnection + parameters: + - $ref: '#/components/parameters/ConnectionId' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateActionConnectionRequest' + description: Update an existing Action Connection request body + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateActionConnectionResponse' + description: Successfully updated Action Connection + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Too Many Request + summary: Update an existing Action Connection + tags: + - Action Connection /api/v2/api_keys: get: description: List all API keys available for your account. @@ -48107,6 +48703,17 @@ tags: externalDocs: url: https://docs.datadoghq.com/integrations/amazon_web_services/#log-collection name: AWS Logs Integration +- description: "Action connections extend your installed integrations and allow you + to take action in your third-party systems\n(e.g. AWS, GitLab, and Statuspage) + with Datadog\u2019s Workflow Automation and App Builder products.\n\nDatadog\u2019s + Integrations automatically provide authentication for Slack, Microsoft Teams, + PagerDuty, Opsgenie,\nJIRA, GitHub, and Statuspage. You do not need additional + connections in order to access these tools within\nWorkflow Automation and App + Builder.\n\nWe offer granular access control for editing and resolving connections." + externalDocs: + description: Find out more at + url: https://docs.datadoghq.com/service_management/workflows/connections/ + name: Action Connection - description: Datadog App Builder provides a low-code solution to rapidly develop and integrate secure, customized applications into your monitoring stack that are built to accelerate remediation at scale. These API endpoints allow you to diff --git a/api/datadogV2/api_action_connection.go b/api/datadogV2/api_action_connection.go new file mode 100644 index 00000000000..5687927823d --- /dev/null +++ b/api/datadogV2/api_action_connection.go @@ -0,0 +1,302 @@ +// 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" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ActionConnectionApi service type +type ActionConnectionApi datadog.Service + +// CreateActionConnection Create a new Action Connection. +// Create a new Action Connection +func (a *ActionConnectionApi) CreateActionConnection(ctx _context.Context, body CreateActionConnectionRequest) (CreateActionConnectionResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue CreateActionConnectionResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ActionConnectionApi.CreateActionConnection") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/actions/connections" + + 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 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 + } + + 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 +} + +// DeleteActionConnection Delete an existing Action Connection. +// Delete an existing Action Connection +func (a *ActionConnectionApi) DeleteActionConnection(ctx _context.Context, connectionId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ActionConnectionApi.DeleteActionConnection") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/actions/connections/{connection_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{connection_id}", _neturl.PathEscape(datadog.ParameterToString(connectionId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + 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 + } + + return localVarHTTPResponse, nil +} + +// GetActionConnection Get an existing Action Connection. +// Get an existing Action Connection +func (a *ActionConnectionApi) GetActionConnection(ctx _context.Context, connectionId string) (GetActionConnectionResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GetActionConnectionResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ActionConnectionApi.GetActionConnection") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/actions/connections/{connection_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{connection_id}", _neturl.PathEscape(datadog.ParameterToString(connectionId, ""))) + + 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 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 + } + + 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 +} + +// UpdateActionConnection Update an existing Action Connection. +// Update an existing Action Connection +func (a *ActionConnectionApi) UpdateActionConnection(ctx _context.Context, connectionId string, body UpdateActionConnectionRequest) (UpdateActionConnectionResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue UpdateActionConnectionResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ActionConnectionApi.UpdateActionConnection") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/actions/connections/{connection_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{connection_id}", _neturl.PathEscape(datadog.ParameterToString(connectionId, ""))) + + 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 == 404 || localVarHTTPResponse.StatusCode == 429 { + 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 + } + + 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 +} + +// NewActionConnectionApi Returns NewActionConnectionApi. +func NewActionConnectionApi(client *datadog.APIClient) *ActionConnectionApi { + return &ActionConnectionApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index a5f7df8536e..a807b7ed8da 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -22,6 +22,10 @@ // - [AWSIntegrationApi.ListAWSNamespaces] // - [AWSIntegrationApi.UpdateAWSAccount] // - [AWSLogsIntegrationApi.ListAWSLogsServices] +// - [ActionConnectionApi.CreateActionConnection] +// - [ActionConnectionApi.DeleteActionConnection] +// - [ActionConnectionApi.GetActionConnection] +// - [ActionConnectionApi.UpdateActionConnection] // - [AppsApi.CreateApp] // - [AppsApi.DeleteApp] // - [AppsApi.DeleteApps] diff --git a/api/datadogV2/model_action_connection_attributes.go b/api/datadogV2/model_action_connection_attributes.go new file mode 100644 index 00000000000..34b4f1d1909 --- /dev/null +++ b/api/datadogV2/model_action_connection_attributes.go @@ -0,0 +1,133 @@ +// 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" +) + +// ActionConnectionAttributes The definition of `ActionConnectionAttributes` object. +type ActionConnectionAttributes struct { + // The definition of `ActionConnectionIntegration` object. + Integration ActionConnectionIntegration `json:"integration"` + // Name of the connection + Name string `json:"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:"-"` +} + +// NewActionConnectionAttributes instantiates a new ActionConnectionAttributes 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 NewActionConnectionAttributes(integration ActionConnectionIntegration, name string) *ActionConnectionAttributes { + this := ActionConnectionAttributes{} + this.Integration = integration + this.Name = name + return &this +} + +// NewActionConnectionAttributesWithDefaults instantiates a new ActionConnectionAttributes 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 NewActionConnectionAttributesWithDefaults() *ActionConnectionAttributes { + this := ActionConnectionAttributes{} + return &this +} + +// GetIntegration returns the Integration field value. +func (o *ActionConnectionAttributes) GetIntegration() ActionConnectionIntegration { + if o == nil { + var ret ActionConnectionIntegration + return ret + } + return o.Integration +} + +// GetIntegrationOk returns a tuple with the Integration field value +// and a boolean to check if the value has been set. +func (o *ActionConnectionAttributes) GetIntegrationOk() (*ActionConnectionIntegration, bool) { + if o == nil { + return nil, false + } + return &o.Integration, true +} + +// SetIntegration sets field value. +func (o *ActionConnectionAttributes) SetIntegration(v ActionConnectionIntegration) { + o.Integration = v +} + +// GetName returns the Name field value. +func (o *ActionConnectionAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ActionConnectionAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *ActionConnectionAttributes) SetName(v string) { + o.Name = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ActionConnectionAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["integration"] = o.Integration + toSerialize["name"] = o.Name + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ActionConnectionAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Integration *ActionConnectionIntegration `json:"integration"` + Name *string `json:"name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Integration == nil { + return fmt.Errorf("required field integration missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"integration", "name"}) + } else { + return err + } + o.Integration = *all.Integration + o.Name = *all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_action_connection_attributes_update.go b/api/datadogV2/model_action_connection_attributes_update.go new file mode 100644 index 00000000000..936999ce7c5 --- /dev/null +++ b/api/datadogV2/model_action_connection_attributes_update.go @@ -0,0 +1,137 @@ +// 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" +) + +// ActionConnectionAttributesUpdate The definition of `ActionConnectionAttributesUpdate` object. +type ActionConnectionAttributesUpdate struct { + // The definition of `ActionConnectionIntegrationUpdate` object. + Integration *ActionConnectionIntegrationUpdate `json:"integration,omitempty"` + // Name of the connection + Name *string `json:"name,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{} `json:"-"` +} + +// NewActionConnectionAttributesUpdate instantiates a new ActionConnectionAttributesUpdate 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 NewActionConnectionAttributesUpdate() *ActionConnectionAttributesUpdate { + this := ActionConnectionAttributesUpdate{} + return &this +} + +// NewActionConnectionAttributesUpdateWithDefaults instantiates a new ActionConnectionAttributesUpdate 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 NewActionConnectionAttributesUpdateWithDefaults() *ActionConnectionAttributesUpdate { + this := ActionConnectionAttributesUpdate{} + return &this +} + +// GetIntegration returns the Integration field value if set, zero value otherwise. +func (o *ActionConnectionAttributesUpdate) GetIntegration() ActionConnectionIntegrationUpdate { + if o == nil || o.Integration == nil { + var ret ActionConnectionIntegrationUpdate + return ret + } + return *o.Integration +} + +// GetIntegrationOk returns a tuple with the Integration field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ActionConnectionAttributesUpdate) GetIntegrationOk() (*ActionConnectionIntegrationUpdate, bool) { + if o == nil || o.Integration == nil { + return nil, false + } + return o.Integration, true +} + +// HasIntegration returns a boolean if a field has been set. +func (o *ActionConnectionAttributesUpdate) HasIntegration() bool { + return o != nil && o.Integration != nil +} + +// SetIntegration gets a reference to the given ActionConnectionIntegrationUpdate and assigns it to the Integration field. +func (o *ActionConnectionAttributesUpdate) SetIntegration(v ActionConnectionIntegrationUpdate) { + o.Integration = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *ActionConnectionAttributesUpdate) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ActionConnectionAttributesUpdate) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *ActionConnectionAttributesUpdate) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *ActionConnectionAttributesUpdate) SetName(v string) { + o.Name = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ActionConnectionAttributesUpdate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Integration != nil { + toSerialize["integration"] = o.Integration + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ActionConnectionAttributesUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Integration *ActionConnectionIntegrationUpdate `json:"integration,omitempty"` + Name *string `json:"name,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{"integration", "name"}) + } else { + return err + } + o.Integration = all.Integration + o.Name = all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_action_connection_data.go b/api/datadogV2/model_action_connection_data.go new file mode 100644 index 00000000000..d6be1dd2c68 --- /dev/null +++ b/api/datadogV2/model_action_connection_data.go @@ -0,0 +1,181 @@ +// 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" +) + +// ActionConnectionData Data related to the connection. +type ActionConnectionData struct { + // The definition of `ActionConnectionAttributes` object. + Attributes ActionConnectionAttributes `json:"attributes"` + // The connection identifier + Id *string `json:"id,omitempty"` + // The definition of `ActionConnectionDataType` object. + Type ActionConnectionDataType `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:"-"` +} + +// NewActionConnectionData instantiates a new ActionConnectionData 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 NewActionConnectionData(attributes ActionConnectionAttributes, typeVar ActionConnectionDataType) *ActionConnectionData { + this := ActionConnectionData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewActionConnectionDataWithDefaults instantiates a new ActionConnectionData 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 NewActionConnectionDataWithDefaults() *ActionConnectionData { + this := ActionConnectionData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ActionConnectionData) GetAttributes() ActionConnectionAttributes { + if o == nil { + var ret ActionConnectionAttributes + 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 *ActionConnectionData) GetAttributesOk() (*ActionConnectionAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ActionConnectionData) SetAttributes(v ActionConnectionAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ActionConnectionData) 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 *ActionConnectionData) 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 *ActionConnectionData) 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 *ActionConnectionData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value. +func (o *ActionConnectionData) GetType() ActionConnectionDataType { + if o == nil { + var ret ActionConnectionDataType + 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 *ActionConnectionData) GetTypeOk() (*ActionConnectionDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ActionConnectionData) SetType(v ActionConnectionDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ActionConnectionData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + if o.Id != nil { + 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 *ActionConnectionData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ActionConnectionAttributes `json:"attributes"` + Id *string `json:"id,omitempty"` + Type *ActionConnectionDataType `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", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + 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_action_connection_data_type.go b/api/datadogV2/model_action_connection_data_type.go new file mode 100644 index 00000000000..80a725d6adf --- /dev/null +++ b/api/datadogV2/model_action_connection_data_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" +) + +// ActionConnectionDataType The definition of `ActionConnectionDataType` object. +type ActionConnectionDataType string + +// List of ActionConnectionDataType. +const ( + ACTIONCONNECTIONDATATYPE_ACTION_CONNECTION ActionConnectionDataType = "action_connection" +) + +var allowedActionConnectionDataTypeEnumValues = []ActionConnectionDataType{ + ACTIONCONNECTIONDATATYPE_ACTION_CONNECTION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ActionConnectionDataType) GetAllowedValues() []ActionConnectionDataType { + return allowedActionConnectionDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ActionConnectionDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ActionConnectionDataType(value) + return nil +} + +// NewActionConnectionDataTypeFromValue returns a pointer to a valid ActionConnectionDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewActionConnectionDataTypeFromValue(v string) (*ActionConnectionDataType, error) { + ev := ActionConnectionDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ActionConnectionDataType: valid values are %v", v, allowedActionConnectionDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ActionConnectionDataType) IsValid() bool { + for _, existing := range allowedActionConnectionDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ActionConnectionDataType value. +func (v ActionConnectionDataType) Ptr() *ActionConnectionDataType { + return &v +} diff --git a/api/datadogV2/model_action_connection_data_update.go b/api/datadogV2/model_action_connection_data_update.go new file mode 100644 index 00000000000..da698cd2d0a --- /dev/null +++ b/api/datadogV2/model_action_connection_data_update.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" +) + +// ActionConnectionDataUpdate Data related to the connection update. +type ActionConnectionDataUpdate struct { + // The definition of `ActionConnectionAttributesUpdate` object. + Attributes ActionConnectionAttributesUpdate `json:"attributes"` + // The definition of `ActionConnectionDataType` object. + Type ActionConnectionDataType `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:"-"` +} + +// NewActionConnectionDataUpdate instantiates a new ActionConnectionDataUpdate 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 NewActionConnectionDataUpdate(attributes ActionConnectionAttributesUpdate, typeVar ActionConnectionDataType) *ActionConnectionDataUpdate { + this := ActionConnectionDataUpdate{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewActionConnectionDataUpdateWithDefaults instantiates a new ActionConnectionDataUpdate 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 NewActionConnectionDataUpdateWithDefaults() *ActionConnectionDataUpdate { + this := ActionConnectionDataUpdate{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ActionConnectionDataUpdate) GetAttributes() ActionConnectionAttributesUpdate { + if o == nil { + var ret ActionConnectionAttributesUpdate + 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 *ActionConnectionDataUpdate) GetAttributesOk() (*ActionConnectionAttributesUpdate, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ActionConnectionDataUpdate) SetAttributes(v ActionConnectionAttributesUpdate) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ActionConnectionDataUpdate) GetType() ActionConnectionDataType { + if o == nil { + var ret ActionConnectionDataType + 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 *ActionConnectionDataUpdate) GetTypeOk() (*ActionConnectionDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ActionConnectionDataUpdate) SetType(v ActionConnectionDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ActionConnectionDataUpdate) 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 *ActionConnectionDataUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ActionConnectionAttributesUpdate `json:"attributes"` + Type *ActionConnectionDataType `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_action_connection_integration.go b/api/datadogV2/model_action_connection_integration.go new file mode 100644 index 00000000000..d5a48b1f46c --- /dev/null +++ b/api/datadogV2/model_action_connection_integration.go @@ -0,0 +1,105 @@ +// 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" +) + +// ActionConnectionIntegration - The definition of `ActionConnectionIntegration` object. +type ActionConnectionIntegration struct { + AWSIntegration *AWSIntegration + HTTPIntegration *HTTPIntegration + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// AWSIntegrationAsActionConnectionIntegration is a convenience function that returns AWSIntegration wrapped in ActionConnectionIntegration. +func AWSIntegrationAsActionConnectionIntegration(v *AWSIntegration) ActionConnectionIntegration { + return ActionConnectionIntegration{AWSIntegration: v} +} + +// HTTPIntegrationAsActionConnectionIntegration is a convenience function that returns HTTPIntegration wrapped in ActionConnectionIntegration. +func HTTPIntegrationAsActionConnectionIntegration(v *HTTPIntegration) ActionConnectionIntegration { + return ActionConnectionIntegration{HTTPIntegration: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *ActionConnectionIntegration) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into AWSIntegration + err = datadog.Unmarshal(data, &obj.AWSIntegration) + if err == nil { + if obj.AWSIntegration != nil && obj.AWSIntegration.UnparsedObject == nil { + jsonAWSIntegration, _ := datadog.Marshal(obj.AWSIntegration) + if string(jsonAWSIntegration) == "{}" { // empty struct + obj.AWSIntegration = nil + } else { + match++ + } + } else { + obj.AWSIntegration = nil + } + } else { + obj.AWSIntegration = nil + } + + // try to unmarshal data into HTTPIntegration + err = datadog.Unmarshal(data, &obj.HTTPIntegration) + if err == nil { + if obj.HTTPIntegration != nil && obj.HTTPIntegration.UnparsedObject == nil { + jsonHTTPIntegration, _ := datadog.Marshal(obj.HTTPIntegration) + if string(jsonHTTPIntegration) == "{}" { // empty struct + obj.HTTPIntegration = nil + } else { + match++ + } + } else { + obj.HTTPIntegration = nil + } + } else { + obj.HTTPIntegration = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.AWSIntegration = nil + obj.HTTPIntegration = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj ActionConnectionIntegration) MarshalJSON() ([]byte, error) { + if obj.AWSIntegration != nil { + return datadog.Marshal(&obj.AWSIntegration) + } + + if obj.HTTPIntegration != nil { + return datadog.Marshal(&obj.HTTPIntegration) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *ActionConnectionIntegration) GetActualInstance() interface{} { + if obj.AWSIntegration != nil { + return obj.AWSIntegration + } + + if obj.HTTPIntegration != nil { + return obj.HTTPIntegration + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_action_connection_integration_update.go b/api/datadogV2/model_action_connection_integration_update.go new file mode 100644 index 00000000000..1f21ea888f7 --- /dev/null +++ b/api/datadogV2/model_action_connection_integration_update.go @@ -0,0 +1,105 @@ +// 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" +) + +// ActionConnectionIntegrationUpdate - The definition of `ActionConnectionIntegrationUpdate` object. +type ActionConnectionIntegrationUpdate struct { + AWSIntegrationUpdate *AWSIntegrationUpdate + HTTPIntegrationUpdate *HTTPIntegrationUpdate + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// AWSIntegrationUpdateAsActionConnectionIntegrationUpdate is a convenience function that returns AWSIntegrationUpdate wrapped in ActionConnectionIntegrationUpdate. +func AWSIntegrationUpdateAsActionConnectionIntegrationUpdate(v *AWSIntegrationUpdate) ActionConnectionIntegrationUpdate { + return ActionConnectionIntegrationUpdate{AWSIntegrationUpdate: v} +} + +// HTTPIntegrationUpdateAsActionConnectionIntegrationUpdate is a convenience function that returns HTTPIntegrationUpdate wrapped in ActionConnectionIntegrationUpdate. +func HTTPIntegrationUpdateAsActionConnectionIntegrationUpdate(v *HTTPIntegrationUpdate) ActionConnectionIntegrationUpdate { + return ActionConnectionIntegrationUpdate{HTTPIntegrationUpdate: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *ActionConnectionIntegrationUpdate) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into AWSIntegrationUpdate + err = datadog.Unmarshal(data, &obj.AWSIntegrationUpdate) + if err == nil { + if obj.AWSIntegrationUpdate != nil && obj.AWSIntegrationUpdate.UnparsedObject == nil { + jsonAWSIntegrationUpdate, _ := datadog.Marshal(obj.AWSIntegrationUpdate) + if string(jsonAWSIntegrationUpdate) == "{}" { // empty struct + obj.AWSIntegrationUpdate = nil + } else { + match++ + } + } else { + obj.AWSIntegrationUpdate = nil + } + } else { + obj.AWSIntegrationUpdate = nil + } + + // try to unmarshal data into HTTPIntegrationUpdate + err = datadog.Unmarshal(data, &obj.HTTPIntegrationUpdate) + if err == nil { + if obj.HTTPIntegrationUpdate != nil && obj.HTTPIntegrationUpdate.UnparsedObject == nil { + jsonHTTPIntegrationUpdate, _ := datadog.Marshal(obj.HTTPIntegrationUpdate) + if string(jsonHTTPIntegrationUpdate) == "{}" { // empty struct + obj.HTTPIntegrationUpdate = nil + } else { + match++ + } + } else { + obj.HTTPIntegrationUpdate = nil + } + } else { + obj.HTTPIntegrationUpdate = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.AWSIntegrationUpdate = nil + obj.HTTPIntegrationUpdate = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj ActionConnectionIntegrationUpdate) MarshalJSON() ([]byte, error) { + if obj.AWSIntegrationUpdate != nil { + return datadog.Marshal(&obj.AWSIntegrationUpdate) + } + + if obj.HTTPIntegrationUpdate != nil { + return datadog.Marshal(&obj.HTTPIntegrationUpdate) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *ActionConnectionIntegrationUpdate) GetActualInstance() interface{} { + if obj.AWSIntegrationUpdate != nil { + return obj.AWSIntegrationUpdate + } + + if obj.HTTPIntegrationUpdate != nil { + return obj.HTTPIntegrationUpdate + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_aws_assume_role.go b/api/datadogV2/model_aws_assume_role.go new file mode 100644 index 00000000000..68438dbdc82 --- /dev/null +++ b/api/datadogV2/model_aws_assume_role.go @@ -0,0 +1,245 @@ +// 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" +) + +// AWSAssumeRole The definition of `AWSAssumeRole` object. +type AWSAssumeRole struct { + // AWS account the connection is created for + AccountId string `json:"account_id"` + // External ID used to scope which connection can be used to assume the role + ExternalId *string `json:"external_id,omitempty"` + // AWS account that will assume the role + PrincipalId *string `json:"principal_id,omitempty"` + // Role to assume + Role string `json:"role"` + // The definition of `AWSAssumeRoleType` object. + Type AWSAssumeRoleType `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:"-"` +} + +// NewAWSAssumeRole instantiates a new AWSAssumeRole 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 NewAWSAssumeRole(accountId string, role string, typeVar AWSAssumeRoleType) *AWSAssumeRole { + this := AWSAssumeRole{} + this.AccountId = accountId + this.Role = role + this.Type = typeVar + return &this +} + +// NewAWSAssumeRoleWithDefaults instantiates a new AWSAssumeRole 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 NewAWSAssumeRoleWithDefaults() *AWSAssumeRole { + this := AWSAssumeRole{} + return &this +} + +// GetAccountId returns the AccountId field value. +func (o *AWSAssumeRole) GetAccountId() string { + if o == nil { + var ret string + return ret + } + return o.AccountId +} + +// GetAccountIdOk returns a tuple with the AccountId field value +// and a boolean to check if the value has been set. +func (o *AWSAssumeRole) GetAccountIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AccountId, true +} + +// SetAccountId sets field value. +func (o *AWSAssumeRole) SetAccountId(v string) { + o.AccountId = v +} + +// GetExternalId returns the ExternalId field value if set, zero value otherwise. +func (o *AWSAssumeRole) GetExternalId() string { + if o == nil || o.ExternalId == nil { + var ret string + return ret + } + return *o.ExternalId +} + +// GetExternalIdOk returns a tuple with the ExternalId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AWSAssumeRole) GetExternalIdOk() (*string, bool) { + if o == nil || o.ExternalId == nil { + return nil, false + } + return o.ExternalId, true +} + +// HasExternalId returns a boolean if a field has been set. +func (o *AWSAssumeRole) HasExternalId() bool { + return o != nil && o.ExternalId != nil +} + +// SetExternalId gets a reference to the given string and assigns it to the ExternalId field. +func (o *AWSAssumeRole) SetExternalId(v string) { + o.ExternalId = &v +} + +// GetPrincipalId returns the PrincipalId field value if set, zero value otherwise. +func (o *AWSAssumeRole) GetPrincipalId() string { + if o == nil || o.PrincipalId == nil { + var ret string + return ret + } + return *o.PrincipalId +} + +// GetPrincipalIdOk returns a tuple with the PrincipalId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AWSAssumeRole) GetPrincipalIdOk() (*string, bool) { + if o == nil || o.PrincipalId == nil { + return nil, false + } + return o.PrincipalId, true +} + +// HasPrincipalId returns a boolean if a field has been set. +func (o *AWSAssumeRole) HasPrincipalId() bool { + return o != nil && o.PrincipalId != nil +} + +// SetPrincipalId gets a reference to the given string and assigns it to the PrincipalId field. +func (o *AWSAssumeRole) SetPrincipalId(v string) { + o.PrincipalId = &v +} + +// GetRole returns the Role field value. +func (o *AWSAssumeRole) GetRole() string { + if o == nil { + var ret string + return ret + } + return o.Role +} + +// GetRoleOk returns a tuple with the Role field value +// and a boolean to check if the value has been set. +func (o *AWSAssumeRole) GetRoleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Role, true +} + +// SetRole sets field value. +func (o *AWSAssumeRole) SetRole(v string) { + o.Role = v +} + +// GetType returns the Type field value. +func (o *AWSAssumeRole) GetType() AWSAssumeRoleType { + if o == nil { + var ret AWSAssumeRoleType + 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 *AWSAssumeRole) GetTypeOk() (*AWSAssumeRoleType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AWSAssumeRole) SetType(v AWSAssumeRoleType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSAssumeRole) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["account_id"] = o.AccountId + if o.ExternalId != nil { + toSerialize["external_id"] = o.ExternalId + } + if o.PrincipalId != nil { + toSerialize["principal_id"] = o.PrincipalId + } + toSerialize["role"] = o.Role + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AWSAssumeRole) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AccountId *string `json:"account_id"` + ExternalId *string `json:"external_id,omitempty"` + PrincipalId *string `json:"principal_id,omitempty"` + Role *string `json:"role"` + Type *AWSAssumeRoleType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AccountId == nil { + return fmt.Errorf("required field account_id missing") + } + if all.Role == nil { + return fmt.Errorf("required field role 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{"account_id", "external_id", "principal_id", "role", "type"}) + } else { + return err + } + + hasInvalidField := false + o.AccountId = *all.AccountId + o.ExternalId = all.ExternalId + o.PrincipalId = all.PrincipalId + o.Role = *all.Role + 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_aws_assume_role_type.go b/api/datadogV2/model_aws_assume_role_type.go new file mode 100644 index 00000000000..345b8474ecf --- /dev/null +++ b/api/datadogV2/model_aws_assume_role_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" +) + +// AWSAssumeRoleType The definition of `AWSAssumeRoleType` object. +type AWSAssumeRoleType string + +// List of AWSAssumeRoleType. +const ( + AWSASSUMEROLETYPE_AWSASSUMEROLE AWSAssumeRoleType = "AWSAssumeRole" +) + +var allowedAWSAssumeRoleTypeEnumValues = []AWSAssumeRoleType{ + AWSASSUMEROLETYPE_AWSASSUMEROLE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AWSAssumeRoleType) GetAllowedValues() []AWSAssumeRoleType { + return allowedAWSAssumeRoleTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AWSAssumeRoleType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AWSAssumeRoleType(value) + return nil +} + +// NewAWSAssumeRoleTypeFromValue returns a pointer to a valid AWSAssumeRoleType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAWSAssumeRoleTypeFromValue(v string) (*AWSAssumeRoleType, error) { + ev := AWSAssumeRoleType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AWSAssumeRoleType: valid values are %v", v, allowedAWSAssumeRoleTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AWSAssumeRoleType) IsValid() bool { + for _, existing := range allowedAWSAssumeRoleTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AWSAssumeRoleType value. +func (v AWSAssumeRoleType) Ptr() *AWSAssumeRoleType { + return &v +} diff --git a/api/datadogV2/model_aws_assume_role_update.go b/api/datadogV2/model_aws_assume_role_update.go new file mode 100644 index 00000000000..d081e846dbe --- /dev/null +++ b/api/datadogV2/model_aws_assume_role_update.go @@ -0,0 +1,216 @@ +// 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" +) + +// AWSAssumeRoleUpdate The definition of `AWSAssumeRoleUpdate` object. +type AWSAssumeRoleUpdate struct { + // AWS account the connection is created for + AccountId *string `json:"account_id,omitempty"` + // The `AWSAssumeRoleUpdate` `generate_new_external_id`. + GenerateNewExternalId *bool `json:"generate_new_external_id,omitempty"` + // Role to assume + Role *string `json:"role,omitempty"` + // The definition of `AWSAssumeRoleType` object. + Type AWSAssumeRoleType `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:"-"` +} + +// NewAWSAssumeRoleUpdate instantiates a new AWSAssumeRoleUpdate 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 NewAWSAssumeRoleUpdate(typeVar AWSAssumeRoleType) *AWSAssumeRoleUpdate { + this := AWSAssumeRoleUpdate{} + this.Type = typeVar + return &this +} + +// NewAWSAssumeRoleUpdateWithDefaults instantiates a new AWSAssumeRoleUpdate 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 NewAWSAssumeRoleUpdateWithDefaults() *AWSAssumeRoleUpdate { + this := AWSAssumeRoleUpdate{} + return &this +} + +// GetAccountId returns the AccountId field value if set, zero value otherwise. +func (o *AWSAssumeRoleUpdate) GetAccountId() string { + if o == nil || o.AccountId == nil { + var ret string + return ret + } + return *o.AccountId +} + +// GetAccountIdOk returns a tuple with the AccountId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AWSAssumeRoleUpdate) GetAccountIdOk() (*string, bool) { + if o == nil || o.AccountId == nil { + return nil, false + } + return o.AccountId, true +} + +// HasAccountId returns a boolean if a field has been set. +func (o *AWSAssumeRoleUpdate) HasAccountId() bool { + return o != nil && o.AccountId != nil +} + +// SetAccountId gets a reference to the given string and assigns it to the AccountId field. +func (o *AWSAssumeRoleUpdate) SetAccountId(v string) { + o.AccountId = &v +} + +// GetGenerateNewExternalId returns the GenerateNewExternalId field value if set, zero value otherwise. +func (o *AWSAssumeRoleUpdate) GetGenerateNewExternalId() bool { + if o == nil || o.GenerateNewExternalId == nil { + var ret bool + return ret + } + return *o.GenerateNewExternalId +} + +// GetGenerateNewExternalIdOk returns a tuple with the GenerateNewExternalId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AWSAssumeRoleUpdate) GetGenerateNewExternalIdOk() (*bool, bool) { + if o == nil || o.GenerateNewExternalId == nil { + return nil, false + } + return o.GenerateNewExternalId, true +} + +// HasGenerateNewExternalId returns a boolean if a field has been set. +func (o *AWSAssumeRoleUpdate) HasGenerateNewExternalId() bool { + return o != nil && o.GenerateNewExternalId != nil +} + +// SetGenerateNewExternalId gets a reference to the given bool and assigns it to the GenerateNewExternalId field. +func (o *AWSAssumeRoleUpdate) SetGenerateNewExternalId(v bool) { + o.GenerateNewExternalId = &v +} + +// GetRole returns the Role field value if set, zero value otherwise. +func (o *AWSAssumeRoleUpdate) GetRole() string { + if o == nil || o.Role == nil { + var ret string + return ret + } + return *o.Role +} + +// GetRoleOk returns a tuple with the Role field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AWSAssumeRoleUpdate) GetRoleOk() (*string, bool) { + if o == nil || o.Role == nil { + return nil, false + } + return o.Role, true +} + +// HasRole returns a boolean if a field has been set. +func (o *AWSAssumeRoleUpdate) HasRole() bool { + return o != nil && o.Role != nil +} + +// SetRole gets a reference to the given string and assigns it to the Role field. +func (o *AWSAssumeRoleUpdate) SetRole(v string) { + o.Role = &v +} + +// GetType returns the Type field value. +func (o *AWSAssumeRoleUpdate) GetType() AWSAssumeRoleType { + if o == nil { + var ret AWSAssumeRoleType + 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 *AWSAssumeRoleUpdate) GetTypeOk() (*AWSAssumeRoleType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AWSAssumeRoleUpdate) SetType(v AWSAssumeRoleType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSAssumeRoleUpdate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AccountId != nil { + toSerialize["account_id"] = o.AccountId + } + if o.GenerateNewExternalId != nil { + toSerialize["generate_new_external_id"] = o.GenerateNewExternalId + } + if o.Role != nil { + toSerialize["role"] = o.Role + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AWSAssumeRoleUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AccountId *string `json:"account_id,omitempty"` + GenerateNewExternalId *bool `json:"generate_new_external_id,omitempty"` + Role *string `json:"role,omitempty"` + Type *AWSAssumeRoleType `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{"account_id", "generate_new_external_id", "role", "type"}) + } else { + return err + } + + hasInvalidField := false + o.AccountId = all.AccountId + o.GenerateNewExternalId = all.GenerateNewExternalId + o.Role = all.Role + 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_aws_credentials.go b/api/datadogV2/model_aws_credentials.go new file mode 100644 index 00000000000..cfe6e6275e2 --- /dev/null +++ b/api/datadogV2/model_aws_credentials.go @@ -0,0 +1,73 @@ +// 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" +) + +// AWSCredentials - The definition of `AWSCredentials` object. +type AWSCredentials struct { + AWSAssumeRole *AWSAssumeRole + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// AWSAssumeRoleAsAWSCredentials is a convenience function that returns AWSAssumeRole wrapped in AWSCredentials. +func AWSAssumeRoleAsAWSCredentials(v *AWSAssumeRole) AWSCredentials { + return AWSCredentials{AWSAssumeRole: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *AWSCredentials) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into AWSAssumeRole + err = datadog.Unmarshal(data, &obj.AWSAssumeRole) + if err == nil { + if obj.AWSAssumeRole != nil && obj.AWSAssumeRole.UnparsedObject == nil { + jsonAWSAssumeRole, _ := datadog.Marshal(obj.AWSAssumeRole) + if string(jsonAWSAssumeRole) == "{}" { // empty struct + obj.AWSAssumeRole = nil + } else { + match++ + } + } else { + obj.AWSAssumeRole = nil + } + } else { + obj.AWSAssumeRole = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.AWSAssumeRole = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj AWSCredentials) MarshalJSON() ([]byte, error) { + if obj.AWSAssumeRole != nil { + return datadog.Marshal(&obj.AWSAssumeRole) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *AWSCredentials) GetActualInstance() interface{} { + if obj.AWSAssumeRole != nil { + return obj.AWSAssumeRole + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_aws_credentials_update.go b/api/datadogV2/model_aws_credentials_update.go new file mode 100644 index 00000000000..603ed90fe2b --- /dev/null +++ b/api/datadogV2/model_aws_credentials_update.go @@ -0,0 +1,73 @@ +// 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" +) + +// AWSCredentialsUpdate - The definition of `AWSCredentialsUpdate` object. +type AWSCredentialsUpdate struct { + AWSAssumeRoleUpdate *AWSAssumeRoleUpdate + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// AWSAssumeRoleUpdateAsAWSCredentialsUpdate is a convenience function that returns AWSAssumeRoleUpdate wrapped in AWSCredentialsUpdate. +func AWSAssumeRoleUpdateAsAWSCredentialsUpdate(v *AWSAssumeRoleUpdate) AWSCredentialsUpdate { + return AWSCredentialsUpdate{AWSAssumeRoleUpdate: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *AWSCredentialsUpdate) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into AWSAssumeRoleUpdate + err = datadog.Unmarshal(data, &obj.AWSAssumeRoleUpdate) + if err == nil { + if obj.AWSAssumeRoleUpdate != nil && obj.AWSAssumeRoleUpdate.UnparsedObject == nil { + jsonAWSAssumeRoleUpdate, _ := datadog.Marshal(obj.AWSAssumeRoleUpdate) + if string(jsonAWSAssumeRoleUpdate) == "{}" { // empty struct + obj.AWSAssumeRoleUpdate = nil + } else { + match++ + } + } else { + obj.AWSAssumeRoleUpdate = nil + } + } else { + obj.AWSAssumeRoleUpdate = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.AWSAssumeRoleUpdate = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj AWSCredentialsUpdate) MarshalJSON() ([]byte, error) { + if obj.AWSAssumeRoleUpdate != nil { + return datadog.Marshal(&obj.AWSAssumeRoleUpdate) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *AWSCredentialsUpdate) GetActualInstance() interface{} { + if obj.AWSAssumeRoleUpdate != nil { + return obj.AWSAssumeRoleUpdate + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_aws_integration.go b/api/datadogV2/model_aws_integration.go new file mode 100644 index 00000000000..795341f0562 --- /dev/null +++ b/api/datadogV2/model_aws_integration.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" +) + +// AWSIntegration The definition of `AWSIntegration` object. +type AWSIntegration struct { + // The definition of `AWSCredentials` object. + Credentials AWSCredentials `json:"credentials"` + // The definition of `AWSIntegrationType` object. + Type AWSIntegrationType `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:"-"` +} + +// NewAWSIntegration instantiates a new AWSIntegration 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 NewAWSIntegration(credentials AWSCredentials, typeVar AWSIntegrationType) *AWSIntegration { + this := AWSIntegration{} + this.Credentials = credentials + this.Type = typeVar + return &this +} + +// NewAWSIntegrationWithDefaults instantiates a new AWSIntegration 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 NewAWSIntegrationWithDefaults() *AWSIntegration { + this := AWSIntegration{} + return &this +} + +// GetCredentials returns the Credentials field value. +func (o *AWSIntegration) GetCredentials() AWSCredentials { + if o == nil { + var ret AWSCredentials + return ret + } + return o.Credentials +} + +// GetCredentialsOk returns a tuple with the Credentials field value +// and a boolean to check if the value has been set. +func (o *AWSIntegration) GetCredentialsOk() (*AWSCredentials, bool) { + if o == nil { + return nil, false + } + return &o.Credentials, true +} + +// SetCredentials sets field value. +func (o *AWSIntegration) SetCredentials(v AWSCredentials) { + o.Credentials = v +} + +// GetType returns the Type field value. +func (o *AWSIntegration) GetType() AWSIntegrationType { + if o == nil { + var ret AWSIntegrationType + 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 *AWSIntegration) GetTypeOk() (*AWSIntegrationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AWSIntegration) SetType(v AWSIntegrationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSIntegration) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["credentials"] = o.Credentials + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AWSIntegration) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Credentials *AWSCredentials `json:"credentials"` + Type *AWSIntegrationType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Credentials == nil { + return fmt.Errorf("required field credentials 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{"credentials", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Credentials = *all.Credentials + 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_aws_integration_type.go b/api/datadogV2/model_aws_integration_type.go new file mode 100644 index 00000000000..a41b349b7bb --- /dev/null +++ b/api/datadogV2/model_aws_integration_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" +) + +// AWSIntegrationType The definition of `AWSIntegrationType` object. +type AWSIntegrationType string + +// List of AWSIntegrationType. +const ( + AWSINTEGRATIONTYPE_AWS AWSIntegrationType = "AWS" +) + +var allowedAWSIntegrationTypeEnumValues = []AWSIntegrationType{ + AWSINTEGRATIONTYPE_AWS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AWSIntegrationType) GetAllowedValues() []AWSIntegrationType { + return allowedAWSIntegrationTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AWSIntegrationType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AWSIntegrationType(value) + return nil +} + +// NewAWSIntegrationTypeFromValue returns a pointer to a valid AWSIntegrationType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAWSIntegrationTypeFromValue(v string) (*AWSIntegrationType, error) { + ev := AWSIntegrationType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AWSIntegrationType: valid values are %v", v, allowedAWSIntegrationTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AWSIntegrationType) IsValid() bool { + for _, existing := range allowedAWSIntegrationTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AWSIntegrationType value. +func (v AWSIntegrationType) Ptr() *AWSIntegrationType { + return &v +} diff --git a/api/datadogV2/model_aws_integration_update.go b/api/datadogV2/model_aws_integration_update.go new file mode 100644 index 00000000000..375d5f31620 --- /dev/null +++ b/api/datadogV2/model_aws_integration_update.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" +) + +// AWSIntegrationUpdate The definition of `AWSIntegrationUpdate` object. +type AWSIntegrationUpdate struct { + // The definition of `AWSCredentialsUpdate` object. + Credentials *AWSCredentialsUpdate `json:"credentials,omitempty"` + // The definition of `AWSIntegrationType` object. + Type AWSIntegrationType `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:"-"` +} + +// NewAWSIntegrationUpdate instantiates a new AWSIntegrationUpdate 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 NewAWSIntegrationUpdate(typeVar AWSIntegrationType) *AWSIntegrationUpdate { + this := AWSIntegrationUpdate{} + this.Type = typeVar + return &this +} + +// NewAWSIntegrationUpdateWithDefaults instantiates a new AWSIntegrationUpdate 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 NewAWSIntegrationUpdateWithDefaults() *AWSIntegrationUpdate { + this := AWSIntegrationUpdate{} + return &this +} + +// GetCredentials returns the Credentials field value if set, zero value otherwise. +func (o *AWSIntegrationUpdate) GetCredentials() AWSCredentialsUpdate { + if o == nil || o.Credentials == nil { + var ret AWSCredentialsUpdate + return ret + } + return *o.Credentials +} + +// GetCredentialsOk returns a tuple with the Credentials field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AWSIntegrationUpdate) GetCredentialsOk() (*AWSCredentialsUpdate, bool) { + if o == nil || o.Credentials == nil { + return nil, false + } + return o.Credentials, true +} + +// HasCredentials returns a boolean if a field has been set. +func (o *AWSIntegrationUpdate) HasCredentials() bool { + return o != nil && o.Credentials != nil +} + +// SetCredentials gets a reference to the given AWSCredentialsUpdate and assigns it to the Credentials field. +func (o *AWSIntegrationUpdate) SetCredentials(v AWSCredentialsUpdate) { + o.Credentials = &v +} + +// GetType returns the Type field value. +func (o *AWSIntegrationUpdate) GetType() AWSIntegrationType { + if o == nil { + var ret AWSIntegrationType + 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 *AWSIntegrationUpdate) GetTypeOk() (*AWSIntegrationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AWSIntegrationUpdate) SetType(v AWSIntegrationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSIntegrationUpdate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Credentials != nil { + toSerialize["credentials"] = o.Credentials + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AWSIntegrationUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Credentials *AWSCredentialsUpdate `json:"credentials,omitempty"` + Type *AWSIntegrationType `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{"credentials", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Credentials = all.Credentials + 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_create_action_connection_request.go b/api/datadogV2/model_create_action_connection_request.go new file mode 100644 index 00000000000..792e0a3b894 --- /dev/null +++ b/api/datadogV2/model_create_action_connection_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" +) + +// CreateActionConnectionRequest Request used to create an action connection. +type CreateActionConnectionRequest struct { + // Data related to the connection. + Data ActionConnectionData `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:"-"` +} + +// NewCreateActionConnectionRequest instantiates a new CreateActionConnectionRequest 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 NewCreateActionConnectionRequest(data ActionConnectionData) *CreateActionConnectionRequest { + this := CreateActionConnectionRequest{} + this.Data = data + return &this +} + +// NewCreateActionConnectionRequestWithDefaults instantiates a new CreateActionConnectionRequest 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 NewCreateActionConnectionRequestWithDefaults() *CreateActionConnectionRequest { + this := CreateActionConnectionRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *CreateActionConnectionRequest) GetData() ActionConnectionData { + if o == nil { + var ret ActionConnectionData + 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 *CreateActionConnectionRequest) GetDataOk() (*ActionConnectionData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *CreateActionConnectionRequest) SetData(v ActionConnectionData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateActionConnectionRequest) 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 *CreateActionConnectionRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ActionConnectionData `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_create_action_connection_response.go b/api/datadogV2/model_create_action_connection_response.go new file mode 100644 index 00000000000..80cd23c61b0 --- /dev/null +++ b/api/datadogV2/model_create_action_connection_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" +) + +// CreateActionConnectionResponse The response for a created connection +type CreateActionConnectionResponse struct { + // Data related to the connection. + Data *ActionConnectionData `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{} `json:"-"` +} + +// NewCreateActionConnectionResponse instantiates a new CreateActionConnectionResponse 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 NewCreateActionConnectionResponse() *CreateActionConnectionResponse { + this := CreateActionConnectionResponse{} + return &this +} + +// NewCreateActionConnectionResponseWithDefaults instantiates a new CreateActionConnectionResponse 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 NewCreateActionConnectionResponseWithDefaults() *CreateActionConnectionResponse { + this := CreateActionConnectionResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *CreateActionConnectionResponse) GetData() ActionConnectionData { + if o == nil || o.Data == nil { + var ret ActionConnectionData + 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 *CreateActionConnectionResponse) GetDataOk() (*ActionConnectionData, 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 *CreateActionConnectionResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given ActionConnectionData and assigns it to the Data field. +func (o *CreateActionConnectionResponse) SetData(v ActionConnectionData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateActionConnectionResponse) 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 *CreateActionConnectionResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ActionConnectionData `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_get_action_connection_response.go b/api/datadogV2/model_get_action_connection_response.go new file mode 100644 index 00000000000..3dbc769d074 --- /dev/null +++ b/api/datadogV2/model_get_action_connection_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" +) + +// GetActionConnectionResponse The response for found connection +type GetActionConnectionResponse struct { + // Data related to the connection. + Data *ActionConnectionData `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{} `json:"-"` +} + +// NewGetActionConnectionResponse instantiates a new GetActionConnectionResponse 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 NewGetActionConnectionResponse() *GetActionConnectionResponse { + this := GetActionConnectionResponse{} + return &this +} + +// NewGetActionConnectionResponseWithDefaults instantiates a new GetActionConnectionResponse 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 NewGetActionConnectionResponseWithDefaults() *GetActionConnectionResponse { + this := GetActionConnectionResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *GetActionConnectionResponse) GetData() ActionConnectionData { + if o == nil || o.Data == nil { + var ret ActionConnectionData + 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 *GetActionConnectionResponse) GetDataOk() (*ActionConnectionData, 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 *GetActionConnectionResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given ActionConnectionData and assigns it to the Data field. +func (o *GetActionConnectionResponse) SetData(v ActionConnectionData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GetActionConnectionResponse) 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 *GetActionConnectionResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ActionConnectionData `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_http_body.go b/api/datadogV2/model_http_body.go new file mode 100644 index 00000000000..1e502e5f24c --- /dev/null +++ b/api/datadogV2/model_http_body.go @@ -0,0 +1,137 @@ +// 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" +) + +// HTTPBody The definition of `HTTPBody` object. +type HTTPBody struct { + // Serialized body content + Content *string `json:"content,omitempty"` + // Content type of the body + ContentType *string `json:"content_type,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{} `json:"-"` +} + +// NewHTTPBody instantiates a new HTTPBody 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 NewHTTPBody() *HTTPBody { + this := HTTPBody{} + return &this +} + +// NewHTTPBodyWithDefaults instantiates a new HTTPBody 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 NewHTTPBodyWithDefaults() *HTTPBody { + this := HTTPBody{} + return &this +} + +// GetContent returns the Content field value if set, zero value otherwise. +func (o *HTTPBody) GetContent() string { + if o == nil || o.Content == nil { + var ret string + return ret + } + return *o.Content +} + +// GetContentOk returns a tuple with the Content field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPBody) GetContentOk() (*string, bool) { + if o == nil || o.Content == nil { + return nil, false + } + return o.Content, true +} + +// HasContent returns a boolean if a field has been set. +func (o *HTTPBody) HasContent() bool { + return o != nil && o.Content != nil +} + +// SetContent gets a reference to the given string and assigns it to the Content field. +func (o *HTTPBody) SetContent(v string) { + o.Content = &v +} + +// GetContentType returns the ContentType field value if set, zero value otherwise. +func (o *HTTPBody) GetContentType() string { + if o == nil || o.ContentType == nil { + var ret string + return ret + } + return *o.ContentType +} + +// GetContentTypeOk returns a tuple with the ContentType field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPBody) GetContentTypeOk() (*string, bool) { + if o == nil || o.ContentType == nil { + return nil, false + } + return o.ContentType, true +} + +// HasContentType returns a boolean if a field has been set. +func (o *HTTPBody) HasContentType() bool { + return o != nil && o.ContentType != nil +} + +// SetContentType gets a reference to the given string and assigns it to the ContentType field. +func (o *HTTPBody) SetContentType(v string) { + o.ContentType = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HTTPBody) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Content != nil { + toSerialize["content"] = o.Content + } + if o.ContentType != nil { + toSerialize["content_type"] = o.ContentType + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HTTPBody) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Content *string `json:"content,omitempty"` + ContentType *string `json:"content_type,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{"content", "content_type"}) + } else { + return err + } + o.Content = all.Content + o.ContentType = all.ContentType + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_http_credentials.go b/api/datadogV2/model_http_credentials.go new file mode 100644 index 00000000000..b43a2da1954 --- /dev/null +++ b/api/datadogV2/model_http_credentials.go @@ -0,0 +1,73 @@ +// 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" +) + +// HTTPCredentials - The definition of `HTTPCredentials` object. +type HTTPCredentials struct { + HTTPTokenAuth *HTTPTokenAuth + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// HTTPTokenAuthAsHTTPCredentials is a convenience function that returns HTTPTokenAuth wrapped in HTTPCredentials. +func HTTPTokenAuthAsHTTPCredentials(v *HTTPTokenAuth) HTTPCredentials { + return HTTPCredentials{HTTPTokenAuth: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *HTTPCredentials) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into HTTPTokenAuth + err = datadog.Unmarshal(data, &obj.HTTPTokenAuth) + if err == nil { + if obj.HTTPTokenAuth != nil && obj.HTTPTokenAuth.UnparsedObject == nil { + jsonHTTPTokenAuth, _ := datadog.Marshal(obj.HTTPTokenAuth) + if string(jsonHTTPTokenAuth) == "{}" { // empty struct + obj.HTTPTokenAuth = nil + } else { + match++ + } + } else { + obj.HTTPTokenAuth = nil + } + } else { + obj.HTTPTokenAuth = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.HTTPTokenAuth = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj HTTPCredentials) MarshalJSON() ([]byte, error) { + if obj.HTTPTokenAuth != nil { + return datadog.Marshal(&obj.HTTPTokenAuth) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *HTTPCredentials) GetActualInstance() interface{} { + if obj.HTTPTokenAuth != nil { + return obj.HTTPTokenAuth + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_http_credentials_update.go b/api/datadogV2/model_http_credentials_update.go new file mode 100644 index 00000000000..94297296240 --- /dev/null +++ b/api/datadogV2/model_http_credentials_update.go @@ -0,0 +1,73 @@ +// 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" +) + +// HTTPCredentialsUpdate - The definition of `HTTPCredentialsUpdate` object. +type HTTPCredentialsUpdate struct { + HTTPTokenAuthUpdate *HTTPTokenAuthUpdate + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// HTTPTokenAuthUpdateAsHTTPCredentialsUpdate is a convenience function that returns HTTPTokenAuthUpdate wrapped in HTTPCredentialsUpdate. +func HTTPTokenAuthUpdateAsHTTPCredentialsUpdate(v *HTTPTokenAuthUpdate) HTTPCredentialsUpdate { + return HTTPCredentialsUpdate{HTTPTokenAuthUpdate: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *HTTPCredentialsUpdate) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into HTTPTokenAuthUpdate + err = datadog.Unmarshal(data, &obj.HTTPTokenAuthUpdate) + if err == nil { + if obj.HTTPTokenAuthUpdate != nil && obj.HTTPTokenAuthUpdate.UnparsedObject == nil { + jsonHTTPTokenAuthUpdate, _ := datadog.Marshal(obj.HTTPTokenAuthUpdate) + if string(jsonHTTPTokenAuthUpdate) == "{}" { // empty struct + obj.HTTPTokenAuthUpdate = nil + } else { + match++ + } + } else { + obj.HTTPTokenAuthUpdate = nil + } + } else { + obj.HTTPTokenAuthUpdate = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.HTTPTokenAuthUpdate = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj HTTPCredentialsUpdate) MarshalJSON() ([]byte, error) { + if obj.HTTPTokenAuthUpdate != nil { + return datadog.Marshal(&obj.HTTPTokenAuthUpdate) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *HTTPCredentialsUpdate) GetActualInstance() interface{} { + if obj.HTTPTokenAuthUpdate != nil { + return obj.HTTPTokenAuthUpdate + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_http_header.go b/api/datadogV2/model_http_header.go new file mode 100644 index 00000000000..84402aab1ab --- /dev/null +++ b/api/datadogV2/model_http_header.go @@ -0,0 +1,133 @@ +// 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" +) + +// HTTPHeader The definition of `HTTPHeader` object. +type HTTPHeader struct { + // The `HTTPHeader` `name`. + Name string `json:"name"` + // The `HTTPHeader` `value`. + Value string `json:"value"` + // 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:"-"` +} + +// NewHTTPHeader instantiates a new HTTPHeader 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 NewHTTPHeader(name string, value string) *HTTPHeader { + this := HTTPHeader{} + this.Name = name + this.Value = value + return &this +} + +// NewHTTPHeaderWithDefaults instantiates a new HTTPHeader 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 NewHTTPHeaderWithDefaults() *HTTPHeader { + this := HTTPHeader{} + return &this +} + +// GetName returns the Name field value. +func (o *HTTPHeader) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *HTTPHeader) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *HTTPHeader) SetName(v string) { + o.Name = v +} + +// GetValue returns the Value field value. +func (o *HTTPHeader) GetValue() string { + if o == nil { + var ret string + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *HTTPHeader) GetValueOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *HTTPHeader) SetValue(v string) { + o.Value = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HTTPHeader) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["name"] = o.Name + toSerialize["value"] = o.Value + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HTTPHeader) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name"` + Value *string `json:"value"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"name", "value"}) + } else { + return err + } + o.Name = *all.Name + o.Value = *all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_http_header_update.go b/api/datadogV2/model_http_header_update.go new file mode 100644 index 00000000000..e44a2cef497 --- /dev/null +++ b/api/datadogV2/model_http_header_update.go @@ -0,0 +1,171 @@ +// 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" +) + +// HTTPHeaderUpdate The definition of `HTTPHeaderUpdate` object. +type HTTPHeaderUpdate struct { + // Should the header be deleted. + Deleted *bool `json:"deleted,omitempty"` + // The `HTTPHeaderUpdate` `name`. + Name string `json:"name"` + // The `HTTPHeaderUpdate` `value`. + Value *string `json:"value,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{} `json:"-"` +} + +// NewHTTPHeaderUpdate instantiates a new HTTPHeaderUpdate 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 NewHTTPHeaderUpdate(name string) *HTTPHeaderUpdate { + this := HTTPHeaderUpdate{} + this.Name = name + return &this +} + +// NewHTTPHeaderUpdateWithDefaults instantiates a new HTTPHeaderUpdate 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 NewHTTPHeaderUpdateWithDefaults() *HTTPHeaderUpdate { + this := HTTPHeaderUpdate{} + return &this +} + +// GetDeleted returns the Deleted field value if set, zero value otherwise. +func (o *HTTPHeaderUpdate) GetDeleted() bool { + if o == nil || o.Deleted == nil { + var ret bool + return ret + } + return *o.Deleted +} + +// GetDeletedOk returns a tuple with the Deleted field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPHeaderUpdate) GetDeletedOk() (*bool, bool) { + if o == nil || o.Deleted == nil { + return nil, false + } + return o.Deleted, true +} + +// HasDeleted returns a boolean if a field has been set. +func (o *HTTPHeaderUpdate) HasDeleted() bool { + return o != nil && o.Deleted != nil +} + +// SetDeleted gets a reference to the given bool and assigns it to the Deleted field. +func (o *HTTPHeaderUpdate) SetDeleted(v bool) { + o.Deleted = &v +} + +// GetName returns the Name field value. +func (o *HTTPHeaderUpdate) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *HTTPHeaderUpdate) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *HTTPHeaderUpdate) SetName(v string) { + o.Name = v +} + +// GetValue returns the Value field value if set, zero value otherwise. +func (o *HTTPHeaderUpdate) GetValue() string { + if o == nil || o.Value == nil { + var ret string + return ret + } + return *o.Value +} + +// GetValueOk returns a tuple with the Value field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPHeaderUpdate) GetValueOk() (*string, bool) { + if o == nil || o.Value == nil { + return nil, false + } + return o.Value, true +} + +// HasValue returns a boolean if a field has been set. +func (o *HTTPHeaderUpdate) HasValue() bool { + return o != nil && o.Value != nil +} + +// SetValue gets a reference to the given string and assigns it to the Value field. +func (o *HTTPHeaderUpdate) SetValue(v string) { + o.Value = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HTTPHeaderUpdate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Deleted != nil { + toSerialize["deleted"] = o.Deleted + } + toSerialize["name"] = o.Name + if o.Value != nil { + toSerialize["value"] = o.Value + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HTTPHeaderUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Deleted *bool `json:"deleted,omitempty"` + Name *string `json:"name"` + Value *string `json:"value,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"deleted", "name", "value"}) + } else { + return err + } + o.Deleted = all.Deleted + o.Name = *all.Name + o.Value = all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_http_integration.go b/api/datadogV2/model_http_integration.go new file mode 100644 index 00000000000..7e9fbb0ca92 --- /dev/null +++ b/api/datadogV2/model_http_integration.go @@ -0,0 +1,175 @@ +// 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" +) + +// HTTPIntegration The definition of `HTTPIntegration` object. +type HTTPIntegration struct { + // Base HTTP url for the integration + BaseUrl string `json:"base_url"` + // The definition of `HTTPCredentials` object. + Credentials HTTPCredentials `json:"credentials"` + // The definition of `HTTPIntegrationType` object. + Type HTTPIntegrationType `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:"-"` +} + +// NewHTTPIntegration instantiates a new HTTPIntegration 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 NewHTTPIntegration(baseUrl string, credentials HTTPCredentials, typeVar HTTPIntegrationType) *HTTPIntegration { + this := HTTPIntegration{} + this.BaseUrl = baseUrl + this.Credentials = credentials + this.Type = typeVar + return &this +} + +// NewHTTPIntegrationWithDefaults instantiates a new HTTPIntegration 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 NewHTTPIntegrationWithDefaults() *HTTPIntegration { + this := HTTPIntegration{} + return &this +} + +// GetBaseUrl returns the BaseUrl field value. +func (o *HTTPIntegration) GetBaseUrl() string { + if o == nil { + var ret string + return ret + } + return o.BaseUrl +} + +// GetBaseUrlOk returns a tuple with the BaseUrl field value +// and a boolean to check if the value has been set. +func (o *HTTPIntegration) GetBaseUrlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.BaseUrl, true +} + +// SetBaseUrl sets field value. +func (o *HTTPIntegration) SetBaseUrl(v string) { + o.BaseUrl = v +} + +// GetCredentials returns the Credentials field value. +func (o *HTTPIntegration) GetCredentials() HTTPCredentials { + if o == nil { + var ret HTTPCredentials + return ret + } + return o.Credentials +} + +// GetCredentialsOk returns a tuple with the Credentials field value +// and a boolean to check if the value has been set. +func (o *HTTPIntegration) GetCredentialsOk() (*HTTPCredentials, bool) { + if o == nil { + return nil, false + } + return &o.Credentials, true +} + +// SetCredentials sets field value. +func (o *HTTPIntegration) SetCredentials(v HTTPCredentials) { + o.Credentials = v +} + +// GetType returns the Type field value. +func (o *HTTPIntegration) GetType() HTTPIntegrationType { + if o == nil { + var ret HTTPIntegrationType + 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 *HTTPIntegration) GetTypeOk() (*HTTPIntegrationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *HTTPIntegration) SetType(v HTTPIntegrationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HTTPIntegration) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["base_url"] = o.BaseUrl + toSerialize["credentials"] = o.Credentials + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HTTPIntegration) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + BaseUrl *string `json:"base_url"` + Credentials *HTTPCredentials `json:"credentials"` + Type *HTTPIntegrationType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.BaseUrl == nil { + return fmt.Errorf("required field base_url missing") + } + if all.Credentials == nil { + return fmt.Errorf("required field credentials 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{"base_url", "credentials", "type"}) + } else { + return err + } + + hasInvalidField := false + o.BaseUrl = *all.BaseUrl + o.Credentials = *all.Credentials + 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_http_integration_type.go b/api/datadogV2/model_http_integration_type.go new file mode 100644 index 00000000000..8e38e1cfac1 --- /dev/null +++ b/api/datadogV2/model_http_integration_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" +) + +// HTTPIntegrationType The definition of `HTTPIntegrationType` object. +type HTTPIntegrationType string + +// List of HTTPIntegrationType. +const ( + HTTPINTEGRATIONTYPE_HTTP HTTPIntegrationType = "HTTP" +) + +var allowedHTTPIntegrationTypeEnumValues = []HTTPIntegrationType{ + HTTPINTEGRATIONTYPE_HTTP, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *HTTPIntegrationType) GetAllowedValues() []HTTPIntegrationType { + return allowedHTTPIntegrationTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *HTTPIntegrationType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = HTTPIntegrationType(value) + return nil +} + +// NewHTTPIntegrationTypeFromValue returns a pointer to a valid HTTPIntegrationType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewHTTPIntegrationTypeFromValue(v string) (*HTTPIntegrationType, error) { + ev := HTTPIntegrationType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for HTTPIntegrationType: valid values are %v", v, allowedHTTPIntegrationTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v HTTPIntegrationType) IsValid() bool { + for _, existing := range allowedHTTPIntegrationTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to HTTPIntegrationType value. +func (v HTTPIntegrationType) Ptr() *HTTPIntegrationType { + return &v +} diff --git a/api/datadogV2/model_http_integration_update.go b/api/datadogV2/model_http_integration_update.go new file mode 100644 index 00000000000..2c4b4ea3f3b --- /dev/null +++ b/api/datadogV2/model_http_integration_update.go @@ -0,0 +1,181 @@ +// 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" +) + +// HTTPIntegrationUpdate The definition of `HTTPIntegrationUpdate` object. +type HTTPIntegrationUpdate struct { + // Base HTTP url for the integration + BaseUrl *string `json:"base_url,omitempty"` + // The definition of `HTTPCredentialsUpdate` object. + Credentials *HTTPCredentialsUpdate `json:"credentials,omitempty"` + // The definition of `HTTPIntegrationType` object. + Type HTTPIntegrationType `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:"-"` +} + +// NewHTTPIntegrationUpdate instantiates a new HTTPIntegrationUpdate 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 NewHTTPIntegrationUpdate(typeVar HTTPIntegrationType) *HTTPIntegrationUpdate { + this := HTTPIntegrationUpdate{} + this.Type = typeVar + return &this +} + +// NewHTTPIntegrationUpdateWithDefaults instantiates a new HTTPIntegrationUpdate 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 NewHTTPIntegrationUpdateWithDefaults() *HTTPIntegrationUpdate { + this := HTTPIntegrationUpdate{} + return &this +} + +// GetBaseUrl returns the BaseUrl field value if set, zero value otherwise. +func (o *HTTPIntegrationUpdate) GetBaseUrl() string { + if o == nil || o.BaseUrl == nil { + var ret string + return ret + } + return *o.BaseUrl +} + +// GetBaseUrlOk returns a tuple with the BaseUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPIntegrationUpdate) GetBaseUrlOk() (*string, bool) { + if o == nil || o.BaseUrl == nil { + return nil, false + } + return o.BaseUrl, true +} + +// HasBaseUrl returns a boolean if a field has been set. +func (o *HTTPIntegrationUpdate) HasBaseUrl() bool { + return o != nil && o.BaseUrl != nil +} + +// SetBaseUrl gets a reference to the given string and assigns it to the BaseUrl field. +func (o *HTTPIntegrationUpdate) SetBaseUrl(v string) { + o.BaseUrl = &v +} + +// GetCredentials returns the Credentials field value if set, zero value otherwise. +func (o *HTTPIntegrationUpdate) GetCredentials() HTTPCredentialsUpdate { + if o == nil || o.Credentials == nil { + var ret HTTPCredentialsUpdate + return ret + } + return *o.Credentials +} + +// GetCredentialsOk returns a tuple with the Credentials field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPIntegrationUpdate) GetCredentialsOk() (*HTTPCredentialsUpdate, bool) { + if o == nil || o.Credentials == nil { + return nil, false + } + return o.Credentials, true +} + +// HasCredentials returns a boolean if a field has been set. +func (o *HTTPIntegrationUpdate) HasCredentials() bool { + return o != nil && o.Credentials != nil +} + +// SetCredentials gets a reference to the given HTTPCredentialsUpdate and assigns it to the Credentials field. +func (o *HTTPIntegrationUpdate) SetCredentials(v HTTPCredentialsUpdate) { + o.Credentials = &v +} + +// GetType returns the Type field value. +func (o *HTTPIntegrationUpdate) GetType() HTTPIntegrationType { + if o == nil { + var ret HTTPIntegrationType + 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 *HTTPIntegrationUpdate) GetTypeOk() (*HTTPIntegrationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *HTTPIntegrationUpdate) SetType(v HTTPIntegrationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HTTPIntegrationUpdate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.BaseUrl != nil { + toSerialize["base_url"] = o.BaseUrl + } + if o.Credentials != nil { + toSerialize["credentials"] = o.Credentials + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HTTPIntegrationUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + BaseUrl *string `json:"base_url,omitempty"` + Credentials *HTTPCredentialsUpdate `json:"credentials,omitempty"` + Type *HTTPIntegrationType `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{"base_url", "credentials", "type"}) + } else { + return err + } + + hasInvalidField := false + o.BaseUrl = all.BaseUrl + o.Credentials = all.Credentials + 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_http_token.go b/api/datadogV2/model_http_token.go new file mode 100644 index 00000000000..d17c85046fa --- /dev/null +++ b/api/datadogV2/model_http_token.go @@ -0,0 +1,175 @@ +// 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" +) + +// HTTPToken The definition of `HTTPToken` object. +type HTTPToken struct { + // The `HTTPToken` `name`. + Name string `json:"name"` + // The definition of `TokenType` object. + Type TokenType `json:"type"` + // The `HTTPToken` `value`. + Value string `json:"value"` + // 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:"-"` +} + +// NewHTTPToken instantiates a new HTTPToken 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 NewHTTPToken(name string, typeVar TokenType, value string) *HTTPToken { + this := HTTPToken{} + this.Name = name + this.Type = typeVar + this.Value = value + return &this +} + +// NewHTTPTokenWithDefaults instantiates a new HTTPToken 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 NewHTTPTokenWithDefaults() *HTTPToken { + this := HTTPToken{} + return &this +} + +// GetName returns the Name field value. +func (o *HTTPToken) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *HTTPToken) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *HTTPToken) SetName(v string) { + o.Name = v +} + +// GetType returns the Type field value. +func (o *HTTPToken) GetType() TokenType { + if o == nil { + var ret TokenType + 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 *HTTPToken) GetTypeOk() (*TokenType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *HTTPToken) SetType(v TokenType) { + o.Type = v +} + +// GetValue returns the Value field value. +func (o *HTTPToken) GetValue() string { + if o == nil { + var ret string + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *HTTPToken) GetValueOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *HTTPToken) SetValue(v string) { + o.Value = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HTTPToken) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["name"] = o.Name + toSerialize["type"] = o.Type + toSerialize["value"] = o.Value + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HTTPToken) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name"` + Type *TokenType `json:"type"` + Value *string `json:"value"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"name", "type", "value"}) + } else { + return err + } + + hasInvalidField := false + o.Name = *all.Name + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.Value = *all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_http_token_auth.go b/api/datadogV2/model_http_token_auth.go new file mode 100644 index 00000000000..3da7a86db4c --- /dev/null +++ b/api/datadogV2/model_http_token_auth.go @@ -0,0 +1,254 @@ +// 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" +) + +// HTTPTokenAuth The definition of `HTTPTokenAuth` object. +type HTTPTokenAuth struct { + // The definition of `HTTPBody` object. + Body *HTTPBody `json:"body,omitempty"` + // The `HTTPTokenAuth` `headers`. + Headers []HTTPHeader `json:"headers,omitempty"` + // The `HTTPTokenAuth` `tokens`. + Tokens []HTTPToken `json:"tokens,omitempty"` + // The definition of `HTTPTokenAuthType` object. + Type HTTPTokenAuthType `json:"type"` + // The `HTTPTokenAuth` `url_parameters`. + UrlParameters []UrlParam `json:"url_parameters,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{} `json:"-"` +} + +// NewHTTPTokenAuth instantiates a new HTTPTokenAuth 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 NewHTTPTokenAuth(typeVar HTTPTokenAuthType) *HTTPTokenAuth { + this := HTTPTokenAuth{} + this.Type = typeVar + return &this +} + +// NewHTTPTokenAuthWithDefaults instantiates a new HTTPTokenAuth 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 NewHTTPTokenAuthWithDefaults() *HTTPTokenAuth { + this := HTTPTokenAuth{} + return &this +} + +// GetBody returns the Body field value if set, zero value otherwise. +func (o *HTTPTokenAuth) GetBody() HTTPBody { + if o == nil || o.Body == nil { + var ret HTTPBody + return ret + } + return *o.Body +} + +// GetBodyOk returns a tuple with the Body field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPTokenAuth) GetBodyOk() (*HTTPBody, bool) { + if o == nil || o.Body == nil { + return nil, false + } + return o.Body, true +} + +// HasBody returns a boolean if a field has been set. +func (o *HTTPTokenAuth) HasBody() bool { + return o != nil && o.Body != nil +} + +// SetBody gets a reference to the given HTTPBody and assigns it to the Body field. +func (o *HTTPTokenAuth) SetBody(v HTTPBody) { + o.Body = &v +} + +// GetHeaders returns the Headers field value if set, zero value otherwise. +func (o *HTTPTokenAuth) GetHeaders() []HTTPHeader { + if o == nil || o.Headers == nil { + var ret []HTTPHeader + return ret + } + return o.Headers +} + +// GetHeadersOk returns a tuple with the Headers field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPTokenAuth) GetHeadersOk() (*[]HTTPHeader, bool) { + if o == nil || o.Headers == nil { + return nil, false + } + return &o.Headers, true +} + +// HasHeaders returns a boolean if a field has been set. +func (o *HTTPTokenAuth) HasHeaders() bool { + return o != nil && o.Headers != nil +} + +// SetHeaders gets a reference to the given []HTTPHeader and assigns it to the Headers field. +func (o *HTTPTokenAuth) SetHeaders(v []HTTPHeader) { + o.Headers = v +} + +// GetTokens returns the Tokens field value if set, zero value otherwise. +func (o *HTTPTokenAuth) GetTokens() []HTTPToken { + if o == nil || o.Tokens == nil { + var ret []HTTPToken + return ret + } + return o.Tokens +} + +// GetTokensOk returns a tuple with the Tokens field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPTokenAuth) GetTokensOk() (*[]HTTPToken, bool) { + if o == nil || o.Tokens == nil { + return nil, false + } + return &o.Tokens, true +} + +// HasTokens returns a boolean if a field has been set. +func (o *HTTPTokenAuth) HasTokens() bool { + return o != nil && o.Tokens != nil +} + +// SetTokens gets a reference to the given []HTTPToken and assigns it to the Tokens field. +func (o *HTTPTokenAuth) SetTokens(v []HTTPToken) { + o.Tokens = v +} + +// GetType returns the Type field value. +func (o *HTTPTokenAuth) GetType() HTTPTokenAuthType { + if o == nil { + var ret HTTPTokenAuthType + 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 *HTTPTokenAuth) GetTypeOk() (*HTTPTokenAuthType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *HTTPTokenAuth) SetType(v HTTPTokenAuthType) { + o.Type = v +} + +// GetUrlParameters returns the UrlParameters field value if set, zero value otherwise. +func (o *HTTPTokenAuth) GetUrlParameters() []UrlParam { + if o == nil || o.UrlParameters == nil { + var ret []UrlParam + return ret + } + return o.UrlParameters +} + +// GetUrlParametersOk returns a tuple with the UrlParameters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPTokenAuth) GetUrlParametersOk() (*[]UrlParam, bool) { + if o == nil || o.UrlParameters == nil { + return nil, false + } + return &o.UrlParameters, true +} + +// HasUrlParameters returns a boolean if a field has been set. +func (o *HTTPTokenAuth) HasUrlParameters() bool { + return o != nil && o.UrlParameters != nil +} + +// SetUrlParameters gets a reference to the given []UrlParam and assigns it to the UrlParameters field. +func (o *HTTPTokenAuth) SetUrlParameters(v []UrlParam) { + o.UrlParameters = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HTTPTokenAuth) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Body != nil { + toSerialize["body"] = o.Body + } + if o.Headers != nil { + toSerialize["headers"] = o.Headers + } + if o.Tokens != nil { + toSerialize["tokens"] = o.Tokens + } + toSerialize["type"] = o.Type + if o.UrlParameters != nil { + toSerialize["url_parameters"] = o.UrlParameters + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HTTPTokenAuth) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Body *HTTPBody `json:"body,omitempty"` + Headers []HTTPHeader `json:"headers,omitempty"` + Tokens []HTTPToken `json:"tokens,omitempty"` + Type *HTTPTokenAuthType `json:"type"` + UrlParameters []UrlParam `json:"url_parameters,omitempty"` + }{} + 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{"body", "headers", "tokens", "type", "url_parameters"}) + } else { + return err + } + + hasInvalidField := false + if all.Body != nil && all.Body.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Body = all.Body + o.Headers = all.Headers + o.Tokens = all.Tokens + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.UrlParameters = all.UrlParameters + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_http_token_auth_type.go b/api/datadogV2/model_http_token_auth_type.go new file mode 100644 index 00000000000..a70eaf521bd --- /dev/null +++ b/api/datadogV2/model_http_token_auth_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" +) + +// HTTPTokenAuthType The definition of `HTTPTokenAuthType` object. +type HTTPTokenAuthType string + +// List of HTTPTokenAuthType. +const ( + HTTPTOKENAUTHTYPE_HTTPTOKENAUTH HTTPTokenAuthType = "HTTPTokenAuth" +) + +var allowedHTTPTokenAuthTypeEnumValues = []HTTPTokenAuthType{ + HTTPTOKENAUTHTYPE_HTTPTOKENAUTH, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *HTTPTokenAuthType) GetAllowedValues() []HTTPTokenAuthType { + return allowedHTTPTokenAuthTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *HTTPTokenAuthType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = HTTPTokenAuthType(value) + return nil +} + +// NewHTTPTokenAuthTypeFromValue returns a pointer to a valid HTTPTokenAuthType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewHTTPTokenAuthTypeFromValue(v string) (*HTTPTokenAuthType, error) { + ev := HTTPTokenAuthType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for HTTPTokenAuthType: valid values are %v", v, allowedHTTPTokenAuthTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v HTTPTokenAuthType) IsValid() bool { + for _, existing := range allowedHTTPTokenAuthTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to HTTPTokenAuthType value. +func (v HTTPTokenAuthType) Ptr() *HTTPTokenAuthType { + return &v +} diff --git a/api/datadogV2/model_http_token_auth_update.go b/api/datadogV2/model_http_token_auth_update.go new file mode 100644 index 00000000000..5426b857457 --- /dev/null +++ b/api/datadogV2/model_http_token_auth_update.go @@ -0,0 +1,254 @@ +// 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" +) + +// HTTPTokenAuthUpdate The definition of `HTTPTokenAuthUpdate` object. +type HTTPTokenAuthUpdate struct { + // The definition of `HTTPBody` object. + Body *HTTPBody `json:"body,omitempty"` + // The `HTTPTokenAuthUpdate` `headers`. + Headers []HTTPHeaderUpdate `json:"headers,omitempty"` + // The `HTTPTokenAuthUpdate` `tokens`. + Tokens []HTTPTokenUpdate `json:"tokens,omitempty"` + // The definition of `HTTPTokenAuthType` object. + Type HTTPTokenAuthType `json:"type"` + // The `HTTPTokenAuthUpdate` `url_parameters`. + UrlParameters []UrlParamUpdate `json:"url_parameters,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{} `json:"-"` +} + +// NewHTTPTokenAuthUpdate instantiates a new HTTPTokenAuthUpdate 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 NewHTTPTokenAuthUpdate(typeVar HTTPTokenAuthType) *HTTPTokenAuthUpdate { + this := HTTPTokenAuthUpdate{} + this.Type = typeVar + return &this +} + +// NewHTTPTokenAuthUpdateWithDefaults instantiates a new HTTPTokenAuthUpdate 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 NewHTTPTokenAuthUpdateWithDefaults() *HTTPTokenAuthUpdate { + this := HTTPTokenAuthUpdate{} + return &this +} + +// GetBody returns the Body field value if set, zero value otherwise. +func (o *HTTPTokenAuthUpdate) GetBody() HTTPBody { + if o == nil || o.Body == nil { + var ret HTTPBody + return ret + } + return *o.Body +} + +// GetBodyOk returns a tuple with the Body field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPTokenAuthUpdate) GetBodyOk() (*HTTPBody, bool) { + if o == nil || o.Body == nil { + return nil, false + } + return o.Body, true +} + +// HasBody returns a boolean if a field has been set. +func (o *HTTPTokenAuthUpdate) HasBody() bool { + return o != nil && o.Body != nil +} + +// SetBody gets a reference to the given HTTPBody and assigns it to the Body field. +func (o *HTTPTokenAuthUpdate) SetBody(v HTTPBody) { + o.Body = &v +} + +// GetHeaders returns the Headers field value if set, zero value otherwise. +func (o *HTTPTokenAuthUpdate) GetHeaders() []HTTPHeaderUpdate { + if o == nil || o.Headers == nil { + var ret []HTTPHeaderUpdate + return ret + } + return o.Headers +} + +// GetHeadersOk returns a tuple with the Headers field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPTokenAuthUpdate) GetHeadersOk() (*[]HTTPHeaderUpdate, bool) { + if o == nil || o.Headers == nil { + return nil, false + } + return &o.Headers, true +} + +// HasHeaders returns a boolean if a field has been set. +func (o *HTTPTokenAuthUpdate) HasHeaders() bool { + return o != nil && o.Headers != nil +} + +// SetHeaders gets a reference to the given []HTTPHeaderUpdate and assigns it to the Headers field. +func (o *HTTPTokenAuthUpdate) SetHeaders(v []HTTPHeaderUpdate) { + o.Headers = v +} + +// GetTokens returns the Tokens field value if set, zero value otherwise. +func (o *HTTPTokenAuthUpdate) GetTokens() []HTTPTokenUpdate { + if o == nil || o.Tokens == nil { + var ret []HTTPTokenUpdate + return ret + } + return o.Tokens +} + +// GetTokensOk returns a tuple with the Tokens field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPTokenAuthUpdate) GetTokensOk() (*[]HTTPTokenUpdate, bool) { + if o == nil || o.Tokens == nil { + return nil, false + } + return &o.Tokens, true +} + +// HasTokens returns a boolean if a field has been set. +func (o *HTTPTokenAuthUpdate) HasTokens() bool { + return o != nil && o.Tokens != nil +} + +// SetTokens gets a reference to the given []HTTPTokenUpdate and assigns it to the Tokens field. +func (o *HTTPTokenAuthUpdate) SetTokens(v []HTTPTokenUpdate) { + o.Tokens = v +} + +// GetType returns the Type field value. +func (o *HTTPTokenAuthUpdate) GetType() HTTPTokenAuthType { + if o == nil { + var ret HTTPTokenAuthType + 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 *HTTPTokenAuthUpdate) GetTypeOk() (*HTTPTokenAuthType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *HTTPTokenAuthUpdate) SetType(v HTTPTokenAuthType) { + o.Type = v +} + +// GetUrlParameters returns the UrlParameters field value if set, zero value otherwise. +func (o *HTTPTokenAuthUpdate) GetUrlParameters() []UrlParamUpdate { + if o == nil || o.UrlParameters == nil { + var ret []UrlParamUpdate + return ret + } + return o.UrlParameters +} + +// GetUrlParametersOk returns a tuple with the UrlParameters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPTokenAuthUpdate) GetUrlParametersOk() (*[]UrlParamUpdate, bool) { + if o == nil || o.UrlParameters == nil { + return nil, false + } + return &o.UrlParameters, true +} + +// HasUrlParameters returns a boolean if a field has been set. +func (o *HTTPTokenAuthUpdate) HasUrlParameters() bool { + return o != nil && o.UrlParameters != nil +} + +// SetUrlParameters gets a reference to the given []UrlParamUpdate and assigns it to the UrlParameters field. +func (o *HTTPTokenAuthUpdate) SetUrlParameters(v []UrlParamUpdate) { + o.UrlParameters = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HTTPTokenAuthUpdate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Body != nil { + toSerialize["body"] = o.Body + } + if o.Headers != nil { + toSerialize["headers"] = o.Headers + } + if o.Tokens != nil { + toSerialize["tokens"] = o.Tokens + } + toSerialize["type"] = o.Type + if o.UrlParameters != nil { + toSerialize["url_parameters"] = o.UrlParameters + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HTTPTokenAuthUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Body *HTTPBody `json:"body,omitempty"` + Headers []HTTPHeaderUpdate `json:"headers,omitempty"` + Tokens []HTTPTokenUpdate `json:"tokens,omitempty"` + Type *HTTPTokenAuthType `json:"type"` + UrlParameters []UrlParamUpdate `json:"url_parameters,omitempty"` + }{} + 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{"body", "headers", "tokens", "type", "url_parameters"}) + } else { + return err + } + + hasInvalidField := false + if all.Body != nil && all.Body.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Body = all.Body + o.Headers = all.Headers + o.Tokens = all.Tokens + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.UrlParameters = all.UrlParameters + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_http_token_update.go b/api/datadogV2/model_http_token_update.go new file mode 100644 index 00000000000..97252eeef08 --- /dev/null +++ b/api/datadogV2/model_http_token_update.go @@ -0,0 +1,210 @@ +// 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" +) + +// HTTPTokenUpdate The definition of `HTTPTokenUpdate` object. +type HTTPTokenUpdate struct { + // Should the header be deleted. + Deleted *bool `json:"deleted,omitempty"` + // The `HTTPToken` `name`. + Name string `json:"name"` + // The definition of `TokenType` object. + Type TokenType `json:"type"` + // The `HTTPToken` `value`. + Value string `json:"value"` + // 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:"-"` +} + +// NewHTTPTokenUpdate instantiates a new HTTPTokenUpdate 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 NewHTTPTokenUpdate(name string, typeVar TokenType, value string) *HTTPTokenUpdate { + this := HTTPTokenUpdate{} + this.Name = name + this.Type = typeVar + this.Value = value + return &this +} + +// NewHTTPTokenUpdateWithDefaults instantiates a new HTTPTokenUpdate 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 NewHTTPTokenUpdateWithDefaults() *HTTPTokenUpdate { + this := HTTPTokenUpdate{} + return &this +} + +// GetDeleted returns the Deleted field value if set, zero value otherwise. +func (o *HTTPTokenUpdate) GetDeleted() bool { + if o == nil || o.Deleted == nil { + var ret bool + return ret + } + return *o.Deleted +} + +// GetDeletedOk returns a tuple with the Deleted field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HTTPTokenUpdate) GetDeletedOk() (*bool, bool) { + if o == nil || o.Deleted == nil { + return nil, false + } + return o.Deleted, true +} + +// HasDeleted returns a boolean if a field has been set. +func (o *HTTPTokenUpdate) HasDeleted() bool { + return o != nil && o.Deleted != nil +} + +// SetDeleted gets a reference to the given bool and assigns it to the Deleted field. +func (o *HTTPTokenUpdate) SetDeleted(v bool) { + o.Deleted = &v +} + +// GetName returns the Name field value. +func (o *HTTPTokenUpdate) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *HTTPTokenUpdate) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *HTTPTokenUpdate) SetName(v string) { + o.Name = v +} + +// GetType returns the Type field value. +func (o *HTTPTokenUpdate) GetType() TokenType { + if o == nil { + var ret TokenType + 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 *HTTPTokenUpdate) GetTypeOk() (*TokenType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *HTTPTokenUpdate) SetType(v TokenType) { + o.Type = v +} + +// GetValue returns the Value field value. +func (o *HTTPTokenUpdate) GetValue() string { + if o == nil { + var ret string + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *HTTPTokenUpdate) GetValueOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *HTTPTokenUpdate) SetValue(v string) { + o.Value = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HTTPTokenUpdate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Deleted != nil { + toSerialize["deleted"] = o.Deleted + } + toSerialize["name"] = o.Name + toSerialize["type"] = o.Type + toSerialize["value"] = o.Value + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HTTPTokenUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Deleted *bool `json:"deleted,omitempty"` + Name *string `json:"name"` + Type *TokenType `json:"type"` + Value *string `json:"value"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"deleted", "name", "type", "value"}) + } else { + return err + } + + hasInvalidField := false + o.Deleted = all.Deleted + o.Name = *all.Name + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.Value = *all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_token_type.go b/api/datadogV2/model_token_type.go new file mode 100644 index 00000000000..3b75874f0a1 --- /dev/null +++ b/api/datadogV2/model_token_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" +) + +// TokenType The definition of `TokenType` object. +type TokenType string + +// List of TokenType. +const ( + TOKENTYPE_SECRET TokenType = "SECRET" +) + +var allowedTokenTypeEnumValues = []TokenType{ + TOKENTYPE_SECRET, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TokenType) GetAllowedValues() []TokenType { + return allowedTokenTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TokenType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TokenType(value) + return nil +} + +// NewTokenTypeFromValue returns a pointer to a valid TokenType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTokenTypeFromValue(v string) (*TokenType, error) { + ev := TokenType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TokenType: valid values are %v", v, allowedTokenTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TokenType) IsValid() bool { + for _, existing := range allowedTokenTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TokenType value. +func (v TokenType) Ptr() *TokenType { + return &v +} diff --git a/api/datadogV2/model_update_action_connection_request.go b/api/datadogV2/model_update_action_connection_request.go new file mode 100644 index 00000000000..57f6fa5a275 --- /dev/null +++ b/api/datadogV2/model_update_action_connection_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" +) + +// UpdateActionConnectionRequest Request used to update an action connection. +type UpdateActionConnectionRequest struct { + // Data related to the connection update. + Data ActionConnectionDataUpdate `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:"-"` +} + +// NewUpdateActionConnectionRequest instantiates a new UpdateActionConnectionRequest 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 NewUpdateActionConnectionRequest(data ActionConnectionDataUpdate) *UpdateActionConnectionRequest { + this := UpdateActionConnectionRequest{} + this.Data = data + return &this +} + +// NewUpdateActionConnectionRequestWithDefaults instantiates a new UpdateActionConnectionRequest 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 NewUpdateActionConnectionRequestWithDefaults() *UpdateActionConnectionRequest { + this := UpdateActionConnectionRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *UpdateActionConnectionRequest) GetData() ActionConnectionDataUpdate { + if o == nil { + var ret ActionConnectionDataUpdate + 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 *UpdateActionConnectionRequest) GetDataOk() (*ActionConnectionDataUpdate, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *UpdateActionConnectionRequest) SetData(v ActionConnectionDataUpdate) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o UpdateActionConnectionRequest) 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 *UpdateActionConnectionRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ActionConnectionDataUpdate `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_update_action_connection_response.go b/api/datadogV2/model_update_action_connection_response.go new file mode 100644 index 00000000000..461454e8f30 --- /dev/null +++ b/api/datadogV2/model_update_action_connection_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" +) + +// UpdateActionConnectionResponse The response for an updated connection. +type UpdateActionConnectionResponse struct { + // Data related to the connection. + Data *ActionConnectionData `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{} `json:"-"` +} + +// NewUpdateActionConnectionResponse instantiates a new UpdateActionConnectionResponse 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 NewUpdateActionConnectionResponse() *UpdateActionConnectionResponse { + this := UpdateActionConnectionResponse{} + return &this +} + +// NewUpdateActionConnectionResponseWithDefaults instantiates a new UpdateActionConnectionResponse 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 NewUpdateActionConnectionResponseWithDefaults() *UpdateActionConnectionResponse { + this := UpdateActionConnectionResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *UpdateActionConnectionResponse) GetData() ActionConnectionData { + if o == nil || o.Data == nil { + var ret ActionConnectionData + 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 *UpdateActionConnectionResponse) GetDataOk() (*ActionConnectionData, 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 *UpdateActionConnectionResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given ActionConnectionData and assigns it to the Data field. +func (o *UpdateActionConnectionResponse) SetData(v ActionConnectionData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o UpdateActionConnectionResponse) 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 *UpdateActionConnectionResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ActionConnectionData `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_url_param.go b/api/datadogV2/model_url_param.go new file mode 100644 index 00000000000..ab13a2bd7f6 --- /dev/null +++ b/api/datadogV2/model_url_param.go @@ -0,0 +1,133 @@ +// 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" +) + +// UrlParam The definition of `UrlParam` object. +type UrlParam struct { + // Name for tokens. + Name string `json:"name"` + // The `UrlParam` `value`. + Value string `json:"value"` + // 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:"-"` +} + +// NewUrlParam instantiates a new UrlParam 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 NewUrlParam(name string, value string) *UrlParam { + this := UrlParam{} + this.Name = name + this.Value = value + return &this +} + +// NewUrlParamWithDefaults instantiates a new UrlParam 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 NewUrlParamWithDefaults() *UrlParam { + this := UrlParam{} + return &this +} + +// GetName returns the Name field value. +func (o *UrlParam) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *UrlParam) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *UrlParam) SetName(v string) { + o.Name = v +} + +// GetValue returns the Value field value. +func (o *UrlParam) GetValue() string { + if o == nil { + var ret string + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *UrlParam) GetValueOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *UrlParam) SetValue(v string) { + o.Value = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o UrlParam) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["name"] = o.Name + toSerialize["value"] = o.Value + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *UrlParam) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name"` + Value *string `json:"value"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"name", "value"}) + } else { + return err + } + o.Name = *all.Name + o.Value = *all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_url_param_update.go b/api/datadogV2/model_url_param_update.go new file mode 100644 index 00000000000..bb0796c9ffa --- /dev/null +++ b/api/datadogV2/model_url_param_update.go @@ -0,0 +1,171 @@ +// 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" +) + +// UrlParamUpdate The definition of `UrlParamUpdate` object. +type UrlParamUpdate struct { + // Should the header be deleted. + Deleted *bool `json:"deleted,omitempty"` + // Name for tokens. + Name string `json:"name"` + // The `UrlParamUpdate` `value`. + Value *string `json:"value,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{} `json:"-"` +} + +// NewUrlParamUpdate instantiates a new UrlParamUpdate 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 NewUrlParamUpdate(name string) *UrlParamUpdate { + this := UrlParamUpdate{} + this.Name = name + return &this +} + +// NewUrlParamUpdateWithDefaults instantiates a new UrlParamUpdate 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 NewUrlParamUpdateWithDefaults() *UrlParamUpdate { + this := UrlParamUpdate{} + return &this +} + +// GetDeleted returns the Deleted field value if set, zero value otherwise. +func (o *UrlParamUpdate) GetDeleted() bool { + if o == nil || o.Deleted == nil { + var ret bool + return ret + } + return *o.Deleted +} + +// GetDeletedOk returns a tuple with the Deleted field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UrlParamUpdate) GetDeletedOk() (*bool, bool) { + if o == nil || o.Deleted == nil { + return nil, false + } + return o.Deleted, true +} + +// HasDeleted returns a boolean if a field has been set. +func (o *UrlParamUpdate) HasDeleted() bool { + return o != nil && o.Deleted != nil +} + +// SetDeleted gets a reference to the given bool and assigns it to the Deleted field. +func (o *UrlParamUpdate) SetDeleted(v bool) { + o.Deleted = &v +} + +// GetName returns the Name field value. +func (o *UrlParamUpdate) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *UrlParamUpdate) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *UrlParamUpdate) SetName(v string) { + o.Name = v +} + +// GetValue returns the Value field value if set, zero value otherwise. +func (o *UrlParamUpdate) GetValue() string { + if o == nil || o.Value == nil { + var ret string + return ret + } + return *o.Value +} + +// GetValueOk returns a tuple with the Value field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UrlParamUpdate) GetValueOk() (*string, bool) { + if o == nil || o.Value == nil { + return nil, false + } + return o.Value, true +} + +// HasValue returns a boolean if a field has been set. +func (o *UrlParamUpdate) HasValue() bool { + return o != nil && o.Value != nil +} + +// SetValue gets a reference to the given string and assigns it to the Value field. +func (o *UrlParamUpdate) SetValue(v string) { + o.Value = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o UrlParamUpdate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Deleted != nil { + toSerialize["deleted"] = o.Deleted + } + toSerialize["name"] = o.Name + if o.Value != nil { + toSerialize["value"] = o.Value + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *UrlParamUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Deleted *bool `json:"deleted,omitempty"` + Name *string `json:"name"` + Value *string `json:"value,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"deleted", "name", "value"}) + } else { + return err + } + o.Deleted = all.Deleted + o.Name = *all.Name + o.Value = all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/action-connection/CreateActionConnection.go b/examples/v2/action-connection/CreateActionConnection.go new file mode 100644 index 00000000000..f89e19510a2 --- /dev/null +++ b/examples/v2/action-connection/CreateActionConnection.go @@ -0,0 +1,47 @@ +// Create a new Action Connection returns "Successfully created Action Connection" 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.CreateActionConnectionRequest{ + Data: datadogV2.ActionConnectionData{ + Type: datadogV2.ACTIONCONNECTIONDATATYPE_ACTION_CONNECTION, + Attributes: datadogV2.ActionConnectionAttributes{ + Name: "Cassette Connection DELETE_ME", + Integration: datadogV2.ActionConnectionIntegration{ + AWSIntegration: &datadogV2.AWSIntegration{ + Type: datadogV2.AWSINTEGRATIONTYPE_AWS, + Credentials: datadogV2.AWSCredentials{ + AWSAssumeRole: &datadogV2.AWSAssumeRole{ + Type: datadogV2.AWSASSUMEROLETYPE_AWSASSUMEROLE, + Role: "MyRoleUpdated", + AccountId: "123456789123", + }}, + }}, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewActionConnectionApi(apiClient) + resp, r, err := api.CreateActionConnection(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ActionConnectionApi.CreateActionConnection`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ActionConnectionApi.CreateActionConnection`:\n%s\n", responseContent) +} diff --git a/examples/v2/action-connection/DeleteActionConnection.go b/examples/v2/action-connection/DeleteActionConnection.go new file mode 100644 index 00000000000..4815f82853b --- /dev/null +++ b/examples/v2/action-connection/DeleteActionConnection.go @@ -0,0 +1,25 @@ +// Delete an existing Action Connection returns "The resource was deleted successfully." 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewActionConnectionApi(apiClient) + r, err := api.DeleteActionConnection(ctx, "connection_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ActionConnectionApi.DeleteActionConnection`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/action-connection/DeleteActionConnection_2142905164.go b/examples/v2/action-connection/DeleteActionConnection_2142905164.go new file mode 100644 index 00000000000..0c745082591 --- /dev/null +++ b/examples/v2/action-connection/DeleteActionConnection_2142905164.go @@ -0,0 +1,28 @@ +// Delete an existing Action Connection returns "Successfully deleted Action Connection" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "action_connection" in the system + ActionConnectionDataID := os.Getenv("ACTION_CONNECTION_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewActionConnectionApi(apiClient) + r, err := api.DeleteActionConnection(ctx, ActionConnectionDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ActionConnectionApi.DeleteActionConnection`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/action-connection/GetActionConnection.go b/examples/v2/action-connection/GetActionConnection.go new file mode 100644 index 00000000000..d73c5bee4dc --- /dev/null +++ b/examples/v2/action-connection/GetActionConnection.go @@ -0,0 +1,29 @@ +// Get an existing Action Connection returns "Successfully get Action Connection" 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.NewActionConnectionApi(apiClient) + resp, r, err := api.GetActionConnection(ctx, "cb460d51-3c88-4e87-adac-d47131d0423d") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ActionConnectionApi.GetActionConnection`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ActionConnectionApi.GetActionConnection`:\n%s\n", responseContent) +} diff --git a/examples/v2/action-connection/UpdateActionConnection.go b/examples/v2/action-connection/UpdateActionConnection.go new file mode 100644 index 00000000000..3bcc7337a1c --- /dev/null +++ b/examples/v2/action-connection/UpdateActionConnection.go @@ -0,0 +1,47 @@ +// Update an existing Action Connection returns "Successfully updated Action Connection" 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.UpdateActionConnectionRequest{ + Data: datadogV2.ActionConnectionDataUpdate{ + Type: datadogV2.ACTIONCONNECTIONDATATYPE_ACTION_CONNECTION, + Attributes: datadogV2.ActionConnectionAttributesUpdate{ + Name: datadog.PtrString("Cassette Connection"), + Integration: &datadogV2.ActionConnectionIntegrationUpdate{ + AWSIntegrationUpdate: &datadogV2.AWSIntegrationUpdate{ + Type: datadogV2.AWSINTEGRATIONTYPE_AWS, + Credentials: &datadogV2.AWSCredentialsUpdate{ + AWSAssumeRoleUpdate: &datadogV2.AWSAssumeRoleUpdate{ + Type: datadogV2.AWSASSUMEROLETYPE_AWSASSUMEROLE, + Role: datadog.PtrString("MyRoleUpdated"), + AccountId: datadog.PtrString("123456789123"), + }}, + }}, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewActionConnectionApi(apiClient) + resp, r, err := api.UpdateActionConnection(ctx, "cb460d51-3c88-4e87-adac-d47131d0423d", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ActionConnectionApi.UpdateActionConnection`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ActionConnectionApi.UpdateActionConnection`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 0bd5ba3a558..7dfb20be163 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -44,6 +44,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "AuthenticationApi": reflect.ValueOf(datadogV1.NewAuthenticationApi), }, "v2": { + "ActionConnectionApi": reflect.ValueOf(datadogV2.NewActionConnectionApi), "KeyManagementApi": reflect.ValueOf(datadogV2.NewKeyManagementApi), "APIManagementApi": reflect.ValueOf(datadogV2.NewAPIManagementApi), "SpansMetricsApi": reflect.ValueOf(datadogV2.NewSpansMetricsApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..43f3dbf1ff4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-01-06T22:02:35.383Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..3b87036d8a1 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Bad_Request_response.yaml @@ -0,0 +1,28 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"integration":{"credentials":{"account_id":"1","role":"MyRoleUpdated","type":"AWSAssumeRole"},"type":"AWS"},"name":"Cassette Connection"},"type":"action_connection"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/actions/connections + response: + body: '{"errors":[{"title":"Generic Error","detail":"error creating connection: + rpc error: code = InvalidArgument desc = multiple errors: 1 error occurred:\n\t* + [error_code=8]: invalid CreateCustomConnectionRequest.Data: embedded message + failed validation | caused by: invalid CustomConnectionData.Aws: embedded message + failed validation | caused by: invalid CustomConnectionData_AwsAuthData.AssumeRole: + embedded message failed validation | caused by: invalid CustomConnectionData_AwsAuthData_AssumeRole.AccountId: + value does not match regex pattern \"^\\\\d{12}$\"\n\n"}]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Successfully_created_Action_Connection_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Successfully_created_Action_Connection_response.freeze new file mode 100644 index 00000000000..e63d0f654be --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Successfully_created_Action_Connection_response.freeze @@ -0,0 +1 @@ +2025-01-06T22:02:35.598Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Successfully_created_Action_Connection_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Successfully_created_Action_Connection_response.yaml new file mode 100644 index 00000000000..3c4cb170cce --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Create_a_new_Action_Connection_returns_Successfully_created_Action_Connection_response.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"integration":{"credentials":{"account_id":"123456789123","role":"MyRoleUpdated","type":"AWSAssumeRole"},"type":"AWS"},"name":"Cassette Connection DELETE_ME"},"type":"action_connection"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/actions/connections + response: + body: '{"data":{"id":"db41b6cb-ef93-45bd-9857-548e9474737c","type":"action_connection","attributes":{"integration":{"credentials":{"account_id":"123456789123","role":"MyRoleUpdated","external_id":"c6f62d439f14423b963e4dd4246af4a7","principal_id":"464622532012","type":"AWSAssumeRole"},"type":"AWS"},"name":"Cassette + Connection DELETE_ME"}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/actions/connections/db41b6cb-ef93-45bd-9857-548e9474737c + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..2dc54861f2f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-01-06T22:02:36.467Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..f195a501f8c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Not_Found_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: DELETE + url: https://api.datadoghq.com/api/v2/actions/connections/aaa11111-aa11-aa11-aaaa-aaaaaa111111 + response: + body: '{"errors":[{"title":"Generic Error","detail":"error deleting connection: + rpc error: code = NotFound desc = connection not found"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Successfully_deleted_Action_Connection_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Successfully_deleted_Action_Connection_response.freeze new file mode 100644 index 00000000000..0ea80a16905 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Successfully_deleted_Action_Connection_response.freeze @@ -0,0 +1 @@ +2025-01-06T22:02:36.636Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Successfully_deleted_Action_Connection_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Successfully_deleted_Action_Connection_response.yaml new file mode 100644 index 00000000000..f439c250df6 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Delete_an_existing_Action_Connection_returns_Successfully_deleted_Action_Connection_response.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"integration":{"credentials":{"account_id":"123456789123","role":"MyRole","type":"AWSAssumeRole"},"type":"AWS"},"name":"Cassette Connection DELETE"},"type":"action_connection"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/actions/connections + response: + body: '{"data":{"id":"4b60345a-85b2-4417-94b2-72a9528b4060","type":"action_connection","attributes":{"integration":{"credentials":{"account_id":"123456789123","role":"MyRole","external_id":"3bceadebe70c4df7b8ec6abb789e08c0","principal_id":"464622532012","type":"AWSAssumeRole"},"type":"AWS"},"name":"Cassette + Connection DELETE"}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/actions/connections/4b60345a-85b2-4417-94b2-72a9528b4060 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/actions/connections/4b60345a-85b2-4417-94b2-72a9528b4060 + response: + body: '{"errors":[{"title":"Generic Error","detail":"error deleting connection: + rpc error: code = NotFound desc = connection not found"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..aa65c8678f0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-01-06T22:02:37.403Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..01b93fc79f4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Bad_Request_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/actions/connections/bad-format + response: + body: '{"errors":[{"title":"Generic Error","detail":"error connectionId not a + valid UUID"}]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..b2ef949344a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-01-06T22:02:37.563Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..2e34e76689f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Not_Found_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/actions/connections/aaa11111-aa11-aa11-aaaa-aaaaaa111111 + response: + body: '{"errors":[{"title":"Generic Error","detail":"error getting connection: + rpc error: code = NotFound desc = connection not found"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Successfully_get_Action_Connection_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Successfully_get_Action_Connection_response.freeze new file mode 100644 index 00000000000..4b2a54697d5 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Successfully_get_Action_Connection_response.freeze @@ -0,0 +1 @@ +2025-01-06T22:02:37.743Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Successfully_get_Action_Connection_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Successfully_get_Action_Connection_response.yaml new file mode 100644 index 00000000000..06476ad9424 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Get_an_existing_Action_Connection_returns_Successfully_get_Action_Connection_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/actions/connections/cb460d51-3c88-4e87-adac-d47131d0423d + response: + body: '{"data":{"id":"cb460d51-3c88-4e87-adac-d47131d0423d","type":"action_connection","attributes":{"integration":{"credentials":{"account_id":"123456789123","role":"MyRoleUpdated","external_id":"909b33b1242748cfbef42f20011e2fa0","principal_id":"464622532012","type":"AWSAssumeRole"},"type":"AWS"},"name":"Cassette + Connection"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..fe27ab93ad5 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-01-06T22:02:38.001Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..e13f085d6c8 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Bad_Request_response.yaml @@ -0,0 +1,28 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"integration":{"credentials":{"account_id":"1","role":"MyRoleUpdated","type":"AWSAssumeRole"},"type":"AWS"},"name":"Cassette Connection"},"type":"action_connection"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/actions/connections/cb460d51-3c88-4e87-adac-d47131d0423d + response: + body: '{"errors":[{"title":"Generic Error","detail":"error creating connection: + rpc error: code = InvalidArgument desc = multiple errors: 1 error occurred:\n\t* + [error_code=8]: invalid UpdateCustomConnectionRequest.DataUpdate: embedded message + failed validation | caused by: invalid CustomConnectionDataUpdate.Aws: embedded + message failed validation | caused by: invalid CustomConnectionDataUpdate_AwsAuth.AssumeRole: + embedded message failed validation | caused by: invalid CustomConnectionDataUpdate_AwsAuth_AssumeRole.AccountId: + value does not match regex pattern \"^\\\\d{12}$\"\n\n"}]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..c89c4afae65 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-01-06T22:02:38.092Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..7ae53e14ae4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Not_Found_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"integration":{"credentials":{"account_id":"123456789123","role":"MyRoleUpdated","type":"AWSAssumeRole"},"type":"AWS"},"name":"Cassette Connection"},"type":"action_connection"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/actions/connections/aaa11111-aa11-aa11-aaaa-aaaaaa111111 + response: + body: '{"errors":[{"title":"Generic Error","detail":"error creating connection: + rpc error: code = NotFound desc = connection not found"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Successfully_updated_Action_Connection_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Successfully_updated_Action_Connection_response.freeze new file mode 100644 index 00000000000..b602ce06d7f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Successfully_updated_Action_Connection_response.freeze @@ -0,0 +1 @@ +2025-01-06T22:02:38.186Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Successfully_updated_Action_Connection_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Successfully_updated_Action_Connection_response.yaml new file mode 100644 index 00000000000..b03bf36edc5 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Action_Connection/Scenario_Update_an_existing_Action_Connection_returns_Successfully_updated_Action_Connection_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"integration":{"credentials":{"account_id":"123456789123","role":"MyRoleUpdated","type":"AWSAssumeRole"},"type":"AWS"},"name":"Cassette Connection"},"type":"action_connection"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/actions/connections/cb460d51-3c88-4e87-adac-d47131d0423d + response: + body: '{"data":{"id":"cb460d51-3c88-4e87-adac-d47131d0423d","type":"action_connection","attributes":{"integration":{"credentials":{"account_id":"123456789123","role":"MyRoleUpdated","external_id":"909b33b1242748cfbef42f20011e2fa0","principal_id":"464622532012","type":"AWSAssumeRole"},"type":"AWS"},"name":"Cassette + Connection"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v2/action_connection.feature b/tests/scenarios/features/v2/action_connection.feature new file mode 100644 index 00000000000..f379fc1a003 --- /dev/null +++ b/tests/scenarios/features/v2/action_connection.feature @@ -0,0 +1,96 @@ +@endpoint(action-connection) @endpoint(action-connection-v2) +Feature: Action Connection + Action connections extend your installed integrations and allow you to + take action in your third-party systems (e.g. AWS, GitLab, and Statuspage) + with Datadog’s Workflow Automation and App Builder products. Datadog’s + Integrations automatically provide authentication for Slack, Microsoft + Teams, PagerDuty, Opsgenie, JIRA, GitHub, and Statuspage. You do not need + additional connections in order to access these tools within Workflow + Automation and App Builder. We offer granular access control for editing + and resolving connections. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "ActionConnection" API + + @team:DataDog/workflow-automation-dev + Scenario: Create a new Action Connection returns "Bad Request" response + Given new "CreateActionConnection" request + And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"1"}}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/workflow-automation-dev + Scenario: Create a new Action Connection returns "Successfully created Action Connection" response + Given new "CreateActionConnection" request + And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection DELETE_ME","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"123456789123"}}}}} + When the request is sent + Then the response status is 201 Successfully created Action Connection + + @team:DataDog/workflow-automation-dev + Scenario: Delete an existing Action Connection returns "Not Found" response + Given new "DeleteActionConnection" request + And request contains "connection_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/workflow-automation-dev + Scenario: Delete an existing Action Connection returns "Successfully deleted Action Connection" response + Given there is a valid "action_connection" in the system + And new "DeleteActionConnection" request + And request contains "connection_id" parameter from "action_connection.data.id" + When the request is sent + Then the response status is 204 The resource was deleted successfully. + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: Delete an existing Action Connection returns "The resource was deleted successfully." response + Given new "DeleteActionConnection" request + And request contains "connection_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 The resource was deleted successfully. + + @team:DataDog/workflow-automation-dev + Scenario: Get an existing Action Connection returns "Bad Request" response + Given new "GetActionConnection" request + And request contains "connection_id" parameter with value "bad-format" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/workflow-automation-dev + Scenario: Get an existing Action Connection returns "Not Found" response + Given new "GetActionConnection" request + And request contains "connection_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/workflow-automation-dev + Scenario: Get an existing Action Connection returns "Successfully get Action Connection" response + Given new "GetActionConnection" request + And request contains "connection_id" parameter with value "cb460d51-3c88-4e87-adac-d47131d0423d" + When the request is sent + Then the response status is 200 Successfully get Action Connection + + @team:DataDog/workflow-automation-dev + Scenario: Update an existing Action Connection returns "Bad Request" response + Given new "UpdateActionConnection" request + And request contains "connection_id" parameter with value "cb460d51-3c88-4e87-adac-d47131d0423d" + And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"1"}}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/workflow-automation-dev + Scenario: Update an existing Action Connection returns "Not Found" response + Given new "UpdateActionConnection" request + And request contains "connection_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"123456789123"}}}}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/workflow-automation-dev + Scenario: Update an existing Action Connection returns "Successfully updated Action Connection" response + Given new "UpdateActionConnection" request + And request contains "connection_id" parameter with value "cb460d51-3c88-4e87-adac-d47131d0423d" + And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"123456789123"}}}}} + When the request is sent + Then the response status is 200 Successfully updated Action Connection diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 3c9e4279380..2af5f560d20 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -1,4 +1,16 @@ [ + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"action_connection\",\n \"attributes\": {\n \"name\": \"Cassette Connection DELETE\",\n \"integration\": {\n \"type\": \"AWS\",\n \"credentials\": {\n \"type\": \"AWSAssumeRole\",\n \"role\": \"MyRole\",\n \"account_id\": \"123456789123\"\n }\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"action_connection\" in the system", + "key": "action_connection", + "tag": "Action Connection", + "operationId": "CreateActionConnection" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 80ce197c931..03cac37723f 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1,4 +1,35 @@ { + "CreateActionConnection": { + "tag": "Action Connection", + "undo": { + "operationId": "DeleteActionConnection", + "parameters": [ + { + "name": "connection_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteActionConnection": { + "tag": "Action Connection", + "undo": { + "type": "idempotent" + } + }, + "GetActionConnection": { + "tag": "Action Connection", + "undo": { + "type": "safe" + } + }, + "UpdateActionConnection": { + "tag": "Action Connection", + "undo": { + "type": "idempotent" + } + }, "ListAPIKeys": { "tag": "Key Management", "undo": {