|
| 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 | +// SyntheticsDowntimeData A Synthetics downtime object. |
| 14 | +type SyntheticsDowntimeData struct { |
| 15 | + // Attributes of a Synthetics downtime response object. |
| 16 | + Attributes SyntheticsDowntimeDataAttributesResponse `json:"attributes"` |
| 17 | + // The unique identifier of the downtime. |
| 18 | + Id string `json:"id"` |
| 19 | + // The resource type for a Synthetics downtime. |
| 20 | + Type SyntheticsDowntimeResourceType `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 | +// NewSyntheticsDowntimeData instantiates a new SyntheticsDowntimeData 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 NewSyntheticsDowntimeData(attributes SyntheticsDowntimeDataAttributesResponse, id string, typeVar SyntheticsDowntimeResourceType) *SyntheticsDowntimeData { |
| 31 | + this := SyntheticsDowntimeData{} |
| 32 | + this.Attributes = attributes |
| 33 | + this.Id = id |
| 34 | + this.Type = typeVar |
| 35 | + return &this |
| 36 | +} |
| 37 | + |
| 38 | +// NewSyntheticsDowntimeDataWithDefaults instantiates a new SyntheticsDowntimeData 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 NewSyntheticsDowntimeDataWithDefaults() *SyntheticsDowntimeData { |
| 42 | + this := SyntheticsDowntimeData{} |
| 43 | + return &this |
| 44 | +} |
| 45 | + |
| 46 | +// GetAttributes returns the Attributes field value. |
| 47 | +func (o *SyntheticsDowntimeData) GetAttributes() SyntheticsDowntimeDataAttributesResponse { |
| 48 | + if o == nil { |
| 49 | + var ret SyntheticsDowntimeDataAttributesResponse |
| 50 | + return ret |
| 51 | + } |
| 52 | + return o.Attributes |
| 53 | +} |
| 54 | + |
| 55 | +// GetAttributesOk returns a tuple with the Attributes field value |
| 56 | +// and a boolean to check if the value has been set. |
| 57 | +func (o *SyntheticsDowntimeData) GetAttributesOk() (*SyntheticsDowntimeDataAttributesResponse, bool) { |
| 58 | + if o == nil { |
| 59 | + return nil, false |
| 60 | + } |
| 61 | + return &o.Attributes, true |
| 62 | +} |
| 63 | + |
| 64 | +// SetAttributes sets field value. |
| 65 | +func (o *SyntheticsDowntimeData) SetAttributes(v SyntheticsDowntimeDataAttributesResponse) { |
| 66 | + o.Attributes = v |
| 67 | +} |
| 68 | + |
| 69 | +// GetId returns the Id field value. |
| 70 | +func (o *SyntheticsDowntimeData) GetId() string { |
| 71 | + if o == nil { |
| 72 | + var ret string |
| 73 | + return ret |
| 74 | + } |
| 75 | + return o.Id |
| 76 | +} |
| 77 | + |
| 78 | +// GetIdOk returns a tuple with the Id field value |
| 79 | +// and a boolean to check if the value has been set. |
| 80 | +func (o *SyntheticsDowntimeData) GetIdOk() (*string, bool) { |
| 81 | + if o == nil { |
| 82 | + return nil, false |
| 83 | + } |
| 84 | + return &o.Id, true |
| 85 | +} |
| 86 | + |
| 87 | +// SetId sets field value. |
| 88 | +func (o *SyntheticsDowntimeData) SetId(v string) { |
| 89 | + o.Id = v |
| 90 | +} |
| 91 | + |
| 92 | +// GetType returns the Type field value. |
| 93 | +func (o *SyntheticsDowntimeData) GetType() SyntheticsDowntimeResourceType { |
| 94 | + if o == nil { |
| 95 | + var ret SyntheticsDowntimeResourceType |
| 96 | + return ret |
| 97 | + } |
| 98 | + return o.Type |
| 99 | +} |
| 100 | + |
| 101 | +// GetTypeOk returns a tuple with the Type field value |
| 102 | +// and a boolean to check if the value has been set. |
| 103 | +func (o *SyntheticsDowntimeData) GetTypeOk() (*SyntheticsDowntimeResourceType, bool) { |
| 104 | + if o == nil { |
| 105 | + return nil, false |
| 106 | + } |
| 107 | + return &o.Type, true |
| 108 | +} |
| 109 | + |
| 110 | +// SetType sets field value. |
| 111 | +func (o *SyntheticsDowntimeData) SetType(v SyntheticsDowntimeResourceType) { |
| 112 | + o.Type = v |
| 113 | +} |
| 114 | + |
| 115 | +// MarshalJSON serializes the struct using spec logic. |
| 116 | +func (o SyntheticsDowntimeData) MarshalJSON() ([]byte, error) { |
| 117 | + toSerialize := map[string]interface{}{} |
| 118 | + if o.UnparsedObject != nil { |
| 119 | + return datadog.Marshal(o.UnparsedObject) |
| 120 | + } |
| 121 | + toSerialize["attributes"] = o.Attributes |
| 122 | + toSerialize["id"] = o.Id |
| 123 | + toSerialize["type"] = o.Type |
| 124 | + |
| 125 | + for key, value := range o.AdditionalProperties { |
| 126 | + toSerialize[key] = value |
| 127 | + } |
| 128 | + return datadog.Marshal(toSerialize) |
| 129 | +} |
| 130 | + |
| 131 | +// UnmarshalJSON deserializes the given payload. |
| 132 | +func (o *SyntheticsDowntimeData) UnmarshalJSON(bytes []byte) (err error) { |
| 133 | + all := struct { |
| 134 | + Attributes *SyntheticsDowntimeDataAttributesResponse `json:"attributes"` |
| 135 | + Id *string `json:"id"` |
| 136 | + Type *SyntheticsDowntimeResourceType `json:"type"` |
| 137 | + }{} |
| 138 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 139 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 140 | + } |
| 141 | + if all.Attributes == nil { |
| 142 | + return fmt.Errorf("required field attributes missing") |
| 143 | + } |
| 144 | + if all.Id == nil { |
| 145 | + return fmt.Errorf("required field id missing") |
| 146 | + } |
| 147 | + if all.Type == nil { |
| 148 | + return fmt.Errorf("required field type missing") |
| 149 | + } |
| 150 | + additionalProperties := make(map[string]interface{}) |
| 151 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 152 | + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) |
| 153 | + } else { |
| 154 | + return err |
| 155 | + } |
| 156 | + |
| 157 | + hasInvalidField := false |
| 158 | + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { |
| 159 | + hasInvalidField = true |
| 160 | + } |
| 161 | + o.Attributes = *all.Attributes |
| 162 | + o.Id = *all.Id |
| 163 | + if !all.Type.IsValid() { |
| 164 | + hasInvalidField = true |
| 165 | + } else { |
| 166 | + o.Type = *all.Type |
| 167 | + } |
| 168 | + |
| 169 | + if len(additionalProperties) > 0 { |
| 170 | + o.AdditionalProperties = additionalProperties |
| 171 | + } |
| 172 | + |
| 173 | + if hasInvalidField { |
| 174 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 175 | + } |
| 176 | + |
| 177 | + return nil |
| 178 | +} |
0 commit comments