Skip to content
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
78 changes: 78 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,72 @@ components:
- layout_type
- widgets
type: object
DashboardAvailableValuesEventsDataSource:
description: The events-based data source for the query.
enum:
- spans
- logs
- rum
example: spans
type: string
x-enum-varnames:
- SPANS
- LOGS
- RUM
DashboardAvailableValuesEventsQuery:
additionalProperties: false
description: Query for available values using an events-based data source (spans, logs, or rum).
properties:
data_source:
$ref: "#/components/schemas/DashboardAvailableValuesEventsDataSource"
group_by:
description: The fields to group by in the query.
items:
$ref: "#/components/schemas/DashboardAvailableValuesEventsQueryGroupByItems"
type: array
search:
$ref: "#/components/schemas/DashboardAvailableValuesEventsQuerySearch"
required:
- data_source
- search
- group_by
type: object
DashboardAvailableValuesEventsQueryGroupByItems:
additionalProperties: false
description: A field to group by in the available values query.
properties:
facet:
description: The facet to group by.
example: ""
type: string
required:
- facet
type: object
DashboardAvailableValuesEventsQuerySearch:
additionalProperties: false
description: The search filter for the query.
properties:
query:
description: The search query string.
example: ""
type: string
required:
- query
type: object
DashboardAvailableValuesMetricsQuery:
additionalProperties: false
description: Query for available values using the metrics data source.
properties:
data_source:
$ref: "#/components/schemas/FormulaAndFunctionMetricDataSource"
query:
description: The metrics query string.
example: ""
type: string
required:
- data_source
- query
type: object
DashboardBulkActionData:
description: Dashboard bulk action request data.
example: {"id": "123-abc-456", "type": "dashboard"}
Expand Down Expand Up @@ -1800,6 +1866,13 @@ components:
type: string
nullable: true
type: array
available_values_query:
$ref: "#/components/schemas/DashboardTemplateVariableAvailableValuesQuery"
data_source_mappings:
additionalProperties:
type: string
description: A mapping from data source type to the variable value to use for that data source.
type: object
default:
deprecated: true
description: (deprecated) The default value for the template variable on dashboard load. Cannot be used in conjunction with `defaults`.
Expand Down Expand Up @@ -1831,6 +1904,11 @@ components:
required:
- name
type: object
DashboardTemplateVariableAvailableValuesQuery:
description: A query that dynamically computes the list of values available for this template variable.
oneOf:
- $ref: "#/components/schemas/DashboardAvailableValuesEventsQuery"
- $ref: "#/components/schemas/DashboardAvailableValuesMetricsQuery"
DashboardTemplateVariablePreset:
description: Template variables saved views.
properties:
Expand Down
16 changes: 14 additions & 2 deletions src/datadogV1/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ pub mod model_dashboard_template_variable_preset_value;
pub use self::model_dashboard_template_variable_preset_value::DashboardTemplateVariablePresetValue;
pub mod model_dashboard_template_variable;
pub use self::model_dashboard_template_variable::DashboardTemplateVariable;
pub mod model_dashboard_available_values_events_query;
pub use self::model_dashboard_available_values_events_query::DashboardAvailableValuesEventsQuery;
pub mod model_dashboard_available_values_events_data_source;
pub use self::model_dashboard_available_values_events_data_source::DashboardAvailableValuesEventsDataSource;
pub mod model_dashboard_available_values_events_query_group_by_items;
pub use self::model_dashboard_available_values_events_query_group_by_items::DashboardAvailableValuesEventsQueryGroupByItems;
pub mod model_dashboard_available_values_events_query_search;
pub use self::model_dashboard_available_values_events_query_search::DashboardAvailableValuesEventsQuerySearch;
pub mod model_dashboard_available_values_metrics_query;
pub use self::model_dashboard_available_values_metrics_query::DashboardAvailableValuesMetricsQuery;
pub mod model_formula_and_function_metric_data_source;
pub use self::model_formula_and_function_metric_data_source::FormulaAndFunctionMetricDataSource;
pub mod model_dashboard_template_variable_available_values_query;
pub use self::model_dashboard_template_variable_available_values_query::DashboardTemplateVariableAvailableValuesQuery;
pub mod model_widget;
pub use self::model_widget::Widget;
pub mod model_alert_graph_widget_definition;
Expand Down Expand Up @@ -188,8 +202,6 @@ pub mod model_formula_and_function_metric_query_definition;
pub use self::model_formula_and_function_metric_query_definition::FormulaAndFunctionMetricQueryDefinition;
pub mod model_formula_and_function_metric_aggregation;
pub use self::model_formula_and_function_metric_aggregation::FormulaAndFunctionMetricAggregation;
pub mod model_formula_and_function_metric_data_source;
pub use self::model_formula_and_function_metric_data_source::FormulaAndFunctionMetricDataSource;
pub mod model_formula_and_function_metric_semantic_mode;
pub use self::model_formula_and_function_metric_semantic_mode::FormulaAndFunctionMetricSemanticMode;
pub mod model_formula_and_function_event_query_definition;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 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 DashboardAvailableValuesEventsDataSource {
SPANS,
LOGS,
RUM,
UnparsedObject(crate::datadog::UnparsedObject),
}

