Skip to content

Powerpack add support for prefix and available values #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-09-16 14:02:52.161932",
"spec_repo_commit": "966987f5"
"regenerated": "2024-09-18 14:45:11.870692",
"spec_repo_commit": "bae57ce1"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-09-16 14:02:52.179359",
"spec_repo_commit": "966987f5"
"regenerated": "2024-09-18 14:45:11.890523",
"spec_repo_commit": "bae57ce1"
}
}
}
18 changes: 18 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16297,6 +16297,18 @@ components:
PowerpackTemplateVariable:
description: Powerpack template variables.
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
defaults:
description: One or many template variable default values within the saved
view, which are unioned together using `OR` if more than one is specified.
Expand All @@ -16309,6 +16321,12 @@ components:
description: The name of the variable.
example: datacenter
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
Expand Down
33 changes: 33 additions & 0 deletions src/datadogV2/model/model_powerpack_template_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@ use std::fmt::{self, Formatter};
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct PowerpackTemplateVariable {
/// 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>>>,
/// One or many template variable default values within the saved view, which are unioned together using `OR` if more than one is specified.
#[serde(rename = "defaults")]
pub defaults: Option<Vec<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)]
Expand All @@ -27,18 +37,30 @@ pub struct PowerpackTemplateVariable {
impl PowerpackTemplateVariable {
pub fn new(name: String) -> PowerpackTemplateVariable {
PowerpackTemplateVariable {
available_values: None,
defaults: 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 defaults(mut self, value: Vec<String>) -> Self {
self.defaults = 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>,
Expand All @@ -65,8 +87,10 @@ impl<'de> Deserialize<'de> for PowerpackTemplateVariable {
where
M: MapAccess<'a>,
{
let mut available_values: Option<Option<Vec<String>>> = None;
let mut defaults: Option<Vec<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,
Expand All @@ -75,6 +99,10 @@ impl<'de> Deserialize<'de> for PowerpackTemplateVariable {

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)?);
}
"defaults" => {
if v.is_null() {
continue;
Expand All @@ -84,6 +112,9 @@ impl<'de> Deserialize<'de> for PowerpackTemplateVariable {
"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);
Expand All @@ -94,8 +125,10 @@ impl<'de> Deserialize<'de> for PowerpackTemplateVariable {
let name = name.ok_or_else(|| M::Error::missing_field("name"))?;

let content = PowerpackTemplateVariable {
available_values,
defaults,
name,
prefix,
additional_properties,
_unparsed,
};
Expand Down
Loading