Skip to main content

oci_rust_sdk/core/requests/
instance_action_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 InstanceActionRequest {
11    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the instance.
12    pub instance_id: String,
13
14    /// The action to perform on the instance.
15    pub action: String,
16
17    /// A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations (for example, if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected).
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub opc_retry_token: Option<String>,
20
21    /// 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.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub if_match: Option<String>,
24
25    /// Instance Power Action details
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub instance_power_action_details: Option<ResetActionDetails>,
28}
29
30/// Required fields for InstanceActionRequest
31pub struct InstanceActionRequestRequired {
32    /// The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the instance.
33    pub instance_id: String,
34
35    /// The action to perform on the instance.
36    pub action: String,
37}
38
39impl InstanceActionRequest {
40    /// Create a new InstanceActionRequest with required fields
41    pub fn new(required: InstanceActionRequestRequired) -> Self {
42        Self {
43            instance_id: required.instance_id,
44
45            action: required.action,
46
47            opc_retry_token: None,
48
49            if_match: None,
50
51            instance_power_action_details: None,
52        }
53    }
54
55    /// Set instance_id
56    pub fn set_instance_id(mut self, value: String) -> Self {
57        self.instance_id = value;
58        self
59    }
60
61    /// Set action
62    pub fn set_action(mut self, value: String) -> Self {
63        self.action = value;
64        self
65    }
66
67    /// Set opc_retry_token
68    pub fn set_opc_retry_token(mut self, value: Option<String>) -> Self {
69        self.opc_retry_token = value;
70        self
71    }
72
73    /// Set if_match
74    pub fn set_if_match(mut self, value: Option<String>) -> Self {
75        self.if_match = value;
76        self
77    }
78
79    /// Set instance_power_action_details
80    pub fn set_instance_power_action_details(mut self, value: Option<ResetActionDetails>) -> Self {
81        self.instance_power_action_details = value;
82        self
83    }
84
85    /// Set opc_retry_token (unwraps Option)
86    pub fn with_opc_retry_token(mut self, value: impl Into<String>) -> Self {
87        self.opc_retry_token = Some(value.into());
88        self
89    }
90
91    /// Set if_match (unwraps Option)
92    pub fn with_if_match(mut self, value: impl Into<String>) -> Self {
93        self.if_match = Some(value.into());
94        self
95    }
96
97    /// Set instance_power_action_details (unwraps Option)
98    pub fn with_instance_power_action_details(mut self, value: ResetActionDetails) -> Self {
99        self.instance_power_action_details = Some(value);
100        self
101    }
102}