Skip to content

Commit 933354a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Google PubSub destination to the Observability Pipelines API (#925)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 4fc57df commit 933354a

6 files changed

+380
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30324,6 +30324,7 @@ components:
3032430324
- $ref: '#/components/schemas/ObservabilityPipelineSocketDestination'
3032530325
- $ref: '#/components/schemas/ObservabilityPipelineAmazonSecurityLakeDestination'
3032630326
- $ref: '#/components/schemas/ObservabilityPipelineCrowdStrikeNextGenSiemDestination'
30327+
- $ref: '#/components/schemas/ObservabilityPipelineGooglePubSubDestination'
3032730328
ObservabilityPipelineConfigProcessorItem:
3032830329
description: A processor for the pipeline.
3032930330
oneOf:
@@ -31385,6 +31386,65 @@ components:
3138531386
type: string
3138631387
x-enum-varnames:
3138731388
- GOOGLE_CLOUD_STORAGE
31389+
ObservabilityPipelineGooglePubSubDestination:
31390+
description: The `google_pubsub` destination publishes logs to a Google Cloud
31391+
Pub/Sub topic.
31392+
properties:
31393+
auth:
31394+
$ref: '#/components/schemas/ObservabilityPipelineGcpAuth'
31395+
encoding:
31396+
$ref: '#/components/schemas/ObservabilityPipelineGooglePubSubDestinationEncoding'
31397+
id:
31398+
description: The unique identifier for this component.
31399+
example: google-pubsub-destination
31400+
type: string
31401+
inputs:
31402+
description: A list of component IDs whose output is used as the `input`
31403+
for this component.
31404+
example:
31405+
- filter-processor
31406+
items:
31407+
type: string
31408+
type: array
31409+
project:
31410+
description: The GCP project ID that owns the Pub/Sub topic.
31411+
example: my-gcp-project
31412+
type: string
31413+
tls:
31414+
$ref: '#/components/schemas/ObservabilityPipelineTls'
31415+
topic:
31416+
description: The Pub/Sub topic name to publish logs to.
31417+
example: logs-subscription
31418+
type: string
31419+
type:
31420+
$ref: '#/components/schemas/ObservabilityPipelineGooglePubSubDestinationType'
31421+
required:
31422+
- id
31423+
- type
31424+
- inputs
31425+
- encoding
31426+
- project
31427+
- topic
31428+
type: object
31429+
ObservabilityPipelineGooglePubSubDestinationEncoding:
31430+
description: Encoding format for log events.
31431+
enum:
31432+
- json
31433+
- raw_message
31434+
example: json
31435+
type: string
31436+
x-enum-varnames:
31437+
- JSON
31438+
- RAW_MESSAGE
31439+
ObservabilityPipelineGooglePubSubDestinationType:
31440+
default: google_pubsub
31441+
description: The destination type. The value should always be `google_pubsub`.
31442+
enum:
31443+
- google_pubsub
31444+
example: google_pubsub
31445+
type: string
31446+
x-enum-varnames:
31447+
- GOOGLE_PUBSUB
3138831448
ObservabilityPipelineGooglePubSubSource:
3138931449
description: The `google_pubsub` source ingests logs from a Google Cloud Pub/Sub
3139031450
subscription.

src/datadogV2/model/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4368,6 +4368,12 @@ pub mod model_observability_pipeline_crowd_strike_next_gen_siem_destination_enco
43684368
pub use self::model_observability_pipeline_crowd_strike_next_gen_siem_destination_encoding::ObservabilityPipelineCrowdStrikeNextGenSiemDestinationEncoding;
43694369
pub mod model_observability_pipeline_crowd_strike_next_gen_siem_destination_type;
43704370
pub use self::model_observability_pipeline_crowd_strike_next_gen_siem_destination_type::ObservabilityPipelineCrowdStrikeNextGenSiemDestinationType;
4371+
pub mod model_observability_pipeline_google_pub_sub_destination;
4372+
pub use self::model_observability_pipeline_google_pub_sub_destination::ObservabilityPipelineGooglePubSubDestination;
4373+
pub mod model_observability_pipeline_google_pub_sub_destination_encoding;
4374+
pub use self::model_observability_pipeline_google_pub_sub_destination_encoding::ObservabilityPipelineGooglePubSubDestinationEncoding;
4375+
pub mod model_observability_pipeline_google_pub_sub_destination_type;
4376+
pub use self::model_observability_pipeline_google_pub_sub_destination_type::ObservabilityPipelineGooglePubSubDestinationType;
43714377
pub mod model_observability_pipeline_config_destination_item;
43724378
pub use self::model_observability_pipeline_config_destination_item::ObservabilityPipelineConfigDestinationItem;
43734379
pub mod model_observability_pipeline_filter_processor;

src/datadogV2/model/model_observability_pipeline_config_destination_item.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ pub enum ObservabilityPipelineConfigDestinationItem {
5858
ObservabilityPipelineCrowdStrikeNextGenSiemDestination(
5959
Box<crate::datadogV2::model::ObservabilityPipelineCrowdStrikeNextGenSiemDestination>,
6060
),
61+
ObservabilityPipelineGooglePubSubDestination(
62+
Box<crate::datadogV2::model::ObservabilityPipelineGooglePubSubDestination>,
63+
),
6164
UnparsedObject(crate::datadog::UnparsedObject),
6265
}
6366

@@ -213,6 +216,14 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineConfigDestinationItem {
213216
return Ok(ObservabilityPipelineConfigDestinationItem::ObservabilityPipelineCrowdStrikeNextGenSiemDestination(_v));
214217
}
215218
}
219+
if let Ok(_v) = serde_json::from_value::<
220+
Box<crate::datadogV2::model::ObservabilityPipelineGooglePubSubDestination>,
221+
>(value.clone())
222+
{
223+
if !_v._unparsed {
224+
return Ok(ObservabilityPipelineConfigDestinationItem::ObservabilityPipelineGooglePubSubDestination(_v));
225+
}
226+
}
216227

