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, conjure_object::private::DeriveWith)]
6#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub enum SearchQuery {
8 #[deprecated(note = "Use startTime instead")]
9 StartTimeInclusive(super::UtcTimestamp),
10 StartTime(Box<super::TimeframeFilter>),
11 #[deprecated(note = "Use endTime instead")]
12 EndTimeInclusive(super::UtcTimestamp),
13 EndTime(Box<super::TimeframeFilter>),
14 TimeRange(super::TimeRangeFilter),
15 CreatedAt(Box<super::TimeframeFilter>),
16 ExactMatch(String),
18 SearchText(String),
19 #[deprecated(note = "Use getRunsByAsset rather than text-based search")]
20 Asset(super::super::super::rids::api::AssetRid),
21 Assets(super::AssetsFilter),
22 IsSingleAsset(bool),
24 #[deprecated(note = "use labels instead")]
25 Label(super::super::super::super::api::Label),
26 Labels(super::super::super::rids::api::LabelsFilter),
27 #[deprecated(note = "use properties")]
28 Property(super::super::super::super::api::Property),
29 PropertyKey(super::super::super::super::api::PropertyName),
31 Properties(super::super::super::rids::api::PropertiesFilter),
32 NumericProperty(super::super::super::super::api::NumericPropertyPredicate),
34 DataSourceSeriesTag(super::DataSourceSeriesTag),
35 DataSourceRefName(super::super::super::api::DataSourceRefName),
36 #[deprecated(
37 note = "Use dataSourceRefName, rather than searching directly by DataSource."
38 )]
39 DataSource(Box<super::DataSource>),
40 RunNumber(conjure_object::SafeLong),
41 RunPrefix(String),
42 CheckAlertStatesFilter(super::CheckAlertStatesFilter),
44 Archived(bool),
45 And(Vec<super::SearchQuery>),
46 Or(Vec<super::SearchQuery>),
47 Not(Box<super::SearchQuery>),
48 Workspace(super::super::super::super::api::rids::WorkspaceRid),
49 Unknown(Unknown),
51}
52impl ser::Serialize for SearchQuery {
53 fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
54 where
55 S: ser::Serializer,
56 {
57 let mut map = s.serialize_map(Some(2))?;
58 match self {
59 #[allow(deprecated)]
60 SearchQuery::StartTimeInclusive(value) => {
61 map.serialize_entry(&"type", &"startTimeInclusive")?;
62 map.serialize_entry(&"startTimeInclusive", value)?;
63 }
64 SearchQuery::StartTime(value) => {
65 map.serialize_entry(&"type", &"startTime")?;
66 map.serialize_entry(&"startTime", value)?;
67 }
68 #[allow(deprecated)]
69 SearchQuery::EndTimeInclusive(value) => {
70 map.serialize_entry(&"type", &"endTimeInclusive")?;
71 map.serialize_entry(&"endTimeInclusive", value)?;
72 }
73 SearchQuery::EndTime(value) => {
74 map.serialize_entry(&"type", &"endTime")?;
75 map.serialize_entry(&"endTime", value)?;
76 }
77 SearchQuery::TimeRange(value) => {
78 map.serialize_entry(&"type", &"timeRange")?;
79 map.serialize_entry(&"timeRange", value)?;
80 }
81 SearchQuery::CreatedAt(value) => {
82 map.serialize_entry(&"type", &"createdAt")?;
83 map.serialize_entry(&"createdAt", value)?;
84 }
85 SearchQuery::ExactMatch(value) => {
86 map.serialize_entry(&"type", &"exactMatch")?;
87 map.serialize_entry(&"exactMatch", value)?;
88 }
89 SearchQuery::SearchText(value) => {
90 map.serialize_entry(&"type", &"searchText")?;
91 map.serialize_entry(&"searchText", value)?;
92 }
93 #[allow(deprecated)]
94 SearchQuery::Asset(value) => {
95 map.serialize_entry(&"type", &"asset")?;
96 map.serialize_entry(&"asset", value)?;
97 }
98 SearchQuery::Assets(value) => {
99 map.serialize_entry(&"type", &"assets")?;
100 map.serialize_entry(&"assets", value)?;
101 }
102 SearchQuery::IsSingleAsset(value) => {
103 map.serialize_entry(&"type", &"isSingleAsset")?;
104 map.serialize_entry(&"isSingleAsset", value)?;
105 }
106 #[allow(deprecated)]
107 SearchQuery::Label(value) => {
108 map.serialize_entry(&"type", &"label")?;
109 map.serialize_entry(&"label", value)?;
110 }
111 SearchQuery::Labels(value) => {
112 map.serialize_entry(&"type", &"labels")?;
113 map.serialize_entry(&"labels", value)?;
114 }
115 #[allow(deprecated)]
116 SearchQuery::Property(value) => {
117 map.serialize_entry(&"type", &"property")?;
118 map.serialize_entry(&"property", value)?;
119 }
120 SearchQuery::PropertyKey(value) => {
121 map.serialize_entry(&"type", &"propertyKey")?;
122 map.serialize_entry(&"propertyKey", value)?;
123 }
124 SearchQuery::Properties(value) => {
125 map.serialize_entry(&"type", &"properties")?;
126 map.serialize_entry(&"properties", value)?;
127 }
128 SearchQuery::NumericProperty(value) => {
129 map.serialize_entry(&"type", &"numericProperty")?;
130 map.serialize_entry(&"numericProperty", value)?;
131 }
132 SearchQuery::DataSourceSeriesTag(value) => {
133 map.serialize_entry(&"type", &"dataSourceSeriesTag")?;
134 map.serialize_entry(&"dataSourceSeriesTag", value)?;
135 }
136 SearchQuery::DataSourceRefName(value) => {
137 map.serialize_entry(&"type", &"dataSourceRefName")?;
138 map.serialize_entry(&"dataSourceRefName", value)?;
139 }
140 #[allow(deprecated)]
141 SearchQuery::DataSource(value) => {
142 map.serialize_entry(&"type", &"dataSource")?;
143 map.serialize_entry(&"dataSource", value)?;
144 }
145 SearchQuery::RunNumber(value) => {
146 map.serialize_entry(&"type", &"runNumber")?;
147 map.serialize_entry(&"runNumber", value)?;
148 }
149 SearchQuery::RunPrefix(value) => {
150 map.serialize_entry(&"type", &"runPrefix")?;
151 map.serialize_entry(&"runPrefix", value)?;
152 }
153 SearchQuery::CheckAlertStatesFilter(value) => {
154 map.serialize_entry(&"type", &"checkAlertStatesFilter")?;
155 map.serialize_entry(&"checkAlertStatesFilter", value)?;
156 }
157 SearchQuery::Archived(value) => {
158 map.serialize_entry(&"type", &"archived")?;
159 map.serialize_entry(&"archived", value)?;
160 }
161 SearchQuery::And(value) => {
162 map.serialize_entry(&"type", &"and")?;
163 map.serialize_entry(&"and", value)?;
164 }
165 SearchQuery::Or(value) => {
166 map.serialize_entry(&"type", &"or")?;
167 map.serialize_entry(&"or", value)?;
168 }
169 SearchQuery::Not(value) => {
170 map.serialize_entry(&"type", &"not")?;
171 map.serialize_entry(&"not", value)?;
172 }
173 SearchQuery::Workspace(value) => {
174 map.serialize_entry(&"type", &"workspace")?;
175 map.serialize_entry(&"workspace", value)?;
176 }
177 SearchQuery::Unknown(value) => {
178 map.serialize_entry(&"type", &value.type_)?;
179 map.serialize_entry(&value.type_, &value.value)?;
180 }
181 }
182 map.end()
183 }
184}
185impl<'de> de::Deserialize<'de> for SearchQuery {
186 fn deserialize<D>(d: D) -> Result<SearchQuery, D::Error>
187 where
188 D: de::Deserializer<'de>,
189 {
190 d.deserialize_map(Visitor_)
191 }
192}
193struct Visitor_;
194impl<'de> de::Visitor<'de> for Visitor_ {
195 type Value = SearchQuery;
196 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
197 fmt.write_str("union SearchQuery")
198 }
199 fn visit_map<A>(self, mut map: A) -> Result<SearchQuery, A::Error>
200 where
201 A: de::MapAccess<'de>,
202 {
203 let v = match map.next_key::<UnionField_<Variant_>>()? {
204 Some(UnionField_::Type) => {
205 let variant = map.next_value()?;
206 let key = map.next_key()?;
207 match (variant, key) {
208 #[allow(deprecated)]
209 (
210 Variant_::StartTimeInclusive,
211 Some(Variant_::StartTimeInclusive),
212 ) => {
213 let value = map.next_value()?;
214 SearchQuery::StartTimeInclusive(value)
215 }
216 (Variant_::StartTime, Some(Variant_::StartTime)) => {
217 let value = map.next_value()?;
218 SearchQuery::StartTime(value)
219 }
220 #[allow(deprecated)]
221 (Variant_::EndTimeInclusive, Some(Variant_::EndTimeInclusive)) => {
222 let value = map.next_value()?;
223 SearchQuery::EndTimeInclusive(value)
224 }
225 (Variant_::EndTime, Some(Variant_::EndTime)) => {
226 let value = map.next_value()?;
227 SearchQuery::EndTime(value)
228 }
229 (Variant_::TimeRange, Some(Variant_::TimeRange)) => {
230 let value = map.next_value()?;
231 SearchQuery::TimeRange(value)
232 }
233 (Variant_::CreatedAt, Some(Variant_::CreatedAt)) => {
234 let value = map.next_value()?;
235 SearchQuery::CreatedAt(value)
236 }
237 (Variant_::ExactMatch, Some(Variant_::ExactMatch)) => {
238 let value = map.next_value()?;
239 SearchQuery::ExactMatch(value)
240 }
241 (Variant_::SearchText, Some(Variant_::SearchText)) => {
242 let value = map.next_value()?;
243 SearchQuery::SearchText(value)
244 }
245 #[allow(deprecated)]
246 (Variant_::Asset, Some(Variant_::Asset)) => {
247 let value = map.next_value()?;
248 SearchQuery::Asset(value)
249 }
250 (Variant_::Assets, Some(Variant_::Assets)) => {
251 let value = map.next_value()?;
252 SearchQuery::Assets(value)
253 }
254 (Variant_::IsSingleAsset, Some(Variant_::IsSingleAsset)) => {
255 let value = map.next_value()?;
256 SearchQuery::IsSingleAsset(value)
257 }
258 #[allow(deprecated)]
259 (Variant_::Label, Some(Variant_::Label)) => {
260 let value = map.next_value()?;
261 SearchQuery::Label(value)
262 }
263 (Variant_::Labels, Some(Variant_::Labels)) => {
264 let value = map.next_value()?;
265 SearchQuery::Labels(value)
266 }
267 #[allow(deprecated)]
268 (Variant_::Property, Some(Variant_::Property)) => {
269 let value = map.next_value()?;
270 SearchQuery::Property(value)
271 }
272 (Variant_::PropertyKey, Some(Variant_::PropertyKey)) => {
273 let value = map.next_value()?;
274 SearchQuery::PropertyKey(value)
275 }
276 (Variant_::Properties, Some(Variant_::Properties)) => {
277 let value = map.next_value()?;
278 SearchQuery::Properties(value)
279 }
280 (Variant_::NumericProperty, Some(Variant_::NumericProperty)) => {
281 let value = map.next_value()?;
282 SearchQuery::NumericProperty(value)
283 }
284 (
285 Variant_::DataSourceSeriesTag,
286 Some(Variant_::DataSourceSeriesTag),
287 ) => {
288 let value = map.next_value()?;
289 SearchQuery::DataSourceSeriesTag(value)
290 }
291 (Variant_::DataSourceRefName, Some(Variant_::DataSourceRefName)) => {
292 let value = map.next_value()?;
293 SearchQuery::DataSourceRefName(value)
294 }
295 #[allow(deprecated)]
296 (Variant_::DataSource, Some(Variant_::DataSource)) => {
297 let value = map.next_value()?;
298 SearchQuery::DataSource(value)
299 }
300 (Variant_::RunNumber, Some(Variant_::RunNumber)) => {
301 let value = map.next_value()?;
302 SearchQuery::RunNumber(value)
303 }
304 (Variant_::RunPrefix, Some(Variant_::RunPrefix)) => {
305 let value = map.next_value()?;
306 SearchQuery::RunPrefix(value)
307 }
308 (
309 Variant_::CheckAlertStatesFilter,
310 Some(Variant_::CheckAlertStatesFilter),
311 ) => {
312 let value = map.next_value()?;
313 SearchQuery::CheckAlertStatesFilter(value)
314 }
315 (Variant_::Archived, Some(Variant_::Archived)) => {
316 let value = map.next_value()?;
317 SearchQuery::Archived(value)
318 }
319 (Variant_::And, Some(Variant_::And)) => {
320 let value = map.next_value()?;
321 SearchQuery::And(value)
322 }
323 (Variant_::Or, Some(Variant_::Or)) => {
324 let value = map.next_value()?;
325 SearchQuery::Or(value)
326 }
327 (Variant_::Not, Some(Variant_::Not)) => {
328 let value = map.next_value()?;
329 SearchQuery::Not(value)
330 }
331 (Variant_::Workspace, Some(Variant_::Workspace)) => {
332 let value = map.next_value()?;
333 SearchQuery::Workspace(value)
334 }
335 (Variant_::Unknown(type_), Some(Variant_::Unknown(b))) => {
336 if type_ == b {
337 let value = map.next_value()?;
338 SearchQuery::Unknown(Unknown { type_, value })
339 } else {
340 return Err(
341 de::Error::invalid_value(de::Unexpected::Str(&type_), &&*b),
342 )
343 }
344 }
345 (variant, Some(key)) => {
346 return Err(
347 de::Error::invalid_value(
348 de::Unexpected::Str(key.as_str()),
349 &variant.as_str(),
350 ),
351 );
352 }
353 (variant, None) => {
354 return Err(de::Error::missing_field(variant.as_str()));
355 }
356 }
357 }
358 Some(UnionField_::Value(variant)) => {
359 let value = match &variant {
360 Variant_::StartTimeInclusive => {
361 let value = map.next_value()?;
362 #[allow(deprecated)] SearchQuery::StartTimeInclusive(value)
363 }
364 Variant_::StartTime => {
365 let value = map.next_value()?;
366 SearchQuery::StartTime(value)
367 }
368 Variant_::EndTimeInclusive => {
369 let value = map.next_value()?;
370 #[allow(deprecated)] SearchQuery::EndTimeInclusive(value)
371 }
372 Variant_::EndTime => {
373 let value = map.next_value()?;
374 SearchQuery::EndTime(value)
375 }
376 Variant_::TimeRange => {
377 let value = map.next_value()?;
378 SearchQuery::TimeRange(value)
379 }
380 Variant_::CreatedAt => {
381 let value = map.next_value()?;
382 SearchQuery::CreatedAt(value)
383 }
384 Variant_::ExactMatch => {
385 let value = map.next_value()?;
386 SearchQuery::ExactMatch(value)
387 }
388 Variant_::SearchText => {
389 let value = map.next_value()?;
390 SearchQuery::SearchText(value)
391 }
392 Variant_::Asset => {
393 let value = map.next_value()?;
394 #[allow(deprecated)] SearchQuery::Asset(value)
395 }
396 Variant_::Assets => {
397 let value = map.next_value()?;
398 SearchQuery::Assets(value)
399 }
400 Variant_::IsSingleAsset => {
401 let value = map.next_value()?;
402 SearchQuery::IsSingleAsset(value)
403 }
404 Variant_::Label => {
405 let value = map.next_value()?;
406 #[allow(deprecated)] SearchQuery::Label(value)
407 }
408 Variant_::Labels => {
409 let value = map.next_value()?;
410 SearchQuery::Labels(value)
411 }
412 Variant_::Property => {
413 let value = map.next_value()?;
414 #[allow(deprecated)] SearchQuery::Property(value)
415 }
416 Variant_::PropertyKey => {
417 let value = map.next_value()?;
418 SearchQuery::PropertyKey(value)
419 }
420 Variant_::Properties => {
421 let value = map.next_value()?;
422 SearchQuery::Properties(value)
423 }
424 Variant_::NumericProperty => {
425 let value = map.next_value()?;
426 SearchQuery::NumericProperty(value)
427 }
428 Variant_::DataSourceSeriesTag => {
429 let value = map.next_value()?;
430 SearchQuery::DataSourceSeriesTag(value)
431 }
432 Variant_::DataSourceRefName => {
433 let value = map.next_value()?;
434 SearchQuery::DataSourceRefName(value)
435 }
436 Variant_::DataSource => {
437 let value = map.next_value()?;
438 #[allow(deprecated)] SearchQuery::DataSource(value)
439 }
440 Variant_::RunNumber => {
441 let value = map.next_value()?;
442 SearchQuery::RunNumber(value)
443 }
444 Variant_::RunPrefix => {
445 let value = map.next_value()?;
446 SearchQuery::RunPrefix(value)
447 }
448 Variant_::CheckAlertStatesFilter => {
449 let value = map.next_value()?;
450 SearchQuery::CheckAlertStatesFilter(value)
451 }
452 Variant_::Archived => {
453 let value = map.next_value()?;
454 SearchQuery::Archived(value)
455 }
456 Variant_::And => {
457 let value = map.next_value()?;
458 SearchQuery::And(value)
459 }
460 Variant_::Or => {
461 let value = map.next_value()?;
462 SearchQuery::Or(value)
463 }
464 Variant_::Not => {
465 let value = map.next_value()?;
466 SearchQuery::Not(value)
467 }
468 Variant_::Workspace => {
469 let value = map.next_value()?;
470 SearchQuery::Workspace(value)
471 }
472 Variant_::Unknown(type_) => {
473 let value = map.next_value()?;
474 SearchQuery::Unknown(Unknown {
475 type_: type_.clone(),
476 value,
477 })
478 }
479 };
480 if map.next_key::<UnionTypeField_>()?.is_none() {
481 return Err(de::Error::missing_field("type"));
482 }
483 let type_variant = map.next_value::<Variant_>()?;
484 if variant != type_variant {
485 return Err(
486 de::Error::invalid_value(
487 de::Unexpected::Str(type_variant.as_str()),
488 &variant.as_str(),
489 ),
490 );
491 }
492 value
493 }
494 None => return Err(de::Error::missing_field("type")),
495 };
496 if map.next_key::<UnionField_<Variant_>>()?.is_some() {
497 return Err(de::Error::invalid_length(3, &"type and value fields"));
498 }
499 Ok(v)
500 }
501}
502#[derive(PartialEq)]
503enum Variant_ {
504 StartTimeInclusive,
505 StartTime,
506 EndTimeInclusive,
507 EndTime,
508 TimeRange,
509 CreatedAt,
510 ExactMatch,
511 SearchText,
512 Asset,
513 Assets,
514 IsSingleAsset,
515 Label,
516 Labels,
517 Property,
518 PropertyKey,
519 Properties,
520 NumericProperty,
521 DataSourceSeriesTag,
522 DataSourceRefName,
523 DataSource,
524 RunNumber,
525 RunPrefix,
526 CheckAlertStatesFilter,
527 Archived,
528 And,
529 Or,
530 Not,
531 Workspace,
532 Unknown(Box<str>),
533}
534impl Variant_ {
535 fn as_str(&self) -> &'static str {
536 match *self {
537 Variant_::StartTimeInclusive => "startTimeInclusive",
538 Variant_::StartTime => "startTime",
539 Variant_::EndTimeInclusive => "endTimeInclusive",
540 Variant_::EndTime => "endTime",
541 Variant_::TimeRange => "timeRange",
542 Variant_::CreatedAt => "createdAt",
543 Variant_::ExactMatch => "exactMatch",
544 Variant_::SearchText => "searchText",
545 Variant_::Asset => "asset",
546 Variant_::Assets => "assets",
547 Variant_::IsSingleAsset => "isSingleAsset",
548 Variant_::Label => "label",
549 Variant_::Labels => "labels",
550 Variant_::Property => "property",
551 Variant_::PropertyKey => "propertyKey",
552 Variant_::Properties => "properties",
553 Variant_::NumericProperty => "numericProperty",
554 Variant_::DataSourceSeriesTag => "dataSourceSeriesTag",
555 Variant_::DataSourceRefName => "dataSourceRefName",
556 Variant_::DataSource => "dataSource",
557 Variant_::RunNumber => "runNumber",
558 Variant_::RunPrefix => "runPrefix",
559 Variant_::CheckAlertStatesFilter => "checkAlertStatesFilter",
560 Variant_::Archived => "archived",
561 Variant_::And => "and",
562 Variant_::Or => "or",
563 Variant_::Not => "not",
564 Variant_::Workspace => "workspace",
565 Variant_::Unknown(_) => "unknown variant",
566 }
567 }
568}
569impl<'de> de::Deserialize<'de> for Variant_ {
570 fn deserialize<D>(d: D) -> Result<Variant_, D::Error>
571 where
572 D: de::Deserializer<'de>,
573 {
574 d.deserialize_str(VariantVisitor_)
575 }
576}
577struct VariantVisitor_;
578impl<'de> de::Visitor<'de> for VariantVisitor_ {
579 type Value = Variant_;
580 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
581 fmt.write_str("string")
582 }
583 fn visit_str<E>(self, value: &str) -> Result<Variant_, E>
584 where
585 E: de::Error,
586 {
587 let v = match value {
588 "startTimeInclusive" => Variant_::StartTimeInclusive,
589 "startTime" => Variant_::StartTime,
590 "endTimeInclusive" => Variant_::EndTimeInclusive,
591 "endTime" => Variant_::EndTime,
592 "timeRange" => Variant_::TimeRange,
593 "createdAt" => Variant_::CreatedAt,
594 "exactMatch" => Variant_::ExactMatch,
595 "searchText" => Variant_::SearchText,
596 "asset" => Variant_::Asset,
597 "assets" => Variant_::Assets,
598 "isSingleAsset" => Variant_::IsSingleAsset,
599 "label" => Variant_::Label,
600 "labels" => Variant_::Labels,
601 "property" => Variant_::Property,
602 "propertyKey" => Variant_::PropertyKey,
603 "properties" => Variant_::Properties,
604 "numericProperty" => Variant_::NumericProperty,
605 "dataSourceSeriesTag" => Variant_::DataSourceSeriesTag,
606 "dataSourceRefName" => Variant_::DataSourceRefName,
607 "dataSource" => Variant_::DataSource,
608 "runNumber" => Variant_::RunNumber,
609 "runPrefix" => Variant_::RunPrefix,
610 "checkAlertStatesFilter" => Variant_::CheckAlertStatesFilter,
611 "archived" => Variant_::Archived,
612 "and" => Variant_::And,
613 "or" => Variant_::Or,
614 "not" => Variant_::Not,
615 "workspace" => Variant_::Workspace,
616 value => Variant_::Unknown(value.to_string().into_boxed_str()),
617 };
618 Ok(v)
619 }
620}
621#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
623pub struct Unknown {
624 type_: Box<str>,
625 value: conjure_object::Any,
626}
627impl Unknown {
628 #[inline]
630 pub fn type_(&self) -> &str {
631 &self.type_
632 }
633}