Skip to main content

openapi_service_fabric/apis/
faults_api.rs

1/*
2 * Service Fabric Client APIs
3 *
4 * Service Fabric REST Client APIs allows management of Service Fabric clusters, applications and services.
5 *
6 * The version of the OpenAPI document: 8.2
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`cancel_operation`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CancelOperationError {
20    DefaultResponse(models::FabricError),
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`get_data_loss_progress`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum GetDataLossProgressError {
28    DefaultResponse(models::FabricError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_fault_operation_list`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetFaultOperationListError {
36    DefaultResponse(models::FabricError),
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`get_node_transition_progress`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetNodeTransitionProgressError {
44    DefaultResponse(models::FabricError),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`get_partition_restart_progress`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetPartitionRestartProgressError {
52    DefaultResponse(models::FabricError),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method [`get_quorum_loss_progress`]
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum GetQuorumLossProgressError {
60    DefaultResponse(models::FabricError),
61    UnknownValue(serde_json::Value),
62}
63
64/// struct for typed errors of method [`start_data_loss`]
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum StartDataLossError {
68    DefaultResponse(models::FabricError),
69    UnknownValue(serde_json::Value),
70}
71
72/// struct for typed errors of method [`start_node_transition`]
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum StartNodeTransitionError {
76    DefaultResponse(models::FabricError),
77    UnknownValue(serde_json::Value),
78}
79
80/// struct for typed errors of method [`start_partition_restart`]
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum StartPartitionRestartError {
84    DefaultResponse(models::FabricError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`start_quorum_loss`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum StartQuorumLossError {
92    DefaultResponse(models::FabricError),
93    UnknownValue(serde_json::Value),
94}
95
96/// The following APIs start fault operations that may be cancelled by using CancelOperation: StartDataLoss, StartQuorumLoss, StartPartitionRestart, StartNodeTransition.  If force is false, then the specified user-induced operation will be gracefully stopped and cleaned up.  If force is true, the command will be aborted, and some internal state may be left behind.  Specifying force as true should be used with care.  Calling this API with force set to true is not allowed until this API has already been called on the same test command with force set to false first, or unless the test command already has an OperationState of OperationState.RollingBack. Clarification: OperationState.RollingBack means that the system will be/is cleaning up internal system state caused by executing the command.  It will not restore data if the test command was to cause data loss.  For example, if you call StartDataLoss then call this API, the system will only clean up internal state from running the command. It will not restore the target partition's data, if the command progressed far enough to cause data loss.  Important note:  if this API is invoked with force==true, internal state may be left behind.
97pub async fn cancel_operation(
98    configuration: &configuration::Configuration,
99    api_version: &str,
100    operation_id: &str,
101    force: bool,
102    timeout: Option<i64>,
103) -> Result<(), Error<CancelOperationError>> {
104    // add a prefix to parameters to efficiently prevent name collisions
105    let p_query_api_version = api_version;
106    let p_query_operation_id = operation_id;
107    let p_query_force = force;
108    let p_query_timeout = timeout;
109
110    let uri_str = format!("{}/Faults/$/Cancel", configuration.base_path);
111    let mut req_builder = configuration
112        .client
113        .request(reqwest::Method::POST, &uri_str);
114
115    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
116    req_builder = req_builder.query(&[("OperationId", &p_query_operation_id.to_string())]);
117    req_builder = req_builder.query(&[("Force", &p_query_force.to_string())]);
118    if let Some(ref param_value) = p_query_timeout {
119        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
120    }
121    if let Some(ref user_agent) = configuration.user_agent {
122        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
123    }
124
125    let req = req_builder.build()?;
126    let resp = configuration.client.execute(req).await?;
127
128    let status = resp.status();
129
130    if !status.is_client_error() && !status.is_server_error() {
131        Ok(())
132    } else {
133        let content = resp.text().await?;
134        let entity: Option<CancelOperationError> = serde_json::from_str(&content).ok();
135        Err(Error::ResponseError(ResponseContent {
136            status,
137            content,
138            entity,
139        }))
140    }
141}
142
143/// Gets the progress of a data loss operation started with StartDataLoss, using the OperationId.
144pub async fn get_data_loss_progress(
145    configuration: &configuration::Configuration,
146    api_version: &str,
147    service_id: &str,
148    partition_id: &str,
149    operation_id: &str,
150    timeout: Option<i64>,
151) -> Result<models::PartitionDataLossProgress, Error<GetDataLossProgressError>> {
152    // add a prefix to parameters to efficiently prevent name collisions
153    let p_query_api_version = api_version;
154    let p_path_service_id = service_id;
155    let p_path_partition_id = partition_id;
156    let p_query_operation_id = operation_id;
157    let p_query_timeout = timeout;
158
159    let uri_str = format!(
160        "{}/Faults/Services/{serviceId}/$/GetPartitions/{partitionId}/$/GetDataLossProgress",
161        configuration.base_path,
162        serviceId = crate::apis::urlencode(p_path_service_id),
163        partitionId = crate::apis::urlencode(p_path_partition_id)
164    );
165    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
166
167    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
168    req_builder = req_builder.query(&[("OperationId", &p_query_operation_id.to_string())]);
169    if let Some(ref param_value) = p_query_timeout {
170        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
171    }
172    if let Some(ref user_agent) = configuration.user_agent {
173        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
174    }
175
176    let req = req_builder.build()?;
177    let resp = configuration.client.execute(req).await?;
178
179    let status = resp.status();
180    let content_type = resp
181        .headers()
182        .get("content-type")
183        .and_then(|v| v.to_str().ok())
184        .unwrap_or("application/octet-stream");
185    let content_type = super::ContentType::from(content_type);
186
187    if !status.is_client_error() && !status.is_server_error() {
188        let content = resp.text().await?;
189        match content_type {
190            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
191            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PartitionDataLossProgress`"))),
192            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PartitionDataLossProgress`")))),
193        }
194    } else {
195        let content = resp.text().await?;
196        let entity: Option<GetDataLossProgressError> = serde_json::from_str(&content).ok();
197        Err(Error::ResponseError(ResponseContent {
198            status,
199            content,
200            entity,
201        }))
202    }
203}
204
205/// Gets the list of user-induced fault operations filtered by provided input.
206pub async fn get_fault_operation_list(
207    configuration: &configuration::Configuration,
208    api_version: &str,
209    type_filter: i32,
210    state_filter: i32,
211    timeout: Option<i64>,
212) -> Result<Vec<models::OperationStatus>, Error<GetFaultOperationListError>> {
213    // add a prefix to parameters to efficiently prevent name collisions
214    let p_query_api_version = api_version;
215    let p_query_type_filter = type_filter;
216    let p_query_state_filter = state_filter;
217    let p_query_timeout = timeout;
218
219    let uri_str = format!("{}/Faults/", configuration.base_path);
220    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
221
222    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
223    req_builder = req_builder.query(&[("TypeFilter", &p_query_type_filter.to_string())]);
224    req_builder = req_builder.query(&[("StateFilter", &p_query_state_filter.to_string())]);
225    if let Some(ref param_value) = p_query_timeout {
226        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
227    }
228    if let Some(ref user_agent) = configuration.user_agent {
229        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
230    }
231
232    let req = req_builder.build()?;
233    let resp = configuration.client.execute(req).await?;
234
235    let status = resp.status();
236    let content_type = resp
237        .headers()
238        .get("content-type")
239        .and_then(|v| v.to_str().ok())
240        .unwrap_or("application/octet-stream");
241    let content_type = super::ContentType::from(content_type);
242
243    if !status.is_client_error() && !status.is_server_error() {
244        let content = resp.text().await?;
245        match content_type {
246            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
247            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::OperationStatus&gt;`"))),
248            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::OperationStatus&gt;`")))),
249        }
250    } else {
251        let content = resp.text().await?;
252        let entity: Option<GetFaultOperationListError> = serde_json::from_str(&content).ok();
253        Err(Error::ResponseError(ResponseContent {
254            status,
255            content,
256            entity,
257        }))
258    }
259}
260
261/// Gets the progress of an operation started with StartNodeTransition using the provided OperationId.
262pub async fn get_node_transition_progress(
263    configuration: &configuration::Configuration,
264    api_version: &str,
265    node_name: &str,
266    operation_id: &str,
267    timeout: Option<i64>,
268) -> Result<models::NodeTransitionProgress, Error<GetNodeTransitionProgressError>> {
269    // add a prefix to parameters to efficiently prevent name collisions
270    let p_query_api_version = api_version;
271    let p_path_node_name = node_name;
272    let p_query_operation_id = operation_id;
273    let p_query_timeout = timeout;
274
275    let uri_str = format!(
276        "{}/Faults/Nodes/{nodeName}/$/GetTransitionProgress",
277        configuration.base_path,
278        nodeName = crate::apis::urlencode(p_path_node_name)
279    );
280    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
281
282    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
283    req_builder = req_builder.query(&[("OperationId", &p_query_operation_id.to_string())]);
284    if let Some(ref param_value) = p_query_timeout {
285        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
286    }
287    if let Some(ref user_agent) = configuration.user_agent {
288        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
289    }
290
291    let req = req_builder.build()?;
292    let resp = configuration.client.execute(req).await?;
293
294    let status = resp.status();
295    let content_type = resp
296        .headers()
297        .get("content-type")
298        .and_then(|v| v.to_str().ok())
299        .unwrap_or("application/octet-stream");
300    let content_type = super::ContentType::from(content_type);
301
302    if !status.is_client_error() && !status.is_server_error() {
303        let content = resp.text().await?;
304        match content_type {
305            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
306            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodeTransitionProgress`"))),
307            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodeTransitionProgress`")))),
308        }
309    } else {
310        let content = resp.text().await?;
311        let entity: Option<GetNodeTransitionProgressError> = serde_json::from_str(&content).ok();
312        Err(Error::ResponseError(ResponseContent {
313            status,
314            content,
315            entity,
316        }))
317    }
318}
319
320/// Gets the progress of a PartitionRestart started with StartPartitionRestart using the provided OperationId.
321pub async fn get_partition_restart_progress(
322    configuration: &configuration::Configuration,
323    api_version: &str,
324    service_id: &str,
325    partition_id: &str,
326    operation_id: &str,
327    timeout: Option<i64>,
328) -> Result<models::PartitionRestartProgress, Error<GetPartitionRestartProgressError>> {
329    // add a prefix to parameters to efficiently prevent name collisions
330    let p_query_api_version = api_version;
331    let p_path_service_id = service_id;
332    let p_path_partition_id = partition_id;
333    let p_query_operation_id = operation_id;
334    let p_query_timeout = timeout;
335
336    let uri_str = format!(
337        "{}/Faults/Services/{serviceId}/$/GetPartitions/{partitionId}/$/GetRestartProgress",
338        configuration.base_path,
339        serviceId = crate::apis::urlencode(p_path_service_id),
340        partitionId = crate::apis::urlencode(p_path_partition_id)
341    );
342    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
343
344    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
345    req_builder = req_builder.query(&[("OperationId", &p_query_operation_id.to_string())]);
346    if let Some(ref param_value) = p_query_timeout {
347        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
348    }
349    if let Some(ref user_agent) = configuration.user_agent {
350        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
351    }
352
353    let req = req_builder.build()?;
354    let resp = configuration.client.execute(req).await?;
355
356    let status = resp.status();
357    let content_type = resp
358        .headers()
359        .get("content-type")
360        .and_then(|v| v.to_str().ok())
361        .unwrap_or("application/octet-stream");
362    let content_type = super::ContentType::from(content_type);
363
364    if !status.is_client_error() && !status.is_server_error() {
365        let content = resp.text().await?;
366        match content_type {
367            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
368            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PartitionRestartProgress`"))),
369            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PartitionRestartProgress`")))),
370        }
371    } else {
372        let content = resp.text().await?;
373        let entity: Option<GetPartitionRestartProgressError> = serde_json::from_str(&content).ok();
374        Err(Error::ResponseError(ResponseContent {
375            status,
376            content,
377            entity,
378        }))
379    }
380}
381
382/// Gets the progress of a quorum loss operation started with StartQuorumLoss, using the provided OperationId.
383pub async fn get_quorum_loss_progress(
384    configuration: &configuration::Configuration,
385    api_version: &str,
386    service_id: &str,
387    partition_id: &str,
388    operation_id: &str,
389    timeout: Option<i64>,
390) -> Result<models::PartitionQuorumLossProgress, Error<GetQuorumLossProgressError>> {
391    // add a prefix to parameters to efficiently prevent name collisions
392    let p_query_api_version = api_version;
393    let p_path_service_id = service_id;
394    let p_path_partition_id = partition_id;
395    let p_query_operation_id = operation_id;
396    let p_query_timeout = timeout;
397
398    let uri_str = format!(
399        "{}/Faults/Services/{serviceId}/$/GetPartitions/{partitionId}/$/GetQuorumLossProgress",
400        configuration.base_path,
401        serviceId = crate::apis::urlencode(p_path_service_id),
402        partitionId = crate::apis::urlencode(p_path_partition_id)
403    );
404    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
405
406    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
407    req_builder = req_builder.query(&[("OperationId", &p_query_operation_id.to_string())]);
408    if let Some(ref param_value) = p_query_timeout {
409        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
410    }
411    if let Some(ref user_agent) = configuration.user_agent {
412        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
413    }
414
415    let req = req_builder.build()?;
416    let resp = configuration.client.execute(req).await?;
417
418    let status = resp.status();
419    let content_type = resp
420        .headers()
421        .get("content-type")
422        .and_then(|v| v.to_str().ok())
423        .unwrap_or("application/octet-stream");
424    let content_type = super::ContentType::from(content_type);
425
426    if !status.is_client_error() && !status.is_server_error() {
427        let content = resp.text().await?;
428        match content_type {
429            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
430            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PartitionQuorumLossProgress`"))),
431            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PartitionQuorumLossProgress`")))),
432        }
433    } else {
434        let content = resp.text().await?;
435        let entity: Option<GetQuorumLossProgressError> = serde_json::from_str(&content).ok();
436        Err(Error::ResponseError(ResponseContent {
437            status,
438            content,
439            entity,
440        }))
441    }
442}
443
444/// This API will induce data loss for the specified partition. It will trigger a call to the OnDataLoss API of the partition. Actual data loss will depend on the specified DataLossMode.  - PartialDataLoss - Only a quorum of replicas are removed and OnDataLoss is triggered for the partition but actual data loss depends on the presence of in-flight replication. - FullDataLoss - All replicas are removed hence all data is lost and OnDataLoss is triggered.  This API should only be called with a stateful service as the target.  Calling this API with a system service as the target is not advised.  Note:  Once this API has been called, it cannot be reversed. Calling CancelOperation will only stop execution and clean up internal system state. It will not restore data if the command has progressed far enough to cause data loss.  Call the GetDataLossProgress API with the same OperationId to return information on the operation started with this API.
445pub async fn start_data_loss(
446    configuration: &configuration::Configuration,
447    api_version: &str,
448    service_id: &str,
449    partition_id: &str,
450    operation_id: &str,
451    data_loss_mode: &str,
452    timeout: Option<i64>,
453) -> Result<(), Error<StartDataLossError>> {
454    // add a prefix to parameters to efficiently prevent name collisions
455    let p_query_api_version = api_version;
456    let p_path_service_id = service_id;
457    let p_path_partition_id = partition_id;
458    let p_query_operation_id = operation_id;
459    let p_query_data_loss_mode = data_loss_mode;
460    let p_query_timeout = timeout;
461
462    let uri_str = format!(
463        "{}/Faults/Services/{serviceId}/$/GetPartitions/{partitionId}/$/StartDataLoss",
464        configuration.base_path,
465        serviceId = crate::apis::urlencode(p_path_service_id),
466        partitionId = crate::apis::urlencode(p_path_partition_id)
467    );
468    let mut req_builder = configuration
469        .client
470        .request(reqwest::Method::POST, &uri_str);
471
472    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
473    req_builder = req_builder.query(&[("OperationId", &p_query_operation_id.to_string())]);
474    req_builder = req_builder.query(&[("DataLossMode", &p_query_data_loss_mode.to_string())]);
475    if let Some(ref param_value) = p_query_timeout {
476        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
477    }
478    if let Some(ref user_agent) = configuration.user_agent {
479        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
480    }
481
482    let req = req_builder.build()?;
483    let resp = configuration.client.execute(req).await?;
484
485    let status = resp.status();
486
487    if !status.is_client_error() && !status.is_server_error() {
488        Ok(())
489    } else {
490        let content = resp.text().await?;
491        let entity: Option<StartDataLossError> = serde_json::from_str(&content).ok();
492        Err(Error::ResponseError(ResponseContent {
493            status,
494            content,
495            entity,
496        }))
497    }
498}
499
500/// Starts or stops a cluster node.  A cluster node is a process, not the OS instance itself.  To start a node, pass in \"Start\" for the NodeTransitionType parameter. To stop a node, pass in \"Stop\" for the NodeTransitionType parameter.  This API starts the operation - when the API returns the node may not have finished transitioning yet. Call GetNodeTransitionProgress with the same OperationId to get the progress of the operation.
501pub async fn start_node_transition(
502    configuration: &configuration::Configuration,
503    api_version: &str,
504    node_name: &str,
505    operation_id: &str,
506    node_transition_type: &str,
507    node_instance_id: &str,
508    stop_duration_in_seconds: i32,
509    timeout: Option<i64>,
510) -> Result<(), Error<StartNodeTransitionError>> {
511    // add a prefix to parameters to efficiently prevent name collisions
512    let p_query_api_version = api_version;
513    let p_path_node_name = node_name;
514    let p_query_operation_id = operation_id;
515    let p_query_node_transition_type = node_transition_type;
516    let p_query_node_instance_id = node_instance_id;
517    let p_query_stop_duration_in_seconds = stop_duration_in_seconds;
518    let p_query_timeout = timeout;
519
520    let uri_str = format!(
521        "{}/Faults/Nodes/{nodeName}/$/StartTransition/",
522        configuration.base_path,
523        nodeName = crate::apis::urlencode(p_path_node_name)
524    );
525    let mut req_builder = configuration
526        .client
527        .request(reqwest::Method::POST, &uri_str);
528
529    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
530    req_builder = req_builder.query(&[("OperationId", &p_query_operation_id.to_string())]);
531    req_builder = req_builder.query(&[(
532        "NodeTransitionType",
533        &p_query_node_transition_type.to_string(),
534    )]);
535    req_builder = req_builder.query(&[("NodeInstanceId", &p_query_node_instance_id.to_string())]);
536    req_builder = req_builder.query(&[(
537        "StopDurationInSeconds",
538        &p_query_stop_duration_in_seconds.to_string(),
539    )]);
540    if let Some(ref param_value) = p_query_timeout {
541        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
542    }
543    if let Some(ref user_agent) = configuration.user_agent {
544        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
545    }
546
547    let req = req_builder.build()?;
548    let resp = configuration.client.execute(req).await?;
549
550    let status = resp.status();
551
552    if !status.is_client_error() && !status.is_server_error() {
553        Ok(())
554    } else {
555        let content = resp.text().await?;
556        let entity: Option<StartNodeTransitionError> = serde_json::from_str(&content).ok();
557        Err(Error::ResponseError(ResponseContent {
558            status,
559            content,
560            entity,
561        }))
562    }
563}
564
565/// This API is useful for testing failover.  If used to target a stateless service partition, RestartPartitionMode must be AllReplicasOrInstances.  Call the GetPartitionRestartProgress API using the same OperationId to get the progress.
566pub async fn start_partition_restart(
567    configuration: &configuration::Configuration,
568    api_version: &str,
569    service_id: &str,
570    partition_id: &str,
571    operation_id: &str,
572    restart_partition_mode: &str,
573    timeout: Option<i64>,
574) -> Result<(), Error<StartPartitionRestartError>> {
575    // add a prefix to parameters to efficiently prevent name collisions
576    let p_query_api_version = api_version;
577    let p_path_service_id = service_id;
578    let p_path_partition_id = partition_id;
579    let p_query_operation_id = operation_id;
580    let p_query_restart_partition_mode = restart_partition_mode;
581    let p_query_timeout = timeout;
582
583    let uri_str = format!(
584        "{}/Faults/Services/{serviceId}/$/GetPartitions/{partitionId}/$/StartRestart",
585        configuration.base_path,
586        serviceId = crate::apis::urlencode(p_path_service_id),
587        partitionId = crate::apis::urlencode(p_path_partition_id)
588    );
589    let mut req_builder = configuration
590        .client
591        .request(reqwest::Method::POST, &uri_str);
592
593    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
594    req_builder = req_builder.query(&[("OperationId", &p_query_operation_id.to_string())]);
595    req_builder = req_builder.query(&[(
596        "RestartPartitionMode",
597        &p_query_restart_partition_mode.to_string(),
598    )]);
599    if let Some(ref param_value) = p_query_timeout {
600        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
601    }
602    if let Some(ref user_agent) = configuration.user_agent {
603        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
604    }
605
606    let req = req_builder.build()?;
607    let resp = configuration.client.execute(req).await?;
608
609    let status = resp.status();
610
611    if !status.is_client_error() && !status.is_server_error() {
612        Ok(())
613    } else {
614        let content = resp.text().await?;
615        let entity: Option<StartPartitionRestartError> = serde_json::from_str(&content).ok();
616        Err(Error::ResponseError(ResponseContent {
617            status,
618            content,
619            entity,
620        }))
621    }
622}
623
624/// This API is useful for a temporary quorum loss situation on your service.  Call the GetQuorumLossProgress API with the same OperationId to return information on the operation started with this API.  This can only be called on stateful persisted (HasPersistedState==true) services.  Do not use this API on stateless services or stateful in-memory only services.
625pub async fn start_quorum_loss(
626    configuration: &configuration::Configuration,
627    api_version: &str,
628    service_id: &str,
629    partition_id: &str,
630    operation_id: &str,
631    quorum_loss_mode: &str,
632    quorum_loss_duration: i32,
633    timeout: Option<i64>,
634) -> Result<(), Error<StartQuorumLossError>> {
635    // add a prefix to parameters to efficiently prevent name collisions
636    let p_query_api_version = api_version;
637    let p_path_service_id = service_id;
638    let p_path_partition_id = partition_id;
639    let p_query_operation_id = operation_id;
640    let p_query_quorum_loss_mode = quorum_loss_mode;
641    let p_query_quorum_loss_duration = quorum_loss_duration;
642    let p_query_timeout = timeout;
643
644    let uri_str = format!(
645        "{}/Faults/Services/{serviceId}/$/GetPartitions/{partitionId}/$/StartQuorumLoss",
646        configuration.base_path,
647        serviceId = crate::apis::urlencode(p_path_service_id),
648        partitionId = crate::apis::urlencode(p_path_partition_id)
649    );
650    let mut req_builder = configuration
651        .client
652        .request(reqwest::Method::POST, &uri_str);
653
654    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
655    req_builder = req_builder.query(&[("OperationId", &p_query_operation_id.to_string())]);
656    req_builder = req_builder.query(&[("QuorumLossMode", &p_query_quorum_loss_mode.to_string())]);
657    req_builder = req_builder.query(&[(
658        "QuorumLossDuration",
659        &p_query_quorum_loss_duration.to_string(),
660    )]);
661    if let Some(ref param_value) = p_query_timeout {
662        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
663    }
664    if let Some(ref user_agent) = configuration.user_agent {
665        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
666    }
667
668    let req = req_builder.build()?;
669    let resp = configuration.client.execute(req).await?;
670
671    let status = resp.status();
672
673    if !status.is_client_error() && !status.is_server_error() {
674        Ok(())
675    } else {
676        let content = resp.text().await?;
677        let entity: Option<StartQuorumLossError> = serde_json::from_str(&content).ok();
678        Err(Error::ResponseError(ResponseContent {
679            status,
680            content,
681            entity,
682        }))
683    }
684}