diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index f731f36b794..a6ab1a8fefd 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -41365,6 +41365,7 @@ components: example: CloudTrail Account Change oneOf: - $ref: '#/components/schemas/ObservabilityPipelineOcsfMappingLibrary' + - $ref: '#/components/schemas/ObservabilityPipelineOcsfMappingCustom' ObservabilityPipelineOcsfMapperProcessorType: default: ocsf_mapper description: The processor type. The value should always be `ocsf_mapper`. @@ -41374,6 +41375,116 @@ components: type: string x-enum-varnames: - OCSF_MAPPER + ObservabilityPipelineOcsfMappingCustom: + description: Custom OCSF mapping configuration for transforming logs. + properties: + mapping: + description: A list of field mapping rules for transforming log fields to + OCSF schema fields. + items: + $ref: '#/components/schemas/ObservabilityPipelineOcsfMappingCustomFieldMapping' + type: array + metadata: + $ref: '#/components/schemas/ObservabilityPipelineOcsfMappingCustomMetadata' + version: + description: The version of the custom mapping configuration. + example: 1 + format: int64 + type: integer + required: + - mapping + - metadata + - version + type: object + ObservabilityPipelineOcsfMappingCustomFieldMapping: + description: Defines a single field mapping rule for transforming a source field + to an OCSF destination field. + properties: + default: + description: The default value to use if the source field is missing or + empty. + example: '' + dest: + description: The destination OCSF field path. + example: device.type + type: string + lookup: + $ref: '#/components/schemas/ObservabilityPipelineOcsfMappingCustomLookup' + source: + description: The source field path from the log event. + example: host.type + sources: + description: Multiple source field paths for combined mapping. + example: + - field1 + - field2 + value: + description: A static value to use for the destination field. + example: static_value + required: + - dest + type: object + ObservabilityPipelineOcsfMappingCustomLookup: + description: Lookup table configuration for mapping source values to destination + values. + properties: + default: + description: The default value to use if no lookup match is found. + example: unknown + table: + description: A list of lookup table entries for value transformation. + items: + $ref: '#/components/schemas/ObservabilityPipelineOcsfMappingCustomLookupTableEntry' + type: array + type: object + ObservabilityPipelineOcsfMappingCustomLookupTableEntry: + description: A single entry in a lookup table for value transformation. + properties: + contains: + description: The substring to match in the source value. + example: Desktop + type: string + equals: + description: The exact value to match in the source. + example: desktop + equals_source: + description: The source field to match against. + example: device_type + type: string + matches: + description: A regex pattern to match in the source value. + example: ^Desktop.* + type: string + not_matches: + description: A regex pattern that must not match the source value. + example: ^Mobile.* + type: string + value: + description: The value to use when a match is found. + example: desktop + type: object + ObservabilityPipelineOcsfMappingCustomMetadata: + description: Metadata for the custom OCSF mapping. + properties: + class: + description: The OCSF event class name. + example: Device Inventory Info + type: string + profiles: + description: A list of OCSF profiles to apply. + example: + - container + items: + type: string + type: array + version: + description: The OCSF schema version. + example: 1.3.0 + type: string + required: + - class + - version + type: object ObservabilityPipelineOcsfMappingLibrary: description: Predefined library mappings for common log formats. enum: diff --git a/examples/v2/observability-pipelines/ValidatePipeline_3024756866.java b/examples/v2/observability-pipelines/ValidatePipeline_3024756866.java new file mode 100644 index 00000000000..e798c055fef --- /dev/null +++ b/examples/v2/observability-pipelines/ValidatePipeline_3024756866.java @@ -0,0 +1,152 @@ +// Validate an observability pipeline with OCSF mapper custom mapping returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ObservabilityPipelinesApi; +import com.datadog.api.client.v2.model.ObservabilityPipelineConfig; +import com.datadog.api.client.v2.model.ObservabilityPipelineConfigDestinationItem; +import com.datadog.api.client.v2.model.ObservabilityPipelineConfigProcessorGroup; +import com.datadog.api.client.v2.model.ObservabilityPipelineConfigProcessorItem; +import com.datadog.api.client.v2.model.ObservabilityPipelineConfigSourceItem; +import com.datadog.api.client.v2.model.ObservabilityPipelineDataAttributes; +import com.datadog.api.client.v2.model.ObservabilityPipelineDatadogAgentSource; +import com.datadog.api.client.v2.model.ObservabilityPipelineDatadogAgentSourceType; +import com.datadog.api.client.v2.model.ObservabilityPipelineDatadogLogsDestination; +import com.datadog.api.client.v2.model.ObservabilityPipelineDatadogLogsDestinationType; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMapperProcessor; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMapperProcessorMapping; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMapperProcessorMappingMapping; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMapperProcessorType; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMappingCustom; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMappingCustomFieldMapping; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMappingCustomLookup; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMappingCustomLookupTableEntry; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMappingCustomMetadata; +import com.datadog.api.client.v2.model.ObservabilityPipelineSpec; +import com.datadog.api.client.v2.model.ObservabilityPipelineSpecData; +import com.datadog.api.client.v2.model.ValidationResponse; +import java.util.Arrays; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + ObservabilityPipelinesApi apiInstance = new ObservabilityPipelinesApi(defaultClient); + + ObservabilityPipelineSpec body = + new ObservabilityPipelineSpec() + .data( + new ObservabilityPipelineSpecData() + .attributes( + new ObservabilityPipelineDataAttributes() + .config( + new ObservabilityPipelineConfig() + .destinations( + Collections.singletonList( + new ObservabilityPipelineConfigDestinationItem( + new ObservabilityPipelineDatadogLogsDestination() + .id("datadog-logs-destination") + .inputs( + Collections.singletonList( + "my-processor-group")) + .type( + ObservabilityPipelineDatadogLogsDestinationType + .DATADOG_LOGS)))) + .processorGroups( + Collections.singletonList( + new ObservabilityPipelineConfigProcessorGroup() + .enabled(true) + .id("my-processor-group") + .include("service:my-service") + .inputs( + Collections.singletonList( + "datadog-agent-source")) + .processors( + Collections.singletonList( + new ObservabilityPipelineConfigProcessorItem( + new ObservabilityPipelineOcsfMapperProcessor() + .enabled(true) + .id("ocsf-mapper-processor") + .include("service:my-service") + .mappings( + Collections.singletonList( + new ObservabilityPipelineOcsfMapperProcessorMapping() + .include( + "source:custom") + .mapping( + new ObservabilityPipelineOcsfMapperProcessorMappingMapping( + new ObservabilityPipelineOcsfMappingCustom() + .mapping( + Arrays + .asList( + new ObservabilityPipelineOcsfMappingCustomFieldMapping() + ._default( + "") + .dest( + "time") + .source( + "timestamp"), + new ObservabilityPipelineOcsfMappingCustomFieldMapping() + ._default( + "") + .dest( + "severity") + .source( + "level"), + new ObservabilityPipelineOcsfMappingCustomFieldMapping() + ._default( + "") + .dest( + "device.type") + .lookup( + new ObservabilityPipelineOcsfMappingCustomLookup() + .table( + Collections + .singletonList( + new ObservabilityPipelineOcsfMappingCustomLookupTableEntry() + .contains( + "Desktop") + .value( + "desktop")))) + .source( + "host.type"))) + .metadata( + new ObservabilityPipelineOcsfMappingCustomMetadata() + ._class( + "Device" + + " Inventory" + + " Info") + .profiles( + Collections + .singletonList( + "container")) + .version( + "1.3.0")) + .version( + 1L))))) + .type( + ObservabilityPipelineOcsfMapperProcessorType + .OCSF_MAPPER)))))) + .sources( + Collections.singletonList( + new ObservabilityPipelineConfigSourceItem( + new ObservabilityPipelineDatadogAgentSource() + .id("datadog-agent-source") + .type( + ObservabilityPipelineDatadogAgentSourceType + .DATADOG_AGENT))))) + .name("OCSF Custom Mapper Pipeline")) + .type("pipelines")); + + try { + ValidationResponse result = apiInstance.validatePipeline(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ObservabilityPipelinesApi#validatePipeline"); + 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/v2/observability-pipelines/ValidatePipeline_3565101276.java b/examples/v2/observability-pipelines/ValidatePipeline_3565101276.java new file mode 100644 index 00000000000..02a8bf41d81 --- /dev/null +++ b/examples/v2/observability-pipelines/ValidatePipeline_3565101276.java @@ -0,0 +1,100 @@ +// Validate an observability pipeline with OCSF mapper library mapping returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ObservabilityPipelinesApi; +import com.datadog.api.client.v2.model.ObservabilityPipelineConfig; +import com.datadog.api.client.v2.model.ObservabilityPipelineConfigDestinationItem; +import com.datadog.api.client.v2.model.ObservabilityPipelineConfigProcessorGroup; +import com.datadog.api.client.v2.model.ObservabilityPipelineConfigProcessorItem; +import com.datadog.api.client.v2.model.ObservabilityPipelineConfigSourceItem; +import com.datadog.api.client.v2.model.ObservabilityPipelineDataAttributes; +import com.datadog.api.client.v2.model.ObservabilityPipelineDatadogAgentSource; +import com.datadog.api.client.v2.model.ObservabilityPipelineDatadogAgentSourceType; +import com.datadog.api.client.v2.model.ObservabilityPipelineDatadogLogsDestination; +import com.datadog.api.client.v2.model.ObservabilityPipelineDatadogLogsDestinationType; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMapperProcessor; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMapperProcessorMapping; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMapperProcessorMappingMapping; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMapperProcessorType; +import com.datadog.api.client.v2.model.ObservabilityPipelineOcsfMappingLibrary; +import com.datadog.api.client.v2.model.ObservabilityPipelineSpec; +import com.datadog.api.client.v2.model.ObservabilityPipelineSpecData; +import com.datadog.api.client.v2.model.ValidationResponse; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + ObservabilityPipelinesApi apiInstance = new ObservabilityPipelinesApi(defaultClient); + + ObservabilityPipelineSpec body = + new ObservabilityPipelineSpec() + .data( + new ObservabilityPipelineSpecData() + .attributes( + new ObservabilityPipelineDataAttributes() + .config( + new ObservabilityPipelineConfig() + .destinations( + Collections.singletonList( + new ObservabilityPipelineConfigDestinationItem( + new ObservabilityPipelineDatadogLogsDestination() + .id("datadog-logs-destination") + .inputs( + Collections.singletonList( + "my-processor-group")) + .type( + ObservabilityPipelineDatadogLogsDestinationType + .DATADOG_LOGS)))) + .processorGroups( + Collections.singletonList( + new ObservabilityPipelineConfigProcessorGroup() + .enabled(true) + .id("my-processor-group") + .include("service:my-service") + .inputs( + Collections.singletonList( + "datadog-agent-source")) + .processors( + Collections.singletonList( + new ObservabilityPipelineConfigProcessorItem( + new ObservabilityPipelineOcsfMapperProcessor() + .enabled(true) + .id("ocsf-mapper-processor") + .include("service:my-service") + .type( + ObservabilityPipelineOcsfMapperProcessorType + .OCSF_MAPPER) + .mappings( + Collections.singletonList( + new ObservabilityPipelineOcsfMapperProcessorMapping() + .include( + "source:cloudtrail") + .mapping( + new ObservabilityPipelineOcsfMapperProcessorMappingMapping( + ObservabilityPipelineOcsfMappingLibrary + .CLOUDTRAIL_ACCOUNT_CHANGE))))))))) + .sources( + Collections.singletonList( + new ObservabilityPipelineConfigSourceItem( + new ObservabilityPipelineDatadogAgentSource() + .id("datadog-agent-source") + .type( + ObservabilityPipelineDatadogAgentSourceType + .DATADOG_AGENT))))) + .name("OCSF Mapper Pipeline")) + .type("pipelines")); + + try { + ValidationResponse result = apiInstance.validatePipeline(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ObservabilityPipelinesApi#validatePipeline"); + 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/v2/model/ObservabilityPipelineOcsfMapperProcessorMappingMapping.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMapperProcessorMappingMapping.java index 437f7ca48ee..4b7e9947ab1 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMapperProcessorMappingMapping.java +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMapperProcessorMappingMapping.java @@ -140,6 +140,57 @@ public ObservabilityPipelineOcsfMapperProcessorMappingMapping deserialize( e); } + // deserialize ObservabilityPipelineOcsfMappingCustom + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ObservabilityPipelineOcsfMappingCustom.class.equals(Integer.class) + || ObservabilityPipelineOcsfMappingCustom.class.equals(Long.class) + || ObservabilityPipelineOcsfMappingCustom.class.equals(Float.class) + || ObservabilityPipelineOcsfMappingCustom.class.equals(Double.class) + || ObservabilityPipelineOcsfMappingCustom.class.equals(Boolean.class) + || ObservabilityPipelineOcsfMappingCustom.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ObservabilityPipelineOcsfMappingCustom.class.equals(Integer.class) + || ObservabilityPipelineOcsfMappingCustom.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ObservabilityPipelineOcsfMappingCustom.class.equals(Float.class) + || ObservabilityPipelineOcsfMappingCustom.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ObservabilityPipelineOcsfMappingCustom.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ObservabilityPipelineOcsfMappingCustom.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ObservabilityPipelineOcsfMappingCustom.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 (!((ObservabilityPipelineOcsfMappingCustom) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, "Input data matches schema 'ObservabilityPipelineOcsfMappingCustom'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ObservabilityPipelineOcsfMappingCustom'", + e); + } + ObservabilityPipelineOcsfMapperProcessorMappingMapping ret = new ObservabilityPipelineOcsfMapperProcessorMappingMapping(); if (match == 1) { @@ -178,10 +229,19 @@ public ObservabilityPipelineOcsfMapperProcessorMappingMapping( setActualInstance(o); } + public ObservabilityPipelineOcsfMapperProcessorMappingMapping( + ObservabilityPipelineOcsfMappingCustom o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + static { schemas.put( "ObservabilityPipelineOcsfMappingLibrary", new GenericType() {}); + schemas.put( + "ObservabilityPipelineOcsfMappingCustom", + new GenericType() {}); JSON.registerDescendants( ObservabilityPipelineOcsfMapperProcessorMappingMapping.class, Collections.unmodifiableMap(schemas)); @@ -194,7 +254,8 @@ public Map getSchemas() { /** * Set the instance that matches the oneOf child schema, check the instance parameter is valid - * against the oneOf child schemas: ObservabilityPipelineOcsfMappingLibrary + * against the oneOf child schemas: ObservabilityPipelineOcsfMappingLibrary, + * ObservabilityPipelineOcsfMappingCustom * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -206,19 +267,27 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf( + ObservabilityPipelineOcsfMappingCustom.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } throw new RuntimeException( - "Invalid instance type. Must be ObservabilityPipelineOcsfMappingLibrary"); + "Invalid instance type. Must be ObservabilityPipelineOcsfMappingLibrary," + + " ObservabilityPipelineOcsfMappingCustom"); } /** - * Get the actual instance, which can be the following: ObservabilityPipelineOcsfMappingLibrary + * Get the actual instance, which can be the following: ObservabilityPipelineOcsfMappingLibrary, + * ObservabilityPipelineOcsfMappingCustom * - * @return The actual instance (ObservabilityPipelineOcsfMappingLibrary) + * @return The actual instance (ObservabilityPipelineOcsfMappingLibrary, + * ObservabilityPipelineOcsfMappingCustom) */ @Override public Object getActualInstance() { @@ -236,4 +305,16 @@ public ObservabilityPipelineOcsfMappingLibrary getObservabilityPipelineOcsfMappi throws ClassCastException { return (ObservabilityPipelineOcsfMappingLibrary) super.getActualInstance(); } + + /** + * Get the actual instance of `ObservabilityPipelineOcsfMappingCustom`. If the actual instance is + * not `ObservabilityPipelineOcsfMappingCustom`, the ClassCastException will be thrown. + * + * @return The actual instance of `ObservabilityPipelineOcsfMappingCustom` + * @throws ClassCastException if the instance is not `ObservabilityPipelineOcsfMappingCustom` + */ + public ObservabilityPipelineOcsfMappingCustom getObservabilityPipelineOcsfMappingCustom() + throws ClassCastException { + return (ObservabilityPipelineOcsfMappingCustom) super.getActualInstance(); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustom.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustom.java new file mode 100644 index 00000000000..c6643101861 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustom.java @@ -0,0 +1,221 @@ +/* + * 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.v2.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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Custom OCSF mapping configuration for transforming logs. */ +@JsonPropertyOrder({ + ObservabilityPipelineOcsfMappingCustom.JSON_PROPERTY_MAPPING, + ObservabilityPipelineOcsfMappingCustom.JSON_PROPERTY_METADATA, + ObservabilityPipelineOcsfMappingCustom.JSON_PROPERTY_VERSION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ObservabilityPipelineOcsfMappingCustom { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_MAPPING = "mapping"; + private List mapping = new ArrayList<>(); + + public static final String JSON_PROPERTY_METADATA = "metadata"; + private ObservabilityPipelineOcsfMappingCustomMetadata metadata; + + public static final String JSON_PROPERTY_VERSION = "version"; + private Long version; + + public ObservabilityPipelineOcsfMappingCustom() {} + + @JsonCreator + public ObservabilityPipelineOcsfMappingCustom( + @JsonProperty(required = true, value = JSON_PROPERTY_MAPPING) + List mapping, + @JsonProperty(required = true, value = JSON_PROPERTY_METADATA) + ObservabilityPipelineOcsfMappingCustomMetadata metadata, + @JsonProperty(required = true, value = JSON_PROPERTY_VERSION) Long version) { + this.mapping = mapping; + this.metadata = metadata; + this.unparsed |= metadata.unparsed; + this.version = version; + } + + public ObservabilityPipelineOcsfMappingCustom mapping( + List mapping) { + this.mapping = mapping; + for (ObservabilityPipelineOcsfMappingCustomFieldMapping item : mapping) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ObservabilityPipelineOcsfMappingCustom addMappingItem( + ObservabilityPipelineOcsfMappingCustomFieldMapping mappingItem) { + this.mapping.add(mappingItem); + this.unparsed |= mappingItem.unparsed; + return this; + } + + /** + * A list of field mapping rules for transforming log fields to OCSF schema fields. + * + * @return mapping + */ + @JsonProperty(JSON_PROPERTY_MAPPING) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getMapping() { + return mapping; + } + + public void setMapping(List mapping) { + this.mapping = mapping; + } + + public ObservabilityPipelineOcsfMappingCustom metadata( + ObservabilityPipelineOcsfMappingCustomMetadata metadata) { + this.metadata = metadata; + this.unparsed |= metadata.unparsed; + return this; + } + + /** + * Metadata for the custom OCSF mapping. + * + * @return metadata + */ + @JsonProperty(JSON_PROPERTY_METADATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ObservabilityPipelineOcsfMappingCustomMetadata getMetadata() { + return metadata; + } + + public void setMetadata(ObservabilityPipelineOcsfMappingCustomMetadata metadata) { + this.metadata = metadata; + } + + public ObservabilityPipelineOcsfMappingCustom version(Long version) { + this.version = version; + return this; + } + + /** + * The version of the custom mapping configuration. + * + * @return version + */ + @JsonProperty(JSON_PROPERTY_VERSION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getVersion() { + return version; + } + + public void setVersion(Long version) { + this.version = version; + } + + /** + * 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 ObservabilityPipelineOcsfMappingCustom + */ + @JsonAnySetter + public ObservabilityPipelineOcsfMappingCustom 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 ObservabilityPipelineOcsfMappingCustom object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObservabilityPipelineOcsfMappingCustom observabilityPipelineOcsfMappingCustom = + (ObservabilityPipelineOcsfMappingCustom) o; + return Objects.equals(this.mapping, observabilityPipelineOcsfMappingCustom.mapping) + && Objects.equals(this.metadata, observabilityPipelineOcsfMappingCustom.metadata) + && Objects.equals(this.version, observabilityPipelineOcsfMappingCustom.version) + && Objects.equals( + this.additionalProperties, observabilityPipelineOcsfMappingCustom.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(mapping, metadata, version, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObservabilityPipelineOcsfMappingCustom {\n"); + sb.append(" mapping: ").append(toIndentedString(mapping)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).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/v2/model/ObservabilityPipelineOcsfMappingCustomFieldMapping.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustomFieldMapping.java new file mode 100644 index 00000000000..75b70575156 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustomFieldMapping.java @@ -0,0 +1,292 @@ +/* + * 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.v2.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; + +/** + * Defines a single field mapping rule for transforming a source field to an OCSF destination field. + */ +@JsonPropertyOrder({ + ObservabilityPipelineOcsfMappingCustomFieldMapping.JSON_PROPERTY_DEFAULT, + ObservabilityPipelineOcsfMappingCustomFieldMapping.JSON_PROPERTY_DEST, + ObservabilityPipelineOcsfMappingCustomFieldMapping.JSON_PROPERTY_LOOKUP, + ObservabilityPipelineOcsfMappingCustomFieldMapping.JSON_PROPERTY_SOURCE, + ObservabilityPipelineOcsfMappingCustomFieldMapping.JSON_PROPERTY_SOURCES, + ObservabilityPipelineOcsfMappingCustomFieldMapping.JSON_PROPERTY_VALUE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ObservabilityPipelineOcsfMappingCustomFieldMapping { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DEFAULT = "default"; + private Object _default = null; + + public static final String JSON_PROPERTY_DEST = "dest"; + private String dest; + + public static final String JSON_PROPERTY_LOOKUP = "lookup"; + private ObservabilityPipelineOcsfMappingCustomLookup lookup; + + public static final String JSON_PROPERTY_SOURCE = "source"; + private Object source = null; + + public static final String JSON_PROPERTY_SOURCES = "sources"; + private Object sources = null; + + public static final String JSON_PROPERTY_VALUE = "value"; + private Object value = null; + + public ObservabilityPipelineOcsfMappingCustomFieldMapping() {} + + @JsonCreator + public ObservabilityPipelineOcsfMappingCustomFieldMapping( + @JsonProperty(required = true, value = JSON_PROPERTY_DEST) String dest) { + this.dest = dest; + } + + public ObservabilityPipelineOcsfMappingCustomFieldMapping _default(Object _default) { + this._default = _default; + return this; + } + + /** + * The default value to use if the source field is missing or empty. + * + * @return _default + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getDefault() { + return _default; + } + + public void setDefault(Object _default) { + this._default = _default; + } + + public ObservabilityPipelineOcsfMappingCustomFieldMapping dest(String dest) { + this.dest = dest; + return this; + } + + /** + * The destination OCSF field path. + * + * @return dest + */ + @JsonProperty(JSON_PROPERTY_DEST) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getDest() { + return dest; + } + + public void setDest(String dest) { + this.dest = dest; + } + + public ObservabilityPipelineOcsfMappingCustomFieldMapping lookup( + ObservabilityPipelineOcsfMappingCustomLookup lookup) { + this.lookup = lookup; + this.unparsed |= lookup.unparsed; + return this; + } + + /** + * Lookup table configuration for mapping source values to destination values. + * + * @return lookup + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LOOKUP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ObservabilityPipelineOcsfMappingCustomLookup getLookup() { + return lookup; + } + + public void setLookup(ObservabilityPipelineOcsfMappingCustomLookup lookup) { + this.lookup = lookup; + } + + public ObservabilityPipelineOcsfMappingCustomFieldMapping source(Object source) { + this.source = source; + return this; + } + + /** + * The source field path from the log event. + * + * @return source + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SOURCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getSource() { + return source; + } + + public void setSource(Object source) { + this.source = source; + } + + public ObservabilityPipelineOcsfMappingCustomFieldMapping sources(Object sources) { + this.sources = sources; + return this; + } + + /** + * Multiple source field paths for combined mapping. + * + * @return sources + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SOURCES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getSources() { + return sources; + } + + public void setSources(Object sources) { + this.sources = sources; + } + + public ObservabilityPipelineOcsfMappingCustomFieldMapping value(Object value) { + this.value = value; + return this; + } + + /** + * A static value to use for the destination field. + * + * @return value + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + /** + * 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 ObservabilityPipelineOcsfMappingCustomFieldMapping + */ + @JsonAnySetter + public ObservabilityPipelineOcsfMappingCustomFieldMapping 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 ObservabilityPipelineOcsfMappingCustomFieldMapping object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObservabilityPipelineOcsfMappingCustomFieldMapping + observabilityPipelineOcsfMappingCustomFieldMapping = + (ObservabilityPipelineOcsfMappingCustomFieldMapping) o; + return Objects.equals( + this._default, observabilityPipelineOcsfMappingCustomFieldMapping._default) + && Objects.equals(this.dest, observabilityPipelineOcsfMappingCustomFieldMapping.dest) + && Objects.equals(this.lookup, observabilityPipelineOcsfMappingCustomFieldMapping.lookup) + && Objects.equals(this.source, observabilityPipelineOcsfMappingCustomFieldMapping.source) + && Objects.equals(this.sources, observabilityPipelineOcsfMappingCustomFieldMapping.sources) + && Objects.equals(this.value, observabilityPipelineOcsfMappingCustomFieldMapping.value) + && Objects.equals( + this.additionalProperties, + observabilityPipelineOcsfMappingCustomFieldMapping.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(_default, dest, lookup, source, sources, value, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObservabilityPipelineOcsfMappingCustomFieldMapping {\n"); + sb.append(" _default: ").append(toIndentedString(_default)).append("\n"); + sb.append(" dest: ").append(toIndentedString(dest)).append("\n"); + sb.append(" lookup: ").append(toIndentedString(lookup)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" sources: ").append(toIndentedString(sources)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).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/v2/model/ObservabilityPipelineOcsfMappingCustomLookup.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustomLookup.java new file mode 100644 index 00000000000..be221db4e74 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustomLookup.java @@ -0,0 +1,184 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Lookup table configuration for mapping source values to destination values. */ +@JsonPropertyOrder({ + ObservabilityPipelineOcsfMappingCustomLookup.JSON_PROPERTY_DEFAULT, + ObservabilityPipelineOcsfMappingCustomLookup.JSON_PROPERTY_TABLE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ObservabilityPipelineOcsfMappingCustomLookup { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DEFAULT = "default"; + private Object _default = null; + + public static final String JSON_PROPERTY_TABLE = "table"; + private List table = null; + + public ObservabilityPipelineOcsfMappingCustomLookup _default(Object _default) { + this._default = _default; + return this; + } + + /** + * The default value to use if no lookup match is found. + * + * @return _default + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getDefault() { + return _default; + } + + public void setDefault(Object _default) { + this._default = _default; + } + + public ObservabilityPipelineOcsfMappingCustomLookup table( + List table) { + this.table = table; + for (ObservabilityPipelineOcsfMappingCustomLookupTableEntry item : table) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ObservabilityPipelineOcsfMappingCustomLookup addTableItem( + ObservabilityPipelineOcsfMappingCustomLookupTableEntry tableItem) { + if (this.table == null) { + this.table = new ArrayList<>(); + } + this.table.add(tableItem); + this.unparsed |= tableItem.unparsed; + return this; + } + + /** + * A list of lookup table entries for value transformation. + * + * @return table + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TABLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTable() { + return table; + } + + public void setTable(List table) { + this.table = table; + } + + /** + * 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 ObservabilityPipelineOcsfMappingCustomLookup + */ + @JsonAnySetter + public ObservabilityPipelineOcsfMappingCustomLookup 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 ObservabilityPipelineOcsfMappingCustomLookup object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObservabilityPipelineOcsfMappingCustomLookup observabilityPipelineOcsfMappingCustomLookup = + (ObservabilityPipelineOcsfMappingCustomLookup) o; + return Objects.equals(this._default, observabilityPipelineOcsfMappingCustomLookup._default) + && Objects.equals(this.table, observabilityPipelineOcsfMappingCustomLookup.table) + && Objects.equals( + this.additionalProperties, + observabilityPipelineOcsfMappingCustomLookup.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(_default, table, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObservabilityPipelineOcsfMappingCustomLookup {\n"); + sb.append(" _default: ").append(toIndentedString(_default)).append("\n"); + sb.append(" table: ").append(toIndentedString(table)).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/v2/model/ObservabilityPipelineOcsfMappingCustomLookupTableEntry.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustomLookupTableEntry.java new file mode 100644 index 00000000000..c0b8468b96c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustomLookupTableEntry.java @@ -0,0 +1,286 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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; + +/** A single entry in a lookup table for value transformation. */ +@JsonPropertyOrder({ + ObservabilityPipelineOcsfMappingCustomLookupTableEntry.JSON_PROPERTY_CONTAINS, + ObservabilityPipelineOcsfMappingCustomLookupTableEntry.JSON_PROPERTY_EQUALS, + ObservabilityPipelineOcsfMappingCustomLookupTableEntry.JSON_PROPERTY_EQUALS_SOURCE, + ObservabilityPipelineOcsfMappingCustomLookupTableEntry.JSON_PROPERTY_MATCHES, + ObservabilityPipelineOcsfMappingCustomLookupTableEntry.JSON_PROPERTY_NOT_MATCHES, + ObservabilityPipelineOcsfMappingCustomLookupTableEntry.JSON_PROPERTY_VALUE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ObservabilityPipelineOcsfMappingCustomLookupTableEntry { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CONTAINS = "contains"; + private String contains; + + public static final String JSON_PROPERTY_EQUALS = "equals"; + private Object _equals = null; + + public static final String JSON_PROPERTY_EQUALS_SOURCE = "equals_source"; + private String equalsSource; + + public static final String JSON_PROPERTY_MATCHES = "matches"; + private String matches; + + public static final String JSON_PROPERTY_NOT_MATCHES = "not_matches"; + private String notMatches; + + public static final String JSON_PROPERTY_VALUE = "value"; + private Object value = null; + + public ObservabilityPipelineOcsfMappingCustomLookupTableEntry contains(String contains) { + this.contains = contains; + return this; + } + + /** + * The substring to match in the source value. + * + * @return contains + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTAINS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getContains() { + return contains; + } + + public void setContains(String contains) { + this.contains = contains; + } + + public ObservabilityPipelineOcsfMappingCustomLookupTableEntry _equals(Object _equals) { + this._equals = _equals; + return this; + } + + /** + * The exact value to match in the source. + * + * @return _equals + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EQUALS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getEquals() { + return _equals; + } + + public void setEquals(Object _equals) { + this._equals = _equals; + } + + public ObservabilityPipelineOcsfMappingCustomLookupTableEntry equalsSource(String equalsSource) { + this.equalsSource = equalsSource; + return this; + } + + /** + * The source field to match against. + * + * @return equalsSource + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EQUALS_SOURCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEqualsSource() { + return equalsSource; + } + + public void setEqualsSource(String equalsSource) { + this.equalsSource = equalsSource; + } + + public ObservabilityPipelineOcsfMappingCustomLookupTableEntry matches(String matches) { + this.matches = matches; + return this; + } + + /** + * A regex pattern to match in the source value. + * + * @return matches + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MATCHES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMatches() { + return matches; + } + + public void setMatches(String matches) { + this.matches = matches; + } + + public ObservabilityPipelineOcsfMappingCustomLookupTableEntry notMatches(String notMatches) { + this.notMatches = notMatches; + return this; + } + + /** + * A regex pattern that must not match the source value. + * + * @return notMatches + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NOT_MATCHES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getNotMatches() { + return notMatches; + } + + public void setNotMatches(String notMatches) { + this.notMatches = notMatches; + } + + public ObservabilityPipelineOcsfMappingCustomLookupTableEntry value(Object value) { + this.value = value; + return this; + } + + /** + * The value to use when a match is found. + * + * @return value + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + /** + * 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 ObservabilityPipelineOcsfMappingCustomLookupTableEntry + */ + @JsonAnySetter + public ObservabilityPipelineOcsfMappingCustomLookupTableEntry 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 ObservabilityPipelineOcsfMappingCustomLookupTableEntry object is equal to + * o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObservabilityPipelineOcsfMappingCustomLookupTableEntry + observabilityPipelineOcsfMappingCustomLookupTableEntry = + (ObservabilityPipelineOcsfMappingCustomLookupTableEntry) o; + return Objects.equals( + this.contains, observabilityPipelineOcsfMappingCustomLookupTableEntry.contains) + && Objects.equals( + this._equals, observabilityPipelineOcsfMappingCustomLookupTableEntry._equals) + && Objects.equals( + this.equalsSource, observabilityPipelineOcsfMappingCustomLookupTableEntry.equalsSource) + && Objects.equals( + this.matches, observabilityPipelineOcsfMappingCustomLookupTableEntry.matches) + && Objects.equals( + this.notMatches, observabilityPipelineOcsfMappingCustomLookupTableEntry.notMatches) + && Objects.equals(this.value, observabilityPipelineOcsfMappingCustomLookupTableEntry.value) + && Objects.equals( + this.additionalProperties, + observabilityPipelineOcsfMappingCustomLookupTableEntry.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + contains, _equals, equalsSource, matches, notMatches, value, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObservabilityPipelineOcsfMappingCustomLookupTableEntry {\n"); + sb.append(" contains: ").append(toIndentedString(contains)).append("\n"); + sb.append(" _equals: ").append(toIndentedString(_equals)).append("\n"); + sb.append(" equalsSource: ").append(toIndentedString(equalsSource)).append("\n"); + sb.append(" matches: ").append(toIndentedString(matches)).append("\n"); + sb.append(" notMatches: ").append(toIndentedString(notMatches)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).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/v2/model/ObservabilityPipelineOcsfMappingCustomMetadata.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustomMetadata.java new file mode 100644 index 00000000000..f96d6d9c64b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineOcsfMappingCustomMetadata.java @@ -0,0 +1,214 @@ +/* + * 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.v2.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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Metadata for the custom OCSF mapping. */ +@JsonPropertyOrder({ + ObservabilityPipelineOcsfMappingCustomMetadata.JSON_PROPERTY_CLASS, + ObservabilityPipelineOcsfMappingCustomMetadata.JSON_PROPERTY_PROFILES, + ObservabilityPipelineOcsfMappingCustomMetadata.JSON_PROPERTY_VERSION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ObservabilityPipelineOcsfMappingCustomMetadata { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CLASS = "class"; + private String _class; + + public static final String JSON_PROPERTY_PROFILES = "profiles"; + private List profiles = null; + + public static final String JSON_PROPERTY_VERSION = "version"; + private String version; + + public ObservabilityPipelineOcsfMappingCustomMetadata() {} + + @JsonCreator + public ObservabilityPipelineOcsfMappingCustomMetadata( + @JsonProperty(required = true, value = JSON_PROPERTY_CLASS) String _class, + @JsonProperty(required = true, value = JSON_PROPERTY_VERSION) String version) { + this._class = _class; + this.version = version; + } + + public ObservabilityPipelineOcsfMappingCustomMetadata _class(String _class) { + this._class = _class; + return this; + } + + /** + * The OCSF event class name. + * + * @return _class + */ + @JsonProperty(JSON_PROPERTY_CLASS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getClassAttribute() { + return _class; + } + + public void setClassAttribute(String _class) { + this._class = _class; + } + + public ObservabilityPipelineOcsfMappingCustomMetadata profiles(List profiles) { + this.profiles = profiles; + return this; + } + + public ObservabilityPipelineOcsfMappingCustomMetadata addProfilesItem(String profilesItem) { + if (this.profiles == null) { + this.profiles = new ArrayList<>(); + } + this.profiles.add(profilesItem); + return this; + } + + /** + * A list of OCSF profiles to apply. + * + * @return profiles + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PROFILES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getProfiles() { + return profiles; + } + + public void setProfiles(List profiles) { + this.profiles = profiles; + } + + public ObservabilityPipelineOcsfMappingCustomMetadata version(String version) { + this.version = version; + return this; + } + + /** + * The OCSF schema version. + * + * @return version + */ + @JsonProperty(JSON_PROPERTY_VERSION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + /** + * 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 ObservabilityPipelineOcsfMappingCustomMetadata + */ + @JsonAnySetter + public ObservabilityPipelineOcsfMappingCustomMetadata 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 ObservabilityPipelineOcsfMappingCustomMetadata object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObservabilityPipelineOcsfMappingCustomMetadata observabilityPipelineOcsfMappingCustomMetadata = + (ObservabilityPipelineOcsfMappingCustomMetadata) o; + return Objects.equals(this._class, observabilityPipelineOcsfMappingCustomMetadata._class) + && Objects.equals(this.profiles, observabilityPipelineOcsfMappingCustomMetadata.profiles) + && Objects.equals(this.version, observabilityPipelineOcsfMappingCustomMetadata.version) + && Objects.equals( + this.additionalProperties, + observabilityPipelineOcsfMappingCustomMetadata.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(_class, profiles, version, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObservabilityPipelineOcsfMappingCustomMetadata {\n"); + sb.append(" _class: ").append(toIndentedString(_class)).append("\n"); + sb.append(" profiles: ").append(toIndentedString(profiles)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).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/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_custom_mapping_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_custom_mapping_returns_OK_response.freeze new file mode 100644 index 00000000000..0a0ae84b13b --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_custom_mapping_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-02-10T14:12:05.668Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_custom_mapping_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_custom_mapping_returns_OK_response.json new file mode 100644 index 00000000000..c5c4434fd3a --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_custom_mapping_returns_OK_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"config\":{\"destinations\":[{\"id\":\"datadog-logs-destination\",\"inputs\":[\"my-processor-group\"],\"type\":\"datadog_logs\"}],\"processor_groups\":[{\"enabled\":true,\"id\":\"my-processor-group\",\"include\":\"service:my-service\",\"inputs\":[\"datadog-agent-source\"],\"processors\":[{\"enabled\":true,\"id\":\"ocsf-mapper-processor\",\"include\":\"service:my-service\",\"mappings\":[{\"include\":\"source:custom\",\"mapping\":{\"mapping\":[{\"default\":\"\",\"dest\":\"time\",\"source\":\"timestamp\"},{\"default\":\"\",\"dest\":\"severity\",\"source\":\"level\"},{\"default\":\"\",\"dest\":\"device.type\",\"lookup\":{\"table\":[{\"contains\":\"Desktop\",\"value\":\"desktop\"}]},\"source\":\"host.type\"}],\"metadata\":{\"class\":\"Device Inventory Info\",\"profiles\":[\"container\"],\"version\":\"1.3.0\"},\"version\":1}}],\"type\":\"ocsf_mapper\"}]}],\"sources\":[{\"id\":\"datadog-agent-source\",\"type\":\"datadog_agent\"}]},\"name\":\"OCSF Custom Mapper Pipeline\"},\"type\":\"pipelines\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/obs-pipelines/pipelines/validate", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[]}\n", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "53ece09f-7d78-b332-7b7e-dee4b1d3bc51" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_invalid_custom_mapping_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_invalid_custom_mapping_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..55487b67b25 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_invalid_custom_mapping_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2026-02-10T14:12:06.064Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_invalid_custom_mapping_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_invalid_custom_mapping_returns_Bad_Request_response.json new file mode 100644 index 00000000000..b92ed7da43b --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_invalid_custom_mapping_returns_Bad_Request_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"config\":{\"destinations\":[{\"id\":\"datadog-logs-destination\",\"inputs\":[\"my-processor-group\"],\"type\":\"datadog_logs\"}],\"processor_groups\":[{\"enabled\":true,\"id\":\"my-processor-group\",\"include\":\"service:my-service\",\"inputs\":[\"datadog-agent-source\"],\"processors\":[{\"enabled\":true,\"id\":\"ocsf-mapper-processor\",\"include\":\"service:my-service\",\"mappings\":[{\"include\":\"source:custom\",\"mapping\":{\"mapping\":[{\"dest\":\"time\",\"source\":\"timestamp\"}],\"metadata\":{\"class\":\"Invalid Class\",\"profiles\":[\"container\"],\"version\":\"1.3.0\"},\"version\":0}}],\"type\":\"ocsf_mapper\"}]}],\"sources\":[{\"id\":\"datadog-agent-source\",\"type\":\"datadog_agent\"}]},\"name\":\"OCSF Invalid Mapper Pipeline\"},\"type\":\"pipelines\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/obs-pipelines/pipelines/validate", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[{\"title\":\"Schema version must be a positive integer\",\"meta\":{\"field\":\"mappings.0.version\",\"id\":\"ocsf-mapper-processor\",\"message\":\"Schema version must be a positive integer\"}},{\"title\":\"Invalid custom mapping class\",\"meta\":{\"field\":\"mappings.0.metadata.class\",\"id\":\"ocsf-mapper-processor\",\"message\":\"Invalid custom mapping class\"}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "61f12364-3079-3b64-7e3d-eccb484f7786" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_library_mapping_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_library_mapping_returns_OK_response.freeze new file mode 100644 index 00000000000..fbeecac324c --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_library_mapping_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-02-10T14:12:05.285Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_library_mapping_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_library_mapping_returns_OK_response.json new file mode 100644 index 00000000000..7949590a2aa --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Validate_an_observability_pipeline_with_OCSF_mapper_library_mapping_returns_OK_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"config\":{\"destinations\":[{\"id\":\"datadog-logs-destination\",\"inputs\":[\"my-processor-group\"],\"type\":\"datadog_logs\"}],\"processor_groups\":[{\"enabled\":true,\"id\":\"my-processor-group\",\"include\":\"service:my-service\",\"inputs\":[\"datadog-agent-source\"],\"processors\":[{\"enabled\":true,\"id\":\"ocsf-mapper-processor\",\"include\":\"service:my-service\",\"mappings\":[{\"include\":\"source:cloudtrail\",\"mapping\":\"CloudTrail Account Change\"}],\"type\":\"ocsf_mapper\"}]}],\"sources\":[{\"id\":\"datadog-agent-source\",\"type\":\"datadog_agent\"}]},\"name\":\"OCSF Mapper Pipeline\"},\"type\":\"pipelines\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/obs-pipelines/pipelines/validate", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[]}\n", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "5e3a17b9-b10f-f846-3285-d7e228eca707" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v2/api/observability_pipelines.feature b/src/test/resources/com/datadog/api/client/v2/api/observability_pipelines.feature index 725b9e425a7..b5c68576805 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/observability_pipelines.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/observability_pipelines.feature @@ -167,3 +167,26 @@ Feature: Observability Pipelines When the request is sent Then the response status is 200 OK And the response "errors" has length 0 + + @team:DataDog/observability-pipelines + Scenario: Validate an observability pipeline with OCSF mapper custom mapping returns "OK" response + Given new "ValidatePipeline" request + And body with value {"data": {"attributes": {"config": {"destinations": [{"id": "datadog-logs-destination", "inputs": ["my-processor-group"], "type": "datadog_logs"}], "processor_groups": [{"enabled": true, "id": "my-processor-group", "include": "service:my-service", "inputs": ["datadog-agent-source"], "processors": [{"enabled": true, "id": "ocsf-mapper-processor", "include": "service:my-service", "mappings": [{"include": "source:custom", "mapping": {"mapping": [{"default": "", "dest": "time", "source": "timestamp"}, {"default": "", "dest": "severity", "source": "level"}, {"default": "", "dest": "device.type", "lookup": {"table": [{"contains": "Desktop", "value": "desktop"}]}, "source": "host.type"}], "metadata": {"class": "Device Inventory Info", "profiles": ["container"], "version": "1.3.0"}, "version": 1}}], "type": "ocsf_mapper"}]}], "sources": [{"id": "datadog-agent-source", "type": "datadog_agent"}]}, "name": "OCSF Custom Mapper Pipeline"}, "type": "pipelines"}} + When the request is sent + Then the response status is 200 OK + And the response "errors" has length 0 + + @team:DataDog/observability-pipelines + Scenario: Validate an observability pipeline with OCSF mapper invalid custom mapping returns "Bad Request" response + Given new "ValidatePipeline" request + And body with value {"data": {"attributes": {"config": {"destinations": [{"id": "datadog-logs-destination", "inputs": ["my-processor-group"], "type": "datadog_logs"}], "processor_groups": [{"enabled": true, "id": "my-processor-group", "include": "service:my-service", "inputs": ["datadog-agent-source"], "processors": [{"enabled": true, "id": "ocsf-mapper-processor", "include": "service:my-service", "mappings": [{"include": "source:custom", "mapping": {"mapping": [{"dest": "time", "source": "timestamp"}], "metadata": {"class": "Invalid Class", "profiles": ["container"], "version": "1.3.0"}, "version": 0}}], "type": "ocsf_mapper"}]}], "sources": [{"id": "datadog-agent-source", "type": "datadog_agent"}]}, "name": "OCSF Invalid Mapper Pipeline"}, "type": "pipelines"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/observability-pipelines + Scenario: Validate an observability pipeline with OCSF mapper library mapping returns "OK" response + Given new "ValidatePipeline" request + And body with value {"data": {"attributes": {"config": {"destinations": [{"id": "datadog-logs-destination", "inputs": ["my-processor-group"], "type": "datadog_logs"}], "processor_groups": [{"enabled": true, "id": "my-processor-group", "include": "service:my-service", "inputs": ["datadog-agent-source"], "processors": [{"enabled": true, "id": "ocsf-mapper-processor", "include": "service:my-service", "type": "ocsf_mapper", "mappings": [{"include": "source:cloudtrail", "mapping": "CloudTrail Account Change"}]}]}], "sources": [{"id": "datadog-agent-source", "type": "datadog_agent"}]}, "name": "OCSF Mapper Pipeline"}, "type": "pipelines"}} + When the request is sent + Then the response status is 200 OK + And the response "errors" has length 0