|
| 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 | +// LogsArchiveEncryptionS3 The S3 encryption settings. |
| 14 | +type LogsArchiveEncryptionS3 struct { |
| 15 | + // An Amazon Resource Name (ARN) used to identify an AWS KMS key. |
| 16 | + Key *string `json:"key,omitempty"` |
| 17 | + // Type of S3 encryption for a destination. |
| 18 | + Type LogsArchiveEncryptionS3Type `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 | +// NewLogsArchiveEncryptionS3 instantiates a new LogsArchiveEncryptionS3 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 NewLogsArchiveEncryptionS3(typeVar LogsArchiveEncryptionS3Type) *LogsArchiveEncryptionS3 { |
| 29 | + this := LogsArchiveEncryptionS3{} |
| 30 | + this.Type = typeVar |
| 31 | + return &this |
| 32 | +} |
| 33 | + |
| 34 | +// NewLogsArchiveEncryptionS3WithDefaults instantiates a new LogsArchiveEncryptionS3 object. |
| 35 | +// This constructor will only assign default values to properties that have it defined, |
| 36 | +// but it doesn't guarantee that properties required by API are set. |
| 37 | +func NewLogsArchiveEncryptionS3WithDefaults() *LogsArchiveEncryptionS3 { |
| 38 | + this := LogsArchiveEncryptionS3{} |
| 39 | + return &this |
| 40 | +} |
| 41 | + |
| 42 | +// GetKey returns the Key field value if set, zero value otherwise. |
| 43 | +func (o *LogsArchiveEncryptionS3) GetKey() string { |
| 44 | + if o == nil || o.Key == nil { |
| 45 | + var ret string |
| 46 | + return ret |
| 47 | + } |
| 48 | + return *o.Key |
| 49 | +} |
| 50 | + |
| 51 | +// GetKeyOk returns a tuple with the Key field value if set, nil otherwise |
| 52 | +// and a boolean to check if the value has been set. |
| 53 | +func (o *LogsArchiveEncryptionS3) GetKeyOk() (*string, bool) { |
| 54 | + if o == nil || o.Key == nil { |
| 55 | + return nil, false |
| 56 | + } |
| 57 | + return o.Key, true |
| 58 | +} |
| 59 | + |
| 60 | +// HasKey returns a boolean if a field has been set. |
| 61 | +func (o *LogsArchiveEncryptionS3) HasKey() bool { |
| 62 | + return o != nil && o.Key != nil |
| 63 | +} |
| 64 | + |
| 65 | +// SetKey gets a reference to the given string and assigns it to the Key field. |
| 66 | +func (o *LogsArchiveEncryptionS3) SetKey(v string) { |
| 67 | + o.Key = &v |
| 68 | +} |
| 69 | + |
| 70 | +// GetType returns the Type field value. |
| 71 | +func (o *LogsArchiveEncryptionS3) GetType() LogsArchiveEncryptionS3Type { |
| 72 | + if o == nil { |
| 73 | + var ret LogsArchiveEncryptionS3Type |
| 74 | + return ret |
| 75 | + } |
| 76 | + return o.Type |
| 77 | +} |
| 78 | + |
| 79 | +// GetTypeOk returns a tuple with the Type field value |
| 80 | +// and a boolean to check if the value has been set. |
| 81 | +func (o *LogsArchiveEncryptionS3) GetTypeOk() (*LogsArchiveEncryptionS3Type, bool) { |
| 82 | + if o == nil { |
| 83 | + return nil, false |
| 84 | + } |
| 85 | + return &o.Type, true |
| 86 | +} |
| 87 | + |
| 88 | +// SetType sets field value. |
| 89 | +func (o *LogsArchiveEncryptionS3) SetType(v LogsArchiveEncryptionS3Type) { |
| 90 | + o.Type = v |
| 91 | +} |
| 92 | + |
| 93 | +// MarshalJSON serializes the struct using spec logic. |
| 94 | +func (o LogsArchiveEncryptionS3) MarshalJSON() ([]byte, error) { |
| 95 | + toSerialize := map[string]interface{}{} |
| 96 | + if o.UnparsedObject != nil { |
| 97 | + return datadog.Marshal(o.UnparsedObject) |
| 98 | + } |
| 99 | + if o.Key != nil { |
| 100 | + toSerialize["key"] = o.Key |
| 101 | + } |
| 102 | + toSerialize["type"] = o.Type |
| 103 | + |
| 104 | + for key, value := range o.AdditionalProperties { |
| 105 | + toSerialize[key] = value |
| 106 | + } |
| 107 | + return datadog.Marshal(toSerialize) |
| 108 | +} |
| 109 | + |
| 110 | +// UnmarshalJSON deserializes the given payload. |
| 111 | +func (o *LogsArchiveEncryptionS3) UnmarshalJSON(bytes []byte) (err error) { |
| 112 | + all := struct { |
| 113 | + Key *string `json:"key,omitempty"` |
| 114 | + Type *LogsArchiveEncryptionS3Type `json:"type"` |
| 115 | + }{} |
| 116 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 117 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 118 | + } |
| 119 | + if all.Type == nil { |
| 120 | + return fmt.Errorf("required field type missing") |
| 121 | + } |
| 122 | + additionalProperties := make(map[string]interface{}) |
| 123 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 124 | + datadog.DeleteKeys(additionalProperties, &[]string{"key", "type"}) |
| 125 | + } else { |
| 126 | + return err |
| 127 | + } |
| 128 | + |
| 129 | + hasInvalidField := false |
| 130 | + o.Key = all.Key |
| 131 | + if !all.Type.IsValid() { |
| 132 | + hasInvalidField = true |
| 133 | + } else { |
| 134 | + o.Type = *all.Type |
| 135 | + } |
| 136 | + |
| 137 | + if len(additionalProperties) > 0 { |
| 138 | + o.AdditionalProperties = additionalProperties |
| 139 | + } |
| 140 | + |
| 141 | + if hasInvalidField { |
| 142 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 143 | + } |
| 144 | + |
| 145 | + return nil |
| 146 | +} |
0 commit comments