nominal_api/conjure/objects/scout/asset/api/
search_assets_query.rs1use conjure_object::serde::{ser, de};
2use conjure_object::serde::ser::SerializeMap as SerializeMap_;
3use conjure_object::private::{UnionField_, UnionTypeField_};
4use std::fmt;
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub enum SearchAssetsQuery {
7 SearchText(String),
8 ExactSubstring(String),
10 #[deprecated(note = "use labels instead")]
11 Label(super::super::super::super::api::Label),
12 Labels(super::super::super::rids::api::LabelsFilter),
13 #[deprecated(note = "use properties")]
14 Property(super::super::super::super::api::Property),
15 PropertyKey(super::super::super::super::api::PropertyName),
17 Properties(super::super::super::rids::api::PropertiesFilter),
18 #[deprecated(note = "use assetTypes")]
19 TypeRid(super::super::super::rids::api::TypeRid),
20 AssetTypes(super::AssetTypesFilter),
21 #[deprecated(note = "staged assets are no longer returned in the search endpoint")]
22 IsStaged(bool),
23 Archived(bool),
24 And(Vec<super::SearchAssetsQuery>),
25 Or(Vec<super::SearchAssetsQuery>),
26 Not(Box<super::SearchAssetsQuery>),
27 Workspace(super::super::super::super::api::rids::WorkspaceRid),
28 Unknown(Unknown),
30}
31impl ser::Serialize for SearchAssetsQuery {
32 fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
33 where
34 S: ser::Serializer,
35 {
36 let mut map = s.serialize_map(Some(2))?;
37 match self {
38 SearchAssetsQuery::SearchText(value) => {
39 map.serialize_entry(&"type", &"searchText")?;
40 map.serialize_entry(&"searchText", value)?;
41 }
42 SearchAssetsQuery::ExactSubstring(value) => {
43 map.serialize_entry(&"type", &"exactSubstring")?;
44 map.serialize_entry(&"exactSubstring", value)?;
45 }
46 #[allow(deprecated)]
47 SearchAssetsQuery::Label(value) => {
48 map.serialize_entry(&"type", &"label")?;
49 map.serialize_entry(&"label", value)?;
50 }
51 SearchAssetsQuery::Labels(value) => {
52 map.serialize_entry(&"type", &"labels")?;
53 map.serialize_entry(&"labels", value)?;
54 }
55 #[allow(deprecated)]
56 SearchAssetsQuery::Property(value) => {
57 map.serialize_entry(&"type", &"property")?;
58 map.serialize_entry(&"property", value)?;
59 }
60 SearchAssetsQuery::PropertyKey(value) => {
61 map.serialize_entry(&"type", &"propertyKey")?;
62 map.serialize_entry(&"propertyKey", value)?;
63 }
64 SearchAssetsQuery::Properties(value) => {
65 map.serialize_entry(&"type", &"properties")?;
66 map.serialize_entry(&"properties", value)?;
67 }
68 #[allow(deprecated)]
69 SearchAssetsQuery::TypeRid(value) => {
70 map.serialize_entry(&"type", &"typeRid")?;
71 map.serialize_entry(&"typeRid", value)?;
72 }
73 SearchAssetsQuery::AssetTypes(value) => {
74 map.serialize_entry(&"type", &"assetTypes")?;
75 map.serialize_entry(&"assetTypes", value)?;
76 }
77 #[allow(deprecated)]
78 SearchAssetsQuery::IsStaged(value) => {
79 map.serialize_entry(&"type", &"isStaged")?;
80 map.serialize_entry(&"isStaged", value)?;
81 }
82 SearchAssetsQuery::Archived(value) => {
83 map.serialize_entry(&"type", &"archived")?;
84 map.serialize_entry(&"archived", value)?;
85 }
86 SearchAssetsQuery::And(value) => {
87 map.serialize_entry(&"type", &"and")?;
88 map.serialize_entry(&"and", value)?;
89 }
90 SearchAssetsQuery::Or(value) => {
91 map.serialize_entry(&"type", &"or")?;
92 map.serialize_entry(&"or", value)?;
93 }
94 SearchAssetsQuery::Not(value) => {
95 map.serialize_entry(&"type", &"not")?;
96 map.serialize_entry(&"not", value)?;
97 }
98 SearchAssetsQuery::Workspace(value) => {
99 map.serialize_entry(&"type", &"workspace")?;
100 map.serialize_entry(&"workspace", value)?;
101 }
102 SearchAssetsQuery::Unknown(value) => {
103 map.serialize_entry(&"type", &value.type_)?;
104 map.serialize_entry(&value.type_, &value.value)?;
105 }
106 }
107 map.end()
108 }
109}
110impl<'de> de::Deserialize<'de> for SearchAssetsQuery {
111 fn deserialize<D>(d: D) -> Result<SearchAssetsQuery, D::Error>
112 where
113 D: de::Deserializer<'de>,
114 {
115 d.deserialize_map(Visitor_)
116 }
117}
118struct Visitor_;
119impl<'de> de::Visitor<'de> for Visitor_ {
120 type Value = SearchAssetsQuery;
121 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
122 fmt.write_str("union SearchAssetsQuery")
123 }
124 fn visit_map<A>(self, mut map: A) -> Result<SearchAssetsQuery, A::Error>
125 where
126 A: de::MapAccess<'de>,
127 {
128 let v = match map.next_key::<UnionField_<Variant_>>()? {
129 Some(UnionField_::Type) => {
130 let variant = map.next_value()?;
131 let key = map.next_key()?;
132 match (variant, key) {
133 (Variant_::SearchText, Some(Variant_::SearchText)) => {
134 let value = map.next_value()?;
135 SearchAssetsQuery::SearchText(value)
136 }
137 (Variant_::ExactSubstring, Some(Variant_::ExactSubstring)) => {
138 let value = map.next_value()?;
139 SearchAssetsQuery::ExactSubstring(value)
140 }
141 #[allow(deprecated)]
142 (Variant_::Label, Some(Variant_::Label)) => {
143 let value = map.next_value()?;
144 SearchAssetsQuery::Label(value)
145 }
146 (Variant_::Labels, Some(Variant_::Labels)) => {
147 let value = map.next_value()?;
148 SearchAssetsQuery::Labels(value)
149 }
150 #[allow(deprecated)]
151 (Variant_::Property, Some(Variant_::Property)) => {
152 let value = map.next_value()?;
153 SearchAssetsQuery::Property(value)
154 }
155 (Variant_::PropertyKey, Some(Variant_::PropertyKey)) => {
156 let value = map.next_value()?;
157 SearchAssetsQuery::PropertyKey(value)
158 }
159 (Variant_::Properties, Some(Variant_::Properties)) => {
160 let value = map.next_value()?;
161 SearchAssetsQuery::Properties(value)
162 }
163 #[allow(deprecated)]
164 (Variant_::TypeRid, Some(Variant_::TypeRid)) => {
165 let value = map.next_value()?;
166 SearchAssetsQuery::TypeRid(value)
167 }
168 (Variant_::AssetTypes, Some(Variant_::AssetTypes)) => {
169 let value = map.next_value()?;
170 SearchAssetsQuery::AssetTypes(value)
171 }
172 #[allow(deprecated)]
173 (Variant_::IsStaged, Some(Variant_::IsStaged)) => {
174 let value = map.next_value()?;
175 SearchAssetsQuery::IsStaged(value)
176 }
177 (Variant_::Archived, Some(Variant_::Archived)) => {
178 let value = map.next_value()?;
179 SearchAssetsQuery::Archived(value)
180 }
181 (Variant_::And, Some(Variant_::And)) => {
182 let value = map.next_value()?;
183 SearchAssetsQuery::And(value)
184 }
185 (Variant_::Or, Some(Variant_::Or)) => {
186 let value = map.next_value()?;
187 SearchAssetsQuery::Or(value)
188 }
189 (Variant_::Not, Some(Variant_::Not)) => {
190 let value = map.next_value()?;
191 SearchAssetsQuery::Not(value)
192 }
193 (Variant_::Workspace, Some(Variant_::Workspace)) => {
194 let value = map.next_value()?;
195 SearchAssetsQuery::Workspace(value)
196 }
197 (Variant_::Unknown(type_), Some(Variant_::Unknown(b))) => {
198 if type_ == b {
199 let value = map.next_value()?;
200 SearchAssetsQuery::Unknown(Unknown { type_, value })
201 } else {
202 return Err(
203 de::Error::invalid_value(de::Unexpected::Str(&type_), &&*b),
204 )
205 }
206 }
207 (variant, Some(key)) => {
208 return Err(
209 de::Error::invalid_value(
210 de::Unexpected::Str(key.as_str()),
211 &variant.as_str(),
212 ),
213 );
214 }
215 (variant, None) => {
216 return Err(de::Error::missing_field(variant.as_str()));
217 }
218 }
219 }
220 Some(UnionField_::Value(variant)) => {
221 let value = match &variant {
222 Variant_::SearchText => {
223 let value = map.next_value()?;
224 SearchAssetsQuery::SearchText(value)
225 }
226 Variant_::ExactSubstring => {
227 let value = map.next_value()?;
228 SearchAssetsQuery::ExactSubstring(value)
229 }
230 Variant_::Label => {
231 let value = map.next_value()?;
232 #[allow(deprecated)] SearchAssetsQuery::Label(value)
233 }
234 Variant_::Labels => {
235 let value = map.next_value()?;
236 SearchAssetsQuery::Labels(value)
237 }
238 Variant_::Property => {
239 let value = map.next_value()?;
240 #[allow(deprecated)] SearchAssetsQuery::Property(value)
241 }
242 Variant_::PropertyKey => {
243 let value = map.next_value()?;
244 SearchAssetsQuery::PropertyKey(value)
245 }
246 Variant_::Properties => {
247 let value = map.next_value()?;
248 SearchAssetsQuery::Properties(value)
249 }
250 Variant_::TypeRid => {
251 let value = map.next_value()?;
252 #[allow(deprecated)] SearchAssetsQuery::TypeRid(value)
253 }
254 Variant_::AssetTypes => {
255 let value = map.next_value()?;
256 SearchAssetsQuery::AssetTypes(value)
257 }
258 Variant_::IsStaged => {
259 let value = map.next_value()?;
260 #[allow(deprecated)] SearchAssetsQuery::IsStaged(value)
261 }
262 Variant_::Archived => {
263 let value = map.next_value()?;
264 SearchAssetsQuery::Archived(value)
265 }
266 Variant_::And => {
267 let value = map.next_value()?;
268 SearchAssetsQuery::And(value)
269 }
270 Variant_::Or => {
271 let value = map.next_value()?;
272 SearchAssetsQuery::Or(value)
273 }
274 Variant_::Not => {
275 let value = map.next_value()?;
276 SearchAssetsQuery::Not(value)
277 }
278 Variant_::Workspace => {
279 let value = map.next_value()?;
280 SearchAssetsQuery::Workspace(value)
281 }
282 Variant_::Unknown(type_) => {
283 let value = map.next_value()?;
284 SearchAssetsQuery::Unknown(Unknown {
285 type_: type_.clone(),
286 value,
287 })
288 }
289 };
290 if map.next_key::<UnionTypeField_>()?.is_none() {
291 return Err(de::Error::missing_field("type"));
292 }
293 let type_variant = map.next_value::<Variant_>()?;
294 if variant != type_variant {
295 return Err(
296 de::Error::invalid_value(
297 de::Unexpected::Str(type_variant.as_str()),
298 &variant.as_str(),
299 ),
300 );
301 }
302 value
303 }
304 None => return Err(de::Error::missing_field("type")),
305 };
306 if map.next_key::<UnionField_<Variant_>>()?.is_some() {
307 return Err(de::Error::invalid_length(3, &"type and value fields"));
308 }
309 Ok(v)
310 }
311}
312#[derive(PartialEq)]
313enum Variant_ {
314 SearchText,
315 ExactSubstring,
316 Label,
317 Labels,
318 Property,
319 PropertyKey,
320 Properties,
321 TypeRid,
322 AssetTypes,
323 IsStaged,
324 Archived,
325 And,
326 Or,
327 Not,
328 Workspace,
329 Unknown(Box<str>),
330}
331impl Variant_ {
332 fn as_str(&self) -> &'static str {
333 match *self {
334 Variant_::SearchText => "searchText",
335 Variant_::ExactSubstring => "exactSubstring",
336 Variant_::Label => "label",
337 Variant_::Labels => "labels",
338 Variant_::Property => "property",
339 Variant_::PropertyKey => "propertyKey",
340 Variant_::Properties => "properties",
341 Variant_::TypeRid => "typeRid",
342 Variant_::AssetTypes => "assetTypes",
343 Variant_::IsStaged => "isStaged",
344 Variant_::Archived => "archived",
345 Variant_::And => "and",
346 Variant_::Or => "or",
347 Variant_::Not => "not",
348 Variant_::Workspace => "workspace",
349 Variant_::Unknown(_) => "unknown variant",
350 }
351 }
352}
353impl<'de> de::Deserialize<'de> for Variant_ {
354 fn deserialize<D>(d: D) -> Result<Variant_, D::Error>
355 where
356 D: de::Deserializer<'de>,
357 {
358 d.deserialize_str(VariantVisitor_)
359 }
360}
361struct VariantVisitor_;
362impl<'de> de::Visitor<'de> for VariantVisitor_ {
363 type Value = Variant_;
364 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
365 fmt.write_str("string")
366 }
367 fn visit_str<E>(self, value: &str) -> Result<Variant_, E>
368 where
369 E: de::Error,
370 {
371 let v = match value {
372 "searchText" => Variant_::SearchText,
373 "exactSubstring" => Variant_::ExactSubstring,
374 "label" => Variant_::Label,
375 "labels" => Variant_::Labels,
376 "property" => Variant_::Property,
377 "propertyKey" => Variant_::PropertyKey,
378 "properties" => Variant_::Properties,
379 "typeRid" => Variant_::TypeRid,
380 "assetTypes" => Variant_::AssetTypes,
381 "isStaged" => Variant_::IsStaged,
382 "archived" => Variant_::Archived,
383 "and" => Variant_::And,
384 "or" => Variant_::Or,
385 "not" => Variant_::Not,
386 "workspace" => Variant_::Workspace,
387 value => Variant_::Unknown(value.to_string().into_boxed_str()),
388 };
389 Ok(v)
390 }
391}
392#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
394pub struct Unknown {
395 type_: Box<str>,
396 value: conjure_object::Any,
397}
398impl Unknown {
399 #[inline]
401 pub fn type_(&self) -> &str {
402 &self.type_
403 }
404}