Skip to content

Pavel.kim/k9 add decoder processor to public api #787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .generated-info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"spec_repo_commit": "f2ae7eb",
"generated": "2025-07-17 19:58:01.335"
"spec_repo_commit": "98aea43",
"generated": "2025-07-17 21:18:05.456"
}
67 changes: 67 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5547,6 +5547,72 @@ components:
type: string
x-enum-varnames:
- DATE_REMAPPER
LogsDecoderProcessor:
description: 'The decoder processor decodes any source attribute containing
a

base64/base16-encoded UTF-8/ASCII string back to its original value, storing
the

result in a target attribute.'
properties:
binary_to_text_encoding:
$ref: '#/components/schemas/LogsDecoderProcessorBinaryToTextEncoding'
input_representation:
$ref: '#/components/schemas/LogsDecoderProcessorInputRepresentation'
is_enabled:
default: false
description: Whether the processor is enabled.
type: boolean
name:
description: Name of the processor.
type: string
source:
description: Name of the log attribute with the encoded data.
example: encoded_message
type: string
target:
description: Name of the log attribute that contains the decoded data.
example: decoded_message
type: string
type:
$ref: '#/components/schemas/LogsDecoderProcessorType'
required:
- source
- target
- binary_to_text_encoding
- input_representation
- type
type: object
LogsDecoderProcessorBinaryToTextEncoding:
description: The encoding used to represent the binary data.
enum:
- base64
- base16
example: base64
type: string
x-enum-varnames:
- BASE64
- BASE16
LogsDecoderProcessorInputRepresentation:
description: The original representation of input string.
enum:
- utf_8
- integer
example: utf_8
type: string
x-enum-varnames:
- UTF_8
- INTEGER
LogsDecoderProcessorType:
default: decoder-processor
description: Type of logs decoder processor.
enum:
- decoder-processor
example: decoder-processor
type: string
x-enum-varnames:
- DECODER_PROCESSOR
LogsExclusion:
description: Represents the index exclusion filter object from configuration
API.
Expand Down Expand Up @@ -6215,6 +6281,7 @@ components:
- $ref: '#/components/schemas/LogsTraceRemapper'
- $ref: '#/components/schemas/LogsSpanRemapper'
- $ref: '#/components/schemas/LogsArrayProcessor'
- $ref: '#/components/schemas/LogsDecoderProcessor'
LogsQueryCompute:
description: Define computation for a log query.
properties:
Expand Down
36 changes: 36 additions & 0 deletions examples/v1_logs-pipelines_CreateLogsPipeline_3336967838.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Create a pipeline with Decoder Processor returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_logs_pipelines::LogsPipelinesAPI;
use datadog_api_client::datadogV1::model::LogsDecoderProcessor;
use datadog_api_client::datadogV1::model::LogsDecoderProcessorBinaryToTextEncoding;
use datadog_api_client::datadogV1::model::LogsDecoderProcessorInputRepresentation;
use datadog_api_client::datadogV1::model::LogsDecoderProcessorType;
use datadog_api_client::datadogV1::model::LogsFilter;
use datadog_api_client::datadogV1::model::LogsPipeline;
use datadog_api_client::datadogV1::model::LogsProcessor;

