Skip to content

Commit 7c07e32

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add public DDSQL tabular query endpoints (#1844)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 1350eff commit 7c07e32

24 files changed

Lines changed: 2601 additions & 1 deletion

.generator/schemas/v2/openapi.yaml

Lines changed: 482 additions & 0 deletions
Large diffs are not rendered by default.

LICENSE-3rdparty.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jni-sys,https://github.com/jni-rs/jni-sys,MIT OR Apache-2.0,"Steven Fackler <sfa
8282
jni-sys-macros,https://github.com/jni-rs/jni-sys,MIT OR Apache-2.0,Robert Bragg <robert@sixbynine.org>
8383
js-sys,https://github.com/wasm-bindgen/wasm-bindgen/tree/master/crates/js-sys,MIT OR Apache-2.0,The wasm-bindgen Developers
8484
lazy_static,https://github.com/rust-lang-nursery/lazy-static.rs,MIT OR Apache-2.0,Marvin Löbel <loebel.marvin@gmail.com>
85-
libc,https://github.com/rust-lang/libc,MIT OR Apache-2.0,The Rust Project Developers
85+
libc,https://github.com/rust-lang/libc,MIT OR Apache-2.0,The libc Authors
8686
linux-raw-sys,https://github.com/sunfishcode/linux-raw-sys,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Dan Gohman <dev@sunfishcode.online>
8787
litemap,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Developers
8888
lock_api,https://github.com/Amanieu/parking_lot,MIT OR Apache-2.0,Amanieu d'Antras <amanieu@gmail.com>

src/datadog/configuration.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,8 @@ impl Default for Configuration {
547547
("v2.get_all_datasets".to_owned(), false),
548548
("v2.get_dataset".to_owned(), false),
549549
("v2.update_dataset".to_owned(), false),
550+
("v2.execute_ddsql_tabular_query".to_owned(), false),
551+
("v2.fetch_ddsql_tabular_query".to_owned(), false),
550552
("v2.cancel_data_deletion_request".to_owned(), false),
551553
("v2.create_data_deletion_request".to_owned(), false),
552554
("v2.get_data_deletion_requests".to_owned(), false),

src/datadogV2/api/api_ddsql.rs

Lines changed: 444 additions & 0 deletions
Large diffs are not rendered by default.

src/datadogV2/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub mod api_dashboards;
4545
pub mod api_data_deletion;
4646
pub mod api_data_observability;
4747
pub mod api_datasets;
48+
pub mod api_ddsql;
4849
pub mod api_deployment_gates;
4950
pub mod api_domain_allowlist;
5051
pub mod api_dora_metrics;

src/datadogV2/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub use self::api::api_dashboards;
4646
pub use self::api::api_data_deletion;
4747
pub use self::api::api_data_observability;
4848
pub use self::api::api_datasets;
49+
pub use self::api::api_ddsql;
4950
pub use self::api::api_deployment_gates;
5051
pub use self::api::api_domain_allowlist;
5152
pub use self::api::api_dora_metrics;

src/datadogV2/model/mod.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3460,6 +3460,38 @@ pub mod model_dataset_response_single;
34603460
pub use self::model_dataset_response_single::DatasetResponseSingle;
34613461
pub mod model_dataset_update_request;
34623462
pub use self::model_dataset_update_request::DatasetUpdateRequest;
3463+
pub mod model_ddsql_tabular_query_request;
3464+
pub use self::model_ddsql_tabular_query_request::DdsqlTabularQueryRequest;
3465+
pub mod model_ddsql_tabular_query_request_data;
3466+
pub use self::model_ddsql_tabular_query_request_data::DdsqlTabularQueryRequestData;
3467+
pub mod model_ddsql_tabular_query_request_attributes;
3468+
pub use self::model_ddsql_tabular_query_request_attributes::DdsqlTabularQueryRequestAttributes;
3469+
pub mod model_ddsql_tabular_query_time_window;
3470+
pub use self::model_ddsql_tabular_query_time_window::DdsqlTabularQueryTimeWindow;
3471+
pub mod model_ddsql_tabular_query_request_type;
3472+
pub use self::model_ddsql_tabular_query_request_type::DdsqlTabularQueryRequestType;
3473+
pub mod model_ddsql_tabular_query_response;
3474+
pub use self::model_ddsql_tabular_query_response::DdsqlTabularQueryResponse;
3475+
pub mod model_ddsql_tabular_query_response_data;
3476+
pub use self::model_ddsql_tabular_query_response_data::DdsqlTabularQueryResponseData;
3477+
pub mod model_ddsql_tabular_query_response_attributes;
3478+
pub use self::model_ddsql_tabular_query_response_attributes::DdsqlTabularQueryResponseAttributes;
3479+
pub mod model_ddsql_tabular_query_column;
3480+
pub use self::model_ddsql_tabular_query_column::DdsqlTabularQueryColumn;
3481+
pub mod model_ddsql_tabular_query_state;
3482+
pub use self::model_ddsql_tabular_query_state::DdsqlTabularQueryState;
3483+
pub mod model_ddsql_tabular_query_response_type;
3484+
pub use self::model_ddsql_tabular_query_response_type::DdsqlTabularQueryResponseType;
3485+
pub mod model_ddsql_tabular_query_response_meta;
3486+
pub use self::model_ddsql_tabular_query_response_meta::DdsqlTabularQueryResponseMeta;
3487+
pub mod model_ddsql_tabular_query_fetch_request;
3488+
pub use self::model_ddsql_tabular_query_fetch_request::DdsqlTabularQueryFetchRequest;
3489+
pub mod model_ddsql_tabular_query_fetch_request_data;
3490+
pub use self::model_ddsql_tabular_query_fetch_request_data::DdsqlTabularQueryFetchRequestData;
3491+
pub mod model_ddsql_tabular_query_fetch_request_attributes;
3492+
pub use self::model_ddsql_tabular_query_fetch_request_attributes::DdsqlTabularQueryFetchRequestAttributes;
3493+
pub mod model_ddsql_tabular_query_fetch_request_type;
3494+
pub use self::model_ddsql_tabular_query_fetch_request_type::DdsqlTabularQueryFetchRequestType;
34633495
pub mod model_create_data_deletion_request_body;
34643496
pub use self::model_create_data_deletion_request_body::CreateDataDeletionRequestBody;
34653497
pub mod model_create_data_deletion_request_body_data;
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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+
/// A single column of a DDSQL tabular query result.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct DdsqlTabularQueryColumn {
14+
/// Name of the column as projected by the SQL statement.
15+
#[serde(rename = "name")]
16+
pub name: String,
17+
/// DDSQL data type of the column's values, for example `VARCHAR`, `BIGINT`,
18+
/// `DECIMAL`, `BOOLEAN`, `TIMESTAMP`, `JSON`, or an array variant such as
19+
/// `VARCHAR[]`. See the
20+
/// [DDSQL data-types reference](<https://docs.datadoghq.com/ddsql_reference/#data-types>)
21+
/// for the full, up-to-date list.
22+
#[serde(rename = "type")]
23+
pub type_: String,
24+
/// Column values in row order. The element type matches the column's `type`;
25+
/// for example a `VARCHAR` column carries strings, a `TIMESTAMP` column carries
26+
/// Unix-millisecond integers. `null` is allowed for missing values.
27+
#[serde(rename = "values")]
28+
pub values: Vec<serde_json::Value>,
29+
#[serde(flatten)]
30+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
31+
#[serde(skip)]
32+
#[serde(default)]
33+
pub(crate) _unparsed: bool,
34+
}
35+
36+
impl DdsqlTabularQueryColumn {
37+
pub fn new(
38+
name: String,
39+
type_: String,
40+
values: Vec<serde_json::Value>,
41+
) -> DdsqlTabularQueryColumn {
42+
DdsqlTabularQueryColumn {
43+
name,
44+
type_,
45+
values,
46+
additional_properties: std::collections::BTreeMap::new(),
47+
_unparsed: false,
48+
}
49+
}
50+
51+
pub fn additional_properties(
52+
mut self,
53+
value: std::collections::BTreeMap<String, serde_json::Value>,
54+
) -> Self {
55+
self.additional_properties = value;
56+
self
57+
}
58+
}
59+
60+
impl<'de> Deserialize<'de> for DdsqlTabularQueryColumn {
61+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
62+
where
63+
D: Deserializer<'de>,
64+
{
65+
struct DdsqlTabularQueryColumnVisitor;
66+
impl<'a> Visitor<'a> for DdsqlTabularQueryColumnVisitor {
67+
type Value = DdsqlTabularQueryColumn;
68+
69+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
70+
f.write_str("a mapping")
71+
}
72+
73+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
74+
where
75+
M: MapAccess<'a>,
76+
{
77+
let mut name: Option<String> = None;
78+
let mut type_: Option<String> = None;
79+
let mut values: Option<Vec<serde_json::Value>> = None;
80+
let mut additional_properties: std::collections::BTreeMap<
81+
String,
82+
serde_json::Value,
83+
> = std::collections::BTreeMap::new();
84+
let mut _unparsed = false;
85+
86+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
87+
match k.as_str() {
88+
"name" => {
89+
name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
90+
}
91+
"type" => {
92+
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
93+
}
94+
"values" => {
95+
values = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
96+
}
97+
&_ => {
98+
if let Ok(value) = serde_json::from_value(v.clone()) {
99+
additional_properties.insert(k, value);
100+
}
101+
}
102+
}
103+
}
104+
let name = name.ok_or_else(|| M::Error::missing_field("name"))?;
105+
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;
106+
let values = values.ok_or_else(|| M::Error::missing_field("values"))?;
107+
108+
let content = DdsqlTabularQueryColumn {
109+
name,
110+
type_,
111+
values,
112+
additional_properties,
113+
_unparsed,
114+
};
115+
116+
Ok(content)
117+
}
118+
}
119+
120+
deserializer.deserialize_any(DdsqlTabularQueryColumnVisitor)
121+
}
122+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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+
/// Wrapper for a DDSQL tabular query fetch request.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct DdsqlTabularQueryFetchRequest {
14+
/// JSON:API resource object for a DDSQL tabular query fetch request.
15+
#[serde(rename = "data")]
16+
pub data: crate::datadogV2::model::DdsqlTabularQueryFetchRequestData,
17+
#[serde(flatten)]
18+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
19+
#[serde(skip)]
20+
#[serde(default)]
21+
pub(crate) _unparsed: bool,
22+
}
23+
24+
impl DdsqlTabularQueryFetchRequest {
25+
pub fn new(
26+
data: crate::datadogV2::model::DdsqlTabularQueryFetchRequestData,
27+
) -> DdsqlTabularQueryFetchRequest {
28+
DdsqlTabularQueryFetchRequest {
29+
data,
30+
additional_properties: std::collections::BTreeMap::new(),
31+
_unparsed: false,
32+
}
33+
}
34+
35+
pub fn additional_properties(
36+
mut self,
37+
value: std::collections::BTreeMap<String, serde_json::Value>,
38+
) -> Self {
39+
self.additional_properties = value;
40+
self
41+
}
42+
}
43+
44+
impl<'de> Deserialize<'de> for DdsqlTabularQueryFetchRequest {
45+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
46+
where
47+
D: Deserializer<'de>,
48+
{
49+
struct DdsqlTabularQueryFetchRequestVisitor;
50+
impl<'a> Visitor<'a> for DdsqlTabularQueryFetchRequestVisitor {
51+
type Value = DdsqlTabularQueryFetchRequest;
52+
53+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
54+
f.write_str("a mapping")
55+
}
56+
57+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
58+
where
59+
M: MapAccess<'a>,
60+
{
61+
let mut data: Option<crate::datadogV2::model::DdsqlTabularQueryFetchRequestData> =
62+
None;
63+
let mut additional_properties: std::collections::BTreeMap<
64+
String,
65+
serde_json::Value,
66+
> = std::collections::BTreeMap::new();
67+
let mut _unparsed = false;
68+
69+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
70+
match k.as_str() {
71+
"data" => {
72+
data = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
73+
}
74+
&_ => {
75+
if let Ok(value) = serde_json::from_value(v.clone()) {
76+
additional_properties.insert(k, value);
77+
}
78+
}
79+
}
80+
}
81+
let data = data.ok_or_else(|| M::Error::missing_field("data"))?;
82+
83+
let content = DdsqlTabularQueryFetchRequest {
84+
data,
85+
additional_properties,
86+
_unparsed,
87+
};
88+
89+
Ok(content)
90+
}
91+
}
92+
93+
deserializer.deserialize_any(DdsqlTabularQueryFetchRequestVisitor)
94+
}
95+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
/// Attributes describing which previously submitted DDSQL query to fetch.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct DdsqlTabularQueryFetchRequestAttributes {
14+
/// Opaque token returned by an earlier execute or fetch response that carried
15+
/// `state: running`. Identifies the query to poll for results.
16+
#[serde(rename = "query_id")]
17+
pub query_id: String,
18+
#[serde(flatten)]
19+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
20+
#[serde(skip)]
21+
#[serde(default)]
22+
pub(crate) _unparsed: bool,
23+
}
24+
25+
impl DdsqlTabularQueryFetchRequestAttributes {
26+
pub fn new(query_id: String) -> DdsqlTabularQueryFetchRequestAttributes {
27+
DdsqlTabularQueryFetchRequestAttributes {
28+
query_id,
29+
additional_properties: std::collections::BTreeMap::new(),
30+
_unparsed: false,
31+
}
32+
}
33+
34+
pub fn additional_properties(
35+
mut self,
36+
value: std::collections::BTreeMap<String, serde_json::Value>,
37+
) -> Self {
38+
self.additional_properties = value;
39+
self
40+
}
41+
}
42+
43+
impl<'de> Deserialize<'de> for DdsqlTabularQueryFetchRequestAttributes {
44+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
45+
where
46+
D: Deserializer<'de>,
47+
{
48+
struct DdsqlTabularQueryFetchRequestAttributesVisitor;
49+
impl<'a> Visitor<'a> for DdsqlTabularQueryFetchRequestAttributesVisitor {
50+
type Value = DdsqlTabularQueryFetchRequestAttributes;
51+
52+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
53+
f.write_str("a mapping")
54+
}
55+
56+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
57+
where
58+
M: MapAccess<'a>,
59+
{
60+
let mut query_id: Option<String> = None;
61+
let mut additional_properties: std::collections::BTreeMap<
62+
String,
63+
serde_json::Value,
64+
> = std::collections::BTreeMap::new();
65+
let mut _unparsed = false;
66+
67+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
68+
match k.as_str() {
69+
"query_id" => {
70+
query_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
71+
}
72+
&_ => {
73+
if let Ok(value) = serde_json::from_value(v.clone()) {
74+
additional_properties.insert(k, value);
75+
}
76+
}
77+
}
78+
}
79+
let query_id = query_id.ok_or_else(|| M::Error::missing_field("query_id"))?;
80+
81+
let content = DdsqlTabularQueryFetchRequestAttributes {
82+
query_id,
83+
additional_properties,
84+
_unparsed,
85+
};
86+
87+
Ok(content)
88+
}
89+
}
90+
91+
deserializer.deserialize_any(DdsqlTabularQueryFetchRequestAttributesVisitor)
92+
}
93+
}

0 commit comments

Comments
 (0)