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