|
| 1 | +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +// This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +// Copyright 2019-Present Datadog, Inc. |
| 4 | + |
| 5 | +package datadogV2 |
| 6 | + |
| 7 | +import ( |
| 8 | + "fmt" |
| 9 | + |
| 10 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 11 | +) |
| 12 | + |
| 13 | +// CreateTableRequestData The definition of `CreateTableRequestData` object. |
| 14 | +type CreateTableRequestData struct { |
| 15 | + // The definition of `CreateTableRequestDataAttributes` object. |
| 16 | + Attributes *CreateTableRequestDataAttributes `json:"attributes,omitempty"` |
| 17 | + // The ID of the reference table. |
| 18 | + Id *string `json:"id,omitempty"` |
| 19 | + // Reference table resource type. |
| 20 | + Type CreateTableRequestDataType `json:"type"` |
| 21 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 22 | + UnparsedObject map[string]interface{} `json:"-"` |
| 23 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 24 | +} |
| 25 | + |
| 26 | +// NewCreateTableRequestData instantiates a new CreateTableRequestData object. |
| 27 | +// This constructor will assign default values to properties that have it defined, |
| 28 | +// and makes sure properties required by API are set, but the set of arguments |
| 29 | +// will change when the set of required properties is changed. |
| 30 | +func NewCreateTableRequestData(typeVar CreateTableRequestDataType) *CreateTableRequestData { |
| 31 | + this := CreateTableRequestData{} |
| 32 | + this.Type = typeVar |
| 33 | + return &this |
| 34 | +} |
| 35 | + |
| 36 | +// NewCreateTableRequestDataWithDefaults instantiates a new CreateTableRequestData object. |
| 37 | +// This constructor will only assign default values to properties that have it defined, |
| 38 | +// but it doesn't guarantee that properties required by API are set. |
| 39 | +func NewCreateTableRequestDataWithDefaults() *CreateTableRequestData { |
| 40 | + this := CreateTableRequestData{} |
| 41 | + var typeVar CreateTableRequestDataType = CREATETABLEREQUESTDATATYPE_REFERENCE_TABLE |
| 42 | + this.Type = typeVar |
| 43 | + return &this |
| 44 | +} |
| 45 | + |
| 46 | +// GetAttributes returns the Attributes field value if set, zero value otherwise. |
| 47 | +func (o *CreateTableRequestData) GetAttributes() CreateTableRequestDataAttributes { |
| 48 | + if o == nil || o.Attributes == nil { |
| 49 | + var ret CreateTableRequestDataAttributes |
| 50 | + return ret |
| 51 | + } |
| 52 | + return *o.Attributes |
| 53 | +} |
| 54 | + |
| 55 | +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise |
| 56 | +// and a boolean to check if the value has been set. |
| 57 | +func (o *CreateTableRequestData) GetAttributesOk() (*CreateTableRequestDataAttributes, bool) { |
| 58 | + if o == nil || o.Attributes == nil { |
| 59 | + return nil, false |
| 60 | + } |
| 61 | + return o.Attributes, true |
| 62 | +} |
| 63 | + |
| 64 | +// HasAttributes returns a boolean if a field has been set. |
| 65 | +func (o *CreateTableRequestData) HasAttributes() bool { |
| 66 | + return o != nil && o.Attributes != nil |
| 67 | +} |
| 68 | + |
| 69 | +// SetAttributes gets a reference to the given CreateTableRequestDataAttributes and assigns it to the Attributes field. |
| 70 | +func (o *CreateTableRequestData) SetAttributes(v CreateTableRequestDataAttributes) { |
| 71 | + o.Attributes = &v |
| 72 | +} |
| 73 | + |
| 74 | +// GetId returns the Id field value if set, zero value otherwise. |
| 75 | +func (o *CreateTableRequestData) GetId() string { |
| 76 | + if o == nil || o.Id == nil { |
| 77 | + var ret string |
| 78 | + return ret |
| 79 | + } |
| 80 | + return *o.Id |
| 81 | +} |
| 82 | + |
| 83 | +// GetIdOk returns a tuple with the Id field value if set, nil otherwise |
| 84 | +// and a boolean to check if the value has been set. |
| 85 | +func (o *CreateTableRequestData) GetIdOk() (*string, bool) { |
| 86 | + if o == nil || o.Id == nil { |
| 87 | + return nil, false |
| 88 | + } |
| 89 | + return o.Id, true |
| 90 | +} |
| 91 | + |
| 92 | +// HasId returns a boolean if a field has been set. |
| 93 | +func (o *CreateTableRequestData) HasId() bool { |
| 94 | + return o != nil && o.Id != nil |
| 95 | +} |
| 96 | + |
| 97 | +// SetId gets a reference to the given string and assigns it to the Id field. |
| 98 | +func (o *CreateTableRequestData) SetId(v string) { |
| 99 | + o.Id = &v |
| 100 | +} |
| 101 | + |
| 102 | +// GetType returns the Type field value. |
| 103 | +func (o *CreateTableRequestData) GetType() CreateTableRequestDataType { |
| 104 | + if o == nil { |
| 105 | + var ret CreateTableRequestDataType |
| 106 | + return ret |
| 107 | + } |
| 108 | + return o.Type |
| 109 | +} |
| 110 | + |
| 111 | +// GetTypeOk returns a tuple with the Type field value |
| 112 | +// and a boolean to check if the value has been set. |
| 113 | +func (o *CreateTableRequestData) GetTypeOk() (*CreateTableRequestDataType, bool) { |
| 114 | + if o == nil { |
| 115 | + return nil, false |
| 116 | + } |
| 117 | + return &o.Type, true |
| 118 | +} |
| 119 | + |
| 120 | +// SetType sets field value. |
| 121 | +func (o *CreateTableRequestData) SetType(v CreateTableRequestDataType) { |
| 122 | + o.Type = v |
| 123 | +} |
| 124 | + |
| 125 | +// MarshalJSON serializes the struct using spec logic. |
| 126 | +func (o CreateTableRequestData) MarshalJSON() ([]byte, error) { |
| 127 | + toSerialize := map[string]interface{}{} |
| 128 | + if o.UnparsedObject != nil { |
| 129 | + return datadog.Marshal(o.UnparsedObject) |
| 130 | + } |
| 131 | + if o.Attributes != nil { |
| 132 | + toSerialize["attributes"] = o.Attributes |
| 133 | + } |
| 134 | + if o.Id != nil { |
| 135 | + toSerialize["id"] = o.Id |
| 136 | + } |
| 137 | + toSerialize["type"] = o.Type |
| 138 | + |
| 139 | + for key, value := range o.AdditionalProperties { |
| 140 | + toSerialize[key] = value |
| 141 | + } |
| 142 | + return datadog.Marshal(toSerialize) |
| 143 | +} |
| 144 | + |
| 145 | +// UnmarshalJSON deserializes the given payload. |
| 146 | +func (o *CreateTableRequestData) UnmarshalJSON(bytes []byte) (err error) { |
| 147 | + all := struct { |
| 148 | + Attributes *CreateTableRequestDataAttributes `json:"attributes,omitempty"` |
| 149 | + Id *string `json:"id,omitempty"` |
| 150 | + Type *CreateTableRequestDataType `json:"type"` |
| 151 | + }{} |
| 152 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 153 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 154 | + } |
| 155 | + if all.Type == nil { |
| 156 | + return fmt.Errorf("required field type missing") |
| 157 | + } |
| 158 | + additionalProperties := make(map[string]interface{}) |
| 159 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 160 | + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) |
| 161 | + } else { |
| 162 | + return err |
| 163 | + } |
| 164 | + |
| 165 | + hasInvalidField := false |
| 166 | + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { |
| 167 | + hasInvalidField = true |
| 168 | + } |
| 169 | + o.Attributes = all.Attributes |
| 170 | + o.Id = all.Id |
| 171 | + if !all.Type.IsValid() { |
| 172 | + hasInvalidField = true |
| 173 | + } else { |
| 174 | + o.Type = *all.Type |
| 175 | + } |
| 176 | + |
| 177 | + if len(additionalProperties) > 0 { |
| 178 | + o.AdditionalProperties = additionalProperties |
| 179 | + } |
| 180 | + |
| 181 | + if hasInvalidField { |
| 182 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 183 | + } |
| 184 | + |
| 185 | + return nil |
| 186 | +} |
0 commit comments