From cf42854c3c201520310000cb210f4e467c8ac111 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Tue, 23 Jun 2026 19:03:04 +0000 Subject: [PATCH 1/2] Regenerate client from commit 3ceeb66 of spec repo (#3458) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v1/openapi.yaml | 185 ++++++++++++++ ...y-Map-Processor-returns-OK-response.frozen | 1 + ...rray-Map-Processor-returns-OK-response.yml | 48 ++++ ...c-sub-processor-returns-OK-response.frozen | 1 + ...etic-sub-processor-returns-OK-response.yml | 49 ++++ ...y-sub-processor-returns-OK-response.frozen | 1 + ...gory-sub-processor-returns-OK-response.yml | 48 ++++ ...ve-source-false-returns-OK-response.frozen | 1 + ...serve-source-false-returns-OK-response.yml | 48 ++++ .../CreateLogsPipeline_104735144.rb | 32 +++ .../CreateLogsPipeline_1185292896.rb | 42 ++++ .../CreateLogsPipeline_2402034476.rb | 29 +++ .../CreateLogsPipeline_3996915493.rb | 38 +++ features/v1/logs_pipelines.feature | 28 +++ lib/datadog_api_client/inflector.rb | 7 + ...logs_array_map_arithmetic_sub_processor.rb | 186 ++++++++++++++ .../logs_array_map_attribute_remapper.rb | 211 ++++++++++++++++ .../logs_array_map_category_sub_processor.rb | 178 ++++++++++++++ .../v1/models/logs_array_map_processor.rb | 228 ++++++++++++++++++ .../models/logs_array_map_processor_type.rb | 26 ++ ..._array_map_string_builder_sub_processor.rb | 186 ++++++++++++++ .../v1/models/logs_array_map_sub_processor.rb | 67 +++++ .../v1/models/logs_processor.rb | 3 +- 23 files changed, 1642 insertions(+), 1 deletion(-) create mode 100644 cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.frozen create mode 100644 cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.yml create mode 100644 cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.frozen create mode 100644 cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.yml create mode 100644 cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.frozen create mode 100644 cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.yml create mode 100644 cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.frozen create mode 100644 cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.yml create mode 100644 examples/v1/logs-pipelines/CreateLogsPipeline_104735144.rb create mode 100644 examples/v1/logs-pipelines/CreateLogsPipeline_1185292896.rb create mode 100644 examples/v1/logs-pipelines/CreateLogsPipeline_2402034476.rb create mode 100644 examples/v1/logs-pipelines/CreateLogsPipeline_3996915493.rb create mode 100644 lib/datadog_api_client/v1/models/logs_array_map_arithmetic_sub_processor.rb create mode 100644 lib/datadog_api_client/v1/models/logs_array_map_attribute_remapper.rb create mode 100644 lib/datadog_api_client/v1/models/logs_array_map_category_sub_processor.rb create mode 100644 lib/datadog_api_client/v1/models/logs_array_map_processor.rb create mode 100644 lib/datadog_api_client/v1/models/logs_array_map_processor_type.rb create mode 100644 lib/datadog_api_client/v1/models/logs_array_map_string_builder_sub_processor.rb create mode 100644 lib/datadog_api_client/v1/models/logs_array_map_sub_processor.rb diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 2ba4dbf6d68b..683c28d9d2ff 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -6182,6 +6182,190 @@ components: type: string x-enum-varnames: - ARITHMETIC_PROCESSOR + LogsArrayMapArithmeticSubProcessor: + description: |- + An arithmetic sub-processor for use inside an array-map processor. + Unlike the top-level arithmetic processor, `is_enabled` is not supported. + properties: + expression: + description: Arithmetic operation to perform. + example: $sourceElem.count * 2 + type: string + is_replace_missing: + default: false + description: Replace missing attribute values with 0. + type: boolean + name: + description: Name of the sub-processor. + type: string + target: + description: Target attribute path for the result. + example: $targetElem.doubled + type: string + type: + $ref: "#/components/schemas/LogsArithmeticProcessorType" + required: + - expression + - target + - type + type: object + LogsArrayMapAttributeRemapper: + description: |- + An attribute remapper sub-processor for use inside an array-map processor. + Unlike the top-level attribute remapper, `is_enabled`, `source_type`, and + `target_type` are not supported. + properties: + name: + description: Name of the sub-processor. + type: string + override_on_conflict: + default: false + description: Override 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 attribute paths. + example: + - $sourceElem.id + items: + type: string + type: array + target: + description: Target attribute path. + example: $targetElem.uid + type: string + target_format: + $ref: "#/components/schemas/TargetFormatType" + type: + $ref: "#/components/schemas/LogsAttributeRemapperType" + required: + - sources + - target + - type + type: object + LogsArrayMapCategorySubProcessor: + description: |- + A category sub-processor for use inside an array-map processor. + Unlike the top-level category processor, `is_enabled` is not supported. + properties: + categories: + description: Array of filters to match against a log and the corresponding value to assign. + items: + $ref: "#/components/schemas/LogsCategoryProcessorCategory" + type: array + name: + description: Name of the sub-processor. + type: string + target: + description: Target attribute path for the category value. + example: $targetElem.level + type: string + type: + $ref: "#/components/schemas/LogsCategoryProcessorType" + required: + - categories + - target + - type + type: object + LogsArrayMapProcessor: + description: |- + The array-map processor transforms each element of a source array by applying + sub-processors in order and collecting the results into a target array. + Results can be written to a new array, to the source array (in-place), or to + an existing target array. Sub-processors can read from `$sourceElem.` + (object element field), bare `$sourceElem` (primitive element), or any parent + log attribute path. Sub-processors write to `$targetElem.` (object + output field) or bare `$targetElem` (primitive output). + properties: + is_enabled: + default: false + description: Whether or not the processor is enabled. + type: boolean + name: + description: Name of the processor. + type: string + preserve_source: + default: true + description: |- + When `false` and `source != target`, the source attribute is removed after + processing. Cannot be `false` when `source == target`. + type: boolean + processors: + description: |- + Sub-processors applied to each element. Allowed types: `attribute-remapper`, + `string-builder-processor`, `arithmetic-processor`, `category-processor`. + items: + $ref: "#/components/schemas/LogsArrayMapSubProcessor" + type: array + source: + description: |- + Attribute path of the source array. Elements are read-only via `$sourceElem` + inside sub-processors. + example: detail.resource.s3BucketDetails + type: string + target: + description: |- + Attribute path of the output array. Sub-processors write to `$targetElem` + (or `$targetElem.`) to build each output element. + example: ocsf.resources + type: string + type: + $ref: "#/components/schemas/LogsArrayMapProcessorType" + required: + - source + - target + - processors + - type + type: object + LogsArrayMapProcessorType: + default: array-map-processor + description: Type of logs array-map processor. + enum: + - array-map-processor + example: array-map-processor + type: string + x-enum-varnames: + - ARRAY_MAP_PROCESSOR + LogsArrayMapStringBuilderSubProcessor: + description: |- + A string builder sub-processor for use inside an array-map processor. + Unlike the top-level string builder processor, `is_enabled` is not supported. + properties: + is_replace_missing: + default: false + description: Replace missing attribute values with an empty string. + type: boolean + name: + description: Name of the sub-processor. + type: string + target: + description: Target attribute path for the result. + example: $targetElem.label + type: string + template: + description: Formula with one or more attributes and raw text. + example: item-%{$sourceElem.id} + type: string + type: + $ref: "#/components/schemas/LogsStringBuilderProcessorType" + required: + - template + - target + - type + type: object + LogsArrayMapSubProcessor: + description: |- + A sub-processor used inside an array-map processor. + Allowed types: `attribute-remapper`, `string-builder-processor`, + `arithmetic-processor`, `category-processor`. + oneOf: + - $ref: "#/components/schemas/LogsArrayMapAttributeRemapper" + - $ref: "#/components/schemas/LogsArrayMapArithmeticSubProcessor" + - $ref: "#/components/schemas/LogsArrayMapStringBuilderSubProcessor" + - $ref: "#/components/schemas/LogsArrayMapCategorySubProcessor" LogsArrayProcessor: description: |- A processor for extracting, aggregating, or transforming values from JSON arrays within your logs. @@ -7237,6 +7421,7 @@ components: - $ref: "#/components/schemas/LogsDecoderProcessor" - $ref: "#/components/schemas/LogsSchemaProcessor" - $ref: "#/components/schemas/LogsExcludeAttributeProcessor" + - $ref: "#/components/schemas/LogsArrayMapProcessor" LogsQueryCompute: description: Define computation for a log query. properties: diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.frozen b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.frozen new file mode 100644 index 000000000000..6324009397dd --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-23T13:26:57.908Z \ No newline at end of file diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.yml b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.yml new file mode 100644 index 000000000000..782a599f240b --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.yml @@ -0,0 +1,48 @@ +http_interactions: +- recorded_at: Tue, 23 Jun 2026 13:26:57 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"query":"source:python"},"name":"testPipelineArrayMap","processors":[{"is_enabled":true,"name":"map + items","preserve_source":true,"processors":[{"preserve_source":true,"sources":["$sourceElem.id"],"target":"$targetElem.uid","type":"attribute-remapper"},{"target":"$targetElem.label","template":"item-%{$sourceElem.id}","type":"string-builder-processor"}],"source":"items","target":"out","type":"array-map-processor"}],"tags":[]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines + response: + body: + encoding: UTF-8 + string: '{"id":"9R-fEK0LRyWg0HzDbM-gOg","type":"pipeline","name":"testPipelineArrayMap","is_enabled":false,"is_read_only":false,"filter":{"query":"source:python"},"processors":[{"name":"map + items","is_enabled":true,"source":"items","target":"out","processors":[{"sources":["$sourceElem.id"],"target":"$targetElem.uid","preserve_source":true,"override_on_conflict":false,"type":"attribute-remapper"},{"template":"item-%{$sourceElem.id}","target":"$targetElem.label","is_replace_missing":false,"type":"string-builder-processor"}],"preserve_source":true,"type":"array-map-processor"}],"tags":[]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Tue, 23 Jun 2026 13:26:57 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/9R-fEK0LRyWg0HzDbM-gOg + response: + body: + encoding: UTF-8 + string: '{} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.frozen b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.frozen new file mode 100644 index 000000000000..56e4aef1acfa --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-23T13:27:34.721Z \ No newline at end of file diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.yml b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.yml new file mode 100644 index 000000000000..de8f3080ac4f --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.yml @@ -0,0 +1,49 @@ +http_interactions: +- recorded_at: Tue, 23 Jun 2026 13:27:34 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"query":"source:python"},"name":"testPipelineArrayMapArithmetic","processors":[{"is_enabled":true,"name":"double + counts","processors":[{"expression":"$sourceElem.count * 2","target":"$targetElem.doubled","type":"arithmetic-processor"}],"source":"items","target":"out","type":"array-map-processor"}],"tags":[]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines + response: + body: + encoding: UTF-8 + string: '{"id":"PxfujWHYRaGCWVqVCVrBAg","type":"pipeline","name":"testPipelineArrayMapArithmetic","is_enabled":false,"is_read_only":false,"filter":{"query":"source:python"},"processors":[{"name":"double + counts","is_enabled":true,"source":"items","target":"out","processors":[{"expression":"$sourceElem.count + * 2","target":"$targetElem.doubled","is_replace_missing":false,"type":"arithmetic-processor"}],"preserve_source":true,"type":"array-map-processor"}],"tags":[]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Tue, 23 Jun 2026 13:27:34 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/PxfujWHYRaGCWVqVCVrBAg + response: + body: + encoding: UTF-8 + string: '{} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.frozen b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.frozen new file mode 100644 index 000000000000..bc38a40a89e5 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-23T13:27:55.552Z \ No newline at end of file diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.yml b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.yml new file mode 100644 index 000000000000..9a8038a0a2b2 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.yml @@ -0,0 +1,48 @@ +http_interactions: +- recorded_at: Tue, 23 Jun 2026 13:27:55 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"query":"source:python"},"name":"testPipelineArrayMapCategory","processors":[{"is_enabled":true,"name":"categorize + items","processors":[{"categories":[{"filter":{"query":"@$sourceElem.status:error"},"name":"error"},{"filter":{"query":"*"},"name":"info"}],"target":"$targetElem.level","type":"category-processor"}],"source":"items","target":"out","type":"array-map-processor"}],"tags":[]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines + response: + body: + encoding: UTF-8 + string: '{"id":"NW1Ws0rnRwWbxKdNUlBFOQ","type":"pipeline","name":"testPipelineArrayMapCategory","is_enabled":false,"is_read_only":false,"filter":{"query":"source:python"},"processors":[{"name":"categorize + items","is_enabled":true,"source":"items","target":"out","processors":[{"categories":[{"filter":{"query":"@$sourceElem.status:error"},"name":"error"},{"filter":{"query":"*"},"name":"info"}],"target":"$targetElem.level","type":"category-processor"}],"preserve_source":true,"type":"array-map-processor"}],"tags":[]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Tue, 23 Jun 2026 13:27:55 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/NW1Ws0rnRwWbxKdNUlBFOQ + response: + body: + encoding: UTF-8 + string: '{} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.frozen b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.frozen new file mode 100644 index 000000000000..4f838f02df21 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-23T13:28:15.444Z \ No newline at end of file diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.yml b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.yml new file mode 100644 index 000000000000..543abb454dd3 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.yml @@ -0,0 +1,48 @@ +http_interactions: +- recorded_at: Tue, 23 Jun 2026 13:28:15 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"query":"source:python"},"name":"testPipelineArrayMapNoPreserve","processors":[{"is_enabled":true,"name":"map + and remove source","preserve_source":false,"processors":[{"sources":["$sourceElem.id"],"target":"$targetElem.uid","type":"attribute-remapper"}],"source":"items","target":"out","type":"array-map-processor"}],"tags":[]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines + response: + body: + encoding: UTF-8 + string: '{"id":"hJXlpnp0RD68QPplvOMAcQ","type":"pipeline","name":"testPipelineArrayMapNoPreserve","is_enabled":false,"is_read_only":false,"filter":{"query":"source:python"},"processors":[{"name":"map + and remove source","is_enabled":true,"source":"items","target":"out","processors":[{"sources":["$sourceElem.id"],"target":"$targetElem.uid","preserve_source":false,"override_on_conflict":false,"type":"attribute-remapper"}],"preserve_source":false,"type":"array-map-processor"}],"tags":[]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Tue, 23 Jun 2026 13:28:15 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/hJXlpnp0RD68QPplvOMAcQ + response: + body: + encoding: UTF-8 + string: '{} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_104735144.rb b/examples/v1/logs-pipelines/CreateLogsPipeline_104735144.rb new file mode 100644 index 000000000000..7e0ca6cabaf0 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_104735144.rb @@ -0,0 +1,32 @@ +# Create a pipeline with Array Map Processor with preserve_source false returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::LogsPipelinesAPI.new + +body = DatadogAPIClient::V1::LogsPipeline.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "source:python", + }), + name: "testPipelineArrayMapNoPreserve", + processors: [ + DatadogAPIClient::V1::LogsArrayMapProcessor.new({ + type: DatadogAPIClient::V1::LogsArrayMapProcessorType::ARRAY_MAP_PROCESSOR, + is_enabled: true, + name: "map and remove source", + source: "items", + target: "out", + preserve_source: false, + processors: [ + DatadogAPIClient::V1::LogsArrayMapAttributeRemapper.new({ + type: DatadogAPIClient::V1::LogsAttributeRemapperType::ATTRIBUTE_REMAPPER, + sources: [ + "$sourceElem.id", + ], + target: "$targetElem.uid", + }), + ], + }), + ], + tags: [], +}) +p api_instance.create_logs_pipeline(body) diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_1185292896.rb b/examples/v1/logs-pipelines/CreateLogsPipeline_1185292896.rb new file mode 100644 index 000000000000..bf1526aaa6d2 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_1185292896.rb @@ -0,0 +1,42 @@ +# Create a pipeline with Array Map Processor using category sub-processor returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::LogsPipelinesAPI.new + +body = DatadogAPIClient::V1::LogsPipeline.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "source:python", + }), + name: "testPipelineArrayMapCategory", + processors: [ + DatadogAPIClient::V1::LogsArrayMapProcessor.new({ + type: DatadogAPIClient::V1::LogsArrayMapProcessorType::ARRAY_MAP_PROCESSOR, + is_enabled: true, + name: "categorize items", + source: "items", + target: "out", + processors: [ + DatadogAPIClient::V1::LogsArrayMapCategorySubProcessor.new({ + type: DatadogAPIClient::V1::LogsCategoryProcessorType::CATEGORY_PROCESSOR, + target: "$targetElem.level", + categories: [ + DatadogAPIClient::V1::LogsCategoryProcessorCategory.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "@$sourceElem.status:error", + }), + name: "error", + }), + DatadogAPIClient::V1::LogsCategoryProcessorCategory.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "*", + }), + name: "info", + }), + ], + }), + ], + }), + ], + tags: [], +}) +p api_instance.create_logs_pipeline(body) diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_2402034476.rb b/examples/v1/logs-pipelines/CreateLogsPipeline_2402034476.rb new file mode 100644 index 000000000000..b62bd4eba7d9 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_2402034476.rb @@ -0,0 +1,29 @@ +# Create a pipeline with Array Map Processor using arithmetic sub-processor returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::LogsPipelinesAPI.new + +body = DatadogAPIClient::V1::LogsPipeline.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "source:python", + }), + name: "testPipelineArrayMapArithmetic", + processors: [ + DatadogAPIClient::V1::LogsArrayMapProcessor.new({ + type: DatadogAPIClient::V1::LogsArrayMapProcessorType::ARRAY_MAP_PROCESSOR, + is_enabled: true, + name: "double counts", + source: "items", + target: "out", + processors: [ + DatadogAPIClient::V1::LogsArrayMapArithmeticSubProcessor.new({ + type: DatadogAPIClient::V1::LogsArithmeticProcessorType::ARITHMETIC_PROCESSOR, + expression: "$sourceElem.count * 2", + target: "$targetElem.doubled", + }), + ], + }), + ], + tags: [], +}) +p api_instance.create_logs_pipeline(body) diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_3996915493.rb b/examples/v1/logs-pipelines/CreateLogsPipeline_3996915493.rb new file mode 100644 index 000000000000..8a2240bf0b8a --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_3996915493.rb @@ -0,0 +1,38 @@ +# Create a pipeline with Array Map Processor returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::LogsPipelinesAPI.new + +body = DatadogAPIClient::V1::LogsPipeline.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "source:python", + }), + name: "testPipelineArrayMap", + processors: [ + DatadogAPIClient::V1::LogsArrayMapProcessor.new({ + type: DatadogAPIClient::V1::LogsArrayMapProcessorType::ARRAY_MAP_PROCESSOR, + is_enabled: true, + name: "map items", + source: "items", + target: "out", + preserve_source: true, + processors: [ + DatadogAPIClient::V1::LogsArrayMapAttributeRemapper.new({ + type: DatadogAPIClient::V1::LogsAttributeRemapperType::ATTRIBUTE_REMAPPER, + sources: [ + "$sourceElem.id", + ], + target: "$targetElem.uid", + preserve_source: true, + }), + DatadogAPIClient::V1::LogsArrayMapStringBuilderSubProcessor.new({ + type: DatadogAPIClient::V1::LogsStringBuilderProcessorType::STRING_BUILDER_PROCESSOR, + template: "item-%{$sourceElem.id}", + target: "$targetElem.label", + }), + ], + }), + ], + tags: [], +}) +p api_instance.create_logs_pipeline(body) diff --git a/features/v1/logs_pipelines.feature b/features/v1/logs_pipelines.feature index 1ab4401b0fdc..ac28f052615b 100644 --- a/features/v1/logs_pipelines.feature +++ b/features/v1/logs_pipelines.feature @@ -35,6 +35,34 @@ Feature: Logs Pipelines When the request is sent Then the response status is 200 OK + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Map Processor returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayMap", "processors": [{"type": "array-map-processor", "is_enabled": true, "name": "map items", "source": "items", "target": "out", "preserve_source": true, "processors": [{"type": "attribute-remapper", "sources": ["$sourceElem.id"], "target": "$targetElem.uid", "preserve_source": true}, {"type": "string-builder-processor", "template": "item-%{$sourceElem.id}", "target": "$targetElem.label"}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Map Processor using arithmetic sub-processor returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayMapArithmetic", "processors": [{"type": "array-map-processor", "is_enabled": true, "name": "double counts", "source": "items", "target": "out", "processors": [{"type": "arithmetic-processor", "expression": "$sourceElem.count * 2", "target": "$targetElem.doubled"}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Map Processor using category sub-processor returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayMapCategory", "processors": [{"type": "array-map-processor", "is_enabled": true, "name": "categorize items", "source": "items", "target": "out", "processors": [{"type": "category-processor", "target": "$targetElem.level", "categories": [{"filter": {"query": "@$sourceElem.status:error"}, "name": "error"}, {"filter": {"query": "*"}, "name": "info"}]}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Map Processor with preserve_source false returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayMapNoPreserve", "processors": [{"type": "array-map-processor", "is_enabled": true, "name": "map and remove source", "source": "items", "target": "out", "preserve_source": false, "processors": [{"type": "attribute-remapper", "sources": ["$sourceElem.id"], "target": "$targetElem.uid"}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + @team:DataDog/logs-onboarding Scenario: Create a pipeline with Array Processor Append Operation returns "OK" response Given new "CreateLogsPipeline" request diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 1912c3a1f419..c168f8873c02 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -282,6 +282,13 @@ def overrides "v1.logs_api_limit_reached_response" => "LogsAPILimitReachedResponse", "v1.logs_arithmetic_processor" => "LogsArithmeticProcessor", "v1.logs_arithmetic_processor_type" => "LogsArithmeticProcessorType", + "v1.logs_array_map_arithmetic_sub_processor" => "LogsArrayMapArithmeticSubProcessor", + "v1.logs_array_map_attribute_remapper" => "LogsArrayMapAttributeRemapper", + "v1.logs_array_map_category_sub_processor" => "LogsArrayMapCategorySubProcessor", + "v1.logs_array_map_processor" => "LogsArrayMapProcessor", + "v1.logs_array_map_processor_type" => "LogsArrayMapProcessorType", + "v1.logs_array_map_string_builder_sub_processor" => "LogsArrayMapStringBuilderSubProcessor", + "v1.logs_array_map_sub_processor" => "LogsArrayMapSubProcessor", "v1.logs_array_processor" => "LogsArrayProcessor", "v1.logs_array_processor_operation" => "LogsArrayProcessorOperation", "v1.logs_array_processor_operation_append" => "LogsArrayProcessorOperationAppend", diff --git a/lib/datadog_api_client/v1/models/logs_array_map_arithmetic_sub_processor.rb b/lib/datadog_api_client/v1/models/logs_array_map_arithmetic_sub_processor.rb new file mode 100644 index 000000000000..a8f33afb25c4 --- /dev/null +++ b/lib/datadog_api_client/v1/models/logs_array_map_arithmetic_sub_processor.rb @@ -0,0 +1,186 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # An arithmetic sub-processor for use inside an array-map processor. + # Unlike the top-level arithmetic processor, `is_enabled` is not supported. + class LogsArrayMapArithmeticSubProcessor + include BaseGenericModel + + # Arithmetic operation to perform. + attr_reader :expression + + # Replace missing attribute values with 0. + attr_accessor :is_replace_missing + + # Name of the sub-processor. + attr_accessor :name + + # Target attribute path for the result. + attr_reader :target + + # Type of logs arithmetic processor. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'expression' => :'expression', + :'is_replace_missing' => :'is_replace_missing', + :'name' => :'name', + :'target' => :'target', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'expression' => :'String', + :'is_replace_missing' => :'Boolean', + :'name' => :'String', + :'target' => :'String', + :'type' => :'LogsArithmeticProcessorType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::LogsArrayMapArithmeticSubProcessor` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'expression') + self.expression = attributes[:'expression'] + end + + if attributes.key?(:'is_replace_missing') + self.is_replace_missing = attributes[:'is_replace_missing'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'target') + self.target = attributes[:'target'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @expression.nil? + return false if @target.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param expression [Object] Object to be assigned + # @!visibility private + def expression=(expression) + if expression.nil? + fail ArgumentError, 'invalid value for "expression", expression cannot be nil.' + end + @expression = expression + end + + # Custom attribute writer method with validation + # @param target [Object] Object to be assigned + # @!visibility private + def target=(target) + if target.nil? + fail ArgumentError, 'invalid value for "target", target cannot be nil.' + end + @target = target + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + expression == o.expression && + is_replace_missing == o.is_replace_missing && + name == o.name && + target == o.target && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [expression, is_replace_missing, name, target, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/logs_array_map_attribute_remapper.rb b/lib/datadog_api_client/v1/models/logs_array_map_attribute_remapper.rb new file mode 100644 index 000000000000..e937833f4e58 --- /dev/null +++ b/lib/datadog_api_client/v1/models/logs_array_map_attribute_remapper.rb @@ -0,0 +1,211 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # An attribute remapper sub-processor for use inside an array-map processor. + # Unlike the top-level attribute remapper, `is_enabled`, `source_type`, and + # `target_type` are not supported. + class LogsArrayMapAttributeRemapper + include BaseGenericModel + + # Name of the sub-processor. + attr_accessor :name + + # Override the target element if already set. + attr_accessor :override_on_conflict + + # Remove or preserve the remapped source element. + attr_accessor :preserve_source + + # Array of source attribute paths. + attr_reader :sources + + # Target attribute path. + attr_reader :target + + # 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. + attr_accessor :target_format + + # Type of logs attribute remapper. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'override_on_conflict' => :'override_on_conflict', + :'preserve_source' => :'preserve_source', + :'sources' => :'sources', + :'target' => :'target', + :'target_format' => :'target_format', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'override_on_conflict' => :'Boolean', + :'preserve_source' => :'Boolean', + :'sources' => :'Array', + :'target' => :'String', + :'target_format' => :'TargetFormatType', + :'type' => :'LogsAttributeRemapperType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::LogsArrayMapAttributeRemapper` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'override_on_conflict') + self.override_on_conflict = attributes[:'override_on_conflict'] + end + + if attributes.key?(:'preserve_source') + self.preserve_source = attributes[:'preserve_source'] + end + + if attributes.key?(:'sources') + if (value = attributes[:'sources']).is_a?(Array) + self.sources = value + end + end + + if attributes.key?(:'target') + self.target = attributes[:'target'] + end + + if attributes.key?(:'target_format') + self.target_format = attributes[:'target_format'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @sources.nil? + return false if @target.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param sources [Object] Object to be assigned + # @!visibility private + def sources=(sources) + if sources.nil? + fail ArgumentError, 'invalid value for "sources", sources cannot be nil.' + end + @sources = sources + end + + # Custom attribute writer method with validation + # @param target [Object] Object to be assigned + # @!visibility private + def target=(target) + if target.nil? + fail ArgumentError, 'invalid value for "target", target cannot be nil.' + end + @target = target + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + override_on_conflict == o.override_on_conflict && + preserve_source == o.preserve_source && + sources == o.sources && + target == o.target && + target_format == o.target_format && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, override_on_conflict, preserve_source, sources, target, target_format, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/logs_array_map_category_sub_processor.rb b/lib/datadog_api_client/v1/models/logs_array_map_category_sub_processor.rb new file mode 100644 index 000000000000..760e175d3450 --- /dev/null +++ b/lib/datadog_api_client/v1/models/logs_array_map_category_sub_processor.rb @@ -0,0 +1,178 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # A category sub-processor for use inside an array-map processor. + # Unlike the top-level category processor, `is_enabled` is not supported. + class LogsArrayMapCategorySubProcessor + include BaseGenericModel + + # Array of filters to match against a log and the corresponding value to assign. + attr_reader :categories + + # Name of the sub-processor. + attr_accessor :name + + # Target attribute path for the category value. + attr_reader :target + + # Type of logs category processor. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'categories' => :'categories', + :'name' => :'name', + :'target' => :'target', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'categories' => :'Array', + :'name' => :'String', + :'target' => :'String', + :'type' => :'LogsCategoryProcessorType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::LogsArrayMapCategorySubProcessor` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'target') + self.target = attributes[:'target'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @categories.nil? + return false if @target.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param categories [Object] Object to be assigned + # @!visibility private + def categories=(categories) + if categories.nil? + fail ArgumentError, 'invalid value for "categories", categories cannot be nil.' + end + @categories = categories + end + + # Custom attribute writer method with validation + # @param target [Object] Object to be assigned + # @!visibility private + def target=(target) + if target.nil? + fail ArgumentError, 'invalid value for "target", target cannot be nil.' + end + @target = target + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + categories == o.categories && + name == o.name && + target == o.target && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [categories, name, target, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/logs_array_map_processor.rb b/lib/datadog_api_client/v1/models/logs_array_map_processor.rb new file mode 100644 index 000000000000..ca6adbeaeb82 --- /dev/null +++ b/lib/datadog_api_client/v1/models/logs_array_map_processor.rb @@ -0,0 +1,228 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # The array-map processor transforms each element of a source array by applying + # sub-processors in order and collecting the results into a target array. + # Results can be written to a new array, to the source array (in-place), or to + # an existing target array. Sub-processors can read from `$sourceElem.` + # (object element field), bare `$sourceElem` (primitive element), or any parent + # log attribute path. Sub-processors write to `$targetElem.` (object + # output field) or bare `$targetElem` (primitive output). + class LogsArrayMapProcessor + include BaseGenericModel + + # Whether or not the processor is enabled. + attr_accessor :is_enabled + + # Name of the processor. + attr_accessor :name + + # When `false` and `source != target`, the source attribute is removed after + # processing. Cannot be `false` when `source == target`. + attr_accessor :preserve_source + + # Sub-processors applied to each element. Allowed types: `attribute-remapper`, + # `string-builder-processor`, `arithmetic-processor`, `category-processor`. + attr_reader :processors + + # Attribute path of the source array. Elements are read-only via `$sourceElem` + # inside sub-processors. + attr_reader :source + + # Attribute path of the output array. Sub-processors write to `$targetElem` + # (or `$targetElem.`) to build each output element. + attr_reader :target + + # Type of logs array-map processor. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'is_enabled' => :'is_enabled', + :'name' => :'name', + :'preserve_source' => :'preserve_source', + :'processors' => :'processors', + :'source' => :'source', + :'target' => :'target', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'is_enabled' => :'Boolean', + :'name' => :'String', + :'preserve_source' => :'Boolean', + :'processors' => :'Array', + :'source' => :'String', + :'target' => :'String', + :'type' => :'LogsArrayMapProcessorType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::LogsArrayMapProcessor` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'is_enabled') + self.is_enabled = attributes[:'is_enabled'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'preserve_source') + self.preserve_source = attributes[:'preserve_source'] + end + + if attributes.key?(:'processors') + if (value = attributes[:'processors']).is_a?(Array) + self.processors = value + end + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + + if attributes.key?(:'target') + self.target = attributes[:'target'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @processors.nil? + return false if @source.nil? + return false if @target.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param processors [Object] Object to be assigned + # @!visibility private + def processors=(processors) + if processors.nil? + fail ArgumentError, 'invalid value for "processors", processors cannot be nil.' + end + @processors = processors + end + + # Custom attribute writer method with validation + # @param source [Object] Object to be assigned + # @!visibility private + def source=(source) + if source.nil? + fail ArgumentError, 'invalid value for "source", source cannot be nil.' + end + @source = source + end + + # Custom attribute writer method with validation + # @param target [Object] Object to be assigned + # @!visibility private + def target=(target) + if target.nil? + fail ArgumentError, 'invalid value for "target", target cannot be nil.' + end + @target = target + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + is_enabled == o.is_enabled && + name == o.name && + preserve_source == o.preserve_source && + processors == o.processors && + source == o.source && + target == o.target && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [is_enabled, name, preserve_source, processors, source, target, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/logs_array_map_processor_type.rb b/lib/datadog_api_client/v1/models/logs_array_map_processor_type.rb new file mode 100644 index 000000000000..76c00d0cca19 --- /dev/null +++ b/lib/datadog_api_client/v1/models/logs_array_map_processor_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # Type of logs array-map processor. + class LogsArrayMapProcessorType + include BaseEnumModel + + ARRAY_MAP_PROCESSOR = "array-map-processor".freeze + end +end diff --git a/lib/datadog_api_client/v1/models/logs_array_map_string_builder_sub_processor.rb b/lib/datadog_api_client/v1/models/logs_array_map_string_builder_sub_processor.rb new file mode 100644 index 000000000000..e912556fa6da --- /dev/null +++ b/lib/datadog_api_client/v1/models/logs_array_map_string_builder_sub_processor.rb @@ -0,0 +1,186 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # A string builder sub-processor for use inside an array-map processor. + # Unlike the top-level string builder processor, `is_enabled` is not supported. + class LogsArrayMapStringBuilderSubProcessor + include BaseGenericModel + + # Replace missing attribute values with an empty string. + attr_accessor :is_replace_missing + + # Name of the sub-processor. + attr_accessor :name + + # Target attribute path for the result. + attr_reader :target + + # Formula with one or more attributes and raw text. + attr_reader :template + + # Type of logs string builder processor. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'is_replace_missing' => :'is_replace_missing', + :'name' => :'name', + :'target' => :'target', + :'template' => :'template', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'is_replace_missing' => :'Boolean', + :'name' => :'String', + :'target' => :'String', + :'template' => :'String', + :'type' => :'LogsStringBuilderProcessorType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::LogsArrayMapStringBuilderSubProcessor` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'is_replace_missing') + self.is_replace_missing = attributes[:'is_replace_missing'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'target') + self.target = attributes[:'target'] + end + + if attributes.key?(:'template') + self.template = attributes[:'template'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @target.nil? + return false if @template.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param target [Object] Object to be assigned + # @!visibility private + def target=(target) + if target.nil? + fail ArgumentError, 'invalid value for "target", target cannot be nil.' + end + @target = target + end + + # Custom attribute writer method with validation + # @param template [Object] Object to be assigned + # @!visibility private + def template=(template) + if template.nil? + fail ArgumentError, 'invalid value for "template", template cannot be nil.' + end + @template = template + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + is_replace_missing == o.is_replace_missing && + name == o.name && + target == o.target && + template == o.template && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [is_replace_missing, name, target, template, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/logs_array_map_sub_processor.rb b/lib/datadog_api_client/v1/models/logs_array_map_sub_processor.rb new file mode 100644 index 000000000000..72e3464621b4 --- /dev/null +++ b/lib/datadog_api_client/v1/models/logs_array_map_sub_processor.rb @@ -0,0 +1,67 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # A sub-processor used inside an array-map processor. + # Allowed types: `attribute-remapper`, `string-builder-processor`, + # `arithmetic-processor`, `category-processor`. + module LogsArrayMapSubProcessor + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'LogsArrayMapAttributeRemapper', + :'LogsArrayMapArithmeticSubProcessor', + :'LogsArrayMapStringBuilderSubProcessor', + :'LogsArrayMapCategorySubProcessor' + ] + end + # Builds the object + # @param data [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end diff --git a/lib/datadog_api_client/v1/models/logs_processor.rb b/lib/datadog_api_client/v1/models/logs_processor.rb index 156f2eae4d94..fc216834c911 100644 --- a/lib/datadog_api_client/v1/models/logs_processor.rb +++ b/lib/datadog_api_client/v1/models/logs_processor.rb @@ -46,7 +46,8 @@ def openapi_one_of :'LogsArrayProcessor', :'LogsDecoderProcessor', :'LogsSchemaProcessor', - :'LogsExcludeAttributeProcessor' + :'LogsExcludeAttributeProcessor', + :'LogsArrayMapProcessor' ] end # Builds the object From ea15ac69c0daab62e976242a7d170852bebc40c2 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Tue, 23 Jun 2026 20:10:11 +0000 Subject: [PATCH 2/2] Regenerate client from commit 281891e of spec repo (#3517) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v2/openapi.yaml | 232 ++++++++++++++++++ .../CreateVariantForFeatureFlag.rb | 11 + .../DeleteVariantFromFeatureFlag.rb | 5 + .../UpdateVariantForFeatureFlag.rb | 10 + features/scenarios_model_mapping.rb | 13 + features/v2/feature_flags.feature | 100 ++++++++ features/v2/undo.json | 18 ++ lib/datadog_api_client/inflector.rb | 1 + .../v2/api/feature_flags_api.rb | 229 +++++++++++++++++ .../v2/models/update_variant_request.rb | 115 +++++++++ 10 files changed, 734 insertions(+) create mode 100644 examples/v2/feature-flags/CreateVariantForFeatureFlag.rb create mode 100644 examples/v2/feature-flags/DeleteVariantFromFeatureFlag.rb create mode 100644 examples/v2/feature-flags/UpdateVariantForFeatureFlag.rb create mode 100644 lib/datadog_api_client/v2/models/update_variant_request.rb diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 99b25f0ac87f..954f75f844f8 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1966,6 +1966,15 @@ components: example: "550e8400-e29b-41d4-a716-446655440000" format: uuid type: string + variant_id: + description: The ID of the variant. + in: path + name: variant_id + required: true + schema: + example: "550e8400-e29b-41d4-a716-446655440002" + format: uuid + type: string requestBodies: {} responses: BadRequestResponse: @@ -105626,6 +105635,18 @@ components: required: - data type: object + UpdateVariantRequest: + description: Request to update an existing variant's name and value. + properties: + name: + description: The display name of the variant. + example: "Variant ABC123 Updated" + type: string + value: + description: The value of the variant as a string. + example: "new_value" + type: string + type: object UpdateWorkflowRequest: description: A request object for updating an existing workflow. example: @@ -132923,6 +132944,217 @@ paths: permissions: - feature_flag_config_write - feature_flag_environment_config_read + /api/v2/feature-flags/{feature_flag_id}/variants: + post: + description: |- + Adds a single new variant to an existing feature flag. This endpoint is + additive-only: it never modifies existing variants. A request whose `key` + already exists on the flag is rejected with `409 Conflict`; a `value` + whose type does not match the flag's `value_type` is rejected with `400`. + The server generates the variant UUID and returns it in the response body; + callers (for example, the flag-migration tool) need this UUID to reference + the new variant in subsequent allocation syncs. + operationId: CreateVariantForFeatureFlag + parameters: + - $ref: "#/components/parameters/feature_flag_id" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + key: dark + name: Dark Theme + value: dark + type: variants + schema: + $ref: "#/components/schemas/CreateVariant" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2024-01-01T00:00:00+00:00" + key: dark + name: Dark Theme + updated_at: "2024-01-01T00:00:00+00:00" + value: dark + id: "550e8400-e29b-41d4-a716-446655440002" + type: variants + schema: + $ref: "#/components/schemas/Variant" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict - A variant with this key already exists on the flag. + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Add a variant to a feature flag + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + /api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}: + delete: + description: |- + Deletes a variant from a feature flag. + + When backend approvals are enabled and the flag requires approval, this endpoint creates and returns a `FlagSuggestion` with `201 Created` instead of deleting the variant immediately. If a pending suggestion already exists for this flag's variant property, the endpoint returns `409 Conflict`. + operationId: DeleteVariantFromFeatureFlag + parameters: + - $ref: "#/components/parameters/feature_flag_id" + - $ref: "#/components/parameters/variant_id" + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict - A pending suggestion already exists for this property. + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Delete a variant + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + put: + description: |- + Updates the name and value of an existing variant on a feature flag. + + When backend approvals are enabled and the flag requires approval, this endpoint creates and returns a `FlagSuggestion` with `201 Created` instead of applying the change immediately. Use the returned suggestion `id` to approve or reject the change. If a pending suggestion already exists for this flag's variant property, the endpoint returns `409 Conflict`. + operationId: UpdateVariantForFeatureFlag + parameters: + - $ref: "#/components/parameters/feature_flag_id" + - $ref: "#/components/parameters/variant_id" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + name: Dark Theme Updated + value: dark_v2 + id: "550e8400-e29b-41d4-a716-446655440002" + type: variants + schema: + $ref: "#/components/schemas/UpdateVariantRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2024-01-01T00:00:00+00:00" + key: dark + name: Dark Theme Updated + updated_at: "2024-06-01T00:00:00+00:00" + value: dark_v2 + id: "550e8400-e29b-41d4-a716-446655440002" + type: variants + schema: + $ref: "#/components/schemas/Variant" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict - A pending suggestion already exists for this property. + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Update a variant + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write /api/v2/forms: get: description: Get all forms for the authenticated user's organization. diff --git a/examples/v2/feature-flags/CreateVariantForFeatureFlag.rb b/examples/v2/feature-flags/CreateVariantForFeatureFlag.rb new file mode 100644 index 000000000000..02367661520f --- /dev/null +++ b/examples/v2/feature-flags/CreateVariantForFeatureFlag.rb @@ -0,0 +1,11 @@ +# Add a variant to a feature flag returns "Created" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new + +body = DatadogAPIClient::V2::CreateVariant.new({ + key: "variant-abc123", + name: "Variant ABC123", + value: "true", +}) +p api_instance.create_variant_for_feature_flag("550e8400-e29b-41d4-a716-446655440000", body) diff --git a/examples/v2/feature-flags/DeleteVariantFromFeatureFlag.rb b/examples/v2/feature-flags/DeleteVariantFromFeatureFlag.rb new file mode 100644 index 000000000000..07e1770ea9de --- /dev/null +++ b/examples/v2/feature-flags/DeleteVariantFromFeatureFlag.rb @@ -0,0 +1,5 @@ +# Delete a variant returns "No Content" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new +api_instance.delete_variant_from_feature_flag("550e8400-e29b-41d4-a716-446655440000", "550e8400-e29b-41d4-a716-446655440002") diff --git a/examples/v2/feature-flags/UpdateVariantForFeatureFlag.rb b/examples/v2/feature-flags/UpdateVariantForFeatureFlag.rb new file mode 100644 index 000000000000..a4b841bbe967 --- /dev/null +++ b/examples/v2/feature-flags/UpdateVariantForFeatureFlag.rb @@ -0,0 +1,10 @@ +# Update a variant returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new + +body = DatadogAPIClient::V2::UpdateVariantRequest.new({ + name: "Variant ABC123 Updated", + value: "new_value", +}) +p api_instance.update_variant_for_feature_flag("550e8400-e29b-41d4-a716-446655440000", "550e8400-e29b-41d4-a716-446655440002", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 8d27a626e6cf..2182ae397869 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3289,6 +3289,19 @@ "v2.UnarchiveFeatureFlag" => { "feature_flag_id" => "UUID", }, + "v2.CreateVariantForFeatureFlag" => { + "feature_flag_id" => "UUID", + "body" => "CreateVariant", + }, + "v2.DeleteVariantFromFeatureFlag" => { + "feature_flag_id" => "UUID", + "variant_id" => "UUID", + }, + "v2.UpdateVariantForFeatureFlag" => { + "feature_flag_id" => "UUID", + "variant_id" => "UUID", + "body" => "UpdateVariantRequest", + }, "v2.CreateForm" => { "body" => "CreateFormRequest", }, diff --git a/features/v2/feature_flags.feature b/features/v2/feature_flags.feature index df31d246a423..c98cd04f77ce 100644 --- a/features/v2/feature_flags.feature +++ b/features/v2/feature_flags.feature @@ -7,6 +7,38 @@ Feature: Feature Flags And a valid "appKeyAuth" key in the system And an instance of "FeatureFlags" API + @generated @skip @team:DataDog/feature-flags + Scenario: Add a variant to a feature flag returns "Bad Request" response + Given new "CreateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"key": "variant-abc123", "name": "Variant ABC123", "value": "true"} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Add a variant to a feature flag returns "Conflict - A variant with this key already exists on the flag." response + Given new "CreateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"key": "variant-abc123", "name": "Variant ABC123", "value": "true"} + When the request is sent + Then the response status is 409 Conflict - A variant with this key already exists on the flag. + + @generated @skip @team:DataDog/feature-flags + Scenario: Add a variant to a feature flag returns "Created" response + Given new "CreateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"key": "variant-abc123", "name": "Variant ABC123", "value": "true"} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/feature-flags + Scenario: Add a variant to a feature flag returns "Not Found" response + Given new "CreateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"key": "variant-abc123", "name": "Variant ABC123", "value": "true"} + When the request is sent + Then the response status is 404 Not Found + @skip @team:DataDog/feature-flags Scenario: Archive a feature flag returns "Bad Request" response Given new "ArchiveFeatureFlag" request @@ -130,6 +162,38 @@ Feature: Feature Flags When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a variant returns "Bad Request" response + Given new "DeleteVariantFromFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a variant returns "Conflict - A pending suggestion already exists for this property." response + Given new "DeleteVariantFromFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Conflict - A pending suggestion already exists for this property. + + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a variant returns "No Content" response + Given new "DeleteVariantFromFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a variant returns "Not Found" response + Given new "DeleteVariantFromFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @skip @team:DataDog/feature-flags Scenario: Delete an environment returns "No Content" response Given there is a valid "environment" in the system @@ -408,6 +472,42 @@ Feature: Feature Flags And the response "data.attributes.name" is equal to "Updated Test Feature Flag {{ unique }}" And the response "data.attributes.description" is equal to "Updated description for the feature flag" + @generated @skip @team:DataDog/feature-flags + Scenario: Update a variant returns "Bad Request" response + Given new "UpdateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + And body with value {"name": "Variant ABC123 Updated", "value": "new_value"} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Update a variant returns "Conflict - A pending suggestion already exists for this property." response + Given new "UpdateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + And body with value {"name": "Variant ABC123 Updated", "value": "new_value"} + When the request is sent + Then the response status is 409 Conflict - A pending suggestion already exists for this property. + + @generated @skip @team:DataDog/feature-flags + Scenario: Update a variant returns "Not Found" response + Given new "UpdateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + And body with value {"name": "Variant ABC123 Updated", "value": "new_value"} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/feature-flags + Scenario: Update a variant returns "OK" response + Given new "UpdateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + And body with value {"name": "Variant ABC123 Updated", "value": "new_value"} + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/feature-flags Scenario: Update an environment returns "Bad Request" response Given new "UpdateFeatureFlagsEnvironment" request diff --git a/features/v2/undo.json b/features/v2/undo.json index a5c43f6c0f2c..b0dab3582baa 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -2675,6 +2675,24 @@ "type": "unsafe" } }, + "CreateVariantForFeatureFlag": { + "tag": "Feature Flags", + "undo": { + "type": "unsafe" + } + }, + "DeleteVariantFromFeatureFlag": { + "tag": "Feature Flags", + "undo": { + "type": "unsafe" + } + }, + "UpdateVariantForFeatureFlag": { + "tag": "Feature Flags", + "undo": { + "type": "idempotent" + } + }, "ListForms": { "tag": "Forms", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index c168f8873c02..d57b2ab2d09d 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -7572,6 +7572,7 @@ def overrides "v2.update_tenancy_config_data_attributes_regions_config" => "UpdateTenancyConfigDataAttributesRegionsConfig", "v2.update_tenancy_config_data_type" => "UpdateTenancyConfigDataType", "v2.update_tenancy_config_request" => "UpdateTenancyConfigRequest", + "v2.update_variant_request" => "UpdateVariantRequest", "v2.update_workflow_request" => "UpdateWorkflowRequest", "v2.update_workflow_response" => "UpdateWorkflowResponse", "v2.upsert_allocation_request" => "UpsertAllocationRequest", diff --git a/lib/datadog_api_client/v2/api/feature_flags_api.rb b/lib/datadog_api_client/v2/api/feature_flags_api.rb index 95979845b986..b00356c8ee82 100644 --- a/lib/datadog_api_client/v2/api/feature_flags_api.rb +++ b/lib/datadog_api_client/v2/api/feature_flags_api.rb @@ -300,6 +300,84 @@ def create_feature_flags_environment_with_http_info(body, opts = {}) return data, status_code, headers end + # Add a variant to a feature flag. + # + # @see #create_variant_for_feature_flag_with_http_info + def create_variant_for_feature_flag(feature_flag_id, body, opts = {}) + data, _status_code, _headers = create_variant_for_feature_flag_with_http_info(feature_flag_id, body, opts) + data + end + + # Add a variant to a feature flag. + # + # Adds a single new variant to an existing feature flag. This endpoint is + # additive-only: it never modifies existing variants. A request whose `key` + # already exists on the flag is rejected with `409 Conflict`; a `value` + # whose type does not match the flag's `value_type` is rejected with `400`. + # The server generates the variant UUID and returns it in the response body; + # callers (for example, the flag-migration tool) need this UUID to reference + # the new variant in subsequent allocation syncs. + # + # @param feature_flag_id [UUID] The ID of the feature flag. + # @param body [CreateVariant] + # @param opts [Hash] the optional parameters + # @return [Array<(Variant, Integer, Hash)>] Variant data, response status code and response headers + def create_variant_for_feature_flag_with_http_info(feature_flag_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.create_variant_for_feature_flag ...' + end + # verify the required parameter 'feature_flag_id' is set + if @api_client.config.client_side_validation && feature_flag_id.nil? + fail ArgumentError, "Missing the required parameter 'feature_flag_id' when calling FeatureFlagsAPI.create_variant_for_feature_flag" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling FeatureFlagsAPI.create_variant_for_feature_flag" + end + # resource path + local_var_path = '/api/v2/feature-flags/{feature_flag_id}/variants'.sub('{feature_flag_id}', CGI.escape(feature_flag_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'Variant' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_variant_for_feature_flag, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#create_variant_for_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete an environment. # # @see #delete_feature_flags_environment_with_http_info @@ -365,6 +443,78 @@ def delete_feature_flags_environment_with_http_info(environment_id, opts = {}) return data, status_code, headers end + # Delete a variant. + # + # @see #delete_variant_from_feature_flag_with_http_info + def delete_variant_from_feature_flag(feature_flag_id, variant_id, opts = {}) + delete_variant_from_feature_flag_with_http_info(feature_flag_id, variant_id, opts) + nil + end + + # Delete a variant. + # + # Deletes a variant from a feature flag. + # + # When backend approvals are enabled and the flag requires approval, this endpoint creates and returns a `FlagSuggestion` with `201 Created` instead of deleting the variant immediately. If a pending suggestion already exists for this flag's variant property, the endpoint returns `409 Conflict`. + # + # @param feature_flag_id [UUID] The ID of the feature flag. + # @param variant_id [UUID] The ID of the variant. + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_variant_from_feature_flag_with_http_info(feature_flag_id, variant_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.delete_variant_from_feature_flag ...' + end + # verify the required parameter 'feature_flag_id' is set + if @api_client.config.client_side_validation && feature_flag_id.nil? + fail ArgumentError, "Missing the required parameter 'feature_flag_id' when calling FeatureFlagsAPI.delete_variant_from_feature_flag" + end + # verify the required parameter 'variant_id' is set + if @api_client.config.client_side_validation && variant_id.nil? + fail ArgumentError, "Missing the required parameter 'variant_id' when calling FeatureFlagsAPI.delete_variant_from_feature_flag" + end + # resource path + local_var_path = '/api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}'.sub('{feature_flag_id}', CGI.escape(feature_flag_id.to_s).gsub('%2F', '/')).sub('{variant_id}', CGI.escape(variant_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :delete_variant_from_feature_flag, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#delete_variant_from_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Disable a feature flag in an environment. # # @see #disable_feature_flag_environment_with_http_info @@ -1341,5 +1491,84 @@ def update_feature_flags_environment_with_http_info(environment_id, body, opts = end return data, status_code, headers end + + # Update a variant. + # + # @see #update_variant_for_feature_flag_with_http_info + def update_variant_for_feature_flag(feature_flag_id, variant_id, body, opts = {}) + data, _status_code, _headers = update_variant_for_feature_flag_with_http_info(feature_flag_id, variant_id, body, opts) + data + end + + # Update a variant. + # + # Updates the name and value of an existing variant on a feature flag. + # + # When backend approvals are enabled and the flag requires approval, this endpoint creates and returns a `FlagSuggestion` with `201 Created` instead of applying the change immediately. Use the returned suggestion `id` to approve or reject the change. If a pending suggestion already exists for this flag's variant property, the endpoint returns `409 Conflict`. + # + # @param feature_flag_id [UUID] The ID of the feature flag. + # @param variant_id [UUID] The ID of the variant. + # @param body [UpdateVariantRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(Variant, Integer, Hash)>] Variant data, response status code and response headers + def update_variant_for_feature_flag_with_http_info(feature_flag_id, variant_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.update_variant_for_feature_flag ...' + end + # verify the required parameter 'feature_flag_id' is set + if @api_client.config.client_side_validation && feature_flag_id.nil? + fail ArgumentError, "Missing the required parameter 'feature_flag_id' when calling FeatureFlagsAPI.update_variant_for_feature_flag" + end + # verify the required parameter 'variant_id' is set + if @api_client.config.client_side_validation && variant_id.nil? + fail ArgumentError, "Missing the required parameter 'variant_id' when calling FeatureFlagsAPI.update_variant_for_feature_flag" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling FeatureFlagsAPI.update_variant_for_feature_flag" + end + # resource path + local_var_path = '/api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}'.sub('{feature_flag_id}', CGI.escape(feature_flag_id.to_s).gsub('%2F', '/')).sub('{variant_id}', CGI.escape(variant_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'Variant' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :update_variant_for_feature_flag, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Put, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#update_variant_for_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/datadog_api_client/v2/models/update_variant_request.rb b/lib/datadog_api_client/v2/models/update_variant_request.rb new file mode 100644 index 000000000000..3a80b65f6244 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_variant_request.rb @@ -0,0 +1,115 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Request to update an existing variant's name and value. + class UpdateVariantRequest + include BaseGenericModel + + # The display name of the variant. + attr_accessor :name + + # The value of the variant as a string. + attr_accessor :value + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'value' => :'value' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'value' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateVariantRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + value == o.value && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, value, additional_properties].hash + end + end +end