diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index c84d61cfe74..416eca61272 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -6331,6 +6331,7 @@ components: - $ref: '#/components/schemas/LogsSpanRemapper' - $ref: '#/components/schemas/LogsArrayProcessor' - $ref: '#/components/schemas/LogsDecoderProcessor' + - $ref: '#/components/schemas/LogsSchemaProcessor' LogsQueryCompute: description: Define computation for a log query. properties: @@ -6392,6 +6393,243 @@ components: periods. type: string type: object + LogsSchemaCategoryMapper: + description: "Use the Schema Category Mapper to categorize log event into enum + fields.\nIn the case of OCSF, they can be used to map sibling fields which + are composed of an ID and a name.\n\n**Notes**:\n\n- The syntax of the query + is the one of Logs Explorer search bar.\n The query can be done on any log + attribute or tag, whether it is a facet or not.\n Wildcards can also be used + inside your query.\n- Categories are executed in order and processing stops + at the first match.\n Make sure categories are properly ordered in case a + log could match multiple queries.\n- Sibling fields always have a numerical + ID field and a human-readable string name.\n- A fallback section handles cases + where the name or ID value matches a specific value.\n If the name matches + \"Other\" or the ID matches 99, the value of the sibling name field will be + pulled from a source field from the original log." + properties: + categories: + description: 'Array of filters to match or not a log and their + + corresponding `name` to assign a custom value to the log.' + example: + - filter: + query: '@eventName:(ConsoleLogin OR ExternalIdPDirectoryLogin OR UserAuthentication + OR Authenticate)' + id: 1 + name: Logon + - filter: + query: '@eventName:*' + id: 99 + name: Other + items: + $ref: '#/components/schemas/LogsSchemaCategoryMapperCategory' + type: array + fallback: + $ref: '#/components/schemas/LogsSchemaCategoryMapperFallback' + name: + description: Name of the logs schema category mapper. + example: activity_id and activity_name + type: string + targets: + $ref: '#/components/schemas/LogsSchemaCategoryMapperTargets' + type: + $ref: '#/components/schemas/LogsSchemaCategoryMapperType' + required: + - categories + - targets + - type + - name + type: object + LogsSchemaCategoryMapperCategory: + description: Object describing the logs filter with corresponding category ID + and name assignment. + properties: + filter: + $ref: '#/components/schemas/LogsFilter' + id: + description: ID to inject into the category. + example: 1 + format: int64 + type: integer + name: + description: Value to assign to target schema field. + example: Password Change + type: string + required: + - filter + - id + - name + type: object + LogsSchemaCategoryMapperFallback: + description: Used to override hardcoded category values with a value pulled + from a source attribute on the log. + properties: + sources: + additionalProperties: + items: + type: string + type: array + description: Fallback sources used to populate value of field. + example: {} + type: object + values: + additionalProperties: + type: string + description: Values that define when the fallback is used. + example: {} + type: object + type: object + LogsSchemaCategoryMapperTargets: + description: Name of the target attributes which value is defined by the matching + category. + properties: + id: + description: ID of the field to map log attributes to. + example: ocsf.activity_id + type: string + name: + description: Name of the field to map log attributes to. + example: ocsf.activity_name + type: string + type: object + LogsSchemaCategoryMapperType: + description: Type of logs schema category mapper. + enum: + - schema-category-mapper + example: schema-category-mapper + type: string + x-enum-varnames: + - SCHEMA_CATEGORY_MAPPER + LogsSchemaData: + description: Configuration of the schema data to use. + properties: + class_name: + description: Class name of the schema to use. + example: Account Change + type: string + class_uid: + description: Class UID of the schema to use. + example: 3001 + format: int64 + type: integer + profiles: + description: Optional list of profiles to modify the schema. + example: + - security_control + - host + items: + type: string + type: array + schema_type: + description: Type of schema to use. + example: ocsf + type: string + version: + description: Version of the schema to use. + example: 1.5.0 + type: string + required: + - schema_type + - version + - class_uid + - class_name + type: object + LogsSchemaMapper: + description: Configuration of the schema processor mapper to use. + oneOf: + - $ref: '#/components/schemas/LogsSchemaRemapper' + - $ref: '#/components/schemas/LogsSchemaCategoryMapper' + LogsSchemaProcessor: + description: A processor that has additional validations and checks for a given + schema. Currently supported schema types include OCSF. + properties: + is_enabled: + default: false + description: Whether or not the processor is enabled. + type: boolean + mappers: + description: The `LogsSchemaProcessor` `mappers`. + example: + - name: Map userIdentity to ocsf.user.uid + sources: + - userIdentity.principalId + target: ocsf.user.uid + type: schema-remapper + items: + $ref: '#/components/schemas/LogsSchemaMapper' + type: array + name: + description: Name of the processor. + example: Map additionalEventData.LoginTo to ocsf.dst_endpoint.svc_name + type: string + schema: + $ref: '#/components/schemas/LogsSchemaData' + type: + $ref: '#/components/schemas/LogsSchemaProcessorType' + required: + - name + - mappers + - type + - schema + type: object + LogsSchemaProcessorType: + default: schema-processor + description: Type of logs schema processor. + enum: + - schema-processor + example: schema-processor + type: string + x-enum-varnames: + - SCHEMA_PROCESSOR + LogsSchemaRemapper: + description: The schema remapper maps source log fields to their correct fields. + properties: + name: + description: Name of the logs schema remapper. + example: Map userIdentity.principalId, responseElements.role.roleId, responseElements.user.userId + to ocsf.user.uid + type: string + override_on_conflict: + default: false + description: Override or not the target element if already set. + type: boolean + preserve_source: + default: false + description: Remove or preserve the remapped source element. + type: boolean + sources: + description: Array of source attributes. + example: + - userIdentity.principalId + - responseElements.role.roleId + - responseElements.user.userId + items: + description: Attribute used as a source to remap its value to the target + attribute. + type: string + type: array + target: + description: Target field to map log source field to. + example: ocsf.user.uid + type: string + target_format: + $ref: '#/components/schemas/TargetFormatType' + type: + $ref: '#/components/schemas/LogsSchemaRemapperType' + required: + - name + - sources + - target + - type + type: object + LogsSchemaRemapperType: + description: Type of logs schema remapper. + enum: + - schema-remapper + example: schema-remapper + type: string + x-enum-varnames: + - SCHEMA_REMAPPER LogsServiceRemapper: description: 'Use this processor if you want to assign one or more attributes as the official service. diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_1745625064.java b/examples/v1/logs-pipelines/CreateLogsPipeline_1745625064.java new file mode 100644 index 00000000000..dfcf0ecd02a --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_1745625064.java @@ -0,0 +1,254 @@ +// Create a pipeline with Schema Processor and preserve_source true 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.LogsFilter; +import com.datadog.api.client.v1.model.LogsPipeline; +import com.datadog.api.client.v1.model.LogsProcessor; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapper; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperCategory; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperFallback; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperTargets; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperType; +import com.datadog.api.client.v1.model.LogsSchemaData; +import com.datadog.api.client.v1.model.LogsSchemaMapper; +import com.datadog.api.client.v1.model.LogsSchemaProcessor; +import com.datadog.api.client.v1.model.LogsSchemaProcessorType; +import com.datadog.api.client.v1.model.LogsSchemaRemapper; +import com.datadog.api.client.v1.model.LogsSchemaRemapperType; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; + +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("testSchemaProcessor") + .processors( + Collections.singletonList( + new LogsProcessor( + new LogsSchemaProcessor() + .type(LogsSchemaProcessorType.SCHEMA_PROCESSOR) + .isEnabled(true) + .name("Apply OCSF schema for 3001") + .schema( + new LogsSchemaData() + .schemaType("ocsf") + .version("1.5.0") + .classUid(3001L) + .className("Account Change") + .profiles(Arrays.asList("cloud", "datetime"))) + .mappers( + Arrays.asList( + new LogsSchemaMapper( + new LogsSchemaCategoryMapper() + .type( + LogsSchemaCategoryMapperType.SCHEMA_CATEGORY_MAPPER) + .name("activity_id and activity_name") + .categories( + Arrays.asList( + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query("@eventName:(*Create*)")) + .name("Create") + .id(1L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query( + "@eventName:(ChangePassword OR" + + " PasswordUpdated)")) + .name("Password Change") + .id(3L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query("@eventName:(*Attach*)")) + .name("Attach Policy") + .id(7L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query( + "@eventName:(*Detach* OR" + + " *Remove*)")) + .name("Detach Policy") + .id(8L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query("@eventName:(*Delete*)")) + .name("Delete") + .id(6L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("@eventName:*")) + .name("Other") + .id(99L))) + .targets( + new LogsSchemaCategoryMapperTargets() + .name("ocsf.activity_name") + .id("ocsf.activity_id")) + .fallback( + new LogsSchemaCategoryMapperFallback() + .values( + Map.ofEntries( + Map.entry("ocsf.activity_id", "99"), + Map.entry( + "ocsf.activity_name", "Other"))) + .sources( + Map.ofEntries( + Map.entry( + "ocsf.activity_name", + Collections.singletonList( + "eventName")))))), + new LogsSchemaMapper( + new LogsSchemaCategoryMapper() + .type( + LogsSchemaCategoryMapperType.SCHEMA_CATEGORY_MAPPER) + .name("status") + .categories( + Arrays.asList( + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("-@errorCode:*")) + .id(1L) + .name("Success"), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("@errorCode:*")) + .id(2L) + .name("Failure"))) + .targets( + new LogsSchemaCategoryMapperTargets() + .id("ocsf.status_id") + .name("ocsf.status"))), + new LogsSchemaMapper( + new LogsSchemaCategoryMapper() + .type( + LogsSchemaCategoryMapperType.SCHEMA_CATEGORY_MAPPER) + .name("Set default severity") + .categories( + Collections.singletonList( + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("@eventName:*")) + .name("Informational") + .id(1L))) + .targets( + new LogsSchemaCategoryMapperTargets() + .name("ocsf.severity") + .id("ocsf.severity_id"))), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map userIdentity to ocsf.user.uid") + .sources( + Arrays.asList( + "userIdentity.principalId", + "responseElements.role.roleId", + "responseElements.user.userId")) + .target("ocsf.user.uid") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map userName to ocsf.user.name") + .sources( + Arrays.asList( + "requestParameters.userName", + "responseElements.role.roleName", + "requestParameters.roleName", + "responseElements.user.userName")) + .target("ocsf.user.name") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map api to ocsf.api") + .sources(Collections.singletonList("api")) + .target("ocsf.api") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map user to ocsf.user") + .sources(Collections.singletonList("user")) + .target("ocsf.user") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map actor to ocsf.actor") + .sources(Collections.singletonList("actor")) + .target("ocsf.actor") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map cloud to ocsf.cloud") + .sources(Collections.singletonList("cloud")) + .target("ocsf.cloud") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map http_request to ocsf.http_request") + .sources(Collections.singletonList("http_request")) + .target("ocsf.http_request") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map metadata to ocsf.metadata") + .sources(Collections.singletonList("metadata")) + .target("ocsf.metadata") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map time to ocsf.time") + .sources(Collections.singletonList("time")) + .target("ocsf.time") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map src_endpoint to ocsf.src_endpoint") + .sources(Collections.singletonList("src_endpoint")) + .target("ocsf.src_endpoint") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map severity to ocsf.severity") + .sources(Collections.singletonList("severity")) + .target("ocsf.severity") + .preserveSource(true)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map severity_id to ocsf.severity_id") + .sources(Collections.singletonList("severity_id")) + .target("ocsf.severity_id") + .preserveSource(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/examples/v1/logs-pipelines/CreateLogsPipeline_2256674867.java b/examples/v1/logs-pipelines/CreateLogsPipeline_2256674867.java new file mode 100644 index 00000000000..30d209117ba --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_2256674867.java @@ -0,0 +1,254 @@ +// Create a pipeline with Schema Processor and preserve_source false 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.LogsFilter; +import com.datadog.api.client.v1.model.LogsPipeline; +import com.datadog.api.client.v1.model.LogsProcessor; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapper; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperCategory; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperFallback; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperTargets; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperType; +import com.datadog.api.client.v1.model.LogsSchemaData; +import com.datadog.api.client.v1.model.LogsSchemaMapper; +import com.datadog.api.client.v1.model.LogsSchemaProcessor; +import com.datadog.api.client.v1.model.LogsSchemaProcessorType; +import com.datadog.api.client.v1.model.LogsSchemaRemapper; +import com.datadog.api.client.v1.model.LogsSchemaRemapperType; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; + +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("testSchemaProcessor") + .processors( + Collections.singletonList( + new LogsProcessor( + new LogsSchemaProcessor() + .type(LogsSchemaProcessorType.SCHEMA_PROCESSOR) + .isEnabled(true) + .name("Apply OCSF schema for 3001") + .schema( + new LogsSchemaData() + .schemaType("ocsf") + .version("1.5.0") + .classUid(3001L) + .className("Account Change") + .profiles(Arrays.asList("cloud", "datetime"))) + .mappers( + Arrays.asList( + new LogsSchemaMapper( + new LogsSchemaCategoryMapper() + .type( + LogsSchemaCategoryMapperType.SCHEMA_CATEGORY_MAPPER) + .name("activity_id and activity_name") + .categories( + Arrays.asList( + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query("@eventName:(*Create*)")) + .name("Create") + .id(1L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query( + "@eventName:(ChangePassword OR" + + " PasswordUpdated)")) + .name("Password Change") + .id(3L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query("@eventName:(*Attach*)")) + .name("Attach Policy") + .id(7L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query( + "@eventName:(*Detach* OR" + + " *Remove*)")) + .name("Detach Policy") + .id(8L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query("@eventName:(*Delete*)")) + .name("Delete") + .id(6L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("@eventName:*")) + .name("Other") + .id(99L))) + .targets( + new LogsSchemaCategoryMapperTargets() + .name("ocsf.activity_name") + .id("ocsf.activity_id")) + .fallback( + new LogsSchemaCategoryMapperFallback() + .values( + Map.ofEntries( + Map.entry("ocsf.activity_id", "99"), + Map.entry( + "ocsf.activity_name", "Other"))) + .sources( + Map.ofEntries( + Map.entry( + "ocsf.activity_name", + Collections.singletonList( + "eventName")))))), + new LogsSchemaMapper( + new LogsSchemaCategoryMapper() + .type( + LogsSchemaCategoryMapperType.SCHEMA_CATEGORY_MAPPER) + .name("status") + .categories( + Arrays.asList( + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("-@errorCode:*")) + .id(1L) + .name("Success"), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("@errorCode:*")) + .id(2L) + .name("Failure"))) + .targets( + new LogsSchemaCategoryMapperTargets() + .id("ocsf.status_id") + .name("ocsf.status"))), + new LogsSchemaMapper( + new LogsSchemaCategoryMapper() + .type( + LogsSchemaCategoryMapperType.SCHEMA_CATEGORY_MAPPER) + .name("Set default severity") + .categories( + Collections.singletonList( + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("@eventName:*")) + .name("Informational") + .id(1L))) + .targets( + new LogsSchemaCategoryMapperTargets() + .name("ocsf.severity") + .id("ocsf.severity_id"))), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map userIdentity to ocsf.user.uid") + .sources( + Arrays.asList( + "userIdentity.principalId", + "responseElements.role.roleId", + "responseElements.user.userId")) + .target("ocsf.user.uid") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map userName to ocsf.user.name") + .sources( + Arrays.asList( + "requestParameters.userName", + "responseElements.role.roleName", + "requestParameters.roleName", + "responseElements.user.userName")) + .target("ocsf.user.name") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map api to ocsf.api") + .sources(Collections.singletonList("api")) + .target("ocsf.api") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map user to ocsf.user") + .sources(Collections.singletonList("user")) + .target("ocsf.user") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map actor to ocsf.actor") + .sources(Collections.singletonList("actor")) + .target("ocsf.actor") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map cloud to ocsf.cloud") + .sources(Collections.singletonList("cloud")) + .target("ocsf.cloud") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map http_request to ocsf.http_request") + .sources(Collections.singletonList("http_request")) + .target("ocsf.http_request") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map metadata to ocsf.metadata") + .sources(Collections.singletonList("metadata")) + .target("ocsf.metadata") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map time to ocsf.time") + .sources(Collections.singletonList("time")) + .target("ocsf.time") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map src_endpoint to ocsf.src_endpoint") + .sources(Collections.singletonList("src_endpoint")) + .target("ocsf.src_endpoint") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map severity to ocsf.severity") + .sources(Collections.singletonList("severity")) + .target("ocsf.severity") + .preserveSource(false)), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map severity_id to ocsf.severity_id") + .sources(Collections.singletonList("severity_id")) + .target("ocsf.severity_id") + .preserveSource(false))))))); + + 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_501419705.java b/examples/v1/logs-pipelines/CreateLogsPipeline_501419705.java new file mode 100644 index 00000000000..9da17615974 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_501419705.java @@ -0,0 +1,242 @@ +// Create a pipeline with schema processor + +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.LogsFilter; +import com.datadog.api.client.v1.model.LogsPipeline; +import com.datadog.api.client.v1.model.LogsProcessor; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapper; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperCategory; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperFallback; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperTargets; +import com.datadog.api.client.v1.model.LogsSchemaCategoryMapperType; +import com.datadog.api.client.v1.model.LogsSchemaData; +import com.datadog.api.client.v1.model.LogsSchemaMapper; +import com.datadog.api.client.v1.model.LogsSchemaProcessor; +import com.datadog.api.client.v1.model.LogsSchemaProcessorType; +import com.datadog.api.client.v1.model.LogsSchemaRemapper; +import com.datadog.api.client.v1.model.LogsSchemaRemapperType; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; + +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("testSchemaProcessor") + .processors( + Collections.singletonList( + new LogsProcessor( + new LogsSchemaProcessor() + .type(LogsSchemaProcessorType.SCHEMA_PROCESSOR) + .isEnabled(true) + .name("Apply OCSF schema for 3001") + .schema( + new LogsSchemaData() + .schemaType("ocsf") + .version("1.5.0") + .classUid(3001L) + .className("Account Change") + .profiles(Arrays.asList("cloud", "datetime"))) + .mappers( + Arrays.asList( + new LogsSchemaMapper( + new LogsSchemaCategoryMapper() + .type( + LogsSchemaCategoryMapperType.SCHEMA_CATEGORY_MAPPER) + .name("activity_id and activity_name") + .categories( + Arrays.asList( + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query("@eventName:(*Create*)")) + .name("Create") + .id(1L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query( + "@eventName:(ChangePassword OR" + + " PasswordUpdated)")) + .name("Password Change") + .id(3L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query("@eventName:(*Attach*)")) + .name("Attach Policy") + .id(7L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query( + "@eventName:(*Detach* OR" + + " *Remove*)")) + .name("Detach Policy") + .id(8L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter() + .query("@eventName:(*Delete*)")) + .name("Delete") + .id(6L), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("@eventName:*")) + .name("Other") + .id(99L))) + .targets( + new LogsSchemaCategoryMapperTargets() + .name("ocsf.activity_name") + .id("ocsf.activity_id")) + .fallback( + new LogsSchemaCategoryMapperFallback() + .values( + Map.ofEntries( + Map.entry("ocsf.activity_id", "99"), + Map.entry( + "ocsf.activity_name", "Other"))) + .sources( + Map.ofEntries( + Map.entry( + "ocsf.activity_name", + Collections.singletonList( + "eventName")))))), + new LogsSchemaMapper( + new LogsSchemaCategoryMapper() + .type( + LogsSchemaCategoryMapperType.SCHEMA_CATEGORY_MAPPER) + .name("status") + .categories( + Arrays.asList( + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("-@errorCode:*")) + .id(1L) + .name("Success"), + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("@errorCode:*")) + .id(2L) + .name("Failure"))) + .targets( + new LogsSchemaCategoryMapperTargets() + .id("ocsf.status_id") + .name("ocsf.status"))), + new LogsSchemaMapper( + new LogsSchemaCategoryMapper() + .type( + LogsSchemaCategoryMapperType.SCHEMA_CATEGORY_MAPPER) + .name("Set default severity") + .categories( + Collections.singletonList( + new LogsSchemaCategoryMapperCategory() + .filter( + new LogsFilter().query("@eventName:*")) + .name("Informational") + .id(1L))) + .targets( + new LogsSchemaCategoryMapperTargets() + .name("ocsf.severity") + .id("ocsf.severity_id"))), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map userIdentity to ocsf.user.uid") + .sources( + Arrays.asList( + "userIdentity.principalId", + "responseElements.role.roleId", + "responseElements.user.userId")) + .target("ocsf.user.uid")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map userName to ocsf.user.name") + .sources( + Arrays.asList( + "requestParameters.userName", + "responseElements.role.roleName", + "requestParameters.roleName", + "responseElements.user.userName")) + .target("ocsf.user.name")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map api to ocsf.api") + .sources(Collections.singletonList("api")) + .target("ocsf.api")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map user to ocsf.user") + .sources(Collections.singletonList("user")) + .target("ocsf.user")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map actor to ocsf.actor") + .sources(Collections.singletonList("actor")) + .target("ocsf.actor")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map cloud to ocsf.cloud") + .sources(Collections.singletonList("cloud")) + .target("ocsf.cloud")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map http_request to ocsf.http_request") + .sources(Collections.singletonList("http_request")) + .target("ocsf.http_request")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map metadata to ocsf.metadata") + .sources(Collections.singletonList("metadata")) + .target("ocsf.metadata")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map time to ocsf.time") + .sources(Collections.singletonList("time")) + .target("ocsf.time")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map src_endpoint to ocsf.src_endpoint") + .sources(Collections.singletonList("src_endpoint")) + .target("ocsf.src_endpoint")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map severity to ocsf.severity") + .sources(Collections.singletonList("severity")) + .target("ocsf.severity")), + new LogsSchemaMapper( + new LogsSchemaRemapper() + .type(LogsSchemaRemapperType.SCHEMA_REMAPPER) + .name("Map severity_id to ocsf.severity_id") + .sources(Collections.singletonList("severity_id")) + .target("ocsf.severity_id"))))))); + + 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/LogsProcessor.java b/src/main/java/com/datadog/api/client/v1/model/LogsProcessor.java index 00bf36e8d2e..0b1bfba06cc 100644 --- a/src/main/java/com/datadog/api/client/v1/model/LogsProcessor.java +++ b/src/main/java/com/datadog/api/client/v1/model/LogsProcessor.java @@ -921,6 +921,50 @@ public LogsProcessor deserialize(JsonParser jp, DeserializationContext ctxt) log.log(Level.FINER, "Input data does not match schema 'LogsDecoderProcessor'", e); } + // deserialize LogsSchemaProcessor + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (LogsSchemaProcessor.class.equals(Integer.class) + || LogsSchemaProcessor.class.equals(Long.class) + || LogsSchemaProcessor.class.equals(Float.class) + || LogsSchemaProcessor.class.equals(Double.class) + || LogsSchemaProcessor.class.equals(Boolean.class) + || LogsSchemaProcessor.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((LogsSchemaProcessor.class.equals(Integer.class) + || LogsSchemaProcessor.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((LogsSchemaProcessor.class.equals(Float.class) + || LogsSchemaProcessor.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (LogsSchemaProcessor.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (LogsSchemaProcessor.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(LogsSchemaProcessor.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 (!((LogsSchemaProcessor) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'LogsSchemaProcessor'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'LogsSchemaProcessor'", e); + } + LogsProcessor ret = new LogsProcessor(); if (match == 1) { ret.setActualInstance(deserialized); @@ -1044,6 +1088,11 @@ public LogsProcessor(LogsDecoderProcessor o) { setActualInstance(o); } + public LogsProcessor(LogsSchemaProcessor o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + static { schemas.put("LogsGrokParser", new GenericType() {}); schemas.put("LogsDateRemapper", new GenericType() {}); @@ -1066,6 +1115,7 @@ public LogsProcessor(LogsDecoderProcessor o) { schemas.put("LogsSpanRemapper", new GenericType() {}); schemas.put("LogsArrayProcessor", new GenericType() {}); schemas.put("LogsDecoderProcessor", new GenericType() {}); + schemas.put("LogsSchemaProcessor", new GenericType() {}); JSON.registerDescendants(LogsProcessor.class, Collections.unmodifiableMap(schemas)); } @@ -1081,7 +1131,7 @@ public Map getSchemas() { * LogsUserAgentParser, LogsCategoryProcessor, LogsArithmeticProcessor, * LogsStringBuilderProcessor, LogsPipelineProcessor, LogsGeoIPParser, LogsLookupProcessor, * ReferenceTableLogsLookupProcessor, LogsTraceRemapper, LogsSpanRemapper, LogsArrayProcessor, - * LogsDecoderProcessor + * LogsDecoderProcessor, LogsSchemaProcessor * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -1165,6 +1215,10 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf(LogsSchemaProcessor.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { super.setActualInstance(instance); @@ -1176,7 +1230,7 @@ public void setActualInstance(Object instance) { + " LogsUserAgentParser, LogsCategoryProcessor, LogsArithmeticProcessor," + " LogsStringBuilderProcessor, LogsPipelineProcessor, LogsGeoIPParser," + " LogsLookupProcessor, ReferenceTableLogsLookupProcessor, LogsTraceRemapper," - + " LogsSpanRemapper, LogsArrayProcessor, LogsDecoderProcessor"); + + " LogsSpanRemapper, LogsArrayProcessor, LogsDecoderProcessor, LogsSchemaProcessor"); } /** @@ -1185,14 +1239,14 @@ public void setActualInstance(Object instance) { * LogsURLParser, LogsUserAgentParser, LogsCategoryProcessor, LogsArithmeticProcessor, * LogsStringBuilderProcessor, LogsPipelineProcessor, LogsGeoIPParser, LogsLookupProcessor, * ReferenceTableLogsLookupProcessor, LogsTraceRemapper, LogsSpanRemapper, LogsArrayProcessor, - * LogsDecoderProcessor + * LogsDecoderProcessor, LogsSchemaProcessor * * @return The actual instance (LogsGrokParser, LogsDateRemapper, LogsStatusRemapper, * LogsServiceRemapper, LogsMessageRemapper, LogsAttributeRemapper, LogsURLParser, * LogsUserAgentParser, LogsCategoryProcessor, LogsArithmeticProcessor, * LogsStringBuilderProcessor, LogsPipelineProcessor, LogsGeoIPParser, LogsLookupProcessor, * ReferenceTableLogsLookupProcessor, LogsTraceRemapper, LogsSpanRemapper, LogsArrayProcessor, - * LogsDecoderProcessor) + * LogsDecoderProcessor, LogsSchemaProcessor) */ @Override public Object getActualInstance() { @@ -1408,4 +1462,15 @@ public LogsArrayProcessor getLogsArrayProcessor() throws ClassCastException { public LogsDecoderProcessor getLogsDecoderProcessor() throws ClassCastException { return (LogsDecoderProcessor) super.getActualInstance(); } + + /** + * Get the actual instance of `LogsSchemaProcessor`. If the actual instance is not + * `LogsSchemaProcessor`, the ClassCastException will be thrown. + * + * @return The actual instance of `LogsSchemaProcessor` + * @throws ClassCastException if the instance is not `LogsSchemaProcessor` + */ + public LogsSchemaProcessor getLogsSchemaProcessor() throws ClassCastException { + return (LogsSchemaProcessor) super.getActualInstance(); + } } diff --git a/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapper.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapper.java new file mode 100644 index 00000000000..b5e6fa42c51 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapper.java @@ -0,0 +1,298 @@ +/* + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * Use the Schema Category Mapper to categorize log event into enum fields. In the case of OCSF, + * they can be used to map sibling fields which are composed of an ID and a name. + * + *

