hcloud/models/
subnet.rs

1/*
2 * Hetzner Cloud API
3 *
4 * Copied from the official API documentation for the Public Hetzner Cloud.
5 *
6 * The version of the OpenAPI document: 0.26.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// Subnet : Subnets divide the ip_range from the parent Network object into multiple Subnetworks that you can use for different specific purposes.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Subnet {
17    /// IP range of the subnet.  Uses CIDR notation.  Must be a subnet of the parent [Networks](#networks) `ip_range`.  Must not overlap with any other subnets or with any destinations in routes.  Minimum network size is /30. We highly recommend that you pick a larger subnet with a /24 netmask.
18    #[serde(rename = "ip_range", skip_serializing_if = "Option::is_none")]
19    pub ip_range: Option<String>,
20    /// Name of the [Network Zone](#network-zones).  The [Location](#locations) contains the `network_zone` property it belongs to.  | Name of the [Network Zone](#network-zones).  The [Location](#locations) contains the `network_zone` it belongs to.
21    #[serde(rename = "network_zone")]
22    pub network_zone: String,
23    /// Type of subnet.  - `cloud` - Used to connect cloud [Servers](#servers) and [Load Balancers](#load-balancers). - `server` - Same as the `cloud` type. **Deprecated**, use the `cloud` type instead. - `vswitch` - Used to [connect cloud Servers and Load Balancers with dedicated Servers](https://docs.hetzner.com/cloud/networks/connect-dedi-vswitch).
24    #[serde(rename = "type")]
25    pub r#type: Type,
26    /// ID of the robot vSwitch.  Must only be supplied for subnets of type `vswitch`.  | ID of the robot vSwitch.  Must be supplied if the subnet is of type `vswitch`.
27    #[serde(rename = "vswitch_id", skip_serializing_if = "Option::is_none")]
28    pub vswitch_id: Option<i64>,
29}
30
31impl Subnet {
32    /// Subnets divide the ip_range from the parent Network object into multiple Subnetworks that you can use for different specific purposes.
33    pub fn new(network_zone: String, r#type: Type) -> Subnet {
34        Subnet {
35            ip_range: None,
36            network_zone,
37            r#type,
38            vswitch_id: None,
39        }
40    }
41}
42/// Type of subnet.  - `cloud` - Used to connect cloud [Servers](#servers) and [Load Balancers](#load-balancers). - `server` - Same as the `cloud` type. **Deprecated**, use the `cloud` type instead. - `vswitch` - Used to [connect cloud Servers and Load Balancers with dedicated Servers](https://docs.hetzner.com/cloud/networks/connect-dedi-vswitch).
43#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
44pub enum Type {
45    #[serde(rename = "cloud")]
46    Cloud,
47    #[serde(rename = "server")]
48    Server,
49    #[serde(rename = "vswitch")]
50    Vswitch,
51}
52
53impl Default for Type {
54    fn default() -> Type {
55        Self::Cloud
56    }
57}