Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6611,6 +6611,7 @@ components:
- Select value from matching element
- Compute array length
- Append a value to an array
- Extract key-value pairs from an array
properties:
is_enabled:
default: false
Expand All @@ -6633,6 +6634,7 @@ components:
- $ref: "#/components/schemas/LogsArrayProcessorOperationAppend"
- $ref: "#/components/schemas/LogsArrayProcessorOperationLength"
- $ref: "#/components/schemas/LogsArrayProcessorOperationSelect"
- $ref: "#/components/schemas/LogsArrayProcessorOperationExtractKeyValue"
LogsArrayProcessorOperationAppend:
description: Operation that appends a value to a target array attribute.
properties:
Expand Down Expand Up @@ -6662,6 +6664,44 @@ components:
type: string
x-enum-varnames:
- APPEND
LogsArrayProcessorOperationExtractKeyValue:
description: Operation that extracts key-value pairs from a `source` array and stores the result in the `target` attribute.
properties:
key_to_extract:
description: Key of the attribute in each array element that holds the name to use for the extracted attribute.
example: name
type: string
override_on_conflict:
default: false
description: Whether to override the target element if it's already set.
type: boolean
source:
description: Attribute path of the array to extract key-value pairs from.
example: tags
type: string
target:
description: Attribute that receives the extracted key-value pairs. If not specified, the extracted attributes are added at the root level of the log.
example: extracted
type: string
type:
$ref: "#/components/schemas/LogsArrayProcessorOperationExtractKeyValueType"
value_to_extract:
description: Key of the attribute in each array element that holds the value to use for the extracted attribute.
example: value
type: string
required:
- type
- source
- key_to_extract
- value_to_extract
type: object
LogsArrayProcessorOperationExtractKeyValueType:
description: Operation type.
enum: [key-value]
example: key-value
type: string
x-enum-varnames:
- KEY_VALUE
LogsArrayProcessorOperationLength:
description: Operation that computes the length of a `source` array and stores the result in the `target` attribute.
properties:
Expand Down Expand Up @@ -6746,7 +6786,7 @@ components:
type: string
override_on_conflict:
default: false
description: Override or not the target element if already set,
description: Whether to override the target element if it's already set.
type: boolean
preserve_source:
default: false
Expand Down Expand Up @@ -7912,7 +7952,7 @@ components:
type: string
override_on_conflict:
default: false
description: Override or not the target element if already set.
description: Whether to override the target element if it's already set.
type: boolean
preserve_source:
default: false
Expand Down
1 change: 1 addition & 0 deletions api/datadogV1/model_logs_array_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
// - Select value from matching element
// - Compute array length
// - Append a value to an array
// - Extract key-value pairs from an array
type LogsArrayProcessor struct {
// Whether or not the processor is enabled.
IsEnabled *bool `json:"is_enabled,omitempty"`
Expand Down
38 changes: 35 additions & 3 deletions api/datadogV1/model_logs_array_processor_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (

// LogsArrayProcessorOperation - Configuration of the array processor operation to perform.
type LogsArrayProcessorOperation struct {
LogsArrayProcessorOperationAppend *LogsArrayProcessorOperationAppend
LogsArrayProcessorOperationLength *LogsArrayProcessorOperationLength
LogsArrayProcessorOperationSelect *LogsArrayProcessorOperationSelect
LogsArrayProcessorOperationAppend *LogsArrayProcessorOperationAppend
LogsArrayProcessorOperationLength *LogsArrayProcessorOperationLength
LogsArrayProcessorOperationSelect *LogsArrayProcessorOperationSelect
LogsArrayProcessorOperationExtractKeyValue *LogsArrayProcessorOperationExtractKeyValue

// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject interface{}
Expand All @@ -33,6 +34,11 @@ func LogsArrayProcessorOperationSelectAsLogsArrayProcessorOperation(v *LogsArray
return LogsArrayProcessorOperation{LogsArrayProcessorOperationSelect: v}
}

// LogsArrayProcessorOperationExtractKeyValueAsLogsArrayProcessorOperation is a convenience function that returns LogsArrayProcessorOperationExtractKeyValue wrapped in LogsArrayProcessorOperation.
func LogsArrayProcessorOperationExtractKeyValueAsLogsArrayProcessorOperation(v *LogsArrayProcessorOperationExtractKeyValue) LogsArrayProcessorOperation {
return LogsArrayProcessorOperation{LogsArrayProcessorOperationExtractKeyValue: v}
}

// UnmarshalJSON turns data into one of the pointers in the struct.
func (obj *LogsArrayProcessorOperation) UnmarshalJSON(data []byte) error {
var err error
Expand Down Expand Up @@ -88,11 +94,29 @@ func (obj *LogsArrayProcessorOperation) UnmarshalJSON(data []byte) error {
obj.LogsArrayProcessorOperationSelect = nil
}

// try to unmarshal data into LogsArrayProcessorOperationExtractKeyValue
err = datadog.Unmarshal(data, &obj.LogsArrayProcessorOperationExtractKeyValue)
if err == nil {
if obj.LogsArrayProcessorOperationExtractKeyValue != nil && obj.LogsArrayProcessorOperationExtractKeyValue.UnparsedObject == nil {
jsonLogsArrayProcessorOperationExtractKeyValue, _ := datadog.Marshal(obj.LogsArrayProcessorOperationExtractKeyValue)
if string(jsonLogsArrayProcessorOperationExtractKeyValue) == "{}" { // empty struct
obj.LogsArrayProcessorOperationExtractKeyValue = nil
} else {
match++
}
} else {
obj.LogsArrayProcessorOperationExtractKeyValue = nil
}
} else {
obj.LogsArrayProcessorOperationExtractKeyValue = nil
}

if match != 1 { // more than 1 match
// reset to nil
obj.LogsArrayProcessorOperationAppend = nil
obj.LogsArrayProcessorOperationLength = nil
obj.LogsArrayProcessorOperationSelect = nil
obj.LogsArrayProcessorOperationExtractKeyValue = nil
return datadog.Unmarshal(data, &obj.UnparsedObject)
}
return nil // exactly one match
Expand All @@ -112,6 +136,10 @@ func (obj LogsArrayProcessorOperation) MarshalJSON() ([]byte, error) {
return datadog.Marshal(&obj.LogsArrayProcessorOperationSelect)
}

if obj.LogsArrayProcessorOperationExtractKeyValue != nil {
return datadog.Marshal(&obj.LogsArrayProcessorOperationExtractKeyValue)
}

if obj.UnparsedObject != nil {
return datadog.Marshal(obj.UnparsedObject)
}
Expand All @@ -132,6 +160,10 @@ func (obj *LogsArrayProcessorOperation) GetActualInstance() interface{} {
return obj.LogsArrayProcessorOperationSelect
}

if obj.LogsArrayProcessorOperationExtractKeyValue != nil {
return obj.LogsArrayProcessorOperationExtractKeyValue
}

// all schemas are nil
return nil
}
Loading
Loading