drive_v3/objects/
label.rs1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4#[derive(Default, Debug, Clone, Serialize, Deserialize)]
14#[serde(rename_all = "camelCase")]
15pub struct LabelList {
16 #[serde(skip_serializing_if = "Option::is_none")]
22 pub next_page_token: Option<String>,
23
24 #[serde(skip_serializing_if = "Option::is_none")]
26 pub kind: Option<String>,
27
28 #[serde(skip_serializing_if = "Option::is_none")]
33 pub labels: Option<Vec<Label>>,
34}
35
36impl fmt::Display for LabelList {
37 fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
38 let json = serde_json::to_string_pretty(&self)
39 .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
40
41 write!(f, "{}", json)
42 }
43}
44
45impl LabelList {
46 pub fn new() -> Self {
48 Self { ..Default::default() }
49 }
50}
51
52#[derive(Default, Debug, Clone, Serialize, Deserialize)]
54#[serde(rename_all = "camelCase")]
55pub struct LabelInfo {
56 #[serde(skip_serializing_if = "Option::is_none")]
60 pub labels: Option<Vec<Label>>,
61}
62
63impl fmt::Display for LabelInfo {
64 fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
65 let json = serde_json::to_string_pretty(&self)
66 .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
67
68 write!(f, "{}", json)
69 }
70}
71
72impl LabelInfo {
73 pub fn new() -> Self {
75 Self { ..Default::default() }
76 }
77}
78
79#[derive(Default, Debug, Clone, Serialize, Deserialize)]
81#[serde(rename_all = "camelCase")]
82pub struct Label {
83 #[serde(skip_serializing_if = "Option::is_none")]
85 pub id: Option<String>,
86
87 #[serde(skip_serializing_if = "Option::is_none")]
89 pub revision_id: Option<String>,
90
91 #[serde(skip_serializing_if = "Option::is_none")]
93 pub kind: Option<String>,
94
95 #[serde(skip_serializing_if = "Option::is_none")]
97 pub fields: Option<serde_json::Map<String, serde_json::Value>>,
98}
99
100impl fmt::Display for Label {
101 fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
102 let json = serde_json::to_string_pretty(&self)
103 .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
104
105 write!(f, "{}", json)
106 }
107}
108
109impl Label {
110 pub fn new() -> Self {
112 Self { ..Default::default() }
113 }
114}
115
116#[derive(Default, Debug, Clone, Serialize, Deserialize)]
118#[serde(rename_all = "camelCase")]
119#[doc(hidden)]
120pub struct ModifyLabelsRequest {
121 #[serde(skip_serializing_if = "Option::is_none")]
123 pub label_modifications: Option<Vec<LabelModification>>,
124
125 #[serde(skip_serializing_if = "Option::is_none")]
127 pub kind: Option<String>,
128}
129
130impl ModifyLabelsRequest {
131 pub fn new() -> Self {
133 Self { ..Default::default() }
134 }
135
136 pub fn from( label_modifications: &[LabelModification] ) -> Self {
139 Self {
140 label_modifications: Some( label_modifications.to_vec() ),
141 ..Default::default()
142 }
143 }
144}
145
146#[derive(Default, Debug, Clone, Serialize, Deserialize)]
151#[serde(rename_all = "camelCase")]
152pub struct LabelModification {
153 #[serde(skip_serializing_if = "Option::is_none")]
155 pub label_id: Option<String>,
156
157 #[serde(skip_serializing_if = "Option::is_none")]
159 pub field_modifications: Option<Vec<FieldModification>>,
160
161 #[serde(skip_serializing_if = "Option::is_none")]
163 pub remove_label: Option<bool>,
164
165 #[serde(skip_serializing_if = "Option::is_none")]
167 pub kind: Option<String>,
168}
169
170impl fmt::Display for LabelModification {
171 fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
172 let json = serde_json::to_string_pretty(&self)
173 .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
174
175 write!(f, "{}", json)
176 }
177}
178
179impl LabelModification {
180 pub fn new() -> Self {
182 Self { ..Default::default() }
183 }
184
185 pub fn from<T: AsRef<str>> ( id: T, field_modifications: &[FieldModification] ) -> Self {
188 Self {
189 label_id: Some( id.as_ref().to_string() ),
190 field_modifications: Some( field_modifications.to_vec() ),
191 ..Default::default()
192 }
193 }
194}
195
196#[derive(Default, Debug, Clone, Serialize, Deserialize)]
198#[serde(rename_all = "camelCase")]
199pub struct FieldModification {
200 #[serde(skip_serializing_if = "Option::is_none")]
202 pub field_id: Option<String>,
203
204 #[serde(skip_serializing_if = "Option::is_none")]
206 pub kind: Option<String>,
207
208 #[serde(skip_serializing_if = "Option::is_none")]
212 pub set_date_values: Option<Vec<String>>,
213
214 #[serde(skip_serializing_if = "Option::is_none")]
216 pub set_text_values: Option<Vec<String>>,
217
218 #[serde(skip_serializing_if = "Option::is_none")]
220 pub set_selection_values: Option<Vec<String>>,
221
222 #[serde(skip_serializing_if = "Option::is_none")]
224 pub set_integer_values: Option<Vec<String>>,
225
226 #[serde(skip_serializing_if = "Option::is_none")]
230 pub set_user_values: Option<Vec<String>>,
231
232 #[serde(skip_serializing_if = "Option::is_none")]
234 pub unset_values: Option<bool>,
235}
236
237impl fmt::Display for FieldModification {
238 fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
239 let json = serde_json::to_string_pretty(&self)
240 .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
241
242 write!(f, "{}", json)
243 }
244}
245
246impl FieldModification {
247 pub fn new() -> Self {
249 Self { ..Default::default() }
250 }
251}