netbox_openapi/models/
webhook.rs

1/*
2 * NetBox REST API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 4.4.2-Docker-3.4.1 (4.4)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// Webhook : Adds support for custom fields and tags.
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<i32>,
17    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
18    pub url: Option<String>,
19    #[serde(rename = "display_url", skip_serializing_if = "Option::is_none")]
20    pub display_url: Option<String>,
21    #[serde(rename = "display", skip_serializing_if = "Option::is_none")]
22    pub display: Option<String>,
23    #[serde(rename = "name")]
24    pub name: String,
25    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
26    pub description: Option<String>,
27    /// This URL will be called using the HTTP method defined when the webhook is called. Jinja2 template processing is supported with the same context as the request body.
28    #[serde(rename = "payload_url")]
29    pub payload_url: String,
30    /// * `GET` - GET * `POST` - POST * `PUT` - PUT * `PATCH` - PATCH * `DELETE` - DELETE
31    #[serde(rename = "http_method", skip_serializing_if = "Option::is_none")]
32    pub http_method: Option<HttpMethod>,
33    /// The complete list of official content types is available here (<https://www.iana.org/assignments/media-types/media-types.xhtml>).
34    #[serde(rename = "http_content_type", skip_serializing_if = "Option::is_none")]
35    pub http_content_type: Option<String>,
36    /// 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).
37    #[serde(rename = "additional_headers", skip_serializing_if = "Option::is_none")]
38    pub additional_headers: Option<String>,
39    /// 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>.
40    #[serde(rename = "body_template", skip_serializing_if = "Option::is_none")]
41    pub body_template: Option<String>,
42    /// When provided, the request will include a <code>X-Hook-Signature</code> header containing a HMAC hex digest of the payload body using the secret as the key. The secret is not transmitted in the request.
43    #[serde(rename = "secret", skip_serializing_if = "Option::is_none")]
44    pub secret: Option<String>,
45    /// Enable SSL certificate verification. Disable with caution!
46    #[serde(rename = "ssl_verification", skip_serializing_if = "Option::is_none")]
47    pub ssl_verification: Option<bool>,
48    /// The specific CA certificate file to use for SSL verification. Leave blank to use the system defaults.
49    #[serde(
50        rename = "ca_file_path",
51        default,
52        with = "::serde_with::rust::double_option",
53        skip_serializing_if = "Option::is_none"
54    )]
55    pub ca_file_path: Option<Option<String>>,
56    #[serde(rename = "custom_fields", skip_serializing_if = "Option::is_none")]
57    pub custom_fields: Option<::std::collections::HashMap<String, serde_json::Value>>,
58    #[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
59    pub tags: Option<Vec<crate::models::NestedTag>>,
60    #[serde(
61        rename = "created",
62        default,
63        with = "::serde_with::rust::double_option",
64        skip_serializing_if = "Option::is_none"
65    )]
66    pub created: Option<Option<String>>,
67    #[serde(
68        rename = "last_updated",
69        default,
70        with = "::serde_with::rust::double_option",
71        skip_serializing_if = "Option::is_none"
72    )]
73    pub last_updated: Option<Option<String>>,
74}
75
76impl Webhook {
77    /// Adds support for custom fields and tags.
78    pub fn new(name: String, payload_url: String) -> Webhook {
79        Webhook {
80            id: None,
81            url: None,
82            display_url: None,
83            display: None,
84            name,
85            description: None,
86            payload_url,
87            http_method: None,
88            http_content_type: None,
89            additional_headers: None,
90            body_template: None,
91            secret: None,
92            ssl_verification: None,
93            ca_file_path: None,
94            custom_fields: None,
95            tags: None,
96            created: None,
97            last_updated: None,
98        }
99    }
100}
101
102/// * `GET` - GET * `POST` - POST * `PUT` - PUT * `PATCH` - PATCH * `DELETE` - DELETE
103#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
104pub enum HttpMethod {
105    #[serde(rename = "GET")]
106    Get,
107    #[serde(rename = "POST")]
108    Post,
109    #[serde(rename = "PUT")]
110    Put,
111    #[serde(rename = "PATCH")]
112    Patch,
113    #[serde(rename = "DELETE")]
114    Delete,
115}
116
117impl Default for HttpMethod {
118    fn default() -> HttpMethod {
119        Self::Get
120    }
121}