From d3d0c761d2ba5961d4d45a9d505e5e98b0154435 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 26 May 2026 19:38:00 +0000 Subject: [PATCH] Regenerate client from commit 6dce5e6 of spec repo --- .generator/schemas/v2/openapi.yaml | 222 +++++++++++++++++ api/datadog/configuration.go | 1 + api/datadogV2/api_aws_integration.go | 99 ++++++++ api/datadogV2/doc.go | 1 + .../model_aws_ccm_config_validation_issue.go | 143 +++++++++++ ...el_aws_ccm_config_validation_issue_code.go | 96 ++++++++ ...model_aws_ccm_config_validation_request.go | 110 +++++++++ ...cm_config_validation_request_attributes.go | 232 ++++++++++++++++++ ..._aws_ccm_config_validation_request_data.go | 148 +++++++++++ ...odel_aws_ccm_config_validation_response.go | 110 +++++++++ ...m_config_validation_response_attributes.go | 133 ++++++++++ ...aws_ccm_config_validation_response_data.go | 180 ++++++++++++++ .../model_aws_ccm_config_validation_type.go | 64 +++++ .../aws-integration/ValidateAWSCCMConfig.go | 42 ++++ .../features/v2/aws_integration.feature | 16 ++ tests/scenarios/features/v2/undo.json | 6 + 16 files changed, 1603 insertions(+) create mode 100644 api/datadogV2/model_aws_ccm_config_validation_issue.go create mode 100644 api/datadogV2/model_aws_ccm_config_validation_issue_code.go create mode 100644 api/datadogV2/model_aws_ccm_config_validation_request.go create mode 100644 api/datadogV2/model_aws_ccm_config_validation_request_attributes.go create mode 100644 api/datadogV2/model_aws_ccm_config_validation_request_data.go create mode 100644 api/datadogV2/model_aws_ccm_config_validation_response.go create mode 100644 api/datadogV2/model_aws_ccm_config_validation_response_attributes.go create mode 100644 api/datadogV2/model_aws_ccm_config_validation_response_data.go create mode 100644 api/datadogV2/model_aws_ccm_config_validation_type.go create mode 100644 examples/v2/aws-integration/ValidateAWSCCMConfig.go diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 086b5f9ef37..fe81c49912b 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -2429,6 +2429,158 @@ components: type: string x-enum-varnames: - CCM_CONFIG + AWSCcmConfigValidationIssue: + description: A single validation issue found while validating an AWS Cost and Usage Report (CUR) 2.0 configuration. + properties: + code: + $ref: "#/components/schemas/AWSCcmConfigValidationIssueCode" + description: + description: Human-readable description of the validation issue. + example: 'no CUR 2.0 export named "cost-and-usage-report" found' + type: string + required: + - code + - description + type: object + AWSCcmConfigValidationIssueCode: + description: Identifies the specific reason a Cost and Usage Report (CUR) 2.0 configuration failed validation. + enum: + - ISSUE_CODE_UNSPECIFIED + - CREDENTIAL_ERROR + - BUCKET_NAME_INVALID_GOVCLOUD + - S3_LIST_PERMISSION_MISSING + - S3_GET_PERMISSION_MISSING + - S3_BUCKET_REGION_MISMATCH + - S3_BUCKET_NOT_ACCESSIBLE + - EXPORT_LIST_PERMISSION_MISSING + - EXPORT_GET_PERMISSION_MISSING + - EXPORT_NOT_FOUND + - EXPORT_STATUS_UNHEALTHY + - TIME_GRANULARITY_INVALID + - FILE_FORMAT_INVALID + - INCLUDE_RESOURCES_DISABLED + - REFRESH_CADENCE_INVALID + - OVERWRITE_MODE_INVALID + - QUERY_STATEMENT_INVALID + example: "EXPORT_NOT_FOUND" + type: string + x-enum-varnames: + - ISSUE_CODE_UNSPECIFIED + - CREDENTIAL_ERROR + - BUCKET_NAME_INVALID_GOVCLOUD + - S3_LIST_PERMISSION_MISSING + - S3_GET_PERMISSION_MISSING + - S3_BUCKET_REGION_MISMATCH + - S3_BUCKET_NOT_ACCESSIBLE + - EXPORT_LIST_PERMISSION_MISSING + - EXPORT_GET_PERMISSION_MISSING + - EXPORT_NOT_FOUND + - EXPORT_STATUS_UNHEALTHY + - TIME_GRANULARITY_INVALID + - FILE_FORMAT_INVALID + - INCLUDE_RESOURCES_DISABLED + - REFRESH_CADENCE_INVALID + - OVERWRITE_MODE_INVALID + - QUERY_STATEMENT_INVALID + AWSCcmConfigValidationIssues: + description: List of validation issues found for the Cost and Usage Report (CUR) 2.0 configuration. Empty when the configuration is valid. + items: + $ref: "#/components/schemas/AWSCcmConfigValidationIssue" + type: array + AWSCcmConfigValidationRequest: + description: AWS CCM config validation request body. + properties: + data: + $ref: "#/components/schemas/AWSCcmConfigValidationRequestData" + required: + - data + type: object + AWSCcmConfigValidationRequestAttributes: + description: Attributes for an AWS CCM config validation request. + properties: + account_id: + description: Your AWS Account ID without dashes. + example: "123456789012" + type: string + bucket_name: + description: Name of the S3 bucket where the Cost and Usage Report is stored. + example: "billing" + type: string + bucket_region: + description: AWS region of the S3 bucket. + example: "us-east-1" + type: string + report_name: + description: Name of the Cost and Usage Report. + example: "cost-and-usage-report" + type: string + report_prefix: + description: S3 prefix where the Cost and Usage Report is stored. + example: "reports" + type: string + required: + - account_id + - bucket_name + - bucket_region + - report_name + type: object + AWSCcmConfigValidationRequestData: + description: AWS CCM config validation request data. + properties: + attributes: + $ref: "#/components/schemas/AWSCcmConfigValidationRequestAttributes" + type: + $ref: "#/components/schemas/AWSCcmConfigValidationType" + required: + - attributes + - type + type: object + AWSCcmConfigValidationResponse: + description: AWS CCM config validation response body. + properties: + data: + $ref: "#/components/schemas/AWSCcmConfigValidationResponseData" + required: + - data + type: object + AWSCcmConfigValidationResponseAttributes: + description: Attributes for an AWS CCM config validation response. + properties: + account_id: + description: Your AWS Account ID without dashes. + example: "123456789012" + type: string + issues: + $ref: "#/components/schemas/AWSCcmConfigValidationIssues" + required: + - account_id + - issues + type: object + AWSCcmConfigValidationResponseData: + description: AWS CCM config validation response data. + properties: + attributes: + $ref: "#/components/schemas/AWSCcmConfigValidationResponseAttributes" + id: + description: AWS CCM config validation resource identifier. + example: "ccm_config_validation" + type: string + type: + $ref: "#/components/schemas/AWSCcmConfigValidationType" + required: + - attributes + - id + - type + type: object + AWSCcmConfigValidationType: + default: "ccm_config_validation" + description: AWS CCM config validation resource type. + enum: + - ccm_config_validation + example: "ccm_config_validation" + type: string + x-enum-varnames: + - CCM_CONFIG_VALIDATION AWSCloudAuthPersonaMappingAttributesResponse: description: Attributes for AWS cloud authentication persona mapping response properties: @@ -120971,6 +121123,76 @@ paths: operator: OR permissions: - aws_configuration_read + /api/v2/integration/aws/validate_ccm_config: + post: + description: |- + Validate a Cloud Cost Management config for an AWS account using Cost and Usage Report + (CUR) 2.0 against Datadog's ingest requirements without persisting it. + operationId: ValidateAWSCCMConfig + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + account_id: "123456789012" + bucket_name: billing + bucket_region: us-east-1 + report_name: cost-and-usage-report + report_prefix: reports + type: ccm_config_validation + schema: + $ref: "#/components/schemas/AWSCcmConfigValidationRequest" + description: Validate a Cloud Cost Management config for an AWS account integration config. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + account_id: "123456789012" + issues: + - code: EXPORT_NOT_FOUND + description: 'no CUR 2.0 export named "cost-and-usage-report" found' + id: ccm_config_validation + type: ccm_config_validation + schema: + $ref: "#/components/schemas/AWSCcmConfigValidationResponse" + description: AWS CCM Config validation result + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + "503": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Service Unavailable + summary: Validate AWS CCM config + tags: + - AWS Integration + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read + - cloud_cost_management_write + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/integration/gcp/accounts: get: description: List all GCP STS-enabled service accounts configured in your Datadog account. diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 4c4508e28ee..948f87712d4 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -934,6 +934,7 @@ func NewConfiguration() *Configuration { "v2.DeleteAWSAccountCCMConfig": false, "v2.GetAWSAccountCCMConfig": false, "v2.UpdateAWSAccountCCMConfig": false, + "v2.ValidateAWSCCMConfig": false, "v2.CreateJiraIssueTemplate": false, "v2.DeleteJiraAccount": false, "v2.DeleteJiraIssueTemplate": false, diff --git a/api/datadogV2/api_aws_integration.go b/api/datadogV2/api_aws_integration.go index 2cc55f7d184..5769cee024a 100644 --- a/api/datadogV2/api_aws_integration.go +++ b/api/datadogV2/api_aws_integration.go @@ -1399,6 +1399,105 @@ func (a *AWSIntegrationApi) UpdateAWSAccountCCMConfig(ctx _context.Context, awsA return localVarReturnValue, localVarHTTPResponse, nil } +// ValidateAWSCCMConfig Validate AWS CCM config. +// Validate a Cloud Cost Management config for an AWS account using Cost and Usage Report +// (CUR) 2.0 against Datadog's ingest requirements without persisting it. +func (a *AWSIntegrationApi) ValidateAWSCCMConfig(ctx _context.Context, body AWSCcmConfigValidationRequest) (AWSCcmConfigValidationResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue AWSCcmConfigValidationResponse + ) + + operationId := "v2.ValidateAWSCCMConfig" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.AWSIntegrationApi.ValidateAWSCCMConfig") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/aws/validate_ccm_config" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 503 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // NewAWSIntegrationApi Returns NewAWSIntegrationApi. func NewAWSIntegrationApi(client *datadog.APIClient) *AWSIntegrationApi { return &AWSIntegrationApi{ diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index ae32f124ff4..3f15e5d54e8 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -32,6 +32,7 @@ // - [AWSIntegrationApi.ListAWSNamespaces] // - [AWSIntegrationApi.UpdateAWSAccount] // - [AWSIntegrationApi.UpdateAWSAccountCCMConfig] +// - [AWSIntegrationApi.ValidateAWSCCMConfig] // - [AWSLogsIntegrationApi.ListAWSLogsServices] // - [ActionConnectionApi.CreateActionConnection] // - [ActionConnectionApi.DeleteActionConnection] diff --git a/api/datadogV2/model_aws_ccm_config_validation_issue.go b/api/datadogV2/model_aws_ccm_config_validation_issue.go new file mode 100644 index 00000000000..325add8f553 --- /dev/null +++ b/api/datadogV2/model_aws_ccm_config_validation_issue.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" +) + +// AWSCcmConfigValidationIssue A single validation issue found while validating an AWS Cost and Usage Report (CUR) 2.0 configuration. +type AWSCcmConfigValidationIssue struct { + // Identifies the specific reason a Cost and Usage Report (CUR) 2.0 configuration failed validation. + Code AWSCcmConfigValidationIssueCode `json:"code"` + // Human-readable description of the validation issue. + Description string `json:"description"` + // 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:"-"` +} + +// NewAWSCcmConfigValidationIssue instantiates a new AWSCcmConfigValidationIssue 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 NewAWSCcmConfigValidationIssue(code AWSCcmConfigValidationIssueCode, description string) *AWSCcmConfigValidationIssue { + this := AWSCcmConfigValidationIssue{} + this.Code = code + this.Description = description + return &this +} + +// NewAWSCcmConfigValidationIssueWithDefaults instantiates a new AWSCcmConfigValidationIssue 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 NewAWSCcmConfigValidationIssueWithDefaults() *AWSCcmConfigValidationIssue { + this := AWSCcmConfigValidationIssue{} + return &this +} + +// GetCode returns the Code field value. +func (o *AWSCcmConfigValidationIssue) GetCode() AWSCcmConfigValidationIssueCode { + if o == nil { + var ret AWSCcmConfigValidationIssueCode + return ret + } + return o.Code +} + +// GetCodeOk returns a tuple with the Code field value +// and a boolean to check if the value has been set. +func (o *AWSCcmConfigValidationIssue) GetCodeOk() (*AWSCcmConfigValidationIssueCode, bool) { + if o == nil { + return nil, false + } + return &o.Code, true +} + +// SetCode sets field value. +func (o *AWSCcmConfigValidationIssue) SetCode(v AWSCcmConfigValidationIssueCode) { + o.Code = v +} + +// GetDescription returns the Description field value. +func (o *AWSCcmConfigValidationIssue) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *AWSCcmConfigValidationIssue) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *AWSCcmConfigValidationIssue) SetDescription(v string) { + o.Description = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSCcmConfigValidationIssue) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["code"] = o.Code + toSerialize["description"] = o.Description + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AWSCcmConfigValidationIssue) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Code *AWSCcmConfigValidationIssueCode `json:"code"` + Description *string `json:"description"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Code == nil { + return fmt.Errorf("required field code missing") + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"code", "description"}) + } else { + return err + } + + hasInvalidField := false + if !all.Code.IsValid() { + hasInvalidField = true + } else { + o.Code = *all.Code + } + o.Description = *all.Description + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_aws_ccm_config_validation_issue_code.go b/api/datadogV2/model_aws_ccm_config_validation_issue_code.go new file mode 100644 index 00000000000..b9a231d229d --- /dev/null +++ b/api/datadogV2/model_aws_ccm_config_validation_issue_code.go @@ -0,0 +1,96 @@ +// 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" +) + +// AWSCcmConfigValidationIssueCode Identifies the specific reason a Cost and Usage Report (CUR) 2.0 configuration failed validation. +type AWSCcmConfigValidationIssueCode string + +// List of AWSCcmConfigValidationIssueCode. +const ( + AWSCCMCONFIGVALIDATIONISSUECODE_ISSUE_CODE_UNSPECIFIED AWSCcmConfigValidationIssueCode = "ISSUE_CODE_UNSPECIFIED" + AWSCCMCONFIGVALIDATIONISSUECODE_CREDENTIAL_ERROR AWSCcmConfigValidationIssueCode = "CREDENTIAL_ERROR" + AWSCCMCONFIGVALIDATIONISSUECODE_BUCKET_NAME_INVALID_GOVCLOUD AWSCcmConfigValidationIssueCode = "BUCKET_NAME_INVALID_GOVCLOUD" + AWSCCMCONFIGVALIDATIONISSUECODE_S3_LIST_PERMISSION_MISSING AWSCcmConfigValidationIssueCode = "S3_LIST_PERMISSION_MISSING" + AWSCCMCONFIGVALIDATIONISSUECODE_S3_GET_PERMISSION_MISSING AWSCcmConfigValidationIssueCode = "S3_GET_PERMISSION_MISSING" + AWSCCMCONFIGVALIDATIONISSUECODE_S3_BUCKET_REGION_MISMATCH AWSCcmConfigValidationIssueCode = "S3_BUCKET_REGION_MISMATCH" + AWSCCMCONFIGVALIDATIONISSUECODE_S3_BUCKET_NOT_ACCESSIBLE AWSCcmConfigValidationIssueCode = "S3_BUCKET_NOT_ACCESSIBLE" + AWSCCMCONFIGVALIDATIONISSUECODE_EXPORT_LIST_PERMISSION_MISSING AWSCcmConfigValidationIssueCode = "EXPORT_LIST_PERMISSION_MISSING" + AWSCCMCONFIGVALIDATIONISSUECODE_EXPORT_GET_PERMISSION_MISSING AWSCcmConfigValidationIssueCode = "EXPORT_GET_PERMISSION_MISSING" + AWSCCMCONFIGVALIDATIONISSUECODE_EXPORT_NOT_FOUND AWSCcmConfigValidationIssueCode = "EXPORT_NOT_FOUND" + AWSCCMCONFIGVALIDATIONISSUECODE_EXPORT_STATUS_UNHEALTHY AWSCcmConfigValidationIssueCode = "EXPORT_STATUS_UNHEALTHY" + AWSCCMCONFIGVALIDATIONISSUECODE_TIME_GRANULARITY_INVALID AWSCcmConfigValidationIssueCode = "TIME_GRANULARITY_INVALID" + AWSCCMCONFIGVALIDATIONISSUECODE_FILE_FORMAT_INVALID AWSCcmConfigValidationIssueCode = "FILE_FORMAT_INVALID" + AWSCCMCONFIGVALIDATIONISSUECODE_INCLUDE_RESOURCES_DISABLED AWSCcmConfigValidationIssueCode = "INCLUDE_RESOURCES_DISABLED" + AWSCCMCONFIGVALIDATIONISSUECODE_REFRESH_CADENCE_INVALID AWSCcmConfigValidationIssueCode = "REFRESH_CADENCE_INVALID" + AWSCCMCONFIGVALIDATIONISSUECODE_OVERWRITE_MODE_INVALID AWSCcmConfigValidationIssueCode = "OVERWRITE_MODE_INVALID" + AWSCCMCONFIGVALIDATIONISSUECODE_QUERY_STATEMENT_INVALID AWSCcmConfigValidationIssueCode = "QUERY_STATEMENT_INVALID" +) + +var allowedAWSCcmConfigValidationIssueCodeEnumValues = []AWSCcmConfigValidationIssueCode{ + AWSCCMCONFIGVALIDATIONISSUECODE_ISSUE_CODE_UNSPECIFIED, + AWSCCMCONFIGVALIDATIONISSUECODE_CREDENTIAL_ERROR, + AWSCCMCONFIGVALIDATIONISSUECODE_BUCKET_NAME_INVALID_GOVCLOUD, + AWSCCMCONFIGVALIDATIONISSUECODE_S3_LIST_PERMISSION_MISSING, + AWSCCMCONFIGVALIDATIONISSUECODE_S3_GET_PERMISSION_MISSING, + AWSCCMCONFIGVALIDATIONISSUECODE_S3_BUCKET_REGION_MISMATCH, + AWSCCMCONFIGVALIDATIONISSUECODE_S3_BUCKET_NOT_ACCESSIBLE, + AWSCCMCONFIGVALIDATIONISSUECODE_EXPORT_LIST_PERMISSION_MISSING, + AWSCCMCONFIGVALIDATIONISSUECODE_EXPORT_GET_PERMISSION_MISSING, + AWSCCMCONFIGVALIDATIONISSUECODE_EXPORT_NOT_FOUND, + AWSCCMCONFIGVALIDATIONISSUECODE_EXPORT_STATUS_UNHEALTHY, + AWSCCMCONFIGVALIDATIONISSUECODE_TIME_GRANULARITY_INVALID, + AWSCCMCONFIGVALIDATIONISSUECODE_FILE_FORMAT_INVALID, + AWSCCMCONFIGVALIDATIONISSUECODE_INCLUDE_RESOURCES_DISABLED, + AWSCCMCONFIGVALIDATIONISSUECODE_REFRESH_CADENCE_INVALID, + AWSCCMCONFIGVALIDATIONISSUECODE_OVERWRITE_MODE_INVALID, + AWSCCMCONFIGVALIDATIONISSUECODE_QUERY_STATEMENT_INVALID, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AWSCcmConfigValidationIssueCode) GetAllowedValues() []AWSCcmConfigValidationIssueCode { + return allowedAWSCcmConfigValidationIssueCodeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AWSCcmConfigValidationIssueCode) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AWSCcmConfigValidationIssueCode(value) + return nil +} + +// NewAWSCcmConfigValidationIssueCodeFromValue returns a pointer to a valid AWSCcmConfigValidationIssueCode +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAWSCcmConfigValidationIssueCodeFromValue(v string) (*AWSCcmConfigValidationIssueCode, error) { + ev := AWSCcmConfigValidationIssueCode(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AWSCcmConfigValidationIssueCode: valid values are %v", v, allowedAWSCcmConfigValidationIssueCodeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AWSCcmConfigValidationIssueCode) IsValid() bool { + for _, existing := range allowedAWSCcmConfigValidationIssueCodeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AWSCcmConfigValidationIssueCode value. +func (v AWSCcmConfigValidationIssueCode) Ptr() *AWSCcmConfigValidationIssueCode { + return &v +} diff --git a/api/datadogV2/model_aws_ccm_config_validation_request.go b/api/datadogV2/model_aws_ccm_config_validation_request.go new file mode 100644 index 00000000000..096e16e9b25 --- /dev/null +++ b/api/datadogV2/model_aws_ccm_config_validation_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" +) + +// AWSCcmConfigValidationRequest AWS CCM config validation request body. +type AWSCcmConfigValidationRequest struct { + // AWS CCM config validation request data. + Data AWSCcmConfigValidationRequestData `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:"-"` +} + +// NewAWSCcmConfigValidationRequest instantiates a new AWSCcmConfigValidationRequest 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 NewAWSCcmConfigValidationRequest(data AWSCcmConfigValidationRequestData) *AWSCcmConfigValidationRequest { + this := AWSCcmConfigValidationRequest{} + this.Data = data + return &this +} + +// NewAWSCcmConfigValidationRequestWithDefaults instantiates a new AWSCcmConfigValidationRequest 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 NewAWSCcmConfigValidationRequestWithDefaults() *AWSCcmConfigValidationRequest { + this := AWSCcmConfigValidationRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *AWSCcmConfigValidationRequest) GetData() AWSCcmConfigValidationRequestData { + if o == nil { + var ret AWSCcmConfigValidationRequestData + 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 *AWSCcmConfigValidationRequest) GetDataOk() (*AWSCcmConfigValidationRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *AWSCcmConfigValidationRequest) SetData(v AWSCcmConfigValidationRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSCcmConfigValidationRequest) 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 *AWSCcmConfigValidationRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *AWSCcmConfigValidationRequestData `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_aws_ccm_config_validation_request_attributes.go b/api/datadogV2/model_aws_ccm_config_validation_request_attributes.go new file mode 100644 index 00000000000..f281e85e071 --- /dev/null +++ b/api/datadogV2/model_aws_ccm_config_validation_request_attributes.go @@ -0,0 +1,232 @@ +// 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" +) + +// AWSCcmConfigValidationRequestAttributes Attributes for an AWS CCM config validation request. +type AWSCcmConfigValidationRequestAttributes struct { + // Your AWS Account ID without dashes. + AccountId string `json:"account_id"` + // Name of the S3 bucket where the Cost and Usage Report is stored. + BucketName string `json:"bucket_name"` + // AWS region of the S3 bucket. + BucketRegion string `json:"bucket_region"` + // Name of the Cost and Usage Report. + ReportName string `json:"report_name"` + // S3 prefix where the Cost and Usage Report is stored. + ReportPrefix *string `json:"report_prefix,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:"-"` +} + +// NewAWSCcmConfigValidationRequestAttributes instantiates a new AWSCcmConfigValidationRequestAttributes 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 NewAWSCcmConfigValidationRequestAttributes(accountId string, bucketName string, bucketRegion string, reportName string) *AWSCcmConfigValidationRequestAttributes { + this := AWSCcmConfigValidationRequestAttributes{} + this.AccountId = accountId + this.BucketName = bucketName + this.BucketRegion = bucketRegion + this.ReportName = reportName + return &this +} + +// NewAWSCcmConfigValidationRequestAttributesWithDefaults instantiates a new AWSCcmConfigValidationRequestAttributes 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 NewAWSCcmConfigValidationRequestAttributesWithDefaults() *AWSCcmConfigValidationRequestAttributes { + this := AWSCcmConfigValidationRequestAttributes{} + return &this +} + +// GetAccountId returns the AccountId field value. +func (o *AWSCcmConfigValidationRequestAttributes) 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 *AWSCcmConfigValidationRequestAttributes) GetAccountIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AccountId, true +} + +// SetAccountId sets field value. +func (o *AWSCcmConfigValidationRequestAttributes) SetAccountId(v string) { + o.AccountId = v +} + +// GetBucketName returns the BucketName field value. +func (o *AWSCcmConfigValidationRequestAttributes) GetBucketName() string { + if o == nil { + var ret string + return ret + } + return o.BucketName +} + +// GetBucketNameOk returns a tuple with the BucketName field value +// and a boolean to check if the value has been set. +func (o *AWSCcmConfigValidationRequestAttributes) GetBucketNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.BucketName, true +} + +// SetBucketName sets field value. +func (o *AWSCcmConfigValidationRequestAttributes) SetBucketName(v string) { + o.BucketName = v +} + +// GetBucketRegion returns the BucketRegion field value. +func (o *AWSCcmConfigValidationRequestAttributes) GetBucketRegion() string { + if o == nil { + var ret string + return ret + } + return o.BucketRegion +} + +// GetBucketRegionOk returns a tuple with the BucketRegion field value +// and a boolean to check if the value has been set. +func (o *AWSCcmConfigValidationRequestAttributes) GetBucketRegionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.BucketRegion, true +} + +// SetBucketRegion sets field value. +func (o *AWSCcmConfigValidationRequestAttributes) SetBucketRegion(v string) { + o.BucketRegion = v +} + +// GetReportName returns the ReportName field value. +func (o *AWSCcmConfigValidationRequestAttributes) GetReportName() string { + if o == nil { + var ret string + return ret + } + return o.ReportName +} + +// GetReportNameOk returns a tuple with the ReportName field value +// and a boolean to check if the value has been set. +func (o *AWSCcmConfigValidationRequestAttributes) GetReportNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ReportName, true +} + +// SetReportName sets field value. +func (o *AWSCcmConfigValidationRequestAttributes) SetReportName(v string) { + o.ReportName = v +} + +// GetReportPrefix returns the ReportPrefix field value if set, zero value otherwise. +func (o *AWSCcmConfigValidationRequestAttributes) GetReportPrefix() string { + if o == nil || o.ReportPrefix == nil { + var ret string + return ret + } + return *o.ReportPrefix +} + +// GetReportPrefixOk returns a tuple with the ReportPrefix field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AWSCcmConfigValidationRequestAttributes) GetReportPrefixOk() (*string, bool) { + if o == nil || o.ReportPrefix == nil { + return nil, false + } + return o.ReportPrefix, true +} + +// HasReportPrefix returns a boolean if a field has been set. +func (o *AWSCcmConfigValidationRequestAttributes) HasReportPrefix() bool { + return o != nil && o.ReportPrefix != nil +} + +// SetReportPrefix gets a reference to the given string and assigns it to the ReportPrefix field. +func (o *AWSCcmConfigValidationRequestAttributes) SetReportPrefix(v string) { + o.ReportPrefix = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSCcmConfigValidationRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["account_id"] = o.AccountId + toSerialize["bucket_name"] = o.BucketName + toSerialize["bucket_region"] = o.BucketRegion + toSerialize["report_name"] = o.ReportName + if o.ReportPrefix != nil { + toSerialize["report_prefix"] = o.ReportPrefix + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AWSCcmConfigValidationRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AccountId *string `json:"account_id"` + BucketName *string `json:"bucket_name"` + BucketRegion *string `json:"bucket_region"` + ReportName *string `json:"report_name"` + ReportPrefix *string `json:"report_prefix,omitempty"` + }{} + 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.BucketName == nil { + return fmt.Errorf("required field bucket_name missing") + } + if all.BucketRegion == nil { + return fmt.Errorf("required field bucket_region missing") + } + if all.ReportName == nil { + return fmt.Errorf("required field report_name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"account_id", "bucket_name", "bucket_region", "report_name", "report_prefix"}) + } else { + return err + } + o.AccountId = *all.AccountId + o.BucketName = *all.BucketName + o.BucketRegion = *all.BucketRegion + o.ReportName = *all.ReportName + o.ReportPrefix = all.ReportPrefix + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_aws_ccm_config_validation_request_data.go b/api/datadogV2/model_aws_ccm_config_validation_request_data.go new file mode 100644 index 00000000000..08484bc9905 --- /dev/null +++ b/api/datadogV2/model_aws_ccm_config_validation_request_data.go @@ -0,0 +1,148 @@ +// 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" +) + +// AWSCcmConfigValidationRequestData AWS CCM config validation request data. +type AWSCcmConfigValidationRequestData struct { + // Attributes for an AWS CCM config validation request. + Attributes AWSCcmConfigValidationRequestAttributes `json:"attributes"` + // AWS CCM config validation resource type. + Type AWSCcmConfigValidationType `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:"-"` +} + +// NewAWSCcmConfigValidationRequestData instantiates a new AWSCcmConfigValidationRequestData 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 NewAWSCcmConfigValidationRequestData(attributes AWSCcmConfigValidationRequestAttributes, typeVar AWSCcmConfigValidationType) *AWSCcmConfigValidationRequestData { + this := AWSCcmConfigValidationRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewAWSCcmConfigValidationRequestDataWithDefaults instantiates a new AWSCcmConfigValidationRequestData 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 NewAWSCcmConfigValidationRequestDataWithDefaults() *AWSCcmConfigValidationRequestData { + this := AWSCcmConfigValidationRequestData{} + var typeVar AWSCcmConfigValidationType = AWSCCMCONFIGVALIDATIONTYPE_CCM_CONFIG_VALIDATION + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *AWSCcmConfigValidationRequestData) GetAttributes() AWSCcmConfigValidationRequestAttributes { + if o == nil { + var ret AWSCcmConfigValidationRequestAttributes + 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 *AWSCcmConfigValidationRequestData) GetAttributesOk() (*AWSCcmConfigValidationRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *AWSCcmConfigValidationRequestData) SetAttributes(v AWSCcmConfigValidationRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *AWSCcmConfigValidationRequestData) GetType() AWSCcmConfigValidationType { + if o == nil { + var ret AWSCcmConfigValidationType + 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 *AWSCcmConfigValidationRequestData) GetTypeOk() (*AWSCcmConfigValidationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AWSCcmConfigValidationRequestData) SetType(v AWSCcmConfigValidationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSCcmConfigValidationRequestData) 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 *AWSCcmConfigValidationRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *AWSCcmConfigValidationRequestAttributes `json:"attributes"` + Type *AWSCcmConfigValidationType `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_aws_ccm_config_validation_response.go b/api/datadogV2/model_aws_ccm_config_validation_response.go new file mode 100644 index 00000000000..fbc6ec62913 --- /dev/null +++ b/api/datadogV2/model_aws_ccm_config_validation_response.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" +) + +// AWSCcmConfigValidationResponse AWS CCM config validation response body. +type AWSCcmConfigValidationResponse struct { + // AWS CCM config validation response data. + Data AWSCcmConfigValidationResponseData `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:"-"` +} + +// NewAWSCcmConfigValidationResponse instantiates a new AWSCcmConfigValidationResponse 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 NewAWSCcmConfigValidationResponse(data AWSCcmConfigValidationResponseData) *AWSCcmConfigValidationResponse { + this := AWSCcmConfigValidationResponse{} + this.Data = data + return &this +} + +// NewAWSCcmConfigValidationResponseWithDefaults instantiates a new AWSCcmConfigValidationResponse 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 NewAWSCcmConfigValidationResponseWithDefaults() *AWSCcmConfigValidationResponse { + this := AWSCcmConfigValidationResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *AWSCcmConfigValidationResponse) GetData() AWSCcmConfigValidationResponseData { + if o == nil { + var ret AWSCcmConfigValidationResponseData + 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 *AWSCcmConfigValidationResponse) GetDataOk() (*AWSCcmConfigValidationResponseData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *AWSCcmConfigValidationResponse) SetData(v AWSCcmConfigValidationResponseData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSCcmConfigValidationResponse) 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 *AWSCcmConfigValidationResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *AWSCcmConfigValidationResponseData `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_aws_ccm_config_validation_response_attributes.go b/api/datadogV2/model_aws_ccm_config_validation_response_attributes.go new file mode 100644 index 00000000000..daa5f92a2b0 --- /dev/null +++ b/api/datadogV2/model_aws_ccm_config_validation_response_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" +) + +// AWSCcmConfigValidationResponseAttributes Attributes for an AWS CCM config validation response. +type AWSCcmConfigValidationResponseAttributes struct { + // Your AWS Account ID without dashes. + AccountId string `json:"account_id"` + // List of validation issues found for the Cost and Usage Report (CUR) 2.0 configuration. Empty when the configuration is valid. + Issues []AWSCcmConfigValidationIssue `json:"issues"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAWSCcmConfigValidationResponseAttributes instantiates a new AWSCcmConfigValidationResponseAttributes 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 NewAWSCcmConfigValidationResponseAttributes(accountId string, issues []AWSCcmConfigValidationIssue) *AWSCcmConfigValidationResponseAttributes { + this := AWSCcmConfigValidationResponseAttributes{} + this.AccountId = accountId + this.Issues = issues + return &this +} + +// NewAWSCcmConfigValidationResponseAttributesWithDefaults instantiates a new AWSCcmConfigValidationResponseAttributes 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 NewAWSCcmConfigValidationResponseAttributesWithDefaults() *AWSCcmConfigValidationResponseAttributes { + this := AWSCcmConfigValidationResponseAttributes{} + return &this +} + +// GetAccountId returns the AccountId field value. +func (o *AWSCcmConfigValidationResponseAttributes) 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 *AWSCcmConfigValidationResponseAttributes) GetAccountIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AccountId, true +} + +// SetAccountId sets field value. +func (o *AWSCcmConfigValidationResponseAttributes) SetAccountId(v string) { + o.AccountId = v +} + +// GetIssues returns the Issues field value. +func (o *AWSCcmConfigValidationResponseAttributes) GetIssues() []AWSCcmConfigValidationIssue { + if o == nil { + var ret []AWSCcmConfigValidationIssue + return ret + } + return o.Issues +} + +// GetIssuesOk returns a tuple with the Issues field value +// and a boolean to check if the value has been set. +func (o *AWSCcmConfigValidationResponseAttributes) GetIssuesOk() (*[]AWSCcmConfigValidationIssue, bool) { + if o == nil { + return nil, false + } + return &o.Issues, true +} + +// SetIssues sets field value. +func (o *AWSCcmConfigValidationResponseAttributes) SetIssues(v []AWSCcmConfigValidationIssue) { + o.Issues = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSCcmConfigValidationResponseAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["account_id"] = o.AccountId + toSerialize["issues"] = o.Issues + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AWSCcmConfigValidationResponseAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AccountId *string `json:"account_id"` + Issues *[]AWSCcmConfigValidationIssue `json:"issues"` + }{} + 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.Issues == nil { + return fmt.Errorf("required field issues missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"account_id", "issues"}) + } else { + return err + } + o.AccountId = *all.AccountId + o.Issues = *all.Issues + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_aws_ccm_config_validation_response_data.go b/api/datadogV2/model_aws_ccm_config_validation_response_data.go new file mode 100644 index 00000000000..02bd86765bb --- /dev/null +++ b/api/datadogV2/model_aws_ccm_config_validation_response_data.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AWSCcmConfigValidationResponseData AWS CCM config validation response data. +type AWSCcmConfigValidationResponseData struct { + // Attributes for an AWS CCM config validation response. + Attributes AWSCcmConfigValidationResponseAttributes `json:"attributes"` + // AWS CCM config validation resource identifier. + Id string `json:"id"` + // AWS CCM config validation resource type. + Type AWSCcmConfigValidationType `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:"-"` +} + +// NewAWSCcmConfigValidationResponseData instantiates a new AWSCcmConfigValidationResponseData 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 NewAWSCcmConfigValidationResponseData(attributes AWSCcmConfigValidationResponseAttributes, id string, typeVar AWSCcmConfigValidationType) *AWSCcmConfigValidationResponseData { + this := AWSCcmConfigValidationResponseData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewAWSCcmConfigValidationResponseDataWithDefaults instantiates a new AWSCcmConfigValidationResponseData 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 NewAWSCcmConfigValidationResponseDataWithDefaults() *AWSCcmConfigValidationResponseData { + this := AWSCcmConfigValidationResponseData{} + var typeVar AWSCcmConfigValidationType = AWSCCMCONFIGVALIDATIONTYPE_CCM_CONFIG_VALIDATION + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *AWSCcmConfigValidationResponseData) GetAttributes() AWSCcmConfigValidationResponseAttributes { + if o == nil { + var ret AWSCcmConfigValidationResponseAttributes + 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 *AWSCcmConfigValidationResponseData) GetAttributesOk() (*AWSCcmConfigValidationResponseAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *AWSCcmConfigValidationResponseData) SetAttributes(v AWSCcmConfigValidationResponseAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *AWSCcmConfigValidationResponseData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *AWSCcmConfigValidationResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *AWSCcmConfigValidationResponseData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *AWSCcmConfigValidationResponseData) GetType() AWSCcmConfigValidationType { + if o == nil { + var ret AWSCcmConfigValidationType + 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 *AWSCcmConfigValidationResponseData) GetTypeOk() (*AWSCcmConfigValidationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AWSCcmConfigValidationResponseData) SetType(v AWSCcmConfigValidationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AWSCcmConfigValidationResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + 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 *AWSCcmConfigValidationResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *AWSCcmConfigValidationResponseAttributes `json:"attributes"` + Id *string `json:"id"` + Type *AWSCcmConfigValidationType `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.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"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_aws_ccm_config_validation_type.go b/api/datadogV2/model_aws_ccm_config_validation_type.go new file mode 100644 index 00000000000..e5345daf408 --- /dev/null +++ b/api/datadogV2/model_aws_ccm_config_validation_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" +) + +// AWSCcmConfigValidationType AWS CCM config validation resource type. +type AWSCcmConfigValidationType string + +// List of AWSCcmConfigValidationType. +const ( + AWSCCMCONFIGVALIDATIONTYPE_CCM_CONFIG_VALIDATION AWSCcmConfigValidationType = "ccm_config_validation" +) + +var allowedAWSCcmConfigValidationTypeEnumValues = []AWSCcmConfigValidationType{ + AWSCCMCONFIGVALIDATIONTYPE_CCM_CONFIG_VALIDATION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AWSCcmConfigValidationType) GetAllowedValues() []AWSCcmConfigValidationType { + return allowedAWSCcmConfigValidationTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AWSCcmConfigValidationType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AWSCcmConfigValidationType(value) + return nil +} + +// NewAWSCcmConfigValidationTypeFromValue returns a pointer to a valid AWSCcmConfigValidationType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAWSCcmConfigValidationTypeFromValue(v string) (*AWSCcmConfigValidationType, error) { + ev := AWSCcmConfigValidationType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AWSCcmConfigValidationType: valid values are %v", v, allowedAWSCcmConfigValidationTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AWSCcmConfigValidationType) IsValid() bool { + for _, existing := range allowedAWSCcmConfigValidationTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AWSCcmConfigValidationType value. +func (v AWSCcmConfigValidationType) Ptr() *AWSCcmConfigValidationType { + return &v +} diff --git a/examples/v2/aws-integration/ValidateAWSCCMConfig.go b/examples/v2/aws-integration/ValidateAWSCCMConfig.go new file mode 100644 index 00000000000..6b3ec60a315 --- /dev/null +++ b/examples/v2/aws-integration/ValidateAWSCCMConfig.go @@ -0,0 +1,42 @@ +// Validate AWS CCM config returns "AWS CCM Config validation result" 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.AWSCcmConfigValidationRequest{ + Data: datadogV2.AWSCcmConfigValidationRequestData{ + Attributes: datadogV2.AWSCcmConfigValidationRequestAttributes{ + AccountId: "123456789012", + BucketName: "billing", + BucketRegion: "us-east-1", + ReportName: "cost-and-usage-report", + ReportPrefix: datadog.PtrString("reports"), + }, + Type: datadogV2.AWSCCMCONFIGVALIDATIONTYPE_CCM_CONFIG_VALIDATION, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ValidateAWSCCMConfig", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewAWSIntegrationApi(apiClient) + resp, r, err := api.ValidateAWSCCMConfig(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `AWSIntegrationApi.ValidateAWSCCMConfig`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `AWSIntegrationApi.ValidateAWSCCMConfig`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/aws_integration.feature b/tests/scenarios/features/v2/aws_integration.feature index 5989319f4ee..dac51bb7449 100644 --- a/tests/scenarios/features/v2/aws_integration.feature +++ b/tests/scenarios/features/v2/aws_integration.feature @@ -292,3 +292,19 @@ Feature: AWS Integration And body with value {"data": {"attributes": {"account_tags": ["key:value"], "auth_config": {"role_name": "DatadogIntegrationRole"}, "aws_account_id": "123456789012", "aws_partition": "aws", "logs_config": {"lambda_forwarder": {"lambdas": ["arn:aws:lambda:us-east-1:123456789012:function:DatadogLambdaLogForwarder"], "log_source_config": {"tag_filters": [{"source": "s3", "tags": ["test:test"]}]}, "sources": ["s3"]}}, "metrics_config": {"automute_enabled": true, "collect_cloudwatch_alarms": true, "collect_custom_metrics": true, "enabled": true, "tag_filters": [{"namespace": "AWS/EC2", "tags": ["key:value"]}]}, "resources_config": {"cloud_security_posture_management_collection": false, "extended_collection": false}, "traces_config": {}}, "type": "account"}} When the request is sent Then the response status is 404 Not Found + + @generated @skip @team:DataDog/aws-integrations + Scenario: Validate AWS CCM config returns "AWS CCM Config validation result" response + Given operation "ValidateAWSCCMConfig" enabled + And new "ValidateAWSCCMConfig" request + And body with value {"data": {"attributes": {"account_id": "123456789012", "bucket_name": "billing", "bucket_region": "us-east-1", "report_name": "cost-and-usage-report", "report_prefix": "reports"}, "type": "ccm_config_validation"}} + When the request is sent + Then the response status is 200 AWS CCM Config validation result + + @generated @skip @team:DataDog/aws-integrations + Scenario: Validate AWS CCM config returns "Bad Request" response + Given operation "ValidateAWSCCMConfig" enabled + And new "ValidateAWSCCMConfig" request + And body with value {"data": {"attributes": {"account_id": "123456789012", "bucket_name": "billing", "bucket_region": "us-east-1", "report_name": "cost-and-usage-report", "report_prefix": "reports"}, "type": "ccm_config_validation"}} + When the request is sent + Then the response status is 400 Bad Request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index a359fccfe1e..7d73e6932e6 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -3120,6 +3120,12 @@ "type": "safe" } }, + "ValidateAWSCCMConfig": { + "tag": "AWS Integration", + "undo": { + "type": "safe" + } + }, "ListGCPSTSAccounts": { "tag": "GCP Integration", "undo": {