Skip to main content

oci_rust_sdk/core/models/
image.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4
5#[allow(unused_imports)]
6use super::*;
7/// A boot disk image for launching an instance. For more information, see [Overview of the Compute Service](https://docs.oracle.com/iaas/Content/Compute/Concepts/computeoverview.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 Image {
11    /// The OCID of the compartment containing the instance you want to use as the basis for the image.
12    pub compartment_id: String,
13
14    /// Whether instances launched with this image can be used to create new images. For example, you cannot create an image of an Oracle Database instance. <p> Example: {@code true}
15    pub create_image_allowed: bool,
16
17    /// The OCID of the image.
18    pub id: String,
19
20    pub lifecycle_state: ImageLifecycleState,
21
22    /// The image's operating system. <p> Example: {@code Oracle Linux}
23    pub operating_system: String,
24
25    /// The image's operating system version. <p> Example: {@code 7.2}
26    pub operating_system_version: String,
27
28    /// The date and time the image was created, in the format defined by [RFC3339](https://tools.ietf.org/html/rfc3339). <p> Example: {@code 2016-08-25T21:10:29.600Z}
29    pub time_created: DateTime<Utc>,
30
31    /// The OCID of the image originally used to launch the instance.
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub base_image_id: Option<String>,
34
35    /// 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\"}}}
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub defined_tags: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
38
39    /// A user-friendly name for the image. It does not have to be unique, and it's changeable. Avoid entering confidential information. <p> You cannot use a platform image name as a custom image name. <p> Example: {@code My custom Oracle Linux image}
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub display_name: Option<String>,
42
43    /// 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\"}}
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub freeform_tags: Option<HashMap<String, String>>,
46
47    /// Specifies the configuration mode for launching virtual machine (VM) instances. The configuration modes are: * {@code NATIVE} - VM instances launch with iSCSI boot and VFIO devices. The default value for platform images. * {@code EMULATED} - VM instances launch with emulated devices, such as the E1000 network driver and emulated SCSI disk controller. * {@code PARAVIRTUALIZED} - VM instances launch with paravirtualized devices using VirtIO drivers. * {@code CUSTOM} - VM instances launch with custom configuration settings specified in the {@code LaunchOptions} parameter.
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub launch_mode: Option<ImageLaunchMode>,
50
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub launch_options: Option<LaunchOptions>,
53
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub agent_features: Option<InstanceAgentFeatures>,
56
57    /// The listing type of the image. The default value is \"NONE\".
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub listing_type: Option<ImageListingType>,
60
61    /// The boot volume size for an instance launched from this image (1 MB = 1,048,576 bytes). Note this is not the same as the size of the image when it was exported or the actual size of the image. <p> Example: {@code 47694} Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub size_in_mbs: Option<i64>,
64
65    /// The size of the internal storage for this image that is subject to billing (1 GB = 1,073,741,824 bytes). <p> Example: {@code 100} Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
66    #[serde(skip_serializing_if = "Option::is_none")]
67    pub billable_size_in_gbs: Option<i64>,
68}
69
70/// Required fields for Image
71pub struct ImageRequired {
72    /// The OCID of the compartment containing the instance you want to use as the basis for the image.
73    pub compartment_id: String,
74
75    /// Whether instances launched with this image can be used to create new images. For example, you cannot create an image of an Oracle Database instance. <p> Example: {@code true}
76    pub create_image_allowed: bool,
77
78    /// The OCID of the image.
79    pub id: String,
80
81    pub lifecycle_state: ImageLifecycleState,
82
83    /// The image's operating system. <p> Example: {@code Oracle Linux}
84    pub operating_system: String,
85
86    /// The image's operating system version. <p> Example: {@code 7.2}
87    pub operating_system_version: String,
88
89    /// The date and time the image was created, in the format defined by [RFC3339](https://tools.ietf.org/html/rfc3339). <p> Example: {@code 2016-08-25T21:10:29.600Z}
90    pub time_created: DateTime<Utc>,
91}
92
93impl Image {
94    /// Create a new Image with required fields
95    pub fn new(required: ImageRequired) -> Self {
96        Self {
97            compartment_id: required.compartment_id,
98
99            create_image_allowed: required.create_image_allowed,
100
101            id: required.id,
102
103            lifecycle_state: required.lifecycle_state,
104
105            operating_system: required.operating_system,
106
107            operating_system_version: required.operating_system_version,
108
109            time_created: required.time_created,
110
111            base_image_id: None,
112
113            defined_tags: None,
114
115            display_name: None,
116
117            freeform_tags: None,
118
119            launch_mode: None,
120
121            launch_options: None,
122
123            agent_features: None,
124
125            listing_type: None,
126
127            size_in_mbs: None,
128
129            billable_size_in_gbs: None,
130        }
131    }
132
133    /// Set base_image_id
134    pub fn set_base_image_id(mut self, value: Option<String>) -> Self {
135        self.base_image_id = value;
136        self
137    }
138
139    /// Set compartment_id
140    pub fn set_compartment_id(mut self, value: String) -> Self {
141        self.compartment_id = value;
142        self
143    }
144
145    /// Set create_image_allowed
146    pub fn set_create_image_allowed(mut self, value: bool) -> Self {
147        self.create_image_allowed = value;
148        self
149    }
150
151    /// Set defined_tags
152    pub fn set_defined_tags(
153        mut self,
154        value: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
155    ) -> Self {
156        self.defined_tags = value;
157        self
158    }
159
160    /// Set display_name
161    pub fn set_display_name(mut self, value: Option<String>) -> Self {
162        self.display_name = value;
163        self
164    }
165
166    /// Set freeform_tags
167    pub fn set_freeform_tags(mut self, value: Option<HashMap<String, String>>) -> Self {
168        self.freeform_tags = value;
169        self
170    }
171
172    /// Set id
173    pub fn set_id(mut self, value: String) -> Self {
174        self.id = value;
175        self
176    }
177
178    /// Set launch_mode
179    pub fn set_launch_mode(mut self, value: Option<ImageLaunchMode>) -> Self {
180        self.launch_mode = value;
181        self
182    }
183
184    /// Set launch_options
185    pub fn set_launch_options(mut self, value: Option<LaunchOptions>) -> Self {
186        self.launch_options = value;
187        self
188    }
189
190    /// Set lifecycle_state
191    pub fn set_lifecycle_state(mut self, value: ImageLifecycleState) -> Self {
192        self.lifecycle_state = value;
193        self
194    }
195
196    /// Set operating_system
197    pub fn set_operating_system(mut self, value: String) -> Self {
198        self.operating_system = value;
199        self
200    }
201
202    /// Set operating_system_version
203    pub fn set_operating_system_version(mut self, value: String) -> Self {
204        self.operating_system_version = value;
205        self
206    }
207
208    /// Set agent_features
209    pub fn set_agent_features(mut self, value: Option<InstanceAgentFeatures>) -> Self {
210        self.agent_features = value;
211        self
212    }
213
214    /// Set listing_type
215    pub fn set_listing_type(mut self, value: Option<ImageListingType>) -> Self {
216        self.listing_type = value;
217        self
218    }
219
220    /// Set size_in_mbs
221    pub fn set_size_in_mbs(mut self, value: Option<i64>) -> Self {
222        self.size_in_mbs = value;
223        self
224    }
225
226    /// Set billable_size_in_gbs
227    pub fn set_billable_size_in_gbs(mut self, value: Option<i64>) -> Self {
228        self.billable_size_in_gbs = 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 base_image_id (unwraps Option)
239    pub fn with_base_image_id(mut self, value: impl Into<String>) -> Self {
240        self.base_image_id = Some(value.into());
241        self
242    }
243
244    /// Set defined_tags (unwraps Option)
245    pub fn with_defined_tags(
246        mut self,
247        value: HashMap<String, HashMap<String, serde_json::Value>>,
248    ) -> Self {
249        self.defined_tags = Some(value);
250        self
251    }
252
253    /// Set display_name (unwraps Option)
254    pub fn with_display_name(mut self, value: impl Into<String>) -> Self {
255        self.display_name = Some(value.into());
256        self
257    }
258
259    /// Set freeform_tags (unwraps Option)
260    pub fn with_freeform_tags(mut self, value: HashMap<String, String>) -> Self {
261        self.freeform_tags = Some(value);
262        self
263    }
264
265    /// Set launch_mode (unwraps Option)
266    pub fn with_launch_mode(mut self, value: ImageLaunchMode) -> Self {
267        self.launch_mode = Some(value);
268        self
269    }
270
271    /// Set launch_options (unwraps Option)
272    pub fn with_launch_options(mut self, value: LaunchOptions) -> Self {
273        self.launch_options = Some(value);
274        self
275    }
276
277    /// Set agent_features (unwraps Option)
278    pub fn with_agent_features(mut self, value: InstanceAgentFeatures) -> Self {
279        self.agent_features = Some(value);
280        self
281    }
282
283    /// Set listing_type (unwraps Option)
284    pub fn with_listing_type(mut self, value: ImageListingType) -> Self {
285        self.listing_type = Some(value);
286        self
287    }
288
289    /// Set size_in_mbs (unwraps Option)
290    pub fn with_size_in_mbs(mut self, value: i64) -> Self {
291        self.size_in_mbs = Some(value);
292        self
293    }
294
295    /// Set billable_size_in_gbs (unwraps Option)
296    pub fn with_billable_size_in_gbs(mut self, value: i64) -> Self {
297        self.billable_size_in_gbs = Some(value);
298        self
299    }
300}