diff --git a/.apigentools-info b/.apigentools-info index 680594d2f66..63ba03ac774 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-05-24 14:57:18.318213", - "spec_repo_commit": "a5ef3fab" + "regenerated": "2023-05-25 17:39:21.534442", + "spec_repo_commit": "328816c2" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-05-24 14:57:18.341092", - "spec_repo_commit": "a5ef3fab" + "regenerated": "2023-05-25 17:39:21.547358", + "spec_repo_commit": "328816c2" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index c9edd318194..6a2bbd9a413 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -173,6 +173,13 @@ components: required: true schema: type: string + GCPServiceAccountID: + description: Your GCP STS enabled service account's unique ID. + in: path + name: account_id + required: true + schema: + type: string IncidentAttachmentFilterQueryParameter: description: Specifies which types of attachments are included in the response. explode: false @@ -3929,6 +3936,156 @@ components: nullable: true type: array type: object + GCPSTSAccount: + description: Your Google Cloud Platform STS enabled service accounts. + properties: + attributes: + $ref: '#/components/schemas/GCPServiceAccountAttributes' + id: + description: Your service account's unique ID. + example: d18bn126-4ab5-6789-0c1d-234g6a67j89 + type: string + meta: + $ref: '#/components/schemas/GCPServiceAccountMeta' + type: + $ref: '#/components/schemas/GCPServiceAccountType' + type: object + GCPSTSDelegateAccount: + description: Datadog principal service account info. + properties: + attributes: + $ref: '#/components/schemas/GCPSTSDelegateAccountAttributes' + id: + description: The ID of the delegate service account. + example: ddgci-1a19n28hb1a812221893@datadog-gci-sts-us5-prod.iam.gserviceaccount.com + type: string + type: + $ref: '#/components/schemas/GCPSTSDelegateAccountType' + type: object + GCPSTSDelegateAccountAttributes: + description: Your delegate account attributes. + properties: + delegate_account_email: + description: Your organization's Datadog principal email address. + example: ddgci-1a19n28hb1a812221893@datadog-gci-sts-us5-prod.iam.gserviceaccount.com + type: string + type: object + GCPSTSDelegateAccountResponse: + description: Your delegate service account response data. + properties: + data: + $ref: '#/components/schemas/GCPSTSDelegateAccount' + type: object + GCPSTSDelegateAccountType: + default: gcp_sts_delegate + description: The type of account. + enum: + - gcp_sts_delegate + example: gcp_sts_delegate + type: string + x-enum-varnames: + - GCP_STS_DELEGATE + GCPSTSEnabledAccountData: + description: Object containing all your STS enabled accounts. + properties: + data: + description: Array of GCP STS enabled service accounts. + items: + $ref: '#/components/schemas/GCPSTSAccount' + type: array + type: object + GCPServiceAccount: + description: Info on your service account. + properties: + attributes: + $ref: '#/components/schemas/GCPServiceAccountAttributes' + id: + description: Your service account's unique ID. + example: d291291f-12c2-22g4-j290-123456678897 + type: string + meta: + $ref: '#/components/schemas/GCPServiceAccountMeta' + type: + $ref: '#/components/schemas/GCPServiceAccountType' + type: object + GCPServiceAccountAttributes: + description: Attributes associated with your service account. + properties: + automute: + description: Silence monitors for expected GCE instance shutdowns. + type: boolean + client_email: + description: Your service account email address. + example: datadog-service-account@test-project.iam.gserviceaccount.com + type: string + host_filters: + description: Your Host Filters. + items: + description: Host Filters + type: string + type: array + is_cspm_enabled: + description: When enabled, Datadog performs configuration checks across + your Google Cloud environment by continuously scanning every resource. + type: boolean + type: object + GCPServiceAccountCreateRequestData: + description: Data on your newly generated service account. + properties: + data: + $ref: '#/components/schemas/GCPServiceAccountData' + type: object + GCPServiceAccountData: + description: Additional metadata on your generated service account. + properties: + attributes: + $ref: '#/components/schemas/GCPServiceAccountAttributes' + type: + $ref: '#/components/schemas/GCPServiceAccountType' + type: object + GCPServiceAccountMeta: + description: Additional information related to your service account. + properties: + accessible_projects: + description: The current list of projects accessible from your service account. + items: + description: List of GCP projects. + type: string + type: array + type: object + GCPServiceAccountResponse: + description: The account creation response. + properties: + data: + $ref: '#/components/schemas/GCPServiceAccount' + type: object + GCPServiceAccountType: + default: gcp_service_account + description: The type of account. + enum: + - gcp_service_account + example: gcp_service_account + type: string + x-enum-varnames: + - GCP_SERVICE_ACCOUNT + GCPServiceAccountUpdateRequest: + description: Service account info. + properties: + data: + $ref: '#/components/schemas/GCPServiceAccountUpdateRequestData' + type: object + GCPServiceAccountUpdateRequestData: + description: Info on your newly generated service account. + properties: + attributes: + $ref: '#/components/schemas/GCPServiceAccountAttributes' + id: + description: Your service account's unique ID. + example: d291291f-12c2-22g4-j290-123456678897 + type: string + type: + $ref: '#/components/schemas/GCPServiceAccountType' + type: object GetFindingResponse: description: The expected response schema when getting a finding. properties: @@ -16844,6 +17001,154 @@ paths: x-unstable: '**Note**: This endpoint is in public beta. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/integration/gcp/accounts: + get: + description: List all GCP STS-enabled service accounts configured in your Datadog + account. + operationId: ListGCPSTSAccounts + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GCPSTSEnabledAccountData' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List all GCP STS-enabled service accounts + tags: + - GCP Integration + post: + description: Create a new entry within Datadog for your STS enabled service + account. + operationId: CreateGCPSTSAccount + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GCPServiceAccountCreateRequestData' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/GCPServiceAccountResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create a new entry for your service account + tags: + - GCP Integration + x-codegen-request-body-name: body + /api/v2/integration/gcp/accounts/{account_id}: + delete: + description: Delete an STS enabled GCP account from within Datadog. + operationId: DeleteGCPSTSAccount + parameters: + - $ref: '#/components/parameters/GCPServiceAccountID' + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete an STS enabled GCP Account + tags: + - GCP Integration + patch: + description: Update an STS enabled service account. + operationId: UpdateGCPSTSAccount + parameters: + - $ref: '#/components/parameters/GCPServiceAccountID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GCPServiceAccountUpdateRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/GCPServiceAccountResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update STS Service Account + tags: + - GCP Integration + x-codegen-request-body-name: body + /api/v2/integration/gcp/sts_delegate: + get: + description: List your Datadog-GCP STS delegate account configured in your Datadog + account. + operationId: GetGCPSTSDelegate + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GCPSTSDelegateAccountResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List delegate account + tags: + - GCP Integration + x-codegen-request-body-name: body + post: + description: Create a Datadog GCP principal. + operationId: MakeGCPSTSDelegate + requestBody: + content: + application/json: + schema: + example: {} + type: object + description: Create a delegate service account within Datadog. + required: false + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GCPSTSDelegateAccountResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create a Datadog GCP principal + tags: + - GCP Integration + x-codegen-request-body-name: body /api/v2/integration/opsgenie/services: get: description: Get a list of all services from the Datadog Opsgenie integration. @@ -24352,6 +24657,12 @@ tags: - description: Configure your Datadog Fastly integration directly through the Datadog API. name: Fastly Integration +- description: 'Configure your Datadog-Google Cloud Platform (GCP) integration directly + + through the Datadog API. Read more about the [Datadog-Google Cloud Platform integration](https://docs.datadoghq.com/integrations/google_cloud_platform).' + externalDocs: + url: https://docs.datadoghq.com/integrations/google_cloud_platform + name: GCP Integration - description: 'The IP allowlist API is used to manage the IP addresses that can access the Datadog API and web UI. It does not block diff --git a/api/datadogV2/api_gcp_integration.go b/api/datadogV2/api_gcp_integration.go new file mode 100644 index 00000000000..f0eef87adac --- /dev/null +++ b/api/datadogV2/api_gcp_integration.go @@ -0,0 +1,472 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + _context "context" + _nethttp "net/http" + _neturl "net/url" + "strings" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPIntegrationApi service type +type GCPIntegrationApi datadog.Service + +// CreateGCPSTSAccount Create a new entry for your service account. +// Create a new entry within Datadog for your STS enabled service account. +func (a *GCPIntegrationApi) CreateGCPSTSAccount(ctx _context.Context, body GCPServiceAccountCreateRequestData) (GCPServiceAccountResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue GCPServiceAccountResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GCPIntegrationApi.CreateGCPSTSAccount") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/gcp/accounts" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 409 || 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 +} + +// DeleteGCPSTSAccount Delete an STS enabled GCP Account. +// Delete an STS enabled GCP account from within Datadog. +func (a *GCPIntegrationApi) DeleteGCPSTSAccount(ctx _context.Context, accountId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GCPIntegrationApi.DeleteGCPSTSAccount") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/gcp/accounts/{account_id}" + localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", _neturl.PathEscape(datadog.ParameterToString(accountId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// GetGCPSTSDelegate List delegate account. +// List your Datadog-GCP STS delegate account configured in your Datadog account. +func (a *GCPIntegrationApi) GetGCPSTSDelegate(ctx _context.Context) (GCPSTSDelegateAccountResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GCPSTSDelegateAccountResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GCPIntegrationApi.GetGCPSTSDelegate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/gcp/sts_delegate" + + 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 == 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 +} + +// ListGCPSTSAccounts List all GCP STS-enabled service accounts. +// List all GCP STS-enabled service accounts configured in your Datadog account. +func (a *GCPIntegrationApi) ListGCPSTSAccounts(ctx _context.Context) (GCPSTSEnabledAccountData, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GCPSTSEnabledAccountData + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GCPIntegrationApi.ListGCPSTSAccounts") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/gcp/accounts" + + 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 == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// MakeGCPSTSDelegateOptionalParameters holds optional parameters for MakeGCPSTSDelegate. +type MakeGCPSTSDelegateOptionalParameters struct { + Body *interface{} +} + +// NewMakeGCPSTSDelegateOptionalParameters creates an empty struct for parameters. +func NewMakeGCPSTSDelegateOptionalParameters() *MakeGCPSTSDelegateOptionalParameters { + this := MakeGCPSTSDelegateOptionalParameters{} + return &this +} + +// WithBody sets the corresponding parameter name and returns the struct. +func (r *MakeGCPSTSDelegateOptionalParameters) WithBody(body interface{}) *MakeGCPSTSDelegateOptionalParameters { + r.Body = &body + return r +} + +// MakeGCPSTSDelegate Create a Datadog GCP principal. +// Create a Datadog GCP principal. +func (a *GCPIntegrationApi) MakeGCPSTSDelegate(ctx _context.Context, o ...MakeGCPSTSDelegateOptionalParameters) (GCPSTSDelegateAccountResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue GCPSTSDelegateAccountResponse + optionalParams MakeGCPSTSDelegateOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type MakeGCPSTSDelegateOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GCPIntegrationApi.MakeGCPSTSDelegate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/gcp/sts_delegate" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + if optionalParams.Body != nil { + localVarPostBody = &optionalParams.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 == 403 || localVarHTTPResponse.StatusCode == 409 || 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 +} + +// UpdateGCPSTSAccount Update STS Service Account. +// Update an STS enabled service account. +func (a *GCPIntegrationApi) UpdateGCPSTSAccount(ctx _context.Context, accountId string, body GCPServiceAccountUpdateRequest) (GCPServiceAccountResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue GCPServiceAccountResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GCPIntegrationApi.UpdateGCPSTSAccount") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/gcp/accounts/{account_id}" + localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", _neturl.PathEscape(datadog.ParameterToString(accountId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// NewGCPIntegrationApi Returns NewGCPIntegrationApi. +func NewGCPIntegrationApi(client *datadog.APIClient) *GCPIntegrationApi { + return &GCPIntegrationApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 2224cbcf46c..4b13b095604 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -53,6 +53,12 @@ // - [FastlyIntegrationApi.ListFastlyServices] // - [FastlyIntegrationApi.UpdateFastlyAccount] // - [FastlyIntegrationApi.UpdateFastlyService] +// - [GCPIntegrationApi.CreateGCPSTSAccount] +// - [GCPIntegrationApi.DeleteGCPSTSAccount] +// - [GCPIntegrationApi.GetGCPSTSDelegate] +// - [GCPIntegrationApi.ListGCPSTSAccounts] +// - [GCPIntegrationApi.MakeGCPSTSDelegate] +// - [GCPIntegrationApi.UpdateGCPSTSAccount] // - [IPAllowlistApi.GetIPAllowlist] // - [IPAllowlistApi.UpdateIPAllowlist] // - [IncidentServicesApi.CreateIncidentService] diff --git a/api/datadogV2/model_gcp_service_account.go b/api/datadogV2/model_gcp_service_account.go new file mode 100644 index 00000000000..d96846b090d --- /dev/null +++ b/api/datadogV2/model_gcp_service_account.go @@ -0,0 +1,241 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPServiceAccount Info on your service account. +type GCPServiceAccount struct { + // Attributes associated with your service account. + Attributes *GCPServiceAccountAttributes `json:"attributes,omitempty"` + // Your service account's unique ID. + Id *string `json:"id,omitempty"` + // Additional information related to your service account. + Meta *GCPServiceAccountMeta `json:"meta,omitempty"` + // The type of account. + Type *GCPServiceAccountType `json:"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{} +} + +// NewGCPServiceAccount instantiates a new GCPServiceAccount 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 NewGCPServiceAccount() *GCPServiceAccount { + this := GCPServiceAccount{} + var typeVar GCPServiceAccountType = GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT + this.Type = &typeVar + return &this +} + +// NewGCPServiceAccountWithDefaults instantiates a new GCPServiceAccount 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 NewGCPServiceAccountWithDefaults() *GCPServiceAccount { + this := GCPServiceAccount{} + var typeVar GCPServiceAccountType = GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GCPServiceAccount) GetAttributes() GCPServiceAccountAttributes { + if o == nil || o.Attributes == nil { + var ret GCPServiceAccountAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccount) GetAttributesOk() (*GCPServiceAccountAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *GCPServiceAccount) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given GCPServiceAccountAttributes and assigns it to the Attributes field. +func (o *GCPServiceAccount) SetAttributes(v GCPServiceAccountAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *GCPServiceAccount) 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 *GCPServiceAccount) 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 *GCPServiceAccount) 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 *GCPServiceAccount) SetId(v string) { + o.Id = &v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *GCPServiceAccount) GetMeta() GCPServiceAccountMeta { + if o == nil || o.Meta == nil { + var ret GCPServiceAccountMeta + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccount) GetMetaOk() (*GCPServiceAccountMeta, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *GCPServiceAccount) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given GCPServiceAccountMeta and assigns it to the Meta field. +func (o *GCPServiceAccount) SetMeta(v GCPServiceAccountMeta) { + o.Meta = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GCPServiceAccount) GetType() GCPServiceAccountType { + if o == nil || o.Type == nil { + var ret GCPServiceAccountType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccount) GetTypeOk() (*GCPServiceAccountType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *GCPServiceAccount) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GCPServiceAccountType and assigns it to the Type field. +func (o *GCPServiceAccount) SetType(v GCPServiceAccountType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPServiceAccount) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPServiceAccount) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Attributes *GCPServiceAccountAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Meta *GCPServiceAccountMeta `json:"meta,omitempty"` + Type *GCPServiceAccountType `json:"type,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "meta", "type"}) + } else { + return err + } + if v := all.Type; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Meta = all.Meta + o.Type = all.Type + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcp_service_account_attributes.go b/api/datadogV2/model_gcp_service_account_attributes.go new file mode 100644 index 00000000000..840723962c1 --- /dev/null +++ b/api/datadogV2/model_gcp_service_account_attributes.go @@ -0,0 +1,215 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPServiceAccountAttributes Attributes associated with your service account. +type GCPServiceAccountAttributes struct { + // Silence monitors for expected GCE instance shutdowns. + Automute *bool `json:"automute,omitempty"` + // Your service account email address. + ClientEmail *string `json:"client_email,omitempty"` + // Your Host Filters. + HostFilters []string `json:"host_filters,omitempty"` + // When enabled, Datadog performs configuration checks across your Google Cloud environment by continuously scanning every resource. + IsCspmEnabled *bool `json:"is_cspm_enabled,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{} +} + +// NewGCPServiceAccountAttributes instantiates a new GCPServiceAccountAttributes 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 NewGCPServiceAccountAttributes() *GCPServiceAccountAttributes { + this := GCPServiceAccountAttributes{} + return &this +} + +// NewGCPServiceAccountAttributesWithDefaults instantiates a new GCPServiceAccountAttributes 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 NewGCPServiceAccountAttributesWithDefaults() *GCPServiceAccountAttributes { + this := GCPServiceAccountAttributes{} + return &this +} + +// GetAutomute returns the Automute field value if set, zero value otherwise. +func (o *GCPServiceAccountAttributes) GetAutomute() bool { + if o == nil || o.Automute == nil { + var ret bool + return ret + } + return *o.Automute +} + +// GetAutomuteOk returns a tuple with the Automute field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccountAttributes) GetAutomuteOk() (*bool, bool) { + if o == nil || o.Automute == nil { + return nil, false + } + return o.Automute, true +} + +// HasAutomute returns a boolean if a field has been set. +func (o *GCPServiceAccountAttributes) HasAutomute() bool { + return o != nil && o.Automute != nil +} + +// SetAutomute gets a reference to the given bool and assigns it to the Automute field. +func (o *GCPServiceAccountAttributes) SetAutomute(v bool) { + o.Automute = &v +} + +// GetClientEmail returns the ClientEmail field value if set, zero value otherwise. +func (o *GCPServiceAccountAttributes) GetClientEmail() string { + if o == nil || o.ClientEmail == nil { + var ret string + return ret + } + return *o.ClientEmail +} + +// GetClientEmailOk returns a tuple with the ClientEmail field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccountAttributes) GetClientEmailOk() (*string, bool) { + if o == nil || o.ClientEmail == nil { + return nil, false + } + return o.ClientEmail, true +} + +// HasClientEmail returns a boolean if a field has been set. +func (o *GCPServiceAccountAttributes) HasClientEmail() bool { + return o != nil && o.ClientEmail != nil +} + +// SetClientEmail gets a reference to the given string and assigns it to the ClientEmail field. +func (o *GCPServiceAccountAttributes) SetClientEmail(v string) { + o.ClientEmail = &v +} + +// GetHostFilters returns the HostFilters field value if set, zero value otherwise. +func (o *GCPServiceAccountAttributes) GetHostFilters() []string { + if o == nil || o.HostFilters == nil { + var ret []string + return ret + } + return o.HostFilters +} + +// GetHostFiltersOk returns a tuple with the HostFilters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccountAttributes) GetHostFiltersOk() (*[]string, bool) { + if o == nil || o.HostFilters == nil { + return nil, false + } + return &o.HostFilters, true +} + +// HasHostFilters returns a boolean if a field has been set. +func (o *GCPServiceAccountAttributes) HasHostFilters() bool { + return o != nil && o.HostFilters != nil +} + +// SetHostFilters gets a reference to the given []string and assigns it to the HostFilters field. +func (o *GCPServiceAccountAttributes) SetHostFilters(v []string) { + o.HostFilters = v +} + +// GetIsCspmEnabled returns the IsCspmEnabled field value if set, zero value otherwise. +func (o *GCPServiceAccountAttributes) GetIsCspmEnabled() bool { + if o == nil || o.IsCspmEnabled == nil { + var ret bool + return ret + } + return *o.IsCspmEnabled +} + +// GetIsCspmEnabledOk returns a tuple with the IsCspmEnabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccountAttributes) GetIsCspmEnabledOk() (*bool, bool) { + if o == nil || o.IsCspmEnabled == nil { + return nil, false + } + return o.IsCspmEnabled, true +} + +// HasIsCspmEnabled returns a boolean if a field has been set. +func (o *GCPServiceAccountAttributes) HasIsCspmEnabled() bool { + return o != nil && o.IsCspmEnabled != nil +} + +// SetIsCspmEnabled gets a reference to the given bool and assigns it to the IsCspmEnabled field. +func (o *GCPServiceAccountAttributes) SetIsCspmEnabled(v bool) { + o.IsCspmEnabled = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPServiceAccountAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Automute != nil { + toSerialize["automute"] = o.Automute + } + if o.ClientEmail != nil { + toSerialize["client_email"] = o.ClientEmail + } + if o.HostFilters != nil { + toSerialize["host_filters"] = o.HostFilters + } + if o.IsCspmEnabled != nil { + toSerialize["is_cspm_enabled"] = o.IsCspmEnabled + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPServiceAccountAttributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Automute *bool `json:"automute,omitempty"` + ClientEmail *string `json:"client_email,omitempty"` + HostFilters []string `json:"host_filters,omitempty"` + IsCspmEnabled *bool `json:"is_cspm_enabled,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"automute", "client_email", "host_filters", "is_cspm_enabled"}) + } else { + return err + } + o.Automute = all.Automute + o.ClientEmail = all.ClientEmail + o.HostFilters = all.HostFilters + o.IsCspmEnabled = all.IsCspmEnabled + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcp_service_account_create_request_data.go b/api/datadogV2/model_gcp_service_account_create_request_data.go new file mode 100644 index 00000000000..febcd6dd7aa --- /dev/null +++ b/api/datadogV2/model_gcp_service_account_create_request_data.go @@ -0,0 +1,117 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPServiceAccountCreateRequestData Data on your newly generated service account. +type GCPServiceAccountCreateRequestData struct { + // Additional metadata on your generated service account. + Data *GCPServiceAccountData `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{} +} + +// NewGCPServiceAccountCreateRequestData instantiates a new GCPServiceAccountCreateRequestData 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 NewGCPServiceAccountCreateRequestData() *GCPServiceAccountCreateRequestData { + this := GCPServiceAccountCreateRequestData{} + return &this +} + +// NewGCPServiceAccountCreateRequestDataWithDefaults instantiates a new GCPServiceAccountCreateRequestData 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 NewGCPServiceAccountCreateRequestDataWithDefaults() *GCPServiceAccountCreateRequestData { + this := GCPServiceAccountCreateRequestData{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *GCPServiceAccountCreateRequestData) GetData() GCPServiceAccountData { + if o == nil || o.Data == nil { + var ret GCPServiceAccountData + 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 *GCPServiceAccountCreateRequestData) GetDataOk() (*GCPServiceAccountData, 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 *GCPServiceAccountCreateRequestData) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given GCPServiceAccountData and assigns it to the Data field. +func (o *GCPServiceAccountCreateRequestData) SetData(v GCPServiceAccountData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPServiceAccountCreateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPServiceAccountCreateRequestData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data *GCPServiceAccountData `json:"data,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcp_service_account_data.go b/api/datadogV2/model_gcp_service_account_data.go new file mode 100644 index 00000000000..489ed7e3f23 --- /dev/null +++ b/api/datadogV2/model_gcp_service_account_data.go @@ -0,0 +1,164 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPServiceAccountData Additional metadata on your generated service account. +type GCPServiceAccountData struct { + // Attributes associated with your service account. + Attributes *GCPServiceAccountAttributes `json:"attributes,omitempty"` + // The type of account. + Type *GCPServiceAccountType `json:"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{} +} + +// NewGCPServiceAccountData instantiates a new GCPServiceAccountData 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 NewGCPServiceAccountData() *GCPServiceAccountData { + this := GCPServiceAccountData{} + var typeVar GCPServiceAccountType = GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT + this.Type = &typeVar + return &this +} + +// NewGCPServiceAccountDataWithDefaults instantiates a new GCPServiceAccountData 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 NewGCPServiceAccountDataWithDefaults() *GCPServiceAccountData { + this := GCPServiceAccountData{} + var typeVar GCPServiceAccountType = GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GCPServiceAccountData) GetAttributes() GCPServiceAccountAttributes { + if o == nil || o.Attributes == nil { + var ret GCPServiceAccountAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccountData) GetAttributesOk() (*GCPServiceAccountAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *GCPServiceAccountData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given GCPServiceAccountAttributes and assigns it to the Attributes field. +func (o *GCPServiceAccountData) SetAttributes(v GCPServiceAccountAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GCPServiceAccountData) GetType() GCPServiceAccountType { + if o == nil || o.Type == nil { + var ret GCPServiceAccountType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccountData) GetTypeOk() (*GCPServiceAccountType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *GCPServiceAccountData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GCPServiceAccountType and assigns it to the Type field. +func (o *GCPServiceAccountData) SetType(v GCPServiceAccountType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPServiceAccountData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPServiceAccountData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Attributes *GCPServiceAccountAttributes `json:"attributes,omitempty"` + Type *GCPServiceAccountType `json:"type,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + if v := all.Type; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Type = all.Type + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcp_service_account_meta.go b/api/datadogV2/model_gcp_service_account_meta.go new file mode 100644 index 00000000000..4ef090e9720 --- /dev/null +++ b/api/datadogV2/model_gcp_service_account_meta.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPServiceAccountMeta Additional information related to your service account. +type GCPServiceAccountMeta struct { + // The current list of projects accessible from your service account. + AccessibleProjects []string `json:"accessible_projects,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{} +} + +// NewGCPServiceAccountMeta instantiates a new GCPServiceAccountMeta 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 NewGCPServiceAccountMeta() *GCPServiceAccountMeta { + this := GCPServiceAccountMeta{} + return &this +} + +// NewGCPServiceAccountMetaWithDefaults instantiates a new GCPServiceAccountMeta 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 NewGCPServiceAccountMetaWithDefaults() *GCPServiceAccountMeta { + this := GCPServiceAccountMeta{} + return &this +} + +// GetAccessibleProjects returns the AccessibleProjects field value if set, zero value otherwise. +func (o *GCPServiceAccountMeta) GetAccessibleProjects() []string { + if o == nil || o.AccessibleProjects == nil { + var ret []string + return ret + } + return o.AccessibleProjects +} + +// GetAccessibleProjectsOk returns a tuple with the AccessibleProjects field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccountMeta) GetAccessibleProjectsOk() (*[]string, bool) { + if o == nil || o.AccessibleProjects == nil { + return nil, false + } + return &o.AccessibleProjects, true +} + +// HasAccessibleProjects returns a boolean if a field has been set. +func (o *GCPServiceAccountMeta) HasAccessibleProjects() bool { + return o != nil && o.AccessibleProjects != nil +} + +// SetAccessibleProjects gets a reference to the given []string and assigns it to the AccessibleProjects field. +func (o *GCPServiceAccountMeta) SetAccessibleProjects(v []string) { + o.AccessibleProjects = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPServiceAccountMeta) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.AccessibleProjects != nil { + toSerialize["accessible_projects"] = o.AccessibleProjects + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPServiceAccountMeta) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + AccessibleProjects []string `json:"accessible_projects,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"accessible_projects"}) + } else { + return err + } + o.AccessibleProjects = all.AccessibleProjects + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcp_service_account_response.go b/api/datadogV2/model_gcp_service_account_response.go new file mode 100644 index 00000000000..f85f02773bd --- /dev/null +++ b/api/datadogV2/model_gcp_service_account_response.go @@ -0,0 +1,117 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPServiceAccountResponse The account creation response. +type GCPServiceAccountResponse struct { + // Info on your service account. + Data *GCPServiceAccount `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{} +} + +// NewGCPServiceAccountResponse instantiates a new GCPServiceAccountResponse 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 NewGCPServiceAccountResponse() *GCPServiceAccountResponse { + this := GCPServiceAccountResponse{} + return &this +} + +// NewGCPServiceAccountResponseWithDefaults instantiates a new GCPServiceAccountResponse 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 NewGCPServiceAccountResponseWithDefaults() *GCPServiceAccountResponse { + this := GCPServiceAccountResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *GCPServiceAccountResponse) GetData() GCPServiceAccount { + if o == nil || o.Data == nil { + var ret GCPServiceAccount + 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 *GCPServiceAccountResponse) GetDataOk() (*GCPServiceAccount, 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 *GCPServiceAccountResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given GCPServiceAccount and assigns it to the Data field. +func (o *GCPServiceAccountResponse) SetData(v GCPServiceAccount) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPServiceAccountResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPServiceAccountResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data *GCPServiceAccount `json:"data,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcp_service_account_type.go b/api/datadogV2/model_gcp_service_account_type.go new file mode 100644 index 00000000000..aa7efb53cdc --- /dev/null +++ b/api/datadogV2/model_gcp_service_account_type.go @@ -0,0 +1,107 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// GCPServiceAccountType The type of account. +type GCPServiceAccountType string + +// List of GCPServiceAccountType. +const ( + GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT GCPServiceAccountType = "gcp_service_account" +) + +var allowedGCPServiceAccountTypeEnumValues = []GCPServiceAccountType{ + GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GCPServiceAccountType) GetAllowedValues() []GCPServiceAccountType { + return allowedGCPServiceAccountTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GCPServiceAccountType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GCPServiceAccountType(value) + return nil +} + +// NewGCPServiceAccountTypeFromValue returns a pointer to a valid GCPServiceAccountType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGCPServiceAccountTypeFromValue(v string) (*GCPServiceAccountType, error) { + ev := GCPServiceAccountType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GCPServiceAccountType: valid values are %v", v, allowedGCPServiceAccountTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GCPServiceAccountType) IsValid() bool { + for _, existing := range allowedGCPServiceAccountTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GCPServiceAccountType value. +func (v GCPServiceAccountType) Ptr() *GCPServiceAccountType { + return &v +} + +// NullableGCPServiceAccountType handles when a null is used for GCPServiceAccountType. +type NullableGCPServiceAccountType struct { + value *GCPServiceAccountType + isSet bool +} + +// Get returns the associated value. +func (v NullableGCPServiceAccountType) Get() *GCPServiceAccountType { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableGCPServiceAccountType) Set(val *GCPServiceAccountType) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableGCPServiceAccountType) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableGCPServiceAccountType) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableGCPServiceAccountType initializes the struct as if Set has been called. +func NewNullableGCPServiceAccountType(val *GCPServiceAccountType) *NullableGCPServiceAccountType { + return &NullableGCPServiceAccountType{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableGCPServiceAccountType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableGCPServiceAccountType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_gcp_service_account_update_request.go b/api/datadogV2/model_gcp_service_account_update_request.go new file mode 100644 index 00000000000..098e1855260 --- /dev/null +++ b/api/datadogV2/model_gcp_service_account_update_request.go @@ -0,0 +1,117 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPServiceAccountUpdateRequest Service account info. +type GCPServiceAccountUpdateRequest struct { + // Info on your newly generated service account. + Data *GCPServiceAccountUpdateRequestData `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{} +} + +// NewGCPServiceAccountUpdateRequest instantiates a new GCPServiceAccountUpdateRequest 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 NewGCPServiceAccountUpdateRequest() *GCPServiceAccountUpdateRequest { + this := GCPServiceAccountUpdateRequest{} + return &this +} + +// NewGCPServiceAccountUpdateRequestWithDefaults instantiates a new GCPServiceAccountUpdateRequest 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 NewGCPServiceAccountUpdateRequestWithDefaults() *GCPServiceAccountUpdateRequest { + this := GCPServiceAccountUpdateRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *GCPServiceAccountUpdateRequest) GetData() GCPServiceAccountUpdateRequestData { + if o == nil || o.Data == nil { + var ret GCPServiceAccountUpdateRequestData + 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 *GCPServiceAccountUpdateRequest) GetDataOk() (*GCPServiceAccountUpdateRequestData, 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 *GCPServiceAccountUpdateRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given GCPServiceAccountUpdateRequestData and assigns it to the Data field. +func (o *GCPServiceAccountUpdateRequest) SetData(v GCPServiceAccountUpdateRequestData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPServiceAccountUpdateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPServiceAccountUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data *GCPServiceAccountUpdateRequestData `json:"data,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcp_service_account_update_request_data.go b/api/datadogV2/model_gcp_service_account_update_request_data.go new file mode 100644 index 00000000000..b655822fbd6 --- /dev/null +++ b/api/datadogV2/model_gcp_service_account_update_request_data.go @@ -0,0 +1,199 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPServiceAccountUpdateRequestData Info on your newly generated service account. +type GCPServiceAccountUpdateRequestData struct { + // Attributes associated with your service account. + Attributes *GCPServiceAccountAttributes `json:"attributes,omitempty"` + // Your service account's unique ID. + Id *string `json:"id,omitempty"` + // The type of account. + Type *GCPServiceAccountType `json:"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{} +} + +// NewGCPServiceAccountUpdateRequestData instantiates a new GCPServiceAccountUpdateRequestData 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 NewGCPServiceAccountUpdateRequestData() *GCPServiceAccountUpdateRequestData { + this := GCPServiceAccountUpdateRequestData{} + var typeVar GCPServiceAccountType = GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT + this.Type = &typeVar + return &this +} + +// NewGCPServiceAccountUpdateRequestDataWithDefaults instantiates a new GCPServiceAccountUpdateRequestData 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 NewGCPServiceAccountUpdateRequestDataWithDefaults() *GCPServiceAccountUpdateRequestData { + this := GCPServiceAccountUpdateRequestData{} + var typeVar GCPServiceAccountType = GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GCPServiceAccountUpdateRequestData) GetAttributes() GCPServiceAccountAttributes { + if o == nil || o.Attributes == nil { + var ret GCPServiceAccountAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccountUpdateRequestData) GetAttributesOk() (*GCPServiceAccountAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *GCPServiceAccountUpdateRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given GCPServiceAccountAttributes and assigns it to the Attributes field. +func (o *GCPServiceAccountUpdateRequestData) SetAttributes(v GCPServiceAccountAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *GCPServiceAccountUpdateRequestData) 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 *GCPServiceAccountUpdateRequestData) 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 *GCPServiceAccountUpdateRequestData) 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 *GCPServiceAccountUpdateRequestData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GCPServiceAccountUpdateRequestData) GetType() GCPServiceAccountType { + if o == nil || o.Type == nil { + var ret GCPServiceAccountType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPServiceAccountUpdateRequestData) GetTypeOk() (*GCPServiceAccountType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *GCPServiceAccountUpdateRequestData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GCPServiceAccountType and assigns it to the Type field. +func (o *GCPServiceAccountUpdateRequestData) SetType(v GCPServiceAccountType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPServiceAccountUpdateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPServiceAccountUpdateRequestData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Attributes *GCPServiceAccountAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *GCPServiceAccountType `json:"type,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + if v := all.Type; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Id = all.Id + o.Type = all.Type + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcpsts_account.go b/api/datadogV2/model_gcpsts_account.go new file mode 100644 index 00000000000..7e61510975a --- /dev/null +++ b/api/datadogV2/model_gcpsts_account.go @@ -0,0 +1,241 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPSTSAccount Your Google Cloud Platform STS enabled service accounts. +type GCPSTSAccount struct { + // Attributes associated with your service account. + Attributes *GCPServiceAccountAttributes `json:"attributes,omitempty"` + // Your service account's unique ID. + Id *string `json:"id,omitempty"` + // Additional information related to your service account. + Meta *GCPServiceAccountMeta `json:"meta,omitempty"` + // The type of account. + Type *GCPServiceAccountType `json:"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{} +} + +// NewGCPSTSAccount instantiates a new GCPSTSAccount 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 NewGCPSTSAccount() *GCPSTSAccount { + this := GCPSTSAccount{} + var typeVar GCPServiceAccountType = GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT + this.Type = &typeVar + return &this +} + +// NewGCPSTSAccountWithDefaults instantiates a new GCPSTSAccount 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 NewGCPSTSAccountWithDefaults() *GCPSTSAccount { + this := GCPSTSAccount{} + var typeVar GCPServiceAccountType = GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GCPSTSAccount) GetAttributes() GCPServiceAccountAttributes { + if o == nil || o.Attributes == nil { + var ret GCPServiceAccountAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPSTSAccount) GetAttributesOk() (*GCPServiceAccountAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *GCPSTSAccount) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given GCPServiceAccountAttributes and assigns it to the Attributes field. +func (o *GCPSTSAccount) SetAttributes(v GCPServiceAccountAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *GCPSTSAccount) 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 *GCPSTSAccount) 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 *GCPSTSAccount) 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 *GCPSTSAccount) SetId(v string) { + o.Id = &v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *GCPSTSAccount) GetMeta() GCPServiceAccountMeta { + if o == nil || o.Meta == nil { + var ret GCPServiceAccountMeta + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPSTSAccount) GetMetaOk() (*GCPServiceAccountMeta, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *GCPSTSAccount) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given GCPServiceAccountMeta and assigns it to the Meta field. +func (o *GCPSTSAccount) SetMeta(v GCPServiceAccountMeta) { + o.Meta = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GCPSTSAccount) GetType() GCPServiceAccountType { + if o == nil || o.Type == nil { + var ret GCPServiceAccountType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPSTSAccount) GetTypeOk() (*GCPServiceAccountType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *GCPSTSAccount) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GCPServiceAccountType and assigns it to the Type field. +func (o *GCPSTSAccount) SetType(v GCPServiceAccountType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPSTSAccount) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPSTSAccount) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Attributes *GCPServiceAccountAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Meta *GCPServiceAccountMeta `json:"meta,omitempty"` + Type *GCPServiceAccountType `json:"type,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "meta", "type"}) + } else { + return err + } + if v := all.Type; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Meta = all.Meta + o.Type = all.Type + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcpsts_delegate_account.go b/api/datadogV2/model_gcpsts_delegate_account.go new file mode 100644 index 00000000000..1f24c70dc32 --- /dev/null +++ b/api/datadogV2/model_gcpsts_delegate_account.go @@ -0,0 +1,199 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPSTSDelegateAccount Datadog principal service account info. +type GCPSTSDelegateAccount struct { + // Your delegate account attributes. + Attributes *GCPSTSDelegateAccountAttributes `json:"attributes,omitempty"` + // The ID of the delegate service account. + Id *string `json:"id,omitempty"` + // The type of account. + Type *GCPSTSDelegateAccountType `json:"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{} +} + +// NewGCPSTSDelegateAccount instantiates a new GCPSTSDelegateAccount 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 NewGCPSTSDelegateAccount() *GCPSTSDelegateAccount { + this := GCPSTSDelegateAccount{} + var typeVar GCPSTSDelegateAccountType = GCPSTSDELEGATEACCOUNTTYPE_GCP_STS_DELEGATE + this.Type = &typeVar + return &this +} + +// NewGCPSTSDelegateAccountWithDefaults instantiates a new GCPSTSDelegateAccount 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 NewGCPSTSDelegateAccountWithDefaults() *GCPSTSDelegateAccount { + this := GCPSTSDelegateAccount{} + var typeVar GCPSTSDelegateAccountType = GCPSTSDELEGATEACCOUNTTYPE_GCP_STS_DELEGATE + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GCPSTSDelegateAccount) GetAttributes() GCPSTSDelegateAccountAttributes { + if o == nil || o.Attributes == nil { + var ret GCPSTSDelegateAccountAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPSTSDelegateAccount) GetAttributesOk() (*GCPSTSDelegateAccountAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *GCPSTSDelegateAccount) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given GCPSTSDelegateAccountAttributes and assigns it to the Attributes field. +func (o *GCPSTSDelegateAccount) SetAttributes(v GCPSTSDelegateAccountAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *GCPSTSDelegateAccount) 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 *GCPSTSDelegateAccount) 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 *GCPSTSDelegateAccount) 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 *GCPSTSDelegateAccount) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GCPSTSDelegateAccount) GetType() GCPSTSDelegateAccountType { + if o == nil || o.Type == nil { + var ret GCPSTSDelegateAccountType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPSTSDelegateAccount) GetTypeOk() (*GCPSTSDelegateAccountType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *GCPSTSDelegateAccount) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GCPSTSDelegateAccountType and assigns it to the Type field. +func (o *GCPSTSDelegateAccount) SetType(v GCPSTSDelegateAccountType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPSTSDelegateAccount) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPSTSDelegateAccount) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Attributes *GCPSTSDelegateAccountAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *GCPSTSDelegateAccountType `json:"type,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + if v := all.Type; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Id = all.Id + o.Type = all.Type + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcpsts_delegate_account_attributes.go b/api/datadogV2/model_gcpsts_delegate_account_attributes.go new file mode 100644 index 00000000000..edd5e399ec6 --- /dev/null +++ b/api/datadogV2/model_gcpsts_delegate_account_attributes.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPSTSDelegateAccountAttributes Your delegate account attributes. +type GCPSTSDelegateAccountAttributes struct { + // Your organization's Datadog principal email address. + DelegateAccountEmail *string `json:"delegate_account_email,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{} +} + +// NewGCPSTSDelegateAccountAttributes instantiates a new GCPSTSDelegateAccountAttributes 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 NewGCPSTSDelegateAccountAttributes() *GCPSTSDelegateAccountAttributes { + this := GCPSTSDelegateAccountAttributes{} + return &this +} + +// NewGCPSTSDelegateAccountAttributesWithDefaults instantiates a new GCPSTSDelegateAccountAttributes 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 NewGCPSTSDelegateAccountAttributesWithDefaults() *GCPSTSDelegateAccountAttributes { + this := GCPSTSDelegateAccountAttributes{} + return &this +} + +// GetDelegateAccountEmail returns the DelegateAccountEmail field value if set, zero value otherwise. +func (o *GCPSTSDelegateAccountAttributes) GetDelegateAccountEmail() string { + if o == nil || o.DelegateAccountEmail == nil { + var ret string + return ret + } + return *o.DelegateAccountEmail +} + +// GetDelegateAccountEmailOk returns a tuple with the DelegateAccountEmail field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GCPSTSDelegateAccountAttributes) GetDelegateAccountEmailOk() (*string, bool) { + if o == nil || o.DelegateAccountEmail == nil { + return nil, false + } + return o.DelegateAccountEmail, true +} + +// HasDelegateAccountEmail returns a boolean if a field has been set. +func (o *GCPSTSDelegateAccountAttributes) HasDelegateAccountEmail() bool { + return o != nil && o.DelegateAccountEmail != nil +} + +// SetDelegateAccountEmail gets a reference to the given string and assigns it to the DelegateAccountEmail field. +func (o *GCPSTSDelegateAccountAttributes) SetDelegateAccountEmail(v string) { + o.DelegateAccountEmail = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPSTSDelegateAccountAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.DelegateAccountEmail != nil { + toSerialize["delegate_account_email"] = o.DelegateAccountEmail + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPSTSDelegateAccountAttributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + DelegateAccountEmail *string `json:"delegate_account_email,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"delegate_account_email"}) + } else { + return err + } + o.DelegateAccountEmail = all.DelegateAccountEmail + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcpsts_delegate_account_response.go b/api/datadogV2/model_gcpsts_delegate_account_response.go new file mode 100644 index 00000000000..ce0f3ca6bae --- /dev/null +++ b/api/datadogV2/model_gcpsts_delegate_account_response.go @@ -0,0 +1,117 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPSTSDelegateAccountResponse Your delegate service account response data. +type GCPSTSDelegateAccountResponse struct { + // Datadog principal service account info. + Data *GCPSTSDelegateAccount `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{} +} + +// NewGCPSTSDelegateAccountResponse instantiates a new GCPSTSDelegateAccountResponse 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 NewGCPSTSDelegateAccountResponse() *GCPSTSDelegateAccountResponse { + this := GCPSTSDelegateAccountResponse{} + return &this +} + +// NewGCPSTSDelegateAccountResponseWithDefaults instantiates a new GCPSTSDelegateAccountResponse 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 NewGCPSTSDelegateAccountResponseWithDefaults() *GCPSTSDelegateAccountResponse { + this := GCPSTSDelegateAccountResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *GCPSTSDelegateAccountResponse) GetData() GCPSTSDelegateAccount { + if o == nil || o.Data == nil { + var ret GCPSTSDelegateAccount + 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 *GCPSTSDelegateAccountResponse) GetDataOk() (*GCPSTSDelegateAccount, 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 *GCPSTSDelegateAccountResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given GCPSTSDelegateAccount and assigns it to the Data field. +func (o *GCPSTSDelegateAccountResponse) SetData(v GCPSTSDelegateAccount) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPSTSDelegateAccountResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPSTSDelegateAccountResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data *GCPSTSDelegateAccount `json:"data,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_gcpsts_delegate_account_type.go b/api/datadogV2/model_gcpsts_delegate_account_type.go new file mode 100644 index 00000000000..a65356e1af7 --- /dev/null +++ b/api/datadogV2/model_gcpsts_delegate_account_type.go @@ -0,0 +1,107 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// GCPSTSDelegateAccountType The type of account. +type GCPSTSDelegateAccountType string + +// List of GCPSTSDelegateAccountType. +const ( + GCPSTSDELEGATEACCOUNTTYPE_GCP_STS_DELEGATE GCPSTSDelegateAccountType = "gcp_sts_delegate" +) + +var allowedGCPSTSDelegateAccountTypeEnumValues = []GCPSTSDelegateAccountType{ + GCPSTSDELEGATEACCOUNTTYPE_GCP_STS_DELEGATE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GCPSTSDelegateAccountType) GetAllowedValues() []GCPSTSDelegateAccountType { + return allowedGCPSTSDelegateAccountTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GCPSTSDelegateAccountType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GCPSTSDelegateAccountType(value) + return nil +} + +// NewGCPSTSDelegateAccountTypeFromValue returns a pointer to a valid GCPSTSDelegateAccountType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGCPSTSDelegateAccountTypeFromValue(v string) (*GCPSTSDelegateAccountType, error) { + ev := GCPSTSDelegateAccountType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GCPSTSDelegateAccountType: valid values are %v", v, allowedGCPSTSDelegateAccountTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GCPSTSDelegateAccountType) IsValid() bool { + for _, existing := range allowedGCPSTSDelegateAccountTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GCPSTSDelegateAccountType value. +func (v GCPSTSDelegateAccountType) Ptr() *GCPSTSDelegateAccountType { + return &v +} + +// NullableGCPSTSDelegateAccountType handles when a null is used for GCPSTSDelegateAccountType. +type NullableGCPSTSDelegateAccountType struct { + value *GCPSTSDelegateAccountType + isSet bool +} + +// Get returns the associated value. +func (v NullableGCPSTSDelegateAccountType) Get() *GCPSTSDelegateAccountType { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableGCPSTSDelegateAccountType) Set(val *GCPSTSDelegateAccountType) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableGCPSTSDelegateAccountType) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableGCPSTSDelegateAccountType) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableGCPSTSDelegateAccountType initializes the struct as if Set has been called. +func NewNullableGCPSTSDelegateAccountType(val *GCPSTSDelegateAccountType) *NullableGCPSTSDelegateAccountType { + return &NullableGCPSTSDelegateAccountType{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableGCPSTSDelegateAccountType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableGCPSTSDelegateAccountType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_gcpsts_enabled_account_data.go b/api/datadogV2/model_gcpsts_enabled_account_data.go new file mode 100644 index 00000000000..fe9b5257087 --- /dev/null +++ b/api/datadogV2/model_gcpsts_enabled_account_data.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GCPSTSEnabledAccountData Object containing all your STS enabled accounts. +type GCPSTSEnabledAccountData struct { + // Array of GCP STS enabled service accounts. + Data []GCPSTSAccount `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{} +} + +// NewGCPSTSEnabledAccountData instantiates a new GCPSTSEnabledAccountData 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 NewGCPSTSEnabledAccountData() *GCPSTSEnabledAccountData { + this := GCPSTSEnabledAccountData{} + return &this +} + +// NewGCPSTSEnabledAccountDataWithDefaults instantiates a new GCPSTSEnabledAccountData 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 NewGCPSTSEnabledAccountDataWithDefaults() *GCPSTSEnabledAccountData { + this := GCPSTSEnabledAccountData{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *GCPSTSEnabledAccountData) GetData() []GCPSTSAccount { + if o == nil || o.Data == nil { + var ret []GCPSTSAccount + 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 *GCPSTSEnabledAccountData) GetDataOk() (*[]GCPSTSAccount, 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 *GCPSTSEnabledAccountData) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []GCPSTSAccount and assigns it to the Data field. +func (o *GCPSTSEnabledAccountData) SetData(v []GCPSTSAccount) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GCPSTSEnabledAccountData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GCPSTSEnabledAccountData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data []GCPSTSAccount `json:"data,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = all.Data + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/gcp-integration/CreateGCPSTSAccount.go b/examples/v2/gcp-integration/CreateGCPSTSAccount.go new file mode 100644 index 00000000000..ca59d3c9ba1 --- /dev/null +++ b/examples/v2/gcp-integration/CreateGCPSTSAccount.go @@ -0,0 +1,38 @@ +// Create a new entry for your service account returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.GCPServiceAccountCreateRequestData{ + Data: &datadogV2.GCPServiceAccountData{ + Attributes: &datadogV2.GCPServiceAccountAttributes{ + ClientEmail: datadog.PtrString("datadog-service-account@test-project.iam.gserviceaccount.com"), + HostFilters: []string{}, + }, + Type: datadogV2.GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGCPIntegrationApi(apiClient) + resp, r, err := api.CreateGCPSTSAccount(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GCPIntegrationApi.CreateGCPSTSAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GCPIntegrationApi.CreateGCPSTSAccount`:\n%s\n", responseContent) +} diff --git a/examples/v2/gcp-integration/DeleteGCPSTSAccount.go b/examples/v2/gcp-integration/DeleteGCPSTSAccount.go new file mode 100644 index 00000000000..3eda3469e44 --- /dev/null +++ b/examples/v2/gcp-integration/DeleteGCPSTSAccount.go @@ -0,0 +1,25 @@ +// Delete an STS enabled GCP Account returns "No Content" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGCPIntegrationApi(apiClient) + r, err := api.DeleteGCPSTSAccount(ctx, "account_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GCPIntegrationApi.DeleteGCPSTSAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/gcp-integration/GetGCPSTSDelegate.go b/examples/v2/gcp-integration/GetGCPSTSDelegate.go new file mode 100644 index 00000000000..f56b04deab9 --- /dev/null +++ b/examples/v2/gcp-integration/GetGCPSTSDelegate.go @@ -0,0 +1,29 @@ +// List delegate account returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGCPIntegrationApi(apiClient) + resp, r, err := api.GetGCPSTSDelegate(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GCPIntegrationApi.GetGCPSTSDelegate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GCPIntegrationApi.GetGCPSTSDelegate`:\n%s\n", responseContent) +} diff --git a/examples/v2/gcp-integration/ListGCPSTSAccounts.go b/examples/v2/gcp-integration/ListGCPSTSAccounts.go new file mode 100644 index 00000000000..a6eafc31369 --- /dev/null +++ b/examples/v2/gcp-integration/ListGCPSTSAccounts.go @@ -0,0 +1,29 @@ +// List all GCP STS-enabled service accounts returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGCPIntegrationApi(apiClient) + resp, r, err := api.ListGCPSTSAccounts(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GCPIntegrationApi.ListGCPSTSAccounts`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GCPIntegrationApi.ListGCPSTSAccounts`:\n%s\n", responseContent) +} diff --git a/examples/v2/gcp-integration/MakeGCPSTSDelegate.go b/examples/v2/gcp-integration/MakeGCPSTSDelegate.go new file mode 100644 index 00000000000..0c6f7b076ce --- /dev/null +++ b/examples/v2/gcp-integration/MakeGCPSTSDelegate.go @@ -0,0 +1,29 @@ +// Create a Datadog GCP principal returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGCPIntegrationApi(apiClient) + resp, r, err := api.MakeGCPSTSDelegate(ctx, *datadogV2.NewMakeGCPSTSDelegateOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GCPIntegrationApi.MakeGCPSTSDelegate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GCPIntegrationApi.MakeGCPSTSDelegate`:\n%s\n", responseContent) +} diff --git a/examples/v2/gcp-integration/MakeGCPSTSDelegate_962598975.go b/examples/v2/gcp-integration/MakeGCPSTSDelegate_962598975.go new file mode 100644 index 00000000000..7ea6e61accf --- /dev/null +++ b/examples/v2/gcp-integration/MakeGCPSTSDelegate_962598975.go @@ -0,0 +1,30 @@ +// Create a Datadog GCP principal with empty body returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := new(interface{}) + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGCPIntegrationApi(apiClient) + resp, r, err := api.MakeGCPSTSDelegate(ctx, *datadogV2.NewMakeGCPSTSDelegateOptionalParameters().WithBody(body)) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GCPIntegrationApi.MakeGCPSTSDelegate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GCPIntegrationApi.MakeGCPSTSDelegate`:\n%s\n", responseContent) +} diff --git a/examples/v2/gcp-integration/UpdateGCPSTSAccount.go b/examples/v2/gcp-integration/UpdateGCPSTSAccount.go new file mode 100644 index 00000000000..7efc79ba20e --- /dev/null +++ b/examples/v2/gcp-integration/UpdateGCPSTSAccount.go @@ -0,0 +1,39 @@ +// Update STS Service Account returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.GCPServiceAccountUpdateRequest{ + Data: &datadogV2.GCPServiceAccountUpdateRequestData{ + Attributes: &datadogV2.GCPServiceAccountAttributes{ + ClientEmail: datadog.PtrString("datadog-service-account@test-project.iam.gserviceaccount.com"), + HostFilters: []string{}, + }, + Id: datadog.PtrString("d291291f-12c2-22g4-j290-123456678897"), + Type: datadogV2.GCPSERVICEACCOUNTTYPE_GCP_SERVICE_ACCOUNT.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGCPIntegrationApi(apiClient) + resp, r, err := api.UpdateGCPSTSAccount(ctx, "account_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GCPIntegrationApi.UpdateGCPSTSAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GCPIntegrationApi.UpdateGCPSTSAccount`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index bcc0b2719ed..3459b0ea129 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -53,6 +53,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "DashboardListsApi": reflect.ValueOf(datadogV2.NewDashboardListsApi), "EventsApi": reflect.ValueOf(datadogV2.NewEventsApi), "IncidentsApi": reflect.ValueOf(datadogV2.NewIncidentsApi), + "GCPIntegrationApi": reflect.ValueOf(datadogV2.NewGCPIntegrationApi), "OpsgenieIntegrationApi": reflect.ValueOf(datadogV2.NewOpsgenieIntegrationApi), "CloudflareIntegrationApi": reflect.ValueOf(datadogV2.NewCloudflareIntegrationApi), "ConfluentCloudApi": reflect.ValueOf(datadogV2.NewConfluentCloudApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_returns_OK_response.freeze new file mode 100644 index 00000000000..de4e11086ac --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-05-18T15:02:26.265Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_returns_OK_response.yaml new file mode 100644 index 00000000000..c997b68cf81 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_returns_OK_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/integration/gcp/sts_delegate + response: + body: '{"data":{"type":"gcp_sts_delegate","attributes":{"delegate_account_email":"ddgci-b5ee8760a0ff148b3056@datadog-cloud-ints-staging.iam.gserviceaccount.com"},"id":"ddgci-b5ee8760a0ff148b3056@datadog-cloud-ints-staging.iam.gserviceaccount.com"}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_with_empty_body_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_with_empty_body_returns_OK_response.freeze new file mode 100644 index 00000000000..b105fff4c83 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_with_empty_body_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-05-25T17:14:37.896Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_with_empty_body_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_with_empty_body_returns_OK_response.yaml new file mode 100644 index 00000000000..0bfe39d03e7 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_Create_a_Datadog_GCP_principal_with_empty_body_returns_OK_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/integration/gcp/sts_delegate + response: + body: '{"data":{"type":"gcp_sts_delegate","attributes":{"delegate_account_email":"ddgci-b5ee8760a0ff148b3056@datadog-cloud-ints-staging.iam.gserviceaccount.com"},"id":"ddgci-b5ee8760a0ff148b3056@datadog-cloud-ints-staging.iam.gserviceaccount.com"}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_all_GCP_STS-enabled_service_accounts_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_all_GCP_STS-enabled_service_accounts_returns_OK_response.freeze new file mode 100644 index 00000000000..501e5fa0d6b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_all_GCP_STS-enabled_service_accounts_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-05-18T15:03:23.705Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_all_GCP_STS-enabled_service_accounts_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_all_GCP_STS-enabled_service_accounts_returns_OK_response.yaml new file mode 100644 index 00000000000..28fabdbb301 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_all_GCP_STS-enabled_service_accounts_returns_OK_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/integration/gcp/accounts + response: + body: '{"data":[{"type":"gcp_service_account","attributes":{"client_email":"mitchdoingtests@lookatthismitchtest.edu","host_filters":["lots","of","filters"],"automute":true,"is_cspm_enabled":true},"id":"4287ec45-bd6b-40d5-b378-de5b3c569155","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":true},"id":"d4738a71-7f23-4af4-a5bf-ad6143b3a5f0","meta":{"accessible_projects":["datadog-staging"]}},{"type":"gcp_service_account","attributes":{"client_email":"joshua-delete-me-terraform-testing-2","host_filters":[],"automute":true,"is_cspm_enabled":true},"id":"f96f39ea-77b0-4886-a46d-2612e5290664","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"c5a7ebfd-c4fd-4542-86f0-9eafc413589e","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-7@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"0828a7c8-d9c0-4d62-bd8e-f05b71ac3f6f","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-8@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"9a505da5-e01e-4f8a-963f-f8d8302f7cd6","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"testing_v2_endpoint_josh_2","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"1fee30d3-2432-4145-9e1a-9ded9a311d2a","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"joshuatesting","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"6a274bbb-fd4e-4864-9afc-36d19a7d7fb5","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"josh.testing@hi.bye.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"3e4a32a5-158a-4441-9040-bf2fdcb7b655","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"reference-tables@datadog-sandbox.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"3d723d45-04ee-46f5-a699-c35a39c4b5a3","meta":{"accessible_projects":["datadog-sandbox"]}},{"type":"gcp_service_account","attributes":{"client_email":"alejandro-test-gcp@datadog-sandbox.iam.gserviceaccount.com","host_filters":["test:true"],"automute":false,"is_cspm_enabled":true},"id":"17a82d20-1a7f-47b8-8342-7b8f42c1ea89","meta":{"accessible_projects":["datadog-sandbox"]}},{"type":"gcp_service_account","attributes":{"client_email":"ricky-staging-test@datadog-sandbox.iam.gserviceaccount.com","host_filters":["potato:potahto"],"automute":false,"is_cspm_enabled":true},"id":"950b23da-adb7-4625-825d-20ec6118803a","meta":{"accessible_projects":["datadog-sandbox"]}},{"type":"gcp_service_account","attributes":{"client_email":"mitch-hierarchy-test-account@datadog-gcp-ints-test-b.iam.gserviceaccount.com","host_filters":[],"automute":true,"is_cspm_enabled":true},"id":"b7bd7831-26c0-426b-a72f-797fc2a35514","meta":{"accessible_projects":["datadog-gcp-ints-test-b"]}},{"type":"gcp_service_account","attributes":{"client_email":"staging-crawl-account@datadog-gcp-ints-test-c.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":true},"id":"c71fc786-2ee3-4643-9b2b-753f0c59e04e","meta":{"accessible_projects":["datadog-gcp-ints-test-c"]}},{"type":"gcp_service_account","attributes":{"client_email":"staging-crawl@datadog-eventarc-dev.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":true},"id":"fe6926ed-3ec8-477a-993d-7b960f4c6da4","meta":{"accessible_projects":["datadog-eventarc-dev"]}},{"type":"gcp_service_account","attributes":{"client_email":"joshuahuietestingaccount@datadog-sandbox.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"b85bb514-e997-4b50-88b5-d3c38a44d84d","meta":{"accessible_projects":["datadog-sandbox"]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-2@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"064f8cd5-2545-46d2-a21d-dad13b637d24","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-6@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"e45e015c-13d7-4b03-bae5-a79bc7c55706","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-9@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"7e638eed-f4b4-4b2b-a854-5a50d6b25325","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"josh-testing-v2","host_filters":[],"automute":true,"is_cspm_enabled":false},"id":"173a52cb-4218-42ef-b977-08ffd7c49d88","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-13@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"6df000a2-515e-4541-845d-54dd475a6b4c","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-14@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"cf0f3638-bb5d-4d05-81cd-1c8c0d038ffb","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-15@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"cd896a52-f6c2-4c89-a060-fba960e6d847","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"graytest@datadog-gcp-ints-test-b.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"ae5a0b9d-1ddf-4a87-b9f2-562f7fde8364","meta":{"accessible_projects":["datadog-gcp-ints-test-b","datadog-gcp-ints-test-c"]}},{"type":"gcp_service_account","attributes":{"client_email":"56425@test.com","host_filters":[],"automute":false,"is_cspm_enabled":true},"id":"47f9fa86-0854-441d-b2b4-1e7e0c721de3","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"staging-crawl-account@cspm-terraform.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":true},"id":"d3a64dfc-60cb-4765-9d8d-c5cba145be71","meta":{"accessible_projects":["cspm-terraform"]}},{"type":"gcp_service_account","attributes":{"client_email":"rachel-test@test.com","host_filters":[],"automute":false,"is_cspm_enabled":true},"id":"dbc365c2-108b-45ec-8b32-da9c817ef116","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"mitchTestingANotRealEmail@notMitchsEmail.com","host_filters":["brand","new"],"automute":false,"is_cspm_enabled":false},"id":"fac2c99e-7ba8-4a13-9558-003a13d019da","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"rachel-test-2@test.com","host_filters":["k:v"],"automute":false,"is_cspm_enabled":false},"id":"d8e508ec-546f-407a-b16f-08f525a0a8d8","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-testing@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"7b325857-bfb5-477f-a1dd-84386590b76d","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"testing_v2_endpoint_josh_3","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"2056ea74-f0b1-42f0-91d0-7e3bf73224c7","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"joshua-delete-me-terraform-testing-3","host_filters":[],"automute":false,"is_cspm_enabled":true},"id":"c590766f-fef1-46e9-9b25-a84d27ab1882","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-3@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"68140f7e-8f70-4a67-a3b9-88f0c2594a31","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-4@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"a80dd4b7-beed-4152-a13a-e5b4e5ce225f","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-5@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"18009dfa-0dce-4e8b-a16f-4156c0a5ceae","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-10@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"9ce798c8-9703-4e72-ad86-00f85ededd4c","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-11@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"91e006f6-38bf-46aa-93d4-09987cb8cf71","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"audrey-yuan@datadog-cloud-ints-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"8724c8b2-f186-4471-8be1-44ccbd33d3b0","meta":{"accessible_projects":["datadog-cloud-ints-staging"]}},{"type":"gcp_service_account","attributes":{"client_email":"sri-may8-qa@datadog-sandbox.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"d88004c8-221b-4d28-922f-9a124f8b508a","meta":{"accessible_projects":["datadog-sandbox"]}},{"type":"gcp_service_account","attributes":{"client_email":"dd-integration-test-12@datadog-staging.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"a0c294d2-f57b-4cf7-8944-8739b1566f8e","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"testing_v2_endpoint_josh","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"9e690d47-d975-4c40-9900-6d5eae6dd3d6","meta":{"accessible_projects":[]}},{"type":"gcp_service_account","attributes":{"client_email":"sri-beta-gcp-service@datadog-sandbox.iam.gserviceaccount.com","host_filters":[],"automute":false,"is_cspm_enabled":false},"id":"b46c7744-b4ad-4b3b-b521-0114960b935b","meta":{"accessible_projects":["datadog-sandbox"]}}]} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_delegate_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_delegate_account_returns_OK_response.freeze new file mode 100644 index 00000000000..77dbc565156 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_delegate_account_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-05-23T13:50:44.429Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_delegate_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_delegate_account_returns_OK_response.yaml new file mode 100644 index 00000000000..af90479a668 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_GCP_Integration/Scenario_List_delegate_account_returns_OK_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/integration/gcp/sts_delegate + response: + body: '{"data":{"type":"gcp_sts_delegate","attributes":{"delegate_account_email":"ddgci-d427c1b4a96cca3986b2@datadog-gci-sts-us1-prod.iam.gserviceaccount.com"},"id":"ddgci-d427c1b4a96cca3986b2@datadog-gci-sts-us1-prod.iam.gserviceaccount.com"}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/features/v2/gcp_integration.feature b/tests/scenarios/features/v2/gcp_integration.feature new file mode 100644 index 00000000000..01d85f94e24 --- /dev/null +++ b/tests/scenarios/features/v2/gcp_integration.feature @@ -0,0 +1,111 @@ +@endpoint(gcp-integration) @endpoint(gcp-integration-v2) +Feature: GCP Integration + Configure your Datadog-Google Cloud Platform (GCP) integration directly + through the Datadog API. Read more about the [Datadog-Google Cloud + Platform integration](https://docs.datadoghq.com/integrations/google_cloud + _platform). + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "GCPIntegration" API + + @generated @skip @team:DataDog/gcp-integrations + Scenario: Create a Datadog GCP principal returns "Conflict" response + Given new "MakeGCPSTSDelegate" request + When the request is sent + Then the response status is 409 Conflict + + @team:DataDog/gcp-integrations + Scenario: Create a Datadog GCP principal returns "OK" response + Given new "MakeGCPSTSDelegate" request + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "gcp_sts_delegate" + + @team:DataDog/gcp-integrations + Scenario: Create a Datadog GCP principal with empty body returns "OK" response + Given new "MakeGCPSTSDelegate" request + And body with value {} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "gcp_sts_delegate" + + @generated @skip @team:DataDog/gcp-integrations + Scenario: Create a new entry for your service account returns "Bad Request" response + Given new "CreateGCPSTSAccount" request + And body with value {"data": {"attributes": {"client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "host_filters": []}, "type": "gcp_service_account"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/gcp-integrations + Scenario: Create a new entry for your service account returns "Conflict" response + Given new "CreateGCPSTSAccount" request + And body with value {"data": {"attributes": {"client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "host_filters": []}, "type": "gcp_service_account"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/gcp-integrations + Scenario: Create a new entry for your service account returns "OK" response + Given new "CreateGCPSTSAccount" request + And body with value {"data": {"attributes": {"client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "host_filters": []}, "type": "gcp_service_account"}} + When the request is sent + Then the response status is 201 OK + + @generated @skip @team:DataDog/gcp-integrations + Scenario: Delete an STS enabled GCP Account returns "Bad Request" response + Given new "DeleteGCPSTSAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/gcp-integrations + Scenario: Delete an STS enabled GCP Account returns "No Content" response + Given new "DeleteGCPSTSAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/gcp-integrations + Scenario: List all GCP STS-enabled service accounts returns "Not Found" response + Given new "ListGCPSTSAccounts" request + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/gcp-integrations + Scenario: List all GCP STS-enabled service accounts returns "OK" response + Given new "ListGCPSTSAccounts" request + When the request is sent + Then the response status is 200 OK + And the response "data" has item with field "type" with value "gcp_service_account" + + @team:DataDog/gcp-integrations + Scenario: List delegate account returns "OK" response + Given new "GetGCPSTSDelegate" request + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "gcp_sts_delegate" + + @generated @skip @team:DataDog/gcp-integrations + Scenario: Update STS Service Account returns "Bad Request" response + Given new "UpdateGCPSTSAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "host_filters": []}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/gcp-integrations + Scenario: Update STS Service Account returns "Not Found" response + Given new "UpdateGCPSTSAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "host_filters": []}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/gcp-integrations + Scenario: Update STS Service Account returns "OK" response + Given new "UpdateGCPSTSAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "host_filters": []}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} + When the request is sent + Then the response status is 201 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 30378f78d53..6a3bd0e0492 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -392,6 +392,49 @@ "type": "idempotent" } }, + "ListGCPSTSAccounts": { + "tag": "GCP Integration", + "undo": { + "type": "safe" + } + }, + "CreateGCPSTSAccount": { + "tag": "GCP Integration", + "undo": { + "operationId": "DeleteGCPSTSAccount", + "parameters": [ + { + "name": "account_id", + "source": "id" + } + ], + "type": "unsafe" + } + }, + "DeleteGCPSTSAccount": { + "tag": "GCP Integration", + "undo": { + "type": "idempotent" + } + }, + "UpdateGCPSTSAccount": { + "tag": "GCP Integration", + "undo": { + "type": "idempotent" + } + }, + "GetGCPSTSDelegate": { + "tag": "GCP Integration", + "undo": { + "type": "safe" + } + }, + "MakeGCPSTSDelegate": { + "tag": "GCP Integration", + "undo": { + "type": "idempotent" + } + }, "ListOpsgenieServices": { "tag": "Opsgenie Integration", "undo": {