Skip to main content

nominal_api/conjure/objects/scout/notebook/api/
search_notebooks_query.rs

1use 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 SearchNotebooksQuery {
7    And(Vec<super::SearchNotebooksQuery>),
8    Or(Vec<super::SearchNotebooksQuery>),
9    Not(Box<super::SearchNotebooksQuery>),
10    /// Performs case insensitive exact match search on the title.
11    ExactMatch(String),
12    SearchText(String),
13    #[deprecated(note = "use labels")]
14    Label(super::super::super::super::api::Label),
15    Labels(super::super::super::rids::api::LabelsFilter),
16    #[deprecated(note = "use properties")]
17    Property(super::super::super::super::api::Property),
18    Properties(super::super::super::rids::api::PropertiesFilter),
19    #[deprecated(note = "use assetRids")]
20    AssetRid(super::super::super::rids::api::AssetRid),
21    AssetRids(super::AssetsFilter),
22    /// Requires the set of assets in the query to exactly match the set of assets in the notebook.
23    /// To do a partial match, use an assetRids query.
24    ExactAssetRids(std::collections::BTreeSet<super::super::super::rids::api::AssetRid>),
25    AuthorRid(super::super::super::rids::api::UserRid),
26    #[deprecated(note = "use runRids")]
27    RunRid(super::super::super::run::api::RunRid),
28    RunRids(super::RunsFilter),
29    #[deprecated(note = "use notebook types")]
30    NotebookType(super::NotebookType),
31    NotebookTypes(super::NotebookTypesFilter),
32    DraftState(bool),
33    Archived(bool),
34    Workspace(super::super::super::super::api::rids::WorkspaceRid),
35    AuthorIsCurrentUser(bool),
36    AuthorRids(std::collections::BTreeSet<super::super::super::rids::api::UserRid>),
37    /// An unknown variant.
38    Unknown(Unknown),
39}
40impl ser::Serialize for SearchNotebooksQuery {
41    fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
42    where
43        S: ser::Serializer,
44    {
45        let mut map = s.serialize_map(Some(2))?;
46        match self {
47            SearchNotebooksQuery::And(value) => {
48                map.serialize_entry(&"type", &"and")?;
49                map.serialize_entry(&"and", value)?;
50            }
51            SearchNotebooksQuery::Or(value) => {
52                map.serialize_entry(&"type", &"or")?;
53                map.serialize_entry(&"or", value)?;
54            }
55            SearchNotebooksQuery::Not(value) => {
56                map.serialize_entry(&"type", &"not")?;
57                map.serialize_entry(&"not", value)?;
58            }
59            SearchNotebooksQuery::ExactMatch(value) => {
60                map.serialize_entry(&"type", &"exactMatch")?;
61                map.serialize_entry(&"exactMatch", value)?;
62            }
63            SearchNotebooksQuery::SearchText(value) => {
64                map.serialize_entry(&"type", &"searchText")?;
65                map.serialize_entry(&"searchText", value)?;
66            }
67            #[allow(deprecated)]
68            SearchNotebooksQuery::Label(value) => {
69                map.serialize_entry(&"type", &"label")?;
70                map.serialize_entry(&"label", value)?;
71            }
72            SearchNotebooksQuery::Labels(value) => {
73                map.serialize_entry(&"type", &"labels")?;
74                map.serialize_entry(&"labels", value)?;
75            }
76            #[allow(deprecated)]
77            SearchNotebooksQuery::Property(value) => {
78                map.serialize_entry(&"type", &"property")?;
79                map.serialize_entry(&"property", value)?;
80            }
81            SearchNotebooksQuery::Properties(value) => {
82                map.serialize_entry(&"type", &"properties")?;
83                map.serialize_entry(&"properties", value)?;
84            }
85            #[allow(deprecated)]
86            SearchNotebooksQuery::AssetRid(value) => {
87                map.serialize_entry(&"type", &"assetRid")?;
88                map.serialize_entry(&"assetRid", value)?;
89            }
90            SearchNotebooksQuery::AssetRids(value) => {
91                map.serialize_entry(&"type", &"assetRids")?;
92                map.serialize_entry(&"assetRids", value)?;
93            }
94            SearchNotebooksQuery::ExactAssetRids(value) => {
95                map.serialize_entry(&"type", &"exactAssetRids")?;
96                map.serialize_entry(&"exactAssetRids", value)?;
97            }
98            SearchNotebooksQuery::AuthorRid(value) => {
99                map.serialize_entry(&"type", &"authorRid")?;
100                map.serialize_entry(&"authorRid", value)?;
101            }
102            #[allow(deprecated)]
103            SearchNotebooksQuery::RunRid(value) => {
104                map.serialize_entry(&"type", &"runRid")?;
105                map.serialize_entry(&"runRid", value)?;
106            }
107            SearchNotebooksQuery::RunRids(value) => {
108                map.serialize_entry(&"type", &"runRids")?;
109                map.serialize_entry(&"runRids", value)?;
110            }
111            #[allow(deprecated)]
112            SearchNotebooksQuery::NotebookType(value) => {
113                map.serialize_entry(&"type", &"notebookType")?;
114                map.serialize_entry(&"notebookType", value)?;
115            }
116            SearchNotebooksQuery::NotebookTypes(value) => {
117                map.serialize_entry(&"type", &"notebookTypes")?;
118                map.serialize_entry(&"notebookTypes", value)?;
119            }
120            SearchNotebooksQuery::DraftState(value) => {
121                map.serialize_entry(&"type", &"draftState")?;
122                map.serialize_entry(&"draftState", value)?;
123            }
124            SearchNotebooksQuery::Archived(value) => {
125                map.serialize_entry(&"type", &"archived")?;
126                map.serialize_entry(&"archived", value)?;
127            }
128            SearchNotebooksQuery::Workspace(value) => {
129                map.serialize_entry(&"type", &"workspace")?;
130                map.serialize_entry(&"workspace", value)?;
131            }
132            SearchNotebooksQuery::AuthorIsCurrentUser(value) => {
133                map.serialize_entry(&"type", &"authorIsCurrentUser")?;
134                map.serialize_entry(&"authorIsCurrentUser", value)?;
135            }
136            SearchNotebooksQuery::AuthorRids(value) => {
137                map.serialize_entry(&"type", &"authorRids")?;
138                map.serialize_entry(&"authorRids", value)?;
139            }
140            SearchNotebooksQuery::Unknown(value) => {
141                map.serialize_entry(&"type", &value.type_)?;
142                map.serialize_entry(&value.type_, &value.value)?;
143            }
144        }
145        map.end()
146    }
147}
148impl<'de> de::Deserialize<'de> for SearchNotebooksQuery {
149    fn deserialize<D>(d: D) -> Result<SearchNotebooksQuery, D::Error>
150    where
151        D: de::Deserializer<'de>,
152    {
153        d.deserialize_map(Visitor_)
154    }
155}
156struct Visitor_;
157impl<'de> de::Visitor<'de> for Visitor_ {
158    type Value = SearchNotebooksQuery;
159    fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
160        fmt.write_str("union SearchNotebooksQuery")
161    }
162    fn visit_map<A>(self, mut map: A) -> Result<SearchNotebooksQuery, A::Error>
163    where
164        A: de::MapAccess<'de>,
165    {
166        let v = match map.next_key::<UnionField_<Variant_>>()? {
167            Some(UnionField_::Type) => {
168                let variant = map.next_value()?;
169                let key = map.next_key()?;
170                match (variant, key) {
171                    (Variant_::And, Some(Variant_::And)) => {
172                        let value = map.next_value()?;
173                        SearchNotebooksQuery::And(value)
174                    }
175                    (Variant_::Or, Some(Variant_::Or)) => {
176                        let value = map.next_value()?;
177                        SearchNotebooksQuery::Or(value)
178                    }
179                    (Variant_::Not, Some(Variant_::Not)) => {
180                        let value = map.next_value()?;
181                        SearchNotebooksQuery::Not(value)
182                    }
183                    (Variant_::ExactMatch, Some(Variant_::ExactMatch)) => {
184                        let value = map.next_value()?;
185                        SearchNotebooksQuery::ExactMatch(value)
186                    }
187                    (Variant_::SearchText, Some(Variant_::SearchText)) => {
188                        let value = map.next_value()?;
189                        SearchNotebooksQuery::SearchText(value)
190                    }
191                    #[allow(deprecated)]
192                    (Variant_::Label, Some(Variant_::Label)) => {
193                        let value = map.next_value()?;
194                        SearchNotebooksQuery::Label(value)
195                    }
196                    (Variant_::Labels, Some(Variant_::Labels)) => {
197                        let value = map.next_value()?;
198                        SearchNotebooksQuery::Labels(value)
199                    }
200                    #[allow(deprecated)]
201                    (Variant_::Property, Some(Variant_::Property)) => {
202                        let value = map.next_value()?;
203                        SearchNotebooksQuery::Property(value)
204                    }
205                    (Variant_::Properties, Some(Variant_::Properties)) => {
206                        let value = map.next_value()?;
207                        SearchNotebooksQuery::Properties(value)
208                    }
209                    #[allow(deprecated)]
210                    (Variant_::AssetRid, Some(Variant_::AssetRid)) => {
211                        let value = map.next_value()?;
212                        SearchNotebooksQuery::AssetRid(value)
213                    }
214                    (Variant_::AssetRids, Some(Variant_::AssetRids)) => {
215                        let value = map.next_value()?;
216                        SearchNotebooksQuery::AssetRids(value)
217                    }
218                    (Variant_::ExactAssetRids, Some(Variant_::ExactAssetRids)) => {
219                        let value = map.next_value()?;
220                        SearchNotebooksQuery::ExactAssetRids(value)
221                    }
222                    (Variant_::AuthorRid, Some(Variant_::AuthorRid)) => {
223                        let value = map.next_value()?;
224                        SearchNotebooksQuery::AuthorRid(value)
225                    }
226                    #[allow(deprecated)]
227                    (Variant_::RunRid, Some(Variant_::RunRid)) => {
228                        let value = map.next_value()?;
229                        SearchNotebooksQuery::RunRid(value)
230                    }
231                    (Variant_::RunRids, Some(Variant_::RunRids)) => {
232                        let value = map.next_value()?;
233                        SearchNotebooksQuery::RunRids(value)
234                    }
235                    #[allow(deprecated)]
236                    (Variant_::NotebookType, Some(Variant_::NotebookType)) => {
237                        let value = map.next_value()?;
238                        SearchNotebooksQuery::NotebookType(value)
239                    }
240                    (Variant_::NotebookTypes, Some(Variant_::NotebookTypes)) => {
241                        let value = map.next_value()?;
242                        SearchNotebooksQuery::NotebookTypes(value)
243                    }
244                    (Variant_::DraftState, Some(Variant_::DraftState)) => {
245                        let value = map.next_value()?;
246                        SearchNotebooksQuery::DraftState(value)
247                    }
248                    (Variant_::Archived, Some(Variant_::Archived)) => {
249                        let value = map.next_value()?;
250                        SearchNotebooksQuery::Archived(value)
251                    }
252                    (Variant_::Workspace, Some(Variant_::Workspace)) => {
253                        let value = map.next_value()?;
254                        SearchNotebooksQuery::Workspace(value)
255                    }
256                    (
257                        Variant_::AuthorIsCurrentUser,
258                        Some(Variant_::AuthorIsCurrentUser),
259                    ) => {
260                        let value = map.next_value()?;
261                        SearchNotebooksQuery::AuthorIsCurrentUser(value)
262                    }
263                    (Variant_::AuthorRids, Some(Variant_::AuthorRids)) => {
264                        let value = map.next_value()?;
265                        SearchNotebooksQuery::AuthorRids(value)
266                    }
267                    (Variant_::Unknown(type_), Some(Variant_::Unknown(b))) => {
268                        if type_ == b {
269                            let value = map.next_value()?;
270                            SearchNotebooksQuery::Unknown(Unknown { type_, value })
271                        } else {
272                            return Err(
273                                de::Error::invalid_value(de::Unexpected::Str(&type_), &&*b),
274                            )
275                        }
276                    }
277                    (variant, Some(key)) => {
278                        return Err(
279                            de::Error::invalid_value(
280                                de::Unexpected::Str(key.as_str()),
281                                &variant.as_str(),
282                            ),
283                        );
284                    }
285                    (variant, None) => {
286                        return Err(de::Error::missing_field(variant.as_str()));
287                    }
288                }
289            }
290            Some(UnionField_::Value(variant)) => {
291                let value = match &variant {
292                    Variant_::And => {
293                        let value = map.next_value()?;
294                        SearchNotebooksQuery::And(value)
295                    }
296                    Variant_::Or => {
297                        let value = map.next_value()?;
298                        SearchNotebooksQuery::Or(value)
299                    }
300                    Variant_::Not => {
301                        let value = map.next_value()?;
302                        SearchNotebooksQuery::Not(value)
303                    }
304                    Variant_::ExactMatch => {
305                        let value = map.next_value()?;
306                        SearchNotebooksQuery::ExactMatch(value)
307                    }
308                    Variant_::SearchText => {
309                        let value = map.next_value()?;
310                        SearchNotebooksQuery::SearchText(value)
311                    }
312                    Variant_::Label => {
313                        let value = map.next_value()?;
314                        #[allow(deprecated)] SearchNotebooksQuery::Label(value)
315                    }
316                    Variant_::Labels => {
317                        let value = map.next_value()?;
318                        SearchNotebooksQuery::Labels(value)
319                    }
320                    Variant_::Property => {
321                        let value = map.next_value()?;
322                        #[allow(deprecated)] SearchNotebooksQuery::Property(value)
323                    }
324                    Variant_::Properties => {
325                        let value = map.next_value()?;
326                        SearchNotebooksQuery::Properties(value)
327                    }
328                    Variant_::AssetRid => {
329                        let value = map.next_value()?;
330                        #[allow(deprecated)] SearchNotebooksQuery::AssetRid(value)
331                    }
332                    Variant_::AssetRids => {
333                        let value = map.next_value()?;
334                        SearchNotebooksQuery::AssetRids(value)
335                    }
336                    Variant_::ExactAssetRids => {
337                        let value = map.next_value()?;
338                        SearchNotebooksQuery::ExactAssetRids(value)
339                    }
340                    Variant_::AuthorRid => {
341                        let value = map.next_value()?;
342                        SearchNotebooksQuery::AuthorRid(value)
343                    }
344                    Variant_::RunRid => {
345                        let value = map.next_value()?;
346                        #[allow(deprecated)] SearchNotebooksQuery::RunRid(value)
347                    }
348                    Variant_::RunRids => {
349                        let value = map.next_value()?;
350                        SearchNotebooksQuery::RunRids(value)
351                    }
352                    Variant_::NotebookType => {
353                        let value = map.next_value()?;
354                        #[allow(deprecated)] SearchNotebooksQuery::NotebookType(value)
355                    }
356                    Variant_::NotebookTypes => {
357                        let value = map.next_value()?;
358                        SearchNotebooksQuery::NotebookTypes(value)
359                    }
360                    Variant_::DraftState => {
361                        let value = map.next_value()?;
362                        SearchNotebooksQuery::DraftState(value)
363                    }
364                    Variant_::Archived => {
365                        let value = map.next_value()?;
366                        SearchNotebooksQuery::Archived(value)
367                    }
368                    Variant_::Workspace => {
369                        let value = map.next_value()?;
370                        SearchNotebooksQuery::Workspace(value)
371                    }
372                    Variant_::AuthorIsCurrentUser => {
373                        let value = map.next_value()?;
374                        SearchNotebooksQuery::AuthorIsCurrentUser(value)
375                    }
376                    Variant_::AuthorRids => {
377                        let value = map.next_value()?;
378                        SearchNotebooksQuery::AuthorRids(value)
379                    }
380                    Variant_::Unknown(type_) => {
381                        let value = map.next_value()?;
382                        SearchNotebooksQuery::Unknown(Unknown {
383                            type_: type_.clone(),
384                            value,
385                        })
386                    }
387                };
388                if map.next_key::<UnionTypeField_>()?.is_none() {
389                    return Err(de::Error::missing_field("type"));
390                }
391                let type_variant = map.next_value::<Variant_>()?;
392                if variant != type_variant {
393                    return Err(
394                        de::Error::invalid_value(
395                            de::Unexpected::Str(type_variant.as_str()),
396                            &variant.as_str(),
397                        ),
398                    );
399                }
400                value
401            }
402            None => return Err(de::Error::missing_field("type")),
403        };
404        if map.next_key::<UnionField_<Variant_>>()?.is_some() {
405            return Err(de::Error::invalid_length(3, &"type and value fields"));
406        }
407        Ok(v)
408    }
409}
410#[derive(PartialEq)]
411enum Variant_ {
412    And,
413    Or,
414    Not,
415    ExactMatch,
416    SearchText,
417    Label,
418    Labels,
419    Property,
420    Properties,
421    AssetRid,
422    AssetRids,
423    ExactAssetRids,
424    AuthorRid,
425    RunRid,
426    RunRids,
427    NotebookType,
428    NotebookTypes,
429    DraftState,
430    Archived,
431    Workspace,
432    AuthorIsCurrentUser,
433    AuthorRids,
434    Unknown(Box<str>),
435}
436impl Variant_ {
437    fn as_str(&self) -> &'static str {
438        match *self {
439            Variant_::And => "and",
440            Variant_::Or => "or",
441            Variant_::Not => "not",
442            Variant_::ExactMatch => "exactMatch",
443            Variant_::SearchText => "searchText",
444            Variant_::Label => "label",
445            Variant_::Labels => "labels",
446            Variant_::Property => "property",
447            Variant_::Properties => "properties",
448            Variant_::AssetRid => "assetRid",
449            Variant_::AssetRids => "assetRids",
450            Variant_::ExactAssetRids => "exactAssetRids",
451            Variant_::AuthorRid => "authorRid",
452            Variant_::RunRid => "runRid",
453            Variant_::RunRids => "runRids",
454            Variant_::NotebookType => "notebookType",
455            Variant_::NotebookTypes => "notebookTypes",
456            Variant_::DraftState => "draftState",
457            Variant_::Archived => "archived",
458            Variant_::Workspace => "workspace",
459            Variant_::AuthorIsCurrentUser => "authorIsCurrentUser",
460            Variant_::AuthorRids => "authorRids",
461            Variant_::Unknown(_) => "unknown variant",
462        }
463    }
464}
465impl<'de> de::Deserialize<'de> for Variant_ {
466    fn deserialize<D>(d: D) -> Result<Variant_, D::Error>
467    where
468        D: de::Deserializer<'de>,
469    {
470        d.deserialize_str(VariantVisitor_)
471    }
472}
473struct VariantVisitor_;
474impl<'de> de::Visitor<'de> for VariantVisitor_ {
475    type Value = Variant_;
476    fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
477        fmt.write_str("string")
478    }
479    fn visit_str<E>(self, value: &str) -> Result<Variant_, E>
480    where
481        E: de::Error,
482    {
483        let v = match value {
484            "and" => Variant_::And,
485            "or" => Variant_::Or,
486            "not" => Variant_::Not,
487            "exactMatch" => Variant_::ExactMatch,
488            "searchText" => Variant_::SearchText,
489            "label" => Variant_::Label,
490            "labels" => Variant_::Labels,
491            "property" => Variant_::Property,
492            "properties" => Variant_::Properties,
493            "assetRid" => Variant_::AssetRid,
494            "assetRids" => Variant_::AssetRids,
495            "exactAssetRids" => Variant_::ExactAssetRids,
496            "authorRid" => Variant_::AuthorRid,
497            "runRid" => Variant_::RunRid,
498            "runRids" => Variant_::RunRids,
499            "notebookType" => Variant_::NotebookType,
500            "notebookTypes" => Variant_::NotebookTypes,
501            "draftState" => Variant_::DraftState,
502            "archived" => Variant_::Archived,
503            "workspace" => Variant_::Workspace,
504            "authorIsCurrentUser" => Variant_::AuthorIsCurrentUser,
505            "authorRids" => Variant_::AuthorRids,
506            value => Variant_::Unknown(value.to_string().into_boxed_str()),
507        };
508        Ok(v)
509    }
510}
511///An unknown variant of the SearchNotebooksQuery union.
512#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
513pub struct Unknown {
514    type_: Box<str>,
515    value: conjure_object::Any,
516}
517impl Unknown {
518    /// Returns the unknown variant's type name.
519    #[inline]
520    pub fn type_(&self) -> &str {
521        &self.type_
522    }
523}