Skip to main content

oci_rust_sdk/core/models/
volume.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4
5#[allow(unused_imports)]
6use super::*;
7/// A detachable block volume device that allows you to dynamically expand the storage capacity of an instance. For more information, see [Overview of Cloud Volume Storage](https://docs.oracle.com/iaas/Content/Block/Concepts/overview.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). <p> *Warning:** Oracle recommends that you avoid using any confidential information when you supply string values using the API.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct Volume {
11    /// The availability domain of the volume. <p> Example: {@code Uocm:PHX-AD-1}
12    pub availability_domain: String,
13
14    /// The OCID of the compartment that contains the volume.
15    pub compartment_id: String,
16
17    /// A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
18    pub display_name: String,
19
20    /// The OCID of the volume.
21    pub id: String,
22
23    /// The current state of a volume.
24    pub lifecycle_state: VolumeLifecycleState,
25
26    /// The size of the volume in MBs. This field is deprecated. Use sizeInGBs instead. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
27    pub size_in_mbs: i64,
28
29    /// The date and time the volume was created. Format defined by [RFC3339](https://tools.ietf.org/html/rfc3339).
30    pub time_created: DateTime<Utc>,
31
32    /// 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\"}}}
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub defined_tags: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
35
36    /// 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\"}}
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub freeform_tags: Option<HashMap<String, String>>,
39
40    /// System tags for this resource. Each key is predefined and scoped to a namespace. Example: {@code {\"foo-namespace\": {\"bar-key\": \"value\"}}}
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub system_tags: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
43
44    /// Specifies whether the cloned volume's data has finished copying from the source volume or backup.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub is_hydrated: Option<bool>,
47
48    /// The OCID of the Vault service key which is the master encryption key for the volume.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub kms_key_id: Option<String>,
51
52    /// The number of volume performance units (VPUs) that will be applied to this volume per GB, representing the Block Volume service's elastic performance options. See [Block Volume Performance Levels](https://docs.oracle.com/iaas/Content/Block/Concepts/blockvolumeperformance.htm#perf_levels) for more information. <p> Allowed values: <p> {@code 0}: Represents Lower Cost option. <p> {@code 10}: Represents Balanced option. <p> {@code 20}: Represents Higher Performance option. <p> {@code 30}-{@code 120}: Represents the Ultra High Performance option. <p> For performance autotune enabled volumes, It would be the Default(Minimum) VPUs/GB. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub vpus_per_gb: Option<i64>,
55
56    /// The clusterPlacementGroup Id of the volume for volume placement.
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub cluster_placement_group_id: Option<String>,
59
60    /// The size of the volume in GBs. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub size_in_gbs: Option<i64>,
63
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub source_details: Option<VolumeSourceFromBlockVolumeReplicaDetails>,
66
67    /// The OCID of the source volume group.
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub volume_group_id: Option<String>,
70
71    /// Specifies whether the auto-tune performance is enabled for this volume. This field is deprecated. Use the {@code DetachedVolumeAutotunePolicy} instead to enable the volume for detached autotune.
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub is_auto_tune_enabled: Option<bool>,
74
75    /// The number of Volume Performance Units per GB that this volume is effectively tuned to. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
76    #[serde(skip_serializing_if = "Option::is_none")]
77    pub auto_tuned_vpus_per_gb: Option<i64>,
78
79    /// The list of block volume replicas of this volume.
80    #[serde(skip_serializing_if = "Option::is_none")]
81    pub block_volume_replicas: Option<Vec<BlockVolumeReplicaInfo>>,
82
83    /// The list of autotune policies enabled for this volume.
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub autotune_policies: Option<Vec<AutotunePolicy>>,
86
87    /// When set to true, enables SCSI Persistent Reservation (SCSI PR) for the volume. For more information, see [Persistent Reservations](https://docs.oracle.com/iaas/Content/Block/Concepts/persistent-reservations.htm).
88    #[serde(skip_serializing_if = "Option::is_none")]
89    pub is_reservations_enabled: Option<bool>,
90}
91
92/// Required fields for Volume
93pub struct VolumeRequired {
94    /// The availability domain of the volume. <p> Example: {@code Uocm:PHX-AD-1}
95    pub availability_domain: String,
96
97    /// The OCID of the compartment that contains the volume.
98    pub compartment_id: String,
99
100    /// A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
101    pub display_name: String,
102
103    /// The OCID of the volume.
104    pub id: String,
105
106    /// The current state of a volume.
107    pub lifecycle_state: VolumeLifecycleState,
108
109    /// The size of the volume in MBs. This field is deprecated. Use sizeInGBs instead. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
110    pub size_in_mbs: i64,
111
112    /// The date and time the volume was created. Format defined by [RFC3339](https://tools.ietf.org/html/rfc3339).
113    pub time_created: DateTime<Utc>,
114}
115
116impl Volume {
117    /// Create a new Volume with required fields
118    pub fn new(required: VolumeRequired) -> Self {
119        Self {
120            availability_domain: required.availability_domain,
121
122            compartment_id: required.compartment_id,
123
124            display_name: required.display_name,
125
126            id: required.id,
127
128            lifecycle_state: required.lifecycle_state,
129
130            size_in_mbs: required.size_in_mbs,
131
132            time_created: required.time_created,
133
134            defined_tags: None,
135
136            freeform_tags: None,
137
138            system_tags: None,
139
140            is_hydrated: None,
141
142            kms_key_id: None,
143
144            vpus_per_gb: None,
145
146            cluster_placement_group_id: None,
147
148            size_in_gbs: None,
149
150            source_details: None,
151
152            volume_group_id: None,
153
154            is_auto_tune_enabled: None,
155
156            auto_tuned_vpus_per_gb: None,
157
158            block_volume_replicas: None,
159
160            autotune_policies: None,
161
162            is_reservations_enabled: None,
163        }
164    }
165
166    /// Set availability_domain
167    pub fn set_availability_domain(mut self, value: String) -> Self {
168        self.availability_domain = value;
169        self
170    }
171
172    /// Set compartment_id
173    pub fn set_compartment_id(mut self, value: String) -> Self {
174        self.compartment_id = value;
175        self
176    }
177
178    /// Set defined_tags
179    pub fn set_defined_tags(
180        mut self,
181        value: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
182    ) -> Self {
183        self.defined_tags = value;
184        self
185    }
186
187    /// Set display_name
188    pub fn set_display_name(mut self, value: String) -> Self {
189        self.display_name = value;
190        self
191    }
192
193    /// Set freeform_tags
194    pub fn set_freeform_tags(mut self, value: Option<HashMap<String, String>>) -> Self {
195        self.freeform_tags = value;
196        self
197    }
198
199    /// Set system_tags
200    pub fn set_system_tags(
201        mut self,
202        value: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
203    ) -> Self {
204        self.system_tags = value;
205        self
206    }
207
208    /// Set id
209    pub fn set_id(mut self, value: String) -> Self {
210        self.id = value;
211        self
212    }
213
214    /// Set is_hydrated
215    pub fn set_is_hydrated(mut self, value: Option<bool>) -> Self {
216        self.is_hydrated = value;
217        self
218    }
219
220    /// Set kms_key_id
221    pub fn set_kms_key_id(mut self, value: Option<String>) -> Self {
222        self.kms_key_id = value;
223        self
224    }
225
226    /// Set lifecycle_state
227    pub fn set_lifecycle_state(mut self, value: VolumeLifecycleState) -> Self {
228        self.lifecycle_state = value;
229        self
230    }
231
232    /// Set vpus_per_gb
233    pub fn set_vpus_per_gb(mut self, value: Option<i64>) -> Self {
234        self.vpus_per_gb = value;
235        self
236    }
237
238    /// Set cluster_placement_group_id
239    pub fn set_cluster_placement_group_id(mut self, value: Option<String>) -> Self {
240        self.cluster_placement_group_id = value;
241        self
242    }
243
244    /// Set size_in_gbs
245    pub fn set_size_in_gbs(mut self, value: Option<i64>) -> Self {
246        self.size_in_gbs = value;
247        self
248    }
249
250    /// Set size_in_mbs
251    pub fn set_size_in_mbs(mut self, value: i64) -> Self {
252        self.size_in_mbs = value;
253        self
254    }
255
256    /// Set source_details
257    pub fn set_source_details(
258        mut self,
259        value: Option<VolumeSourceFromBlockVolumeReplicaDetails>,
260    ) -> Self {
261        self.source_details = value;
262        self
263    }
264
265    /// Set time_created
266    pub fn set_time_created(mut self, value: DateTime<Utc>) -> Self {
267        self.time_created = value;
268        self
269    }
270
271    /// Set volume_group_id
272    pub fn set_volume_group_id(mut self, value: Option<String>) -> Self {
273        self.volume_group_id = value;
274        self
275    }
276
277    /// Set is_auto_tune_enabled
278    pub fn set_is_auto_tune_enabled(mut self, value: Option<bool>) -> Self {
279        self.is_auto_tune_enabled = value;
280        self
281    }
282
283    /// Set auto_tuned_vpus_per_gb
284    pub fn set_auto_tuned_vpus_per_gb(mut self, value: Option<i64>) -> Self {
285        self.auto_tuned_vpus_per_gb = value;
286        self
287    }
288
289    /// Set block_volume_replicas
290    pub fn set_block_volume_replicas(mut self, value: Option<Vec<BlockVolumeReplicaInfo>>) -> Self {
291        self.block_volume_replicas = value;
292        self
293    }
294
295    /// Set autotune_policies
296    pub fn set_autotune_policies(mut self, value: Option<Vec<AutotunePolicy>>) -> Self {
297        self.autotune_policies = value;
298        self
299    }
300
301    /// Set is_reservations_enabled
302    pub fn set_is_reservations_enabled(mut self, value: Option<bool>) -> Self {
303        self.is_reservations_enabled = value;
304        self
305    }
306
307    /// Set defined_tags (unwraps Option)
308    pub fn with_defined_tags(
309        mut self,
310        value: HashMap<String, HashMap<String, serde_json::Value>>,
311    ) -> Self {
312        self.defined_tags = Some(value);
313        self
314    }
315
316    /// Set freeform_tags (unwraps Option)
317    pub fn with_freeform_tags(mut self, value: HashMap<String, String>) -> Self {
318        self.freeform_tags = Some(value);
319        self
320    }
321
322    /// Set system_tags (unwraps Option)
323    pub fn with_system_tags(
324        mut self,
325        value: HashMap<String, HashMap<String, serde_json::Value>>,
326    ) -> Self {
327        self.system_tags = Some(value);
328        self
329    }
330
331    /// Set is_hydrated (unwraps Option)
332    pub fn with_is_hydrated(mut self, value: bool) -> Self {
333        self.is_hydrated = Some(value);
334        self
335    }
336
337    /// Set kms_key_id (unwraps Option)
338    pub fn with_kms_key_id(mut self, value: impl Into<String>) -> Self {
339        self.kms_key_id = Some(value.into());
340        self
341    }
342
343    /// Set vpus_per_gb (unwraps Option)
344    pub fn with_vpus_per_gb(mut self, value: i64) -> Self {
345        self.vpus_per_gb = Some(value);
346        self
347    }
348
349    /// Set cluster_placement_group_id (unwraps Option)
350    pub fn with_cluster_placement_group_id(mut self, value: impl Into<String>) -> Self {
351        self.cluster_placement_group_id = Some(value.into());
352        self
353    }
354
355    /// Set size_in_gbs (unwraps Option)
356    pub fn with_size_in_gbs(mut self, value: i64) -> Self {
357        self.size_in_gbs = Some(value);
358        self
359    }
360
361    /// Set source_details (unwraps Option)
362    pub fn with_source_details(mut self, value: VolumeSourceFromBlockVolumeReplicaDetails) -> Self {
363        self.source_details = Some(value);
364        self
365    }
366
367    /// Set volume_group_id (unwraps Option)
368    pub fn with_volume_group_id(mut self, value: impl Into<String>) -> Self {
369        self.volume_group_id = Some(value.into());
370        self
371    }
372
373    /// Set is_auto_tune_enabled (unwraps Option)
374    pub fn with_is_auto_tune_enabled(mut self, value: bool) -> Self {
375        self.is_auto_tune_enabled = Some(value);
376        self
377    }
378
379    /// Set auto_tuned_vpus_per_gb (unwraps Option)
380    pub fn with_auto_tuned_vpus_per_gb(mut self, value: i64) -> Self {
381        self.auto_tuned_vpus_per_gb = Some(value);
382        self
383    }
384
385    /// Set block_volume_replicas (unwraps Option)
386    pub fn with_block_volume_replicas(mut self, value: Vec<BlockVolumeReplicaInfo>) -> Self {
387        self.block_volume_replicas = Some(value);
388        self
389    }
390
391    /// Set autotune_policies (unwraps Option)
392    pub fn with_autotune_policies(mut self, value: Vec<AutotunePolicy>) -> Self {
393        self.autotune_policies = Some(value);
394        self
395    }
396
397    /// Set is_reservations_enabled (unwraps Option)
398    pub fn with_is_reservations_enabled(mut self, value: bool) -> Self {
399        self.is_reservations_enabled = Some(value);
400        self
401    }
402}