Skip to content

Commit

Permalink
Regenerate client from commit b7f92f57 of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Feb 13, 2024
1 parent e4db190 commit ece90b4
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 6 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-02-12 17:39:25.538669",
"spec_repo_commit": "3cda457d"
"regenerated": "2024-02-13 18:10:15.960581",
"spec_repo_commit": "b7f92f57"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-02-12 17:39:25.567065",
"spec_repo_commit": "3cda457d"
"regenerated": "2024-02-13 18:10:15.980192",
"spec_repo_commit": "b7f92f57"
}
}
}
9 changes: 9 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21265,6 +21265,10 @@ components:
required:
- type
type: object
UserTeamIncluded:
description: Included resources related to the team membership
oneOf:
- $ref: '#/components/schemas/User'
UserTeamPermission:
description: A user's permissions for a given team
properties:
Expand Down Expand Up @@ -21319,6 +21323,11 @@ components:
properties:
data:
$ref: '#/components/schemas/UserTeam'
included:
description: Resources related to the team memberships
items:
$ref: '#/components/schemas/UserTeamIncluded'
type: array
type: object
UserTeamRole:
description: The user's role within the team
Expand Down
73 changes: 73 additions & 0 deletions api/datadogV2/model_user_team_included.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// 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 (
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// UserTeamIncluded - Included resources related to the team membership
type UserTeamIncluded struct {
User *User

// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject interface{}
}

// UserAsUserTeamIncluded is a convenience function that returns User wrapped in UserTeamIncluded.
func UserAsUserTeamIncluded(v *User) UserTeamIncluded {
return UserTeamIncluded{User: v}
}

// UnmarshalJSON turns data into one of the pointers in the struct.
func (obj *UserTeamIncluded) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into User
err = datadog.Unmarshal(data, &obj.User)
if err == nil {
if obj.User != nil && obj.User.UnparsedObject == nil {
jsonUser, _ := datadog.Marshal(obj.User)
if string(jsonUser) == "{}" { // empty struct
obj.User = nil
} else {
match++
}
} else {
obj.User = nil
}
} else {
obj.User = nil
}

if match != 1 { // more than 1 match
// reset to nil
obj.User = nil
return datadog.Unmarshal(data, &obj.UnparsedObject)
}
return nil // exactly one match
}

// MarshalJSON turns data from the first non-nil pointers in the struct to JSON.
func (obj UserTeamIncluded) MarshalJSON() ([]byte, error) {
if obj.User != nil {
return datadog.Marshal(&obj.User)
}

if obj.UnparsedObject != nil {
return datadog.Marshal(obj.UnparsedObject)
}
return nil, nil // no data in oneOf schemas
}

// GetActualInstance returns the actual instance.
func (obj *UserTeamIncluded) GetActualInstance() interface{} {
if obj.User != nil {
return obj.User
}

// all schemas are nil
return nil
}
39 changes: 37 additions & 2 deletions api/datadogV2/model_user_team_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
type UserTeamResponse struct {
// A user's relationship with a team
Data *UserTeam `json:"data,omitempty"`
// Resources related to the team memberships
Included []UserTeamIncluded `json:"included,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 @@ -62,6 +64,34 @@ func (o *UserTeamResponse) SetData(v UserTeam) {
o.Data = &v
}

// GetIncluded returns the Included field value if set, zero value otherwise.
func (o *UserTeamResponse) GetIncluded() []UserTeamIncluded {
if o == nil || o.Included == nil {
var ret []UserTeamIncluded
return ret
}
return o.Included
}

// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UserTeamResponse) GetIncludedOk() (*[]UserTeamIncluded, bool) {
if o == nil || o.Included == nil {
return nil, false
}
return &o.Included, true
}

// HasIncluded returns a boolean if a field has been set.
func (o *UserTeamResponse) HasIncluded() bool {
return o != nil && o.Included != nil
}

// SetIncluded gets a reference to the given []UserTeamIncluded and assigns it to the Included field.
func (o *UserTeamResponse) SetIncluded(v []UserTeamIncluded) {
o.Included = v
}

// MarshalJSON serializes the struct using spec logic.
func (o UserTeamResponse) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
Expand All @@ -71,6 +101,9 @@ func (o UserTeamResponse) MarshalJSON() ([]byte, error) {
if o.Data != nil {
toSerialize["data"] = o.Data
}
if o.Included != nil {
toSerialize["included"] = o.Included
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -81,14 +114,15 @@ func (o UserTeamResponse) MarshalJSON() ([]byte, error) {
// UnmarshalJSON deserializes the given payload.
func (o *UserTeamResponse) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Data *UserTeam `json:"data,omitempty"`
Data *UserTeam `json:"data,omitempty"`
Included []UserTeamIncluded `json:"included,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"data"})
datadog.DeleteKeys(additionalProperties, &[]string{"data", "included"})
} else {
return err
}
Expand All @@ -98,6 +132,7 @@ func (o *UserTeamResponse) UnmarshalJSON(bytes []byte) (err error) {
hasInvalidField = true
}
o.Data = all.Data
o.Included = all.Included

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
Expand Down

0 comments on commit ece90b4

Please sign in to comment.