-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add domain allowlist endpoints (#2749)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
- Loading branch information
1 parent
6452a5e
commit 80b1780
Showing
20 changed files
with
1,424 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.