diff --git a/.apigentools-info b/.apigentools-info index 2f7b370427d..912624e6fdf 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-10-29 20:46:37.332067", - "spec_repo_commit": "c0b9551e" + "regenerated": "2024-10-30 18:18:17.589940", + "spec_repo_commit": "10f85c67" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-10-29 20:46:37.350717", - "spec_repo_commit": "c0b9551e" + "regenerated": "2024-10-30 18:18:17.609191", + "spec_repo_commit": "10f85c67" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ab32a814306..38238fba6cc 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -7115,6 +7115,81 @@ components: description: The type of the resource. The value should always be device. type: string type: object + DomainAllowlist: + description: The email domain allowlist for an org. + properties: + attributes: + $ref: '#/components/schemas/DomainAllowlistAttributes' + id: + description: The unique identifier of the org. + nullable: true + type: string + type: + $ref: '#/components/schemas/DomainAllowlistType' + required: + - type + type: object + DomainAllowlistAttributes: + description: The details of the email domain allowlist. + properties: + domains: + description: The list of domains in the email domain allowlist. + items: + type: string + type: array + enabled: + description: Whether the email domain allowlist is enabled for the org. + type: boolean + type: object + DomainAllowlistRequest: + description: Request containing the desired email domain allowlist configuration. + properties: + data: + $ref: '#/components/schemas/DomainAllowlist' + required: + - data + type: object + DomainAllowlistResponse: + description: Response containing information about the email domain allowlist. + properties: + data: + $ref: '#/components/schemas/DomainAllowlistResponseData' + type: object + DomainAllowlistResponseData: + description: The email domain allowlist response for an org. + properties: + attributes: + $ref: '#/components/schemas/DomainAllowlistResponseDataAttributes' + id: + description: The unique identifier of the org. + nullable: true + type: string + type: + $ref: '#/components/schemas/DomainAllowlistType' + required: + - type + type: object + DomainAllowlistResponseDataAttributes: + description: The details of the email domain allowlist. + properties: + domains: + description: The list of domains in the email domain allowlist. + items: + type: string + type: array + enabled: + description: Whether the email domain allowlist is enabled for the org. + type: boolean + type: object + DomainAllowlistType: + default: domain_allowlist + description: Email domain allowlist allowlist type. + enum: + - domain_allowlist + example: domain_allowlist + type: string + x-enum-varnames: + - DOMAIN_ALLOWLIST DowntimeCreateRequest: description: Request for creating a downtime. properties: @@ -29433,6 +29508,61 @@ paths: tags: - Dashboard Lists x-codegen-request-body-name: body + /api/v2/domain_allowlist: + get: + description: Get the domain allowlist for an organization. + operationId: GetDomainAllowlist + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DomainAllowlistResponse' + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - org_management + summary: Get Domain Allowlist + tags: + - Domain Allowlist + x-permission: + operator: OR + permissions: + - org_management + patch: + description: Update the domain allowlist for an organization. + operationId: PatchDomainAllowlist + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DomainAllowlistRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DomainAllowlistResponse' + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - org_management + summary: Sets Domain Allowlist + tags: + - Domain Allowlist + x-permission: + operator: OR + permissions: + - org_management /api/v2/dora/deployment: post: description: 'Use this API endpoint to provide data about deployments for DORA @@ -41786,6 +41916,14 @@ tags: organization.' name: Dashboard Lists +- description: 'Configure your Datadog Email Domain Allowlist directly through the + Datadog API. + + The Email Domain Allowlist controls the domains that certain datadog emails can + be sent to. + + For more information, see the [Domain Allowlist docs page](https://docs.datadoghq.com/account_management/org_settings/domain_allowlist)' + name: Domain Allowlist - description: '**Note**: Downtime V2 is currently in private beta. To request access, contact [Datadog support](https://docs.datadoghq.com/help/). diff --git a/api/datadogV2/api_domain_allowlist.go b/api/datadogV2/api_domain_allowlist.go new file mode 100644 index 00000000000..05e3e3d10c4 --- /dev/null +++ b/api/datadogV2/api_domain_allowlist.go @@ -0,0 +1,166 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + _context "context" + _nethttp "net/http" + _neturl "net/url" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DomainAllowlistApi service type +type DomainAllowlistApi datadog.Service + +// GetDomainAllowlist Get Domain Allowlist. +// Get the domain allowlist for an organization. +func (a *DomainAllowlistApi) GetDomainAllowlist(ctx _context.Context) (DomainAllowlistResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue DomainAllowlistResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DomainAllowlistApi.GetDomainAllowlist") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/domain_allowlist" + + 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 == 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 +} + +// PatchDomainAllowlist Sets Domain Allowlist. +// Update the domain allowlist for an organization. +func (a *DomainAllowlistApi) PatchDomainAllowlist(ctx _context.Context, body DomainAllowlistRequest) (DomainAllowlistResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue DomainAllowlistResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DomainAllowlistApi.PatchDomainAllowlist") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/domain_allowlist" + + 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 == 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 +} + +// NewDomainAllowlistApi Returns NewDomainAllowlistApi. +func NewDomainAllowlistApi(client *datadog.APIClient) *DomainAllowlistApi { + return &DomainAllowlistApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index f4ebd04e21a..43fe946bdae 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -90,6 +90,8 @@ // - [DashboardListsApi.DeleteDashboardListItems] // - [DashboardListsApi.GetDashboardListItems] // - [DashboardListsApi.UpdateDashboardListItems] +// - [DomainAllowlistApi.GetDomainAllowlist] +// - [DomainAllowlistApi.PatchDomainAllowlist] // - [DowntimesApi.CancelDowntime] // - [DowntimesApi.CreateDowntime] // - [DowntimesApi.GetDowntime] diff --git a/api/datadogV2/model_domain_allowlist.go b/api/datadogV2/model_domain_allowlist.go new file mode 100644 index 00000000000..4bee3b9e1a2 --- /dev/null +++ b/api/datadogV2/model_domain_allowlist.go @@ -0,0 +1,197 @@ +// 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" +) + +// DomainAllowlist The email domain allowlist for an org. +type DomainAllowlist struct { + // The details of the email domain allowlist. + Attributes *DomainAllowlistAttributes `json:"attributes,omitempty"` + // The unique identifier of the org. + Id datadog.NullableString `json:"id,omitempty"` + // Email domain allowlist allowlist type. + Type DomainAllowlistType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDomainAllowlist instantiates a new DomainAllowlist 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 NewDomainAllowlist(typeVar DomainAllowlistType) *DomainAllowlist { + this := DomainAllowlist{} + this.Type = typeVar + return &this +} + +// NewDomainAllowlistWithDefaults instantiates a new DomainAllowlist 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 NewDomainAllowlistWithDefaults() *DomainAllowlist { + this := DomainAllowlist{} + var typeVar DomainAllowlistType = DOMAINALLOWLISTTYPE_DOMAIN_ALLOWLIST + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *DomainAllowlist) GetAttributes() DomainAllowlistAttributes { + if o == nil || o.Attributes == nil { + var ret DomainAllowlistAttributes + 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 *DomainAllowlist) GetAttributesOk() (*DomainAllowlistAttributes, 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 *DomainAllowlist) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given DomainAllowlistAttributes and assigns it to the Attributes field. +func (o *DomainAllowlist) SetAttributes(v DomainAllowlistAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *DomainAllowlist) GetId() string { + if o == nil || o.Id.Get() == nil { + var ret string + return ret + } + return *o.Id.Get() +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *DomainAllowlist) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Id.Get(), o.Id.IsSet() +} + +// HasId returns a boolean if a field has been set. +func (o *DomainAllowlist) HasId() bool { + return o != nil && o.Id.IsSet() +} + +// SetId gets a reference to the given datadog.NullableString and assigns it to the Id field. +func (o *DomainAllowlist) SetId(v string) { + o.Id.Set(&v) +} + +// SetIdNil sets the value for Id to be an explicit nil. +func (o *DomainAllowlist) SetIdNil() { + o.Id.Set(nil) +} + +// UnsetId ensures that no value is present for Id, not even an explicit nil. +func (o *DomainAllowlist) UnsetId() { + o.Id.Unset() +} + +// GetType returns the Type field value. +func (o *DomainAllowlist) GetType() DomainAllowlistType { + if o == nil { + var ret DomainAllowlistType + 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 *DomainAllowlist) GetTypeOk() (*DomainAllowlistType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DomainAllowlist) SetType(v DomainAllowlistType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DomainAllowlist) 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.Id.IsSet() { + toSerialize["id"] = o.Id.Get() + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DomainAllowlist) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *DomainAllowlistAttributes `json:"attributes,omitempty"` + Id datadog.NullableString `json:"id,omitempty"` + Type *DomainAllowlistType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && 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_domain_allowlist_attributes.go b/api/datadogV2/model_domain_allowlist_attributes.go new file mode 100644 index 00000000000..9680793f92b --- /dev/null +++ b/api/datadogV2/model_domain_allowlist_attributes.go @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DomainAllowlistAttributes The details of the email domain allowlist. +type DomainAllowlistAttributes struct { + // The list of domains in the email domain allowlist. + Domains []string `json:"domains,omitempty"` + // Whether the email domain allowlist is enabled for the org. + Enabled *bool `json:"enabled,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDomainAllowlistAttributes instantiates a new DomainAllowlistAttributes 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 NewDomainAllowlistAttributes() *DomainAllowlistAttributes { + this := DomainAllowlistAttributes{} + return &this +} + +// NewDomainAllowlistAttributesWithDefaults instantiates a new DomainAllowlistAttributes 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 NewDomainAllowlistAttributesWithDefaults() *DomainAllowlistAttributes { + this := DomainAllowlistAttributes{} + return &this +} + +// GetDomains returns the Domains field value if set, zero value otherwise. +func (o *DomainAllowlistAttributes) GetDomains() []string { + if o == nil || o.Domains == nil { + var ret []string + return ret + } + return o.Domains +} + +// GetDomainsOk returns a tuple with the Domains field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DomainAllowlistAttributes) GetDomainsOk() (*[]string, bool) { + if o == nil || o.Domains == nil { + return nil, false + } + return &o.Domains, true +} + +// HasDomains returns a boolean if a field has been set. +func (o *DomainAllowlistAttributes) HasDomains() bool { + return o != nil && o.Domains != nil +} + +// SetDomains gets a reference to the given []string and assigns it to the Domains field. +func (o *DomainAllowlistAttributes) SetDomains(v []string) { + o.Domains = v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *DomainAllowlistAttributes) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DomainAllowlistAttributes) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *DomainAllowlistAttributes) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *DomainAllowlistAttributes) SetEnabled(v bool) { + o.Enabled = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DomainAllowlistAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Domains != nil { + toSerialize["domains"] = o.Domains + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DomainAllowlistAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Domains []string `json:"domains,omitempty"` + Enabled *bool `json:"enabled,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{"domains", "enabled"}) + } else { + return err + } + o.Domains = all.Domains + o.Enabled = all.Enabled + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_domain_allowlist_request.go b/api/datadogV2/model_domain_allowlist_request.go new file mode 100644 index 00000000000..5887bb8d30d --- /dev/null +++ b/api/datadogV2/model_domain_allowlist_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" +) + +// DomainAllowlistRequest Request containing the desired email domain allowlist configuration. +type DomainAllowlistRequest struct { + // The email domain allowlist for an org. + Data DomainAllowlist `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDomainAllowlistRequest instantiates a new DomainAllowlistRequest 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 NewDomainAllowlistRequest(data DomainAllowlist) *DomainAllowlistRequest { + this := DomainAllowlistRequest{} + this.Data = data + return &this +} + +// NewDomainAllowlistRequestWithDefaults instantiates a new DomainAllowlistRequest 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 NewDomainAllowlistRequestWithDefaults() *DomainAllowlistRequest { + this := DomainAllowlistRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *DomainAllowlistRequest) GetData() DomainAllowlist { + if o == nil { + var ret DomainAllowlist + 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 *DomainAllowlistRequest) GetDataOk() (*DomainAllowlist, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *DomainAllowlistRequest) SetData(v DomainAllowlist) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DomainAllowlistRequest) 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 *DomainAllowlistRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *DomainAllowlist `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_domain_allowlist_response.go b/api/datadogV2/model_domain_allowlist_response.go new file mode 100644 index 00000000000..c0e5e9b439f --- /dev/null +++ b/api/datadogV2/model_domain_allowlist_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" +) + +// DomainAllowlistResponse Response containing information about the email domain allowlist. +type DomainAllowlistResponse struct { + // The email domain allowlist response for an org. + Data *DomainAllowlistResponseData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDomainAllowlistResponse instantiates a new DomainAllowlistResponse 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 NewDomainAllowlistResponse() *DomainAllowlistResponse { + this := DomainAllowlistResponse{} + return &this +} + +// NewDomainAllowlistResponseWithDefaults instantiates a new DomainAllowlistResponse 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 NewDomainAllowlistResponseWithDefaults() *DomainAllowlistResponse { + this := DomainAllowlistResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *DomainAllowlistResponse) GetData() DomainAllowlistResponseData { + if o == nil || o.Data == nil { + var ret DomainAllowlistResponseData + 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 *DomainAllowlistResponse) GetDataOk() (*DomainAllowlistResponseData, 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 *DomainAllowlistResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given DomainAllowlistResponseData and assigns it to the Data field. +func (o *DomainAllowlistResponse) SetData(v DomainAllowlistResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DomainAllowlistResponse) 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 *DomainAllowlistResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *DomainAllowlistResponseData `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_domain_allowlist_response_data.go b/api/datadogV2/model_domain_allowlist_response_data.go new file mode 100644 index 00000000000..c5e31352a4a --- /dev/null +++ b/api/datadogV2/model_domain_allowlist_response_data.go @@ -0,0 +1,197 @@ +// 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" +) + +// DomainAllowlistResponseData The email domain allowlist response for an org. +type DomainAllowlistResponseData struct { + // The details of the email domain allowlist. + Attributes *DomainAllowlistResponseDataAttributes `json:"attributes,omitempty"` + // The unique identifier of the org. + Id datadog.NullableString `json:"id,omitempty"` + // Email domain allowlist allowlist type. + Type DomainAllowlistType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDomainAllowlistResponseData instantiates a new DomainAllowlistResponseData 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 NewDomainAllowlistResponseData(typeVar DomainAllowlistType) *DomainAllowlistResponseData { + this := DomainAllowlistResponseData{} + this.Type = typeVar + return &this +} + +// NewDomainAllowlistResponseDataWithDefaults instantiates a new DomainAllowlistResponseData 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 NewDomainAllowlistResponseDataWithDefaults() *DomainAllowlistResponseData { + this := DomainAllowlistResponseData{} + var typeVar DomainAllowlistType = DOMAINALLOWLISTTYPE_DOMAIN_ALLOWLIST + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *DomainAllowlistResponseData) GetAttributes() DomainAllowlistResponseDataAttributes { + if o == nil || o.Attributes == nil { + var ret DomainAllowlistResponseDataAttributes + 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 *DomainAllowlistResponseData) GetAttributesOk() (*DomainAllowlistResponseDataAttributes, 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 *DomainAllowlistResponseData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given DomainAllowlistResponseDataAttributes and assigns it to the Attributes field. +func (o *DomainAllowlistResponseData) SetAttributes(v DomainAllowlistResponseDataAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *DomainAllowlistResponseData) GetId() string { + if o == nil || o.Id.Get() == nil { + var ret string + return ret + } + return *o.Id.Get() +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *DomainAllowlistResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Id.Get(), o.Id.IsSet() +} + +// HasId returns a boolean if a field has been set. +func (o *DomainAllowlistResponseData) HasId() bool { + return o != nil && o.Id.IsSet() +} + +// SetId gets a reference to the given datadog.NullableString and assigns it to the Id field. +func (o *DomainAllowlistResponseData) SetId(v string) { + o.Id.Set(&v) +} + +// SetIdNil sets the value for Id to be an explicit nil. +func (o *DomainAllowlistResponseData) SetIdNil() { + o.Id.Set(nil) +} + +// UnsetId ensures that no value is present for Id, not even an explicit nil. +func (o *DomainAllowlistResponseData) UnsetId() { + o.Id.Unset() +} + +// GetType returns the Type field value. +func (o *DomainAllowlistResponseData) GetType() DomainAllowlistType { + if o == nil { + var ret DomainAllowlistType + 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 *DomainAllowlistResponseData) GetTypeOk() (*DomainAllowlistType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DomainAllowlistResponseData) SetType(v DomainAllowlistType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DomainAllowlistResponseData) 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.Id.IsSet() { + toSerialize["id"] = o.Id.Get() + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DomainAllowlistResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *DomainAllowlistResponseDataAttributes `json:"attributes,omitempty"` + Id datadog.NullableString `json:"id,omitempty"` + Type *DomainAllowlistType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && 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_domain_allowlist_response_data_attributes.go b/api/datadogV2/model_domain_allowlist_response_data_attributes.go new file mode 100644 index 00000000000..4d9d0534bbe --- /dev/null +++ b/api/datadogV2/model_domain_allowlist_response_data_attributes.go @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DomainAllowlistResponseDataAttributes The details of the email domain allowlist. +type DomainAllowlistResponseDataAttributes struct { + // The list of domains in the email domain allowlist. + Domains []string `json:"domains,omitempty"` + // Whether the email domain allowlist is enabled for the org. + Enabled *bool `json:"enabled,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDomainAllowlistResponseDataAttributes instantiates a new DomainAllowlistResponseDataAttributes 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 NewDomainAllowlistResponseDataAttributes() *DomainAllowlistResponseDataAttributes { + this := DomainAllowlistResponseDataAttributes{} + return &this +} + +// NewDomainAllowlistResponseDataAttributesWithDefaults instantiates a new DomainAllowlistResponseDataAttributes 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 NewDomainAllowlistResponseDataAttributesWithDefaults() *DomainAllowlistResponseDataAttributes { + this := DomainAllowlistResponseDataAttributes{} + return &this +} + +// GetDomains returns the Domains field value if set, zero value otherwise. +func (o *DomainAllowlistResponseDataAttributes) GetDomains() []string { + if o == nil || o.Domains == nil { + var ret []string + return ret + } + return o.Domains +} + +// GetDomainsOk returns a tuple with the Domains field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DomainAllowlistResponseDataAttributes) GetDomainsOk() (*[]string, bool) { + if o == nil || o.Domains == nil { + return nil, false + } + return &o.Domains, true +} + +// HasDomains returns a boolean if a field has been set. +func (o *DomainAllowlistResponseDataAttributes) HasDomains() bool { + return o != nil && o.Domains != nil +} + +// SetDomains gets a reference to the given []string and assigns it to the Domains field. +func (o *DomainAllowlistResponseDataAttributes) SetDomains(v []string) { + o.Domains = v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *DomainAllowlistResponseDataAttributes) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DomainAllowlistResponseDataAttributes) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *DomainAllowlistResponseDataAttributes) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *DomainAllowlistResponseDataAttributes) SetEnabled(v bool) { + o.Enabled = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DomainAllowlistResponseDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Domains != nil { + toSerialize["domains"] = o.Domains + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DomainAllowlistResponseDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Domains []string `json:"domains,omitempty"` + Enabled *bool `json:"enabled,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{"domains", "enabled"}) + } else { + return err + } + o.Domains = all.Domains + o.Enabled = all.Enabled + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_domain_allowlist_type.go b/api/datadogV2/model_domain_allowlist_type.go new file mode 100644 index 00000000000..d76e4db6b64 --- /dev/null +++ b/api/datadogV2/model_domain_allowlist_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" +) + +// DomainAllowlistType Email domain allowlist allowlist type. +type DomainAllowlistType string + +// List of DomainAllowlistType. +const ( + DOMAINALLOWLISTTYPE_DOMAIN_ALLOWLIST DomainAllowlistType = "domain_allowlist" +) + +var allowedDomainAllowlistTypeEnumValues = []DomainAllowlistType{ + DOMAINALLOWLISTTYPE_DOMAIN_ALLOWLIST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *DomainAllowlistType) GetAllowedValues() []DomainAllowlistType { + return allowedDomainAllowlistTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *DomainAllowlistType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = DomainAllowlistType(value) + return nil +} + +// NewDomainAllowlistTypeFromValue returns a pointer to a valid DomainAllowlistType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewDomainAllowlistTypeFromValue(v string) (*DomainAllowlistType, error) { + ev := DomainAllowlistType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for DomainAllowlistType: valid values are %v", v, allowedDomainAllowlistTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v DomainAllowlistType) IsValid() bool { + for _, existing := range allowedDomainAllowlistTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to DomainAllowlistType value. +func (v DomainAllowlistType) Ptr() *DomainAllowlistType { + return &v +} diff --git a/examples/v2/domain-allowlist/GetDomainAllowlist.go b/examples/v2/domain-allowlist/GetDomainAllowlist.go new file mode 100644 index 00000000000..1aed876012e --- /dev/null +++ b/examples/v2/domain-allowlist/GetDomainAllowlist.go @@ -0,0 +1,29 @@ +// Get Domain Allowlist 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.NewDomainAllowlistApi(apiClient) + resp, r, err := api.GetDomainAllowlist(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DomainAllowlistApi.GetDomainAllowlist`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `DomainAllowlistApi.GetDomainAllowlist`:\n%s\n", responseContent) +} diff --git a/examples/v2/domain-allowlist/PatchDomainAllowlist.go b/examples/v2/domain-allowlist/PatchDomainAllowlist.go new file mode 100644 index 00000000000..d0c87656936 --- /dev/null +++ b/examples/v2/domain-allowlist/PatchDomainAllowlist.go @@ -0,0 +1,40 @@ +// Sets Domain Allowlist 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.DomainAllowlistRequest{ + Data: datadogV2.DomainAllowlist{ + Attributes: &datadogV2.DomainAllowlistAttributes{ + Domains: []string{ + "@static-test-domain.test", + }, + Enabled: datadog.PtrBool(false), + }, + Type: datadogV2.DOMAINALLOWLISTTYPE_DOMAIN_ALLOWLIST, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewDomainAllowlistApi(apiClient) + resp, r, err := api.PatchDomainAllowlist(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DomainAllowlistApi.PatchDomainAllowlist`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `DomainAllowlistApi.PatchDomainAllowlist`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index fcd6d96bcfa..724daaae045 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -59,6 +59,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "CloudCostManagementApi": reflect.ValueOf(datadogV2.NewCloudCostManagementApi), "UsageMeteringApi": reflect.ValueOf(datadogV2.NewUsageMeteringApi), "DashboardListsApi": reflect.ValueOf(datadogV2.NewDashboardListsApi), + "DomainAllowlistApi": reflect.ValueOf(datadogV2.NewDomainAllowlistApi), "DORAMetricsApi": reflect.ValueOf(datadogV2.NewDORAMetricsApi), "DowntimesApi": reflect.ValueOf(datadogV2.NewDowntimesApi), "EventsApi": reflect.ValueOf(datadogV2.NewEventsApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Get_Domain_Allowlist_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Get_Domain_Allowlist_returns_OK_response.freeze new file mode 100644 index 00000000000..2090a82fa0f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Get_Domain_Allowlist_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-10-23T18:16:16.668Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Get_Domain_Allowlist_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Get_Domain_Allowlist_returns_OK_response.yaml new file mode 100644 index 00000000000..43f20bb5922 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Get_Domain_Allowlist_returns_OK_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/domain_allowlist + response: + body: '{"data":{"type":"domain_allowlist","attributes":{"enabled":false,"domains":["@static-test-domain.test"]}}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Sets_Domain_Allowlist_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Sets_Domain_Allowlist_returns_OK_response.freeze new file mode 100644 index 00000000000..6315d630bc7 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Sets_Domain_Allowlist_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-10-23T18:16:16.928Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Sets_Domain_Allowlist_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Sets_Domain_Allowlist_returns_OK_response.yaml new file mode 100644 index 00000000000..2e3dfe6c8d1 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Domain_Allowlist/Scenario_Sets_Domain_Allowlist_returns_OK_response.yaml @@ -0,0 +1,24 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"domains":["@static-test-domain.test"],"enabled":false},"type":"domain_allowlist"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/domain_allowlist + response: + body: '{"data":{"type":"domain_allowlist","attributes":{"enabled":false,"domains":["@static-test-domain.test"]}}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v2/domain_allowlist.feature b/tests/scenarios/features/v2/domain_allowlist.feature new file mode 100644 index 00000000000..4e9143792a7 --- /dev/null +++ b/tests/scenarios/features/v2/domain_allowlist.feature @@ -0,0 +1,32 @@ +@endpoint(domain-allowlist) @endpoint(domain-allowlist-v2) +Feature: Domain Allowlist + Configure your Datadog Email Domain Allowlist directly through the Datadog + API. The Email Domain Allowlist controls the domains that certain datadog + emails can be sent to. For more information, see the [Domain Allowlist + docs page](https://docs.datadoghq.com/account_management/org_settings/doma + in_allowlist) + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "DomainAllowlist" API + + @team:Datadog/team-aaa-dogmail + Scenario: Get Domain Allowlist returns "OK" response + Given new "GetDomainAllowlist" request + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "domain_allowlist" + And the response "data.attributes.domains[0]" array contains value "@static-test-domain.test" + And the response "data.attributes.enabled" is equal to false + + @team:Datadog/team-aaa-dogmail + Scenario: Sets Domain Allowlist returns "OK" response + Given new "PatchDomainAllowlist" request + And body with value {"data": {"attributes": {"domains": ["@static-test-domain.test"], "enabled": false}, "type": "domain_allowlist"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "domain_allowlist" + And the response "data.attributes.domains" has length 1 + And the response "data.attributes.domains[0]" array contains value "@static-test-domain.test" + And the response "data.attributes.enabled" is equal to false diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 68b64dfc24d..5516102f8ff 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -547,6 +547,18 @@ "type": "safe" } }, + "GetDomainAllowlist": { + "tag": "Domain Allowlist", + "undo": { + "type": "safe" + } + }, + "PatchDomainAllowlist": { + "tag": "Domain Allowlist", + "undo": { + "type": "idempotent" + } + }, "CreateDORADeployment": { "tag": "DORA Metrics", "undo": {