|
| 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 `databricks_zerobus` destination sends logs to Databricks using the Zerobus ingestion API, streaming data directly into your Databricks Lakehouse. |
| 10 | +/// |
| 11 | +/// **Supported pipeline types:** Logs, rehydration |
| 12 | +#[non_exhaustive] |
| 13 | +#[skip_serializing_none] |
| 14 | +#[derive(Clone, Debug, PartialEq, Serialize)] |
| 15 | +pub struct ObservabilityPipelineDatabricksZerobusDestination { |
| 16 | + /// OAuth credentials for authenticating with the Databricks Zerobus ingestion API. |
| 17 | + #[serde(rename = "auth")] |
| 18 | + pub auth: crate::datadogV2::model::ObservabilityPipelineDatabricksZerobusDestinationAuth, |
| 19 | + /// Configuration for buffer settings on destination components. |
| 20 | + #[serde(rename = "buffer")] |
| 21 | + pub buffer: Option<crate::datadogV2::model::ObservabilityPipelineBufferOptions>, |
| 22 | + /// The unique identifier for this component. |
| 23 | + #[serde(rename = "id")] |
| 24 | + pub id: String, |
| 25 | + /// Your Databricks Zerobus ingestion endpoint. This is the endpoint used to stream data directly into your Databricks Lakehouse. |
| 26 | + #[serde(rename = "ingestion_endpoint")] |
| 27 | + pub ingestion_endpoint: String, |
| 28 | + /// A list of component IDs whose output is used as the `input` for this component. |
| 29 | + #[serde(rename = "inputs")] |
| 30 | + pub inputs: Vec<String>, |
| 31 | + /// The fully qualified name of your target Databricks table. Make sure this table already exists in your Databricks workspace before deploying. |
| 32 | + #[serde(rename = "table_name")] |
| 33 | + pub table_name: String, |
| 34 | + /// The destination type. The value must be `databricks_zerobus`. |
| 35 | + #[serde(rename = "type")] |
| 36 | + pub type_: crate::datadogV2::model::ObservabilityPipelineDatabricksZerobusDestinationType, |
| 37 | + /// Your Databricks workspace URL. This is used to communicate with the Unity Catalog API. |
| 38 | + #[serde(rename = "unity_catalog_endpoint")] |
| 39 | + pub unity_catalog_endpoint: String, |
| 40 | + #[serde(flatten)] |
| 41 | + pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>, |
| 42 | + #[serde(skip)] |
| 43 | + #[serde(default)] |
| 44 | + pub(crate) _unparsed: bool, |
| 45 | +} |
| 46 | + |
| 47 | +impl ObservabilityPipelineDatabricksZerobusDestination { |
| 48 | + pub fn new( |
| 49 | + auth: crate::datadogV2::model::ObservabilityPipelineDatabricksZerobusDestinationAuth, |
| 50 | + id: String, |
| 51 | + ingestion_endpoint: String, |
| 52 | + inputs: Vec<String>, |
| 53 | + table_name: String, |
| 54 | + type_: crate::datadogV2::model::ObservabilityPipelineDatabricksZerobusDestinationType, |
| 55 | + unity_catalog_endpoint: String, |
| 56 | + ) -> ObservabilityPipelineDatabricksZerobusDestination { |
| 57 | + ObservabilityPipelineDatabricksZerobusDestination { |
| 58 | + auth, |
| 59 | + buffer: None, |
| 60 | + id, |
| 61 | + ingestion_endpoint, |
| 62 | + inputs, |
| 63 | + table_name, |
| 64 | + type_, |
| 65 | + unity_catalog_endpoint, |
| 66 | + additional_properties: std::collections::BTreeMap::new(), |
| 67 | + _unparsed: false, |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + pub fn buffer( |
| 72 | + mut self, |
| 73 | + value: crate::datadogV2::model::ObservabilityPipelineBufferOptions, |
| 74 | + ) -> Self { |
| 75 | + self.buffer = 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 ObservabilityPipelineDatabricksZerobusDestination { |
| 89 | + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
| 90 | + where |
| 91 | + D: Deserializer<'de>, |
| 92 | + { |
| 93 | + struct ObservabilityPipelineDatabricksZerobusDestinationVisitor; |
| 94 | + impl<'a> Visitor<'a> for ObservabilityPipelineDatabricksZerobusDestinationVisitor { |
| 95 | + type Value = ObservabilityPipelineDatabricksZerobusDestination; |
| 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< |
| 106 | + crate::datadogV2::model::ObservabilityPipelineDatabricksZerobusDestinationAuth, |
| 107 | + > = None; |
| 108 | + let mut buffer: Option< |
| 109 | + crate::datadogV2::model::ObservabilityPipelineBufferOptions, |
| 110 | + > = None; |
| 111 | + let mut id: Option<String> = None; |
| 112 | + let mut ingestion_endpoint: Option<String> = None; |
| 113 | + let mut inputs: Option<Vec<String>> = None; |
| 114 | + let mut table_name: Option<String> = None; |
| 115 | + let mut type_: Option< |
| 116 | + crate::datadogV2::model::ObservabilityPipelineDatabricksZerobusDestinationType, |
| 117 | + > = None; |
| 118 | + let mut unity_catalog_endpoint: Option<String> = None; |
| 119 | + let mut additional_properties: std::collections::BTreeMap< |
| 120 | + String, |
| 121 | + serde_json::Value, |
| 122 | + > = std::collections::BTreeMap::new(); |
| 123 | + let mut _unparsed = false; |
| 124 | + |
| 125 | + while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? { |
| 126 | + match k.as_str() { |
| 127 | + "auth" => { |
| 128 | + auth = Some(serde_json::from_value(v).map_err(M::Error::custom)?); |
| 129 | + } |
| 130 | + "buffer" => { |
| 131 | + if v.is_null() { |
| 132 | + continue; |
| 133 | + } |
| 134 | + buffer = Some(serde_json::from_value(v).map_err(M::Error::custom)?); |
| 135 | + if let Some(ref _buffer) = buffer { |
| 136 | + match _buffer { |
| 137 | + crate::datadogV2::model::ObservabilityPipelineBufferOptions::UnparsedObject(_buffer) => { |
| 138 | + _unparsed = true; |
| 139 | + }, |
| 140 | + _ => {} |
| 141 | + } |
| 142 | + } |
| 143 | + } |
| 144 | + "id" => { |
| 145 | + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); |
| 146 | + } |
| 147 | + "ingestion_endpoint" => { |
| 148 | + ingestion_endpoint = |
| 149 | + Some(serde_json::from_value(v).map_err(M::Error::custom)?); |
| 150 | + } |
| 151 | + "inputs" => { |
| 152 | + inputs = Some(serde_json::from_value(v).map_err(M::Error::custom)?); |
| 153 | + } |
| 154 | + "table_name" => { |
| 155 | + table_name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); |
| 156 | + } |
| 157 | + "type" => { |
| 158 | + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); |
| 159 | + if let Some(ref _type_) = type_ { |
| 160 | + match _type_ { |
| 161 | + crate::datadogV2::model::ObservabilityPipelineDatabricksZerobusDestinationType::UnparsedObject(_type_) => { |
| 162 | + _unparsed = true; |
| 163 | + }, |
| 164 | + _ => {} |
| 165 | + } |
| 166 | + } |
| 167 | + } |
| 168 | + "unity_catalog_endpoint" => { |
| 169 | + unity_catalog_endpoint = |
| 170 | + Some(serde_json::from_value(v).map_err(M::Error::custom)?); |
| 171 | + } |
| 172 | + &_ => { |
| 173 | + if let Ok(value) = serde_json::from_value(v.clone()) { |
| 174 | + additional_properties.insert(k, value); |
| 175 | + } |
| 176 | + } |
| 177 | + } |
| 178 | + } |
| 179 | + let auth = auth.ok_or_else(|| M::Error::missing_field("auth"))?; |
| 180 | + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; |
| 181 | + let ingestion_endpoint = ingestion_endpoint |
| 182 | + .ok_or_else(|| M::Error::missing_field("ingestion_endpoint"))?; |
| 183 | + let inputs = inputs.ok_or_else(|| M::Error::missing_field("inputs"))?; |
| 184 | + let table_name = table_name.ok_or_else(|| M::Error::missing_field("table_name"))?; |
| 185 | + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; |
| 186 | + let unity_catalog_endpoint = unity_catalog_endpoint |
| 187 | + .ok_or_else(|| M::Error::missing_field("unity_catalog_endpoint"))?; |
| 188 | + |
| 189 | + let content = ObservabilityPipelineDatabricksZerobusDestination { |
| 190 | + auth, |
| 191 | + buffer, |
| 192 | + id, |
| 193 | + ingestion_endpoint, |
| 194 | + inputs, |
| 195 | + table_name, |
| 196 | + type_, |
| 197 | + unity_catalog_endpoint, |
| 198 | + additional_properties, |
| 199 | + _unparsed, |
| 200 | + }; |
| 201 | + |
| 202 | + Ok(content) |
| 203 | + } |
| 204 | + } |
| 205 | + |
| 206 | + deserializer.deserialize_any(ObservabilityPipelineDatabricksZerobusDestinationVisitor) |
| 207 | + } |
| 208 | +} |
0 commit comments