|
| 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 datadogV1 |
| 6 | + |
| 7 | +import ( |
| 8 | + "fmt" |
| 9 | + |
| 10 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 11 | +) |
| 12 | + |
| 13 | +// LogsArrayProcessor A processor for extracting, aggregating, or transforming values from JSON arrays within your logs. |
| 14 | +// Supported operations are: |
| 15 | +// - Select value from matching element |
| 16 | +// - Compute array length |
| 17 | +// - Append a value to an array |
| 18 | +type LogsArrayProcessor struct { |
| 19 | + // Whether or not the processor is enabled. |
| 20 | + IsEnabled *bool `json:"is_enabled,omitempty"` |
| 21 | + // Name of the processor. |
| 22 | + Name *string `json:"name,omitempty"` |
| 23 | + // Configuration of the array processor operation to perform. |
| 24 | + Operation LogsArrayProcessorOperation `json:"operation"` |
| 25 | + // Type of logs array processor. |
| 26 | + Type LogsArrayProcessorType `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 | +// NewLogsArrayProcessor instantiates a new LogsArrayProcessor 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 NewLogsArrayProcessor(operation LogsArrayProcessorOperation, typeVar LogsArrayProcessorType) *LogsArrayProcessor { |
| 37 | + this := LogsArrayProcessor{} |
| 38 | + var isEnabled bool = false |
| 39 | + this.IsEnabled = &isEnabled |
| 40 | + this.Operation = operation |
| 41 | + this.Type = typeVar |
| 42 | + return &this |
| 43 | +} |
| 44 | + |
| 45 | +// NewLogsArrayProcessorWithDefaults instantiates a new LogsArrayProcessor 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 NewLogsArrayProcessorWithDefaults() *LogsArrayProcessor { |
| 49 | + this := LogsArrayProcessor{} |
| 50 | + var isEnabled bool = false |
| 51 | + this.IsEnabled = &isEnabled |
| 52 | + var typeVar LogsArrayProcessorType = LOGSARRAYPROCESSORTYPE_ARRAY_PROCESSOR |
| 53 | + this.Type = typeVar |
| 54 | + return &this |
| 55 | +} |
| 56 | + |
| 57 | +// GetIsEnabled returns the IsEnabled field value if set, zero value otherwise. |
| 58 | +func (o *LogsArrayProcessor) GetIsEnabled() bool { |
| 59 | + if o == nil || o.IsEnabled == nil { |
| 60 | + var ret bool |
| 61 | + return ret |
| 62 | + } |
| 63 | + return *o.IsEnabled |
| 64 | +} |
| 65 | + |
| 66 | +// GetIsEnabledOk returns a tuple with the IsEnabled field value if set, nil otherwise |
| 67 | +// and a boolean to check if the value has been set. |
| 68 | +func (o *LogsArrayProcessor) GetIsEnabledOk() (*bool, bool) { |
| 69 | + if o == nil || o.IsEnabled == nil { |
| 70 | + return nil, false |
| 71 | + } |
| 72 | + return o.IsEnabled, true |
| 73 | +} |
| 74 | + |
| 75 | +// HasIsEnabled returns a boolean if a field has been set. |
| 76 | +func (o *LogsArrayProcessor) HasIsEnabled() bool { |
| 77 | + return o != nil && o.IsEnabled != nil |
| 78 | +} |
| 79 | + |
| 80 | +// SetIsEnabled gets a reference to the given bool and assigns it to the IsEnabled field. |
| 81 | +func (o *LogsArrayProcessor) SetIsEnabled(v bool) { |
| 82 | + o.IsEnabled = &v |
| 83 | +} |
| 84 | + |
| 85 | +// GetName returns the Name field value if set, zero value otherwise. |
| 86 | +func (o *LogsArrayProcessor) GetName() string { |
| 87 | + if o == nil || o.Name == nil { |
| 88 | + var ret string |
| 89 | + return ret |
| 90 | + } |
| 91 | + return *o.Name |
| 92 | +} |
| 93 | + |
| 94 | +// GetNameOk returns a tuple with the Name field value if set, nil otherwise |
| 95 | +// and a boolean to check if the value has been set. |
| 96 | +func (o *LogsArrayProcessor) GetNameOk() (*string, bool) { |
| 97 | + if o == nil || o.Name == nil { |
| 98 | + return nil, false |
| 99 | + } |
| 100 | + return o.Name, true |
| 101 | +} |
| 102 | + |
| 103 | +// HasName returns a boolean if a field has been set. |
| 104 | +func (o *LogsArrayProcessor) HasName() bool { |
| 105 | + return o != nil && o.Name != nil |
| 106 | +} |
| 107 | + |
| 108 | +// SetName gets a reference to the given string and assigns it to the Name field. |
| 109 | +func (o *LogsArrayProcessor) SetName(v string) { |
| 110 | + o.Name = &v |
| 111 | +} |
| 112 | + |
| 113 | +// GetOperation returns the Operation field value. |
| 114 | +func (o *LogsArrayProcessor) GetOperation() LogsArrayProcessorOperation { |
| 115 | + if o == nil { |
| 116 | + var ret LogsArrayProcessorOperation |
| 117 | + return ret |
| 118 | + } |
| 119 | + return o.Operation |
| 120 | +} |
| 121 | + |
| 122 | +// GetOperationOk returns a tuple with the Operation field value |
| 123 | +// and a boolean to check if the value has been set. |
| 124 | +func (o *LogsArrayProcessor) GetOperationOk() (*LogsArrayProcessorOperation, bool) { |
| 125 | + if o == nil { |
| 126 | + return nil, false |
| 127 | + } |
| 128 | + return &o.Operation, true |
| 129 | +} |
| 130 | + |
| 131 | +// SetOperation sets field value. |
| 132 | +func (o *LogsArrayProcessor) SetOperation(v LogsArrayProcessorOperation) { |
| 133 | + o.Operation = v |
| 134 | +} |
| 135 | + |
| 136 | +// GetType returns the Type field value. |
| 137 | +func (o *LogsArrayProcessor) GetType() LogsArrayProcessorType { |
| 138 | + if o == nil { |
| 139 | + var ret LogsArrayProcessorType |
| 140 | + return ret |
| 141 | + } |
| 142 | + return o.Type |
| 143 | +} |
| 144 | + |
| 145 | +// GetTypeOk returns a tuple with the Type field value |
| 146 | +// and a boolean to check if the value has been set. |
| 147 | +func (o *LogsArrayProcessor) GetTypeOk() (*LogsArrayProcessorType, bool) { |
| 148 | + if o == nil { |
| 149 | + return nil, false |
| 150 | + } |
| 151 | + return &o.Type, true |
| 152 | +} |
| 153 | + |
| 154 | +// SetType sets field value. |
| 155 | +func (o *LogsArrayProcessor) SetType(v LogsArrayProcessorType) { |
| 156 | + o.Type = v |
| 157 | +} |
| 158 | + |
| 159 | +// MarshalJSON serializes the struct using spec logic. |
| 160 | +func (o LogsArrayProcessor) MarshalJSON() ([]byte, error) { |
| 161 | + toSerialize := map[string]interface{}{} |
| 162 | + if o.UnparsedObject != nil { |
| 163 | + return datadog.Marshal(o.UnparsedObject) |
| 164 | + } |
| 165 | + if o.IsEnabled != nil { |
| 166 | + toSerialize["is_enabled"] = o.IsEnabled |
| 167 | + } |
| 168 | + if o.Name != nil { |
| 169 | + toSerialize["name"] = o.Name |
| 170 | + } |
| 171 | + toSerialize["operation"] = o.Operation |
| 172 | + toSerialize["type"] = o.Type |
| 173 | + |
| 174 | + for key, value := range o.AdditionalProperties { |
| 175 | + toSerialize[key] = value |
| 176 | + } |
| 177 | + return datadog.Marshal(toSerialize) |
| 178 | +} |
| 179 | + |
| 180 | +// UnmarshalJSON deserializes the given payload. |
| 181 | +func (o *LogsArrayProcessor) UnmarshalJSON(bytes []byte) (err error) { |
| 182 | + all := struct { |
| 183 | + IsEnabled *bool `json:"is_enabled,omitempty"` |
| 184 | + Name *string `json:"name,omitempty"` |
| 185 | + Operation *LogsArrayProcessorOperation `json:"operation"` |
| 186 | + Type *LogsArrayProcessorType `json:"type"` |
| 187 | + }{} |
| 188 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 189 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 190 | + } |
| 191 | + if all.Operation == nil { |
| 192 | + return fmt.Errorf("required field operation missing") |
| 193 | + } |
| 194 | + if all.Type == nil { |
| 195 | + return fmt.Errorf("required field type missing") |
| 196 | + } |
| 197 | + additionalProperties := make(map[string]interface{}) |
| 198 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 199 | + datadog.DeleteKeys(additionalProperties, &[]string{"is_enabled", "name", "operation", "type"}) |
| 200 | + } else { |
| 201 | + return err |
| 202 | + } |
| 203 | + |
| 204 | + hasInvalidField := false |
| 205 | + o.IsEnabled = all.IsEnabled |
| 206 | + o.Name = all.Name |
| 207 | + o.Operation = *all.Operation |
| 208 | + if !all.Type.IsValid() { |
| 209 | + hasInvalidField = true |
| 210 | + } else { |
| 211 | + o.Type = *all.Type |
| 212 | + } |
| 213 | + |
| 214 | + if len(additionalProperties) > 0 { |
| 215 | + o.AdditionalProperties = additionalProperties |
| 216 | + } |
| 217 | + |
| 218 | + if hasInvalidField { |
| 219 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 220 | + } |
| 221 | + |
| 222 | + return nil |
| 223 | +} |
0 commit comments