Skip to content

Commit 17afb54

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Regenerate client from commit 534cb46 of spec repo (#4111)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent d4b8797 commit 17afb54

14 files changed

Lines changed: 744 additions & 9 deletions

.generator/schemas/v1/openapi.yaml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6611,6 +6611,7 @@ components:
66116611
- Select value from matching element
66126612
- Compute array length
66136613
- Append a value to an array
6614+
- Extract key-value pairs from an array
66146615
properties:
66156616
is_enabled:
66166617
default: false
@@ -6633,6 +6634,7 @@ components:
66336634
- $ref: "#/components/schemas/LogsArrayProcessorOperationAppend"
66346635
- $ref: "#/components/schemas/LogsArrayProcessorOperationLength"
66356636
- $ref: "#/components/schemas/LogsArrayProcessorOperationSelect"
6637+
- $ref: "#/components/schemas/LogsArrayProcessorOperationExtractKeyValue"
66366638
LogsArrayProcessorOperationAppend:
66376639
description: Operation that appends a value to a target array attribute.
66386640
properties:
@@ -6662,6 +6664,44 @@ components:
66626664
type: string
66636665
x-enum-varnames:
66646666
- APPEND
6667+
LogsArrayProcessorOperationExtractKeyValue:
6668+
description: Operation that extracts key-value pairs from a `source` array and stores the result in the `target` attribute.
6669+
properties:
6670+
key_to_extract:
6671+
description: Key of the attribute in each array element that holds the name to use for the extracted attribute.
6672+
example: name
6673+
type: string
6674+
override_on_conflict:
6675+
default: false
6676+
description: Whether to override the target element if it's already set.
6677+
type: boolean
6678+
source:
6679+
description: Attribute path of the array to extract key-value pairs from.
6680+
example: tags
6681+
type: string
6682+
target:
6683+
description: Attribute that receives the extracted key-value pairs. If not specified, the extracted attributes are added at the root level of the log.
6684+
example: extracted
6685+
type: string
6686+
type:
6687+
$ref: "#/components/schemas/LogsArrayProcessorOperationExtractKeyValueType"
6688+
value_to_extract:
6689+
description: Key of the attribute in each array element that holds the value to use for the extracted attribute.
6690+
example: value
6691+
type: string
6692+
required:
6693+
- type
6694+
- source
6695+
- key_to_extract
6696+
- value_to_extract
6697+
type: object
6698+
LogsArrayProcessorOperationExtractKeyValueType:
6699+
description: Operation type.
6700+
enum: [key-value]
6701+
example: key-value
6702+
type: string
6703+
x-enum-varnames:
6704+
- KEY_VALUE
66656705
LogsArrayProcessorOperationLength:
66666706
description: Operation that computes the length of a `source` array and stores the result in the `target` attribute.
66676707
properties:
@@ -6746,7 +6786,7 @@ components:
67466786
type: string
67476787
override_on_conflict:
67486788
default: false
6749-
description: Override or not the target element if already set,
6789+
description: Whether to override the target element if it's already set.
67506790
type: boolean
67516791
preserve_source:
67526792
default: false
@@ -7912,7 +7952,7 @@ components:
79127952
type: string
79137953
override_on_conflict:
79147954
default: false
7915-
description: Override or not the target element if already set.
7955+
description: Whether to override the target element if it's already set.
79167956
type: boolean
79177957
preserve_source:
79187958
default: false
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Create a pipeline with Array Processor Key Value Operation returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v1.api.LogsPipelinesApi;
6+
import com.datadog.api.client.v1.model.LogsArrayProcessor;
7+
import com.datadog.api.client.v1.model.LogsArrayProcessorOperation;
8+
import com.datadog.api.client.v1.model.LogsArrayProcessorOperationExtractKeyValue;
9+
import com.datadog.api.client.v1.model.LogsArrayProcessorOperationExtractKeyValueType;
10+
import com.datadog.api.client.v1.model.LogsArrayProcessorType;
11+
import com.datadog.api.client.v1.model.LogsFilter;
12+
import com.datadog.api.client.v1.model.LogsPipeline;
13+
import com.datadog.api.client.v1.model.LogsProcessor;
14+
import java.util.Collections;
15+
16+
public class Example {
17+
public static void main(String[] args) {
18+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
19+
LogsPipelinesApi apiInstance = new LogsPipelinesApi(defaultClient);
20+
21+
LogsPipeline body =
22+
new LogsPipeline()
23+
.filter(new LogsFilter().query("source:python"))
24+
.name("testPipelineArrayKeyValue")
25+
.processors(
26+
Collections.singletonList(
27+
new LogsProcessor(
28+
new LogsArrayProcessor()
29+
.type(LogsArrayProcessorType.ARRAY_PROCESSOR)
30+
.isEnabled(true)
31+
.name("extract_kv")
32+
.operation(
33+
new LogsArrayProcessorOperation(
34+
new LogsArrayProcessorOperationExtractKeyValue()
35+
.type(
36+
LogsArrayProcessorOperationExtractKeyValueType
37+
.KEY_VALUE)
38+
.source("tags")
39+
.keyToExtract("name")
40+
.valueToExtract("value"))))));
41+
42+
try {
43+
LogsPipeline result = apiInstance.createLogsPipeline(body);
44+
System.out.println(result);
45+
} catch (ApiException e) {
46+
System.err.println("Exception when calling LogsPipelinesApi#createLogsPipeline");
47+
System.err.println("Status code: " + e.getCode());
48+
System.err.println("Reason: " + e.getResponseBody());
49+
System.err.println("Response headers: " + e.getResponseHeaders());
50+
e.printStackTrace();
51+
}
52+
}
53+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Create a pipeline with Array Processor Key Value Operation with target and override_on_conflict
2+
// returns "OK" response
3+
4+
import com.datadog.api.client.ApiClient;
5+
import com.datadog.api.client.ApiException;
6+
import com.datadog.api.client.v1.api.LogsPipelinesApi;
7+
import com.datadog.api.client.v1.model.LogsArrayProcessor;
8+
import com.datadog.api.client.v1.model.LogsArrayProcessorOperation;
9+
import com.datadog.api.client.v1.model.LogsArrayProcessorOperationExtractKeyValue;
10+
import com.datadog.api.client.v1.model.LogsArrayProcessorOperationExtractKeyValueType;
11+
import com.datadog.api.client.v1.model.LogsArrayProcessorType;
12+
import com.datadog.api.client.v1.model.LogsFilter;
13+
import com.datadog.api.client.v1.model.LogsPipeline;
14+
import com.datadog.api.client.v1.model.LogsProcessor;
15+
import java.util.Collections;
16+
17+
public class Example {
18+
public static void main(String[] args) {
19+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
20+
LogsPipelinesApi apiInstance = new LogsPipelinesApi(defaultClient);
21+
22+
LogsPipeline body =
23+
new LogsPipeline()
24+
.filter(new LogsFilter().query("source:python"))
25+
.name("testPipelineArrayKeyValueTarget")
26+
.processors(
27+
Collections.singletonList(
28+
new LogsProcessor(
29+
new LogsArrayProcessor()
30+
.type(LogsArrayProcessorType.ARRAY_PROCESSOR)
31+
.isEnabled(true)
32+
.name("extract_kv_to_target")
33+
.operation(
34+
new LogsArrayProcessorOperation(
35+
new LogsArrayProcessorOperationExtractKeyValue()
36+
.type(
37+
LogsArrayProcessorOperationExtractKeyValueType
38+
.KEY_VALUE)
39+
.source("tags")
40+
.keyToExtract("name")
41+
.valueToExtract("value")
42+
.target("extracted")
43+
.overrideOnConflict(true))))));
44+
45+
try {
46+
LogsPipeline result = apiInstance.createLogsPipeline(body);
47+
System.out.println(result);
48+
} catch (ApiException e) {
49+
System.err.println("Exception when calling LogsPipelinesApi#createLogsPipeline");
50+
System.err.println("Status code: " + e.getCode());
51+
System.err.println("Reason: " + e.getResponseBody());
52+
System.err.println("Response headers: " + e.getResponseHeaders());
53+
e.printStackTrace();
54+
}
55+
}
56+
}

src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* A processor for extracting, aggregating, or transforming values from JSON arrays within your
2222
* logs. Supported operations are: - Select value from matching element - Compute array length -
23-
* Append a value to an array
23+
* Append a value to an array - Extract key-value pairs from an array
2424
*/
2525
@JsonPropertyOrder({
2626
LogsArrayProcessor.JSON_PROPERTY_IS_ENABLED,

src/main/java/com/datadog/api/client/v1/model/LogsArrayProcessorOperation.java

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,58 @@ public LogsArrayProcessorOperation deserialize(JsonParser jp, DeserializationCon
218218
Level.FINER, "Input data does not match schema 'LogsArrayProcessorOperationSelect'", e);
219219
}
220220

221+
// deserialize LogsArrayProcessorOperationExtractKeyValue
222+
try {
223+
boolean attemptParsing = true;
224+
// ensure that we respect type coercion as set on the client ObjectMapper
225+
if (LogsArrayProcessorOperationExtractKeyValue.class.equals(Integer.class)
226+
|| LogsArrayProcessorOperationExtractKeyValue.class.equals(Long.class)
227+
|| LogsArrayProcessorOperationExtractKeyValue.class.equals(Float.class)
228+
|| LogsArrayProcessorOperationExtractKeyValue.class.equals(Double.class)
229+
|| LogsArrayProcessorOperationExtractKeyValue.class.equals(Boolean.class)
230+
|| LogsArrayProcessorOperationExtractKeyValue.class.equals(String.class)) {
231+
attemptParsing = typeCoercion;
232+
if (!attemptParsing) {
233+
attemptParsing |=
234+
((LogsArrayProcessorOperationExtractKeyValue.class.equals(Integer.class)
235+
|| LogsArrayProcessorOperationExtractKeyValue.class.equals(Long.class))
236+
&& token == JsonToken.VALUE_NUMBER_INT);
237+
attemptParsing |=
238+
((LogsArrayProcessorOperationExtractKeyValue.class.equals(Float.class)
239+
|| LogsArrayProcessorOperationExtractKeyValue.class.equals(Double.class))
240+
&& (token == JsonToken.VALUE_NUMBER_FLOAT
241+
|| token == JsonToken.VALUE_NUMBER_INT));
242+
attemptParsing |=
243+
(LogsArrayProcessorOperationExtractKeyValue.class.equals(Boolean.class)
244+
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
245+
attemptParsing |=
246+
(LogsArrayProcessorOperationExtractKeyValue.class.equals(String.class)
247+
&& token == JsonToken.VALUE_STRING);
248+
}
249+
}
250+
if (attemptParsing) {
251+
tmp =
252+
tree.traverse(jp.getCodec())
253+
.readValueAs(LogsArrayProcessorOperationExtractKeyValue.class);
254+
// TODO: there is no validation against JSON schema constraints
255+
// (min, max, enum, pattern...), this does not perform a strict JSON
256+
// validation, which means the 'match' count may be higher than it should be.
257+
if (!((LogsArrayProcessorOperationExtractKeyValue) tmp).unparsed) {
258+
deserialized = tmp;
259+
match++;
260+
}
261+
log.log(
262+
Level.FINER,
263+
"Input data matches schema 'LogsArrayProcessorOperationExtractKeyValue'");
264+
}
265+
} catch (Exception e) {
266+
// deserialization failed, continue
267+
log.log(
268+
Level.FINER,
269+
"Input data does not match schema 'LogsArrayProcessorOperationExtractKeyValue'",
270+
e);
271+
}
272+
221273
LogsArrayProcessorOperation ret = new LogsArrayProcessorOperation();
222274
if (match == 1) {
223275
ret.setActualInstance(deserialized);
@@ -263,6 +315,11 @@ public LogsArrayProcessorOperation(LogsArrayProcessorOperationSelect o) {
263315
setActualInstance(o);
264316
}
265317

318+
public LogsArrayProcessorOperation(LogsArrayProcessorOperationExtractKeyValue o) {
319+
super("oneOf", Boolean.FALSE);
320+
setActualInstance(o);
321+
}
322+
266323
static {
267324
schemas.put(
268325
"LogsArrayProcessorOperationAppend",
@@ -273,6 +330,9 @@ public LogsArrayProcessorOperation(LogsArrayProcessorOperationSelect o) {
273330
schemas.put(
274331
"LogsArrayProcessorOperationSelect",
275332
new GenericType<LogsArrayProcessorOperationSelect>() {});
333+
schemas.put(
334+
"LogsArrayProcessorOperationExtractKeyValue",
335+
new GenericType<LogsArrayProcessorOperationExtractKeyValue>() {});
276336
JSON.registerDescendants(
277337
LogsArrayProcessorOperation.class, Collections.unmodifiableMap(schemas));
278338
}
@@ -285,7 +345,8 @@ public Map<String, GenericType> getSchemas() {
285345
/**
286346
* Set the instance that matches the oneOf child schema, check the instance parameter is valid
287347
* against the oneOf child schemas: LogsArrayProcessorOperationAppend,
288-
* LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect
348+
* LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect,
349+
* LogsArrayProcessorOperationExtractKeyValue
289350
*
290351
* <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
291352
* composed schema (allOf, anyOf, oneOf).
@@ -307,22 +368,30 @@ public void setActualInstance(Object instance) {
307368
super.setActualInstance(instance);
308369
return;
309370
}
371+
if (JSON.isInstanceOf(
372+
LogsArrayProcessorOperationExtractKeyValue.class, instance, new HashSet<Class<?>>())) {
373+
super.setActualInstance(instance);
374+
return;
375+
}
310376

311377
if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet<Class<?>>())) {
312378
super.setActualInstance(instance);
313379
return;
314380
}
315381
throw new RuntimeException(
316382
"Invalid instance type. Must be LogsArrayProcessorOperationAppend,"
317-
+ " LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect");
383+
+ " LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect,"
384+
+ " LogsArrayProcessorOperationExtractKeyValue");
318385
}
319386

320387
/**
321388
* Get the actual instance, which can be the following: LogsArrayProcessorOperationAppend,
322-
* LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect
389+
* LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect,
390+
* LogsArrayProcessorOperationExtractKeyValue
323391
*
324392
* @return The actual instance (LogsArrayProcessorOperationAppend,
325-
* LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect)
393+
* LogsArrayProcessorOperationLength, LogsArrayProcessorOperationSelect,
394+
* LogsArrayProcessorOperationExtractKeyValue)
326395
*/
327396
@Override
328397
public Object getActualInstance() {
@@ -364,4 +433,16 @@ public LogsArrayProcessorOperationSelect getLogsArrayProcessorOperationSelect()
364433
throws ClassCastException {
365434
return (LogsArrayProcessorOperationSelect) super.getActualInstance();
366435
}
436+
437+
/**
438+
* Get the actual instance of `LogsArrayProcessorOperationExtractKeyValue`. If the actual instance
439+
* is not `LogsArrayProcessorOperationExtractKeyValue`, the ClassCastException will be thrown.
440+
*
441+
* @return The actual instance of `LogsArrayProcessorOperationExtractKeyValue`
442+
* @throws ClassCastException if the instance is not `LogsArrayProcessorOperationExtractKeyValue`
443+
*/
444+
public LogsArrayProcessorOperationExtractKeyValue getLogsArrayProcessorOperationExtractKeyValue()
445+
throws ClassCastException {
446+
return (LogsArrayProcessorOperationExtractKeyValue) super.getActualInstance();
447+
}
367448
}

0 commit comments

Comments
 (0)