Skip to main content

openapi_service_fabric/apis/
service_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 [`create_service`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CreateServiceError {
20    DefaultResponse(models::FabricError),
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`create_service_from_template`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum CreateServiceFromTemplateError {
28    DefaultResponse(models::FabricError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`delete_service`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteServiceError {
36    DefaultResponse(models::FabricError),
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`get_application_name_info`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetApplicationNameInfoError {
44    DefaultResponse(models::FabricError),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`get_service_description`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetServiceDescriptionError {
52    DefaultResponse(models::FabricError),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method [`get_service_health`]
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum GetServiceHealthError {
60    DefaultResponse(models::FabricError),
61    UnknownValue(serde_json::Value),
62}
63
64/// struct for typed errors of method [`get_service_health_using_policy`]
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum GetServiceHealthUsingPolicyError {
68    DefaultResponse(models::FabricError),
69    UnknownValue(serde_json::Value),
70}
71
72/// struct for typed errors of method [`get_service_info`]
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum GetServiceInfoError {
76    DefaultResponse(models::FabricError),
77    UnknownValue(serde_json::Value),
78}
79
80/// struct for typed errors of method [`get_service_info_list`]
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum GetServiceInfoListError {
84    DefaultResponse(models::FabricError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`get_unplaced_replica_information`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetUnplacedReplicaInformationError {
92    DefaultResponse(models::FabricError),
93    UnknownValue(serde_json::Value),
94}
95
96/// struct for typed errors of method [`report_service_health`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum ReportServiceHealthError {
100    DefaultResponse(models::FabricError),
101    UnknownValue(serde_json::Value),
102}
103
104/// struct for typed errors of method [`resolve_service`]
105#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum ResolveServiceError {
108    DefaultResponse(models::FabricError),
109    UnknownValue(serde_json::Value),
110}
111
112/// struct for typed errors of method [`update_service`]
113#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum UpdateServiceError {
116    DefaultResponse(models::FabricError),
117    UnknownValue(serde_json::Value),
118}
119
120/// This api allows creating a new Service Fabric stateless or stateful service under a specified Service Fabric application. The description for creating the service includes partitioning information and optional properties for placement and load balancing. Some of the properties can later be modified using `UpdateService` API.
121pub async fn create_service(
122    configuration: &configuration::Configuration,
123    api_version: &str,
124    application_id: &str,
125    service_description: models::ServiceDescription,
126    timeout: Option<i64>,
127) -> Result<(), Error<CreateServiceError>> {
128    // add a prefix to parameters to efficiently prevent name collisions
129    let p_query_api_version = api_version;
130    let p_path_application_id = application_id;
131    let p_body_service_description = service_description;
132    let p_query_timeout = timeout;
133
134    let uri_str = format!(
135        "{}/Applications/{applicationId}/$/GetServices/$/Create",
136        configuration.base_path,
137        applicationId = crate::apis::urlencode(p_path_application_id)
138    );
139    let mut req_builder = configuration
140        .client
141        .request(reqwest::Method::POST, &uri_str);
142
143    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
144    if let Some(ref param_value) = p_query_timeout {
145        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
146    }
147    if let Some(ref user_agent) = configuration.user_agent {
148        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
149    }
150    req_builder = req_builder.json(&p_body_service_description);
151
152    let req = req_builder.build()?;
153    let resp = configuration.client.execute(req).await?;
154
155    let status = resp.status();
156
157    if !status.is_client_error() && !status.is_server_error() {
158        Ok(())
159    } else {
160        let content = resp.text().await?;
161        let entity: Option<CreateServiceError> = serde_json::from_str(&content).ok();
162        Err(Error::ResponseError(ResponseContent {
163            status,
164            content,
165            entity,
166        }))
167    }
168}
169
170/// Creates a Service Fabric service from the service template defined in the application manifest. A service template contains the properties that will be same for the service instance of the same type. The API allows overriding the properties that are usually different for different services of the same service type.
171pub async fn create_service_from_template(
172    configuration: &configuration::Configuration,
173    api_version: &str,
174    application_id: &str,
175    service_from_template_description: models::ServiceFromTemplateDescription,
176    timeout: Option<i64>,
177) -> Result<(), Error<CreateServiceFromTemplateError>> {
178    // add a prefix to parameters to efficiently prevent name collisions
179    let p_query_api_version = api_version;
180    let p_path_application_id = application_id;
181    let p_body_service_from_template_description = service_from_template_description;
182    let p_query_timeout = timeout;
183
184    let uri_str = format!(
185        "{}/Applications/{applicationId}/$/GetServices/$/CreateFromTemplate",
186        configuration.base_path,
187        applicationId = crate::apis::urlencode(p_path_application_id)
188    );
189    let mut req_builder = configuration
190        .client
191        .request(reqwest::Method::POST, &uri_str);
192
193    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
194    if let Some(ref param_value) = p_query_timeout {
195        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
196    }
197    if let Some(ref user_agent) = configuration.user_agent {
198        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
199    }
200    req_builder = req_builder.json(&p_body_service_from_template_description);
201
202    let req = req_builder.build()?;
203    let resp = configuration.client.execute(req).await?;
204
205    let status = resp.status();
206
207    if !status.is_client_error() && !status.is_server_error() {
208        Ok(())
209    } else {
210        let content = resp.text().await?;
211        let entity: Option<CreateServiceFromTemplateError> = serde_json::from_str(&content).ok();
212        Err(Error::ResponseError(ResponseContent {
213            status,
214            content,
215            entity,
216        }))
217    }
218}
219
220/// A service must be created before it can be deleted. By default, Service Fabric will try to close service replicas in a graceful manner and then delete the service. However, if the service is having issues closing the replica gracefully, the delete operation may take a long time or get stuck. Use the optional ForceRemove flag to skip the graceful close sequence and forcefully delete the service.
221pub async fn delete_service(
222    configuration: &configuration::Configuration,
223    api_version: &str,
224    service_id: &str,
225    force_remove: Option<bool>,
226    timeout: Option<i64>,
227) -> Result<(), Error<DeleteServiceError>> {
228    // add a prefix to parameters to efficiently prevent name collisions
229    let p_query_api_version = api_version;
230    let p_path_service_id = service_id;
231    let p_query_force_remove = force_remove;
232    let p_query_timeout = timeout;
233
234    let uri_str = format!(
235        "{}/Services/{serviceId}/$/Delete",
236        configuration.base_path,
237        serviceId = crate::apis::urlencode(p_path_service_id)
238    );
239    let mut req_builder = configuration
240        .client
241        .request(reqwest::Method::POST, &uri_str);
242
243    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
244    if let Some(ref param_value) = p_query_force_remove {
245        req_builder = req_builder.query(&[("ForceRemove", &param_value.to_string())]);
246    }
247    if let Some(ref param_value) = p_query_timeout {
248        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
249    }
250    if let Some(ref user_agent) = configuration.user_agent {
251        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
252    }
253
254    let req = req_builder.build()?;
255    let resp = configuration.client.execute(req).await?;
256
257    let status = resp.status();
258
259    if !status.is_client_error() && !status.is_server_error() {
260        Ok(())
261    } else {
262        let content = resp.text().await?;
263        let entity: Option<DeleteServiceError> = serde_json::from_str(&content).ok();
264        Err(Error::ResponseError(ResponseContent {
265            status,
266            content,
267            entity,
268        }))
269    }
270}
271
272/// Gets the name of the application for the specified service. A 404 FABRIC_E_SERVICE_DOES_NOT_EXIST error is returned if a service with the provided service ID does not exist.
273pub async fn get_application_name_info(
274    configuration: &configuration::Configuration,
275    api_version: &str,
276    service_id: &str,
277    timeout: Option<i64>,
278) -> Result<models::ApplicationNameInfo, Error<GetApplicationNameInfoError>> {
279    // add a prefix to parameters to efficiently prevent name collisions
280    let p_query_api_version = api_version;
281    let p_path_service_id = service_id;
282    let p_query_timeout = timeout;
283
284    let uri_str = format!(
285        "{}/Services/{serviceId}/$/GetApplicationName",
286        configuration.base_path,
287        serviceId = crate::apis::urlencode(p_path_service_id)
288    );
289    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
290
291    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
292    if let Some(ref param_value) = p_query_timeout {
293        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
294    }
295    if let Some(ref user_agent) = configuration.user_agent {
296        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
297    }
298
299    let req = req_builder.build()?;
300    let resp = configuration.client.execute(req).await?;
301
302    let status = resp.status();
303    let content_type = resp
304        .headers()
305        .get("content-type")
306        .and_then(|v| v.to_str().ok())
307        .unwrap_or("application/octet-stream");
308    let content_type = super::ContentType::from(content_type);
309
310    if !status.is_client_error() && !status.is_server_error() {
311        let content = resp.text().await?;
312        match content_type {
313            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
314            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApplicationNameInfo`"))),
315            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::ApplicationNameInfo`")))),
316        }
317    } else {
318        let content = resp.text().await?;
319        let entity: Option<GetApplicationNameInfoError> = serde_json::from_str(&content).ok();
320        Err(Error::ResponseError(ResponseContent {
321            status,
322            content,
323            entity,
324        }))
325    }
326}
327
328/// Gets the description of an existing Service Fabric service. A service must be created before its description can be obtained.
329pub async fn get_service_description(
330    configuration: &configuration::Configuration,
331    api_version: &str,
332    service_id: &str,
333    timeout: Option<i64>,
334) -> Result<models::ServiceDescription, Error<GetServiceDescriptionError>> {
335    // add a prefix to parameters to efficiently prevent name collisions
336    let p_query_api_version = api_version;
337    let p_path_service_id = service_id;
338    let p_query_timeout = timeout;
339
340    let uri_str = format!(
341        "{}/Services/{serviceId}/$/GetDescription",
342        configuration.base_path,
343        serviceId = crate::apis::urlencode(p_path_service_id)
344    );
345    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
346
347    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
348    if let Some(ref param_value) = p_query_timeout {
349        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
350    }
351    if let Some(ref user_agent) = configuration.user_agent {
352        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
353    }
354
355    let req = req_builder.build()?;
356    let resp = configuration.client.execute(req).await?;
357
358    let status = resp.status();
359    let content_type = resp
360        .headers()
361        .get("content-type")
362        .and_then(|v| v.to_str().ok())
363        .unwrap_or("application/octet-stream");
364    let content_type = super::ContentType::from(content_type);
365
366    if !status.is_client_error() && !status.is_server_error() {
367        let content = resp.text().await?;
368        match content_type {
369            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
370            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceDescription`"))),
371            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::ServiceDescription`")))),
372        }
373    } else {
374        let content = resp.text().await?;
375        let entity: Option<GetServiceDescriptionError> = serde_json::from_str(&content).ok();
376        Err(Error::ResponseError(ResponseContent {
377            status,
378            content,
379            entity,
380        }))
381    }
382}
383
384/// Gets the health information of the specified service. Use EventsHealthStateFilter to filter the collection of health events reported on the service based on the health state. Use PartitionsHealthStateFilter to filter the collection of partitions returned. If you specify a service that does not exist in the health store, this request returns an error.
385pub async fn get_service_health(
386    configuration: &configuration::Configuration,
387    api_version: &str,
388    service_id: &str,
389    events_health_state_filter: Option<i32>,
390    partitions_health_state_filter: Option<i32>,
391    exclude_health_statistics: Option<bool>,
392    timeout: Option<i64>,
393) -> Result<models::ServiceHealth, Error<GetServiceHealthError>> {
394    // add a prefix to parameters to efficiently prevent name collisions
395    let p_query_api_version = api_version;
396    let p_path_service_id = service_id;
397    let p_query_events_health_state_filter = events_health_state_filter;
398    let p_query_partitions_health_state_filter = partitions_health_state_filter;
399    let p_query_exclude_health_statistics = exclude_health_statistics;
400    let p_query_timeout = timeout;
401
402    let uri_str = format!(
403        "{}/Services/{serviceId}/$/GetHealth",
404        configuration.base_path,
405        serviceId = crate::apis::urlencode(p_path_service_id)
406    );
407    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
408
409    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
410    if let Some(ref param_value) = p_query_events_health_state_filter {
411        req_builder = req_builder.query(&[("EventsHealthStateFilter", &param_value.to_string())]);
412    }
413    if let Some(ref param_value) = p_query_partitions_health_state_filter {
414        req_builder =
415            req_builder.query(&[("PartitionsHealthStateFilter", &param_value.to_string())]);
416    }
417    if let Some(ref param_value) = p_query_exclude_health_statistics {
418        req_builder = req_builder.query(&[("ExcludeHealthStatistics", &param_value.to_string())]);
419    }
420    if let Some(ref param_value) = p_query_timeout {
421        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
422    }
423    if let Some(ref user_agent) = configuration.user_agent {
424        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
425    }
426
427    let req = req_builder.build()?;
428    let resp = configuration.client.execute(req).await?;
429
430    let status = resp.status();
431    let content_type = resp
432        .headers()
433        .get("content-type")
434        .and_then(|v| v.to_str().ok())
435        .unwrap_or("application/octet-stream");
436    let content_type = super::ContentType::from(content_type);
437
438    if !status.is_client_error() && !status.is_server_error() {
439        let content = resp.text().await?;
440        match content_type {
441            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
442            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceHealth`"))),
443            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::ServiceHealth`")))),
444        }
445    } else {
446        let content = resp.text().await?;
447        let entity: Option<GetServiceHealthError> = serde_json::from_str(&content).ok();
448        Err(Error::ResponseError(ResponseContent {
449            status,
450            content,
451            entity,
452        }))
453    }
454}
455
456/// Gets the health information of the specified service. If the application health policy is specified, the health evaluation uses it to get the aggregated health state. If the policy is not specified, the health evaluation uses the application health policy defined in the application manifest, or the default health policy, if no policy is defined in the manifest. Use EventsHealthStateFilter to filter the collection of health events reported on the service based on the health state. Use PartitionsHealthStateFilter to filter the collection of partitions returned. If you specify a service that does not exist in the health store, this request returns an error.
457pub async fn get_service_health_using_policy(
458    configuration: &configuration::Configuration,
459    api_version: &str,
460    service_id: &str,
461    events_health_state_filter: Option<i32>,
462    partitions_health_state_filter: Option<i32>,
463    exclude_health_statistics: Option<bool>,
464    timeout: Option<i64>,
465    application_health_policy: Option<models::ApplicationHealthPolicy>,
466) -> Result<models::ServiceHealth, Error<GetServiceHealthUsingPolicyError>> {
467    // add a prefix to parameters to efficiently prevent name collisions
468    let p_query_api_version = api_version;
469    let p_path_service_id = service_id;
470    let p_query_events_health_state_filter = events_health_state_filter;
471    let p_query_partitions_health_state_filter = partitions_health_state_filter;
472    let p_query_exclude_health_statistics = exclude_health_statistics;
473    let p_query_timeout = timeout;
474    let p_body_application_health_policy = application_health_policy;
475
476    let uri_str = format!(
477        "{}/Services/{serviceId}/$/GetHealth",
478        configuration.base_path,
479        serviceId = crate::apis::urlencode(p_path_service_id)
480    );
481    let mut req_builder = configuration
482        .client
483        .request(reqwest::Method::POST, &uri_str);
484
485    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
486    if let Some(ref param_value) = p_query_events_health_state_filter {
487        req_builder = req_builder.query(&[("EventsHealthStateFilter", &param_value.to_string())]);
488    }
489    if let Some(ref param_value) = p_query_partitions_health_state_filter {
490        req_builder =
491            req_builder.query(&[("PartitionsHealthStateFilter", &param_value.to_string())]);
492    }
493    if let Some(ref param_value) = p_query_exclude_health_statistics {
494        req_builder = req_builder.query(&[("ExcludeHealthStatistics", &param_value.to_string())]);
495    }
496    if let Some(ref param_value) = p_query_timeout {
497        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
498    }
499    if let Some(ref user_agent) = configuration.user_agent {
500        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
501    }
502    req_builder = req_builder.json(&p_body_application_health_policy);
503
504    let req = req_builder.build()?;
505    let resp = configuration.client.execute(req).await?;
506
507    let status = resp.status();
508    let content_type = resp
509        .headers()
510        .get("content-type")
511        .and_then(|v| v.to_str().ok())
512        .unwrap_or("application/octet-stream");
513    let content_type = super::ContentType::from(content_type);
514
515    if !status.is_client_error() && !status.is_server_error() {
516        let content = resp.text().await?;
517        match content_type {
518            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
519            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceHealth`"))),
520            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::ServiceHealth`")))),
521        }
522    } else {
523        let content = resp.text().await?;
524        let entity: Option<GetServiceHealthUsingPolicyError> = serde_json::from_str(&content).ok();
525        Err(Error::ResponseError(ResponseContent {
526            status,
527            content,
528            entity,
529        }))
530    }
531}
532
533/// Returns the information about the specified service belonging to the specified Service Fabric application.
534pub async fn get_service_info(
535    configuration: &configuration::Configuration,
536    application_id: &str,
537    service_id: &str,
538    api_version: &str,
539    timeout: Option<i64>,
540) -> Result<models::ServiceInfo, Error<GetServiceInfoError>> {
541    // add a prefix to parameters to efficiently prevent name collisions
542    let p_path_application_id = application_id;
543    let p_path_service_id = service_id;
544    let p_query_api_version = api_version;
545    let p_query_timeout = timeout;
546
547    let uri_str = format!(
548        "{}/Applications/{applicationId}/$/GetServices/{serviceId}",
549        configuration.base_path,
550        applicationId = crate::apis::urlencode(p_path_application_id),
551        serviceId = crate::apis::urlencode(p_path_service_id)
552    );
553    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
554
555    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
556    if let Some(ref param_value) = p_query_timeout {
557        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
558    }
559    if let Some(ref user_agent) = configuration.user_agent {
560        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
561    }
562
563    let req = req_builder.build()?;
564    let resp = configuration.client.execute(req).await?;
565
566    let status = resp.status();
567    let content_type = resp
568        .headers()
569        .get("content-type")
570        .and_then(|v| v.to_str().ok())
571        .unwrap_or("application/octet-stream");
572    let content_type = super::ContentType::from(content_type);
573
574    if !status.is_client_error() && !status.is_server_error() {
575        let content = resp.text().await?;
576        match content_type {
577            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
578            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceInfo`"))),
579            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::ServiceInfo`")))),
580        }
581    } else {
582        let content = resp.text().await?;
583        let entity: Option<GetServiceInfoError> = serde_json::from_str(&content).ok();
584        Err(Error::ResponseError(ResponseContent {
585            status,
586            content,
587            entity,
588        }))
589    }
590}
591
592/// Returns the information about all services belonging to the application specified by the application ID.
593pub async fn get_service_info_list(
594    configuration: &configuration::Configuration,
595    application_id: &str,
596    api_version: &str,
597    service_type_name: Option<&str>,
598    continuation_token: Option<&str>,
599    timeout: Option<i64>,
600) -> Result<models::PagedServiceInfoList, Error<GetServiceInfoListError>> {
601    // add a prefix to parameters to efficiently prevent name collisions
602    let p_path_application_id = application_id;
603    let p_query_api_version = api_version;
604    let p_query_service_type_name = service_type_name;
605    let p_query_continuation_token = continuation_token;
606    let p_query_timeout = timeout;
607
608    let uri_str = format!(
609        "{}/Applications/{applicationId}/$/GetServices",
610        configuration.base_path,
611        applicationId = crate::apis::urlencode(p_path_application_id)
612    );
613    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
614
615    if let Some(ref param_value) = p_query_service_type_name {
616        req_builder = req_builder.query(&[("ServiceTypeName", &param_value.to_string())]);
617    }
618    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
619    if let Some(ref param_value) = p_query_continuation_token {
620        req_builder = req_builder.query(&[("ContinuationToken", &param_value.to_string())]);
621    }
622    if let Some(ref param_value) = p_query_timeout {
623        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
624    }
625    if let Some(ref user_agent) = configuration.user_agent {
626        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
627    }
628
629    let req = req_builder.build()?;
630    let resp = configuration.client.execute(req).await?;
631
632    let status = resp.status();
633    let content_type = resp
634        .headers()
635        .get("content-type")
636        .and_then(|v| v.to_str().ok())
637        .unwrap_or("application/octet-stream");
638    let content_type = super::ContentType::from(content_type);
639
640    if !status.is_client_error() && !status.is_server_error() {
641        let content = resp.text().await?;
642        match content_type {
643            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
644            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagedServiceInfoList`"))),
645            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::PagedServiceInfoList`")))),
646        }
647    } else {
648        let content = resp.text().await?;
649        let entity: Option<GetServiceInfoListError> = serde_json::from_str(&content).ok();
650        Err(Error::ResponseError(ResponseContent {
651            status,
652            content,
653            entity,
654        }))
655    }
656}
657
658/// Returns the information about the unplaced replicas of the service. If PartitionId is specified, then result will contain information only about unplaced replicas for that partition. If PartitionId is not specified, then result will contain information about unplaced replicas for all partitions of that service. If OnlyQueryPrimaries is set to true, then result will contain information only about primary replicas, and will ignore unplaced secondary replicas.
659pub async fn get_unplaced_replica_information(
660    configuration: &configuration::Configuration,
661    api_version: &str,
662    service_id: &str,
663    partition_id: Option<&str>,
664    only_query_primaries: Option<bool>,
665    timeout: Option<i64>,
666) -> Result<models::UnplacedReplicaInformation, Error<GetUnplacedReplicaInformationError>> {
667    // add a prefix to parameters to efficiently prevent name collisions
668    let p_query_api_version = api_version;
669    let p_path_service_id = service_id;
670    let p_query_partition_id = partition_id;
671    let p_query_only_query_primaries = only_query_primaries;
672    let p_query_timeout = timeout;
673
674    let uri_str = format!(
675        "{}/Services/{serviceId}/$/GetUnplacedReplicaInformation",
676        configuration.base_path,
677        serviceId = crate::apis::urlencode(p_path_service_id)
678    );
679    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
680
681    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
682    if let Some(ref param_value) = p_query_partition_id {
683        req_builder = req_builder.query(&[("PartitionId", &param_value.to_string())]);
684    }
685    if let Some(ref param_value) = p_query_only_query_primaries {
686        req_builder = req_builder.query(&[("OnlyQueryPrimaries", &param_value.to_string())]);
687    }
688    if let Some(ref param_value) = p_query_timeout {
689        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
690    }
691    if let Some(ref user_agent) = configuration.user_agent {
692        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
693    }
694
695    let req = req_builder.build()?;
696    let resp = configuration.client.execute(req).await?;
697
698    let status = resp.status();
699    let content_type = resp
700        .headers()
701        .get("content-type")
702        .and_then(|v| v.to_str().ok())
703        .unwrap_or("application/octet-stream");
704    let content_type = super::ContentType::from(content_type);
705
706    if !status.is_client_error() && !status.is_server_error() {
707        let content = resp.text().await?;
708        match content_type {
709            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
710            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UnplacedReplicaInformation`"))),
711            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::UnplacedReplicaInformation`")))),
712        }
713    } else {
714        let content = resp.text().await?;
715        let entity: Option<GetUnplacedReplicaInformationError> =
716            serde_json::from_str(&content).ok();
717        Err(Error::ResponseError(ResponseContent {
718            status,
719            content,
720            entity,
721        }))
722    }
723}
724
725/// Reports health state of the specified Service Fabric service. The report must contain the information about the source of the health report and property on which it is reported. The report is sent to a Service Fabric gateway Service, which forwards to the health store. The report may be accepted by the gateway, but rejected by the health store after extra validation. For example, the health store may reject the report because of an invalid parameter, like a stale sequence number. To see whether the report was applied in the health store, run GetServiceHealth and check that the report appears in the HealthEvents section.
726pub async fn report_service_health(
727    configuration: &configuration::Configuration,
728    api_version: &str,
729    service_id: &str,
730    health_information: models::HealthInformation,
731    immediate: Option<bool>,
732    timeout: Option<i64>,
733) -> Result<(), Error<ReportServiceHealthError>> {
734    // add a prefix to parameters to efficiently prevent name collisions
735    let p_query_api_version = api_version;
736    let p_path_service_id = service_id;
737    let p_body_health_information = health_information;
738    let p_query_immediate = immediate;
739    let p_query_timeout = timeout;
740
741    let uri_str = format!(
742        "{}/Services/{serviceId}/$/ReportHealth",
743        configuration.base_path,
744        serviceId = crate::apis::urlencode(p_path_service_id)
745    );
746    let mut req_builder = configuration
747        .client
748        .request(reqwest::Method::POST, &uri_str);
749
750    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
751    if let Some(ref param_value) = p_query_immediate {
752        req_builder = req_builder.query(&[("Immediate", &param_value.to_string())]);
753    }
754    if let Some(ref param_value) = p_query_timeout {
755        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
756    }
757    if let Some(ref user_agent) = configuration.user_agent {
758        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
759    }
760    req_builder = req_builder.json(&p_body_health_information);
761
762    let req = req_builder.build()?;
763    let resp = configuration.client.execute(req).await?;
764
765    let status = resp.status();
766
767    if !status.is_client_error() && !status.is_server_error() {
768        Ok(())
769    } else {
770        let content = resp.text().await?;
771        let entity: Option<ReportServiceHealthError> = serde_json::from_str(&content).ok();
772        Err(Error::ResponseError(ResponseContent {
773            status,
774            content,
775            entity,
776        }))
777    }
778}
779
780/// Resolve a Service Fabric service partition to get the endpoints of the service replicas.
781pub async fn resolve_service(
782    configuration: &configuration::Configuration,
783    api_version: &str,
784    service_id: &str,
785    partition_key_type: Option<i32>,
786    partition_key_value: Option<&str>,
787    previous_rsp_version: Option<&str>,
788    timeout: Option<i64>,
789) -> Result<models::ResolvedServicePartition, Error<ResolveServiceError>> {
790    // add a prefix to parameters to efficiently prevent name collisions
791    let p_query_api_version = api_version;
792    let p_path_service_id = service_id;
793    let p_query_partition_key_type = partition_key_type;
794    let p_query_partition_key_value = partition_key_value;
795    let p_query_previous_rsp_version = previous_rsp_version;
796    let p_query_timeout = timeout;
797
798    let uri_str = format!(
799        "{}/Services/{serviceId}/$/ResolvePartition",
800        configuration.base_path,
801        serviceId = crate::apis::urlencode(p_path_service_id)
802    );
803    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
804
805    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
806    if let Some(ref param_value) = p_query_partition_key_type {
807        req_builder = req_builder.query(&[("PartitionKeyType", &param_value.to_string())]);
808    }
809    if let Some(ref param_value) = p_query_partition_key_value {
810        req_builder = req_builder.query(&[("PartitionKeyValue", &param_value.to_string())]);
811    }
812    if let Some(ref param_value) = p_query_previous_rsp_version {
813        req_builder = req_builder.query(&[("PreviousRspVersion", &param_value.to_string())]);
814    }
815    if let Some(ref param_value) = p_query_timeout {
816        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
817    }
818    if let Some(ref user_agent) = configuration.user_agent {
819        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
820    }
821
822    let req = req_builder.build()?;
823    let resp = configuration.client.execute(req).await?;
824
825    let status = resp.status();
826    let content_type = resp
827        .headers()
828        .get("content-type")
829        .and_then(|v| v.to_str().ok())
830        .unwrap_or("application/octet-stream");
831    let content_type = super::ContentType::from(content_type);
832
833    if !status.is_client_error() && !status.is_server_error() {
834        let content = resp.text().await?;
835        match content_type {
836            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
837            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResolvedServicePartition`"))),
838            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::ResolvedServicePartition`")))),
839        }
840    } else {
841        let content = resp.text().await?;
842        let entity: Option<ResolveServiceError> = serde_json::from_str(&content).ok();
843        Err(Error::ResponseError(ResponseContent {
844            status,
845            content,
846            entity,
847        }))
848    }
849}
850
851/// This API allows updating properties of a running Service Fabric service. The set of properties that can be updated are a subset of the properties that were specified at the time of creating the service. The current set of properties can be obtained using `GetServiceDescription` API. Note that updating the properties of a running service is different than upgrading your application using `StartApplicationUpgrade` API. The upgrade is a long running background operation that involves moving the application from one version to another, one upgrade domain at a time, whereas update applies the new properties immediately to the service.
852pub async fn update_service(
853    configuration: &configuration::Configuration,
854    api_version: &str,
855    service_id: &str,
856    service_update_description: models::ServiceUpdateDescription,
857    timeout: Option<i64>,
858) -> Result<(), Error<UpdateServiceError>> {
859    // add a prefix to parameters to efficiently prevent name collisions
860    let p_query_api_version = api_version;
861    let p_path_service_id = service_id;
862    let p_body_service_update_description = service_update_description;
863    let p_query_timeout = timeout;
864
865    let uri_str = format!(
866        "{}/Services/{serviceId}/$/Update",
867        configuration.base_path,
868        serviceId = crate::apis::urlencode(p_path_service_id)
869    );
870    let mut req_builder = configuration
871        .client
872        .request(reqwest::Method::POST, &uri_str);
873
874    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
875    if let Some(ref param_value) = p_query_timeout {
876        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
877    }
878    if let Some(ref user_agent) = configuration.user_agent {
879        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
880    }
881    req_builder = req_builder.json(&p_body_service_update_description);
882
883    let req = req_builder.build()?;
884    let resp = configuration.client.execute(req).await?;
885
886    let status = resp.status();
887
888    if !status.is_client_error() && !status.is_server_error() {
889        Ok(())
890    } else {
891        let content = resp.text().await?;
892        let entity: Option<UpdateServiceError> = serde_json::from_str(&content).ok();
893        Err(Error::ResponseError(ResponseContent {
894            status,
895            content,
896            entity,
897        }))
898    }
899}