Skip to main content

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.6.2 (4.6)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// Webhook : Adds an `owner` field for models which have a ForeignKey to users.Owner.
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(
59        rename = "owner",
60        default,
61        with = "::serde_with::rust::double_option",
62        skip_serializing_if = "Option::is_none"
63    )]
64    pub owner: Option<Option<Box<crate::models::BriefOwner>>>,
65    #[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
66    pub tags: Option<Vec<crate::models::NestedTag>>,
67    #[serde(
68        rename = "created",
69        default,
70        with = "::serde_with::rust::double_option",
71        skip_serializing_if = "Option::is_none"
72    )]
73    pub created: Option<Option<String>>,
74    #[serde(
75        rename = "last_updated",
76        default,
77        with = "::serde_with::rust::double_option",
78        skip_serializing_if = "Option::is_none"
79    )]
80    pub last_updated: Option<Option<String>>,
81}
82
83impl Webhook {
84    /// Adds an `owner` field for models which have a ForeignKey to users.Owner.
85    pub fn new(name: String, payload_url: String) -> Webhook {
86        Webhook {
87            id: None,
88            url: None,
89            display_url: None,
90            display: None,
91            name,
92            description: None,
93            payload_url,
94            http_method: None,
95            http_content_type: None,
96            additional_headers: None,
97            body_template: None,
98            secret: None,
99            ssl_verification: None,
100            ca_file_path: None,
101            custom_fields: None,
102            owner: None,
103            tags: None,
104            created: None,
105            last_updated: None,
106        }
107    }
108}
109
110/// * `GET` - GET * `POST` - POST * `PUT` - PUT * `PATCH` - PATCH * `DELETE` - DELETE
111#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
112pub enum HttpMethod {
113    #[serde(rename = "GET")]
114    Get,
115    #[serde(rename = "POST")]
116    Post,
117    #[serde(rename = "PUT")]
118    Put,
119    #[serde(rename = "PATCH")]
120    Patch,
121    #[serde(rename = "DELETE")]
122    Delete,
123}
124
125impl Default for HttpMethod {
126    fn default() -> HttpMethod {
127        Self::Get
128    }
129}