|
| 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 | +// DORADeploymentPatchRemediation Remediation details for the deployment. |
| 14 | +type DORADeploymentPatchRemediation struct { |
| 15 | + // The ID of the remediation action. |
| 16 | + Id string `json:"id"` |
| 17 | + // The type of remediation action taken. |
| 18 | + Type DORADeploymentPatchRemediationType `json:"type"` |
| 19 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 20 | + UnparsedObject map[string]interface{} `json:"-"` |
| 21 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 22 | +} |
| 23 | + |
| 24 | +// NewDORADeploymentPatchRemediation instantiates a new DORADeploymentPatchRemediation object. |
| 25 | +// This constructor will assign default values to properties that have it defined, |
| 26 | +// and makes sure properties required by API are set, but the set of arguments |
| 27 | +// will change when the set of required properties is changed. |
| 28 | +func NewDORADeploymentPatchRemediation(id string, typeVar DORADeploymentPatchRemediationType) *DORADeploymentPatchRemediation { |
| 29 | + this := DORADeploymentPatchRemediation{} |
| 30 | + this.Id = id |
| 31 | + this.Type = typeVar |
| 32 | + return &this |
| 33 | +} |
| 34 | + |
| 35 | +// NewDORADeploymentPatchRemediationWithDefaults instantiates a new DORADeploymentPatchRemediation object. |
| 36 | +// This constructor will only assign default values to properties that have it defined, |
| 37 | +// but it doesn't guarantee that properties required by API are set. |
| 38 | +func NewDORADeploymentPatchRemediationWithDefaults() *DORADeploymentPatchRemediation { |
| 39 | + this := DORADeploymentPatchRemediation{} |
| 40 | + return &this |
| 41 | +} |
| 42 | + |
| 43 | +// GetId returns the Id field value. |
| 44 | +func (o *DORADeploymentPatchRemediation) GetId() string { |
| 45 | + if o == nil { |
| 46 | + var ret string |
| 47 | + return ret |
| 48 | + } |
| 49 | + return o.Id |
| 50 | +} |
| 51 | + |
| 52 | +// GetIdOk returns a tuple with the Id field value |
| 53 | +// and a boolean to check if the value has been set. |
| 54 | +func (o *DORADeploymentPatchRemediation) GetIdOk() (*string, bool) { |
| 55 | + if o == nil { |
| 56 | + return nil, false |
| 57 | + } |
| 58 | + return &o.Id, true |
| 59 | +} |
| 60 | + |
| 61 | +// SetId sets field value. |
| 62 | +func (o *DORADeploymentPatchRemediation) SetId(v string) { |
| 63 | + o.Id = v |
| 64 | +} |
| 65 | + |
| 66 | +// GetType returns the Type field value. |
| 67 | +func (o *DORADeploymentPatchRemediation) GetType() DORADeploymentPatchRemediationType { |
| 68 | + if o == nil { |
| 69 | + var ret DORADeploymentPatchRemediationType |
| 70 | + return ret |
| 71 | + } |
| 72 | + return o.Type |
| 73 | +} |
| 74 | + |
| 75 | +// GetTypeOk returns a tuple with the Type field value |
| 76 | +// and a boolean to check if the value has been set. |
| 77 | +func (o *DORADeploymentPatchRemediation) GetTypeOk() (*DORADeploymentPatchRemediationType, bool) { |
| 78 | + if o == nil { |
| 79 | + return nil, false |
| 80 | + } |
| 81 | + return &o.Type, true |
| 82 | +} |
| 83 | + |
| 84 | +// SetType sets field value. |
| 85 | +func (o *DORADeploymentPatchRemediation) SetType(v DORADeploymentPatchRemediationType) { |
| 86 | + o.Type = v |
| 87 | +} |
| 88 | + |
| 89 | +// MarshalJSON serializes the struct using spec logic. |
| 90 | +func (o DORADeploymentPatchRemediation) MarshalJSON() ([]byte, error) { |
| 91 | + toSerialize := map[string]interface{}{} |
| 92 | + if o.UnparsedObject != nil { |
| 93 | + return datadog.Marshal(o.UnparsedObject) |
| 94 | + } |
| 95 | + toSerialize["id"] = o.Id |
| 96 | + toSerialize["type"] = o.Type |
| 97 | + |
| 98 | + for key, value := range o.AdditionalProperties { |
| 99 | + toSerialize[key] = value |
| 100 | + } |
| 101 | + return datadog.Marshal(toSerialize) |
| 102 | +} |
| 103 | + |
| 104 | +// UnmarshalJSON deserializes the given payload. |
| 105 | +func (o *DORADeploymentPatchRemediation) UnmarshalJSON(bytes []byte) (err error) { |
| 106 | + all := struct { |
| 107 | + Id *string `json:"id"` |
| 108 | + Type *DORADeploymentPatchRemediationType `json:"type"` |
| 109 | + }{} |
| 110 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 111 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 112 | + } |
| 113 | + if all.Id == nil { |
| 114 | + return fmt.Errorf("required field id missing") |
| 115 | + } |
| 116 | + if all.Type == nil { |
| 117 | + return fmt.Errorf("required field type missing") |
| 118 | + } |
| 119 | + additionalProperties := make(map[string]interface{}) |
| 120 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 121 | + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) |
| 122 | + } else { |
| 123 | + return err |
| 124 | + } |
| 125 | + |
| 126 | + hasInvalidField := false |
| 127 | + o.Id = *all.Id |
| 128 | + if !all.Type.IsValid() { |
| 129 | + hasInvalidField = true |
| 130 | + } else { |
| 131 | + o.Type = *all.Type |
| 132 | + } |
| 133 | + |
| 134 | + if len(additionalProperties) > 0 { |
| 135 | + o.AdditionalProperties = additionalProperties |
| 136 | + } |
| 137 | + |
| 138 | + if hasInvalidField { |
| 139 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 140 | + } |
| 141 | + |
| 142 | + return nil |
| 143 | +} |
0 commit comments