Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make modified by field nullable for get all API keys #2576

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-07-19 18:52:07.546868",
"spec_repo_commit": "be099b30"
"regenerated": "2024-07-19 19:37:58.750999",
"spec_repo_commit": "a3f2b7d2"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-07-19 18:52:07.564960",
"spec_repo_commit": "be099b30"
"regenerated": "2024-07-19 19:37:58.775987",
"spec_repo_commit": "a3f2b7d2"
}
}
}
2 changes: 1 addition & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ components:
created_by:
$ref: '#/components/schemas/RelationshipToUser'
modified_by:
$ref: '#/components/schemas/RelationshipToUser'
$ref: '#/components/schemas/NullableRelationshipToUser'
type: object
APIKeyResponse:
description: Response for retrieving an API key.
Expand Down
48 changes: 28 additions & 20 deletions api/datadogV2/model_api_key_relationships.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type APIKeyRelationships struct {
// Relationship to user.
CreatedBy *RelationshipToUser `json:"created_by,omitempty"`
// Relationship to user.
ModifiedBy *RelationshipToUser `json:"modified_by,omitempty"`
ModifiedBy NullableNullableRelationshipToUser `json:"modified_by,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{}
Expand Down Expand Up @@ -64,32 +64,43 @@ func (o *APIKeyRelationships) SetCreatedBy(v RelationshipToUser) {
o.CreatedBy = &v
}

// GetModifiedBy returns the ModifiedBy field value if set, zero value otherwise.
func (o *APIKeyRelationships) GetModifiedBy() RelationshipToUser {
if o == nil || o.ModifiedBy == nil {
var ret RelationshipToUser
// GetModifiedBy returns the ModifiedBy field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *APIKeyRelationships) GetModifiedBy() NullableRelationshipToUser {
if o == nil || o.ModifiedBy.Get() == nil {
var ret NullableRelationshipToUser
return ret
}
return *o.ModifiedBy
return *o.ModifiedBy.Get()
}

// GetModifiedByOk returns a tuple with the ModifiedBy field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *APIKeyRelationships) GetModifiedByOk() (*RelationshipToUser, bool) {
if o == nil || o.ModifiedBy == nil {
// NOTE: If the value is an explicit nil, `nil, true` will be returned.
func (o *APIKeyRelationships) GetModifiedByOk() (*NullableRelationshipToUser, bool) {
if o == nil {
return nil, false
}
return o.ModifiedBy, true
return o.ModifiedBy.Get(), o.ModifiedBy.IsSet()
}

// HasModifiedBy returns a boolean if a field has been set.
func (o *APIKeyRelationships) HasModifiedBy() bool {
return o != nil && o.ModifiedBy != nil
return o != nil && o.ModifiedBy.IsSet()
}

// SetModifiedBy gets a reference to the given NullableNullableRelationshipToUser and assigns it to the ModifiedBy field.
func (o *APIKeyRelationships) SetModifiedBy(v NullableRelationshipToUser) {
o.ModifiedBy.Set(&v)
}

// SetModifiedBy gets a reference to the given RelationshipToUser and assigns it to the ModifiedBy field.
func (o *APIKeyRelationships) SetModifiedBy(v RelationshipToUser) {
o.ModifiedBy = &v
// SetModifiedByNil sets the value for ModifiedBy to be an explicit nil.
func (o *APIKeyRelationships) SetModifiedByNil() {
o.ModifiedBy.Set(nil)
}

// UnsetModifiedBy ensures that no value is present for ModifiedBy, not even an explicit nil.
func (o *APIKeyRelationships) UnsetModifiedBy() {
o.ModifiedBy.Unset()
}

// MarshalJSON serializes the struct using spec logic.
Expand All @@ -101,8 +112,8 @@ func (o APIKeyRelationships) MarshalJSON() ([]byte, error) {
if o.CreatedBy != nil {
toSerialize["created_by"] = o.CreatedBy
}
if o.ModifiedBy != nil {
toSerialize["modified_by"] = o.ModifiedBy
if o.ModifiedBy.IsSet() {
toSerialize["modified_by"] = o.ModifiedBy.Get()
}

for key, value := range o.AdditionalProperties {
Expand All @@ -114,8 +125,8 @@ func (o APIKeyRelationships) MarshalJSON() ([]byte, error) {
// UnmarshalJSON deserializes the given payload.
func (o *APIKeyRelationships) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
CreatedBy *RelationshipToUser `json:"created_by,omitempty"`
ModifiedBy *RelationshipToUser `json:"modified_by,omitempty"`
CreatedBy *RelationshipToUser `json:"created_by,omitempty"`
ModifiedBy NullableNullableRelationshipToUser `json:"modified_by,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
Expand All @@ -132,9 +143,6 @@ func (o *APIKeyRelationships) UnmarshalJSON(bytes []byte) (err error) {
hasInvalidField = true
}
o.CreatedBy = all.CreatedBy
if all.ModifiedBy != nil && all.ModifiedBy.UnparsedObject != nil && o.UnparsedObject == nil {
hasInvalidField = true
}
o.ModifiedBy = all.ModifiedBy

if len(additionalProperties) > 0 {
Expand Down
Loading