Skip to main content

nominal_api/conjure/objects/scout/asset/api/
create_asset_request.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 CreateAssetRequest {
16    #[builder(into)]
17    #[serde(rename = "title")]
18    title: String,
19    #[builder(default, into)]
20    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
21    description: Option<String>,
22    #[builder(
23        default,
24        map(
25            key(type = super::super::super::super::api::PropertyName),
26            value(type = super::super::super::super::api::PropertyValue)
27        )
28    )]
29    #[serde(
30        rename = "properties",
31        skip_serializing_if = "std::collections::BTreeMap::is_empty",
32        default
33    )]
34    properties: std::collections::BTreeMap<
35        super::super::super::super::api::PropertyName,
36        super::super::super::super::api::PropertyValue,
37    >,
38    #[builder(default, set(item(type = super::super::super::super::api::Label)))]
39    #[serde(
40        rename = "labels",
41        skip_serializing_if = "std::collections::BTreeSet::is_empty",
42        default
43    )]
44    labels: std::collections::BTreeSet<super::super::super::super::api::Label>,
45    #[builder(default, list(item(type = super::super::super::run::api::Link)))]
46    #[serde(rename = "links", skip_serializing_if = "Vec::is_empty", default)]
47    links: Vec<super::super::super::run::api::Link>,
48    #[builder(default, set(item(type = super::CreateAssetDataScope)))]
49    #[serde(
50        rename = "dataScopes",
51        skip_serializing_if = "std::collections::BTreeSet::is_empty",
52        default
53    )]
54    data_scopes: std::collections::BTreeSet<super::CreateAssetDataScope>,
55    #[builder(default, set(item(type = conjure_object::ResourceIdentifier)))]
56    #[serde(
57        rename = "attachments",
58        skip_serializing_if = "std::collections::BTreeSet::is_empty",
59        default
60    )]
61    attachments: std::collections::BTreeSet<conjure_object::ResourceIdentifier>,
62    #[builder(default, into)]
63    #[serde(rename = "type", skip_serializing_if = "Option::is_none", default)]
64    type_: Option<super::super::super::rids::api::TypeRid>,
65    #[builder(default, into)]
66    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
67    workspace: Option<conjure_object::ResourceIdentifier>,
68}
69impl CreateAssetRequest {
70    /// Constructs a new instance of the type.
71    #[inline]
72    pub fn new(title: impl Into<String>) -> Self {
73        Self::builder().title(title).build()
74    }
75    #[inline]
76    pub fn title(&self) -> &str {
77        &*self.title
78    }
79    #[inline]
80    pub fn description(&self) -> Option<&str> {
81        self.description.as_ref().map(|o| &**o)
82    }
83    #[inline]
84    pub fn properties(
85        &self,
86    ) -> &std::collections::BTreeMap<
87        super::super::super::super::api::PropertyName,
88        super::super::super::super::api::PropertyValue,
89    > {
90        &self.properties
91    }
92    #[inline]
93    pub fn labels(
94        &self,
95    ) -> &std::collections::BTreeSet<super::super::super::super::api::Label> {
96        &self.labels
97    }
98    #[inline]
99    pub fn links(&self) -> &[super::super::super::run::api::Link] {
100        &*self.links
101    }
102    /// The data scopes associated with the asset.
103    #[inline]
104    pub fn data_scopes(
105        &self,
106    ) -> &std::collections::BTreeSet<super::CreateAssetDataScope> {
107        &self.data_scopes
108    }
109    #[inline]
110    pub fn attachments(
111        &self,
112    ) -> &std::collections::BTreeSet<conjure_object::ResourceIdentifier> {
113        &self.attachments
114    }
115    #[inline]
116    pub fn type_(&self) -> Option<&super::super::super::rids::api::TypeRid> {
117        self.type_.as_ref().map(|o| &*o)
118    }
119    /// The workspace in which to create the asset. If not provided, the asset will be created in
120    /// the default workspace for the user's organization, if the default workspace for the
121    /// organization is configured.
122    /// All data scopes, attachments, and the optional asset type must be in the same workspace.
123    #[inline]
124    pub fn workspace(&self) -> Option<&conjure_object::ResourceIdentifier> {
125        self.workspace.as_ref().map(|o| &*o)
126    }
127}