Skip to main content

nominal_api/conjure/objects/scout/run/api/
create_run_data_source.rs

1/// For write requests, we want to allow for optional fields
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    PartialEq,
8    Eq,
9    PartialOrd,
10    Ord,
11    Hash
12)]
13#[serde(crate = "conjure_object::serde")]
14#[conjure_object::private::staged_builder::staged_builder]
15#[builder(crate = conjure_object::private::staged_builder, update, inline)]
16pub struct CreateRunDataSource {
17    #[builder(
18        default,
19        custom(
20            type = impl
21            Into<Option<super::DataSource>>,
22            convert = |v|v.into().map(Box::new)
23        )
24    )]
25    #[serde(rename = "dataSource", skip_serializing_if = "Option::is_none", default)]
26    data_source: Option<Box<super::DataSource>>,
27    #[builder(default, into)]
28    #[serde(rename = "dataSourceRid", skip_serializing_if = "Option::is_none", default)]
29    data_source_rid: Option<conjure_object::ResourceIdentifier>,
30    #[builder(
31        default,
32        custom(
33            type = impl
34            Into<Option<super::Duration>>,
35            convert = |v|v.into().map(Box::new)
36        )
37    )]
38    #[serde(rename = "offset", skip_serializing_if = "Option::is_none", default)]
39    offset: Option<Box<super::Duration>>,
40    #[builder(default, map(key(type = String, into), value(type = String, into)))]
41    #[serde(
42        rename = "seriesTags",
43        skip_serializing_if = "std::collections::BTreeMap::is_empty",
44        default
45    )]
46    series_tags: std::collections::BTreeMap<String, String>,
47}
48impl CreateRunDataSource {
49    /// Constructs a new instance of the type.
50    #[inline]
51    pub fn new() -> Self {
52        Self::builder().build()
53    }
54    /// One of dataSource and dataSourceRid must be present.
55    /// dataSourceRid takes precedence.
56    #[deprecated(note = "Use dataSourceRid instead.")]
57    #[inline]
58    pub fn data_source(&self) -> Option<&super::DataSource> {
59        self.data_source.as_ref().map(|o| &**o)
60    }
61    /// One of dataSource and dataSourceRid must be present.
62    /// dataSourceRid takes precedence.
63    #[inline]
64    pub fn data_source_rid(&self) -> Option<&conjure_object::ResourceIdentifier> {
65        self.data_source_rid.as_ref().map(|o| &*o)
66    }
67    #[inline]
68    pub fn offset(&self) -> Option<&super::Duration> {
69        self.offset.as_ref().map(|o| &**o)
70    }
71    /// Used to resolve logical series for this data source.
72    #[inline]
73    pub fn series_tags(&self) -> &std::collections::BTreeMap<String, String> {
74        &self.series_tags
75    }
76}