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(
33        default,
34        set(item(type = super::super::super::super::super::api::TagName))
35    )]
36    #[serde(
37        rename = "requiredTagNames",
38        skip_serializing_if = "std::collections::BTreeSet::is_empty",
39        default
40    )]
41    required_tag_names: std::collections::BTreeSet<
42        super::super::super::super::super::api::TagName,
43    >,
44    #[builder(default, into)]
45    #[serde(
46        rename = "availableTagValues",
47        skip_serializing_if = "Option::is_none",
48        default
49    )]
50    available_tag_values: Option<
51        std::collections::BTreeMap<
52            super::super::super::super::super::api::TagName,
53            std::collections::BTreeSet<super::super::super::super::super::api::TagValue>,
54        >,
55    >,
56    #[builder(
57        default,
58        custom(
59            type = impl
60            Into<Option<super::ScrapingConfig>>,
61            convert = |v|v.into().map(Box::new)
62        )
63    )]
64    #[serde(rename = "scraping", skip_serializing_if = "Option::is_none", default)]
65    scraping: Option<Box<super::ScrapingConfig>>,
66    #[serde(rename = "shouldScrape")]
67    should_scrape: bool,
68    #[builder(
69        default,
70        custom(
71            type = impl
72            Into<Option<super::LimitsConfig>>,
73            convert = |v|v.into().map(Box::new)
74        )
75    )]
76    #[serde(rename = "limits", skip_serializing_if = "Option::is_none", default)]
77    limits: Option<Box<super::LimitsConfig>>,
78    #[builder(default, into)]
79    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
80    workspace: Option<super::super::super::super::super::api::rids::WorkspaceRid>,
81    #[builder(
82        default,
83        set(item(type = super::super::super::super::rids::api::MarkingRid))
84    )]
85    #[serde(
86        rename = "markingRids",
87        skip_serializing_if = "std::collections::BTreeSet::is_empty",
88        default
89    )]
90    marking_rids: std::collections::BTreeSet<
91        super::super::super::super::rids::api::MarkingRid,
92    >,
93}
94impl CreateConnection {
95    /// Constructs a new instance of the type.
96    #[inline]
97    pub fn new(
98        name: impl Into<String>,
99        connection_details: super::ConnectionDetails,
100        should_scrape: bool,
101    ) -> Self {
102        Self::builder()
103            .name(name)
104            .connection_details(connection_details)
105            .should_scrape(should_scrape)
106            .build()
107    }
108    #[inline]
109    pub fn name(&self) -> &str {
110        &*self.name
111    }
112    #[inline]
113    pub fn description(&self) -> Option<&str> {
114        self.description.as_ref().map(|o| &**o)
115    }
116    #[inline]
117    pub fn connection_details(&self) -> &super::ConnectionDetails {
118        &*self.connection_details
119    }
120    /// Metadata information about the connection which is not relevant to the DB connection itself.
121    #[inline]
122    pub fn metadata(&self) -> &std::collections::BTreeMap<String, String> {
123        &self.metadata
124    }
125    /// Additional tag name that are required to construct a fully qualified series.
126    #[inline]
127    pub fn required_tag_names(
128        &self,
129    ) -> &std::collections::BTreeSet<super::super::super::super::super::api::TagName> {
130        &self.required_tag_names
131    }
132    /// In most cases, this does not to be set by the user. Throws if populated for Nominal connections, which
133    /// have their tags automatically indexed in the underlying database. Tags for external connections are
134    /// periodically scraped. Tags should only be updated  manually for Visual crossing connections.
135    #[inline]
136    pub fn available_tag_values(
137        &self,
138    ) -> Option<
139        &std::collections::BTreeMap<
140            super::super::super::super::super::api::TagName,
141            std::collections::BTreeSet<super::super::super::super::super::api::TagValue>,
142        >,
143    > {
144        self.available_tag_values.as_ref().map(|o| &*o)
145    }
146    #[inline]
147    pub fn scraping(&self) -> Option<&super::ScrapingConfig> {
148        self.scraping.as_ref().map(|o| &**o)
149    }
150    #[inline]
151    pub fn should_scrape(&self) -> bool {
152        self.should_scrape
153    }
154    #[inline]
155    pub fn limits(&self) -> Option<&super::LimitsConfig> {
156        self.limits.as_ref().map(|o| &**o)
157    }
158    /// The workspace in which to create the connection. If not provided, the connection will be created in the default workspace for
159    /// the user's organization, if the default workspace for the organization is configured.
160    #[inline]
161    pub fn workspace(
162        &self,
163    ) -> Option<&super::super::super::super::super::api::rids::WorkspaceRid> {
164        self.workspace.as_ref().map(|o| &*o)
165    }
166    /// The markings to apply to the created connection.
167    /// If not provided, the connection will be visible to all users in the same workspace.
168    #[inline]
169    pub fn marking_rids(
170        &self,
171    ) -> &std::collections::BTreeSet<super::super::super::super::rids::api::MarkingRid> {
172        &self.marking_rids
173    }
174}