Skip to main content

nautobot_openapi/models/
webhook.rs

1/*
2 * API Documentation
3 *
4 * Source of truth and network automation platform
5 *
6 * The version of the OpenAPI document: 3.1.0 (3.1)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// Webhook : Extends the built-in ModelSerializer to enforce calling full_clean() on a copy of the associated instance during validation. (DRF does not do this by default; see <https://github.com/encode/django-rest-framework/issues/3144>)
12
13#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
14pub struct Webhook {
15    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
16    pub id: Option<uuid::Uuid>,
17    #[serde(rename = "object_type", skip_serializing_if = "Option::is_none")]
18    pub object_type: Option<String>,
19    /// Human friendly display value
20    #[serde(rename = "display", skip_serializing_if = "Option::is_none")]
21    pub display: Option<String>,
22    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
23    pub url: Option<String>,
24    #[serde(rename = "natural_slug", skip_serializing_if = "Option::is_none")]
25    pub natural_slug: Option<String>,
26    #[serde(rename = "content_types")]
27    pub content_types: Vec<String>,
28    #[serde(rename = "name")]
29    pub name: String,
30    /// Call this webhook when a matching object is created.
31    #[serde(rename = "type_create", skip_serializing_if = "Option::is_none")]
32    pub type_create: Option<bool>,
33    /// Call this webhook when a matching object is updated.
34    #[serde(rename = "type_update", skip_serializing_if = "Option::is_none")]
35    pub type_update: Option<bool>,
36    /// Call this webhook when a matching object is deleted.
37    #[serde(rename = "type_delete", skip_serializing_if = "Option::is_none")]
38    pub type_delete: Option<bool>,
39    /// A POST will be sent to this URL when the webhook is called.
40    #[serde(rename = "payload_url")]
41    pub payload_url: String,
42    #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
43    pub enabled: Option<bool>,
44    #[serde(rename = "http_method", skip_serializing_if = "Option::is_none")]
45    pub http_method: Option<crate::models::HttpMethodEnum>,
46    /// The complete list of official content types is available here (<https://www.iana.org/assignments/media-types/media-types.xhtml>).
47    #[serde(rename = "http_content_type", skip_serializing_if = "Option::is_none")]
48    pub http_content_type: Option<String>,
49    /// User-supplied HTTP headers to be sent with the request in addition to the HTTP content type. Headers should be defined in the format <code>Name: Value</code>. Jinja2 template processing is supported with the same context as the request body (below).
50    #[serde(rename = "additional_headers", skip_serializing_if = "Option::is_none")]
51    pub additional_headers: Option<String>,
52    /// Jinja2 template for a custom request body. If blank, a JSON object representing the change will be included. Available context data includes: <code>event</code>, <code>model</code>, <code>timestamp</code>, <code>username</code>, <code>request_id</code>, and <code>data</code>.
53    #[serde(rename = "body_template", skip_serializing_if = "Option::is_none")]
54    pub body_template: Option<String>,
55    /// When provided, the request will include a 'X-Hook-Signature' header containing a HMAC hex digest of the payload body using the secret as the key. The secret is not transmitted in the request.
56    #[serde(rename = "secret", skip_serializing_if = "Option::is_none")]
57    pub secret: Option<String>,
58    /// Enable SSL certificate verification. Disable with caution!
59    #[serde(rename = "ssl_verification", skip_serializing_if = "Option::is_none")]
60    pub ssl_verification: Option<bool>,
61    /// The specific CA certificate file to use for SSL verification. Leave blank to use the system defaults.
62    #[serde(rename = "ca_file_path", skip_serializing_if = "Option::is_none")]
63    pub ca_file_path: Option<String>,
64    #[serde(
65        rename = "created",
66        default,
67        with = "::serde_with::rust::double_option",
68        skip_serializing_if = "Option::is_none"
69    )]
70    pub created: Option<Option<String>>,
71    #[serde(
72        rename = "last_updated",
73        default,
74        with = "::serde_with::rust::double_option",
75        skip_serializing_if = "Option::is_none"
76    )]
77    pub last_updated: Option<Option<String>>,
78    #[serde(rename = "notes_url", skip_serializing_if = "Option::is_none")]
79    pub notes_url: Option<String>,
80}
81
82impl Webhook {
83    /// Extends the built-in ModelSerializer to enforce calling full_clean() on a copy of the associated instance during validation. (DRF does not do this by default; see <https://github.com/encode/django-rest-framework/issues/3144>)
84    pub fn new(content_types: Vec<String>, name: String, payload_url: String) -> Webhook {
85        Webhook {
86            id: None,
87            object_type: None,
88            display: None,
89            url: None,
90            natural_slug: None,
91            content_types,
92            name,
93            type_create: None,
94            type_update: None,
95            type_delete: None,
96            payload_url,
97            enabled: None,
98            http_method: None,
99            http_content_type: None,
100            additional_headers: None,
101            body_template: None,
102            secret: None,
103            ssl_verification: None,
104            ca_file_path: None,
105            created: None,
106            last_updated: None,
107            notes_url: None,
108        }
109    }
110}