Skip to main content

oci_rust_sdk/core/models/
instance_configuration.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4
5#[allow(unused_imports)]
6use super::*;
7/// An instance configuration is a template that defines the settings to use when creating Compute instances. For more information about 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 InstanceConfiguration {
11    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the instance configuration.
12    pub compartment_id: String,
13
14    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the instance configuration.
15    pub id: String,
16
17    /// The date and time the instance configuration was created, in the format defined by [RFC3339](https://tools.ietf.org/html/rfc3339). <p> Example: {@code 2016-08-25T21:10:29.600Z}
18    pub time_created: DateTime<Utc>,
19
20    /// 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\"}}}
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub defined_tags: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
23
24    /// A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub display_name: Option<String>,
27
28    /// 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\"}}
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub freeform_tags: Option<HashMap<String, String>>,
31
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub instance_details: Option<ComputeInstanceOptions>,
34
35    /// Parameters that were not specified when the instance configuration was created, but that are required to launch an instance from the instance configuration. See the {@link #launchInstanceConfiguration(LaunchInstanceConfigurationRequest) launchInstanceConfiguration} operation.
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub deferred_fields: Option<Vec<String>>,
38}
39
40/// Required fields for InstanceConfiguration
41pub struct InstanceConfigurationRequired {
42    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the instance configuration.
43    pub compartment_id: String,
44
45    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the instance configuration.
46    pub id: String,
47
48    /// The date and time the instance configuration was created, in the format defined by [RFC3339](https://tools.ietf.org/html/rfc3339). <p> Example: {@code 2016-08-25T21:10:29.600Z}
49    pub time_created: DateTime<Utc>,
50}
51
52impl InstanceConfiguration {
53    /// Create a new InstanceConfiguration with required fields
54    pub fn new(required: InstanceConfigurationRequired) -> Self {
55        Self {
56            compartment_id: required.compartment_id,
57
58            id: required.id,
59
60            time_created: required.time_created,
61
62            defined_tags: None,
63
64            display_name: None,
65
66            freeform_tags: None,
67
68            instance_details: None,
69
70            deferred_fields: None,
71        }
72    }
73
74    /// Set compartment_id
75    pub fn set_compartment_id(mut self, value: String) -> Self {
76        self.compartment_id = value;
77        self
78    }
79
80    /// Set defined_tags
81    pub fn set_defined_tags(
82        mut self,
83        value: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
84    ) -> Self {
85        self.defined_tags = value;
86        self
87    }
88
89    /// Set display_name
90    pub fn set_display_name(mut self, value: Option<String>) -> Self {
91        self.display_name = value;
92        self
93    }
94
95    /// Set freeform_tags
96    pub fn set_freeform_tags(mut self, value: Option<HashMap<String, String>>) -> Self {
97        self.freeform_tags = value;
98        self
99    }
100
101    /// Set id
102    pub fn set_id(mut self, value: String) -> Self {
103        self.id = value;
104        self
105    }
106
107    /// Set instance_details
108    pub fn set_instance_details(mut self, value: Option<ComputeInstanceOptions>) -> Self {
109        self.instance_details = value;
110        self
111    }
112
113    /// Set deferred_fields
114    pub fn set_deferred_fields(mut self, value: Option<Vec<String>>) -> Self {
115        self.deferred_fields = value;
116        self
117    }
118
119    /// Set time_created
120    pub fn set_time_created(mut self, value: DateTime<Utc>) -> Self {
121        self.time_created = value;
122        self
123    }
124
125    /// Set defined_tags (unwraps Option)
126    pub fn with_defined_tags(
127        mut self,
128        value: HashMap<String, HashMap<String, serde_json::Value>>,
129    ) -> Self {
130        self.defined_tags = Some(value);
131        self
132    }
133
134    /// Set display_name (unwraps Option)
135    pub fn with_display_name(mut self, value: impl Into<String>) -> Self {
136        self.display_name = Some(value.into());
137        self
138    }
139
140    /// Set freeform_tags (unwraps Option)
141    pub fn with_freeform_tags(mut self, value: HashMap<String, String>) -> Self {
142        self.freeform_tags = Some(value);
143        self
144    }
145
146    /// Set instance_details (unwraps Option)
147    pub fn with_instance_details(mut self, value: ComputeInstanceOptions) -> Self {
148        self.instance_details = Some(value);
149        self
150    }
151
152    /// Set deferred_fields (unwraps Option)
153    pub fn with_deferred_fields(mut self, value: Vec<String>) -> Self {
154        self.deferred_fields = Some(value);
155        self
156    }
157}