Skip to main content

nautobot_openapi/models/
webhook_request.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/// WebhookRequest : 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 WebhookRequest {
15    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
16    pub id: Option<uuid::Uuid>,
17    #[serde(rename = "content_types")]
18    pub content_types: Vec<String>,
19    #[serde(rename = "name")]
20    pub name: String,
21    /// Call this webhook when a matching object is created.
22    #[serde(rename = "type_create", skip_serializing_if = "Option::is_none")]
23    pub type_create: Option<bool>,
24    /// Call this webhook when a matching object is updated.
25    #[serde(rename = "type_update", skip_serializing_if = "Option::is_none")]
26    pub type_update: Option<bool>,
27    /// Call this webhook when a matching object is deleted.
28    #[serde(rename = "type_delete", skip_serializing_if = "Option::is_none")]
29    pub type_delete: Option<bool>,
30    /// A POST will be sent to this URL when the webhook is called.
31    #[serde(rename = "payload_url")]
32    pub payload_url: String,
33    #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
34    pub enabled: Option<bool>,
35    #[serde(rename = "http_method", skip_serializing_if = "Option::is_none")]
36    pub http_method: Option<crate::models::HttpMethodEnum>,
37    /// The complete list of official content types is available here (<https://www.iana.org/assignments/media-types/media-types.xhtml>).
38    #[serde(rename = "http_content_type", skip_serializing_if = "Option::is_none")]
39    pub http_content_type: Option<String>,
40    /// 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).
41    #[serde(rename = "additional_headers", skip_serializing_if = "Option::is_none")]
42    pub additional_headers: Option<String>,
43    /// 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>.
44    #[serde(rename = "body_template", skip_serializing_if = "Option::is_none")]
45    pub body_template: Option<String>,
46    /// 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.
47    #[serde(rename = "secret", skip_serializing_if = "Option::is_none")]
48    pub secret: Option<String>,
49    /// Enable SSL certificate verification. Disable with caution!
50    #[serde(rename = "ssl_verification", skip_serializing_if = "Option::is_none")]
51    pub ssl_verification: Option<bool>,
52    /// The specific CA certificate file to use for SSL verification. Leave blank to use the system defaults.
53    #[serde(rename = "ca_file_path", skip_serializing_if = "Option::is_none")]
54    pub ca_file_path: Option<String>,
55}
56
57impl WebhookRequest {
58    /// 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>)
59    pub fn new(content_types: Vec<String>, name: String, payload_url: String) -> WebhookRequest {
60        WebhookRequest {
61            id: None,
62            content_types,
63            name,
64            type_create: None,
65            type_update: None,
66            type_delete: None,
67            payload_url,
68            enabled: None,
69            http_method: None,
70            http_content_type: None,
71            additional_headers: None,
72            body_template: None,
73            secret: None,
74            ssl_verification: None,
75            ca_file_path: None,
76        }
77    }
78}