|
| 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 | +// ObservabilityPipelineAddHostnameProcessor The `add_hostname` processor adds the hostname to log events. |
| 14 | +// |
| 15 | +// **Supported pipeline types:** logs |
| 16 | +type ObservabilityPipelineAddHostnameProcessor struct { |
| 17 | + // The display name for a component. |
| 18 | + DisplayName *string `json:"display_name,omitempty"` |
| 19 | + // Indicates whether the processor is enabled. |
| 20 | + Enabled bool `json:"enabled"` |
| 21 | + // The unique identifier for this component. Used in other parts of the pipeline to reference this component (for example, as the `input` to downstream components). |
| 22 | + Id string `json:"id"` |
| 23 | + // A Datadog search query used to determine which logs this processor targets. |
| 24 | + Include string `json:"include"` |
| 25 | + // The processor type. The value should always be `add_hostname`. |
| 26 | + Type ObservabilityPipelineAddHostnameProcessorType `json:"type"` |
| 27 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 28 | + UnparsedObject map[string]interface{} `json:"-"` |
| 29 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 30 | +} |
| 31 | + |
| 32 | +// NewObservabilityPipelineAddHostnameProcessor instantiates a new ObservabilityPipelineAddHostnameProcessor object. |
| 33 | +// This constructor will assign default values to properties that have it defined, |
| 34 | +// and makes sure properties required by API are set, but the set of arguments |
| 35 | +// will change when the set of required properties is changed. |
| 36 | +func NewObservabilityPipelineAddHostnameProcessor(enabled bool, id string, include string, typeVar ObservabilityPipelineAddHostnameProcessorType) *ObservabilityPipelineAddHostnameProcessor { |
| 37 | + this := ObservabilityPipelineAddHostnameProcessor{} |
| 38 | + this.Enabled = enabled |
| 39 | + this.Id = id |
| 40 | + this.Include = include |
| 41 | + this.Type = typeVar |
| 42 | + return &this |
| 43 | +} |
| 44 | + |
| 45 | +// NewObservabilityPipelineAddHostnameProcessorWithDefaults instantiates a new ObservabilityPipelineAddHostnameProcessor object. |
| 46 | +// This constructor will only assign default values to properties that have it defined, |
| 47 | +// but it doesn't guarantee that properties required by API are set. |
| 48 | +func NewObservabilityPipelineAddHostnameProcessorWithDefaults() *ObservabilityPipelineAddHostnameProcessor { |
| 49 | + this := ObservabilityPipelineAddHostnameProcessor{} |
| 50 | + var typeVar ObservabilityPipelineAddHostnameProcessorType = OBSERVABILITYPIPELINEADDHOSTNAMEPROCESSORTYPE_ADD_HOSTNAME |
| 51 | + this.Type = typeVar |
| 52 | + return &this |
| 53 | +} |
| 54 | + |
| 55 | +// GetDisplayName returns the DisplayName field value if set, zero value otherwise. |
| 56 | +func (o *ObservabilityPipelineAddHostnameProcessor) GetDisplayName() string { |
| 57 | + if o == nil || o.DisplayName == nil { |
| 58 | + var ret string |
| 59 | + return ret |
| 60 | + } |
| 61 | + return *o.DisplayName |
| 62 | +} |
| 63 | + |
| 64 | +// GetDisplayNameOk returns a tuple with the DisplayName field value if set, nil otherwise |
| 65 | +// and a boolean to check if the value has been set. |
| 66 | +func (o *ObservabilityPipelineAddHostnameProcessor) GetDisplayNameOk() (*string, bool) { |
| 67 | + if o == nil || o.DisplayName == nil { |
| 68 | + return nil, false |
| 69 | + } |
| 70 | + return o.DisplayName, true |
| 71 | +} |
| 72 | + |
| 73 | +// HasDisplayName returns a boolean if a field has been set. |
| 74 | +func (o *ObservabilityPipelineAddHostnameProcessor) HasDisplayName() bool { |
| 75 | + return o != nil && o.DisplayName != nil |
| 76 | +} |
| 77 | + |
| 78 | +// SetDisplayName gets a reference to the given string and assigns it to the DisplayName field. |
| 79 | +func (o *ObservabilityPipelineAddHostnameProcessor) SetDisplayName(v string) { |
| 80 | + o.DisplayName = &v |
| 81 | +} |
| 82 | + |
| 83 | +// GetEnabled returns the Enabled field value. |
| 84 | +func (o *ObservabilityPipelineAddHostnameProcessor) GetEnabled() bool { |
| 85 | + if o == nil { |
| 86 | + var ret bool |
| 87 | + return ret |
| 88 | + } |
| 89 | + return o.Enabled |
| 90 | +} |
| 91 | + |
| 92 | +// GetEnabledOk returns a tuple with the Enabled field value |
| 93 | +// and a boolean to check if the value has been set. |
| 94 | +func (o *ObservabilityPipelineAddHostnameProcessor) GetEnabledOk() (*bool, bool) { |
| 95 | + if o == nil { |
| 96 | + return nil, false |
| 97 | + } |
| 98 | + return &o.Enabled, true |
| 99 | +} |
| 100 | + |
| 101 | +// SetEnabled sets field value. |
| 102 | +func (o *ObservabilityPipelineAddHostnameProcessor) SetEnabled(v bool) { |
| 103 | + o.Enabled = v |
| 104 | +} |
| 105 | + |
| 106 | +// GetId returns the Id field value. |
| 107 | +func (o *ObservabilityPipelineAddHostnameProcessor) GetId() string { |
| 108 | + if o == nil { |
| 109 | + var ret string |
| 110 | + return ret |
| 111 | + } |
| 112 | + return o.Id |
| 113 | +} |
| 114 | + |
| 115 | +// GetIdOk returns a tuple with the Id field value |
| 116 | +// and a boolean to check if the value has been set. |
| 117 | +func (o *ObservabilityPipelineAddHostnameProcessor) GetIdOk() (*string, bool) { |
| 118 | + if o == nil { |
| 119 | + return nil, false |
| 120 | + } |
| 121 | + return &o.Id, true |
| 122 | +} |
| 123 | + |
| 124 | +// SetId sets field value. |
| 125 | +func (o *ObservabilityPipelineAddHostnameProcessor) SetId(v string) { |
| 126 | + o.Id = v |
| 127 | +} |
| 128 | + |
| 129 | +// GetInclude returns the Include field value. |
| 130 | +func (o *ObservabilityPipelineAddHostnameProcessor) GetInclude() string { |
| 131 | + if o == nil { |
| 132 | + var ret string |
| 133 | + return ret |
| 134 | + } |
| 135 | + return o.Include |
| 136 | +} |
| 137 | + |
| 138 | +// GetIncludeOk returns a tuple with the Include field value |
| 139 | +// and a boolean to check if the value has been set. |
| 140 | +func (o *ObservabilityPipelineAddHostnameProcessor) GetIncludeOk() (*string, bool) { |
| 141 | + if o == nil { |
| 142 | + return nil, false |
| 143 | + } |
| 144 | + return &o.Include, true |
| 145 | +} |
| 146 | + |
| 147 | +// SetInclude sets field value. |
| 148 | +func (o *ObservabilityPipelineAddHostnameProcessor) SetInclude(v string) { |
| 149 | + o.Include = v |
| 150 | +} |
| 151 | + |
| 152 | +// GetType returns the Type field value. |
| 153 | +func (o *ObservabilityPipelineAddHostnameProcessor) GetType() ObservabilityPipelineAddHostnameProcessorType { |
| 154 | + if o == nil { |
| 155 | + var ret ObservabilityPipelineAddHostnameProcessorType |
| 156 | + return ret |
| 157 | + } |
| 158 | + return o.Type |
| 159 | +} |
| 160 | + |
| 161 | +// GetTypeOk returns a tuple with the Type field value |
| 162 | +// and a boolean to check if the value has been set. |
| 163 | +func (o *ObservabilityPipelineAddHostnameProcessor) GetTypeOk() (*ObservabilityPipelineAddHostnameProcessorType, bool) { |
| 164 | + if o == nil { |
| 165 | + return nil, false |
| 166 | + } |
| 167 | + return &o.Type, true |
| 168 | +} |
| 169 | + |
| 170 | +// SetType sets field value. |
| 171 | +func (o *ObservabilityPipelineAddHostnameProcessor) SetType(v ObservabilityPipelineAddHostnameProcessorType) { |
| 172 | + o.Type = v |
| 173 | +} |
| 174 | + |
| 175 | +// MarshalJSON serializes the struct using spec logic. |
| 176 | +func (o ObservabilityPipelineAddHostnameProcessor) MarshalJSON() ([]byte, error) { |
| 177 | + toSerialize := map[string]interface{}{} |
| 178 | + if o.UnparsedObject != nil { |
| 179 | + return datadog.Marshal(o.UnparsedObject) |
| 180 | + } |
| 181 | + if o.DisplayName != nil { |
| 182 | + toSerialize["display_name"] = o.DisplayName |
| 183 | + } |
| 184 | + toSerialize["enabled"] = o.Enabled |
| 185 | + toSerialize["id"] = o.Id |
| 186 | + toSerialize["include"] = o.Include |
| 187 | + toSerialize["type"] = o.Type |
| 188 | + |
| 189 | + for key, value := range o.AdditionalProperties { |
| 190 | + toSerialize[key] = value |
| 191 | + } |
| 192 | + return datadog.Marshal(toSerialize) |
| 193 | +} |
| 194 | + |
| 195 | +// UnmarshalJSON deserializes the given payload. |
| 196 | +func (o *ObservabilityPipelineAddHostnameProcessor) UnmarshalJSON(bytes []byte) (err error) { |
| 197 | + all := struct { |
| 198 | + DisplayName *string `json:"display_name,omitempty"` |
| 199 | + Enabled *bool `json:"enabled"` |
| 200 | + Id *string `json:"id"` |
| 201 | + Include *string `json:"include"` |
| 202 | + Type *ObservabilityPipelineAddHostnameProcessorType `json:"type"` |
| 203 | + }{} |
| 204 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 205 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 206 | + } |
| 207 | + if all.Enabled == nil { |
| 208 | + return fmt.Errorf("required field enabled missing") |
| 209 | + } |
| 210 | + if all.Id == nil { |
| 211 | + return fmt.Errorf("required field id missing") |
| 212 | + } |
| 213 | + if all.Include == nil { |
| 214 | + return fmt.Errorf("required field include missing") |
| 215 | + } |
| 216 | + if all.Type == nil { |
| 217 | + return fmt.Errorf("required field type missing") |
| 218 | + } |
| 219 | + additionalProperties := make(map[string]interface{}) |
| 220 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 221 | + datadog.DeleteKeys(additionalProperties, &[]string{"display_name", "enabled", "id", "include", "type"}) |
| 222 | + } else { |
| 223 | + return err |
| 224 | + } |
| 225 | + |
| 226 | + hasInvalidField := false |
| 227 | + o.DisplayName = all.DisplayName |
| 228 | + o.Enabled = *all.Enabled |
| 229 | + o.Id = *all.Id |
| 230 | + o.Include = *all.Include |
| 231 | + if !all.Type.IsValid() { |
| 232 | + hasInvalidField = true |
| 233 | + } else { |
| 234 | + o.Type = *all.Type |
| 235 | + } |
| 236 | + |
| 237 | + if len(additionalProperties) > 0 { |
| 238 | + o.AdditionalProperties = additionalProperties |
| 239 | + } |
| 240 | + |
| 241 | + if hasInvalidField { |
| 242 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 243 | + } |
| 244 | + |
| 245 | + return nil |
| 246 | +} |
0 commit comments