oci_rust_sdk/core/models/
image.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4
5#[allow(unused_imports)]
6use super::*;
7#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct Image {
11 pub compartment_id: String,
13
14 pub create_image_allowed: bool,
16
17 pub id: String,
19
20 pub lifecycle_state: ImageLifecycleState,
21
22 pub operating_system: String,
24
25 pub operating_system_version: String,
27
28 pub time_created: DateTime<Utc>,
30
31 #[serde(skip_serializing_if = "Option::is_none")]
33 pub base_image_id: Option<String>,
34
35 #[serde(skip_serializing_if = "Option::is_none")]
37 pub defined_tags: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
38
39 #[serde(skip_serializing_if = "Option::is_none")]
41 pub display_name: Option<String>,
42
43 #[serde(skip_serializing_if = "Option::is_none")]
45 pub freeform_tags: Option<HashMap<String, String>>,
46
47 #[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 #[serde(skip_serializing_if = "Option::is_none")]
59 pub listing_type: Option<ImageListingType>,
60
61 #[serde(skip_serializing_if = "Option::is_none")]
63 pub size_in_mbs: Option<i64>,
64
65 #[serde(skip_serializing_if = "Option::is_none")]
67 pub billable_size_in_gbs: Option<i64>,
68}
69
70pub struct ImageRequired {
72 pub compartment_id: String,
74
75 pub create_image_allowed: bool,
77
78 pub id: String,
80
81 pub lifecycle_state: ImageLifecycleState,
82
83 pub operating_system: String,
85
86 pub operating_system_version: String,
88
89 pub time_created: DateTime<Utc>,
91}
92
93impl Image {
94 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 pub fn set_base_image_id(mut self, value: Option<String>) -> Self {
135 self.base_image_id = value;
136 self
137 }
138
139 pub fn set_compartment_id(mut self, value: String) -> Self {
141 self.compartment_id = value;
142 self
143 }
144
145 pub fn set_create_image_allowed(mut self, value: bool) -> Self {
147 self.create_image_allowed = value;
148 self
149 }
150
151 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 pub fn set_display_name(mut self, value: Option<String>) -> Self {
162 self.display_name = value;
163 self
164 }
165
166 pub fn set_freeform_tags(mut self, value: Option<HashMap<String, String>>) -> Self {
168 self.freeform_tags = value;
169 self
170 }
171
172 pub fn set_id(mut self, value: String) -> Self {
174 self.id = value;
175 self
176 }
177
178 pub fn set_launch_mode(mut self, value: Option<ImageLaunchMode>) -> Self {
180 self.launch_mode = value;
181 self
182 }
183
184 pub fn set_launch_options(mut self, value: Option<LaunchOptions>) -> Self {
186 self.launch_options = value;
187 self
188 }
189
190 pub fn set_lifecycle_state(mut self, value: ImageLifecycleState) -> Self {
192 self.lifecycle_state = value;
193 self
194 }
195
196 pub fn set_operating_system(mut self, value: String) -> Self {
198 self.operating_system = value;
199 self
200 }
201
202 pub fn set_operating_system_version(mut self, value: String) -> Self {
204 self.operating_system_version = value;
205 self
206 }
207
208 pub fn set_agent_features(mut self, value: Option<InstanceAgentFeatures>) -> Self {
210 self.agent_features = value;
211 self
212 }
213
214 pub fn set_listing_type(mut self, value: Option<ImageListingType>) -> Self {
216 self.listing_type = value;
217 self
218 }
219
220 pub fn set_size_in_mbs(mut self, value: Option<i64>) -> Self {
222 self.size_in_mbs = value;
223 self
224 }
225
226 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 pub fn set_time_created(mut self, value: DateTime<Utc>) -> Self {
234 self.time_created = value;
235 self
236 }
237
238 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 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 pub fn with_display_name(mut self, value: impl Into<String>) -> Self {
255 self.display_name = Some(value.into());
256 self
257 }
258
259 pub fn with_freeform_tags(mut self, value: HashMap<String, String>) -> Self {
261 self.freeform_tags = Some(value);
262 self
263 }
264
265 pub fn with_launch_mode(mut self, value: ImageLaunchMode) -> Self {
267 self.launch_mode = Some(value);
268 self
269 }
270
271 pub fn with_launch_options(mut self, value: LaunchOptions) -> Self {
273 self.launch_options = Some(value);
274 self
275 }
276
277 pub fn with_agent_features(mut self, value: InstanceAgentFeatures) -> Self {
279 self.agent_features = Some(value);
280 self
281 }
282
283 pub fn with_listing_type(mut self, value: ImageListingType) -> Self {
285 self.listing_type = Some(value);
286 self
287 }
288
289 pub fn with_size_in_mbs(mut self, value: i64) -> Self {
291 self.size_in_mbs = Some(value);
292 self
293 }
294
295 pub fn with_billable_size_in_gbs(mut self, value: i64) -> Self {
297 self.billable_size_in_gbs = Some(value);
298 self
299 }
300}