Notes: + * + *

    + *
  • The syntax of the query is the one of Logs Explorer search bar. The query can be done on + * any log attribute or tag, whether it is a facet or not. Wildcards can also be used inside + * your query. + *
  • Categories are executed in order and processing stops at the first match. Make sure + * categories are properly ordered in case a log could match multiple queries. + *
  • Sibling fields always have a numerical ID field and a human-readable string name. + *
  • A fallback section handles cases where the name or ID value matches a specific value. If + * the name matches "Other" or the ID matches 99, the value of the sibling name field will be + * pulled from a source field from the original log. + *
+ */ +@JsonPropertyOrder({ + LogsSchemaCategoryMapper.JSON_PROPERTY_CATEGORIES, + LogsSchemaCategoryMapper.JSON_PROPERTY_FALLBACK, + LogsSchemaCategoryMapper.JSON_PROPERTY_NAME, + LogsSchemaCategoryMapper.JSON_PROPERTY_TARGETS, + LogsSchemaCategoryMapper.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class LogsSchemaCategoryMapper { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CATEGORIES = "categories"; + private List categories = new ArrayList<>(); + + public static final String JSON_PROPERTY_FALLBACK = "fallback"; + private LogsSchemaCategoryMapperFallback fallback; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_TARGETS = "targets"; + private LogsSchemaCategoryMapperTargets targets; + + public static final String JSON_PROPERTY_TYPE = "type"; + private LogsSchemaCategoryMapperType type; + + public LogsSchemaCategoryMapper() {} + + @JsonCreator + public LogsSchemaCategoryMapper( + @JsonProperty(required = true, value = JSON_PROPERTY_CATEGORIES) + List categories, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_TARGETS) + LogsSchemaCategoryMapperTargets targets, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + LogsSchemaCategoryMapperType type) { + this.categories = categories; + this.name = name; + this.targets = targets; + this.unparsed |= targets.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public LogsSchemaCategoryMapper categories(List categories) { + this.categories = categories; + for (LogsSchemaCategoryMapperCategory item : categories) { + this.unparsed |= item.unparsed; + } + return this; + } + + public LogsSchemaCategoryMapper addCategoriesItem( + LogsSchemaCategoryMapperCategory categoriesItem) { + this.categories.add(categoriesItem); + this.unparsed |= categoriesItem.unparsed; + return this; + } + + /** + * Array of filters to match or not a log and their corresponding name to assign a + * custom value to the log. + * + * @return categories + */ + @JsonProperty(JSON_PROPERTY_CATEGORIES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getCategories() { + return categories; + } + + public void setCategories(List categories) { + this.categories = categories; + } + + public LogsSchemaCategoryMapper fallback(LogsSchemaCategoryMapperFallback fallback) { + this.fallback = fallback; + this.unparsed |= fallback.unparsed; + return this; + } + + /** + * Used to override hardcoded category values with a value pulled from a source attribute on the + * log. + * + * @return fallback + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FALLBACK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public LogsSchemaCategoryMapperFallback getFallback() { + return fallback; + } + + public void setFallback(LogsSchemaCategoryMapperFallback fallback) { + this.fallback = fallback; + } + + public LogsSchemaCategoryMapper name(String name) { + this.name = name; + return this; + } + + /** + * Name of the logs schema category mapper. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public LogsSchemaCategoryMapper targets(LogsSchemaCategoryMapperTargets targets) { + this.targets = targets; + this.unparsed |= targets.unparsed; + return this; + } + + /** + * Name of the target attributes which value is defined by the matching category. + * + * @return targets + */ + @JsonProperty(JSON_PROPERTY_TARGETS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public LogsSchemaCategoryMapperTargets getTargets() { + return targets; + } + + public void setTargets(LogsSchemaCategoryMapperTargets targets) { + this.targets = targets; + } + + public LogsSchemaCategoryMapper type(LogsSchemaCategoryMapperType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Type of logs schema category mapper. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public LogsSchemaCategoryMapperType getType() { + return type; + } + + public void setType(LogsSchemaCategoryMapperType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * 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 LogsSchemaCategoryMapper + */ + @JsonAnySetter + public LogsSchemaCategoryMapper 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 LogsSchemaCategoryMapper object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogsSchemaCategoryMapper logsSchemaCategoryMapper = (LogsSchemaCategoryMapper) o; + return Objects.equals(this.categories, logsSchemaCategoryMapper.categories) + && Objects.equals(this.fallback, logsSchemaCategoryMapper.fallback) + && Objects.equals(this.name, logsSchemaCategoryMapper.name) + && Objects.equals(this.targets, logsSchemaCategoryMapper.targets) + && Objects.equals(this.type, logsSchemaCategoryMapper.type) + && Objects.equals(this.additionalProperties, logsSchemaCategoryMapper.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(categories, fallback, name, targets, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LogsSchemaCategoryMapper {\n"); + sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" fallback: ").append(toIndentedString(fallback)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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/LogsSchemaCategoryMapperCategory.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapperCategory.java new file mode 100644 index 00000000000..62166dbec7a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapperCategory.java @@ -0,0 +1,205 @@ +/* + * 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; + +/** Object describing the logs filter with corresponding category ID and name assignment. */ +@JsonPropertyOrder({ + LogsSchemaCategoryMapperCategory.JSON_PROPERTY_FILTER, + LogsSchemaCategoryMapperCategory.JSON_PROPERTY_ID, + LogsSchemaCategoryMapperCategory.JSON_PROPERTY_NAME +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class LogsSchemaCategoryMapperCategory { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FILTER = "filter"; + private LogsFilter filter; + + public static final String JSON_PROPERTY_ID = "id"; + private Long id; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public LogsSchemaCategoryMapperCategory() {} + + @JsonCreator + public LogsSchemaCategoryMapperCategory( + @JsonProperty(required = true, value = JSON_PROPERTY_FILTER) LogsFilter filter, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) Long id, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name) { + this.filter = filter; + this.unparsed |= filter.unparsed; + this.id = id; + this.name = name; + } + + public LogsSchemaCategoryMapperCategory filter(LogsFilter filter) { + this.filter = filter; + this.unparsed |= filter.unparsed; + return this; + } + + /** + * Filter for logs. + * + * @return filter + */ + @JsonProperty(JSON_PROPERTY_FILTER) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public LogsFilter getFilter() { + return filter; + } + + public void setFilter(LogsFilter filter) { + this.filter = filter; + } + + public LogsSchemaCategoryMapperCategory id(Long id) { + this.id = id; + return this; + } + + /** + * ID to inject into the category. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LogsSchemaCategoryMapperCategory name(String name) { + this.name = name; + return this; + } + + /** + * Value to assign to target schema field. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * 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 LogsSchemaCategoryMapperCategory + */ + @JsonAnySetter + public LogsSchemaCategoryMapperCategory 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 LogsSchemaCategoryMapperCategory object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogsSchemaCategoryMapperCategory logsSchemaCategoryMapperCategory = + (LogsSchemaCategoryMapperCategory) o; + return Objects.equals(this.filter, logsSchemaCategoryMapperCategory.filter) + && Objects.equals(this.id, logsSchemaCategoryMapperCategory.id) + && Objects.equals(this.name, logsSchemaCategoryMapperCategory.name) + && Objects.equals( + this.additionalProperties, logsSchemaCategoryMapperCategory.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(filter, id, name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LogsSchemaCategoryMapperCategory {\n"); + sb.append(" filter: ").append(toIndentedString(filter)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/LogsSchemaCategoryMapperFallback.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapperFallback.java new file mode 100644 index 00000000000..5c5d285b48e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapperFallback.java @@ -0,0 +1,186 @@ +/* + * 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.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.List; +import java.util.Map; +import java.util.Objects; + +/** + * Used to override hardcoded category values with a value pulled from a source attribute on the + * log. + */ +@JsonPropertyOrder({ + LogsSchemaCategoryMapperFallback.JSON_PROPERTY_SOURCES, + LogsSchemaCategoryMapperFallback.JSON_PROPERTY_VALUES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class LogsSchemaCategoryMapperFallback { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_SOURCES = "sources"; + private Map> sources = null; + + public static final String JSON_PROPERTY_VALUES = "values"; + private Map values = null; + + public LogsSchemaCategoryMapperFallback sources(Map> sources) { + this.sources = sources; + return this; + } + + public LogsSchemaCategoryMapperFallback putSourcesItem(String key, List sourcesItem) { + if (this.sources == null) { + this.sources = new HashMap<>(); + } + this.sources.put(key, sourcesItem); + return this; + } + + /** + * Fallback sources used to populate value of field. + * + * @return sources + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SOURCES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map> getSources() { + return sources; + } + + public void setSources(Map> sources) { + this.sources = sources; + } + + public LogsSchemaCategoryMapperFallback values(Map values) { + this.values = values; + return this; + } + + public LogsSchemaCategoryMapperFallback putValuesItem(String key, String valuesItem) { + if (this.values == null) { + this.values = new HashMap<>(); + } + this.values.put(key, valuesItem); + return this; + } + + /** + * Values that define when the fallback is used. + * + * @return values + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_VALUES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getValues() { + return values; + } + + public void setValues(Map values) { + this.values = values; + } + + /** + * 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 LogsSchemaCategoryMapperFallback + */ + @JsonAnySetter + public LogsSchemaCategoryMapperFallback 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 LogsSchemaCategoryMapperFallback object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogsSchemaCategoryMapperFallback logsSchemaCategoryMapperFallback = + (LogsSchemaCategoryMapperFallback) o; + return Objects.equals(this.sources, logsSchemaCategoryMapperFallback.sources) + && Objects.equals(this.values, logsSchemaCategoryMapperFallback.values) + && Objects.equals( + this.additionalProperties, logsSchemaCategoryMapperFallback.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(sources, values, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LogsSchemaCategoryMapperFallback {\n"); + sb.append(" sources: ").append(toIndentedString(sources)).append("\n"); + sb.append(" values: ").append(toIndentedString(values)).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/LogsSchemaCategoryMapperTargets.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapperTargets.java new file mode 100644 index 00000000000..8253c1c85e2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapperTargets.java @@ -0,0 +1,166 @@ +/* + * 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.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; + +/** Name of the target attributes which value is defined by the matching category. */ +@JsonPropertyOrder({ + LogsSchemaCategoryMapperTargets.JSON_PROPERTY_ID, + LogsSchemaCategoryMapperTargets.JSON_PROPERTY_NAME +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class LogsSchemaCategoryMapperTargets { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public LogsSchemaCategoryMapperTargets id(String id) { + this.id = id; + return this; + } + + /** + * ID of the field to map log attributes to. + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public LogsSchemaCategoryMapperTargets name(String name) { + this.name = name; + return this; + } + + /** + * Name of the field to map log attributes to. + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * 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 LogsSchemaCategoryMapperTargets + */ + @JsonAnySetter + public LogsSchemaCategoryMapperTargets 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 LogsSchemaCategoryMapperTargets object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogsSchemaCategoryMapperTargets logsSchemaCategoryMapperTargets = + (LogsSchemaCategoryMapperTargets) o; + return Objects.equals(this.id, logsSchemaCategoryMapperTargets.id) + && Objects.equals(this.name, logsSchemaCategoryMapperTargets.name) + && Objects.equals( + this.additionalProperties, logsSchemaCategoryMapperTargets.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LogsSchemaCategoryMapperTargets {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/LogsSchemaCategoryMapperType.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapperType.java new file mode 100644 index 00000000000..5f9cb26e2f1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaCategoryMapperType.java @@ -0,0 +1,57 @@ +/* + * 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; + +/** Type of logs schema category mapper. */ +@JsonSerialize(using = LogsSchemaCategoryMapperType.LogsSchemaCategoryMapperTypeSerializer.class) +public class LogsSchemaCategoryMapperType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("schema-category-mapper")); + + public static final LogsSchemaCategoryMapperType SCHEMA_CATEGORY_MAPPER = + new LogsSchemaCategoryMapperType("schema-category-mapper"); + + LogsSchemaCategoryMapperType(String value) { + super(value, allowedValues); + } + + public static class LogsSchemaCategoryMapperTypeSerializer + extends StdSerializer { + public LogsSchemaCategoryMapperTypeSerializer(Class t) { + super(t); + } + + public LogsSchemaCategoryMapperTypeSerializer() { + this(null); + } + + @Override + public void serialize( + LogsSchemaCategoryMapperType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static LogsSchemaCategoryMapperType fromValue(String value) { + return new LogsSchemaCategoryMapperType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/LogsSchemaData.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaData.java new file mode 100644 index 00000000000..74d118f88e8 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaData.java @@ -0,0 +1,266 @@ +/* + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Configuration of the schema data to use. */ +@JsonPropertyOrder({ + LogsSchemaData.JSON_PROPERTY_CLASS_NAME, + LogsSchemaData.JSON_PROPERTY_CLASS_UID, + LogsSchemaData.JSON_PROPERTY_PROFILES, + LogsSchemaData.JSON_PROPERTY_SCHEMA_TYPE, + LogsSchemaData.JSON_PROPERTY_VERSION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class LogsSchemaData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CLASS_NAME = "class_name"; + private String className; + + public static final String JSON_PROPERTY_CLASS_UID = "class_uid"; + private Long classUid; + + public static final String JSON_PROPERTY_PROFILES = "profiles"; + private List profiles = null; + + public static final String JSON_PROPERTY_SCHEMA_TYPE = "schema_type"; + private String schemaType; + + public static final String JSON_PROPERTY_VERSION = "version"; + private String version; + + public LogsSchemaData() {} + + @JsonCreator + public LogsSchemaData( + @JsonProperty(required = true, value = JSON_PROPERTY_CLASS_NAME) String className, + @JsonProperty(required = true, value = JSON_PROPERTY_CLASS_UID) Long classUid, + @JsonProperty(required = true, value = JSON_PROPERTY_SCHEMA_TYPE) String schemaType, + @JsonProperty(required = true, value = JSON_PROPERTY_VERSION) String version) { + this.className = className; + this.classUid = classUid; + this.schemaType = schemaType; + this.version = version; + } + + public LogsSchemaData className(String className) { + this.className = className; + return this; + } + + /** + * Class name of the schema to use. + * + * @return className + */ + @JsonProperty(JSON_PROPERTY_CLASS_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public LogsSchemaData classUid(Long classUid) { + this.classUid = classUid; + return this; + } + + /** + * Class UID of the schema to use. + * + * @return classUid + */ + @JsonProperty(JSON_PROPERTY_CLASS_UID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getClassUid() { + return classUid; + } + + public void setClassUid(Long classUid) { + this.classUid = classUid; + } + + public LogsSchemaData profiles(List profiles) { + this.profiles = profiles; + return this; + } + + public LogsSchemaData addProfilesItem(String profilesItem) { + if (this.profiles == null) { + this.profiles = new ArrayList<>(); + } + this.profiles.add(profilesItem); + return this; + } + + /** + * Optional list of profiles to modify the schema. + * + * @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 LogsSchemaData schemaType(String schemaType) { + this.schemaType = schemaType; + return this; + } + + /** + * Type of schema to use. + * + * @return schemaType + */ + @JsonProperty(JSON_PROPERTY_SCHEMA_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getSchemaType() { + return schemaType; + } + + public void setSchemaType(String schemaType) { + this.schemaType = schemaType; + } + + public LogsSchemaData version(String version) { + this.version = version; + return this; + } + + /** + * Version of the schema to use. + * + * @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 LogsSchemaData + */ + @JsonAnySetter + public LogsSchemaData 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 LogsSchemaData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogsSchemaData logsSchemaData = (LogsSchemaData) o; + return Objects.equals(this.className, logsSchemaData.className) + && Objects.equals(this.classUid, logsSchemaData.classUid) + && Objects.equals(this.profiles, logsSchemaData.profiles) + && Objects.equals(this.schemaType, logsSchemaData.schemaType) + && Objects.equals(this.version, logsSchemaData.version) + && Objects.equals(this.additionalProperties, logsSchemaData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(className, classUid, profiles, schemaType, version, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LogsSchemaData {\n"); + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" classUid: ").append(toIndentedString(classUid)).append("\n"); + sb.append(" profiles: ").append(toIndentedString(profiles)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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/v1/model/LogsSchemaMapper.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaMapper.java new file mode 100644 index 00000000000..36bd70d2d14 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaMapper.java @@ -0,0 +1,276 @@ +/* + * 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.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize(using = LogsSchemaMapper.LogsSchemaMapperDeserializer.class) +@JsonSerialize(using = LogsSchemaMapper.LogsSchemaMapperSerializer.class) +public class LogsSchemaMapper extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(LogsSchemaMapper.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class LogsSchemaMapperSerializer extends StdSerializer { + public LogsSchemaMapperSerializer(Class t) { + super(t); + } + + public LogsSchemaMapperSerializer() { + this(null); + } + + @Override + public void serialize(LogsSchemaMapper value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class LogsSchemaMapperDeserializer extends StdDeserializer { + public LogsSchemaMapperDeserializer() { + this(LogsSchemaMapper.class); + } + + public LogsSchemaMapperDeserializer(Class vc) { + super(vc); + } + + @Override + public LogsSchemaMapper deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize LogsSchemaRemapper + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (LogsSchemaRemapper.class.equals(Integer.class) + || LogsSchemaRemapper.class.equals(Long.class) + || LogsSchemaRemapper.class.equals(Float.class) + || LogsSchemaRemapper.class.equals(Double.class) + || LogsSchemaRemapper.class.equals(Boolean.class) + || LogsSchemaRemapper.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((LogsSchemaRemapper.class.equals(Integer.class) + || LogsSchemaRemapper.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((LogsSchemaRemapper.class.equals(Float.class) + || LogsSchemaRemapper.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (LogsSchemaRemapper.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (LogsSchemaRemapper.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(LogsSchemaRemapper.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 (!((LogsSchemaRemapper) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'LogsSchemaRemapper'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'LogsSchemaRemapper'", e); + } + + // deserialize LogsSchemaCategoryMapper + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (LogsSchemaCategoryMapper.class.equals(Integer.class) + || LogsSchemaCategoryMapper.class.equals(Long.class) + || LogsSchemaCategoryMapper.class.equals(Float.class) + || LogsSchemaCategoryMapper.class.equals(Double.class) + || LogsSchemaCategoryMapper.class.equals(Boolean.class) + || LogsSchemaCategoryMapper.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((LogsSchemaCategoryMapper.class.equals(Integer.class) + || LogsSchemaCategoryMapper.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((LogsSchemaCategoryMapper.class.equals(Float.class) + || LogsSchemaCategoryMapper.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (LogsSchemaCategoryMapper.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (LogsSchemaCategoryMapper.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(LogsSchemaCategoryMapper.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 (!((LogsSchemaCategoryMapper) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'LogsSchemaCategoryMapper'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'LogsSchemaCategoryMapper'", e); + } + + LogsSchemaMapper ret = new LogsSchemaMapper(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public LogsSchemaMapper getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "LogsSchemaMapper cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public LogsSchemaMapper() { + super("oneOf", Boolean.FALSE); + } + + public LogsSchemaMapper(LogsSchemaRemapper o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public LogsSchemaMapper(LogsSchemaCategoryMapper o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("LogsSchemaRemapper", new GenericType() {}); + schemas.put("LogsSchemaCategoryMapper", new GenericType() {}); + JSON.registerDescendants(LogsSchemaMapper.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return LogsSchemaMapper.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: LogsSchemaRemapper, LogsSchemaCategoryMapper + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(LogsSchemaRemapper.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(LogsSchemaCategoryMapper.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 LogsSchemaRemapper, LogsSchemaCategoryMapper"); + } + + /** + * Get the actual instance, which can be the following: LogsSchemaRemapper, + * LogsSchemaCategoryMapper + * + * @return The actual instance (LogsSchemaRemapper, LogsSchemaCategoryMapper) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `LogsSchemaRemapper`. If the actual instance is not + * `LogsSchemaRemapper`, the ClassCastException will be thrown. + * + * @return The actual instance of `LogsSchemaRemapper` + * @throws ClassCastException if the instance is not `LogsSchemaRemapper` + */ + public LogsSchemaRemapper getLogsSchemaRemapper() throws ClassCastException { + return (LogsSchemaRemapper) super.getActualInstance(); + } + + /** + * Get the actual instance of `LogsSchemaCategoryMapper`. If the actual instance is not + * `LogsSchemaCategoryMapper`, the ClassCastException will be thrown. + * + * @return The actual instance of `LogsSchemaCategoryMapper` + * @throws ClassCastException if the instance is not `LogsSchemaCategoryMapper` + */ + public LogsSchemaCategoryMapper getLogsSchemaCategoryMapper() throws ClassCastException { + return (LogsSchemaCategoryMapper) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/LogsSchemaProcessor.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaProcessor.java new file mode 100644 index 00000000000..1f62ec0e1cc --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaProcessor.java @@ -0,0 +1,277 @@ +/* + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A processor that has additional validations and checks for a given schema. Currently supported + * schema types include OCSF. + */ +@JsonPropertyOrder({ + LogsSchemaProcessor.JSON_PROPERTY_IS_ENABLED, + LogsSchemaProcessor.JSON_PROPERTY_MAPPERS, + LogsSchemaProcessor.JSON_PROPERTY_NAME, + LogsSchemaProcessor.JSON_PROPERTY_SCHEMA, + LogsSchemaProcessor.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class LogsSchemaProcessor { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_IS_ENABLED = "is_enabled"; + private Boolean isEnabled = false; + + public static final String JSON_PROPERTY_MAPPERS = "mappers"; + private List mappers = new ArrayList<>(); + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SCHEMA = "schema"; + private LogsSchemaData schema; + + public static final String JSON_PROPERTY_TYPE = "type"; + private LogsSchemaProcessorType type = LogsSchemaProcessorType.SCHEMA_PROCESSOR; + + public LogsSchemaProcessor() {} + + @JsonCreator + public LogsSchemaProcessor( + @JsonProperty(required = true, value = JSON_PROPERTY_MAPPERS) List mappers, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_SCHEMA) LogsSchemaData schema, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) LogsSchemaProcessorType type) { + this.mappers = mappers; + this.name = name; + this.schema = schema; + this.unparsed |= schema.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public LogsSchemaProcessor isEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + return this; + } + + /** + * Whether or not the processor is enabled. + * + * @return isEnabled + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_IS_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getIsEnabled() { + return isEnabled; + } + + public void setIsEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + } + + public LogsSchemaProcessor mappers(List mappers) { + this.mappers = mappers; + for (LogsSchemaMapper item : mappers) { + this.unparsed |= item.unparsed; + } + return this; + } + + public LogsSchemaProcessor addMappersItem(LogsSchemaMapper mappersItem) { + this.mappers.add(mappersItem); + this.unparsed |= mappersItem.unparsed; + return this; + } + + /** + * The LogsSchemaProcessor mappers. + * + * @return mappers + */ + @JsonProperty(JSON_PROPERTY_MAPPERS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getMappers() { + return mappers; + } + + public void setMappers(List mappers) { + this.mappers = mappers; + } + + public LogsSchemaProcessor name(String name) { + this.name = name; + return this; + } + + /** + * Name of the processor. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public LogsSchemaProcessor schema(LogsSchemaData schema) { + this.schema = schema; + this.unparsed |= schema.unparsed; + return this; + } + + /** + * Configuration of the schema data to use. + * + * @return schema + */ + @JsonProperty(JSON_PROPERTY_SCHEMA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public LogsSchemaData getSchema() { + return schema; + } + + public void setSchema(LogsSchemaData schema) { + this.schema = schema; + } + + public LogsSchemaProcessor type(LogsSchemaProcessorType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Type of logs schema processor. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public LogsSchemaProcessorType getType() { + return type; + } + + public void setType(LogsSchemaProcessorType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * 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 LogsSchemaProcessor + */ + @JsonAnySetter + public LogsSchemaProcessor 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 LogsSchemaProcessor object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogsSchemaProcessor logsSchemaProcessor = (LogsSchemaProcessor) o; + return Objects.equals(this.isEnabled, logsSchemaProcessor.isEnabled) + && Objects.equals(this.mappers, logsSchemaProcessor.mappers) + && Objects.equals(this.name, logsSchemaProcessor.name) + && Objects.equals(this.schema, logsSchemaProcessor.schema) + && Objects.equals(this.type, logsSchemaProcessor.type) + && Objects.equals(this.additionalProperties, logsSchemaProcessor.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(isEnabled, mappers, name, schema, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LogsSchemaProcessor {\n"); + sb.append(" isEnabled: ").append(toIndentedString(isEnabled)).append("\n"); + sb.append(" mappers: ").append(toIndentedString(mappers)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" schema: ").append(toIndentedString(schema)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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/LogsSchemaProcessorType.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaProcessorType.java new file mode 100644 index 00000000000..d0efb0d1b10 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaProcessorType.java @@ -0,0 +1,57 @@ +/* + * 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; + +/** Type of logs schema processor. */ +@JsonSerialize(using = LogsSchemaProcessorType.LogsSchemaProcessorTypeSerializer.class) +public class LogsSchemaProcessorType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("schema-processor")); + + public static final LogsSchemaProcessorType SCHEMA_PROCESSOR = + new LogsSchemaProcessorType("schema-processor"); + + LogsSchemaProcessorType(String value) { + super(value, allowedValues); + } + + public static class LogsSchemaProcessorTypeSerializer + extends StdSerializer { + public LogsSchemaProcessorTypeSerializer(Class t) { + super(t); + } + + public LogsSchemaProcessorTypeSerializer() { + this(null); + } + + @Override + public void serialize( + LogsSchemaProcessorType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static LogsSchemaProcessorType fromValue(String value) { + return new LogsSchemaProcessorType(value); + } +} 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 new file mode 100644 index 00000000000..dfbe23723b0 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaRemapper.java @@ -0,0 +1,337 @@ +/* + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** The schema remapper maps source log fields to their correct fields. */ +@JsonPropertyOrder({ + LogsSchemaRemapper.JSON_PROPERTY_NAME, + LogsSchemaRemapper.JSON_PROPERTY_OVERRIDE_ON_CONFLICT, + LogsSchemaRemapper.JSON_PROPERTY_PRESERVE_SOURCE, + LogsSchemaRemapper.JSON_PROPERTY_SOURCES, + LogsSchemaRemapper.JSON_PROPERTY_TARGET, + LogsSchemaRemapper.JSON_PROPERTY_TARGET_FORMAT, + LogsSchemaRemapper.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class LogsSchemaRemapper { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_OVERRIDE_ON_CONFLICT = "override_on_conflict"; + private Boolean overrideOnConflict = false; + + public static final String JSON_PROPERTY_PRESERVE_SOURCE = "preserve_source"; + private Boolean preserveSource = false; + + public static final String JSON_PROPERTY_SOURCES = "sources"; + private List sources = new ArrayList<>(); + + public static final String JSON_PROPERTY_TARGET = "target"; + private String target; + + public static final String JSON_PROPERTY_TARGET_FORMAT = "target_format"; + private TargetFormatType targetFormat; + + public static final String JSON_PROPERTY_TYPE = "type"; + private LogsSchemaRemapperType type; + + public LogsSchemaRemapper() {} + + @JsonCreator + public LogsSchemaRemapper( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_SOURCES) List sources, + @JsonProperty(required = true, value = JSON_PROPERTY_TARGET) String target, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) LogsSchemaRemapperType type) { + this.name = name; + this.sources = sources; + this.target = target; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public LogsSchemaRemapper name(String name) { + this.name = name; + return this; + } + + /** + * Name of the logs schema remapper. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public LogsSchemaRemapper overrideOnConflict(Boolean overrideOnConflict) { + this.overrideOnConflict = overrideOnConflict; + return this; + } + + /** + * Override or not the target element if 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 LogsSchemaRemapper preserveSource(Boolean preserveSource) { + this.preserveSource = preserveSource; + return this; + } + + /** + * Remove or preserve the remapped source element. + * + * @return preserveSource + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PRESERVE_SOURCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getPreserveSource() { + return preserveSource; + } + + public void setPreserveSource(Boolean preserveSource) { + this.preserveSource = preserveSource; + } + + public LogsSchemaRemapper sources(List sources) { + this.sources = sources; + return this; + } + + public LogsSchemaRemapper addSourcesItem(String sourcesItem) { + this.sources.add(sourcesItem); + return this; + } + + /** + * Array of source attributes. + * + * @return sources + */ + @JsonProperty(JSON_PROPERTY_SOURCES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getSources() { + return sources; + } + + public void setSources(List sources) { + this.sources = sources; + } + + public LogsSchemaRemapper target(String target) { + this.target = target; + return this; + } + + /** + * Target field to map log source field to. + * + * @return target + */ + @JsonProperty(JSON_PROPERTY_TARGET) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public LogsSchemaRemapper targetFormat(TargetFormatType targetFormat) { + this.targetFormat = targetFormat; + this.unparsed |= !targetFormat.isValid(); + return this; + } + + /** + * If the target_type of the remapper is attribute, try to cast the + * value to a new specific type. If the cast is not possible, the original type is kept. + * string, integer, or double are the possible types. If the + * target_type is tag, this parameter may not be specified. + * + * @return targetFormat + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TARGET_FORMAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TargetFormatType getTargetFormat() { + return targetFormat; + } + + public void setTargetFormat(TargetFormatType targetFormat) { + if (!targetFormat.isValid()) { + this.unparsed = true; + } + this.targetFormat = targetFormat; + } + + public LogsSchemaRemapper type(LogsSchemaRemapperType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Type of logs schema remapper. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public LogsSchemaRemapperType getType() { + return type; + } + + public void setType(LogsSchemaRemapperType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * 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 LogsSchemaRemapper + */ + @JsonAnySetter + public LogsSchemaRemapper 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 LogsSchemaRemapper object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogsSchemaRemapper logsSchemaRemapper = (LogsSchemaRemapper) o; + return Objects.equals(this.name, logsSchemaRemapper.name) + && Objects.equals(this.overrideOnConflict, logsSchemaRemapper.overrideOnConflict) + && Objects.equals(this.preserveSource, logsSchemaRemapper.preserveSource) + && Objects.equals(this.sources, logsSchemaRemapper.sources) + && Objects.equals(this.target, logsSchemaRemapper.target) + && Objects.equals(this.targetFormat, logsSchemaRemapper.targetFormat) + && Objects.equals(this.type, logsSchemaRemapper.type) + && Objects.equals(this.additionalProperties, logsSchemaRemapper.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + overrideOnConflict, + preserveSource, + sources, + target, + targetFormat, + type, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LogsSchemaRemapper {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" overrideOnConflict: ").append(toIndentedString(overrideOnConflict)).append("\n"); + sb.append(" preserveSource: ").append(toIndentedString(preserveSource)).append("\n"); + sb.append(" sources: ").append(toIndentedString(sources)).append("\n"); + sb.append(" target: ").append(toIndentedString(target)).append("\n"); + sb.append(" targetFormat: ").append(toIndentedString(targetFormat)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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/LogsSchemaRemapperType.java b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaRemapperType.java new file mode 100644 index 00000000000..4a0df2ce291 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/LogsSchemaRemapperType.java @@ -0,0 +1,57 @@ +/* + * 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; + +/** Type of logs schema remapper. */ +@JsonSerialize(using = LogsSchemaRemapperType.LogsSchemaRemapperTypeSerializer.class) +public class LogsSchemaRemapperType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("schema-remapper")); + + public static final LogsSchemaRemapperType SCHEMA_REMAPPER = + new LogsSchemaRemapperType("schema-remapper"); + + LogsSchemaRemapperType(String value) { + super(value, allowedValues); + } + + public static class LogsSchemaRemapperTypeSerializer + extends StdSerializer { + public LogsSchemaRemapperTypeSerializer(Class t) { + super(t); + } + + public LogsSchemaRemapperTypeSerializer() { + this(null); + } + + @Override + public void serialize( + LogsSchemaRemapperType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static LogsSchemaRemapperType fromValue(String value) { + return new LogsSchemaRemapperType(value); + } +} diff --git a/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_false_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_false_returns_OK_response.freeze new file mode 100644 index 00000000000..bbc78f11a09 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_false_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-10-22T19:11:58.774Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_false_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_false_returns_OK_response.json new file mode 100644 index 00000000000..c4051559405 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_false_returns_OK_response.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"filter\":{\"query\":\"source:python\"},\"name\":\"testSchemaProcessor\",\"processors\":[{\"is_enabled\":true,\"mappers\":[{\"categories\":[{\"filter\":{\"query\":\"@eventName:(*Create*)\"},\"id\":1,\"name\":\"Create\"},{\"filter\":{\"query\":\"@eventName:(ChangePassword OR PasswordUpdated)\"},\"id\":3,\"name\":\"Password Change\"},{\"filter\":{\"query\":\"@eventName:(*Attach*)\"},\"id\":7,\"name\":\"Attach Policy\"},{\"filter\":{\"query\":\"@eventName:(*Detach* OR *Remove*)\"},\"id\":8,\"name\":\"Detach Policy\"},{\"filter\":{\"query\":\"@eventName:(*Delete*)\"},\"id\":6,\"name\":\"Delete\"},{\"filter\":{\"query\":\"@eventName:*\"},\"id\":99,\"name\":\"Other\"}],\"fallback\":{\"sources\":{\"ocsf.activity_name\":[\"eventName\"]},\"values\":{\"ocsf.activity_id\":\"99\",\"ocsf.activity_name\":\"Other\"}},\"name\":\"activity_id and activity_name\",\"targets\":{\"id\":\"ocsf.activity_id\",\"name\":\"ocsf.activity_name\"},\"type\":\"schema-category-mapper\"},{\"categories\":[{\"filter\":{\"query\":\"-@errorCode:*\"},\"id\":1,\"name\":\"Success\"},{\"filter\":{\"query\":\"@errorCode:*\"},\"id\":2,\"name\":\"Failure\"}],\"name\":\"status\",\"targets\":{\"id\":\"ocsf.status_id\",\"name\":\"ocsf.status\"},\"type\":\"schema-category-mapper\"},{\"categories\":[{\"filter\":{\"query\":\"@eventName:*\"},\"id\":1,\"name\":\"Informational\"}],\"name\":\"Set default severity\",\"targets\":{\"id\":\"ocsf.severity_id\",\"name\":\"ocsf.severity\"},\"type\":\"schema-category-mapper\"},{\"name\":\"Map userIdentity to ocsf.user.uid\",\"preserve_source\":false,\"sources\":[\"userIdentity.principalId\",\"responseElements.role.roleId\",\"responseElements.user.userId\"],\"target\":\"ocsf.user.uid\",\"type\":\"schema-remapper\"},{\"name\":\"Map userName to ocsf.user.name\",\"preserve_source\":false,\"sources\":[\"requestParameters.userName\",\"responseElements.role.roleName\",\"requestParameters.roleName\",\"responseElements.user.userName\"],\"target\":\"ocsf.user.name\",\"type\":\"schema-remapper\"},{\"name\":\"Map api to ocsf.api\",\"preserve_source\":false,\"sources\":[\"api\"],\"target\":\"ocsf.api\",\"type\":\"schema-remapper\"},{\"name\":\"Map user to ocsf.user\",\"preserve_source\":false,\"sources\":[\"user\"],\"target\":\"ocsf.user\",\"type\":\"schema-remapper\"},{\"name\":\"Map actor to ocsf.actor\",\"preserve_source\":false,\"sources\":[\"actor\"],\"target\":\"ocsf.actor\",\"type\":\"schema-remapper\"},{\"name\":\"Map cloud to ocsf.cloud\",\"preserve_source\":false,\"sources\":[\"cloud\"],\"target\":\"ocsf.cloud\",\"type\":\"schema-remapper\"},{\"name\":\"Map http_request to ocsf.http_request\",\"preserve_source\":false,\"sources\":[\"http_request\"],\"target\":\"ocsf.http_request\",\"type\":\"schema-remapper\"},{\"name\":\"Map metadata to ocsf.metadata\",\"preserve_source\":false,\"sources\":[\"metadata\"],\"target\":\"ocsf.metadata\",\"type\":\"schema-remapper\"},{\"name\":\"Map time to ocsf.time\",\"preserve_source\":false,\"sources\":[\"time\"],\"target\":\"ocsf.time\",\"type\":\"schema-remapper\"},{\"name\":\"Map src_endpoint to ocsf.src_endpoint\",\"preserve_source\":false,\"sources\":[\"src_endpoint\"],\"target\":\"ocsf.src_endpoint\",\"type\":\"schema-remapper\"},{\"name\":\"Map severity to ocsf.severity\",\"preserve_source\":false,\"sources\":[\"severity\"],\"target\":\"ocsf.severity\",\"type\":\"schema-remapper\"},{\"name\":\"Map severity_id to ocsf.severity_id\",\"preserve_source\":false,\"sources\":[\"severity_id\"],\"target\":\"ocsf.severity_id\",\"type\":\"schema-remapper\"}],\"name\":\"Apply OCSF schema for 3001\",\"schema\":{\"class_name\":\"Account Change\",\"class_uid\":3001,\"profiles\":[\"cloud\",\"datetime\"],\"schema_type\":\"ocsf\",\"version\":\"1.5.0\"},\"type\":\"schema-processor\"}],\"tags\":[]}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/logs/config/pipelines", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":\"-qkKiJPYTne-113i8XJ_Nw\",\"type\":\"pipeline\",\"name\":\"testSchemaProcessor\",\"is_enabled\":false,\"is_read_only\":false,\"filter\":{\"query\":\"source:python\"},\"processors\":[{\"name\":\"Apply OCSF schema for 3001\",\"is_enabled\":true,\"mappers\":[{\"name\":\"activity_id and activity_name\",\"categories\":[{\"filter\":{\"query\":\"@eventName:(*Create*)\"},\"name\":\"Create\",\"id\":1},{\"filter\":{\"query\":\"@eventName:(ChangePassword OR PasswordUpdated)\"},\"name\":\"Password Change\",\"id\":3},{\"filter\":{\"query\":\"@eventName:(*Attach*)\"},\"name\":\"Attach Policy\",\"id\":7},{\"filter\":{\"query\":\"@eventName:(*Detach* OR *Remove*)\"},\"name\":\"Detach Policy\",\"id\":8},{\"filter\":{\"query\":\"@eventName:(*Delete*)\"},\"name\":\"Delete\",\"id\":6},{\"filter\":{\"query\":\"@eventName:*\"},\"name\":\"Other\",\"id\":99}],\"targets\":{\"name\":\"ocsf.activity_name\",\"id\":\"ocsf.activity_id\"},\"fallback\":{\"values\":{\"ocsf.activity_id\":\"99\",\"ocsf.activity_name\":\"Other\"},\"sources\":{\"ocsf.activity_name\":[\"eventName\"]}},\"type\":\"schema-category-mapper\"},{\"name\":\"status\",\"categories\":[{\"filter\":{\"query\":\"-@errorCode:*\"},\"name\":\"Success\",\"id\":1},{\"filter\":{\"query\":\"@errorCode:*\"},\"name\":\"Failure\",\"id\":2}],\"targets\":{\"name\":\"ocsf.status\",\"id\":\"ocsf.status_id\"},\"fallback\":{\"values\":{},\"sources\":{}},\"type\":\"schema-category-mapper\"},{\"name\":\"Set default severity\",\"categories\":[{\"filter\":{\"query\":\"@eventName:*\"},\"name\":\"Informational\",\"id\":1}],\"targets\":{\"name\":\"ocsf.severity\",\"id\":\"ocsf.severity_id\"},\"fallback\":{\"values\":{},\"sources\":{}},\"type\":\"schema-category-mapper\"},{\"name\":\"Map userIdentity to ocsf.user.uid\",\"sources\":[\"userIdentity.principalId\",\"responseElements.role.roleId\",\"responseElements.user.userId\"],\"target\":\"ocsf.user.uid\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map userName to ocsf.user.name\",\"sources\":[\"requestParameters.userName\",\"responseElements.role.roleName\",\"requestParameters.roleName\",\"responseElements.user.userName\"],\"target\":\"ocsf.user.name\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map api to ocsf.api\",\"sources\":[\"api\"],\"target\":\"ocsf.api\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map user to ocsf.user\",\"sources\":[\"user\"],\"target\":\"ocsf.user\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map actor to ocsf.actor\",\"sources\":[\"actor\"],\"target\":\"ocsf.actor\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map cloud to ocsf.cloud\",\"sources\":[\"cloud\"],\"target\":\"ocsf.cloud\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map http_request to ocsf.http_request\",\"sources\":[\"http_request\"],\"target\":\"ocsf.http_request\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map metadata to ocsf.metadata\",\"sources\":[\"metadata\"],\"target\":\"ocsf.metadata\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map time to ocsf.time\",\"sources\":[\"time\"],\"target\":\"ocsf.time\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map src_endpoint to ocsf.src_endpoint\",\"sources\":[\"src_endpoint\"],\"target\":\"ocsf.src_endpoint\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map severity to ocsf.severity\",\"sources\":[\"severity\"],\"target\":\"ocsf.severity\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map severity_id to ocsf.severity_id\",\"sources\":[\"severity_id\"],\"target\":\"ocsf.severity_id\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"}],\"schema\":{\"schema_type\":\"ocsf\",\"version\":\"1.5.0\",\"class_name\":\"Account Change\",\"class_uid\":3001,\"extensions\":[],\"profiles\":[\"cloud\",\"datetime\"]},\"type\":\"schema-processor\"}],\"tags\":[]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "98435b4b-38f6-6ccd-e06a-72100d3c817d" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/logs/config/pipelines/-qkKiJPYTne-113i8XJ_Nw", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "b2bb1a96-7f84-f27f-f9e0-bbf774a5d296" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_true_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_true_returns_OK_response.freeze new file mode 100644 index 00000000000..bd4fc475d30 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_true_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-10-22T19:11:59.195Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_true_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_true_returns_OK_response.json new file mode 100644 index 00000000000..794ecf26b3c --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_Schema_Processor_and_preserve_source_true_returns_OK_response.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"filter\":{\"query\":\"source:python\"},\"name\":\"testSchemaProcessor\",\"processors\":[{\"is_enabled\":true,\"mappers\":[{\"categories\":[{\"filter\":{\"query\":\"@eventName:(*Create*)\"},\"id\":1,\"name\":\"Create\"},{\"filter\":{\"query\":\"@eventName:(ChangePassword OR PasswordUpdated)\"},\"id\":3,\"name\":\"Password Change\"},{\"filter\":{\"query\":\"@eventName:(*Attach*)\"},\"id\":7,\"name\":\"Attach Policy\"},{\"filter\":{\"query\":\"@eventName:(*Detach* OR *Remove*)\"},\"id\":8,\"name\":\"Detach Policy\"},{\"filter\":{\"query\":\"@eventName:(*Delete*)\"},\"id\":6,\"name\":\"Delete\"},{\"filter\":{\"query\":\"@eventName:*\"},\"id\":99,\"name\":\"Other\"}],\"fallback\":{\"sources\":{\"ocsf.activity_name\":[\"eventName\"]},\"values\":{\"ocsf.activity_id\":\"99\",\"ocsf.activity_name\":\"Other\"}},\"name\":\"activity_id and activity_name\",\"targets\":{\"id\":\"ocsf.activity_id\",\"name\":\"ocsf.activity_name\"},\"type\":\"schema-category-mapper\"},{\"categories\":[{\"filter\":{\"query\":\"-@errorCode:*\"},\"id\":1,\"name\":\"Success\"},{\"filter\":{\"query\":\"@errorCode:*\"},\"id\":2,\"name\":\"Failure\"}],\"name\":\"status\",\"targets\":{\"id\":\"ocsf.status_id\",\"name\":\"ocsf.status\"},\"type\":\"schema-category-mapper\"},{\"categories\":[{\"filter\":{\"query\":\"@eventName:*\"},\"id\":1,\"name\":\"Informational\"}],\"name\":\"Set default severity\",\"targets\":{\"id\":\"ocsf.severity_id\",\"name\":\"ocsf.severity\"},\"type\":\"schema-category-mapper\"},{\"name\":\"Map userIdentity to ocsf.user.uid\",\"preserve_source\":true,\"sources\":[\"userIdentity.principalId\",\"responseElements.role.roleId\",\"responseElements.user.userId\"],\"target\":\"ocsf.user.uid\",\"type\":\"schema-remapper\"},{\"name\":\"Map userName to ocsf.user.name\",\"preserve_source\":true,\"sources\":[\"requestParameters.userName\",\"responseElements.role.roleName\",\"requestParameters.roleName\",\"responseElements.user.userName\"],\"target\":\"ocsf.user.name\",\"type\":\"schema-remapper\"},{\"name\":\"Map api to ocsf.api\",\"preserve_source\":true,\"sources\":[\"api\"],\"target\":\"ocsf.api\",\"type\":\"schema-remapper\"},{\"name\":\"Map user to ocsf.user\",\"preserve_source\":true,\"sources\":[\"user\"],\"target\":\"ocsf.user\",\"type\":\"schema-remapper\"},{\"name\":\"Map actor to ocsf.actor\",\"preserve_source\":true,\"sources\":[\"actor\"],\"target\":\"ocsf.actor\",\"type\":\"schema-remapper\"},{\"name\":\"Map cloud to ocsf.cloud\",\"preserve_source\":true,\"sources\":[\"cloud\"],\"target\":\"ocsf.cloud\",\"type\":\"schema-remapper\"},{\"name\":\"Map http_request to ocsf.http_request\",\"preserve_source\":true,\"sources\":[\"http_request\"],\"target\":\"ocsf.http_request\",\"type\":\"schema-remapper\"},{\"name\":\"Map metadata to ocsf.metadata\",\"preserve_source\":true,\"sources\":[\"metadata\"],\"target\":\"ocsf.metadata\",\"type\":\"schema-remapper\"},{\"name\":\"Map time to ocsf.time\",\"preserve_source\":true,\"sources\":[\"time\"],\"target\":\"ocsf.time\",\"type\":\"schema-remapper\"},{\"name\":\"Map src_endpoint to ocsf.src_endpoint\",\"preserve_source\":true,\"sources\":[\"src_endpoint\"],\"target\":\"ocsf.src_endpoint\",\"type\":\"schema-remapper\"},{\"name\":\"Map severity to ocsf.severity\",\"preserve_source\":true,\"sources\":[\"severity\"],\"target\":\"ocsf.severity\",\"type\":\"schema-remapper\"},{\"name\":\"Map severity_id to ocsf.severity_id\",\"preserve_source\":true,\"sources\":[\"severity_id\"],\"target\":\"ocsf.severity_id\",\"type\":\"schema-remapper\"}],\"name\":\"Apply OCSF schema for 3001\",\"schema\":{\"class_name\":\"Account Change\",\"class_uid\":3001,\"profiles\":[\"cloud\",\"datetime\"],\"schema_type\":\"ocsf\",\"version\":\"1.5.0\"},\"type\":\"schema-processor\"}],\"tags\":[]}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/logs/config/pipelines", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":\"ReEWRVSbQ-ersoCn0Ibo6g\",\"type\":\"pipeline\",\"name\":\"testSchemaProcessor\",\"is_enabled\":false,\"is_read_only\":false,\"filter\":{\"query\":\"source:python\"},\"processors\":[{\"name\":\"Apply OCSF schema for 3001\",\"is_enabled\":true,\"mappers\":[{\"name\":\"activity_id and activity_name\",\"categories\":[{\"filter\":{\"query\":\"@eventName:(*Create*)\"},\"name\":\"Create\",\"id\":1},{\"filter\":{\"query\":\"@eventName:(ChangePassword OR PasswordUpdated)\"},\"name\":\"Password Change\",\"id\":3},{\"filter\":{\"query\":\"@eventName:(*Attach*)\"},\"name\":\"Attach Policy\",\"id\":7},{\"filter\":{\"query\":\"@eventName:(*Detach* OR *Remove*)\"},\"name\":\"Detach Policy\",\"id\":8},{\"filter\":{\"query\":\"@eventName:(*Delete*)\"},\"name\":\"Delete\",\"id\":6},{\"filter\":{\"query\":\"@eventName:*\"},\"name\":\"Other\",\"id\":99}],\"targets\":{\"name\":\"ocsf.activity_name\",\"id\":\"ocsf.activity_id\"},\"fallback\":{\"values\":{\"ocsf.activity_id\":\"99\",\"ocsf.activity_name\":\"Other\"},\"sources\":{\"ocsf.activity_name\":[\"eventName\"]}},\"type\":\"schema-category-mapper\"},{\"name\":\"status\",\"categories\":[{\"filter\":{\"query\":\"-@errorCode:*\"},\"name\":\"Success\",\"id\":1},{\"filter\":{\"query\":\"@errorCode:*\"},\"name\":\"Failure\",\"id\":2}],\"targets\":{\"name\":\"ocsf.status\",\"id\":\"ocsf.status_id\"},\"fallback\":{\"values\":{},\"sources\":{}},\"type\":\"schema-category-mapper\"},{\"name\":\"Set default severity\",\"categories\":[{\"filter\":{\"query\":\"@eventName:*\"},\"name\":\"Informational\",\"id\":1}],\"targets\":{\"name\":\"ocsf.severity\",\"id\":\"ocsf.severity_id\"},\"fallback\":{\"values\":{},\"sources\":{}},\"type\":\"schema-category-mapper\"},{\"name\":\"Map userIdentity to ocsf.user.uid\",\"sources\":[\"userIdentity.principalId\",\"responseElements.role.roleId\",\"responseElements.user.userId\"],\"target\":\"ocsf.user.uid\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map userName to ocsf.user.name\",\"sources\":[\"requestParameters.userName\",\"responseElements.role.roleName\",\"requestParameters.roleName\",\"responseElements.user.userName\"],\"target\":\"ocsf.user.name\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map api to ocsf.api\",\"sources\":[\"api\"],\"target\":\"ocsf.api\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map user to ocsf.user\",\"sources\":[\"user\"],\"target\":\"ocsf.user\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map actor to ocsf.actor\",\"sources\":[\"actor\"],\"target\":\"ocsf.actor\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map cloud to ocsf.cloud\",\"sources\":[\"cloud\"],\"target\":\"ocsf.cloud\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map http_request to ocsf.http_request\",\"sources\":[\"http_request\"],\"target\":\"ocsf.http_request\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map metadata to ocsf.metadata\",\"sources\":[\"metadata\"],\"target\":\"ocsf.metadata\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map time to ocsf.time\",\"sources\":[\"time\"],\"target\":\"ocsf.time\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map src_endpoint to ocsf.src_endpoint\",\"sources\":[\"src_endpoint\"],\"target\":\"ocsf.src_endpoint\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map severity to ocsf.severity\",\"sources\":[\"severity\"],\"target\":\"ocsf.severity\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map severity_id to ocsf.severity_id\",\"sources\":[\"severity_id\"],\"target\":\"ocsf.severity_id\",\"preserve_source\":true,\"override_on_conflict\":false,\"type\":\"schema-remapper\"}],\"schema\":{\"schema_type\":\"ocsf\",\"version\":\"1.5.0\",\"class_name\":\"Account Change\",\"class_uid\":3001,\"extensions\":[],\"profiles\":[\"cloud\",\"datetime\"]},\"type\":\"schema-processor\"}],\"tags\":[]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e3a75d25-782f-2b47-b606-e5adef07a8eb" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/logs/config/pipelines/ReEWRVSbQ-ersoCn0Ibo6g", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "90ae866a-67bd-6842-7b9e-79f26788873e" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_schema_processor.freeze b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_schema_processor.freeze new file mode 100644 index 00000000000..ac0d5b77e90 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_schema_processor.freeze @@ -0,0 +1 @@ +2025-10-22T19:12:00.030Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_schema_processor.json b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_schema_processor.json new file mode 100644 index 00000000000..0a41068fd8d --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_pipeline_with_schema_processor.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"filter\":{\"query\":\"source:python\"},\"name\":\"testSchemaProcessor\",\"processors\":[{\"is_enabled\":true,\"mappers\":[{\"categories\":[{\"filter\":{\"query\":\"@eventName:(*Create*)\"},\"id\":1,\"name\":\"Create\"},{\"filter\":{\"query\":\"@eventName:(ChangePassword OR PasswordUpdated)\"},\"id\":3,\"name\":\"Password Change\"},{\"filter\":{\"query\":\"@eventName:(*Attach*)\"},\"id\":7,\"name\":\"Attach Policy\"},{\"filter\":{\"query\":\"@eventName:(*Detach* OR *Remove*)\"},\"id\":8,\"name\":\"Detach Policy\"},{\"filter\":{\"query\":\"@eventName:(*Delete*)\"},\"id\":6,\"name\":\"Delete\"},{\"filter\":{\"query\":\"@eventName:*\"},\"id\":99,\"name\":\"Other\"}],\"fallback\":{\"sources\":{\"ocsf.activity_name\":[\"eventName\"]},\"values\":{\"ocsf.activity_id\":\"99\",\"ocsf.activity_name\":\"Other\"}},\"name\":\"activity_id and activity_name\",\"targets\":{\"id\":\"ocsf.activity_id\",\"name\":\"ocsf.activity_name\"},\"type\":\"schema-category-mapper\"},{\"categories\":[{\"filter\":{\"query\":\"-@errorCode:*\"},\"id\":1,\"name\":\"Success\"},{\"filter\":{\"query\":\"@errorCode:*\"},\"id\":2,\"name\":\"Failure\"}],\"name\":\"status\",\"targets\":{\"id\":\"ocsf.status_id\",\"name\":\"ocsf.status\"},\"type\":\"schema-category-mapper\"},{\"categories\":[{\"filter\":{\"query\":\"@eventName:*\"},\"id\":1,\"name\":\"Informational\"}],\"name\":\"Set default severity\",\"targets\":{\"id\":\"ocsf.severity_id\",\"name\":\"ocsf.severity\"},\"type\":\"schema-category-mapper\"},{\"name\":\"Map userIdentity to ocsf.user.uid\",\"sources\":[\"userIdentity.principalId\",\"responseElements.role.roleId\",\"responseElements.user.userId\"],\"target\":\"ocsf.user.uid\",\"type\":\"schema-remapper\"},{\"name\":\"Map userName to ocsf.user.name\",\"sources\":[\"requestParameters.userName\",\"responseElements.role.roleName\",\"requestParameters.roleName\",\"responseElements.user.userName\"],\"target\":\"ocsf.user.name\",\"type\":\"schema-remapper\"},{\"name\":\"Map api to ocsf.api\",\"sources\":[\"api\"],\"target\":\"ocsf.api\",\"type\":\"schema-remapper\"},{\"name\":\"Map user to ocsf.user\",\"sources\":[\"user\"],\"target\":\"ocsf.user\",\"type\":\"schema-remapper\"},{\"name\":\"Map actor to ocsf.actor\",\"sources\":[\"actor\"],\"target\":\"ocsf.actor\",\"type\":\"schema-remapper\"},{\"name\":\"Map cloud to ocsf.cloud\",\"sources\":[\"cloud\"],\"target\":\"ocsf.cloud\",\"type\":\"schema-remapper\"},{\"name\":\"Map http_request to ocsf.http_request\",\"sources\":[\"http_request\"],\"target\":\"ocsf.http_request\",\"type\":\"schema-remapper\"},{\"name\":\"Map metadata to ocsf.metadata\",\"sources\":[\"metadata\"],\"target\":\"ocsf.metadata\",\"type\":\"schema-remapper\"},{\"name\":\"Map time to ocsf.time\",\"sources\":[\"time\"],\"target\":\"ocsf.time\",\"type\":\"schema-remapper\"},{\"name\":\"Map src_endpoint to ocsf.src_endpoint\",\"sources\":[\"src_endpoint\"],\"target\":\"ocsf.src_endpoint\",\"type\":\"schema-remapper\"},{\"name\":\"Map severity to ocsf.severity\",\"sources\":[\"severity\"],\"target\":\"ocsf.severity\",\"type\":\"schema-remapper\"},{\"name\":\"Map severity_id to ocsf.severity_id\",\"sources\":[\"severity_id\"],\"target\":\"ocsf.severity_id\",\"type\":\"schema-remapper\"}],\"name\":\"Apply OCSF schema for 3001\",\"schema\":{\"class_name\":\"Account Change\",\"class_uid\":3001,\"profiles\":[\"cloud\",\"datetime\"],\"schema_type\":\"ocsf\",\"version\":\"1.5.0\"},\"type\":\"schema-processor\"}],\"tags\":[]}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/logs/config/pipelines", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":\"1unf0vMNQKSSwzsg6BuWMw\",\"type\":\"pipeline\",\"name\":\"testSchemaProcessor\",\"is_enabled\":false,\"is_read_only\":false,\"filter\":{\"query\":\"source:python\"},\"processors\":[{\"name\":\"Apply OCSF schema for 3001\",\"is_enabled\":true,\"mappers\":[{\"name\":\"activity_id and activity_name\",\"categories\":[{\"filter\":{\"query\":\"@eventName:(*Create*)\"},\"name\":\"Create\",\"id\":1},{\"filter\":{\"query\":\"@eventName:(ChangePassword OR PasswordUpdated)\"},\"name\":\"Password Change\",\"id\":3},{\"filter\":{\"query\":\"@eventName:(*Attach*)\"},\"name\":\"Attach Policy\",\"id\":7},{\"filter\":{\"query\":\"@eventName:(*Detach* OR *Remove*)\"},\"name\":\"Detach Policy\",\"id\":8},{\"filter\":{\"query\":\"@eventName:(*Delete*)\"},\"name\":\"Delete\",\"id\":6},{\"filter\":{\"query\":\"@eventName:*\"},\"name\":\"Other\",\"id\":99}],\"targets\":{\"name\":\"ocsf.activity_name\",\"id\":\"ocsf.activity_id\"},\"fallback\":{\"values\":{\"ocsf.activity_id\":\"99\",\"ocsf.activity_name\":\"Other\"},\"sources\":{\"ocsf.activity_name\":[\"eventName\"]}},\"type\":\"schema-category-mapper\"},{\"name\":\"status\",\"categories\":[{\"filter\":{\"query\":\"-@errorCode:*\"},\"name\":\"Success\",\"id\":1},{\"filter\":{\"query\":\"@errorCode:*\"},\"name\":\"Failure\",\"id\":2}],\"targets\":{\"name\":\"ocsf.status\",\"id\":\"ocsf.status_id\"},\"fallback\":{\"values\":{},\"sources\":{}},\"type\":\"schema-category-mapper\"},{\"name\":\"Set default severity\",\"categories\":[{\"filter\":{\"query\":\"@eventName:*\"},\"name\":\"Informational\",\"id\":1}],\"targets\":{\"name\":\"ocsf.severity\",\"id\":\"ocsf.severity_id\"},\"fallback\":{\"values\":{},\"sources\":{}},\"type\":\"schema-category-mapper\"},{\"name\":\"Map userIdentity to ocsf.user.uid\",\"sources\":[\"userIdentity.principalId\",\"responseElements.role.roleId\",\"responseElements.user.userId\"],\"target\":\"ocsf.user.uid\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map userName to ocsf.user.name\",\"sources\":[\"requestParameters.userName\",\"responseElements.role.roleName\",\"requestParameters.roleName\",\"responseElements.user.userName\"],\"target\":\"ocsf.user.name\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map api to ocsf.api\",\"sources\":[\"api\"],\"target\":\"ocsf.api\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map user to ocsf.user\",\"sources\":[\"user\"],\"target\":\"ocsf.user\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map actor to ocsf.actor\",\"sources\":[\"actor\"],\"target\":\"ocsf.actor\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map cloud to ocsf.cloud\",\"sources\":[\"cloud\"],\"target\":\"ocsf.cloud\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map http_request to ocsf.http_request\",\"sources\":[\"http_request\"],\"target\":\"ocsf.http_request\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map metadata to ocsf.metadata\",\"sources\":[\"metadata\"],\"target\":\"ocsf.metadata\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map time to ocsf.time\",\"sources\":[\"time\"],\"target\":\"ocsf.time\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map src_endpoint to ocsf.src_endpoint\",\"sources\":[\"src_endpoint\"],\"target\":\"ocsf.src_endpoint\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map severity to ocsf.severity\",\"sources\":[\"severity\"],\"target\":\"ocsf.severity\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"},{\"name\":\"Map severity_id to ocsf.severity_id\",\"sources\":[\"severity_id\"],\"target\":\"ocsf.severity_id\",\"preserve_source\":false,\"override_on_conflict\":false,\"type\":\"schema-remapper\"}],\"schema\":{\"schema_type\":\"ocsf\",\"version\":\"1.5.0\",\"class_name\":\"Account Change\",\"class_uid\":3001,\"extensions\":[],\"profiles\":[\"cloud\",\"datetime\"]},\"type\":\"schema-processor\"}],\"tags\":[]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "6426e129-050e-a85b-56f4-8ca515bfbcc8" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/logs/config/pipelines/1unf0vMNQKSSwzsg6BuWMw", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "cb55958d-5612-352d-4a6b-bf1fc8e94391" + } +] \ 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 cdb150dd6ed..5f7dde5db67 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 @@ -77,6 +77,20 @@ Feature: Logs Pipelines When the request is sent Then the response status is 200 OK + @team:DataDog/event-platform-experience + Scenario: Create a pipeline with Schema Processor and preserve_source false returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testSchemaProcessor", "processors": [{"type": "schema-processor", "is_enabled": true, "name": "Apply OCSF schema for 3001", "schema": {"schema_type": "ocsf", "version": "1.5.0", "class_uid": 3001, "class_name": "Account Change", "profiles": ["cloud", "datetime"]}, "mappers": [{"type": "schema-category-mapper", "name": "activity_id and activity_name", "categories": [{"filter": {"query": "@eventName:(*Create*)"}, "name": "Create", "id": 1}, {"filter": {"query": "@eventName:(ChangePassword OR PasswordUpdated)"}, "name": "Password Change", "id": 3}, {"filter": {"query": "@eventName:(*Attach*)"}, "name": "Attach Policy", "id": 7}, {"filter": {"query": "@eventName:(*Detach* OR *Remove*)"}, "name": "Detach Policy", "id": 8}, {"filter": {"query": "@eventName:(*Delete*)"}, "name": "Delete", "id": 6}, {"filter": {"query": "@eventName:*"}, "name": "Other", "id": 99}], "targets": {"name": "ocsf.activity_name", "id": "ocsf.activity_id"}, "fallback": {"values": {"ocsf.activity_id": "99", "ocsf.activity_name": "Other"}, "sources": {"ocsf.activity_name": ["eventName"]}}}, {"type": "schema-category-mapper", "name": "status", "categories": [{"filter": {"query": "-@errorCode:*"}, "id": 1, "name": "Success"}, {"filter": {"query": "@errorCode:*"}, "id": 2, "name": "Failure"}], "targets": {"id": "ocsf.status_id", "name": "ocsf.status"}}, {"type": "schema-category-mapper", "name": "Set default severity", "categories": [{"filter": {"query": "@eventName:*"}, "name": "Informational", "id": 1}], "targets": {"name": "ocsf.severity", "id": "ocsf.severity_id"}}, {"type": "schema-remapper", "name": "Map userIdentity to ocsf.user.uid", "sources": ["userIdentity.principalId", "responseElements.role.roleId", "responseElements.user.userId"], "target": "ocsf.user.uid", "preserve_source": false}, {"type": "schema-remapper", "name": "Map userName to ocsf.user.name", "sources": ["requestParameters.userName", "responseElements.role.roleName", "requestParameters.roleName", "responseElements.user.userName"], "target": "ocsf.user.name", "preserve_source": false}, {"type": "schema-remapper", "name": "Map api to ocsf.api", "sources": ["api"], "target": "ocsf.api", "preserve_source": false}, {"type": "schema-remapper", "name": "Map user to ocsf.user", "sources": ["user"], "target": "ocsf.user", "preserve_source": false}, {"type": "schema-remapper", "name": "Map actor to ocsf.actor", "sources": ["actor"], "target": "ocsf.actor", "preserve_source": false}, {"type": "schema-remapper", "name": "Map cloud to ocsf.cloud", "sources": ["cloud"], "target": "ocsf.cloud", "preserve_source": false}, {"type": "schema-remapper", "name": "Map http_request to ocsf.http_request", "sources": ["http_request"], "target": "ocsf.http_request", "preserve_source": false}, {"type": "schema-remapper", "name": "Map metadata to ocsf.metadata", "sources": ["metadata"], "target": "ocsf.metadata", "preserve_source": false}, {"type": "schema-remapper", "name": "Map time to ocsf.time", "sources": ["time"], "target": "ocsf.time", "preserve_source": false}, {"type": "schema-remapper", "name": "Map src_endpoint to ocsf.src_endpoint", "sources": ["src_endpoint"], "target": "ocsf.src_endpoint", "preserve_source": false}, {"type": "schema-remapper", "name": "Map severity to ocsf.severity", "sources": ["severity"], "target": "ocsf.severity", "preserve_source": false}, {"type": "schema-remapper", "name": "Map severity_id to ocsf.severity_id", "sources": ["severity_id"], "target": "ocsf.severity_id", "preserve_source": false}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/event-platform-experience + Scenario: Create a pipeline with Schema Processor and preserve_source true returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testSchemaProcessor", "processors": [{"type": "schema-processor", "is_enabled": true, "name": "Apply OCSF schema for 3001", "schema": {"schema_type": "ocsf", "version": "1.5.0", "class_uid": 3001, "class_name": "Account Change", "profiles": ["cloud", "datetime"]}, "mappers": [{"type": "schema-category-mapper", "name": "activity_id and activity_name", "categories": [{"filter": {"query": "@eventName:(*Create*)"}, "name": "Create", "id": 1}, {"filter": {"query": "@eventName:(ChangePassword OR PasswordUpdated)"}, "name": "Password Change", "id": 3}, {"filter": {"query": "@eventName:(*Attach*)"}, "name": "Attach Policy", "id": 7}, {"filter": {"query": "@eventName:(*Detach* OR *Remove*)"}, "name": "Detach Policy", "id": 8}, {"filter": {"query": "@eventName:(*Delete*)"}, "name": "Delete", "id": 6}, {"filter": {"query": "@eventName:*"}, "name": "Other", "id": 99}], "targets": {"name": "ocsf.activity_name", "id": "ocsf.activity_id"}, "fallback": {"values": {"ocsf.activity_id": "99", "ocsf.activity_name": "Other"}, "sources": {"ocsf.activity_name": ["eventName"]}}}, {"type": "schema-category-mapper", "name": "status", "categories": [{"filter": {"query": "-@errorCode:*"}, "id": 1, "name": "Success"}, {"filter": {"query": "@errorCode:*"}, "id": 2, "name": "Failure"}], "targets": {"id": "ocsf.status_id", "name": "ocsf.status"}}, {"type": "schema-category-mapper", "name": "Set default severity", "categories": [{"filter": {"query": "@eventName:*"}, "name": "Informational", "id": 1}], "targets": {"name": "ocsf.severity", "id": "ocsf.severity_id"}}, {"type": "schema-remapper", "name": "Map userIdentity to ocsf.user.uid", "sources": ["userIdentity.principalId", "responseElements.role.roleId", "responseElements.user.userId"], "target": "ocsf.user.uid", "preserve_source": true}, {"type": "schema-remapper", "name": "Map userName to ocsf.user.name", "sources": ["requestParameters.userName", "responseElements.role.roleName", "requestParameters.roleName", "responseElements.user.userName"], "target": "ocsf.user.name", "preserve_source": true}, {"type": "schema-remapper", "name": "Map api to ocsf.api", "sources": ["api"], "target": "ocsf.api", "preserve_source": true}, {"type": "schema-remapper", "name": "Map user to ocsf.user", "sources": ["user"], "target": "ocsf.user", "preserve_source": true}, {"type": "schema-remapper", "name": "Map actor to ocsf.actor", "sources": ["actor"], "target": "ocsf.actor", "preserve_source": true}, {"type": "schema-remapper", "name": "Map cloud to ocsf.cloud", "sources": ["cloud"], "target": "ocsf.cloud", "preserve_source": true}, {"type": "schema-remapper", "name": "Map http_request to ocsf.http_request", "sources": ["http_request"], "target": "ocsf.http_request", "preserve_source": true}, {"type": "schema-remapper", "name": "Map metadata to ocsf.metadata", "sources": ["metadata"], "target": "ocsf.metadata", "preserve_source": true}, {"type": "schema-remapper", "name": "Map time to ocsf.time", "sources": ["time"], "target": "ocsf.time", "preserve_source": true}, {"type": "schema-remapper", "name": "Map src_endpoint to ocsf.src_endpoint", "sources": ["src_endpoint"], "target": "ocsf.src_endpoint", "preserve_source": true}, {"type": "schema-remapper", "name": "Map severity to ocsf.severity", "sources": ["severity"], "target": "ocsf.severity", "preserve_source": true}, {"type": "schema-remapper", "name": "Map severity_id to ocsf.severity_id", "sources": ["severity_id"], "target": "ocsf.severity_id", "preserve_source": true}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + @team:DataDog/event-platform-experience Scenario: Create a pipeline with Span Id Remapper returns "OK" response Given new "CreateLogsPipeline" request @@ -84,6 +98,13 @@ Feature: Logs Pipelines When the request is sent Then the response status is 200 OK + @team:DataDog/event-platform-experience + Scenario: Create a pipeline with schema processor + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testSchemaProcessor", "processors": [{"type": "schema-processor", "is_enabled": true, "name": "Apply OCSF schema for 3001", "schema": {"schema_type": "ocsf", "version": "1.5.0", "class_uid": 3001, "class_name": "Account Change", "profiles": ["cloud", "datetime"]}, "mappers": [{"type": "schema-category-mapper", "name": "activity_id and activity_name", "categories": [{"filter": {"query": "@eventName:(*Create*)"}, "name": "Create", "id": 1}, {"filter": {"query": "@eventName:(ChangePassword OR PasswordUpdated)"}, "name": "Password Change", "id": 3}, {"filter": {"query": "@eventName:(*Attach*)"}, "name": "Attach Policy", "id": 7}, {"filter": {"query": "@eventName:(*Detach* OR *Remove*)"}, "name": "Detach Policy", "id": 8}, {"filter": {"query": "@eventName:(*Delete*)"}, "name": "Delete", "id": 6}, {"filter": {"query": "@eventName:*"}, "name": "Other", "id": 99}], "targets": {"name": "ocsf.activity_name", "id": "ocsf.activity_id"}, "fallback": {"values": {"ocsf.activity_id": "99", "ocsf.activity_name": "Other"}, "sources": {"ocsf.activity_name": ["eventName"]}}}, {"type": "schema-category-mapper", "name": "status", "categories": [{"filter": {"query": "-@errorCode:*"}, "id": 1, "name": "Success"}, {"filter": {"query": "@errorCode:*"}, "id": 2, "name": "Failure"}], "targets": {"id": "ocsf.status_id", "name": "ocsf.status"}}, {"type": "schema-category-mapper", "name": "Set default severity", "categories": [{"filter": {"query": "@eventName:*"}, "name": "Informational", "id": 1}], "targets": {"name": "ocsf.severity", "id": "ocsf.severity_id"}}, {"type": "schema-remapper", "name": "Map userIdentity to ocsf.user.uid", "sources": ["userIdentity.principalId", "responseElements.role.roleId", "responseElements.user.userId"], "target": "ocsf.user.uid"}, {"type": "schema-remapper", "name": "Map userName to ocsf.user.name", "sources": ["requestParameters.userName", "responseElements.role.roleName", "requestParameters.roleName", "responseElements.user.userName"], "target": "ocsf.user.name"}, {"type": "schema-remapper", "name": "Map api to ocsf.api", "sources": ["api"], "target": "ocsf.api"}, {"type": "schema-remapper", "name": "Map user to ocsf.user", "sources": ["user"], "target": "ocsf.user"}, {"type": "schema-remapper", "name": "Map actor to ocsf.actor", "sources": ["actor"], "target": "ocsf.actor"}, {"type": "schema-remapper", "name": "Map cloud to ocsf.cloud", "sources": ["cloud"], "target": "ocsf.cloud"}, {"type": "schema-remapper", "name": "Map http_request to ocsf.http_request", "sources": ["http_request"], "target": "ocsf.http_request"}, {"type": "schema-remapper", "name": "Map metadata to ocsf.metadata", "sources": ["metadata"], "target": "ocsf.metadata"}, {"type": "schema-remapper", "name": "Map time to ocsf.time", "sources": ["time"], "target": "ocsf.time"}, {"type": "schema-remapper", "name": "Map src_endpoint to ocsf.src_endpoint", "sources": ["src_endpoint"], "target": "ocsf.src_endpoint"}, {"type": "schema-remapper", "name": "Map severity to ocsf.severity", "sources": ["severity"], "target": "ocsf.severity"}, {"type": "schema-remapper", "name": "Map severity_id to ocsf.severity_id", "sources": ["severity_id"], "target": "ocsf.severity_id"}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/event-platform-experience Scenario: Delete a pipeline returns "Bad Request" response Given new "DeleteLogsPipeline" request