Skip to main content

oci_rust_sdk/core/models/
instance_pool.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4
5#[allow(unused_imports)]
6use super::*;
7/// An instance pool is a set of instances within the same region that are managed as a group. For more information about instance pools and instance configurations, see [Managing Compute Instances](https://docs.oracle.com/iaas/Content/Compute/Concepts/instancemanagement.htm).
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct InstancePool {
11    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the instance pool.
12    pub id: String,
13
14    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the instance pool.
15    pub compartment_id: String,
16
17    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the instance configuration associated with the instance pool.
18    pub instance_configuration_id: String,
19
20    /// The current state of the instance pool.
21    pub lifecycle_state: InstancePoolLifecycleState,
22
23    /// The placement configurations for the instance pool.
24    pub placement_configurations: Vec<InstancePoolPlacementConfiguration>,
25
26    /// The number of instances that should be in the instance pool. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
27    pub size: i64,
28
29    /// The date and time the instance pool was created, in the format defined by [RFC3339](https://tools.ietf.org/html/rfc3339). Example: {@code 2016-08-25T21:10:29.600Z}
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    /// A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub display_name: Option<String>,
39
40    /// 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\"}}
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub freeform_tags: Option<HashMap<String, String>>,
43
44    /// The load balancers attached to the instance pool.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub load_balancers: Option<Vec<InstancePoolLoadBalancerAttachment>>,
47
48    /// A user-friendly formatter for the instance pool's instances. Instance displaynames follow the format. The formatter does not retroactively change instance's displaynames, only instance displaynames in the future follow the format
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub instance_display_name_formatter: Option<String>,
51
52    /// A user-friendly formatter for the instance pool's instances. Instance hostnames follow the format. The formatter does not retroactively change instance's hostnames, only instance hostnames in the future follow the format
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub instance_hostname_formatter: Option<String>,
55
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub lifecycle_management: Option<InstancePoolLifecycleManagementDetails>,
58}
59
60/// Required fields for InstancePool
61pub struct InstancePoolRequired {
62    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the instance pool.
63    pub id: String,
64
65    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the instance pool.
66    pub compartment_id: String,
67
68    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the instance configuration associated with the instance pool.
69    pub instance_configuration_id: String,
70
71    /// The current state of the instance pool.
72    pub lifecycle_state: InstancePoolLifecycleState,
73
74    /// The placement configurations for the instance pool.
75    pub placement_configurations: Vec<InstancePoolPlacementConfiguration>,
76
77    /// The number of instances that should be in the instance pool. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
78    pub size: i64,
79
80    /// The date and time the instance pool was created, in the format defined by [RFC3339](https://tools.ietf.org/html/rfc3339). Example: {@code 2016-08-25T21:10:29.600Z}
81    pub time_created: DateTime<Utc>,
82}
83
84impl InstancePool {
85    /// Create a new InstancePool with required fields
86    pub fn new(required: InstancePoolRequired) -> Self {
87        Self {
88            id: required.id,
89
90            compartment_id: required.compartment_id,
91
92            instance_configuration_id: required.instance_configuration_id,
93
94            lifecycle_state: required.lifecycle_state,
95
96            placement_configurations: required.placement_configurations,
97
98            size: required.size,
99
100            time_created: required.time_created,
101
102            defined_tags: None,
103
104            display_name: None,
105
106            freeform_tags: None,
107
108            load_balancers: None,
109
110            instance_display_name_formatter: None,
111
112            instance_hostname_formatter: None,
113
114            lifecycle_management: None,
115        }
116    }
117
118    /// Set id
119    pub fn set_id(mut self, value: String) -> Self {
120        self.id = value;
121        self
122    }
123
124    /// Set compartment_id
125    pub fn set_compartment_id(mut self, value: String) -> Self {
126        self.compartment_id = value;
127        self
128    }
129
130    /// Set defined_tags
131    pub fn set_defined_tags(
132        mut self,
133        value: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
134    ) -> Self {
135        self.defined_tags = value;
136        self
137    }
138
139    /// Set display_name
140    pub fn set_display_name(mut self, value: Option<String>) -> Self {
141        self.display_name = value;
142        self
143    }
144
145    /// Set freeform_tags
146    pub fn set_freeform_tags(mut self, value: Option<HashMap<String, String>>) -> Self {
147        self.freeform_tags = value;
148        self
149    }
150
151    /// Set instance_configuration_id
152    pub fn set_instance_configuration_id(mut self, value: String) -> Self {
153        self.instance_configuration_id = value;
154        self
155    }
156
157    /// Set lifecycle_state
158    pub fn set_lifecycle_state(mut self, value: InstancePoolLifecycleState) -> Self {
159        self.lifecycle_state = value;
160        self
161    }
162
163    /// Set placement_configurations
164    pub fn set_placement_configurations(
165        mut self,
166        value: Vec<InstancePoolPlacementConfiguration>,
167    ) -> Self {
168        self.placement_configurations = value;
169        self
170    }
171
172    /// Set size
173    pub fn set_size(mut self, value: i64) -> Self {
174        self.size = value;
175        self
176    }
177
178    /// Set time_created
179    pub fn set_time_created(mut self, value: DateTime<Utc>) -> Self {
180        self.time_created = value;
181        self
182    }
183
184    /// Set load_balancers
185    pub fn set_load_balancers(
186        mut self,
187        value: Option<Vec<InstancePoolLoadBalancerAttachment>>,
188    ) -> Self {
189        self.load_balancers = value;
190        self
191    }
192
193    /// Set instance_display_name_formatter
194    pub fn set_instance_display_name_formatter(mut self, value: Option<String>) -> Self {
195        self.instance_display_name_formatter = value;
196        self
197    }
198
199    /// Set instance_hostname_formatter
200    pub fn set_instance_hostname_formatter(mut self, value: Option<String>) -> Self {
201        self.instance_hostname_formatter = value;
202        self
203    }
204
205    /// Set lifecycle_management
206    pub fn set_lifecycle_management(
207        mut self,
208        value: Option<InstancePoolLifecycleManagementDetails>,
209    ) -> Self {
210        self.lifecycle_management = value;
211        self
212    }
213
214    /// Set defined_tags (unwraps Option)
215    pub fn with_defined_tags(
216        mut self,
217        value: HashMap<String, HashMap<String, serde_json::Value>>,
218    ) -> Self {
219        self.defined_tags = Some(value);
220        self
221    }
222
223    /// Set display_name (unwraps Option)
224    pub fn with_display_name(mut self, value: impl Into<String>) -> Self {
225        self.display_name = Some(value.into());
226        self
227    }
228
229    /// Set freeform_tags (unwraps Option)
230    pub fn with_freeform_tags(mut self, value: HashMap<String, String>) -> Self {
231        self.freeform_tags = Some(value);
232        self
233    }
234
235    /// Set load_balancers (unwraps Option)
236    pub fn with_load_balancers(mut self, value: Vec<InstancePoolLoadBalancerAttachment>) -> Self {
237        self.load_balancers = Some(value);
238        self
239    }
240
241    /// Set instance_display_name_formatter (unwraps Option)
242    pub fn with_instance_display_name_formatter(mut self, value: impl Into<String>) -> Self {
243        self.instance_display_name_formatter = Some(value.into());
244        self
245    }
246
247    /// Set instance_hostname_formatter (unwraps Option)
248    pub fn with_instance_hostname_formatter(mut self, value: impl Into<String>) -> Self {
249        self.instance_hostname_formatter = Some(value.into());
250        self
251    }
252
253    /// Set lifecycle_management (unwraps Option)
254    pub fn with_lifecycle_management(
255        mut self,
256        value: InstancePoolLifecycleManagementDetails,
257    ) -> Self {
258        self.lifecycle_management = Some(value);
259        self
260    }
261}