netbox_openapi/models/
writable_service_template_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.4.2-Docker-3.4.1 (4.4)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// WritableServiceTemplateRequest : Adds support for custom fields and tags.
12
13#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
14pub struct WritableServiceTemplateRequest {
15    #[serde(rename = "name")]
16    pub name: String,
17    /// * `tcp` - TCP * `udp` - UDP * `sctp` - SCTP
18    #[serde(rename = "protocol")]
19    pub protocol: Protocol,
20    #[serde(rename = "ports")]
21    pub ports: Vec<i32>,
22    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
23    pub description: Option<String>,
24    #[serde(rename = "comments", skip_serializing_if = "Option::is_none")]
25    pub comments: Option<String>,
26    #[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
27    pub tags: Option<Vec<crate::models::NestedTagRequest>>,
28    #[serde(rename = "custom_fields", skip_serializing_if = "Option::is_none")]
29    pub custom_fields: Option<::std::collections::HashMap<String, serde_json::Value>>,
30}
31
32impl WritableServiceTemplateRequest {
33    /// Adds support for custom fields and tags.
34    pub fn new(
35        name: String,
36        protocol: Protocol,
37        ports: Vec<i32>,
38    ) -> WritableServiceTemplateRequest {
39        WritableServiceTemplateRequest {
40            name,
41            protocol,
42            ports,
43            description: None,
44            comments: None,
45            tags: None,
46            custom_fields: None,
47        }
48    }
49}
50
51/// * `tcp` - TCP * `udp` - UDP * `sctp` - SCTP
52#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
53pub enum Protocol {
54    #[serde(rename = "tcp")]
55    Tcp,
56    #[serde(rename = "udp")]
57    Udp,
58    #[serde(rename = "sctp")]
59    Sctp,
60}
61
62impl Default for Protocol {
63    fn default() -> Protocol {
64        Self::Tcp
65    }
66}