1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CreateServiceError {
20 DefaultResponse(models::FabricError),
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum CreateServiceFromTemplateError {
28 DefaultResponse(models::FabricError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteServiceError {
36 DefaultResponse(models::FabricError),
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetApplicationNameInfoError {
44 DefaultResponse(models::FabricError),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetServiceDescriptionError {
52 DefaultResponse(models::FabricError),
53 UnknownValue(serde_json::Value),
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum GetServiceHealthError {
60 DefaultResponse(models::FabricError),
61 UnknownValue(serde_json::Value),
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum GetServiceHealthUsingPolicyError {
68 DefaultResponse(models::FabricError),
69 UnknownValue(serde_json::Value),
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum GetServiceInfoError {
76 DefaultResponse(models::FabricError),
77 UnknownValue(serde_json::Value),
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum GetServiceInfoListError {
84 DefaultResponse(models::FabricError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetUnplacedReplicaInformationError {
92 DefaultResponse(models::FabricError),
93 UnknownValue(serde_json::Value),
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum ReportServiceHealthError {
100 DefaultResponse(models::FabricError),
101 UnknownValue(serde_json::Value),
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum ResolveServiceError {
108 DefaultResponse(models::FabricError),
109 UnknownValue(serde_json::Value),
110}
111
112#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum UpdateServiceError {
116 DefaultResponse(models::FabricError),
117 UnknownValue(serde_json::Value),
118}
119
120pub 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 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", ¶m_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
170pub 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 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", ¶m_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
220pub 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 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", ¶m_value.to_string())]);
246 }
247 if let Some(ref param_value) = p_query_timeout {
248 req_builder = req_builder.query(&[("timeout", ¶m_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
272pub 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 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", ¶m_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
328pub 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 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", ¶m_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
384pub 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 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", ¶m_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", ¶m_value.to_string())]);
416 }
417 if let Some(ref param_value) = p_query_exclude_health_statistics {
418 req_builder = req_builder.query(&[("ExcludeHealthStatistics", ¶m_value.to_string())]);
419 }
420 if let Some(ref param_value) = p_query_timeout {
421 req_builder = req_builder.query(&[("timeout", ¶m_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
456pub 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 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", ¶m_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", ¶m_value.to_string())]);
492 }
493 if let Some(ref param_value) = p_query_exclude_health_statistics {
494 req_builder = req_builder.query(&[("ExcludeHealthStatistics", ¶m_value.to_string())]);
495 }
496 if let Some(ref param_value) = p_query_timeout {
497 req_builder = req_builder.query(&[("timeout", ¶m_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
533pub 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 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", ¶m_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
592pub 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 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", ¶m_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", ¶m_value.to_string())]);
621 }
622 if let Some(ref param_value) = p_query_timeout {
623 req_builder = req_builder.query(&[("timeout", ¶m_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
658pub 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 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", ¶m_value.to_string())]);
684 }
685 if let Some(ref param_value) = p_query_only_query_primaries {
686 req_builder = req_builder.query(&[("OnlyQueryPrimaries", ¶m_value.to_string())]);
687 }
688 if let Some(ref param_value) = p_query_timeout {
689 req_builder = req_builder.query(&[("timeout", ¶m_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
725pub 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 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", ¶m_value.to_string())]);
753 }
754 if let Some(ref param_value) = p_query_timeout {
755 req_builder = req_builder.query(&[("timeout", ¶m_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
780pub 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 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", ¶m_value.to_string())]);
808 }
809 if let Some(ref param_value) = p_query_partition_key_value {
810 req_builder = req_builder.query(&[("PartitionKeyValue", ¶m_value.to_string())]);
811 }
812 if let Some(ref param_value) = p_query_previous_rsp_version {
813 req_builder = req_builder.query(&[("PreviousRspVersion", ¶m_value.to_string())]);
814 }
815 if let Some(ref param_value) = p_query_timeout {
816 req_builder = req_builder.query(&[("timeout", ¶m_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
851pub 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 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", ¶m_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}