Skip to main content

oci_rust_sdk/core/requests/
terminate_instance_request.rs

1use serde::{Deserialize, Serialize};
2
3#[allow(unused_imports)]
4use super::super::models::*;
5#[allow(unused_imports)]
6use super::*;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct TerminateInstanceRequest {
11    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the instance.
12    pub instance_id: String,
13
14    /// For optimistic concurrency control. In the PUT or DELETE call for a resource, set the {@code if-match} parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub if_match: Option<String>,
17
18    /// Specifies whether to delete or preserve the boot volume when terminating an instance. When set to {@code true}, the boot volume is preserved. The default value is {@code false}.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub preserve_boot_volume: Option<bool>,
21
22    /// Specifies whether to delete or preserve the data volumes created during launch when terminating an instance. When set to {@code true}, the data volumes are preserved. The default value is {@code true}.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub preserve_data_volumes_created_at_launch: Option<bool>,
25
26    /// This optional parameter overrides recycle level for hosts. The parameter can be used when hosts are associated with a Capacity Reservation. * {@code FULL_RECYCLE} - Does not skip host wipe. This is the default behavior.
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub recycle_level: Option<TerminateInstanceRequestRecycleLevel>,
29}
30
31/// Required fields for TerminateInstanceRequest
32pub struct TerminateInstanceRequestRequired {
33    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the instance.
34    pub instance_id: String,
35}
36
37impl TerminateInstanceRequest {
38    /// Create a new TerminateInstanceRequest with required fields
39    pub fn new(required: TerminateInstanceRequestRequired) -> Self {
40        Self {
41            instance_id: required.instance_id,
42
43            if_match: None,
44
45            preserve_boot_volume: None,
46
47            preserve_data_volumes_created_at_launch: None,
48
49            recycle_level: None,
50        }
51    }
52
53    /// Set instance_id
54    pub fn set_instance_id(mut self, value: String) -> Self {
55        self.instance_id = value;
56        self
57    }
58
59    /// Set if_match
60    pub fn set_if_match(mut self, value: Option<String>) -> Self {
61        self.if_match = value;
62        self
63    }
64
65    /// Set preserve_boot_volume
66    pub fn set_preserve_boot_volume(mut self, value: Option<bool>) -> Self {
67        self.preserve_boot_volume = value;
68        self
69    }
70
71    /// Set preserve_data_volumes_created_at_launch
72    pub fn set_preserve_data_volumes_created_at_launch(mut self, value: Option<bool>) -> Self {
73        self.preserve_data_volumes_created_at_launch = value;
74        self
75    }
76
77    /// Set recycle_level
78    pub fn set_recycle_level(
79        mut self,
80        value: Option<TerminateInstanceRequestRecycleLevel>,
81    ) -> Self {
82        self.recycle_level = value;
83        self
84    }
85
86    /// Set if_match (unwraps Option)
87    pub fn with_if_match(mut self, value: impl Into<String>) -> Self {
88        self.if_match = Some(value.into());
89        self
90    }
91
92    /// Set preserve_boot_volume (unwraps Option)
93    pub fn with_preserve_boot_volume(mut self, value: bool) -> Self {
94        self.preserve_boot_volume = Some(value);
95        self
96    }
97
98    /// Set preserve_data_volumes_created_at_launch (unwraps Option)
99    pub fn with_preserve_data_volumes_created_at_launch(mut self, value: bool) -> Self {
100        self.preserve_data_volumes_created_at_launch = Some(value);
101        self
102    }
103
104    /// Set recycle_level (unwraps Option)
105    pub fn with_recycle_level(mut self, value: TerminateInstanceRequestRecycleLevel) -> Self {
106        self.recycle_level = Some(value);
107        self
108    }
109}