nominal_api/conjure/objects/scout/catalog/
search_datasets_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 SearchDatasetsQuery {
7 SearchText(String),
8 ExactMatch(String),
10 Label(String),
11 Properties(super::super::super::api::Property),
12 IngestStatus(super::IngestStatus),
13 IngestedBeforeInclusive(conjure_object::DateTime<conjure_object::Utc>),
14 IngestedAfterInclusive(conjure_object::DateTime<conjure_object::Utc>),
15 ArchiveStatus(bool),
16 Derived(bool),
18 And(std::collections::BTreeSet<super::SearchDatasetsQuery>),
19 Or(std::collections::BTreeSet<super::SearchDatasetsQuery>),
20 Workspace(conjure_object::ResourceIdentifier),
21 Unknown(Unknown),
23}
24impl ser::Serialize for SearchDatasetsQuery {
25 fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
26 where
27 S: ser::Serializer,
28 {
29 let mut map = s.serialize_map(Some(2))?;
30 match self {
31 SearchDatasetsQuery::SearchText(value) => {
32 map.serialize_entry(&"type", &"searchText")?;
33 map.serialize_entry(&"searchText", value)?;
34 }
35 SearchDatasetsQuery::ExactMatch(value) => {
36 map.serialize_entry(&"type", &"exactMatch")?;
37 map.serialize_entry(&"exactMatch", value)?;
38 }
39 SearchDatasetsQuery::Label(value) => {
40 map.serialize_entry(&"type", &"label")?;
41 map.serialize_entry(&"label", value)?;
42 }
43 SearchDatasetsQuery::Properties(value) => {
44 map.serialize_entry(&"type", &"properties")?;
45 map.serialize_entry(&"properties", value)?;
46 }
47 SearchDatasetsQuery::IngestStatus(value) => {
48 map.serialize_entry(&"type", &"ingestStatus")?;
49 map.serialize_entry(&"ingestStatus", value)?;
50 }
51 SearchDatasetsQuery::IngestedBeforeInclusive(value) => {
52 map.serialize_entry(&"type", &"ingestedBeforeInclusive")?;
53 map.serialize_entry(&"ingestedBeforeInclusive", value)?;
54 }
55 SearchDatasetsQuery::IngestedAfterInclusive(value) => {
56 map.serialize_entry(&"type", &"ingestedAfterInclusive")?;
57 map.serialize_entry(&"ingestedAfterInclusive", value)?;
58 }
59 SearchDatasetsQuery::ArchiveStatus(value) => {
60 map.serialize_entry(&"type", &"archiveStatus")?;
61 map.serialize_entry(&"archiveStatus", value)?;
62 }
63 SearchDatasetsQuery::Derived(value) => {
64 map.serialize_entry(&"type", &"derived")?;
65 map.serialize_entry(&"derived", value)?;
66 }
67 SearchDatasetsQuery::And(value) => {
68 map.serialize_entry(&"type", &"and")?;
69 map.serialize_entry(&"and", value)?;
70 }
71 SearchDatasetsQuery::Or(value) => {
72 map.serialize_entry(&"type", &"or")?;
73 map.serialize_entry(&"or", value)?;
74 }
75 SearchDatasetsQuery::Workspace(value) => {
76 map.serialize_entry(&"type", &"workspace")?;
77 map.serialize_entry(&"workspace", value)?;
78 }
79 SearchDatasetsQuery::Unknown(value) => {
80 map.serialize_entry(&"type", &value.type_)?;
81 map.serialize_entry(&value.type_, &value.value)?;
82 }
83 }
84 map.end()
85 }
86}
87impl<'de> de::Deserialize<'de> for SearchDatasetsQuery {
88 fn deserialize<D>(d: D) -> Result<SearchDatasetsQuery, D::Error>
89 where
90 D: de::Deserializer<'de>,
91 {
92 d.deserialize_map(Visitor_)
93 }
94}
95struct Visitor_;
96impl<'de> de::Visitor<'de> for Visitor_ {
97 type Value = SearchDatasetsQuery;
98 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
99 fmt.write_str("union SearchDatasetsQuery")
100 }
101 fn visit_map<A>(self, mut map: A) -> Result<SearchDatasetsQuery, A::Error>
102 where
103 A: de::MapAccess<'de>,
104 {
105 let v = match map.next_key::<UnionField_<Variant_>>()? {
106 Some(UnionField_::Type) => {
107 let variant = map.next_value()?;
108 let key = map.next_key()?;
109 match (variant, key) {
110 (Variant_::SearchText, Some(Variant_::SearchText)) => {
111 let value = map.next_value()?;
112 SearchDatasetsQuery::SearchText(value)
113 }
114 (Variant_::ExactMatch, Some(Variant_::ExactMatch)) => {
115 let value = map.next_value()?;
116 SearchDatasetsQuery::ExactMatch(value)
117 }
118 (Variant_::Label, Some(Variant_::Label)) => {
119 let value = map.next_value()?;
120 SearchDatasetsQuery::Label(value)
121 }
122 (Variant_::Properties, Some(Variant_::Properties)) => {
123 let value = map.next_value()?;
124 SearchDatasetsQuery::Properties(value)
125 }
126 (Variant_::IngestStatus, Some(Variant_::IngestStatus)) => {
127 let value = map.next_value()?;
128 SearchDatasetsQuery::IngestStatus(value)
129 }
130 (
131 Variant_::IngestedBeforeInclusive,
132 Some(Variant_::IngestedBeforeInclusive),
133 ) => {
134 let value = map.next_value()?;
135 SearchDatasetsQuery::IngestedBeforeInclusive(value)
136 }
137 (
138 Variant_::IngestedAfterInclusive,
139 Some(Variant_::IngestedAfterInclusive),
140 ) => {
141 let value = map.next_value()?;
142 SearchDatasetsQuery::IngestedAfterInclusive(value)
143 }
144 (Variant_::ArchiveStatus, Some(Variant_::ArchiveStatus)) => {
145 let value = map.next_value()?;
146 SearchDatasetsQuery::ArchiveStatus(value)
147 }
148 (Variant_::Derived, Some(Variant_::Derived)) => {
149 let value = map.next_value()?;
150 SearchDatasetsQuery::Derived(value)
151 }
152 (Variant_::And, Some(Variant_::And)) => {
153 let value = map.next_value()?;
154 SearchDatasetsQuery::And(value)
155 }
156 (Variant_::Or, Some(Variant_::Or)) => {
157 let value = map.next_value()?;
158 SearchDatasetsQuery::Or(value)
159 }
160 (Variant_::Workspace, Some(Variant_::Workspace)) => {
161 let value = map.next_value()?;
162 SearchDatasetsQuery::Workspace(value)
163 }
164 (Variant_::Unknown(type_), Some(Variant_::Unknown(b))) => {
165 if type_ == b {
166 let value = map.next_value()?;
167 SearchDatasetsQuery::Unknown(Unknown { type_, value })
168 } else {
169 return Err(
170 de::Error::invalid_value(de::Unexpected::Str(&type_), &&*b),
171 )
172 }
173 }
174 (variant, Some(key)) => {
175 return Err(
176 de::Error::invalid_value(
177 de::Unexpected::Str(key.as_str()),
178 &variant.as_str(),
179 ),
180 );
181 }
182 (variant, None) => {
183 return Err(de::Error::missing_field(variant.as_str()));
184 }
185 }
186 }
187 Some(UnionField_::Value(variant)) => {
188 let value = match &variant {
189 Variant_::SearchText => {
190 let value = map.next_value()?;
191 SearchDatasetsQuery::SearchText(value)
192 }
193 Variant_::ExactMatch => {
194 let value = map.next_value()?;
195 SearchDatasetsQuery::ExactMatch(value)
196 }
197 Variant_::Label => {
198 let value = map.next_value()?;
199 SearchDatasetsQuery::Label(value)
200 }
201 Variant_::Properties => {
202 let value = map.next_value()?;
203 SearchDatasetsQuery::Properties(value)
204 }
205 Variant_::IngestStatus => {
206 let value = map.next_value()?;
207 SearchDatasetsQuery::IngestStatus(value)
208 }
209 Variant_::IngestedBeforeInclusive => {
210 let value = map.next_value()?;
211 SearchDatasetsQuery::IngestedBeforeInclusive(value)
212 }
213 Variant_::IngestedAfterInclusive => {
214 let value = map.next_value()?;
215 SearchDatasetsQuery::IngestedAfterInclusive(value)
216 }
217 Variant_::ArchiveStatus => {
218 let value = map.next_value()?;
219 SearchDatasetsQuery::ArchiveStatus(value)
220 }
221 Variant_::Derived => {
222 let value = map.next_value()?;
223 SearchDatasetsQuery::Derived(value)
224 }
225 Variant_::And => {
226 let value = map.next_value()?;
227 SearchDatasetsQuery::And(value)
228 }
229 Variant_::Or => {
230 let value = map.next_value()?;
231 SearchDatasetsQuery::Or(value)
232 }
233 Variant_::Workspace => {
234 let value = map.next_value()?;
235 SearchDatasetsQuery::Workspace(value)
236 }
237 Variant_::Unknown(type_) => {
238 let value = map.next_value()?;
239 SearchDatasetsQuery::Unknown(Unknown {
240 type_: type_.clone(),
241 value,
242 })
243 }
244 };
245 if map.next_key::<UnionTypeField_>()?.is_none() {
246 return Err(de::Error::missing_field("type"));
247 }
248 let type_variant = map.next_value::<Variant_>()?;
249 if variant != type_variant {
250 return Err(
251 de::Error::invalid_value(
252 de::Unexpected::Str(type_variant.as_str()),
253 &variant.as_str(),
254 ),
255 );
256 }
257 value
258 }
259 None => return Err(de::Error::missing_field("type")),
260 };
261 if map.next_key::<UnionField_<Variant_>>()?.is_some() {
262 return Err(de::Error::invalid_length(3, &"type and value fields"));
263 }
264 Ok(v)
265 }
266}
267#[derive(PartialEq)]
268enum Variant_ {
269 SearchText,
270 ExactMatch,
271 Label,
272 Properties,
273 IngestStatus,
274 IngestedBeforeInclusive,
275 IngestedAfterInclusive,
276 ArchiveStatus,
277 Derived,
278 And,
279 Or,
280 Workspace,
281 Unknown(Box<str>),
282}
283impl Variant_ {
284 fn as_str(&self) -> &'static str {
285 match *self {
286 Variant_::SearchText => "searchText",
287 Variant_::ExactMatch => "exactMatch",
288 Variant_::Label => "label",
289 Variant_::Properties => "properties",
290 Variant_::IngestStatus => "ingestStatus",
291 Variant_::IngestedBeforeInclusive => "ingestedBeforeInclusive",
292 Variant_::IngestedAfterInclusive => "ingestedAfterInclusive",
293 Variant_::ArchiveStatus => "archiveStatus",
294 Variant_::Derived => "derived",
295 Variant_::And => "and",
296 Variant_::Or => "or",
297 Variant_::Workspace => "workspace",
298 Variant_::Unknown(_) => "unknown variant",
299 }
300 }
301}
302impl<'de> de::Deserialize<'de> for Variant_ {
303 fn deserialize<D>(d: D) -> Result<Variant_, D::Error>
304 where
305 D: de::Deserializer<'de>,
306 {
307 d.deserialize_str(VariantVisitor_)
308 }
309}
310struct VariantVisitor_;
311impl<'de> de::Visitor<'de> for VariantVisitor_ {
312 type Value = Variant_;
313 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
314 fmt.write_str("string")
315 }
316 fn visit_str<E>(self, value: &str) -> Result<Variant_, E>
317 where
318 E: de::Error,
319 {
320 let v = match value {
321 "searchText" => Variant_::SearchText,
322 "exactMatch" => Variant_::ExactMatch,
323 "label" => Variant_::Label,
324 "properties" => Variant_::Properties,
325 "ingestStatus" => Variant_::IngestStatus,
326 "ingestedBeforeInclusive" => Variant_::IngestedBeforeInclusive,
327 "ingestedAfterInclusive" => Variant_::IngestedAfterInclusive,
328 "archiveStatus" => Variant_::ArchiveStatus,
329 "derived" => Variant_::Derived,
330 "and" => Variant_::And,
331 "or" => Variant_::Or,
332 "workspace" => Variant_::Workspace,
333 value => Variant_::Unknown(value.to_string().into_boxed_str()),
334 };
335 Ok(v)
336 }
337}
338#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
340pub struct Unknown {
341 type_: Box<str>,
342 value: conjure_object::Any,
343}
344impl Unknown {
345 #[inline]
347 pub fn type_(&self) -> &str {
348 &self.type_
349 }
350}