Skip to main content

oci_rust_sdk/core/models/
instance_reservation_config.rs

1use serde::{Deserialize, Serialize};
2
3#[allow(unused_imports)]
4use super::*;
5/// Data that defines the capacity configuration.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct InstanceReservationConfig {
9    /// The shape to use when launching instances using compute capacity reservations. The shape determines the number of CPUs, the amount of memory, and other resources allocated to the instance. You can list all available shapes by calling {@link ListComputeCapacityReservationInstanceShapes}.
10    pub instance_shape: String,
11
12    /// The total number of instances that can be launched from the capacity configuration. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
13    pub reserved_count: i64,
14
15    /// The amount of capacity in use out of the total capacity reserved in this capacity configuration. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
16    pub used_count: i64,
17
18    /// The fault domain of this capacity configuration. If a value is not supplied, this capacity configuration is applicable to all fault domains in the specified availability domain. For more information, see [Capacity Reservations](https://docs.oracle.com/iaas/Content/Compute/Tasks/reserve-capacity.htm).
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub fault_domain: Option<String>,
21
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub cluster_config: Option<ClusterConfigDetails>,
24
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub instance_shape_config: Option<InstanceReservationShapeConfigDetails>,
27
28    /// The OCID of the cluster placement group for this instance reservation capacity configuration.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub cluster_placement_group_id: Option<String>,
31}
32
33/// Required fields for InstanceReservationConfig
34pub struct InstanceReservationConfigRequired {
35    /// The shape to use when launching instances using compute capacity reservations. The shape determines the number of CPUs, the amount of memory, and other resources allocated to the instance. You can list all available shapes by calling {@link ListComputeCapacityReservationInstanceShapes}.
36    pub instance_shape: String,
37
38    /// The total number of instances that can be launched from the capacity configuration. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
39    pub reserved_count: i64,
40
41    /// The amount of capacity in use out of the total capacity reserved in this capacity configuration. Note: Numbers greater than Number.MAX_SAFE_INTEGER will result in rounding issues.
42    pub used_count: i64,
43}
44
45impl InstanceReservationConfig {
46    /// Create a new InstanceReservationConfig with required fields
47    pub fn new(required: InstanceReservationConfigRequired) -> Self {
48        Self {
49            instance_shape: required.instance_shape,
50
51            reserved_count: required.reserved_count,
52
53            used_count: required.used_count,
54
55            fault_domain: None,
56
57            cluster_config: None,
58
59            instance_shape_config: None,
60
61            cluster_placement_group_id: None,
62        }
63    }
64
65    /// Set fault_domain
66    pub fn set_fault_domain(mut self, value: Option<String>) -> Self {
67        self.fault_domain = value;
68        self
69    }
70
71    /// Set cluster_config
72    pub fn set_cluster_config(mut self, value: Option<ClusterConfigDetails>) -> Self {
73        self.cluster_config = value;
74        self
75    }
76
77    /// Set instance_shape
78    pub fn set_instance_shape(mut self, value: String) -> Self {
79        self.instance_shape = value;
80        self
81    }
82
83    /// Set instance_shape_config
84    pub fn set_instance_shape_config(
85        mut self,
86        value: Option<InstanceReservationShapeConfigDetails>,
87    ) -> Self {
88        self.instance_shape_config = value;
89        self
90    }
91
92    /// Set reserved_count
93    pub fn set_reserved_count(mut self, value: i64) -> Self {
94        self.reserved_count = value;
95        self
96    }
97
98    /// Set used_count
99    pub fn set_used_count(mut self, value: i64) -> Self {
100        self.used_count = value;
101        self
102    }
103
104    /// Set cluster_placement_group_id
105    pub fn set_cluster_placement_group_id(mut self, value: Option<String>) -> Self {
106        self.cluster_placement_group_id = value;
107        self
108    }
109
110    /// Set fault_domain (unwraps Option)
111    pub fn with_fault_domain(mut self, value: impl Into<String>) -> Self {
112        self.fault_domain = Some(value.into());
113        self
114    }
115
116    /// Set cluster_config (unwraps Option)
117    pub fn with_cluster_config(mut self, value: ClusterConfigDetails) -> Self {
118        self.cluster_config = Some(value);
119        self
120    }
121
122    /// Set instance_shape_config (unwraps Option)
123    pub fn with_instance_shape_config(
124        mut self,
125        value: InstanceReservationShapeConfigDetails,
126    ) -> Self {
127        self.instance_shape_config = Some(value);
128        self
129    }
130
131    /// Set cluster_placement_group_id (unwraps Option)
132    pub fn with_cluster_placement_group_id(mut self, value: impl Into<String>) -> Self {
133        self.cluster_placement_group_id = Some(value.into());
134        self
135    }
136}