-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regenerate client from commit b7f92f57 of spec repo
- Loading branch information
ci.datadog-api-spec
committed
Feb 13, 2024
1 parent
e4db190
commit ece90b4
Showing
4 changed files
with
123 additions
and
6 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,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 | ||
} |
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