Skip to content

Commit

Permalink
Add domain allowlist endpoints (#2749)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Oct 30, 2024
1 parent 6452a5e commit 80b1780
Show file tree
Hide file tree
Showing 20 changed files with 1,424 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -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:58:08.560968",
"spec_repo_commit": "755120dd"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-29 20:46:37.350717",
"spec_repo_commit": "c0b9551e"
"regenerated": "2024-10-30 18:58:08.580038",
"spec_repo_commit": "755120dd"
}
}
}
138 changes: 138 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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/).

Expand Down
166 changes: 166 additions & 0 deletions api/datadogV2/api_domain_allowlist.go
Original file line number Diff line number Diff line change
@@ -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,
}
}
2 changes: 2 additions & 0 deletions api/datadogV2/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
// - [DashboardListsApi.DeleteDashboardListItems]
// - [DashboardListsApi.GetDashboardListItems]
// - [DashboardListsApi.UpdateDashboardListItems]
// - [DomainAllowlistApi.GetDomainAllowlist]
// - [DomainAllowlistApi.PatchDomainAllowlist]
// - [DowntimesApi.CancelDowntime]
// - [DowntimesApi.CreateDowntime]
// - [DowntimesApi.GetDowntime]
Expand Down
Loading

0 comments on commit 80b1780

Please sign in to comment.