Skip to main content

nominal_api/conjure/objects/scout/webhook/template/api/
validate_template_request.rs

1/// Request to validate a Handlebars webhook template
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    PartialEq,
8    Eq,
9    PartialOrd,
10    Ord,
11    Hash
12)]
13#[serde(crate = "conjure_object::serde")]
14#[conjure_object::private::staged_builder::staged_builder]
15#[builder(crate = conjure_object::private::staged_builder, update, inline)]
16pub struct ValidateTemplateRequest {
17    #[builder(into)]
18    #[serde(rename = "template")]
19    template: String,
20    #[builder(
21        default,
22        map(
23            key(type = String, into),
24            value(
25                custom(
26                    type = impl
27                    conjure_object::serde::Serialize,
28                    convert = |v|conjure_object::Any::new(
29                        v
30                    ).expect("value failed to serialize")
31                )
32            )
33        )
34    )]
35    #[serde(
36        rename = "sampleContext",
37        skip_serializing_if = "std::collections::BTreeMap::is_empty",
38        default
39    )]
40    sample_context: std::collections::BTreeMap<String, conjure_object::Any>,
41}
42impl ValidateTemplateRequest {
43    /// Constructs a new instance of the type.
44    #[inline]
45    pub fn new(template: impl Into<String>) -> Self {
46        Self::builder().template(template).build()
47    }
48    /// Handlebars template string to validate
49    #[inline]
50    pub fn template(&self) -> &str {
51        &*self.template
52    }
53    /// Sample variable values for template evaluation
54    #[inline]
55    pub fn sample_context(
56        &self,
57    ) -> &std::collections::BTreeMap<String, conjure_object::Any> {
58        &self.sample_context
59    }
60}