217228
return Ok(ObservabilityPipelineConfigDestinationItem::UnparsedObject(
218229
crate::datadog::UnparsedObject { value },
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
use serde::de::{Error, MapAccess, Visitor};
5+
use serde::{Deserialize, Deserializer, Serialize};
6+
use serde_with::skip_serializing_none;
7+
use std::fmt::{self, Formatter};
8+
9+
/// The `google_pubsub` destination publishes logs to a Google Cloud Pub/Sub topic.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct ObservabilityPipelineGooglePubSubDestination {
14+
/// GCP credentials used to authenticate with Google Cloud Storage.
15+
///
16+
#[serde(rename = "auth")]
17+
pub auth: Option<crate::datadogV2::model::ObservabilityPipelineGcpAuth>,
18+
/// Encoding format for log events.
19+
#[serde(rename = "encoding")]
20+
pub encoding: crate::datadogV2::model::ObservabilityPipelineGooglePubSubDestinationEncoding,
21+
/// The unique identifier for this component.
22+
#[serde(rename = "id")]
23+
pub id: String,
24+
/// A list of component IDs whose output is used as the `input` for this component.
25+
#[serde(rename = "inputs")]
26+
pub inputs: Vec<String>,
27+
/// The GCP project ID that owns the Pub/Sub topic.
28+
#[serde(rename = "project")]
29+
pub project: String,
30+
/// Configuration for enabling TLS encryption between the pipeline component and external services.
31+
#[serde(rename = "tls")]
32+
pub tls: Option<crate::datadogV2::model::ObservabilityPipelineTls>,
33+
/// The Pub/Sub topic name to publish logs to.
34+
#[serde(rename = "topic")]
35+
pub topic: String,
36+
/// The destination type. The value should always be `google_pubsub`.
37+
#[serde(rename = "type")]
38+
pub type_: crate::datadogV2::model::ObservabilityPipelineGooglePubSubDestinationType,
39+
#[serde(flatten)]
40+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
41+
#[serde(skip)]
42+
#[serde(default)]
43+
pub(crate) _unparsed: bool,
44+
}
45+
46+
impl ObservabilityPipelineGooglePubSubDestination {
47+
pub fn new(
48+
encoding: crate::datadogV2::model::ObservabilityPipelineGooglePubSubDestinationEncoding,
49+
id: String,
50+
inputs: Vec<String>,
51+
project: String,
52+
topic: String,
53+
type_: crate::datadogV2::model::ObservabilityPipelineGooglePubSubDestinationType,
54+
) -> ObservabilityPipelineGooglePubSubDestination {
55+
ObservabilityPipelineGooglePubSubDestination {
56+
auth: None,
57+
encoding,
58+
id,
59+
inputs,
60+
project,
61+
tls: None,
62+
topic,
63+
type_,
64+
additional_properties: std::collections::BTreeMap::new(),
65+
_unparsed: false,
66+
}
67+
}
68+
69+
pub fn auth(mut self, value: crate::datadogV2::model::ObservabilityPipelineGcpAuth) -> Self {
70+
self.auth = Some(value);
71+
self
72+
}
73+
74+
pub fn tls(mut self, value: crate::datadogV2::model::ObservabilityPipelineTls) -> Self {
75+
self.tls = Some(value);
76+
self
77+
}
78+
79+
pub fn additional_properties(
80+
mut self,
81+
value: std::collections::BTreeMap<String, serde_json::Value>,
82+
) -> Self {
83+
self.additional_properties = value;
84+
self
85+
}
86+
}
87+
88+
impl<'de> Deserialize<'de> for ObservabilityPipelineGooglePubSubDestination {
89+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
90+
where
91+
D: Deserializer<'de>,
92+
{
93+
struct ObservabilityPipelineGooglePubSubDestinationVisitor;
94+
impl<'a> Visitor<'a> for ObservabilityPipelineGooglePubSubDestinationVisitor {
95+
type Value = ObservabilityPipelineGooglePubSubDestination;
96+
97+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
98+
f.write_str("a mapping")
99+
}
100+
101+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
102+
where
103+
M: MapAccess<'a>,
104+
{
105+
let mut auth: Option<crate::datadogV2::model::ObservabilityPipelineGcpAuth> = None;
106+
let mut encoding: Option<
107+
crate::datadogV2::model::ObservabilityPipelineGooglePubSubDestinationEncoding,
108+
> = None;
109+
let mut id: Option<String> = None;
110+
let mut inputs: Option<Vec<String>> = None;
111+
let mut project: Option<String> = None;
112+
let mut tls: Option<crate::datadogV2::model::ObservabilityPipelineTls> = None;
113+
let mut topic: Option<String> = None;
114+
let mut type_: Option<
115+
crate::datadogV2::model::ObservabilityPipelineGooglePubSubDestinationType,
116+
> = None;
117+
let mut additional_properties: std::collections::BTreeMap<
118+
String,
119+
serde_json::Value,
120+
> = std::collections::BTreeMap::new();
121+
let mut _unparsed = false;
122+
123+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
124+
match k.as_str() {
125+
"auth" => {
126+
if v.is_null() {
127+
continue;
128+
}
129+
auth = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
130+
}
131+
"encoding" => {
132+
encoding = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
133+
if let Some(ref _encoding) = encoding {
134+
match _encoding {
135+
crate::datadogV2::model::ObservabilityPipelineGooglePubSubDestinationEncoding::UnparsedObject(_encoding) => {
136+
_unparsed = true;
137+
},
138+
_ => {}
139+
}
140+
}
141+
}
142+
"id" => {
143+
id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
144+
}
145+
"inputs" => {
146+
inputs = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
147+
}
148+
"project" => {
149+
project = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
150+
}
151+
"tls" => {
152+
if v.is_null() {
153+
continue;
154+
}
155+
tls = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
156+
}
157+
"topic" => {
158+
topic = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
159+
}
160+
"type" => {
161+
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
162+
if let Some(ref _type_) = type_ {
163+
match _type_ {
164+
crate::datadogV2::model::ObservabilityPipelineGooglePubSubDestinationType::UnparsedObject(_type_) => {
165+
_unparsed = true;
166+
},
167+
_ => {}
168+
}
169+
}
170+
}
171+
&_ => {
172+
if let Ok(value) = serde_json::from_value(v.clone()) {
173+
additional_properties.insert(k, value);
174+
}
175+
}
176+
}
177+
}
178+
let encoding = encoding.ok_or_else(|| M::Error::missing_field("encoding"))?;
179+
let id = id.ok_or_else(|| M::Error::missing_field("id"))?;
180+
let inputs = inputs.ok_or_else(|| M::Error::missing_field("inputs"))?;
181+
let project = project.ok_or_else(|| M::Error::missing_field("project"))?;
182+
let topic = topic.ok_or_else(|| M::Error::missing_field("topic"))?;
183+
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;
184+
185+
let content = ObservabilityPipelineGooglePubSubDestination {
186+
auth,
187+
encoding,
188+
id,
189+
inputs,
190+
project,
191+
tls,
192+
topic,
193+
type_,
194+
additional_properties,
195+
_unparsed,
196+
};
197+
198+
Ok(content)
199+
}
200+
}
201+
202+
deserializer.deserialize_any(ObservabilityPipelineGooglePubSubDestinationVisitor)
203+
}
204+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
use serde::{Deserialize, Deserializer, Serialize, Serializer};
6+
7+
#[non_exhaustive]
8+
#[derive(Clone, Debug, Eq, PartialEq)]
9+
pub enum ObservabilityPipelineGooglePubSubDestinationEncoding {
10+
JSON,
11+
RAW_MESSAGE,
12+
UnparsedObject(crate::datadog::UnparsedObject),
13+
}
14+
15+
impl ToString for ObservabilityPipelineGooglePubSubDestinationEncoding {
16+
fn to_string(&self) -> String {
17+
match self {
18+
Self::JSON => String::from("json"),
19+
Self::RAW_MESSAGE => String::from("raw_message"),
20+
Self::UnparsedObject(v) => v.value.to_string(),
21+
}
22+
}
23+
}
24+
25+
impl Serialize for ObservabilityPipelineGooglePubSubDestinationEncoding {
26+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
27+
where
28+
S: Serializer,
29+
{
30+
match self {
31+
Self::UnparsedObject(v) => v.serialize(serializer),
32+
_ => serializer.serialize_str(self.to_string().as_str()),
33+
}
34+
}
35+
}
36+
37+
impl<'de> Deserialize<'de> for ObservabilityPipelineGooglePubSubDestinationEncoding {
38+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
39+
where
40+
D: Deserializer<'de>,
41+
{
42+
let s: String = String::deserialize(deserializer)?;
43+
Ok(match s.as_str() {
44+
"json" => Self::JSON,
45+
"raw_message" => Self::RAW_MESSAGE,
46+
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
47+
value: serde_json::Value::String(s.into()),
48+
}),
49+
})
50+
}
51+
}

0 commit comments

Comments
 (0)