Skip to main content

nominal_api/conjure/objects/scout/spatial/api/
create_spatial_request.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    conjure_object::private::DeriveWith
7)]
8#[serde(crate = "conjure_object::serde")]
9#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[conjure_object::private::staged_builder::staged_builder]
11#[builder(crate = conjure_object::private::staged_builder, update, inline)]
12pub struct CreateSpatialRequest {
13    #[builder(into)]
14    #[serde(rename = "title")]
15    title: String,
16    #[builder(default, into)]
17    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
18    description: Option<String>,
19    #[builder(default, set(item(type = super::super::super::super::api::Label)))]
20    #[serde(
21        rename = "labels",
22        skip_serializing_if = "std::collections::BTreeSet::is_empty",
23        default
24    )]
25    labels: std::collections::BTreeSet<super::super::super::super::api::Label>,
26    #[builder(
27        default,
28        map(
29            key(type = super::super::super::super::api::PropertyName),
30            value(type = super::super::super::super::api::PropertyValue)
31        )
32    )]
33    #[serde(
34        rename = "properties",
35        skip_serializing_if = "std::collections::BTreeMap::is_empty",
36        default
37    )]
38    properties: std::collections::BTreeMap<
39        super::super::super::super::api::PropertyName,
40        super::super::super::super::api::PropertyValue,
41    >,
42    #[builder(custom(type = super::SpatialTypeMetadata, convert = Box::new))]
43    #[serde(rename = "typeMetadata")]
44    type_metadata: Box<super::SpatialTypeMetadata>,
45    #[builder(default, into)]
46    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
47    workspace: Option<super::super::super::super::api::rids::WorkspaceRid>,
48    #[builder(default, set(item(type = super::super::super::rids::api::MarkingRid)))]
49    #[serde(
50        rename = "markingRids",
51        skip_serializing_if = "std::collections::BTreeSet::is_empty",
52        default
53    )]
54    marking_rids: std::collections::BTreeSet<super::super::super::rids::api::MarkingRid>,
55}
56impl CreateSpatialRequest {
57    /// Constructs a new instance of the type.
58    #[inline]
59    pub fn new(
60        title: impl Into<String>,
61        type_metadata: super::SpatialTypeMetadata,
62    ) -> Self {
63        Self::builder().title(title).type_metadata(type_metadata).build()
64    }
65    #[inline]
66    pub fn title(&self) -> &str {
67        &*self.title
68    }
69    #[inline]
70    pub fn description(&self) -> Option<&str> {
71        self.description.as_ref().map(|o| &**o)
72    }
73    #[inline]
74    pub fn labels(
75        &self,
76    ) -> &std::collections::BTreeSet<super::super::super::super::api::Label> {
77        &self.labels
78    }
79    #[inline]
80    pub fn properties(
81        &self,
82    ) -> &std::collections::BTreeMap<
83        super::super::super::super::api::PropertyName,
84        super::super::super::super::api::PropertyValue,
85    > {
86        &self.properties
87    }
88    #[inline]
89    pub fn type_metadata(&self) -> &super::SpatialTypeMetadata {
90        &*self.type_metadata
91    }
92    /// The workspace in which to create the spatial asset. If not provided, the asset will be created in
93    /// the default workspace for the user's organization, if the default workspace is configured.
94    #[inline]
95    pub fn workspace(
96        &self,
97    ) -> Option<&super::super::super::super::api::rids::WorkspaceRid> {
98        self.workspace.as_ref().map(|o| &*o)
99    }
100    /// The markings to apply to the created spatial asset.
101    /// If not provided, the asset will be visible to all users in the same workspace.
102    #[inline]
103    pub fn marking_rids(
104        &self,
105    ) -> &std::collections::BTreeSet<super::super::super::rids::api::MarkingRid> {
106        &self.marking_rids
107    }
108}