Skip to main content

netbox_openapi/models/
webhook_request.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/// WebhookRequest : Adds an `owner` field for models which have a ForeignKey to users.Owner.
12
13#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
14pub struct WebhookRequest {
15    #[serde(rename = "name")]
16    pub name: String,
17    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
18    pub description: Option<String>,
19    /// 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.
20    #[serde(rename = "payload_url")]
21    pub payload_url: String,
22    /// * `GET` - GET * `POST` - POST * `PUT` - PUT * `PATCH` - PATCH * `DELETE` - DELETE
23    #[serde(rename = "http_method", skip_serializing_if = "Option::is_none")]
24    pub http_method: Option<HttpMethod>,
25    /// The complete list of official content types is available here (<https://www.iana.org/assignments/media-types/media-types.xhtml>).
26    #[serde(rename = "http_content_type", skip_serializing_if = "Option::is_none")]
27    pub http_content_type: Option<String>,
28    /// 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).
29    #[serde(rename = "additional_headers", skip_serializing_if = "Option::is_none")]
30    pub additional_headers: Option<String>,
31    /// 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>.
32    #[serde(rename = "body_template", skip_serializing_if = "Option::is_none")]
33    pub body_template: Option<String>,
34    /// 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.
35    #[serde(rename = "secret", skip_serializing_if = "Option::is_none")]
36    pub secret: Option<String>,
37    /// Enable SSL certificate verification. Disable with caution!
38    #[serde(rename = "ssl_verification", skip_serializing_if = "Option::is_none")]
39    pub ssl_verification: Option<bool>,
40    /// The specific CA certificate file to use for SSL verification. Leave blank to use the system defaults.
41    #[serde(
42        rename = "ca_file_path",
43        default,
44        with = "::serde_with::rust::double_option",
45        skip_serializing_if = "Option::is_none"
46    )]
47    pub ca_file_path: Option<Option<String>>,
48    #[serde(rename = "custom_fields", skip_serializing_if = "Option::is_none")]
49    pub custom_fields: Option<::std::collections::HashMap<String, serde_json::Value>>,
50    #[serde(
51        rename = "owner",
52        default,
53        with = "::serde_with::rust::double_option",
54        skip_serializing_if = "Option::is_none"
55    )]
56    pub owner: Option<Option<Box<crate::models::AsnRangeRequestOwner>>>,
57    #[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
58    pub tags: Option<Vec<crate::models::NestedTagRequest>>,
59}
60
61impl WebhookRequest {
62    /// Adds an `owner` field for models which have a ForeignKey to users.Owner.
63    pub fn new(name: String, payload_url: String) -> WebhookRequest {
64        WebhookRequest {
65            name,
66            description: None,
67            payload_url,
68            http_method: None,
69            http_content_type: None,
70            additional_headers: None,
71            body_template: None,
72            secret: None,
73            ssl_verification: None,
74            ca_file_path: None,
75            custom_fields: None,
76            owner: None,
77            tags: None,
78        }
79    }
80}
81
82/// * `GET` - GET * `POST` - POST * `PUT` - PUT * `PATCH` - PATCH * `DELETE` - DELETE
83#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
84pub enum HttpMethod {
85    #[serde(rename = "GET")]
86    Get,
87    #[serde(rename = "POST")]
88    Post,
89    #[serde(rename = "PUT")]
90    Put,
91    #[serde(rename = "PATCH")]
92    Patch,
93    #[serde(rename = "DELETE")]
94    Delete,
95}
96
97impl Default for HttpMethod {
98    fn default() -> HttpMethod {
99        Self::Get
100    }
101}