Skip to content

Commit 977884d

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 5b4da40 of spec repo
1 parent 6ad8dae commit 977884d

11 files changed

Lines changed: 840 additions & 47 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82245,6 +82245,61 @@ components:
8224582245
description: The title of the event.
8224682246
example: "The event title"
8224782247
type: string
82248+
ValidateV2Attributes:
82249+
description: Attributes of the API key validation response.
82250+
properties:
82251+
api_key_id:
82252+
description: The UUID of the API key.
82253+
example: "a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6"
82254+
type: string
82255+
api_key_scopes:
82256+
description: List of scope names associated with the API key.
82257+
example:
82258+
- "remote_config_read"
82259+
items:
82260+
type: string
82261+
type: array
82262+
valid:
82263+
description: Whether the API key is valid.
82264+
example: true
82265+
type: boolean
82266+
required:
82267+
- valid
82268+
- api_key_scopes
82269+
- api_key_id
82270+
type: object
82271+
ValidateV2Data:
82272+
description: Data object containing the API key validation result.
82273+
properties:
82274+
attributes:
82275+
$ref: "#/components/schemas/ValidateV2Attributes"
82276+
id:
82277+
description: The UUID of the organization associated with the API key.
82278+
example: "550e8400-e29b-41d4-a716-446655440000"
82279+
type: string
82280+
type:
82281+
$ref: "#/components/schemas/ValidateV2Type"
82282+
required:
82283+
- id
82284+
- type
82285+
- attributes
82286+
type: object
82287+
ValidateV2Response:
82288+
description: Response for the API key validation endpoint.
82289+
properties:
82290+
data:
82291+
$ref: "#/components/schemas/ValidateV2Data"
82292+
required:
82293+
- data
82294+
type: object
82295+
ValidateV2Type:
82296+
description: Resource type for the API key validation response.
82297+
enum:
82298+
- validate_v2
82299+
example: validate_v2
82300+
type: string
82301+
x-enum-varnames:
82302+
- ValidateV2
8224882303
ValidationError:
8224982304
description: Represents a single validation error, including a human-readable title and metadata.
8225082305
properties:
@@ -144871,6 +144926,47 @@ paths:
144871144926
operator: OR
144872144927
permissions:
144873144928
- teams_read
144929+
/api/v2/validate:
144930+
get:
144931+
description: Check if the API key is valid. Returns the organization UUID, API key ID, and associated scopes.
144932+
operationId: Validate
144933+
responses:
144934+
"200":
144935+
content:
144936+
application/json:
144937+
examples:
144938+
default:
144939+
value:
144940+
data:
144941+
attributes:
144942+
api_key_id: "a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6"
144943+
api_key_scopes:
144944+
- "remote_config_read"
144945+
valid: true
144946+
id: "550e8400-e29b-41d4-a716-446655440000"
144947+
type: "validate_v2"
144948+
schema:
144949+
$ref: "#/components/schemas/ValidateV2Response"
144950+
description: OK
144951+
"403":
144952+
content:
144953+
application/json:
144954+
schema:
144955+
$ref: "#/components/schemas/JSONAPIErrorResponse"
144956+
description: Forbidden
144957+
"429":
144958+
$ref: "#/components/responses/TooManyRequestsResponse"
144959+
security:
144960+
- apiKeyAuth: []
144961+
summary: Validate API key
144962+
tags:
144963+
- Key Management
144964+
"x-permission":
144965+
operator: OPEN
144966+
permissions: []
144967+
x-unstable: |-
144968+
**Note**: This endpoint is in preview and is subject to change.
144969+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
144874144970
/api/v2/widgets/{experience_type}:
144875144971
get:
144876144972
description: |-

