Skip to main content

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