oci_rust_sdk/core/models/subnet.rs
1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4
5#[allow(unused_imports)]
6use super::*;
7/// A logical subdivision of a VCN. Each subnet consists of a contiguous range of IP addresses that do not overlap with other subnets in the VCN. Example: 172.16.1.0/24. For more information, see [Overview of the Networking Service](https://docs.oracle.com/iaas/Content/Network/Concepts/overview.htm) and [VCNs and Subnets](https://docs.oracle.com/iaas/Content/Network/Tasks/managingVCNs.htm). <p> To use any of the API operations, you must be authorized in an IAM policy. If you're not authorized, talk to an administrator. If you're an administrator who needs to write policies to give users access, see [Getting Started with Policies](https://docs.oracle.com/iaas/Content/Identity/Concepts/policygetstarted.htm).
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct Subnet {
11 /// The subnet's CIDR block. <p> Example: {@code 10.0.1.0/24}
12 pub cidr_block: String,
13
14 /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the subnet.
15 pub compartment_id: String,
16
17 /// The subnet's Oracle ID ([OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm)).
18 pub id: String,
19
20 /// The subnet's current state.
21 pub lifecycle_state: SubnetLifecycleState,
22
23 /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the route table that the subnet uses.
24 pub route_table_id: String,
25
26 /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the VCN the subnet is in.
27 pub vcn_id: String,
28
29 /// The IP address of the virtual router. <p> Example: {@code 10.0.14.1}
30 pub virtual_router_ip: String,
31
32 /// The MAC address of the virtual router. <p> Example: {@code 00:00:00:00:00:01}
33 pub virtual_router_mac: String,
34
35 /// The subnet's availability domain. This attribute will be null if this is a regional subnet instead of an AD-specific subnet. Oracle recommends creating regional subnets. <p> Example: {@code Uocm:PHX-AD-1}
36 #[serde(skip_serializing_if = "Option::is_none")]
37 pub availability_domain: Option<String>,
38
39 /// The list of all IPv4 CIDR blocks for the subnet that meets the following criteria: - Ipv4 CIDR blocks must be valid. - Multiple Ipv4 CIDR blocks must not overlap each other or the on-premises network CIDR block. - The number of prefixes must not exceed the limit of IPv4 prefixes allowed to a subnet.
40 #[serde(skip_serializing_if = "Option::is_none")]
41 pub ipv4_cidr_blocks: Option<Vec<String>>,
42
43 /// Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). <p> Example: {@code {\"Operations\": {\"CostCenter\": \"42\"}}}
44 #[serde(skip_serializing_if = "Option::is_none")]
45 pub defined_tags: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
46
47 /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the set of DHCP options that the subnet uses.
48 #[serde(skip_serializing_if = "Option::is_none")]
49 pub dhcp_options_id: Option<String>,
50
51 /// A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
52 #[serde(skip_serializing_if = "Option::is_none")]
53 pub display_name: Option<String>,
54
55 /// A DNS label for the subnet, used in conjunction with the VNIC's hostname and VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC within this subnet (for example, {@code bminstance1.subnet123.vcn1.oraclevcn.com}). Must be an alphanumeric string that begins with a letter and is unique within the VCN. The value cannot be changed. <p> The absence of this parameter means the Internet and VCN Resolver will not resolve hostnames of instances in this subnet. <p> For more information, see [DNS in Your Virtual Cloud Network](https://docs.oracle.com/iaas/Content/Network/Concepts/dns.htm). <p> Example: {@code subnet123}
56 #[serde(skip_serializing_if = "Option::is_none")]
57 pub dns_label: Option<String>,
58
59 /// Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). <p> Example: {@code {\"Department\": \"Finance\"}}
60 #[serde(skip_serializing_if = "Option::is_none")]
61 pub freeform_tags: Option<HashMap<String, String>>,
62
63 /// For an IPv6-enabled subnet, this is the IPv6 prefix for the subnet's IP address space. The subnet size is always /64. See [IPv6 Addresses](https://docs.oracle.com/iaas/Content/Network/Concepts/ipv6.htm). <p> Example: {@code 2001:0db8:0123:1111::/64}
64 #[serde(skip_serializing_if = "Option::is_none")]
65 pub ipv6_cidr_block: Option<String>,
66
67 /// The list of all IPv6 prefixes (Oracle allocated IPv6 GUA, ULA or private IPv6 prefixes, BYOIPv6 prefixes) for the subnet.
68 #[serde(skip_serializing_if = "Option::is_none")]
69 pub ipv6_cidr_blocks: Option<Vec<String>>,
70
71 /// For an IPv6-enabled subnet, this is the IPv6 address of the virtual router. <p> Example: {@code 2001:0db8:0123:1111:89ab:cdef:1234:5678}
72 #[serde(skip_serializing_if = "Option::is_none")]
73 pub ipv6_virtual_router_ip: Option<String>,
74
75 /// Whether to disallow ingress internet traffic to VNICs within this subnet. Defaults to false. <p> For IPV4, {@code prohibitInternetIngress} behaves similarly to {@code prohibitPublicIpOnVnic}. If it is set to false, VNICs created in this subnet will automatically be assigned public IP addresses unless specified otherwise during instance launch or VNIC creation (with the {@code assignPublicIp} flag in {@link CreateVnicDetails}). If {@code prohibitInternetIngress} is set to true, VNICs created in this subnet cannot have public IP addresses (that is, it's a privatesubnet). <p> For IPv6, if {@code prohibitInternetIngress} is set to {@code true}, internet access is not allowed for any IPv6s assigned to VNICs in the subnet. Otherwise, ingress internet traffic is allowed by default. <p> Example: {@code true}
76 #[serde(skip_serializing_if = "Option::is_none")]
77 pub prohibit_internet_ingress: Option<bool>,
78
79 /// Whether VNICs within this subnet can have public IP addresses. Defaults to false, which means VNICs created in this subnet will automatically be assigned public IP addresses unless specified otherwise during instance launch or VNIC creation (with the {@code assignPublicIp} flag in {@link CreateVnicDetails}). If {@code prohibitPublicIpOnVnic} is set to true, VNICs created in this subnet cannot have public IP addresses (that is, it's a private subnet). <p> Example: {@code true}
80 #[serde(skip_serializing_if = "Option::is_none")]
81 pub prohibit_public_ip_on_vnic: Option<bool>,
82
83 /// The OCIDs of the security list or lists that the subnet uses. Remember that security lists are associated *with the subnet*, but the rules are applied to the individual VNICs in the subnet.
84 #[serde(skip_serializing_if = "Option::is_none")]
85 pub security_list_ids: Option<Vec<String>>,
86
87 /// The subnet's domain name, which consists of the subnet's DNS label, the VCN's DNS label, and the {@code oraclevcn.com} domain. <p> For more information, see [DNS in Your Virtual Cloud Network](https://docs.oracle.com/iaas/Content/Network/Concepts/dns.htm). <p> Example: {@code subnet123.vcn1.oraclevcn.com}
88 #[serde(skip_serializing_if = "Option::is_none")]
89 pub subnet_domain_name: Option<String>,
90
91 /// The date and time the subnet was created, in the format defined by [RFC3339](https://tools.ietf.org/html/rfc3339). <p> Example: {@code 2016-08-25T21:10:29.600Z}
92 #[serde(skip_serializing_if = "Option::is_none")]
93 pub time_created: Option<DateTime<Utc>>,
94}
95
96/// Required fields for Subnet
97pub struct SubnetRequired {
98 /// The subnet's CIDR block. <p> Example: {@code 10.0.1.0/24}
99 pub cidr_block: String,
100
101 /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the subnet.
102 pub compartment_id: String,
103
104 /// The subnet's Oracle ID ([OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm)).
105 pub id: String,
106
107 /// The subnet's current state.
108 pub lifecycle_state: SubnetLifecycleState,
109
110 /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the route table that the subnet uses.
111 pub route_table_id: String,
112
113 /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the VCN the subnet is in.
114 pub vcn_id: String,
115
116 /// The IP address of the virtual router. <p> Example: {@code 10.0.14.1}
117 pub virtual_router_ip: String,
118
119 /// The MAC address of the virtual router. <p> Example: {@code 00:00:00:00:00:01}
120 pub virtual_router_mac: String,
121}
122
123impl Subnet {
124 /// Create a new Subnet with required fields
125 pub fn new(required: SubnetRequired) -> Self {
126 Self {
127 cidr_block: required.cidr_block,
128
129 compartment_id: required.compartment_id,
130
131 id: required.id,
132
133 lifecycle_state: required.lifecycle_state,
134
135 route_table_id: required.route_table_id,
136
137 vcn_id: required.vcn_id,
138
139 virtual_router_ip: required.virtual_router_ip,
140
141 virtual_router_mac: required.virtual_router_mac,
142
143 availability_domain: None,
144
145 ipv4_cidr_blocks: None,
146
147 defined_tags: None,
148
149 dhcp_options_id: None,
150
151 display_name: None,
152
153 dns_label: None,
154
155 freeform_tags: None,
156
157 ipv6_cidr_block: None,
158
159 ipv6_cidr_blocks: None,
160
161 ipv6_virtual_router_ip: None,
162
163 prohibit_internet_ingress: None,
164
165 prohibit_public_ip_on_vnic: None,
166
167 security_list_ids: None,
168
169 subnet_domain_name: None,
170
171 time_created: None,
172 }
173 }
174
175 /// Set availability_domain
176 pub fn set_availability_domain(mut self, value: Option<String>) -> Self {
177 self.availability_domain = value;
178 self
179 }
180
181 /// Set cidr_block
182 pub fn set_cidr_block(mut self, value: String) -> Self {
183 self.cidr_block = value;
184 self
185 }
186
187 /// Set ipv4_cidr_blocks
188 pub fn set_ipv4_cidr_blocks(mut self, value: Option<Vec<String>>) -> Self {
189 self.ipv4_cidr_blocks = value;
190 self
191 }
192
193 /// Set compartment_id
194 pub fn set_compartment_id(mut self, value: String) -> Self {
195 self.compartment_id = value;
196 self
197 }
198
199 /// Set defined_tags
200 pub fn set_defined_tags(
201 mut self,
202 value: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
203 ) -> Self {
204 self.defined_tags = value;
205 self
206 }
207
208 /// Set dhcp_options_id
209 pub fn set_dhcp_options_id(mut self, value: Option<String>) -> Self {
210 self.dhcp_options_id = value;
211 self
212 }
213
214 /// Set display_name
215 pub fn set_display_name(mut self, value: Option<String>) -> Self {
216 self.display_name = value;
217 self
218 }
219
220 /// Set dns_label
221 pub fn set_dns_label(mut self, value: Option<String>) -> Self {
222 self.dns_label = value;
223 self
224 }
225
226 /// Set freeform_tags
227 pub fn set_freeform_tags(mut self, value: Option<HashMap<String, String>>) -> Self {
228 self.freeform_tags = value;
229 self
230 }
231
232 /// Set id
233 pub fn set_id(mut self, value: String) -> Self {
234 self.id = value;
235 self
236 }
237
238 /// Set ipv6_cidr_block
239 pub fn set_ipv6_cidr_block(mut self, value: Option<String>) -> Self {
240 self.ipv6_cidr_block = value;
241 self
242 }
243
244 /// Set ipv6_cidr_blocks
245 pub fn set_ipv6_cidr_blocks(mut self, value: Option<Vec<String>>) -> Self {
246 self.ipv6_cidr_blocks = value;
247 self
248 }
249
250 /// Set ipv6_virtual_router_ip
251 pub fn set_ipv6_virtual_router_ip(mut self, value: Option<String>) -> Self {
252 self.ipv6_virtual_router_ip = value;
253 self
254 }
255
256 /// Set lifecycle_state
257 pub fn set_lifecycle_state(mut self, value: SubnetLifecycleState) -> Self {
258 self.lifecycle_state = value;
259 self
260 }
261
262 /// Set prohibit_internet_ingress
263 pub fn set_prohibit_internet_ingress(mut self, value: Option<bool>) -> Self {
264 self.prohibit_internet_ingress = value;
265 self
266 }
267
268 /// Set prohibit_public_ip_on_vnic
269 pub fn set_prohibit_public_ip_on_vnic(mut self, value: Option<bool>) -> Self {
270 self.prohibit_public_ip_on_vnic = value;
271 self
272 }
273
274 /// Set route_table_id
275 pub fn set_route_table_id(mut self, value: String) -> Self {
276 self.route_table_id = value;
277 self
278 }
279
280 /// Set security_list_ids
281 pub fn set_security_list_ids(mut self, value: Option<Vec<String>>) -> Self {
282 self.security_list_ids = value;
283 self
284 }
285
286 /// Set subnet_domain_name
287 pub fn set_subnet_domain_name(mut self, value: Option<String>) -> Self {
288 self.subnet_domain_name = value;
289 self
290 }
291
292 /// Set time_created
293 pub fn set_time_created(mut self, value: Option<DateTime<Utc>>) -> Self {
294 self.time_created = value;
295 self
296 }
297
298 /// Set vcn_id
299 pub fn set_vcn_id(mut self, value: String) -> Self {
300 self.vcn_id = value;
301 self
302 }
303
304 /// Set virtual_router_ip
305 pub fn set_virtual_router_ip(mut self, value: String) -> Self {
306 self.virtual_router_ip = value;
307 self
308 }
309
310 /// Set virtual_router_mac
311 pub fn set_virtual_router_mac(mut self, value: String) -> Self {
312 self.virtual_router_mac = value;
313 self
314 }
315
316 /// Set availability_domain (unwraps Option)
317 pub fn with_availability_domain(mut self, value: impl Into<String>) -> Self {
318 self.availability_domain = Some(value.into());
319 self
320 }
321
322 /// Set ipv4_cidr_blocks (unwraps Option)
323 pub fn with_ipv4_cidr_blocks(mut self, value: Vec<String>) -> Self {
324 self.ipv4_cidr_blocks = Some(value);
325 self
326 }
327
328 /// Set defined_tags (unwraps Option)
329 pub fn with_defined_tags(
330 mut self,
331 value: HashMap<String, HashMap<String, serde_json::Value>>,
332 ) -> Self {
333 self.defined_tags = Some(value);
334 self
335 }
336
337 /// Set dhcp_options_id (unwraps Option)
338 pub fn with_dhcp_options_id(mut self, value: impl Into<String>) -> Self {
339 self.dhcp_options_id = Some(value.into());
340 self
341 }
342
343 /// Set display_name (unwraps Option)
344 pub fn with_display_name(mut self, value: impl Into<String>) -> Self {
345 self.display_name = Some(value.into());
346 self
347 }
348
349 /// Set dns_label (unwraps Option)
350 pub fn with_dns_label(mut self, value: impl Into<String>) -> Self {
351 self.dns_label = Some(value.into());
352 self
353 }
354
355 /// Set freeform_tags (unwraps Option)
356 pub fn with_freeform_tags(mut self, value: HashMap<String, String>) -> Self {
357 self.freeform_tags = Some(value);
358 self
359 }
360
361 /// Set ipv6_cidr_block (unwraps Option)
362 pub fn with_ipv6_cidr_block(mut self, value: impl Into<String>) -> Self {
363 self.ipv6_cidr_block = Some(value.into());
364 self
365 }
366
367 /// Set ipv6_cidr_blocks (unwraps Option)
368 pub fn with_ipv6_cidr_blocks(mut self, value: Vec<String>) -> Self {
369 self.ipv6_cidr_blocks = Some(value);
370 self
371 }
372
373 /// Set ipv6_virtual_router_ip (unwraps Option)
374 pub fn with_ipv6_virtual_router_ip(mut self, value: impl Into<String>) -> Self {
375 self.ipv6_virtual_router_ip = Some(value.into());
376 self
377 }
378
379 /// Set prohibit_internet_ingress (unwraps Option)
380 pub fn with_prohibit_internet_ingress(mut self, value: bool) -> Self {
381 self.prohibit_internet_ingress = Some(value);
382 self
383 }
384
385 /// Set prohibit_public_ip_on_vnic (unwraps Option)
386 pub fn with_prohibit_public_ip_on_vnic(mut self, value: bool) -> Self {
387 self.prohibit_public_ip_on_vnic = Some(value);
388 self
389 }
390
391 /// Set security_list_ids (unwraps Option)
392 pub fn with_security_list_ids(mut self, value: Vec<String>) -> Self {
393 self.security_list_ids = Some(value);
394 self
395 }
396
397 /// Set subnet_domain_name (unwraps Option)
398 pub fn with_subnet_domain_name(mut self, value: impl Into<String>) -> Self {
399 self.subnet_domain_name = Some(value.into());
400 self
401 }
402
403 /// Set time_created (unwraps Option)
404 pub fn with_time_created(mut self, value: DateTime<Utc>) -> Self {
405 self.time_created = Some(value);
406 self
407 }
408}