Skip to main content

nominal_api/conjure/objects/scout/template/api/
create_template_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 CreateTemplateRequest {
13    #[builder(into)]
14    #[serde(rename = "title")]
15    title: String,
16    #[builder(into)]
17    #[serde(rename = "description")]
18    description: String,
19    #[builder(default, set(item(type = String, into)))]
20    #[serde(
21        rename = "labels",
22        skip_serializing_if = "std::collections::BTreeSet::is_empty",
23        default
24    )]
25    labels: std::collections::BTreeSet<String>,
26    #[builder(default, map(key(type = String, into), value(type = String, into)))]
27    #[serde(
28        rename = "properties",
29        skip_serializing_if = "std::collections::BTreeMap::is_empty",
30        default
31    )]
32    properties: std::collections::BTreeMap<String, String>,
33    #[builder(default, into)]
34    #[serde(rename = "isPublished", skip_serializing_if = "Option::is_none", default)]
35    is_published: Option<bool>,
36    #[builder(default, into)]
37    #[serde(rename = "charts", skip_serializing_if = "Option::is_none", default)]
38    charts: Option<Vec<super::super::super::rids::api::VersionedVizId>>,
39    #[builder(
40        custom(
41            type = super::super::super::layout::api::WorkbookLayout,
42            convert = Box::new
43        )
44    )]
45    #[serde(rename = "layout")]
46    layout: Box<super::super::super::layout::api::WorkbookLayout>,
47    #[builder(
48        custom(
49            type = super::super::super::workbookcommon::api::WorkbookContent,
50            convert = Box::new
51        )
52    )]
53    #[serde(rename = "content")]
54    content: Box<super::super::super::workbookcommon::api::WorkbookContent>,
55    #[builder(into)]
56    #[serde(rename = "message")]
57    message: String,
58    #[builder(
59        default,
60        custom(
61            type = impl
62            Into<Option<super::super::super::super::api::ThemeAwareImage>>,
63            convert = |v|v.into().map(Box::new)
64        )
65    )]
66    #[serde(rename = "previewImage", skip_serializing_if = "Option::is_none", default)]
67    preview_image: Option<Box<super::super::super::super::api::ThemeAwareImage>>,
68    #[builder(default, into)]
69    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
70    workspace: Option<conjure_object::ResourceIdentifier>,
71}
72impl CreateTemplateRequest {
73    #[inline]
74    pub fn title(&self) -> &str {
75        &*self.title
76    }
77    #[inline]
78    pub fn description(&self) -> &str {
79        &*self.description
80    }
81    #[inline]
82    pub fn labels(&self) -> &std::collections::BTreeSet<String> {
83        &self.labels
84    }
85    #[inline]
86    pub fn properties(&self) -> &std::collections::BTreeMap<String, String> {
87        &self.properties
88    }
89    /// Default is true
90    #[inline]
91    pub fn is_published(&self) -> Option<bool> {
92        self.is_published.as_ref().map(|o| *o)
93    }
94    #[deprecated(
95        note = "charts are no longer versioned resources. They are stored in workbook content."
96    )]
97    #[inline]
98    pub fn charts(&self) -> Option<&[super::super::super::rids::api::VersionedVizId]> {
99        self.charts.as_ref().map(|o| &**o)
100    }
101    #[inline]
102    pub fn layout(&self) -> &super::super::super::layout::api::WorkbookLayout {
103        &*self.layout
104    }
105    #[inline]
106    pub fn content(&self) -> &super::super::super::workbookcommon::api::WorkbookContent {
107        &*self.content
108    }
109    #[inline]
110    pub fn message(&self) -> &str {
111        &*self.message
112    }
113    /// Theme-aware preview image for the template. Falls back to a default illustration if not provided.
114    #[inline]
115    pub fn preview_image(
116        &self,
117    ) -> Option<&super::super::super::super::api::ThemeAwareImage> {
118        self.preview_image.as_ref().map(|o| &**o)
119    }
120    /// The workspace in which to create the template. If not provided, the template will be created in the default workspace for
121    /// the user's organization, if the default workspace for the organization is configured.
122    #[inline]
123    pub fn workspace(&self) -> Option<&conjure_object::ResourceIdentifier> {
124        self.workspace.as_ref().map(|o| &*o)
125    }
126}