Skip to main content

openapi_service_fabric/apis/
compose_deployment_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_compose_deployment`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CreateComposeDeploymentError {
20    DefaultResponse(models::FabricError),
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`get_compose_deployment_status`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum GetComposeDeploymentStatusError {
28    DefaultResponse(models::FabricError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_compose_deployment_status_list`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetComposeDeploymentStatusListError {
36    DefaultResponse(models::FabricError),
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`get_compose_deployment_upgrade_progress`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetComposeDeploymentUpgradeProgressError {
44    DefaultResponse(models::FabricError),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`remove_compose_deployment`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum RemoveComposeDeploymentError {
52    DefaultResponse(models::FabricError),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method [`start_compose_deployment_upgrade`]
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum StartComposeDeploymentUpgradeError {
60    DefaultResponse(models::FabricError),
61    UnknownValue(serde_json::Value),
62}
63
64/// struct for typed errors of method [`start_rollback_compose_deployment_upgrade`]
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum StartRollbackComposeDeploymentUpgradeError {
68    DefaultResponse(models::FabricError),
69    UnknownValue(serde_json::Value),
70}
71
72/// Compose is a file format that describes multi-container applications. This API allows deploying container based applications defined in compose format in a Service Fabric cluster. Once the deployment is created, its status can be tracked via the `GetComposeDeploymentStatus` API.
73pub async fn create_compose_deployment(
74    configuration: &configuration::Configuration,
75    api_version: &str,
76    create_compose_deployment_description: models::CreateComposeDeploymentDescription,
77    timeout: Option<i64>,
78) -> Result<(), Error<CreateComposeDeploymentError>> {
79    // add a prefix to parameters to efficiently prevent name collisions
80    let p_query_api_version = api_version;
81    let p_body_create_compose_deployment_description = create_compose_deployment_description;
82    let p_query_timeout = timeout;
83
84    let uri_str = format!("{}/ComposeDeployments/$/Create", configuration.base_path);
85    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
86
87    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
88    if let Some(ref param_value) = p_query_timeout {
89        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
90    }
91    if let Some(ref user_agent) = configuration.user_agent {
92        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
93    }
94    req_builder = req_builder.json(&p_body_create_compose_deployment_description);
95
96    let req = req_builder.build()?;
97    let resp = configuration.client.execute(req).await?;
98
99    let status = resp.status();
100
101    if !status.is_client_error() && !status.is_server_error() {
102        Ok(())
103    } else {
104        let content = resp.text().await?;
105        let entity: Option<CreateComposeDeploymentError> = serde_json::from_str(&content).ok();
106        Err(Error::ResponseError(ResponseContent {
107            status,
108            content,
109            entity,
110        }))
111    }
112}
113
114/// Returns the status of the compose deployment that was created or in the process of being created in the Service Fabric cluster and whose name matches the one specified as the parameter. The response includes the name, status, and other details about the deployment.
115pub async fn get_compose_deployment_status(
116    configuration: &configuration::Configuration,
117    api_version: &str,
118    deployment_name: &str,
119    timeout: Option<i64>,
120) -> Result<models::ComposeDeploymentStatusInfo, Error<GetComposeDeploymentStatusError>> {
121    // add a prefix to parameters to efficiently prevent name collisions
122    let p_query_api_version = api_version;
123    let p_path_deployment_name = deployment_name;
124    let p_query_timeout = timeout;
125
126    let uri_str = format!(
127        "{}/ComposeDeployments/{deploymentName}",
128        configuration.base_path,
129        deploymentName = crate::apis::urlencode(p_path_deployment_name)
130    );
131    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
132
133    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
134    if let Some(ref param_value) = p_query_timeout {
135        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
136    }
137    if let Some(ref user_agent) = configuration.user_agent {
138        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
139    }
140
141    let req = req_builder.build()?;
142    let resp = configuration.client.execute(req).await?;
143
144    let status = resp.status();
145    let content_type = resp
146        .headers()
147        .get("content-type")
148        .and_then(|v| v.to_str().ok())
149        .unwrap_or("application/octet-stream");
150    let content_type = super::ContentType::from(content_type);
151
152    if !status.is_client_error() && !status.is_server_error() {
153        let content = resp.text().await?;
154        match content_type {
155            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
156            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ComposeDeploymentStatusInfo`"))),
157            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::ComposeDeploymentStatusInfo`")))),
158        }
159    } else {
160        let content = resp.text().await?;
161        let entity: Option<GetComposeDeploymentStatusError> = serde_json::from_str(&content).ok();
162        Err(Error::ResponseError(ResponseContent {
163            status,
164            content,
165            entity,
166        }))
167    }
168}
169
170/// Gets the status about the compose deployments that were created or in the process of being created in the Service Fabric cluster. The response includes the name, status, and other details about the compose deployments. If the list of deployments do not fit in a page, one page of results is returned as well as a continuation token, which can be used to get the next page.
171pub async fn get_compose_deployment_status_list(
172    configuration: &configuration::Configuration,
173    api_version: &str,
174    continuation_token: Option<&str>,
175    max_results: Option<i64>,
176    timeout: Option<i64>,
177) -> Result<models::PagedComposeDeploymentStatusInfoList, Error<GetComposeDeploymentStatusListError>>
178{
179    // add a prefix to parameters to efficiently prevent name collisions
180    let p_query_api_version = api_version;
181    let p_query_continuation_token = continuation_token;
182    let p_query_max_results = max_results;
183    let p_query_timeout = timeout;
184
185    let uri_str = format!("{}/ComposeDeployments", configuration.base_path);
186    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
187
188    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
189    if let Some(ref param_value) = p_query_continuation_token {
190        req_builder = req_builder.query(&[("ContinuationToken", &param_value.to_string())]);
191    }
192    if let Some(ref param_value) = p_query_max_results {
193        req_builder = req_builder.query(&[("MaxResults", &param_value.to_string())]);
194    }
195    if let Some(ref param_value) = p_query_timeout {
196        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
197    }
198    if let Some(ref user_agent) = configuration.user_agent {
199        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
200    }
201
202    let req = req_builder.build()?;
203    let resp = configuration.client.execute(req).await?;
204
205    let status = resp.status();
206    let content_type = resp
207        .headers()
208        .get("content-type")
209        .and_then(|v| v.to_str().ok())
210        .unwrap_or("application/octet-stream");
211    let content_type = super::ContentType::from(content_type);
212
213    if !status.is_client_error() && !status.is_server_error() {
214        let content = resp.text().await?;
215        match content_type {
216            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
217            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagedComposeDeploymentStatusInfoList`"))),
218            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::PagedComposeDeploymentStatusInfoList`")))),
219        }
220    } else {
221        let content = resp.text().await?;
222        let entity: Option<GetComposeDeploymentStatusListError> =
223            serde_json::from_str(&content).ok();
224        Err(Error::ResponseError(ResponseContent {
225            status,
226            content,
227            entity,
228        }))
229    }
230}
231
232/// Returns the information about the state of the compose deployment upgrade along with details to aid debugging application health issues.
233pub async fn get_compose_deployment_upgrade_progress(
234    configuration: &configuration::Configuration,
235    api_version: &str,
236    deployment_name: &str,
237    timeout: Option<i64>,
238) -> Result<
239    models::ComposeDeploymentUpgradeProgressInfo,
240    Error<GetComposeDeploymentUpgradeProgressError>,
241> {
242    // add a prefix to parameters to efficiently prevent name collisions
243    let p_query_api_version = api_version;
244    let p_path_deployment_name = deployment_name;
245    let p_query_timeout = timeout;
246
247    let uri_str = format!(
248        "{}/ComposeDeployments/{deploymentName}/$/GetUpgradeProgress",
249        configuration.base_path,
250        deploymentName = crate::apis::urlencode(p_path_deployment_name)
251    );
252    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
253
254    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
255    if let Some(ref param_value) = p_query_timeout {
256        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
257    }
258    if let Some(ref user_agent) = configuration.user_agent {
259        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
260    }
261
262    let req = req_builder.build()?;
263    let resp = configuration.client.execute(req).await?;
264
265    let status = resp.status();
266    let content_type = resp
267        .headers()
268        .get("content-type")
269        .and_then(|v| v.to_str().ok())
270        .unwrap_or("application/octet-stream");
271    let content_type = super::ContentType::from(content_type);
272
273    if !status.is_client_error() && !status.is_server_error() {
274        let content = resp.text().await?;
275        match content_type {
276            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
277            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ComposeDeploymentUpgradeProgressInfo`"))),
278            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::ComposeDeploymentUpgradeProgressInfo`")))),
279        }
280    } else {
281        let content = resp.text().await?;
282        let entity: Option<GetComposeDeploymentUpgradeProgressError> =
283            serde_json::from_str(&content).ok();
284        Err(Error::ResponseError(ResponseContent {
285            status,
286            content,
287            entity,
288        }))
289    }
290}
291
292/// Deletes an existing Service Fabric compose deployment.
293pub async fn remove_compose_deployment(
294    configuration: &configuration::Configuration,
295    api_version: &str,
296    deployment_name: &str,
297    timeout: Option<i64>,
298) -> Result<(), Error<RemoveComposeDeploymentError>> {
299    // add a prefix to parameters to efficiently prevent name collisions
300    let p_query_api_version = api_version;
301    let p_path_deployment_name = deployment_name;
302    let p_query_timeout = timeout;
303
304    let uri_str = format!(
305        "{}/ComposeDeployments/{deploymentName}/$/Delete",
306        configuration.base_path,
307        deploymentName = crate::apis::urlencode(p_path_deployment_name)
308    );
309    let mut req_builder = configuration
310        .client
311        .request(reqwest::Method::POST, &uri_str);
312
313    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
314    if let Some(ref param_value) = p_query_timeout {
315        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
316    }
317    if let Some(ref user_agent) = configuration.user_agent {
318        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
319    }
320
321    let req = req_builder.build()?;
322    let resp = configuration.client.execute(req).await?;
323
324    let status = resp.status();
325
326    if !status.is_client_error() && !status.is_server_error() {
327        Ok(())
328    } else {
329        let content = resp.text().await?;
330        let entity: Option<RemoveComposeDeploymentError> = serde_json::from_str(&content).ok();
331        Err(Error::ResponseError(ResponseContent {
332            status,
333            content,
334            entity,
335        }))
336    }
337}
338
339/// Validates the supplied upgrade parameters and starts upgrading the deployment if the parameters are valid.
340pub async fn start_compose_deployment_upgrade(
341    configuration: &configuration::Configuration,
342    api_version: &str,
343    deployment_name: &str,
344    compose_deployment_upgrade_description: models::ComposeDeploymentUpgradeDescription,
345    timeout: Option<i64>,
346) -> Result<(), Error<StartComposeDeploymentUpgradeError>> {
347    // add a prefix to parameters to efficiently prevent name collisions
348    let p_query_api_version = api_version;
349    let p_path_deployment_name = deployment_name;
350    let p_body_compose_deployment_upgrade_description = compose_deployment_upgrade_description;
351    let p_query_timeout = timeout;
352
353    let uri_str = format!(
354        "{}/ComposeDeployments/{deploymentName}/$/Upgrade",
355        configuration.base_path,
356        deploymentName = crate::apis::urlencode(p_path_deployment_name)
357    );
358    let mut req_builder = configuration
359        .client
360        .request(reqwest::Method::POST, &uri_str);
361
362    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
363    if let Some(ref param_value) = p_query_timeout {
364        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
365    }
366    if let Some(ref user_agent) = configuration.user_agent {
367        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
368    }
369    req_builder = req_builder.json(&p_body_compose_deployment_upgrade_description);
370
371    let req = req_builder.build()?;
372    let resp = configuration.client.execute(req).await?;
373
374    let status = resp.status();
375
376    if !status.is_client_error() && !status.is_server_error() {
377        Ok(())
378    } else {
379        let content = resp.text().await?;
380        let entity: Option<StartComposeDeploymentUpgradeError> =
381            serde_json::from_str(&content).ok();
382        Err(Error::ResponseError(ResponseContent {
383            status,
384            content,
385            entity,
386        }))
387    }
388}
389
390/// Rollback a service fabric compose deployment upgrade.
391pub async fn start_rollback_compose_deployment_upgrade(
392    configuration: &configuration::Configuration,
393    api_version: &str,
394    deployment_name: &str,
395    timeout: Option<i64>,
396) -> Result<(), Error<StartRollbackComposeDeploymentUpgradeError>> {
397    // add a prefix to parameters to efficiently prevent name collisions
398    let p_query_api_version = api_version;
399    let p_path_deployment_name = deployment_name;
400    let p_query_timeout = timeout;
401
402    let uri_str = format!(
403        "{}/ComposeDeployments/{deploymentName}/$/RollbackUpgrade",
404        configuration.base_path,
405        deploymentName = crate::apis::urlencode(p_path_deployment_name)
406    );
407    let mut req_builder = configuration
408        .client
409        .request(reqwest::Method::POST, &uri_str);
410
411    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
412    if let Some(ref param_value) = p_query_timeout {
413        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
414    }
415    if let Some(ref user_agent) = configuration.user_agent {
416        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
417    }
418
419    let req = req_builder.build()?;
420    let resp = configuration.client.execute(req).await?;
421
422    let status = resp.status();
423
424    if !status.is_client_error() && !status.is_server_error() {
425        Ok(())
426    } else {
427        let content = resp.text().await?;
428        let entity: Option<StartRollbackComposeDeploymentUpgradeError> =
429            serde_json::from_str(&content).ok();
430        Err(Error::ResponseError(ResponseContent {
431            status,
432            content,
433            entity,
434        }))
435    }
436}