impl ToString for DashboardAvailableValuesEventsDataSource {
fn to_string(&self) -> String {
match self {
Self::SPANS => String::from("spans"),
Self::LOGS => String::from("logs"),
Self::RUM => String::from("rum"),
Self::UnparsedObject(v) => v.value.to_string(),
}
}
}

impl Serialize for DashboardAvailableValuesEventsDataSource {
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 DashboardAvailableValuesEventsDataSource {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s: String = String::deserialize(deserializer)?;
Ok(match s.as_str() {
"spans" => Self::SPANS,
"logs" => Self::LOGS,
"rum" => Self::RUM,
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
value: serde_json::Value::String(s.into()),
}),
})
}
}
116 changes: 116 additions & 0 deletions src/datadogV1/model/model_dashboard_available_values_events_query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// 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};

/// Query for available values using an events-based data source (spans, logs, or rum).
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct DashboardAvailableValuesEventsQuery {
/// The events-based data source for the query.
#[serde(rename = "data_source")]
pub data_source: crate::datadogV1::model::DashboardAvailableValuesEventsDataSource,
/// The fields to group by in the query.
#[serde(rename = "group_by")]
pub group_by: Vec<crate::datadogV1::model::DashboardAvailableValuesEventsQueryGroupByItems>,
/// The search filter for the query.
#[serde(rename = "search")]
pub search: crate::datadogV1::model::DashboardAvailableValuesEventsQuerySearch,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl DashboardAvailableValuesEventsQuery {
pub fn new(
data_source: crate::datadogV1::model::DashboardAvailableValuesEventsDataSource,
group_by: Vec<crate::datadogV1::model::DashboardAvailableValuesEventsQueryGroupByItems>,
search: crate::datadogV1::model::DashboardAvailableValuesEventsQuerySearch,
) -> DashboardAvailableValuesEventsQuery {
DashboardAvailableValuesEventsQuery {
data_source,
group_by,
search,
_unparsed: false,
}
}
}

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

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 data_source: Option<
crate::datadogV1::model::DashboardAvailableValuesEventsDataSource,
> = None;
let mut group_by: Option<
Vec<crate::datadogV1::model::DashboardAvailableValuesEventsQueryGroupByItems>,
> = None;
let mut search: Option<
crate::datadogV1::model::DashboardAvailableValuesEventsQuerySearch,
> = None;
let mut _unparsed = false;

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"data_source" => {
data_source =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _data_source) = data_source {
match _data_source {
crate::datadogV1::model::DashboardAvailableValuesEventsDataSource::UnparsedObject(_data_source) => {
_unparsed = true;
},
_ => {}
}
}
}
"group_by" => {
group_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"search" => {
search = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
&_ => {
return Err(serde::de::Error::custom(
"Additional properties not allowed",
));
}
}
}
let data_source =
data_source.ok_or_else(|| M::Error::missing_field("data_source"))?;
let group_by = group_by.ok_or_else(|| M::Error::missing_field("group_by"))?;
let search = search.ok_or_else(|| M::Error::missing_field("search"))?;

let content = DashboardAvailableValuesEventsQuery {
data_source,
group_by,
search,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(DashboardAvailableValuesEventsQueryVisitor)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// 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};

/// A field to group by in the available values query.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct DashboardAvailableValuesEventsQueryGroupByItems {
/// The facet to group by.
#[serde(rename = "facet")]
pub facet: String,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl DashboardAvailableValuesEventsQueryGroupByItems {
pub fn new(facet: String) -> DashboardAvailableValuesEventsQueryGroupByItems {
DashboardAvailableValuesEventsQueryGroupByItems {
facet,
_unparsed: false,
}
}
}

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

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 facet: Option<String> = None;
let mut _unparsed = false;

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"facet" => {
facet = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
&_ => {
return Err(serde::de::Error::custom(
"Additional properties not allowed",
));
}
}
}
let facet = facet.ok_or_else(|| M::Error::missing_field("facet"))?;

let content = DashboardAvailableValuesEventsQueryGroupByItems { facet, _unparsed };

Ok(content)
}
}

deserializer.deserialize_any(DashboardAvailableValuesEventsQueryGroupByItemsVisitor)
}
}
Loading
Loading