Skip to content

Commit

Permalink
Enable auto-merging for keys routes. (#2634)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <[email protected]>
Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Aug 15, 2024
1 parent 423dfaa commit 52febbc
Show file tree
Hide file tree
Showing 10 changed files with 686 additions and 32 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-08-14 22:02:33.356148",
"spec_repo_commit": "5e33062a"
"regenerated": "2024-08-14 22:32:02.181891",
"spec_repo_commit": "07d72513"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-08-14 22:02:33.380397",
"spec_repo_commit": "5e33062a"
"regenerated": "2024-08-14 22:32:02.200367",
"spec_repo_commit": "07d72513"
}
}
}
55 changes: 55 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,16 @@ components:
APIKeyCreateAttributes:
description: Attributes used to create an API Key.
properties:
category:
description: The APIKeyCreateAttributes category.
type: string
name:
description: Name of the API key.
example: API Key for submitting metrics
type: string
remote_config_read_enabled:
description: The APIKeyCreateAttributes remote_config_read_enabled.
type: boolean
required:
- name
type: object
Expand Down Expand Up @@ -722,13 +728,20 @@ components:
description: An object related to an API key.
oneOf:
- $ref: '#/components/schemas/User'
- $ref: '#/components/schemas/LeakedKey'
APIKeyUpdateAttributes:
description: Attributes used to update an API Key.
properties:
category:
description: The APIKeyUpdateAttributes category.
type: string
name:
description: Name of the API key.
example: API Key for submitting metrics
type: string
remote_config_read_enabled:
description: The APIKeyUpdateAttributes remote_config_read_enabled.
type: boolean
required:
- name
type: object
Expand Down Expand Up @@ -981,6 +994,7 @@ components:
oneOf:
- $ref: '#/components/schemas/User'
- $ref: '#/components/schemas/Role'
- $ref: '#/components/schemas/LeakedKey'
ApplicationKeyResponseMeta:
description: Additional information related to the application key response.
properties:
Expand Down Expand Up @@ -8461,6 +8475,7 @@ components:
created_at:
description: Creation date of the API key.
example: '2020-11-23T10:00:00.000Z'
format: date-time
readOnly: true
type: string
key:
Expand All @@ -8477,6 +8492,7 @@ components:
modified_at:
description: Date the API key was last modified.
example: '2020-11-23T10:00:00.000Z'
format: date-time
readOnly: true
type: string
name:
Expand Down Expand Up @@ -11140,6 +11156,45 @@ components:
description: Jira project key
type: string
type: object
LeakedKey:
description: The definition of LeakedKey object.
properties:
attributes:
$ref: '#/components/schemas/LeakedKeyAttributes'
id:
description: The LeakedKey id.
example: id
type: string
type:
$ref: '#/components/schemas/LeakedKeyType'
required:
- attributes
- id
- type
type: object
LeakedKeyAttributes:
description: The definition of LeakedKeyAttributes object.
properties:
date:
description: The LeakedKeyAttributes date.
example: '2017-07-21T17:32:28Z'
format: date-time
type: string
leak_source:
description: The LeakedKeyAttributes leak_source.
type: string
required:
- date
type: object
LeakedKeyType:
default: leaked_keys
description: The definition of LeakedKeyType object.
enum:
- leaked_keys
example: leaked_keys
type: string
x-enum-varnames:
- LEAKED_KEYS
ListAPIsResponse:
description: Response for `ListAPIs`.
properties:
Expand Down
74 changes: 72 additions & 2 deletions api/datadogV2/model_api_key_create_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ import (

// APIKeyCreateAttributes Attributes used to create an API Key.
type APIKeyCreateAttributes struct {
// The APIKeyCreateAttributes category.
Category *string `json:"category,omitempty"`
// Name of the API key.
Name string `json:"name"`
// The APIKeyCreateAttributes remote_config_read_enabled.
RemoteConfigReadEnabled *bool `json:"remote_config_read_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:"-"`
Expand All @@ -37,6 +41,34 @@ func NewAPIKeyCreateAttributesWithDefaults() *APIKeyCreateAttributes {
return &this
}

// GetCategory returns the Category field value if set, zero value otherwise.
func (o *APIKeyCreateAttributes) GetCategory() string {
if o == nil || o.Category == nil {
var ret string
return ret
}
return *o.Category
}

// GetCategoryOk returns a tuple with the Category field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *APIKeyCreateAttributes) GetCategoryOk() (*string, bool) {
if o == nil || o.Category == nil {
return nil, false
}
return o.Category, true
}

// HasCategory returns a boolean if a field has been set.
func (o *APIKeyCreateAttributes) HasCategory() bool {
return o != nil && o.Category != nil
}

// SetCategory gets a reference to the given string and assigns it to the Category field.
func (o *APIKeyCreateAttributes) SetCategory(v string) {
o.Category = &v
}

// GetName returns the Name field value.
func (o *APIKeyCreateAttributes) GetName() string {
if o == nil {
Expand All @@ -60,13 +92,47 @@ func (o *APIKeyCreateAttributes) SetName(v string) {
o.Name = v
}

// GetRemoteConfigReadEnabled returns the RemoteConfigReadEnabled field value if set, zero value otherwise.
func (o *APIKeyCreateAttributes) GetRemoteConfigReadEnabled() bool {
if o == nil || o.RemoteConfigReadEnabled == nil {
var ret bool
return ret
}
return *o.RemoteConfigReadEnabled
}

// GetRemoteConfigReadEnabledOk returns a tuple with the RemoteConfigReadEnabled field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *APIKeyCreateAttributes) GetRemoteConfigReadEnabledOk() (*bool, bool) {
if o == nil || o.RemoteConfigReadEnabled == nil {
return nil, false
}
return o.RemoteConfigReadEnabled, true
}

// HasRemoteConfigReadEnabled returns a boolean if a field has been set.
func (o *APIKeyCreateAttributes) HasRemoteConfigReadEnabled() bool {
return o != nil && o.RemoteConfigReadEnabled != nil
}

// SetRemoteConfigReadEnabled gets a reference to the given bool and assigns it to the RemoteConfigReadEnabled field.
func (o *APIKeyCreateAttributes) SetRemoteConfigReadEnabled(v bool) {
o.RemoteConfigReadEnabled = &v
}

// MarshalJSON serializes the struct using spec logic.
func (o APIKeyCreateAttributes) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
if o.Category != nil {
toSerialize["category"] = o.Category
}
toSerialize["name"] = o.Name
if o.RemoteConfigReadEnabled != nil {
toSerialize["remote_config_read_enabled"] = o.RemoteConfigReadEnabled
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -77,7 +143,9 @@ func (o APIKeyCreateAttributes) MarshalJSON() ([]byte, error) {
// UnmarshalJSON deserializes the given payload.
func (o *APIKeyCreateAttributes) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Name *string `json:"name"`
Category *string `json:"category,omitempty"`
Name *string `json:"name"`
RemoteConfigReadEnabled *bool `json:"remote_config_read_enabled,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
Expand All @@ -87,11 +155,13 @@ func (o *APIKeyCreateAttributes) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"name"})
datadog.DeleteKeys(additionalProperties, &[]string{"category", "name", "remote_config_read_enabled"})
} else {
return err
}
o.Category = all.Category
o.Name = *all.Name
o.RemoteConfigReadEnabled = all.RemoteConfigReadEnabled

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
Expand Down
34 changes: 33 additions & 1 deletion api/datadogV2/model_api_key_response_included_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (

// APIKeyResponseIncludedItem - An object related to an API key.
type APIKeyResponseIncludedItem struct {
User *User
User *User
LeakedKey *LeakedKey

// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject interface{}
Expand All @@ -21,6 +22,11 @@ func UserAsAPIKeyResponseIncludedItem(v *User) APIKeyResponseIncludedItem {
return APIKeyResponseIncludedItem{User: v}
}

// LeakedKeyAsAPIKeyResponseIncludedItem is a convenience function that returns LeakedKey wrapped in APIKeyResponseIncludedItem.
func LeakedKeyAsAPIKeyResponseIncludedItem(v *LeakedKey) APIKeyResponseIncludedItem {
return APIKeyResponseIncludedItem{LeakedKey: v}
}

// UnmarshalJSON turns data into one of the pointers in the struct.
func (obj *APIKeyResponseIncludedItem) UnmarshalJSON(data []byte) error {
var err error
Expand All @@ -42,9 +48,27 @@ func (obj *APIKeyResponseIncludedItem) UnmarshalJSON(data []byte) error {
obj.User = nil
}

// try to unmarshal data into LeakedKey
err = datadog.Unmarshal(data, &obj.LeakedKey)
if err == nil {
if obj.LeakedKey != nil && obj.LeakedKey.UnparsedObject == nil {
jsonLeakedKey, _ := datadog.Marshal(obj.LeakedKey)
if string(jsonLeakedKey) == "{}" { // empty struct
obj.LeakedKey = nil
} else {
match++
}
} else {
obj.LeakedKey = nil
}
} else {
obj.LeakedKey = nil
}

if match != 1 { // more than 1 match
// reset to nil
obj.User = nil
obj.LeakedKey = nil
return datadog.Unmarshal(data, &obj.UnparsedObject)
}
return nil // exactly one match
Expand All @@ -56,6 +80,10 @@ func (obj APIKeyResponseIncludedItem) MarshalJSON() ([]byte, error) {
return datadog.Marshal(&obj.User)
}

if obj.LeakedKey != nil {
return datadog.Marshal(&obj.LeakedKey)
}

if obj.UnparsedObject != nil {
return datadog.Marshal(obj.UnparsedObject)
}
Expand All @@ -68,6 +96,10 @@ func (obj *APIKeyResponseIncludedItem) GetActualInstance() interface{} {
return obj.User
}

if obj.LeakedKey != nil {
return obj.LeakedKey
}

// all schemas are nil
return nil
}
Loading

0 comments on commit 52febbc

Please sign in to comment.