api/datadog/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ func NewConfiguration() *Configuration {
702702
"v2.UpdateLLMObsExperiment": false,
703703
"v2.UpdateLLMObsProject": false,
704704
"v2.AnonymizeUsers": false,
705+
"v2.Validate": false,
705706
"v2.CreateOpenAPI": false,
706707
"v2.DeleteOpenAPI": false,
707708
"v2.GetOpenAPI": false,

api/datadogV2/api_key_management.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package datadogV2
66

77
import (
88
_context "context"
9+
_fmt "fmt"
10+
_log "log"
911
_nethttp "net/http"
1012
_neturl "net/url"
1113
"reflect"
@@ -1910,6 +1912,94 @@ func (a *KeyManagementApi) UpdatePersonalAccessToken(ctx _context.Context, patId
19101912
return localVarReturnValue, localVarHTTPResponse, nil
19111913
}
19121914

1915+
// Validate Validate API key.
1916+
// Check if the API key is valid. Returns the organization UUID, API key ID, and associated scopes.
1917+
func (a *KeyManagementApi) Validate(ctx _context.Context) (ValidateV2Response, *_nethttp.Response, error) {
1918+
var (
1919+
localVarHTTPMethod = _nethttp.MethodGet
1920+
localVarPostBody interface{}
1921+
localVarReturnValue ValidateV2Response
1922+
)
1923+
1924+
operationId := "v2.Validate"
1925+
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
1926+
if !isOperationEnabled {
1927+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
1928+
}
1929+
if isOperationEnabled && a.Client.Cfg.Debug {
1930+
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
1931+
}
1932+
1933+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.KeyManagementApi.Validate")
1934+
if err != nil {
1935+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
1936+
}
1937+
1938+
localVarPath := localBasePath + "/api/v2/validate"
1939+
1940+
localVarHeaderParams := make(map[string]string)
1941+
localVarQueryParams := _neturl.Values{}
1942+
localVarFormParams := _neturl.Values{}
1943+
localVarHeaderParams["Accept"] = "application/json"
1944+
1945+
datadog.SetAuthKeys(
1946+
ctx,
1947+
&localVarHeaderParams,
1948+
[2]string{"apiKeyAuth", "DD-API-KEY"},
1949+
)
1950+
1951+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
1952+
if err != nil {
1953+
return localVarReturnValue, nil, err
1954+
}
1955+
1956+
localVarHTTPResponse, err := a.Client.CallAPI(req)
1957+
if err != nil || localVarHTTPResponse == nil {
1958+
return localVarReturnValue, localVarHTTPResponse, err
1959+
}
1960+
1961+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
1962+
if err != nil {
1963+
return localVarReturnValue, localVarHTTPResponse, err
1964+
}
1965+
1966+
if localVarHTTPResponse.StatusCode >= 300 {
1967+
newErr := datadog.GenericOpenAPIError{
1968+
ErrorBody: localVarBody,
1969+
ErrorMessage: localVarHTTPResponse.Status,
1970+
}
1971+
if localVarHTTPResponse.StatusCode == 403 {
1972+
var v JSONAPIErrorResponse
1973+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
1974+
if err != nil {
1975+
return localVarReturnValue, localVarHTTPResponse, newErr
1976+
}
1977+
newErr.ErrorModel = v
1978+
return localVarReturnValue, localVarHTTPResponse, newErr
1979+
}
1980+
if localVarHTTPResponse.StatusCode == 429 {
1981+
var v APIErrorResponse
1982+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
1983+
if err != nil {
1984+
return localVarReturnValue, localVarHTTPResponse, newErr
1985+
}
1986+
newErr.ErrorModel = v
1987+
}
1988+
return localVarReturnValue, localVarHTTPResponse, newErr
1989+
}
1990+
1991+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
1992+
if err != nil {
1993+
newErr := datadog.GenericOpenAPIError{
1994+
ErrorBody: localVarBody,
1995+
ErrorMessage: err.Error(),
1996+
}
1997+
return localVarReturnValue, localVarHTTPResponse, newErr
1998+
}
1999+
2000+
return localVarReturnValue, localVarHTTPResponse, nil
2001+
}
2002+
19132003
// NewKeyManagementApi Returns NewKeyManagementApi.
19142004
func NewKeyManagementApi(client *datadog.APIClient) *KeyManagementApi {
19152005
return &KeyManagementApi{

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@
449449
// - [KeyManagementApi.UpdateApplicationKey]
450450
// - [KeyManagementApi.UpdateCurrentUserApplicationKey]
451451
// - [KeyManagementApi.UpdatePersonalAccessToken]
452+
// - [KeyManagementApi.Validate]
452453
// - [LLMObservabilityApi.CreateLLMObsAnnotationQueue]
453454
// - [LLMObservabilityApi.CreateLLMObsAnnotationQueueInteractions]
454455
// - [LLMObservabilityApi.CreateLLMObsDataset]
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// ValidateV2Attributes Attributes of the API key validation response.
14+
type ValidateV2Attributes struct {
15+
// The UUID of the API key.
16+
ApiKeyId string `json:"api_key_id"`
17+
// List of scope names associated with the API key.
18+
ApiKeyScopes []string `json:"api_key_scopes"`
19+
// Whether the API key is valid.
20+
Valid bool `json:"valid"`
21+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
22+
UnparsedObject map[string]interface{} `json:"-"`
23+
AdditionalProperties map[string]interface{} `json:"-"`
24+
}
25+
26+
// NewValidateV2Attributes instantiates a new ValidateV2Attributes object.
27+
// This constructor will assign default values to properties that have it defined,
28+
// and makes sure properties required by API are set, but the set of arguments
29+
// will change when the set of required properties is changed.
30+
func NewValidateV2Attributes(apiKeyId string, apiKeyScopes []string, valid bool) *ValidateV2Attributes {
31+
this := ValidateV2Attributes{}
32+
this.ApiKeyId = apiKeyId
33+
this.ApiKeyScopes = apiKeyScopes
34+
this.Valid = valid
35+
return &this
36+
}
37+
38+
// NewValidateV2AttributesWithDefaults instantiates a new ValidateV2Attributes object.
39+
// This constructor will only assign default values to properties that have it defined,
40+
// but it doesn't guarantee that properties required by API are set.
41+
func NewValidateV2AttributesWithDefaults() *ValidateV2Attributes {
42+
this := ValidateV2Attributes{}
43+
return &this
44+
}
45+
46+
// GetApiKeyId returns the ApiKeyId field value.
47+
func (o *ValidateV2Attributes) GetApiKeyId() string {
48+
if o == nil {
49+
var ret string
50+
return ret
51+
}
52+
return o.ApiKeyId
53+
}
54+
55+
// GetApiKeyIdOk returns a tuple with the ApiKeyId field value
56+
// and a boolean to check if the value has been set.
57+
func (o *ValidateV2Attributes) GetApiKeyIdOk() (*string, bool) {
58+
if o == nil {
59+
return nil, false
60+
}
61+
return &o.ApiKeyId, true
62+
}
63+
64+
// SetApiKeyId sets field value.
65+
func (o *ValidateV2Attributes) SetApiKeyId(v string) {
66+
o.ApiKeyId = v
67+
}
68+
69+
// GetApiKeyScopes returns the ApiKeyScopes field value.
70+
func (o *ValidateV2Attributes) GetApiKeyScopes() []string {
71+
if o == nil {
72+
var ret []string
73+
return ret
74+
}
75+
return o.ApiKeyScopes
76+
}
77+
78+
// GetApiKeyScopesOk returns a tuple with the ApiKeyScopes field value
79+
// and a boolean to check if the value has been set.
80+
func (o *ValidateV2Attributes) GetApiKeyScopesOk() (*[]string, bool) {
81+
if o == nil {
82+
return nil, false
83+
}
84+
return &o.ApiKeyScopes, true
85+
}
86+
87+
// SetApiKeyScopes sets field value.
88+
func (o *ValidateV2Attributes) SetApiKeyScopes(v []string) {
89+
o.ApiKeyScopes = v
90+
}
91+
92+
// GetValid returns the Valid field value.
93+
func (o *ValidateV2Attributes) GetValid() bool {
94+
if o == nil {
95+
var ret bool
96+
return ret
97+
}
98+
return o.Valid
99+
}
100+
101+
// GetValidOk returns a tuple with the Valid field value
102+
// and a boolean to check if the value has been set.
103+
func (o *ValidateV2Attributes) GetValidOk() (*bool, bool) {
104+
if o == nil {
105+
return nil, false
106+
}
107+
return &o.Valid, true
108+
}
109+
110+
// SetValid sets field value.
111+
func (o *ValidateV2Attributes) SetValid(v bool) {
112+
o.Valid = v
113+
}
114+
115+
// MarshalJSON serializes the struct using spec logic.
116+
func (o ValidateV2Attributes) MarshalJSON() ([]byte, error) {
117+
toSerialize := map[string]interface{}{}
118+
if o.UnparsedObject != nil {
119+
return datadog.Marshal(o.UnparsedObject)
120+
}
121+
toSerialize["api_key_id"] = o.ApiKeyId
122+
toSerialize["api_key_scopes"] = o.ApiKeyScopes
123+
toSerialize["valid"] = o.Valid
124+
125+
for key, value := range o.AdditionalProperties {
126+
toSerialize[key] = value
127+
}
128+
return datadog.Marshal(toSerialize)
129+
}
130+
131+
// UnmarshalJSON deserializes the given payload.
132+
func (o *ValidateV2Attributes) UnmarshalJSON(bytes []byte) (err error) {
133+
all := struct {
134+
ApiKeyId *string `json:"api_key_id"`
135+
ApiKeyScopes *[]string `json:"api_key_scopes"`
136+
Valid *bool `json:"valid"`
137+
}{}
138+
if err = datadog.Unmarshal(bytes, &all); err != nil {
139+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
140+
}
141+
if all.ApiKeyId == nil {
142+
return fmt.Errorf("required field api_key_id missing")
143+
}
144+
if all.ApiKeyScopes == nil {
145+
return fmt.Errorf("required field api_key_scopes missing")
146+
}
147+
if all.Valid == nil {
148+
return fmt.Errorf("required field valid missing")
149+
}
150+
additionalProperties := make(map[string]interface{})
151+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
152+
datadog.DeleteKeys(additionalProperties, &[]string{"api_key_id", "api_key_scopes", "valid"})
153+
} else {
154+
return err
155+
}
156+
o.ApiKeyId = *all.ApiKeyId
157+
o.ApiKeyScopes = *all.ApiKeyScopes
158+
o.Valid = *all.Valid
159+
160+
if len(additionalProperties) > 0 {
161+
o.AdditionalProperties = additionalProperties
162+
}
163+
164+
return nil
165+
}

0 commit comments

Comments
 (0)