diff --git a/.apigentools-info b/.apigentools-info index cb35989d598..ffd05c4226b 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2023-11-14 15:18:29.364146", - "spec_repo_commit": "b95546fe" + "regenerated": "2023-11-14 20:55:38.969518", + "spec_repo_commit": "4a4cc7c8" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2023-11-14 15:18:29.383624", - "spec_repo_commit": "b95546fe" + "regenerated": "2023-11-14 20:55:38.986475", + "spec_repo_commit": "4a4cc7c8" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2c1cf38a93d..8c17b4690e9 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -10775,6 +10775,141 @@ components: - id - type type: object + OktaAccount: + description: Schema for an Okta account. + properties: + attributes: + $ref: '#/components/schemas/OktaAccountAttributes' + id: + description: The ID of the Okta account, a UUID hash of the account name. + example: f749daaf-682e-4208-a38d-c9b43162c609 + type: string + type: + $ref: '#/components/schemas/OktaAccountType' + required: + - attributes + - type + type: object + OktaAccountAttributes: + description: Attributes object for an Okta account. + properties: + api_key: + description: The API key of the Okta account. + type: string + writeOnly: true + auth_method: + description: The authorization method for an Okta account. + example: oauth + type: string + client_id: + description: The Client ID of an Okta app integration. + type: string + client_secret: + description: The client secret of an Okta app integration. + type: string + writeOnly: true + domain: + description: The domain of the Okta account. + example: https://example.okta.com/ + type: string + name: + description: The name of the Okta account. + example: Okta-Prod + type: string + required: + - auth_method + - domain + - name + type: object + OktaAccountRequest: + description: Request object for an Okta account. + properties: + data: + $ref: '#/components/schemas/OktaAccount' + required: + - data + type: object + OktaAccountResponse: + description: Response object for an Okta account. + properties: + data: + $ref: '#/components/schemas/OktaAccount' + type: object + OktaAccountResponseData: + description: Data object of an Okta account + properties: + attributes: + $ref: '#/components/schemas/OktaAccountAttributes' + id: + description: The ID of the Okta account, a UUID hash of the account name. + example: f749daaf-682e-4208-a38d-c9b43162c609 + type: string + type: + $ref: '#/components/schemas/OktaAccountType' + required: + - attributes + - id + - type + type: object + OktaAccountType: + default: okta-accounts + description: Account type for an Okta account. + enum: + - okta-accounts + example: okta-accounts + type: string + x-enum-varnames: + - OKTA_ACCOUNTS + OktaAccountUpdateRequest: + description: Payload schema when updating an Okta account. + properties: + data: + $ref: '#/components/schemas/OktaAccountUpdateRequestData' + required: + - data + type: object + OktaAccountUpdateRequestAttributes: + description: Attributes object for updating an Okta account. + properties: + api_key: + description: The API key of the Okta account. + type: string + writeOnly: true + auth_method: + description: The authorization method for an Okta account. + example: oauth + type: string + client_id: + description: The Client ID of an Okta app integration. + type: string + client_secret: + description: The client secret of an Okta app integration. + type: string + writeOnly: true + domain: + description: The domain associated with an Okta account. + example: https://dev-test.okta.com/ + type: string + required: + - auth_method + - domain + type: object + OktaAccountUpdateRequestData: + description: Data object for updating an Okta account. + properties: + attributes: + $ref: '#/components/schemas/OktaAccountUpdateRequestAttributes' + type: + $ref: '#/components/schemas/OktaAccountType' + OktaAccountsResponse: + description: The expected response schema when getting Okta accounts. + properties: + data: + description: List of Okta accounts. + items: + $ref: '#/components/schemas/OktaAccountResponseData' + type: array + type: object OnDemandConcurrencyCap: description: On-demand concurrency cap. properties: @@ -22897,6 +23032,156 @@ paths: tags: - Fastly Integration x-codegen-request-body-name: body + /api/v2/integrations/okta/accounts: + get: + description: List Okta accounts. + operationId: ListOktaAccounts + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OktaAccountsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Okta Public - List accounts + tags: + - Okta Integration + post: + description: Create an Okta account. + operationId: CreateOktaAccount + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OktaAccountRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/OktaAccountResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Okta Public - Add account + tags: + - Okta Integration + x-codegen-request-body-name: body + /api/v2/integrations/okta/accounts/{account_id}: + delete: + description: Delete an Okta account. + operationId: DeleteOktaAccount + parameters: + - description: None + in: path + name: account_id + required: true + schema: + type: string + responses: + '204': + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Okta Public - Delete account + tags: + - Okta Integration + get: + description: Get an Okta account. + operationId: GetOktaAccount + parameters: + - description: None + in: path + name: account_id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OktaAccountResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Okta Public - Get account + tags: + - Okta Integration + patch: + description: Update an Okta account. + operationId: UpdateOktaAccount + parameters: + - description: None + in: path + name: account_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OktaAccountUpdateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OktaAccountResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Okta Public - Update account + tags: + - Okta Integration + x-codegen-request-body-name: body /api/v2/ip_allowlist: get: description: Returns the IP allowlist and its enabled or disabled state. @@ -30549,6 +30834,9 @@ tags: description: Find out more at url: https://docs.datadoghq.com/monitors/create/types/ name: Monitors +- description: Configure your Datadog Okta integration directly through the Datadog + API. + name: Okta Integration - description: 'Configure your [Datadog Opsgenie integration](https://docs.datadoghq.com/integrations/opsgenie/) directly through the Datadog API.' diff --git a/api/datadogV2/api_okta_integration.go b/api/datadogV2/api_okta_integration.go new file mode 100644 index 00000000000..774a9e9b580 --- /dev/null +++ b/api/datadogV2/api_okta_integration.go @@ -0,0 +1,373 @@ +// 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" +) + +// OktaIntegrationApi service type +type OktaIntegrationApi datadog.Service + +// CreateOktaAccount Okta Public - Add account. +// Create an Okta account. +func (a *OktaIntegrationApi) CreateOktaAccount(ctx _context.Context, body OktaAccountRequest) (OktaAccountResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue OktaAccountResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.OktaIntegrationApi.CreateOktaAccount") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/okta/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 == 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 +} + +// DeleteOktaAccount Okta Public - Delete account. +// Delete an Okta account. +func (a *OktaIntegrationApi) DeleteOktaAccount(ctx _context.Context, accountId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.OktaIntegrationApi.DeleteOktaAccount") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/okta/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 == 404 || 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 +} + +// GetOktaAccount Okta Public - Get account. +// Get an Okta account. +func (a *OktaIntegrationApi) GetOktaAccount(ctx _context.Context, accountId string) (OktaAccountResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue OktaAccountResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.OktaIntegrationApi.GetOktaAccount") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/okta/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"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListOktaAccounts Okta Public - List accounts. +// List Okta accounts. +func (a *OktaIntegrationApi) ListOktaAccounts(ctx _context.Context) (OktaAccountsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue OktaAccountsResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.OktaIntegrationApi.ListOktaAccounts") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/okta/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 == 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 +} + +// UpdateOktaAccount Okta Public - Update account. +// Update an Okta account. +func (a *OktaIntegrationApi) UpdateOktaAccount(ctx _context.Context, accountId string, body OktaAccountUpdateRequest) (OktaAccountResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue OktaAccountResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.OktaIntegrationApi.UpdateOktaAccount") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/okta/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 +} + +// NewOktaIntegrationApi Returns NewOktaIntegrationApi. +func NewOktaIntegrationApi(client *datadog.APIClient) *OktaIntegrationApi { + return &OktaIntegrationApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index c913c2825c0..a51c538aad7 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -156,6 +156,11 @@ // - [MonitorsApi.GetMonitorConfigPolicy] // - [MonitorsApi.ListMonitorConfigPolicies] // - [MonitorsApi.UpdateMonitorConfigPolicy] +// - [OktaIntegrationApi.CreateOktaAccount] +// - [OktaIntegrationApi.DeleteOktaAccount] +// - [OktaIntegrationApi.GetOktaAccount] +// - [OktaIntegrationApi.ListOktaAccounts] +// - [OktaIntegrationApi.UpdateOktaAccount] // - [OpsgenieIntegrationApi.CreateOpsgenieService] // - [OpsgenieIntegrationApi.DeleteOpsgenieService] // - [OpsgenieIntegrationApi.GetOpsgenieService] diff --git a/api/datadogV2/model_okta_account.go b/api/datadogV2/model_okta_account.go new file mode 100644 index 00000000000..c17e386998b --- /dev/null +++ b/api/datadogV2/model_okta_account.go @@ -0,0 +1,183 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OktaAccount Schema for an Okta account. +type OktaAccount struct { + // Attributes object for an Okta account. + Attributes OktaAccountAttributes `json:"attributes"` + // The ID of the Okta account, a UUID hash of the account name. + Id *string `json:"id,omitempty"` + // Account type for an Okta account. + Type OktaAccountType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOktaAccount instantiates a new OktaAccount 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 NewOktaAccount(attributes OktaAccountAttributes, typeVar OktaAccountType) *OktaAccount { + this := OktaAccount{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewOktaAccountWithDefaults instantiates a new OktaAccount 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 NewOktaAccountWithDefaults() *OktaAccount { + this := OktaAccount{} + var typeVar OktaAccountType = OKTAACCOUNTTYPE_OKTA_ACCOUNTS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *OktaAccount) GetAttributes() OktaAccountAttributes { + if o == nil { + var ret OktaAccountAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *OktaAccount) GetAttributesOk() (*OktaAccountAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *OktaAccount) SetAttributes(v OktaAccountAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *OktaAccount) 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 *OktaAccount) 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 *OktaAccount) 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 *OktaAccount) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value. +func (o *OktaAccount) GetType() OktaAccountType { + if o == nil { + var ret OktaAccountType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *OktaAccount) GetTypeOk() (*OktaAccountType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *OktaAccount) SetType(v OktaAccountType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OktaAccount) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + if o.Id != nil { + toSerialize["id"] = o.Id + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OktaAccount) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *OktaAccountAttributes `json:"attributes"` + Id *string `json:"id,omitempty"` + Type *OktaAccountType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_okta_account_attributes.go b/api/datadogV2/model_okta_account_attributes.go new file mode 100644 index 00000000000..d99622916c2 --- /dev/null +++ b/api/datadogV2/model_okta_account_attributes.go @@ -0,0 +1,270 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OktaAccountAttributes Attributes object for an Okta account. +type OktaAccountAttributes struct { + // The API key of the Okta account. + ApiKey *string `json:"api_key,omitempty"` + // The authorization method for an Okta account. + AuthMethod string `json:"auth_method"` + // The Client ID of an Okta app integration. + ClientId *string `json:"client_id,omitempty"` + // The client secret of an Okta app integration. + ClientSecret *string `json:"client_secret,omitempty"` + // The domain of the Okta account. + Domain string `json:"domain"` + // The name of the Okta account. + Name string `json:"name"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOktaAccountAttributes instantiates a new OktaAccountAttributes 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 NewOktaAccountAttributes(authMethod string, domain string, name string) *OktaAccountAttributes { + this := OktaAccountAttributes{} + this.AuthMethod = authMethod + this.Domain = domain + this.Name = name + return &this +} + +// NewOktaAccountAttributesWithDefaults instantiates a new OktaAccountAttributes 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 NewOktaAccountAttributesWithDefaults() *OktaAccountAttributes { + this := OktaAccountAttributes{} + return &this +} + +// GetApiKey returns the ApiKey field value if set, zero value otherwise. +func (o *OktaAccountAttributes) GetApiKey() string { + if o == nil || o.ApiKey == nil { + var ret string + return ret + } + return *o.ApiKey +} + +// GetApiKeyOk returns a tuple with the ApiKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OktaAccountAttributes) GetApiKeyOk() (*string, bool) { + if o == nil || o.ApiKey == nil { + return nil, false + } + return o.ApiKey, true +} + +// HasApiKey returns a boolean if a field has been set. +func (o *OktaAccountAttributes) HasApiKey() bool { + return o != nil && o.ApiKey != nil +} + +// SetApiKey gets a reference to the given string and assigns it to the ApiKey field. +func (o *OktaAccountAttributes) SetApiKey(v string) { + o.ApiKey = &v +} + +// GetAuthMethod returns the AuthMethod field value. +func (o *OktaAccountAttributes) GetAuthMethod() string { + if o == nil { + var ret string + return ret + } + return o.AuthMethod +} + +// GetAuthMethodOk returns a tuple with the AuthMethod field value +// and a boolean to check if the value has been set. +func (o *OktaAccountAttributes) GetAuthMethodOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AuthMethod, true +} + +// SetAuthMethod sets field value. +func (o *OktaAccountAttributes) SetAuthMethod(v string) { + o.AuthMethod = v +} + +// GetClientId returns the ClientId field value if set, zero value otherwise. +func (o *OktaAccountAttributes) GetClientId() string { + if o == nil || o.ClientId == nil { + var ret string + return ret + } + return *o.ClientId +} + +// GetClientIdOk returns a tuple with the ClientId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OktaAccountAttributes) GetClientIdOk() (*string, bool) { + if o == nil || o.ClientId == nil { + return nil, false + } + return o.ClientId, true +} + +// HasClientId returns a boolean if a field has been set. +func (o *OktaAccountAttributes) HasClientId() bool { + return o != nil && o.ClientId != nil +} + +// SetClientId gets a reference to the given string and assigns it to the ClientId field. +func (o *OktaAccountAttributes) SetClientId(v string) { + o.ClientId = &v +} + +// GetClientSecret returns the ClientSecret field value if set, zero value otherwise. +func (o *OktaAccountAttributes) GetClientSecret() string { + if o == nil || o.ClientSecret == nil { + var ret string + return ret + } + return *o.ClientSecret +} + +// GetClientSecretOk returns a tuple with the ClientSecret field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OktaAccountAttributes) GetClientSecretOk() (*string, bool) { + if o == nil || o.ClientSecret == nil { + return nil, false + } + return o.ClientSecret, true +} + +// HasClientSecret returns a boolean if a field has been set. +func (o *OktaAccountAttributes) HasClientSecret() bool { + return o != nil && o.ClientSecret != nil +} + +// SetClientSecret gets a reference to the given string and assigns it to the ClientSecret field. +func (o *OktaAccountAttributes) SetClientSecret(v string) { + o.ClientSecret = &v +} + +// GetDomain returns the Domain field value. +func (o *OktaAccountAttributes) GetDomain() string { + if o == nil { + var ret string + return ret + } + return o.Domain +} + +// GetDomainOk returns a tuple with the Domain field value +// and a boolean to check if the value has been set. +func (o *OktaAccountAttributes) GetDomainOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Domain, true +} + +// SetDomain sets field value. +func (o *OktaAccountAttributes) SetDomain(v string) { + o.Domain = v +} + +// GetName returns the Name field value. +func (o *OktaAccountAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *OktaAccountAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *OktaAccountAttributes) SetName(v string) { + o.Name = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OktaAccountAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ApiKey != nil { + toSerialize["api_key"] = o.ApiKey + } + toSerialize["auth_method"] = o.AuthMethod + if o.ClientId != nil { + toSerialize["client_id"] = o.ClientId + } + if o.ClientSecret != nil { + toSerialize["client_secret"] = o.ClientSecret + } + toSerialize["domain"] = o.Domain + toSerialize["name"] = o.Name + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OktaAccountAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ApiKey *string `json:"api_key,omitempty"` + AuthMethod *string `json:"auth_method"` + ClientId *string `json:"client_id,omitempty"` + ClientSecret *string `json:"client_secret,omitempty"` + Domain *string `json:"domain"` + Name *string `json:"name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AuthMethod == nil { + return fmt.Errorf("required field auth_method missing") + } + if all.Domain == nil { + return fmt.Errorf("required field domain missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"api_key", "auth_method", "client_id", "client_secret", "domain", "name"}) + } else { + return err + } + o.ApiKey = all.ApiKey + o.AuthMethod = *all.AuthMethod + o.ClientId = all.ClientId + o.ClientSecret = all.ClientSecret + o.Domain = *all.Domain + o.Name = *all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_okta_account_request.go b/api/datadogV2/model_okta_account_request.go new file mode 100644 index 00000000000..d7992846c7a --- /dev/null +++ b/api/datadogV2/model_okta_account_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OktaAccountRequest Request object for an Okta account. +type OktaAccountRequest struct { + // Schema for an Okta account. + Data OktaAccount `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOktaAccountRequest instantiates a new OktaAccountRequest 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 NewOktaAccountRequest(data OktaAccount) *OktaAccountRequest { + this := OktaAccountRequest{} + this.Data = data + return &this +} + +// NewOktaAccountRequestWithDefaults instantiates a new OktaAccountRequest 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 NewOktaAccountRequestWithDefaults() *OktaAccountRequest { + this := OktaAccountRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *OktaAccountRequest) GetData() OktaAccount { + if o == nil { + var ret OktaAccount + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *OktaAccountRequest) GetDataOk() (*OktaAccount, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *OktaAccountRequest) SetData(v OktaAccount) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OktaAccountRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OktaAccountRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *OktaAccount `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_okta_account_response.go b/api/datadogV2/model_okta_account_response.go new file mode 100644 index 00000000000..01668981ece --- /dev/null +++ b/api/datadogV2/model_okta_account_response.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OktaAccountResponse Response object for an Okta account. +type OktaAccountResponse struct { + // Schema for an Okta account. + Data *OktaAccount `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{} +} + +// NewOktaAccountResponse instantiates a new OktaAccountResponse 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 NewOktaAccountResponse() *OktaAccountResponse { + this := OktaAccountResponse{} + return &this +} + +// NewOktaAccountResponseWithDefaults instantiates a new OktaAccountResponse 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 NewOktaAccountResponseWithDefaults() *OktaAccountResponse { + this := OktaAccountResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *OktaAccountResponse) GetData() OktaAccount { + if o == nil || o.Data == nil { + var ret OktaAccount + 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 *OktaAccountResponse) GetDataOk() (*OktaAccount, 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 *OktaAccountResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given OktaAccount and assigns it to the Data field. +func (o *OktaAccountResponse) SetData(v OktaAccount) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OktaAccountResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OktaAccountResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *OktaAccount `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_okta_account_response_data.go b/api/datadogV2/model_okta_account_response_data.go new file mode 100644 index 00000000000..20dcd952704 --- /dev/null +++ b/api/datadogV2/model_okta_account_response_data.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OktaAccountResponseData Data object of an Okta account +type OktaAccountResponseData struct { + // Attributes object for an Okta account. + Attributes OktaAccountAttributes `json:"attributes"` + // The ID of the Okta account, a UUID hash of the account name. + Id string `json:"id"` + // Account type for an Okta account. + Type OktaAccountType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOktaAccountResponseData instantiates a new OktaAccountResponseData 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 NewOktaAccountResponseData(attributes OktaAccountAttributes, id string, typeVar OktaAccountType) *OktaAccountResponseData { + this := OktaAccountResponseData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewOktaAccountResponseDataWithDefaults instantiates a new OktaAccountResponseData 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 NewOktaAccountResponseDataWithDefaults() *OktaAccountResponseData { + this := OktaAccountResponseData{} + var typeVar OktaAccountType = OKTAACCOUNTTYPE_OKTA_ACCOUNTS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *OktaAccountResponseData) GetAttributes() OktaAccountAttributes { + if o == nil { + var ret OktaAccountAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *OktaAccountResponseData) GetAttributesOk() (*OktaAccountAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *OktaAccountResponseData) SetAttributes(v OktaAccountAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *OktaAccountResponseData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *OktaAccountResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *OktaAccountResponseData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *OktaAccountResponseData) GetType() OktaAccountType { + if o == nil { + var ret OktaAccountType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *OktaAccountResponseData) GetTypeOk() (*OktaAccountType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *OktaAccountResponseData) SetType(v OktaAccountType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OktaAccountResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OktaAccountResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *OktaAccountAttributes `json:"attributes"` + Id *string `json:"id"` + Type *OktaAccountType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_okta_account_type.go b/api/datadogV2/model_okta_account_type.go new file mode 100644 index 00000000000..bac620f0c81 --- /dev/null +++ b/api/datadogV2/model_okta_account_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OktaAccountType Account type for an Okta account. +type OktaAccountType string + +// List of OktaAccountType. +const ( + OKTAACCOUNTTYPE_OKTA_ACCOUNTS OktaAccountType = "okta-accounts" +) + +var allowedOktaAccountTypeEnumValues = []OktaAccountType{ + OKTAACCOUNTTYPE_OKTA_ACCOUNTS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *OktaAccountType) GetAllowedValues() []OktaAccountType { + return allowedOktaAccountTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *OktaAccountType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = OktaAccountType(value) + return nil +} + +// NewOktaAccountTypeFromValue returns a pointer to a valid OktaAccountType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewOktaAccountTypeFromValue(v string) (*OktaAccountType, error) { + ev := OktaAccountType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for OktaAccountType: valid values are %v", v, allowedOktaAccountTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v OktaAccountType) IsValid() bool { + for _, existing := range allowedOktaAccountTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to OktaAccountType value. +func (v OktaAccountType) Ptr() *OktaAccountType { + return &v +} diff --git a/api/datadogV2/model_okta_account_update_request.go b/api/datadogV2/model_okta_account_update_request.go new file mode 100644 index 00000000000..b1a5b6e0a34 --- /dev/null +++ b/api/datadogV2/model_okta_account_update_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OktaAccountUpdateRequest Payload schema when updating an Okta account. +type OktaAccountUpdateRequest struct { + // Data object for updating an Okta account. + Data OktaAccountUpdateRequestData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOktaAccountUpdateRequest instantiates a new OktaAccountUpdateRequest 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 NewOktaAccountUpdateRequest(data OktaAccountUpdateRequestData) *OktaAccountUpdateRequest { + this := OktaAccountUpdateRequest{} + this.Data = data + return &this +} + +// NewOktaAccountUpdateRequestWithDefaults instantiates a new OktaAccountUpdateRequest 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 NewOktaAccountUpdateRequestWithDefaults() *OktaAccountUpdateRequest { + this := OktaAccountUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *OktaAccountUpdateRequest) GetData() OktaAccountUpdateRequestData { + if o == nil { + var ret OktaAccountUpdateRequestData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *OktaAccountUpdateRequest) GetDataOk() (*OktaAccountUpdateRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *OktaAccountUpdateRequest) SetData(v OktaAccountUpdateRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OktaAccountUpdateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OktaAccountUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *OktaAccountUpdateRequestData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_okta_account_update_request_attributes.go b/api/datadogV2/model_okta_account_update_request_attributes.go new file mode 100644 index 00000000000..6c2b3ec8295 --- /dev/null +++ b/api/datadogV2/model_okta_account_update_request_attributes.go @@ -0,0 +1,238 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OktaAccountUpdateRequestAttributes Attributes object for updating an Okta account. +type OktaAccountUpdateRequestAttributes struct { + // The API key of the Okta account. + ApiKey *string `json:"api_key,omitempty"` + // The authorization method for an Okta account. + AuthMethod string `json:"auth_method"` + // The Client ID of an Okta app integration. + ClientId *string `json:"client_id,omitempty"` + // The client secret of an Okta app integration. + ClientSecret *string `json:"client_secret,omitempty"` + // The domain associated with an Okta account. + Domain string `json:"domain"` + // 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{} +} + +// NewOktaAccountUpdateRequestAttributes instantiates a new OktaAccountUpdateRequestAttributes 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 NewOktaAccountUpdateRequestAttributes(authMethod string, domain string) *OktaAccountUpdateRequestAttributes { + this := OktaAccountUpdateRequestAttributes{} + this.AuthMethod = authMethod + this.Domain = domain + return &this +} + +// NewOktaAccountUpdateRequestAttributesWithDefaults instantiates a new OktaAccountUpdateRequestAttributes 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 NewOktaAccountUpdateRequestAttributesWithDefaults() *OktaAccountUpdateRequestAttributes { + this := OktaAccountUpdateRequestAttributes{} + return &this +} + +// GetApiKey returns the ApiKey field value if set, zero value otherwise. +func (o *OktaAccountUpdateRequestAttributes) GetApiKey() string { + if o == nil || o.ApiKey == nil { + var ret string + return ret + } + return *o.ApiKey +} + +// GetApiKeyOk returns a tuple with the ApiKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OktaAccountUpdateRequestAttributes) GetApiKeyOk() (*string, bool) { + if o == nil || o.ApiKey == nil { + return nil, false + } + return o.ApiKey, true +} + +// HasApiKey returns a boolean if a field has been set. +func (o *OktaAccountUpdateRequestAttributes) HasApiKey() bool { + return o != nil && o.ApiKey != nil +} + +// SetApiKey gets a reference to the given string and assigns it to the ApiKey field. +func (o *OktaAccountUpdateRequestAttributes) SetApiKey(v string) { + o.ApiKey = &v +} + +// GetAuthMethod returns the AuthMethod field value. +func (o *OktaAccountUpdateRequestAttributes) GetAuthMethod() string { + if o == nil { + var ret string + return ret + } + return o.AuthMethod +} + +// GetAuthMethodOk returns a tuple with the AuthMethod field value +// and a boolean to check if the value has been set. +func (o *OktaAccountUpdateRequestAttributes) GetAuthMethodOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AuthMethod, true +} + +// SetAuthMethod sets field value. +func (o *OktaAccountUpdateRequestAttributes) SetAuthMethod(v string) { + o.AuthMethod = v +} + +// GetClientId returns the ClientId field value if set, zero value otherwise. +func (o *OktaAccountUpdateRequestAttributes) GetClientId() string { + if o == nil || o.ClientId == nil { + var ret string + return ret + } + return *o.ClientId +} + +// GetClientIdOk returns a tuple with the ClientId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OktaAccountUpdateRequestAttributes) GetClientIdOk() (*string, bool) { + if o == nil || o.ClientId == nil { + return nil, false + } + return o.ClientId, true +} + +// HasClientId returns a boolean if a field has been set. +func (o *OktaAccountUpdateRequestAttributes) HasClientId() bool { + return o != nil && o.ClientId != nil +} + +// SetClientId gets a reference to the given string and assigns it to the ClientId field. +func (o *OktaAccountUpdateRequestAttributes) SetClientId(v string) { + o.ClientId = &v +} + +// GetClientSecret returns the ClientSecret field value if set, zero value otherwise. +func (o *OktaAccountUpdateRequestAttributes) GetClientSecret() string { + if o == nil || o.ClientSecret == nil { + var ret string + return ret + } + return *o.ClientSecret +} + +// GetClientSecretOk returns a tuple with the ClientSecret field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OktaAccountUpdateRequestAttributes) GetClientSecretOk() (*string, bool) { + if o == nil || o.ClientSecret == nil { + return nil, false + } + return o.ClientSecret, true +} + +// HasClientSecret returns a boolean if a field has been set. +func (o *OktaAccountUpdateRequestAttributes) HasClientSecret() bool { + return o != nil && o.ClientSecret != nil +} + +// SetClientSecret gets a reference to the given string and assigns it to the ClientSecret field. +func (o *OktaAccountUpdateRequestAttributes) SetClientSecret(v string) { + o.ClientSecret = &v +} + +// GetDomain returns the Domain field value. +func (o *OktaAccountUpdateRequestAttributes) GetDomain() string { + if o == nil { + var ret string + return ret + } + return o.Domain +} + +// GetDomainOk returns a tuple with the Domain field value +// and a boolean to check if the value has been set. +func (o *OktaAccountUpdateRequestAttributes) GetDomainOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Domain, true +} + +// SetDomain sets field value. +func (o *OktaAccountUpdateRequestAttributes) SetDomain(v string) { + o.Domain = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OktaAccountUpdateRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ApiKey != nil { + toSerialize["api_key"] = o.ApiKey + } + toSerialize["auth_method"] = o.AuthMethod + if o.ClientId != nil { + toSerialize["client_id"] = o.ClientId + } + if o.ClientSecret != nil { + toSerialize["client_secret"] = o.ClientSecret + } + toSerialize["domain"] = o.Domain + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OktaAccountUpdateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ApiKey *string `json:"api_key,omitempty"` + AuthMethod *string `json:"auth_method"` + ClientId *string `json:"client_id,omitempty"` + ClientSecret *string `json:"client_secret,omitempty"` + Domain *string `json:"domain"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AuthMethod == nil { + return fmt.Errorf("required field auth_method missing") + } + if all.Domain == nil { + return fmt.Errorf("required field domain missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"api_key", "auth_method", "client_id", "client_secret", "domain"}) + } else { + return err + } + o.ApiKey = all.ApiKey + o.AuthMethod = *all.AuthMethod + o.ClientId = all.ClientId + o.ClientSecret = all.ClientSecret + o.Domain = *all.Domain + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_okta_account_update_request_data.go b/api/datadogV2/model_okta_account_update_request_data.go new file mode 100644 index 00000000000..3945bc4b5b4 --- /dev/null +++ b/api/datadogV2/model_okta_account_update_request_data.go @@ -0,0 +1,154 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OktaAccountUpdateRequestData Data object for updating an Okta account. +type OktaAccountUpdateRequestData struct { + // Attributes object for updating an Okta account. + Attributes *OktaAccountUpdateRequestAttributes `json:"attributes,omitempty"` + // Account type for an Okta account. + Type *OktaAccountType `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{} +} + +// NewOktaAccountUpdateRequestData instantiates a new OktaAccountUpdateRequestData 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 NewOktaAccountUpdateRequestData() *OktaAccountUpdateRequestData { + this := OktaAccountUpdateRequestData{} + var typeVar OktaAccountType = OKTAACCOUNTTYPE_OKTA_ACCOUNTS + this.Type = &typeVar + return &this +} + +// NewOktaAccountUpdateRequestDataWithDefaults instantiates a new OktaAccountUpdateRequestData 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 NewOktaAccountUpdateRequestDataWithDefaults() *OktaAccountUpdateRequestData { + this := OktaAccountUpdateRequestData{} + var typeVar OktaAccountType = OKTAACCOUNTTYPE_OKTA_ACCOUNTS + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *OktaAccountUpdateRequestData) GetAttributes() OktaAccountUpdateRequestAttributes { + if o == nil || o.Attributes == nil { + var ret OktaAccountUpdateRequestAttributes + 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 *OktaAccountUpdateRequestData) GetAttributesOk() (*OktaAccountUpdateRequestAttributes, 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 *OktaAccountUpdateRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given OktaAccountUpdateRequestAttributes and assigns it to the Attributes field. +func (o *OktaAccountUpdateRequestData) SetAttributes(v OktaAccountUpdateRequestAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *OktaAccountUpdateRequestData) GetType() OktaAccountType { + if o == nil || o.Type == nil { + var ret OktaAccountType + 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 *OktaAccountUpdateRequestData) GetTypeOk() (*OktaAccountType, 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 *OktaAccountUpdateRequestData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given OktaAccountType and assigns it to the Type field. +func (o *OktaAccountUpdateRequestData) SetType(v OktaAccountType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OktaAccountUpdateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.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 datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OktaAccountUpdateRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *OktaAccountUpdateRequestAttributes `json:"attributes,omitempty"` + Type *OktaAccountType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_okta_accounts_response.go b/api/datadogV2/model_okta_accounts_response.go new file mode 100644 index 00000000000..b32297af2d4 --- /dev/null +++ b/api/datadogV2/model_okta_accounts_response.go @@ -0,0 +1,102 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OktaAccountsResponse The expected response schema when getting Okta accounts. +type OktaAccountsResponse struct { + // List of Okta accounts. + Data []OktaAccountResponseData `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{} +} + +// NewOktaAccountsResponse instantiates a new OktaAccountsResponse 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 NewOktaAccountsResponse() *OktaAccountsResponse { + this := OktaAccountsResponse{} + return &this +} + +// NewOktaAccountsResponseWithDefaults instantiates a new OktaAccountsResponse 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 NewOktaAccountsResponseWithDefaults() *OktaAccountsResponse { + this := OktaAccountsResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *OktaAccountsResponse) GetData() []OktaAccountResponseData { + if o == nil || o.Data == nil { + var ret []OktaAccountResponseData + 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 *OktaAccountsResponse) GetDataOk() (*[]OktaAccountResponseData, 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 *OktaAccountsResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []OktaAccountResponseData and assigns it to the Data field. +func (o *OktaAccountsResponse) SetData(v []OktaAccountResponseData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OktaAccountsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OktaAccountsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []OktaAccountResponseData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/okta-integration/CreateOktaAccount.go b/examples/v2/okta-integration/CreateOktaAccount.go new file mode 100644 index 00000000000..372c2c4fce3 --- /dev/null +++ b/examples/v2/okta-integration/CreateOktaAccount.go @@ -0,0 +1,42 @@ +// Okta Public - Add 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.OktaAccountRequest{ + Data: datadogV2.OktaAccount{ + Attributes: datadogV2.OktaAccountAttributes{ + AuthMethod: "oauth", + Domain: "https://example.okta.com/", + Name: "Okta_Prod", + ClientId: datadog.PtrString("client_id"), + ClientSecret: datadog.PtrString("client_secret"), + }, + Id: datadog.PtrString("f749daaf-682e-4208-a38d-c9b43162c609"), + Type: datadogV2.OKTAACCOUNTTYPE_OKTA_ACCOUNTS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewOktaIntegrationApi(apiClient) + resp, r, err := api.CreateOktaAccount(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OktaIntegrationApi.CreateOktaAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `OktaIntegrationApi.CreateOktaAccount`:\n%s\n", responseContent) +} diff --git a/examples/v2/okta-integration/DeleteOktaAccount.go b/examples/v2/okta-integration/DeleteOktaAccount.go new file mode 100644 index 00000000000..25924070d39 --- /dev/null +++ b/examples/v2/okta-integration/DeleteOktaAccount.go @@ -0,0 +1,25 @@ +// Okta Public - Delete account returns "OK" 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.NewOktaIntegrationApi(apiClient) + r, err := api.DeleteOktaAccount(ctx, "account_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OktaIntegrationApi.DeleteOktaAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/okta-integration/GetOktaAccount.go b/examples/v2/okta-integration/GetOktaAccount.go new file mode 100644 index 00000000000..01301ca9fed --- /dev/null +++ b/examples/v2/okta-integration/GetOktaAccount.go @@ -0,0 +1,32 @@ +// Okta Public - Get 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() { + // there is a valid "okta_account" in the system + OktaAccountDataID := os.Getenv("OKTA_ACCOUNT_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewOktaIntegrationApi(apiClient) + resp, r, err := api.GetOktaAccount(ctx, OktaAccountDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OktaIntegrationApi.GetOktaAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `OktaIntegrationApi.GetOktaAccount`:\n%s\n", responseContent) +} diff --git a/examples/v2/okta-integration/ListOktaAccounts.go b/examples/v2/okta-integration/ListOktaAccounts.go new file mode 100644 index 00000000000..9d58c464684 --- /dev/null +++ b/examples/v2/okta-integration/ListOktaAccounts.go @@ -0,0 +1,29 @@ +// Okta Public - List 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.NewOktaIntegrationApi(apiClient) + resp, r, err := api.ListOktaAccounts(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OktaIntegrationApi.ListOktaAccounts`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `OktaIntegrationApi.ListOktaAccounts`:\n%s\n", responseContent) +} diff --git a/examples/v2/okta-integration/UpdateOktaAccount.go b/examples/v2/okta-integration/UpdateOktaAccount.go new file mode 100644 index 00000000000..0441a4eadb7 --- /dev/null +++ b/examples/v2/okta-integration/UpdateOktaAccount.go @@ -0,0 +1,43 @@ +// Okta Public - Update 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() { + // there is a valid "okta_account" in the system + OktaAccountDataID := os.Getenv("OKTA_ACCOUNT_DATA_ID") + + body := datadogV2.OktaAccountUpdateRequest{ + Data: datadogV2.OktaAccountUpdateRequestData{ + Attributes: &datadogV2.OktaAccountUpdateRequestAttributes{ + AuthMethod: "oauth", + Domain: "https://example.okta.com/", + ClientId: datadog.PtrString("client_id"), + ClientSecret: datadog.PtrString("client_secret"), + }, + Type: datadogV2.OKTAACCOUNTTYPE_OKTA_ACCOUNTS.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewOktaIntegrationApi(apiClient) + resp, r, err := api.UpdateOktaAccount(ctx, OktaAccountDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OktaIntegrationApi.UpdateOktaAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `OktaIntegrationApi.UpdateOktaAccount`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 38da1ac950d..e8185649c65 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -62,6 +62,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "CloudflareIntegrationApi": reflect.ValueOf(datadogV2.NewCloudflareIntegrationApi), "ConfluentCloudApi": reflect.ValueOf(datadogV2.NewConfluentCloudApi), "FastlyIntegrationApi": reflect.ValueOf(datadogV2.NewFastlyIntegrationApi), + "OktaIntegrationApi": reflect.ValueOf(datadogV2.NewOktaIntegrationApi), "IPAllowlistApi": reflect.ValueOf(datadogV2.NewIPAllowlistApi), "LogsApi": reflect.ValueOf(datadogV2.NewLogsApi), "LogsArchivesApi": reflect.ValueOf(datadogV2.NewLogsArchivesApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Add_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Add_account_returns_OK_response.freeze new file mode 100644 index 00000000000..ca0230b7cb6 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Add_account_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-11-14T16:22:56.895Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Add_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Add_account_returns_OK_response.yaml new file mode 100644 index 00000000000..f0dd5d1bd45 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Add_account_returns_OK_response.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"auth_method":"oauth","client_id":"client_id","client_secret":"client_secret","domain":"https://example.okta.com/","name":"Okta_Prod"},"id":"f749daaf-682e-4208-a38d-c9b43162c609","type":"okta-accounts"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts + response: + body: '{"data":{"type":"okta-accounts","attributes":{"client_id":"client_id","domain":"https://example.okta.com/","auth_method":"oauth","name":"Okta_Prod"},"id":"fa09f5b1-9ef7-4ff6-a5c7-850aeaf25c31"}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts/fa09f5b1-9ef7-4ff6-a5c7-850aeaf25c31 + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Get_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Get_account_returns_OK_response.freeze new file mode 100644 index 00000000000..2aba91505ca --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Get_account_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-11-14T16:22:58.356Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Get_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Get_account_returns_OK_response.yaml new file mode 100644 index 00000000000..3161ddc644a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Get_account_returns_OK_response.yaml @@ -0,0 +1,57 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"auth_method":"oauth","client_id":"fakeclientid","client_secret":"fakeclientsecret","domain":"https://dev-test.okta.com/","name":"testoktapublicgetaccountreturnsokresponse1699978978"},"type":"okta-accounts"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts + response: + body: '{"data":{"type":"okta-accounts","attributes":{"auth_method":"oauth","domain":"https://dev-test.okta.com/","name":"testoktapublicgetaccountreturnsokresponse1699978978","client_id":"fakeclientid"},"id":"68ae77bb-60b4-48b3-b581-b0aea6063807"}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts/68ae77bb-60b4-48b3-b581-b0aea6063807 + response: + body: '{"data":{"type":"okta-accounts","id":"68ae77bb-60b4-48b3-b581-b0aea6063807","attributes":{"domain":"https://dev-test.okta.com/","client_id":"fakeclientid","name":"testoktapublicgetaccountreturnsokresponse1699978978","auth_method":"oauth"}}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts/68ae77bb-60b4-48b3-b581-b0aea6063807 + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_List_accounts_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_List_accounts_returns_OK_response.freeze new file mode 100644 index 00000000000..cf0578ede28 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_List_accounts_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-11-14T19:29:24.526Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_List_accounts_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_List_accounts_returns_OK_response.yaml new file mode 100644 index 00000000000..2890a18a3c7 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_List_accounts_returns_OK_response.yaml @@ -0,0 +1,57 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"auth_method":"oauth","client_id":"fakeclientid","client_secret":"fakeclientsecret","domain":"https://dev-test.okta.com/","name":"testoktapubliclistaccountsreturnsokresponse1699990164"},"type":"okta-accounts"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts + response: + body: '{"data":{"type":"okta-accounts","id":"2136ea28-e185-4c33-8a47-0b5acea6009d","attributes":{"domain":"https://dev-test.okta.com/","name":"testoktapubliclistaccountsreturnsokresponse1699990164","client_id":"fakeclientid","auth_method":"oauth"}}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts + response: + body: '{"data":[{"type":"okta-accounts","attributes":{"client_id":"client_id","auth_method":"oauth","name":"testoktapublicupdateaccountreturnsokresponse1699978854","domain":"https://example.okta.com/"},"id":"9637ddf0-4f5e-4adb-89b0-72b7c843116f"},{"type":"okta-accounts","attributes":{"client_id":"client_id","auth_method":"oauth","name":"testoktapublicupdateaccountreturnsokresponse1699978979","domain":"https://example.okta.com/"},"id":"199e06bf-6805-403c-8b97-34c10f526485"},{"type":"okta-accounts","attributes":{"client_id":"client_id","auth_method":"oauth","name":"testoktapublicupdateaccountreturnsokresponse1699989540","domain":"https://example.okta.com/"},"id":"2770caff-0eb2-4edf-b3dd-63b42d706c79"},{"type":"okta-accounts","attributes":{"client_id":"fakeclientid","auth_method":"oauth","name":"testoktapubliclistaccountsreturnsokresponse1699990164","domain":"https://dev-test.okta.com/"},"id":"2136ea28-e185-4c33-8a47-0b5acea6009d"}]} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts/2136ea28-e185-4c33-8a47-0b5acea6009d + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Update_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Update_account_returns_OK_response.freeze new file mode 100644 index 00000000000..601fee0d973 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Update_account_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-11-14T19:29:25.467Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Update_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Update_account_returns_OK_response.yaml new file mode 100644 index 00000000000..7c246ea4ff0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Okta_Integration/Scenario_Okta_Public_-_Update_account_returns_OK_response.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"auth_method":"oauth","client_id":"fakeclientid","client_secret":"fakeclientsecret","domain":"https://dev-test.okta.com/","name":"testoktapublicupdateaccountreturnsokresponse1699990165"},"type":"okta-accounts"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts + response: + body: '{"data":{"type":"okta-accounts","attributes":{"auth_method":"oauth","client_id":"fakeclientid","domain":"https://dev-test.okta.com/","name":"testoktapublicupdateaccountreturnsokresponse1699990165"},"id":"6a6f3fab-9cf9-46b4-8d45-604f86124137"}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"auth_method":"oauth","client_id":"client_id","client_secret":"client_secret","domain":"https://example.okta.com/"},"type":"okta-accounts"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: PATCH + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts/6a6f3fab-9cf9-46b4-8d45-604f86124137 + response: + body: '{"data":{"type":"okta-accounts","attributes":{"client_id":"client_id","name":"testoktapublicupdateaccountreturnsokresponse1699990165","auth_method":"oauth","domain":"https://example.okta.com/"},"id":"ee163be4-1a6d-466e-ba9d-539e5c505645"}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/integrations/okta/accounts/6a6f3fab-9cf9-46b4-8d45-604f86124137 + response: + body: '{"errors":["Unknown error occurred: "]}' + code: 400 + duration: '' + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 1 diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 396c5f5089c..87cad5da34c 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -223,6 +223,18 @@ "tag": "Fastly Integration", "operationId": "CreateFastlyAccount" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"okta-accounts\",\n \"attributes\": {\n \"auth_method\": \"oauth\",\n \"name\": \"{{ unique_lower_alnum }}\",\n \"domain\": \"https://dev-test.okta.com/\",\n \"client_id\": \"fakeclientid\",\n \"client_secret\": \"fakeclientsecret\"\n }\n }\n}" + } + ], + "step": "there is a valid \"okta_account\" in the system", + "key": "okta_account", + "tag": "Okta Integration", + "operationId": "CreateOktaAccount" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/okta_integration.feature b/tests/scenarios/features/v2/okta_integration.feature new file mode 100644 index 00000000000..e30bbd9bf68 --- /dev/null +++ b/tests/scenarios/features/v2/okta_integration.feature @@ -0,0 +1,117 @@ +@endpoint(okta-integration) @endpoint(okta-integration-v2) +Feature: Okta Integration + Configure your Datadog Okta integration directly through the Datadog API. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "OktaIntegration" API + + @generated @skip @team:Datadog/web-integrations + Scenario: Okta Public - Add account returns "Bad Request" response + Given new "CreateOktaAccount" request + And body with value {"data": {"attributes": {"auth_method": "oauth", "domain": "https://example.okta.com/", "name": "Okta-Prod"}, "id": "f749daaf-682e-4208-a38d-c9b43162c609", "type": "okta-accounts"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: Okta Public - Add account returns "Not Found" response + Given new "CreateOktaAccount" request + And body with value {"data": {"attributes": {"auth_method": "oauth", "domain": "https://example.okta.com/", "name": "Okta-Prod"}, "id": "f749daaf-682e-4208-a38d-c9b43162c609", "type": "okta-accounts"}} + When the request is sent + Then the response status is 404 Not Found + + @team:Datadog/web-integrations + Scenario: Okta Public - Add account returns "OK" response + Given new "CreateOktaAccount" request + And body with value {"data": {"attributes": {"auth_method": "oauth", "domain": "https://example.okta.com/", "name": "Okta_Prod", "client_id": "client_id", "client_secret":"client_secret"},"id": "f749daaf-682e-4208-a38d-c9b43162c609", "type": "okta-accounts"}} + When the request is sent + Then the response status is 201 OK + + @generated @skip @team:Datadog/web-integrations + Scenario: Okta Public - Delete account returns "Bad Request" response + Given new "DeleteOktaAccount" 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/web-integrations + Scenario: Okta Public - Delete account returns "Not Found" response + Given new "DeleteOktaAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/web-integrations + Scenario: Okta Public - Delete account returns "OK" response + Given new "DeleteOktaAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 OK + + @generated @skip @team:Datadog/web-integrations + Scenario: Okta Public - Get account returns "Bad Request" response + Given new "GetOktaAccount" 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/web-integrations + Scenario: Okta Public - Get account returns "Not Found" response + Given new "GetOktaAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:Datadog/web-integrations + Scenario: Okta Public - Get account returns "OK" response + Given there is a valid "okta_account" in the system + And new "GetOktaAccount" request + And request contains "account_id" parameter from "okta_account.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "okta-accounts" + + @generated @skip @team:Datadog/web-integrations + Scenario: Okta Public - List accounts returns "Bad Request" response + Given new "ListOktaAccounts" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: Okta Public - List accounts returns "Not Found" response + Given new "ListOktaAccounts" request + When the request is sent + Then the response status is 404 Not Found + + @team:Datadog/web-integrations + Scenario: Okta Public - List accounts returns "OK" response + Given there is a valid "okta_account" in the system + And new "ListOktaAccounts" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/web-integrations + Scenario: Okta Public - Update account returns "Bad Request" response + Given new "UpdateOktaAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: Okta Public - Update account returns "Not Found" response + Given new "UpdateOktaAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {} + When the request is sent + Then the response status is 404 Not Found + + @team:Datadog/web-integrations + Scenario: Okta Public - Update account returns "OK" response + Given there is a valid "okta_account" in the system + And new "UpdateOktaAccount" request + And request contains "account_id" parameter from "okta_account.data.id" + And body with value {"data": {"attributes": {"auth_method": "oauth", "domain": "https://example.okta.com/", "client_id": "client_id", "client_secret":"client_secret"}, "type": "okta-accounts"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 1e1bd2a6a45..64b679bf090 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -748,6 +748,43 @@ "type": "safe" } }, + "ListOktaAccounts": { + "tag": "Okta Integration", + "undo": { + "type": "safe" + } + }, + "CreateOktaAccount": { + "tag": "Okta Integration", + "undo": { + "operationId": "DeleteOktaAccount", + "parameters": [ + { + "name": "account_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteOktaAccount": { + "tag": "Okta Integration", + "undo": { + "type": "idempotent" + } + }, + "GetOktaAccount": { + "tag": "Okta Integration", + "undo": { + "type": "safe" + } + }, + "UpdateOktaAccount": { + "tag": "Okta Integration", + "undo": { + "type": "idempotent" + } + }, "GetIPAllowlist": { "tag": "IP Allowlist", "undo": {