@@ -11,12 +11,22 @@ use std::fmt::{self, Formatter};
11
11
#[ skip_serializing_none]
12
12
#[ derive( Clone , Debug , PartialEq , Serialize ) ]
13
13
pub struct PowerpackTemplateVariable {
14
+ /// The list of values that the template variable drop-down is limited to.
15
+ #[ serde(
16
+ rename = "available_values" ,
17
+ default ,
18
+ with = "::serde_with::rust::double_option"
19
+ ) ]
20
+ pub available_values : Option < Option < Vec < String > > > ,
14
21
/// One or many template variable default values within the saved view, which are unioned together using `OR` if more than one is specified.
15
22
#[ serde( rename = "defaults" ) ]
16
23
pub defaults : Option < Vec < String > > ,
17
24
/// The name of the variable.
18
25
#[ serde( rename = "name" ) ]
19
26
pub name : String ,
27
+ /// The tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down.
28
+ #[ serde( rename = "prefix" , default , with = "::serde_with::rust::double_option" ) ]
29
+ pub prefix : Option < Option < String > > ,
20
30
#[ serde( flatten) ]
21
31
pub additional_properties : std:: collections:: BTreeMap < String , serde_json:: Value > ,
22
32
#[ serde( skip) ]
@@ -27,18 +37,30 @@ pub struct PowerpackTemplateVariable {
27
37
impl PowerpackTemplateVariable {
28
38
pub fn new ( name : String ) -> PowerpackTemplateVariable {
29
39
PowerpackTemplateVariable {
40
+ available_values : None ,
30
41
defaults : None ,
31
42
name,
43
+ prefix : None ,
32
44
additional_properties : std:: collections:: BTreeMap :: new ( ) ,
33
45
_unparsed : false ,
34
46
}
35
47
}
36
48
49
+ pub fn available_values ( mut self , value : Option < Vec < String > > ) -> Self {
50
+ self . available_values = Some ( value) ;
51
+ self
52
+ }
53
+
37
54
pub fn defaults ( mut self , value : Vec < String > ) -> Self {
38
55
self . defaults = Some ( value) ;
39
56
self
40
57
}
41
58
59
+ pub fn prefix ( mut self , value : Option < String > ) -> Self {
60
+ self . prefix = Some ( value) ;
61
+ self
62
+ }
63
+
42
64
pub fn additional_properties (
43
65
mut self ,
44
66
value : std:: collections:: BTreeMap < String , serde_json:: Value > ,
@@ -65,8 +87,10 @@ impl<'de> Deserialize<'de> for PowerpackTemplateVariable {
65
87
where
66
88
M : MapAccess < ' a > ,
67
89
{
90
+ let mut available_values: Option < Option < Vec < String > > > = None ;
68
91
let mut defaults: Option < Vec < String > > = None ;
69
92
let mut name: Option < String > = None ;
93
+ let mut prefix: Option < Option < String > > = None ;
70
94
let mut additional_properties: std:: collections:: BTreeMap <
71
95
String ,
72
96
serde_json:: Value ,
@@ -75,6 +99,10 @@ impl<'de> Deserialize<'de> for PowerpackTemplateVariable {
75
99
76
100
while let Some ( ( k, v) ) = map. next_entry :: < String , serde_json:: Value > ( ) ? {
77
101
match k. as_str ( ) {
102
+ "available_values" => {
103
+ available_values =
104
+ Some ( serde_json:: from_value ( v) . map_err ( M :: Error :: custom) ?) ;
105
+ }
78
106
"defaults" => {
79
107
if v. is_null ( ) {
80
108
continue ;
@@ -84,6 +112,9 @@ impl<'de> Deserialize<'de> for PowerpackTemplateVariable {
84
112
"name" => {
85
113
name = Some ( serde_json:: from_value ( v) . map_err ( M :: Error :: custom) ?) ;
86
114
}
115
+ "prefix" => {
116
+ prefix = Some ( serde_json:: from_value ( v) . map_err ( M :: Error :: custom) ?) ;
117
+ }
87
118
& _ => {
88
119
if let Ok ( value) = serde_json:: from_value ( v. clone ( ) ) {
89
120
additional_properties. insert ( k, value) ;
@@ -94,8 +125,10 @@ impl<'de> Deserialize<'de> for PowerpackTemplateVariable {
94
125
let name = name. ok_or_else ( || M :: Error :: missing_field ( "name" ) ) ?;
95
126
96
127
let content = PowerpackTemplateVariable {
128
+ available_values,
97
129
defaults,
98
130
name,
131
+ prefix,
99
132
additional_properties,
100
133
_unparsed,
101
134
} ;
0 commit comments