diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index b043de0e648..13b137f25f8 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -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 @@ -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: @@ -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: @@ -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 @@ -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 diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_2595757342.java b/examples/v1/logs-pipelines/CreateLogsPipeline_2595757342.java new file mode 100644 index 00000000000..5ea38c72b98 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_2595757342.java @@ -0,0 +1,53 @@ +// Create a pipeline with Array Processor Key Value Operation returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.LogsPipelinesApi; +import com.datadog.api.client.v1.model.LogsArrayProcessor; +import com.datadog.api.client.v1.model.LogsArrayProcessorOperation; +import com.datadog.api.client.v1.model.LogsArrayProcessorOperationExtractKeyValue; +import com.datadog.api.client.v1.model.LogsArrayProcessorOperationExtractKeyValueType; +import com.datadog.api.client.v1.model.LogsArrayProcessorType; +import com.datadog.api.client.v1.model.LogsFilter; +import com.datadog.api.client.v1.model.LogsPipeline; +import com.datadog.api.client.v1.model.LogsProcessor; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + LogsPipelinesApi apiInstance = new LogsPipelinesApi(defaultClient); + + LogsPipeline body = + new LogsPipeline() + .filter(new LogsFilter().query("source:python")) + .name("testPipelineArrayKeyValue") + .processors( + Collections.singletonList( + new LogsProcessor( + new LogsArrayProcessor() + .type(LogsArrayProcessorType.ARRAY_PROCESSOR) + .isEnabled(true) + .name("extract_kv") + .operation( + new LogsArrayProcessorOperation( + new LogsArrayProcessorOperationExtractKeyValue() + .type( + LogsArrayProcessorOperationExtractKeyValueType + .KEY_VALUE) + .source("tags") + .keyToExtract("name") + .valueToExtract("value")))))); + + try { + LogsPipeline result = apiInstance.createLogsPipeline(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling LogsPipelinesApi#createLogsPipeline"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_4041812833.java b/examples/v1/logs-pipelines/CreateLogsPipeline_4041812833.java new file mode 100644 index 00000000000..973a874fdf7 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_4041812833.java @@ -0,0 +1,56 @@ +// Create a pipeline with Array Processor Key Value Operation with target and override_on_conflict +// returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.LogsPipelinesApi; +import com.datadog.api.client.v1.model.LogsArrayProcessor; +import com.datadog.api.client.v1.model.LogsArrayProcessorOperation; +import com.datadog.api.client.v1.model.LogsArrayProcessorOperationExtractKeyValue; +import com.datadog.api.client.v1.model.LogsArrayProcessorOperationExtractKeyValueType; +import com.datadog.api.client.v1.model.LogsArrayProcessorType; +import com.datadog.api.client.v1.model.LogsFilter; +import com.datadog.api.client.v1.model.LogsPipeline; +import com.datadog.api.client.v1.model.LogsProcessor; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + LogsPipelinesApi apiInstance = new LogsPipelinesApi(defaultClient); + + LogsPipeline body = + new LogsPipeline() + .filter(new LogsFilter().query("source:python")) + .name("testPipelineArrayKeyValueTarget") + .processors( + Collections.singletonList( + new LogsProcessor( + new LogsArrayProcessor() + .type(LogsArrayProcessorType.ARRAY_PROCESSOR) + .isEnabled(true) + .name("extract_kv_to_target") + .operation( + new LogsArrayProcessorOperation( + new LogsArrayProcessorOperationExtractKeyValue() + .type( + LogsArrayProcessorOperationExtractKeyValueType + .KEY_VALUE) + .source("tags") + .keyToExtract("name") + .valueToExtract("value") + .target("extracted") + .overrideOnConflict(true)))))); + + try { + LogsPipeline result = apiInstance.createLogsPipeline(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling LogsPipelinesApi#createLogsPipeline"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessor.java b/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessor.java index 0cbfde4f5e5..dbf1bb33f29 100644 --- a/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessor.java +++ b/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessor.java @@ -20,7 +20,7 @@ /** * A processor for extracting, aggregating, or transforming values from JSON arrays within your * logs. Supported operations are: - Select value from matching element - Compute array length - - * Append a value to an array + * Append a value to an array - Extract key-value pairs from an array */ @JsonPropertyOrder({ LogsArrayProcessor.JSON_PROPERTY_IS_ENABLED, diff --git a/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperation.java b/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperation.java index 2fa1ae726f0..ba5ba63ea88 100644 --- a/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperation.java +++ b/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperation.java @@ -218,6 +218,58 @@ public LogsArrayProcessorOperation deserialize(JsonParser jp, DeserializationCon Level.FINER, "Input data does not match schema 'LogsArrayProcessorOperationSelect'", e); } + // deserialize LogsArrayProcessorOperationExtractKeyValue + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (LogsArrayProcessorOperationExtractKeyValue.class.equals(Integer.class) + || LogsArrayProcessorOperationExtractKeyValue.class.equals(Long.class) + || LogsArrayProcessorOperationExtractKeyValue.class.equals(Float.class) + || LogsArrayProcessorOperationExtractKeyValue.class.equals(Double.class) + || LogsArrayProcessorOperationExtractKeyValue.class.equals(Boolean.class) + || LogsArrayProcessorOperationExtractKeyValue.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((LogsArrayProcessorOperationExtractKeyValue.class.equals(Integer.class) + || LogsArrayProcessorOperationExtractKeyValue.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((LogsArrayProcessorOperationExtractKeyValue.class.equals(Float.class) + || LogsArrayProcessorOperationExtractKeyValue.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (LogsArrayProcessorOperationExtractKeyValue.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (LogsArrayProcessorOperationExtractKeyValue.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(LogsArrayProcessorOperationExtractKeyValue.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((LogsArrayProcessorOperationExtractKeyValue) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'LogsArrayProcessorOperationExtractKeyValue'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'LogsArrayProcessorOperationExtractKeyValue'", + e); + } + LogsArrayProcessorOperation ret = new LogsArrayProcessorOperation(); if (match == 1) { ret.setActualInstance(deserialized); @@ -263,6 +315,11 @@ public LogsArrayProcessorOperation(LogsArrayProcessorOperationSelect o) { setActualInstance(o); } + public LogsArrayProcessorOperation(LogsArrayProcessorOperationExtractKeyValue o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + static { schemas.put( "LogsArrayProcessorOperationAppend", @@ -273,6 +330,9 @@ public LogsArrayProcessorOperation(LogsArrayProcessorOperationSelect o) { schemas.put( "LogsArrayProcessorOperationSelect", new GenericType() {}); + schemas.put( + "LogsArrayProcessorOperationExtractKeyValue", + new GenericType() {}); JSON.registerDescendants( LogsArrayProcessorOperation.class, Collections.unmodifiableMap(schemas)); } @@ -285,7 +345,8 @@ public Map getSchemas() { /** * Set the instance that matches the oneOf child schema, check the instance parameter is valid * against the oneOf child schemas: LogsArrayProcessorOperationAppend, - * LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect + * LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect, + * LogsArrayProcessorOperationExtractKeyValue * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -307,6 +368,11 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf( + LogsArrayProcessorOperationExtractKeyValue.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { super.setActualInstance(instance); @@ -314,15 +380,18 @@ public void setActualInstance(Object instance) { } throw new RuntimeException( "Invalid instance type. Must be LogsArrayProcessorOperationAppend," - + " LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect"); + + " LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect," + + " LogsArrayProcessorOperationExtractKeyValue"); } /** * Get the actual instance, which can be the following: LogsArrayProcessorOperationAppend, - * LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect + * LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect, + * LogsArrayProcessorOperationExtractKeyValue * * @return The actual instance (LogsArrayProcessorOperationAppend, - * LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect) + * LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect, + * LogsArrayProcessorOperationExtractKeyValue) */ @Override public Object getActualInstance() { @@ -364,4 +433,16 @@ public LogsArrayProcessorOperationSelect getLogsArrayProcessorOperationSelect() throws ClassCastException { return (LogsArrayProcessorOperationSelect) super.getActualInstance(); } + + /** + * Get the actual instance of `LogsArrayProcessorOperationExtractKeyValue`. If the actual instance + * is not `LogsArrayProcessorOperationExtractKeyValue`, the ClassCastException will be thrown. + * + * @return The actual instance of `LogsArrayProcessorOperationExtractKeyValue` + * @throws ClassCastException if the instance is not `LogsArrayProcessorOperationExtractKeyValue` + */ + public LogsArrayProcessorOperationExtractKeyValue getLogsArrayProcessorOperationExtractKeyValue() + throws ClassCastException { + return (LogsArrayProcessorOperationExtractKeyValue) super.getActualInstance(); + } } diff --git a/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperationExtractKeyValue.java b/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperationExtractKeyValue.java new file mode 100644 index 00000000000..72c30cb82d8 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperationExtractKeyValue.java @@ -0,0 +1,311 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Operation that extracts key-value pairs from a source array and stores the result in + * the target attribute. + */ +@JsonPropertyOrder({ + LogsArrayProcessorOperationExtractKeyValue.JSON_PROPERTY_KEY_TO_EXTRACT, + LogsArrayProcessorOperationExtractKeyValue.JSON_PROPERTY_OVERRIDE_ON_CONFLICT, + LogsArrayProcessorOperationExtractKeyValue.JSON_PROPERTY_SOURCE, + LogsArrayProcessorOperationExtractKeyValue.JSON_PROPERTY_TARGET, + LogsArrayProcessorOperationExtractKeyValue.JSON_PROPERTY_TYPE, + LogsArrayProcessorOperationExtractKeyValue.JSON_PROPERTY_VALUE_TO_EXTRACT +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class LogsArrayProcessorOperationExtractKeyValue { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_KEY_TO_EXTRACT = "key_to_extract"; + private String keyToExtract; + + public static final String JSON_PROPERTY_OVERRIDE_ON_CONFLICT = "override_on_conflict"; + private Boolean overrideOnConflict = false; + + public static final String JSON_PROPERTY_SOURCE = "source"; + private String source; + + public static final String JSON_PROPERTY_TARGET = "target"; + private String target; + + public static final String JSON_PROPERTY_TYPE = "type"; + private LogsArrayProcessorOperationExtractKeyValueType type; + + public static final String JSON_PROPERTY_VALUE_TO_EXTRACT = "value_to_extract"; + private String valueToExtract; + + public LogsArrayProcessorOperationExtractKeyValue() {} + + @JsonCreator + public LogsArrayProcessorOperationExtractKeyValue( + @JsonProperty(required = true, value = JSON_PROPERTY_KEY_TO_EXTRACT) String keyToExtract, + @JsonProperty(required = true, value = JSON_PROPERTY_SOURCE) String source, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + LogsArrayProcessorOperationExtractKeyValueType type, + @JsonProperty(required = true, value = JSON_PROPERTY_VALUE_TO_EXTRACT) + String valueToExtract) { + this.keyToExtract = keyToExtract; + this.source = source; + this.type = type; + this.unparsed |= !type.isValid(); + this.valueToExtract = valueToExtract; + } + + public LogsArrayProcessorOperationExtractKeyValue keyToExtract(String keyToExtract) { + this.keyToExtract = keyToExtract; + return this; + } + + /** + * Key of the attribute in each array element that holds the name to use for the extracted + * attribute. + * + * @return keyToExtract + */ + @JsonProperty(JSON_PROPERTY_KEY_TO_EXTRACT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getKeyToExtract() { + return keyToExtract; + } + + public void setKeyToExtract(String keyToExtract) { + this.keyToExtract = keyToExtract; + } + + public LogsArrayProcessorOperationExtractKeyValue overrideOnConflict(Boolean overrideOnConflict) { + this.overrideOnConflict = overrideOnConflict; + return this; + } + + /** + * Whether to override the target element if it's already set. + * + * @return overrideOnConflict + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OVERRIDE_ON_CONFLICT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getOverrideOnConflict() { + return overrideOnConflict; + } + + public void setOverrideOnConflict(Boolean overrideOnConflict) { + this.overrideOnConflict = overrideOnConflict; + } + + public LogsArrayProcessorOperationExtractKeyValue source(String source) { + this.source = source; + return this; + } + + /** + * Attribute path of the array to extract key-value pairs from. + * + * @return source + */ + @JsonProperty(JSON_PROPERTY_SOURCE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public LogsArrayProcessorOperationExtractKeyValue target(String target) { + this.target = target; + return this; + } + + /** + * Attribute that receives the extracted key-value pairs. If not specified, the extracted + * attributes are added at the root level of the log. + * + * @return target + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TARGET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public LogsArrayProcessorOperationExtractKeyValue type( + LogsArrayProcessorOperationExtractKeyValueType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Operation type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public LogsArrayProcessorOperationExtractKeyValueType getType() { + return type; + } + + public void setType(LogsArrayProcessorOperationExtractKeyValueType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + public LogsArrayProcessorOperationExtractKeyValue valueToExtract(String valueToExtract) { + this.valueToExtract = valueToExtract; + return this; + } + + /** + * Key of the attribute in each array element that holds the value to use for the extracted + * attribute. + * + * @return valueToExtract + */ + @JsonProperty(JSON_PROPERTY_VALUE_TO_EXTRACT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getValueToExtract() { + return valueToExtract; + } + + public void setValueToExtract(String valueToExtract) { + this.valueToExtract = valueToExtract; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return LogsArrayProcessorOperationExtractKeyValue + */ + @JsonAnySetter + public LogsArrayProcessorOperationExtractKeyValue putAdditionalProperty( + String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this LogsArrayProcessorOperationExtractKeyValue object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogsArrayProcessorOperationExtractKeyValue logsArrayProcessorOperationExtractKeyValue = + (LogsArrayProcessorOperationExtractKeyValue) o; + return Objects.equals( + this.keyToExtract, logsArrayProcessorOperationExtractKeyValue.keyToExtract) + && Objects.equals( + this.overrideOnConflict, logsArrayProcessorOperationExtractKeyValue.overrideOnConflict) + && Objects.equals(this.source, logsArrayProcessorOperationExtractKeyValue.source) + && Objects.equals(this.target, logsArrayProcessorOperationExtractKeyValue.target) + && Objects.equals(this.type, logsArrayProcessorOperationExtractKeyValue.type) + && Objects.equals( + this.valueToExtract, logsArrayProcessorOperationExtractKeyValue.valueToExtract) + && Objects.equals( + this.additionalProperties, + logsArrayProcessorOperationExtractKeyValue.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + keyToExtract, + overrideOnConflict, + source, + target, + type, + valueToExtract, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LogsArrayProcessorOperationExtractKeyValue {\n"); + sb.append(" keyToExtract: ").append(toIndentedString(keyToExtract)).append("\n"); + sb.append(" overrideOnConflict: ").append(toIndentedString(overrideOnConflict)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" target: ").append(toIndentedString(target)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" valueToExtract: ").append(toIndentedString(valueToExtract)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperationExtractKeyValueType.java b/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperationExtractKeyValueType.java new file mode 100644 index 00000000000..d5ef8b6f6db --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperationExtractKeyValueType.java @@ -0,0 +1,62 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Operation type. */ +@JsonSerialize( + using = + LogsArrayProcessorOperationExtractKeyValueType + .LogsArrayProcessorOperationExtractKeyValueTypeSerializer.class) +public class LogsArrayProcessorOperationExtractKeyValueType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("key-value")); + + public static final LogsArrayProcessorOperationExtractKeyValueType KEY_VALUE = + new LogsArrayProcessorOperationExtractKeyValueType("key-value"); + + LogsArrayProcessorOperationExtractKeyValueType(String value) { + super(value, allowedValues); + } + + public static class LogsArrayProcessorOperationExtractKeyValueTypeSerializer + extends StdSerializer { + public LogsArrayProcessorOperationExtractKeyValueTypeSerializer( + Class t) { + super(t); + } + + public LogsArrayProcessorOperationExtractKeyValueTypeSerializer() { + this(null); + } + + @Override + public void serialize( + LogsArrayProcessorOperationExtractKeyValueType value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static LogsArrayProcessorOperationExtractKeyValueType fromValue(String value) { + return new LogsArrayProcessorOperationExtractKeyValueType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/LogsAttributeRemapper.java b/src/main/java/com/datadog/api/client/v1/model/LogsAttributeRemapper.java index 3aa854f9826..e6dc6ae5f24 100644 --- a/src/main/java/com/datadog/api/client/v1/model/LogsAttributeRemapper.java +++ b/src/main/java/com/datadog/api/client/v1/model/LogsAttributeRemapper.java @@ -133,7 +133,7 @@ public LogsAttributeRemapper overrideOnConflict(Boolean overrideOnConflict) { } /** - * Override or not the target element if already set, + * Whether to override the target element if it's already set. * * @return overrideOnConflict */ diff --git a/src/main/java/com/datadog/api/client/v1/model/LogsSchemaRemapper.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaRemapper.java index dfbe23723b0..4b13c4e4a63 100644 --- a/src/main/java/com/datadog/api/client/v1/model/LogsSchemaRemapper.java +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaRemapper.java @@ -95,7 +95,7 @@ public LogsSchemaRemapper overrideOnConflict(Boolean overrideOnConflict) { } /** - * Override or not the target element if already set. + * Whether to override the target element if it's already set. * * @return overrideOnConflict */ diff --git a/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_returns_OK_response.freeze new file mode 100644 index 00000000000..79a90597f73 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-07-22T18:27:14.576Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_returns_OK_response.json new file mode 100644 index 00000000000..4ed25ed95ba --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_returns_OK_response.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"filter\":{\"query\":\"source:python\"},\"name\":\"testPipelineArrayKeyValue\",\"processors\":[{\"is_enabled\":true,\"name\":\"extract_kv\",\"operation\":{\"key_to_extract\":\"name\",\"source\":\"tags\",\"type\":\"key-value\",\"value_to_extract\":\"value\"},\"type\":\"array-processor\"}],\"tags\":[]}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/logs/config/pipelines", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":\"KLmRE95XSCKQcsktzgs9eQ\",\"type\":\"pipeline\",\"name\":\"testPipelineArrayKeyValue\",\"is_enabled\":false,\"is_read_only\":false,\"filter\":{\"query\":\"source:python\"},\"processors\":[{\"name\":\"extract_kv\",\"is_enabled\":true,\"operation\":{\"source\":\"tags\",\"key_to_extract\":\"name\",\"value_to_extract\":\"value\",\"override_on_conflict\":false,\"type\":\"key-value\"},\"type\":\"array-processor\"}],\"tags\":[]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "91c12ee8-8103-b3d0-e54e-5a16e0bd2ab9" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/logs/config/pipelines/KLmRE95XSCKQcsktzgs9eQ", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "86336c64-7ba9-5680-d116-b6e8d59f318d" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_with_target_and_override_on_conflict_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_with_target_and_override_on_conflict_returns_OK_response.freeze new file mode 100644 index 00000000000..fe1037276ab --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_with_target_and_override_on_conflict_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-07-22T18:27:15.202Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_with_target_and_override_on_conflict_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_with_target_and_override_on_conflict_returns_OK_response.json new file mode 100644 index 00000000000..15fcbf0adf9 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Array_Processor_Key_Value_Operation_with_target_and_override_on_conflict_returns_OK_response.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"filter\":{\"query\":\"source:python\"},\"name\":\"testPipelineArrayKeyValueTarget\",\"processors\":[{\"is_enabled\":true,\"name\":\"extract_kv_to_target\",\"operation\":{\"key_to_extract\":\"name\",\"override_on_conflict\":true,\"source\":\"tags\",\"target\":\"extracted\",\"type\":\"key-value\",\"value_to_extract\":\"value\"},\"type\":\"array-processor\"}],\"tags\":[]}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/logs/config/pipelines", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":\"LsxyDpcbTL6KztluS2oBYA\",\"type\":\"pipeline\",\"name\":\"testPipelineArrayKeyValueTarget\",\"is_enabled\":false,\"is_read_only\":false,\"filter\":{\"query\":\"source:python\"},\"processors\":[{\"name\":\"extract_kv_to_target\",\"is_enabled\":true,\"operation\":{\"source\":\"tags\",\"target\":\"extracted\",\"key_to_extract\":\"name\",\"value_to_extract\":\"value\",\"override_on_conflict\":true,\"type\":\"key-value\"},\"type\":\"array-processor\"}],\"tags\":[]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "8006e6f1-11dc-406b-021b-be08658f6562" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/logs/config/pipelines/LsxyDpcbTL6KztluS2oBYA", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "9fecd787-c0a1-eb02-22c4-750b3ed0218f" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v1/api/logs_pipelines.feature b/src/test/resources/com/datadog/api/client/v1/api/logs_pipelines.feature index ac28f052615..8b584949d9a 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/logs_pipelines.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/logs_pipelines.feature @@ -84,6 +84,20 @@ Feature: Logs Pipelines When the request is sent Then the response status is 200 OK + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Processor Key Value Operation returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayKeyValue", "processors": [{"type": "array-processor", "is_enabled": true, "name": "extract_kv", "operation": {"type": "key-value", "source": "tags", "key_to_extract": "name", "value_to_extract": "value"}}], "tags": []} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Processor Key Value Operation with target and override_on_conflict returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayKeyValueTarget", "processors": [{"type": "array-processor", "is_enabled": true, "name": "extract_kv_to_target", "operation": {"type": "key-value", "source": "tags", "key_to_extract": "name", "value_to_extract": "value", "target": "extracted", "override_on_conflict": true}}], "tags": []} + When the request is sent + Then the response status is 200 OK + @team:DataDog/logs-onboarding Scenario: Create a pipeline with Array Processor Length Operation returns "OK" response Given new "CreateLogsPipeline" request