Skip to main content

nominal_api/conjure/objects/scout/template/api/
duplicate_template_request.rs

1/// Request to duplicate a template. All content fields (layout, content) are copied from the
2/// source template. Metadata fields can be optionally overridden; if not provided, they default
3/// to the source template's values (except isPublished, which defaults to false).
4#[derive(
5    Debug,
6    Clone,
7    conjure_object::serde::Serialize,
8    conjure_object::serde::Deserialize,
9    PartialEq,
10    Eq,
11    PartialOrd,
12    Ord,
13    Hash
14)]
15#[serde(crate = "conjure_object::serde")]
16#[conjure_object::private::staged_builder::staged_builder]
17#[builder(crate = conjure_object::private::staged_builder, update, inline)]
18pub struct DuplicateTemplateRequest {
19    #[builder(default, into)]
20    #[serde(rename = "title", skip_serializing_if = "Option::is_none", default)]
21    title: Option<String>,
22    #[builder(default, into)]
23    #[serde(rename = "titleSuffix", skip_serializing_if = "Option::is_none", default)]
24    title_suffix: Option<String>,
25    #[builder(default, into)]
26    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
27    description: Option<String>,
28    #[builder(default, into)]
29    #[serde(rename = "isPublished", skip_serializing_if = "Option::is_none", default)]
30    is_published: Option<bool>,
31    #[builder(default, into)]
32    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
33    workspace: Option<super::super::super::super::api::rids::WorkspaceRid>,
34    #[builder(default, into)]
35    #[serde(rename = "labels", skip_serializing_if = "Option::is_none", default)]
36    labels: Option<std::collections::BTreeSet<super::super::super::super::api::Label>>,
37    #[builder(default, into)]
38    #[serde(rename = "properties", skip_serializing_if = "Option::is_none", default)]
39    properties: Option<
40        std::collections::BTreeMap<
41            super::super::super::super::api::PropertyName,
42            super::super::super::super::api::PropertyValue,
43        >,
44    >,
45    #[builder(
46        default,
47        custom(
48            type = impl
49            Into<Option<super::super::super::super::api::ThemeAwareImage>>,
50            convert = |v|v.into().map(Box::new)
51        )
52    )]
53    #[serde(rename = "previewImage", skip_serializing_if = "Option::is_none", default)]
54    preview_image: Option<Box<super::super::super::super::api::ThemeAwareImage>>,
55}
56impl DuplicateTemplateRequest {
57    /// Constructs a new instance of the type.
58    #[inline]
59    pub fn new() -> Self {
60        Self::builder().build()
61    }
62    /// Override the title of the duplicated template. If not provided, generates a copy title
63    /// from the source using the titleSuffix.
64    #[inline]
65    pub fn title(&self) -> Option<&str> {
66        self.title.as_ref().map(|o| &**o)
67    }
68    /// Custom suffix for generating the copy title (e.g., "v2").
69    /// Defaults to "copy". Ignored if title is explicitly provided.
70    #[inline]
71    pub fn title_suffix(&self) -> Option<&str> {
72        self.title_suffix.as_ref().map(|o| &**o)
73    }
74    /// Override description. Defaults to the source template's description.
75    #[inline]
76    pub fn description(&self) -> Option<&str> {
77        self.description.as_ref().map(|o| &**o)
78    }
79    /// Override published status. Defaults to false.
80    #[inline]
81    pub fn is_published(&self) -> Option<bool> {
82        self.is_published.as_ref().map(|o| *o)
83    }
84    /// The workspace for the duplicated template. If not provided, the template will be created
85    /// in the default workspace for the user's organization.
86    #[inline]
87    pub fn workspace(
88        &self,
89    ) -> Option<&super::super::super::super::api::rids::WorkspaceRid> {
90        self.workspace.as_ref().map(|o| &*o)
91    }
92    /// Override labels. Defaults to the source template's labels.
93    #[inline]
94    pub fn labels(
95        &self,
96    ) -> Option<&std::collections::BTreeSet<super::super::super::super::api::Label>> {
97        self.labels.as_ref().map(|o| &*o)
98    }
99    /// Override properties. Defaults to the source template's properties.
100    #[inline]
101    pub fn properties(
102        &self,
103    ) -> Option<
104        &std::collections::BTreeMap<
105            super::super::super::super::api::PropertyName,
106            super::super::super::super::api::PropertyValue,
107        >,
108    > {
109        self.properties.as_ref().map(|o| &*o)
110    }
111    /// Override preview image. Defaults to the source template's preview image.
112    #[inline]
113    pub fn preview_image(
114        &self,
115    ) -> Option<&super::super::super::super::api::ThemeAwareImage> {
116        self.preview_image.as_ref().map(|o| &**o)
117    }
118}