Skip to main content

nominal_api/conjure/objects/scout/integrations/api/
secure_webhook_integration.rs

1/// Advanced webhook integration with HMAC signing, custom headers, and configurable defaults.
2///
3/// Server-side validation enforces:
4/// - URL must use HTTPS protocol
5/// - customHeaders blocklist (see customHeaders field documentation)
6#[derive(
7    Debug,
8    Clone,
9    conjure_object::serde::Serialize,
10    conjure_object::serde::Deserialize,
11    PartialEq,
12    Eq,
13    PartialOrd,
14    Ord,
15    Hash
16)]
17#[serde(crate = "conjure_object::serde")]
18#[conjure_object::private::staged_builder::staged_builder]
19#[builder(crate = conjure_object::private::staged_builder, update, inline)]
20pub struct SecureWebhookIntegration {
21    #[builder(into)]
22    #[serde(rename = "url")]
23    url: String,
24    #[builder(default, map(key(type = String, into), value(type = String, into)))]
25    #[serde(
26        rename = "customHeaders",
27        skip_serializing_if = "std::collections::BTreeMap::is_empty",
28        default
29    )]
30    custom_headers: std::collections::BTreeMap<String, String>,
31    #[builder(custom(type = super::WebhookDeliveryConfig, convert = Box::new))]
32    #[serde(rename = "deliveryConfig")]
33    delivery_config: Box<super::WebhookDeliveryConfig>,
34}
35impl SecureWebhookIntegration {
36    /// Constructs a new instance of the type.
37    #[inline]
38    pub fn new(
39        url: impl Into<String>,
40        delivery_config: super::WebhookDeliveryConfig,
41    ) -> Self {
42        Self::builder().url(url).delivery_config(delivery_config).build()
43    }
44    /// Webhook URL (must be HTTPS)
45    #[inline]
46    pub fn url(&self) -> &str {
47        &*self.url
48    }
49    /// Additional HTTP headers to include in all webhook requests.
50    /// Server-side validation rejects security-sensitive headers to prevent credential leakage:
51    /// Authorization, Cookie, X-API-Key, X-Auth-Token, Proxy-Authorization, and any header starting with X-Nominal-.
52    /// Validation returns clear error messages for blocked headers.
53    #[inline]
54    pub fn custom_headers(&self) -> &std::collections::BTreeMap<String, String> {
55        &self.custom_headers
56    }
57    /// Retry and timeout configuration for webhook delivery attempts
58    #[inline]
59    pub fn delivery_config(&self) -> &super::WebhookDeliveryConfig {
60        &*self.delivery_config
61    }
62}