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<conjure_object::ResourceIdentifier>,
34    #[builder(default, into)]
35    #[serde(rename = "labels", skip_serializing_if = "Option::is_none", default)]
36    labels: Option<std::collections::BTreeSet<String>>,
37    #[builder(default, into)]
38    #[serde(rename = "properties", skip_serializing_if = "Option::is_none", default)]
39    properties: Option<std::collections::BTreeMap<String, String>>,
40    #[builder(
41        default,
42        custom(
43            type = impl
44            Into<Option<super::super::super::super::api::ThemeAwareImage>>,
45            convert = |v|v.into().map(Box::new)
46        )
47    )]
48    #[serde(rename = "previewImage", skip_serializing_if = "Option::is_none", default)]
49    preview_image: Option<Box<super::super::super::super::api::ThemeAwareImage>>,
50}
51impl DuplicateTemplateRequest {
52    /// Constructs a new instance of the type.
53    #[inline]
54    pub fn new() -> Self {
55        Self::builder().build()
56    }
57    /// Override the title of the duplicated template. If not provided, generates a copy title
58    /// from the source using the titleSuffix.
59    #[inline]
60    pub fn title(&self) -> Option<&str> {
61        self.title.as_ref().map(|o| &**o)
62    }
63    /// Custom suffix for generating the copy title (e.g., "v2").
64    /// Defaults to "copy". Ignored if title is explicitly provided.
65    #[inline]
66    pub fn title_suffix(&self) -> Option<&str> {
67        self.title_suffix.as_ref().map(|o| &**o)
68    }
69    /// Override description. Defaults to the source template's description.
70    #[inline]
71    pub fn description(&self) -> Option<&str> {
72        self.description.as_ref().map(|o| &**o)
73    }
74    /// Override published status. Defaults to false.
75    #[inline]
76    pub fn is_published(&self) -> Option<bool> {
77        self.is_published.as_ref().map(|o| *o)
78    }
79    /// The workspace for the duplicated template. If not provided, the template will be created
80    /// in the default workspace for the user's organization.
81    #[inline]
82    pub fn workspace(&self) -> Option<&conjure_object::ResourceIdentifier> {
83        self.workspace.as_ref().map(|o| &*o)
84    }
85    /// Override labels. Defaults to the source template's labels.
86    #[inline]
87    pub fn labels(&self) -> Option<&std::collections::BTreeSet<String>> {
88        self.labels.as_ref().map(|o| &*o)
89    }
90    /// Override properties. Defaults to the source template's properties.
91    #[inline]
92    pub fn properties(&self) -> Option<&std::collections::BTreeMap<String, String>> {
93        self.properties.as_ref().map(|o| &*o)
94    }
95    /// Override preview image. Defaults to the source template's preview image.
96    #[inline]
97    pub fn preview_image(
98        &self,
99    ) -> Option<&super::super::super::super::api::ThemeAwareImage> {
100        self.preview_image.as_ref().map(|o| &**o)
101    }
102}