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
63 changes: 63 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10354,6 +10354,16 @@ components:
type: string
status:
$ref: '#/components/schemas/NotebookStatus'
template_variables:
description: List of template variables for this notebook.
example:
- available_values: []
default: '*'
name: host
prefix: host
items:
$ref: '#/components/schemas/NotebookTemplateVariable'
type: array
time:
$ref: '#/components/schemas/NotebookGlobalTime'
required:
Expand Down Expand Up @@ -10657,6 +10667,39 @@ components:
type: string
x-enum-varnames:
- PUBLISHED
NotebookTemplateVariable:
description: Template variable for a notebook.
properties:
available_values:
description: The list of values that the template variable drop-down is
limited to.
example:
- my-host
- host1
- host2
items:
description: Template variable value.
type: string
nullable: true
type: array
default:
description: The default value for the template variable.
example: '*'
nullable: true
type: string
name:
description: The name of the variable.
example: host
type: string
prefix:
description: The tag prefix associated with the variable. Only tags with
this prefix appear in the variable drop-down.
example: host
nullable: true
type: string
required:
- name
type: object
NotebookTimeseriesCellAttributes:
description: The attributes of a notebook `timeseries` cell.
properties:
Expand Down Expand Up @@ -10760,6 +10803,16 @@ components:
type: string
status:
$ref: '#/components/schemas/NotebookStatus'
template_variables:
description: List of template variables for this notebook.
example:
- available_values: []
default: '*'
name: host
prefix: host
items:
$ref: '#/components/schemas/NotebookTemplateVariable'
type: array
time:
$ref: '#/components/schemas/NotebookGlobalTime'
required:
Expand Down Expand Up @@ -10836,6 +10889,16 @@ components:
type: string
status:
$ref: '#/components/schemas/NotebookStatus'
template_variables:
description: List of template variables for this notebook.
example:
- available_values: []
default: '*'
name: host
prefix: host
items:
$ref: '#/components/schemas/NotebookTemplateVariable'
type: array
time:
$ref: '#/components/schemas/NotebookGlobalTime'
required:
Expand Down
2 changes: 2 additions & 0 deletions src/datadogV1/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,8 @@ pub mod model_notebook_metadata_type;
pub use self::model_notebook_metadata_type::NotebookMetadataType;
pub mod model_notebook_status;
pub use self::model_notebook_status::NotebookStatus;
pub mod model_notebook_template_variable;
pub use self::model_notebook_template_variable::NotebookTemplateVariable;
pub mod model_notebook_global_time;
pub use self::model_notebook_global_time::NotebookGlobalTime;
pub mod model_notebook_resource_type;
Expand Down
23 changes: 23 additions & 0 deletions src/datadogV1/model/model_notebook_create_data_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ pub struct NotebookCreateDataAttributes {
/// Publication status of the notebook. For now, always "published".
#[serde(rename = "status")]
pub status: Option<crate::datadogV1::model::NotebookStatus>,
/// List of template variables for this notebook.
#[serde(rename = "template_variables")]
pub template_variables: Option<Vec<crate::datadogV1::model::NotebookTemplateVariable>>,
/// Notebook global timeframe.
#[serde(rename = "time")]
pub time: crate::datadogV1::model::NotebookGlobalTime,
Expand All @@ -44,6 +47,7 @@ impl NotebookCreateDataAttributes {
metadata: None,
name,
status: None,
template_variables: None,
time,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
Expand All @@ -60,6 +64,14 @@ impl NotebookCreateDataAttributes {
self
}

pub fn template_variables(
mut self,
value: Vec<crate::datadogV1::model::NotebookTemplateVariable>,
) -> Self {
self.template_variables = Some(value);
self
}

pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
Expand Down Expand Up @@ -91,6 +103,9 @@ impl<'de> Deserialize<'de> for NotebookCreateDataAttributes {
let mut metadata: Option<crate::datadogV1::model::NotebookMetadata> = None;
let mut name: Option<String> = None;
let mut status: Option<crate::datadogV1::model::NotebookStatus> = None;
let mut template_variables: Option<
Vec<crate::datadogV1::model::NotebookTemplateVariable>,
> = None;
let mut time: Option<crate::datadogV1::model::NotebookGlobalTime> = None;
let mut additional_properties: std::collections::BTreeMap<
String,
Expand Down Expand Up @@ -128,6 +143,13 @@ impl<'de> Deserialize<'de> for NotebookCreateDataAttributes {
}
}
}
"template_variables" => {
if v.is_null() {
continue;
}
template_variables =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"time" => {
time = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _time) = time {
Expand Down Expand Up @@ -157,6 +179,7 @@ impl<'de> Deserialize<'de> for NotebookCreateDataAttributes {
metadata,
name,
status,
template_variables,
time,
additional_properties,
_unparsed,
Expand Down
143 changes: 143 additions & 0 deletions src/datadogV1/model/model_notebook_template_variable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// 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};

/// Template variable for a notebook.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct NotebookTemplateVariable {
/// The list of values that the template variable drop-down is limited to.
#[serde(
rename = "available_values",
default,
with = "::serde_with::rust::double_option"
)]
pub available_values: Option<Option<Vec<String>>>,
/// The default value for the template variable.
#[serde(
rename = "default",
default,
with = "::serde_with::rust::double_option"
)]
pub default: Option<Option<String>>,
/// The name of the variable.
#[serde(rename = "name")]
pub name: String,
/// The tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down.
#[serde(rename = "prefix", default, with = "::serde_with::rust::double_option")]
pub prefix: Option<Option<String>>,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl NotebookTemplateVariable {
pub fn new(name: String) -> NotebookTemplateVariable {
NotebookTemplateVariable {
available_values: None,
default: None,
name,
prefix: None,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn available_values(mut self, value: Option<Vec<String>>) -> Self {
self.available_values = Some(value);
self
}

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

pub fn prefix(mut self, value: Option<String>) -> Self {
self.prefix = 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 NotebookTemplateVariable {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct NotebookTemplateVariableVisitor;
impl<'a> Visitor<'a> for NotebookTemplateVariableVisitor {
type Value = NotebookTemplateVariable;

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 available_values: Option<Option<Vec<String>>> = None;
let mut default: Option<Option<String>> = None;
let mut name: Option<String> = None;
let mut prefix: Option<Option<String>> = 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() {
"available_values" => {
available_values =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"default" => {
default = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"name" => {
name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"prefix" => {
prefix = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
}
}
}
}
let name = name.ok_or_else(|| M::Error::missing_field("name"))?;

let content = NotebookTemplateVariable {
available_values,
default,
name,
prefix,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(NotebookTemplateVariableVisitor)
}
}
23 changes: 23 additions & 0 deletions src/datadogV1/model/model_notebook_update_data_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ pub struct NotebookUpdateDataAttributes {
/// Publication status of the notebook. For now, always "published".
#[serde(rename = "status")]
pub status: Option<crate::datadogV1::model::NotebookStatus>,
/// List of template variables for this notebook.
#[serde(rename = "template_variables")]
pub template_variables: Option<Vec<crate::datadogV1::model::NotebookTemplateVariable>>,
/// Notebook global timeframe.
#[serde(rename = "time")]
pub time: crate::datadogV1::model::NotebookGlobalTime,
Expand All @@ -44,6 +47,7 @@ impl NotebookUpdateDataAttributes {
metadata: None,
name,
status: None,
template_variables: None,
time,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
Expand All @@ -60,6 +64,14 @@ impl NotebookUpdateDataAttributes {
self
}

pub fn template_variables(
mut self,
value: Vec<crate::datadogV1::model::NotebookTemplateVariable>,
) -> Self {
self.template_variables = Some(value);
self
}

pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
Expand Down Expand Up @@ -90,6 +102,9 @@ impl<'de> Deserialize<'de> for NotebookUpdateDataAttributes {
let mut metadata: Option<crate::datadogV1::model::NotebookMetadata> = None;
let mut name: Option<String> = None;
let mut status: Option<crate::datadogV1::model::NotebookStatus> = None;
let mut template_variables: Option<
Vec<crate::datadogV1::model::NotebookTemplateVariable>,
> = None;
let mut time: Option<crate::datadogV1::model::NotebookGlobalTime> = None;
let mut additional_properties: std::collections::BTreeMap<
String,
Expand Down Expand Up @@ -127,6 +142,13 @@ impl<'de> Deserialize<'de> for NotebookUpdateDataAttributes {
}
}
}
"template_variables" => {
if v.is_null() {
continue;
}
template_variables =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"time" => {
time = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _time) = time {
Expand Down Expand Up @@ -156,6 +178,7 @@ impl<'de> Deserialize<'de> for NotebookUpdateDataAttributes {
metadata,
name,
status,
template_variables,
time,
additional_properties,
_unparsed,
Expand Down
Loading