Skip to main content

nominal_api/conjure/objects/scout/datasource/connection/api/
create_connection.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    PartialEq,
7    Eq,
8    PartialOrd,
9    Ord,
10    Hash
11)]
12#[serde(crate = "conjure_object::serde")]
13#[conjure_object::private::staged_builder::staged_builder]
14#[builder(crate = conjure_object::private::staged_builder, update, inline)]
15pub struct CreateConnection {
16    #[builder(into)]
17    #[serde(rename = "name")]
18    name: String,
19    #[builder(default, into)]
20    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
21    description: Option<String>,
22    #[builder(custom(type = super::ConnectionDetails, convert = Box::new))]
23    #[serde(rename = "connectionDetails")]
24    connection_details: Box<super::ConnectionDetails>,
25    #[builder(default, map(key(type = String, into), value(type = String, into)))]
26    #[serde(
27        rename = "metadata",
28        skip_serializing_if = "std::collections::BTreeMap::is_empty",
29        default
30    )]
31    metadata: std::collections::BTreeMap<String, String>,
32    #[builder(default, set(item(type = String, into)))]
33    #[serde(
34        rename = "requiredTagNames",
35        skip_serializing_if = "std::collections::BTreeSet::is_empty",
36        default
37    )]
38    required_tag_names: std::collections::BTreeSet<String>,
39    #[builder(default, into)]
40    #[serde(
41        rename = "availableTagValues",
42        skip_serializing_if = "Option::is_none",
43        default
44    )]
45    available_tag_values: Option<
46        std::collections::BTreeMap<String, std::collections::BTreeSet<String>>,
47    >,
48    #[builder(
49        default,
50        custom(
51            type = impl
52            Into<Option<super::ScrapingConfig>>,
53            convert = |v|v.into().map(Box::new)
54        )
55    )]
56    #[serde(rename = "scraping", skip_serializing_if = "Option::is_none", default)]
57    scraping: Option<Box<super::ScrapingConfig>>,
58    #[serde(rename = "shouldScrape")]
59    should_scrape: bool,
60    #[builder(
61        default,
62        custom(
63            type = impl
64            Into<Option<super::LimitsConfig>>,
65            convert = |v|v.into().map(Box::new)
66        )
67    )]
68    #[serde(rename = "limits", skip_serializing_if = "Option::is_none", default)]
69    limits: Option<Box<super::LimitsConfig>>,
70    #[builder(default, into)]
71    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
72    workspace: Option<conjure_object::ResourceIdentifier>,
73    #[builder(
74        default,
75        set(item(type = super::super::super::super::rids::api::MarkingRid))
76    )]
77    #[serde(
78        rename = "markingRids",
79        skip_serializing_if = "std::collections::BTreeSet::is_empty",
80        default
81    )]
82    marking_rids: std::collections::BTreeSet<
83        super::super::super::super::rids::api::MarkingRid,
84    >,
85}
86impl CreateConnection {
87    /// Constructs a new instance of the type.
88    #[inline]
89    pub fn new(
90        name: impl Into<String>,
91        connection_details: super::ConnectionDetails,
92        should_scrape: bool,
93    ) -> Self {
94        Self::builder()
95            .name(name)
96            .connection_details(connection_details)
97            .should_scrape(should_scrape)
98            .build()
99    }
100    #[inline]
101    pub fn name(&self) -> &str {
102        &*self.name
103    }
104    #[inline]
105    pub fn description(&self) -> Option<&str> {
106        self.description.as_ref().map(|o| &**o)
107    }
108    #[inline]
109    pub fn connection_details(&self) -> &super::ConnectionDetails {
110        &*self.connection_details
111    }
112    /// Metadata information about the connection which is not relevant to the DB connection itself.
113    #[inline]
114    pub fn metadata(&self) -> &std::collections::BTreeMap<String, String> {
115        &self.metadata
116    }
117    /// Additional tag name that are required to construct a fully qualified series.
118    #[inline]
119    pub fn required_tag_names(&self) -> &std::collections::BTreeSet<String> {
120        &self.required_tag_names
121    }
122    /// In most cases, this does not to be set by the user. Throws if populated for Nominal connections, which
123    /// have their tags automatically indexed in the underlying database. Tags for external connections are
124    /// periodically scraped. Tags should only be updated  manually for Visual crossing connections.
125    #[inline]
126    pub fn available_tag_values(
127        &self,
128    ) -> Option<
129        &std::collections::BTreeMap<String, std::collections::BTreeSet<String>>,
130    > {
131        self.available_tag_values.as_ref().map(|o| &*o)
132    }
133    #[inline]
134    pub fn scraping(&self) -> Option<&super::ScrapingConfig> {
135        self.scraping.as_ref().map(|o| &**o)
136    }
137    #[inline]
138    pub fn should_scrape(&self) -> bool {
139        self.should_scrape
140    }
141    #[inline]
142    pub fn limits(&self) -> Option<&super::LimitsConfig> {
143        self.limits.as_ref().map(|o| &**o)
144    }
145    /// The workspace in which to create the connection. If not provided, the connection will be created in the default workspace for
146    /// the user's organization, if the default workspace for the organization is configured.
147    #[inline]
148    pub fn workspace(&self) -> Option<&conjure_object::ResourceIdentifier> {
149        self.workspace.as_ref().map(|o| &*o)
150    }
151    /// The markings to apply to the created connection.
152    /// If not provided, the connection will be visible to all users in the same workspace.
153    #[inline]
154    pub fn marking_rids(
155        &self,
156    ) -> &std::collections::BTreeSet<super::super::super::super::rids::api::MarkingRid> {
157        &self.marking_rids
158    }
159}