#[tokio::main]
async fn main() {
let body = LogsPipeline::new("testDecoderProcessor".to_string())
.filter(LogsFilter::new().query("source:python".to_string()))
.processors(vec![LogsProcessor::LogsDecoderProcessor(Box::new(
LogsDecoderProcessor::new(
LogsDecoderProcessorBinaryToTextEncoding::BASE16,
LogsDecoderProcessorInputRepresentation::UTF_8,
"encoded_message".to_string(),
"decoded_message".to_string(),
LogsDecoderProcessorType::DECODER_PROCESSOR,
)
.is_enabled(true)
.name("test_decoder".to_string()),
))])
.tags(vec![]);
let configuration = datadog::Configuration::new();
let api = LogsPipelinesAPI::with_config(configuration);
let resp = api.create_logs_pipeline(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
8 changes: 8 additions & 0 deletions src/datadogV1/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,14 @@ pub mod model_logs_array_processor_operation;
pub use self::model_logs_array_processor_operation::LogsArrayProcessorOperation;
pub mod model_logs_array_processor_type;
pub use self::model_logs_array_processor_type::LogsArrayProcessorType;
pub mod model_logs_decoder_processor;
pub use self::model_logs_decoder_processor::LogsDecoderProcessor;
pub mod model_logs_decoder_processor_binary_to_text_encoding;
pub use self::model_logs_decoder_processor_binary_to_text_encoding::LogsDecoderProcessorBinaryToTextEncoding;
pub mod model_logs_decoder_processor_input_representation;
pub use self::model_logs_decoder_processor_input_representation::LogsDecoderProcessorInputRepresentation;
pub mod model_logs_decoder_processor_type;
pub use self::model_logs_decoder_processor_type::LogsDecoderProcessorType;
pub mod model_logs_processor;
pub use self::model_logs_processor::LogsProcessor;
pub mod model_logs_pipeline_processor_type;
Expand Down
206 changes: 206 additions & 0 deletions src/datadogV1/model/model_logs_decoder_processor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.
use serde::de::{Error, MapAccess, Visitor};
use serde::{Deserialize, Deserializer, Serialize};
use serde_with::skip_serializing_none;
use std::fmt::{self, Formatter};

/// The decoder processor decodes any source attribute containing a
/// base64/base16-encoded UTF-8/ASCII string back to its original value, storing the
/// result in a target attribute.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct LogsDecoderProcessor {
/// The encoding used to represent the binary data.
#[serde(rename = "binary_to_text_encoding")]
pub binary_to_text_encoding: crate::datadogV1::model::LogsDecoderProcessorBinaryToTextEncoding,
/// The original representation of input string.
#[serde(rename = "input_representation")]
pub input_representation: crate::datadogV1::model::LogsDecoderProcessorInputRepresentation,
/// Whether the processor is enabled.
#[serde(rename = "is_enabled")]
pub is_enabled: Option<bool>,
/// Name of the processor.
#[serde(rename = "name")]
pub name: Option<String>,
/// Name of the log attribute with the encoded data.
#[serde(rename = "source")]
pub source: String,
/// Name of the log attribute that contains the decoded data.
#[serde(rename = "target")]
pub target: String,
/// Type of logs decoder processor.
#[serde(rename = "type")]
pub type_: crate::datadogV1::model::LogsDecoderProcessorType,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl LogsDecoderProcessor {
pub fn new(
binary_to_text_encoding: crate::datadogV1::model::LogsDecoderProcessorBinaryToTextEncoding,
input_representation: crate::datadogV1::model::LogsDecoderProcessorInputRepresentation,
source: String,
target: String,
type_: crate::datadogV1::model::LogsDecoderProcessorType,
) -> LogsDecoderProcessor {
LogsDecoderProcessor {
binary_to_text_encoding,
input_representation,
is_enabled: None,
name: None,
source,
target,
type_,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn is_enabled(mut self, value: bool) -> Self {
self.is_enabled = Some(value);
self
}

pub fn name(mut self, value: String) -> Self {
self.name = Some(value);
self
}

pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
) -> Self {
self.additional_properties = value;
self
}
}

impl<'de> Deserialize<'de> for LogsDecoderProcessor {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct LogsDecoderProcessorVisitor;
impl<'a> Visitor<'a> for LogsDecoderProcessorVisitor {
type Value = LogsDecoderProcessor;

fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("a mapping")
}

fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'a>,
{
let mut binary_to_text_encoding: Option<
crate::datadogV1::model::LogsDecoderProcessorBinaryToTextEncoding,
> = None;
let mut input_representation: Option<
crate::datadogV1::model::LogsDecoderProcessorInputRepresentation,
> = None;
let mut is_enabled: Option<bool> = None;
let mut name: Option<String> = None;
let mut source: Option<String> = None;
let mut target: Option<String> = None;
let mut type_: Option<crate::datadogV1::model::LogsDecoderProcessorType> = None;
let mut additional_properties: std::collections::BTreeMap<
String,
serde_json::Value,
> = std::collections::BTreeMap::new();
let mut _unparsed = false;

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"binary_to_text_encoding" => {
binary_to_text_encoding =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _binary_to_text_encoding) = binary_to_text_encoding {
match _binary_to_text_encoding {
crate::datadogV1::model::LogsDecoderProcessorBinaryToTextEncoding::UnparsedObject(_binary_to_text_encoding) => {
_unparsed = true;
},
_ => {}
}
}
}
"input_representation" => {
input_representation =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _input_representation) = input_representation {
match _input_representation {
crate::datadogV1::model::LogsDecoderProcessorInputRepresentation::UnparsedObject(_input_representation) => {
_unparsed = true;
},
_ => {}
}
}
}
"is_enabled" => {
if v.is_null() {
continue;
}
is_enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"name" => {
if v.is_null() {
continue;
}
name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"source" => {
source = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"target" => {
target = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"type" => {
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _type_) = type_ {
match _type_ {
crate::datadogV1::model::LogsDecoderProcessorType::UnparsedObject(_type_) => {
_unparsed = true;
},
_ => {}
}
}
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
}
}
}
}
let binary_to_text_encoding = binary_to_text_encoding
.ok_or_else(|| M::Error::missing_field("binary_to_text_encoding"))?;
let input_representation = input_representation
.ok_or_else(|| M::Error::missing_field("input_representation"))?;
let source = source.ok_or_else(|| M::Error::missing_field("source"))?;
let target = target.ok_or_else(|| M::Error::missing_field("target"))?;
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;

let content = LogsDecoderProcessor {
binary_to_text_encoding,
input_representation,
is_enabled,
name,
source,
target,
type_,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(LogsDecoderProcessorVisitor)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[non_exhaustive]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum LogsDecoderProcessorBinaryToTextEncoding {
BASE64,
BASE16,
UnparsedObject(crate::datadog::UnparsedObject),
}

impl ToString for LogsDecoderProcessorBinaryToTextEncoding {
fn to_string(&self) -> String {
match self {
Self::BASE64 => String::from("base64"),
Self::BASE16 => String::from("base16"),
Self::UnparsedObject(v) => v.value.to_string(),
}
}
}

impl Serialize for LogsDecoderProcessorBinaryToTextEncoding {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match self {
Self::UnparsedObject(v) => v.serialize(serializer),
_ => serializer.serialize_str(self.to_string().as_str()),
}
}
}

impl<'de> Deserialize<'de> for LogsDecoderProcessorBinaryToTextEncoding {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s: String = String::deserialize(deserializer)?;
Ok(match s.as_str() {
"base64" => Self::BASE64,
"base16" => Self::BASE16,
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
value: serde_json::Value::String(s.into()),
}),
})
}
}
Loading
Loading