// 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 ( "encoding/json" "fmt" "github.com/DataDog/datadog-api-client-go/v2/api/datadog" ) // Team A team type Team struct { // Team attributes Attributes TeamAttributes `json:"attributes"` // The team's identifier Id string `json:"id"` // Resources related to a team Relationships *TeamRelationships `json:"relationships,omitempty"` // Team type Type TeamType `json:"type"` // 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{} } // NewTeam instantiates a new Team object. // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed. func NewTeam(attributes TeamAttributes, id string, typeVar TeamType) *Team { this := Team{} this.Attributes = attributes this.Id = id this.Type = typeVar return &this } // NewTeamWithDefaults instantiates a new Team object. // This constructor will only assign default values to properties that have it defined, // but it doesn't guarantee that properties required by API are set. func NewTeamWithDefaults() *Team { this := Team{} var typeVar TeamType = TEAMTYPE_TEAM this.Type = typeVar return &this } // GetAttributes returns the Attributes field value. func (o *Team) GetAttributes() TeamAttributes { if o == nil { var ret TeamAttributes return ret } return o.Attributes } // GetAttributesOk returns a tuple with the Attributes field value // and a boolean to check if the value has been set. func (o *Team) GetAttributesOk() (*TeamAttributes, bool) { if o == nil { return nil, false } return &o.Attributes, true } // SetAttributes sets field value. func (o *Team) SetAttributes(v TeamAttributes) { o.Attributes = v } // GetId returns the Id field value. func (o *Team) GetId() string { if o == nil { var ret string return ret } return o.Id } // GetIdOk returns a tuple with the Id field value // and a boolean to check if the value has been set. func (o *Team) GetIdOk() (*string, bool) { if o == nil { return nil, false } return &o.Id, true } // SetId sets field value. func (o *Team) SetId(v string) { o.Id = v } // GetRelationships returns the Relationships field value if set, zero value otherwise. func (o *Team) GetRelationships() TeamRelationships { if o == nil || o.Relationships == nil { var ret TeamRelationships return ret } return *o.Relationships } // GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Team) GetRelationshipsOk() (*TeamRelationships, bool) { if o == nil || o.Relationships == nil { return nil, false } return o.Relationships, true } // HasRelationships returns a boolean if a field has been set. func (o *Team) HasRelationships() bool { return o != nil && o.Relationships != nil } // SetRelationships gets a reference to the given TeamRelationships and assigns it to the Relationships field. func (o *Team) SetRelationships(v TeamRelationships) { o.Relationships = &v } // GetType returns the Type field value. func (o *Team) GetType() TeamType { if o == nil { var ret TeamType return ret } return o.Type } // GetTypeOk returns a tuple with the Type field value // and a boolean to check if the value has been set. func (o *Team) GetTypeOk() (*TeamType, bool) { if o == nil { return nil, false } return &o.Type, true } // SetType sets field value. func (o *Team) SetType(v TeamType) { o.Type = v } // MarshalJSON serializes the struct using spec logic. func (o Team) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} if o.UnparsedObject != nil { return json.Marshal(o.UnparsedObject) } toSerialize["attributes"] = o.Attributes toSerialize["id"] = o.Id if o.Relationships != nil { toSerialize["relationships"] = o.Relationships } toSerialize["type"] = o.Type for key, value := range o.AdditionalProperties { toSerialize[key] = value } return json.Marshal(toSerialize) } // UnmarshalJSON deserializes the given payload. func (o *Team) UnmarshalJSON(bytes []byte) (err error) { raw := map[string]interface{}{} all := struct { Attributes *TeamAttributes `json:"attributes"` Id *string `json:"id"` Relationships *TeamRelationships `json:"relationships,omitempty"` Type *TeamType `json:"type"` }{} if err = json.Unmarshal(bytes, &all); err != nil { err = json.Unmarshal(bytes, &raw) if err != nil { return err } o.UnparsedObject = raw return nil } if all.Attributes == nil { return fmt.Errorf("required field attributes missing") } if all.Id == nil { return fmt.Errorf("required field id missing") } if all.Type == nil { return fmt.Errorf("required field type missing") } additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(bytes, &additionalProperties); err == nil { datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) } else { return err } if v := all.Type; !v.IsValid() { err = json.Unmarshal(bytes, &raw) if err != nil { return err } o.UnparsedObject = raw return nil } if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { err = json.Unmarshal(bytes, &raw) if err != nil { return err } o.UnparsedObject = raw } o.Attributes = *all.Attributes o.Id = *all.Id if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { err = json.Unmarshal(bytes, &raw) if err != nil { return err } o.UnparsedObject = raw } o.Relationships = all.Relationships o.Type = *all.Type if len(additionalProperties) > 0 { o.AdditionalProperties = additionalProperties } return nil }