Skip to main content

oci_rust_sdk/core/models/
volume_backup.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4
5#[allow(unused_imports)]
6use super::*;
7/// A point-in-time copy of a volume that can then be used to create a new block volume or recover a block volume. 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 VolumeBackup {
11    /// The OCID of the compartment that contains the volume backup.
12    pub compartment_id: String,
13
14    /// A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
15    pub display_name: String,
16
17    /// The OCID of the volume backup.
18    pub id: String,
19
20    /// The current state of a volume backup.
21    pub lifecycle_state: VolumeBackupLifecycleState,
22
23    /// The date and time the volume backup was created. This is the time the actual point-in-time image of the volume data was taken. Format defined by [RFC3339](https://tools.ietf.org/html/rfc3339).
24    pub time_created: DateTime<Utc>,
25
26    /// The type of a volume backup.
27    #[serde(rename = "type")]
28    pub r#type: VolumeBackupType,
29
30    /// 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\"}}}
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub defined_tags: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
33
34    /// System tags for this resource. Each key is predefined and scoped to a namespace. Example: {@code {\"foo-namespace\": {\"bar-key\": \"value\"}}}
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub system_tags: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
37
38    /// The date and time the volume backup will expire and be automatically deleted. Format defined by [RFC3339](https://tools.ietf.org/html/rfc3339). This parameter will always be present for backups that were created automatically by a scheduled-backup policy. For manually created backups, it will be absent, signifying that there is no expiration time and the backup will last forever until manually deleted.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub expiration_time: Option<DateTime<Utc>>,
41
42    /// 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\"}}
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub freeform_tags: Option<HashMap<String, String>>,
45
46    /// The OCID of the Vault service key which is the master encryption key for the volume backup. For more information about the Vault service and encryption keys, see [Overview of Vault service](https://docs.oracle.com/iaas/Content/KeyManagement/Concepts/keyoverview.htm) and [Using Keys](https://docs.oracle.com/iaas/Content/KeyManagement/Tasks/usingkeys.htm).
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub kms_key_id: Option<String>,
49
50    /// The size of the volume, in GBs. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub size_in_gbs: Option<i64>,
53
54    /// The size of the volume in MBs. The value must be a multiple of 1024. This field is deprecated. Please use sizeInGBs. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub size_in_mbs: Option<i64>,
57
58    /// Specifies whether the backup was created manually, or via scheduled backup policy.
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub source_type: Option<VolumeBackupSourceType>,
61
62    /// The OCID of the source volume backup.
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub source_volume_backup_id: Option<String>,
65
66    /// The date and time the request to create the volume backup was received. Format defined by [RFC3339]https://tools.ietf.org/html/rfc3339.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub time_request_received: Option<DateTime<Utc>>,
69
70    /// The size used by the backup, in GBs. It is typically smaller than sizeInGBs, depending on the space consumed on the volume and whether the backup is full or incremental. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub unique_size_in_gbs: Option<i64>,
73
74    /// The size used by the backup, in MBs. It is typically smaller than sizeInMBs, depending on the space consumed on the volume and whether the backup is full or incremental. This field is deprecated. Please use uniqueSizeInGBs. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub unique_size_in_mbs: Option<i64>,
77
78    /// The OCID of the volume.
79    #[serde(skip_serializing_if = "Option::is_none")]
80    pub volume_id: Option<String>,
81}
82
83/// Required fields for VolumeBackup
84pub struct VolumeBackupRequired {
85    /// The OCID of the compartment that contains the volume backup.
86    pub compartment_id: String,
87
88    /// A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
89    pub display_name: String,
90
91    /// The OCID of the volume backup.
92    pub id: String,
93
94    /// The current state of a volume backup.
95    pub lifecycle_state: VolumeBackupLifecycleState,
96
97    /// The date and time the volume backup was created. This is the time the actual point-in-time image of the volume data was taken. Format defined by [RFC3339](https://tools.ietf.org/html/rfc3339).
98    pub time_created: DateTime<Utc>,
99
100    /// The type of a volume backup.
101    pub r#type: VolumeBackupType,
102}
103
104impl VolumeBackup {
105    /// Create a new VolumeBackup with required fields
106    pub fn new(required: VolumeBackupRequired) -> Self {
107        Self {
108            compartment_id: required.compartment_id,
109
110            display_name: required.display_name,
111
112            id: required.id,
113
114            lifecycle_state: required.lifecycle_state,
115
116            time_created: required.time_created,
117
118            r#type: required.r#type,
119
120            defined_tags: None,
121
122            system_tags: None,
123
124            expiration_time: None,
125
126            freeform_tags: None,
127
128            kms_key_id: None,
129
130            size_in_gbs: None,
131
132            size_in_mbs: None,
133
134            source_type: None,
135
136            source_volume_backup_id: None,
137
138            time_request_received: None,
139
140            unique_size_in_gbs: None,
141
142            unique_size_in_mbs: None,
143
144            volume_id: None,
145        }
146    }
147
148    /// Set compartment_id
149    pub fn set_compartment_id(mut self, value: String) -> Self {
150        self.compartment_id = value;
151        self
152    }
153
154    /// Set defined_tags
155    pub fn set_defined_tags(
156        mut self,
157        value: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
158    ) -> Self {
159        self.defined_tags = value;
160        self
161    }
162
163    /// Set system_tags
164    pub fn set_system_tags(
165        mut self,
166        value: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
167    ) -> Self {
168        self.system_tags = value;
169        self
170    }
171
172    /// Set display_name
173    pub fn set_display_name(mut self, value: String) -> Self {
174        self.display_name = value;
175        self
176    }
177
178    /// Set expiration_time
179    pub fn set_expiration_time(mut self, value: Option<DateTime<Utc>>) -> Self {
180        self.expiration_time = value;
181        self
182    }
183
184    /// Set freeform_tags
185    pub fn set_freeform_tags(mut self, value: Option<HashMap<String, String>>) -> Self {
186        self.freeform_tags = value;
187        self
188    }
189
190    /// Set id
191    pub fn set_id(mut self, value: String) -> Self {
192        self.id = value;
193        self
194    }
195
196    /// Set kms_key_id
197    pub fn set_kms_key_id(mut self, value: Option<String>) -> Self {
198        self.kms_key_id = value;
199        self
200    }
201
202    /// Set lifecycle_state
203    pub fn set_lifecycle_state(mut self, value: VolumeBackupLifecycleState) -> Self {
204        self.lifecycle_state = value;
205        self
206    }
207
208    /// Set size_in_gbs
209    pub fn set_size_in_gbs(mut self, value: Option<i64>) -> Self {
210        self.size_in_gbs = value;
211        self
212    }
213
214    /// Set size_in_mbs
215    pub fn set_size_in_mbs(mut self, value: Option<i64>) -> Self {
216        self.size_in_mbs = value;
217        self
218    }
219
220    /// Set source_type
221    pub fn set_source_type(mut self, value: Option<VolumeBackupSourceType>) -> Self {
222        self.source_type = value;
223        self
224    }
225
226    /// Set source_volume_backup_id
227    pub fn set_source_volume_backup_id(mut self, value: Option<String>) -> Self {
228        self.source_volume_backup_id = value;
229        self
230    }
231
232    /// Set time_created
233    pub fn set_time_created(mut self, value: DateTime<Utc>) -> Self {
234        self.time_created = value;
235        self
236    }
237
238    /// Set time_request_received
239    pub fn set_time_request_received(mut self, value: Option<DateTime<Utc>>) -> Self {
240        self.time_request_received = value;
241        self
242    }
243
244    /// Set r#type
245    pub fn set_type(mut self, value: VolumeBackupType) -> Self {
246        self.r#type = value;
247        self
248    }
249
250    /// Set unique_size_in_gbs
251    pub fn set_unique_size_in_gbs(mut self, value: Option<i64>) -> Self {
252        self.unique_size_in_gbs = value;
253        self
254    }
255
256    /// Set unique_size_in_mbs
257    pub fn set_unique_size_in_mbs(mut self, value: Option<i64>) -> Self {
258        self.unique_size_in_mbs = value;
259        self
260    }
261
262    /// Set volume_id
263    pub fn set_volume_id(mut self, value: Option<String>) -> Self {
264        self.volume_id = value;
265        self
266    }
267
268    /// Set defined_tags (unwraps Option)
269    pub fn with_defined_tags(
270        mut self,
271        value: HashMap<String, HashMap<String, serde_json::Value>>,
272    ) -> Self {
273        self.defined_tags = Some(value);
274        self
275    }
276
277    /// Set system_tags (unwraps Option)
278    pub fn with_system_tags(
279        mut self,
280        value: HashMap<String, HashMap<String, serde_json::Value>>,
281    ) -> Self {
282        self.system_tags = Some(value);
283        self
284    }
285
286    /// Set expiration_time (unwraps Option)
287    pub fn with_expiration_time(mut self, value: DateTime<Utc>) -> Self {
288        self.expiration_time = Some(value);
289        self
290    }
291
292    /// Set freeform_tags (unwraps Option)
293    pub fn with_freeform_tags(mut self, value: HashMap<String, String>) -> Self {
294        self.freeform_tags = Some(value);
295        self
296    }
297
298    /// Set kms_key_id (unwraps Option)
299    pub fn with_kms_key_id(mut self, value: impl Into<String>) -> Self {
300        self.kms_key_id = Some(value.into());
301        self
302    }
303
304    /// Set size_in_gbs (unwraps Option)
305    pub fn with_size_in_gbs(mut self, value: i64) -> Self {
306        self.size_in_gbs = Some(value);
307        self
308    }
309
310    /// Set size_in_mbs (unwraps Option)
311    pub fn with_size_in_mbs(mut self, value: i64) -> Self {
312        self.size_in_mbs = Some(value);
313        self
314    }
315
316    /// Set source_type (unwraps Option)
317    pub fn with_source_type(mut self, value: VolumeBackupSourceType) -> Self {
318        self.source_type = Some(value);
319        self
320    }
321
322    /// Set source_volume_backup_id (unwraps Option)
323    pub fn with_source_volume_backup_id(mut self, value: impl Into<String>) -> Self {
324        self.source_volume_backup_id = Some(value.into());
325        self
326    }
327
328    /// Set time_request_received (unwraps Option)
329    pub fn with_time_request_received(mut self, value: DateTime<Utc>) -> Self {
330        self.time_request_received = Some(value);
331        self
332    }
333
334    /// Set unique_size_in_gbs (unwraps Option)
335    pub fn with_unique_size_in_gbs(mut self, value: i64) -> Self {
336        self.unique_size_in_gbs = Some(value);
337        self
338    }
339
340    /// Set unique_size_in_mbs (unwraps Option)
341    pub fn with_unique_size_in_mbs(mut self, value: i64) -> Self {
342        self.unique_size_in_mbs = Some(value);
343        self
344    }
345
346    /// Set volume_id (unwraps Option)
347    pub fn with_volume_id(mut self, value: impl Into<String>) -> Self {
348        self.volume_id = Some(value.into());
349        self
350    }
351}