openapi_service_fabric/apis/
mesh_applications_api.rs1use 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 MeshApplicationCreateOrUpdateError {
20 DefaultResponse(models::FabricError),
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum MeshApplicationDeleteError {
28 DefaultResponse(models::FabricError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum MeshApplicationGetError {
36 DefaultResponse(models::FabricError),
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum MeshApplicationGetUpgradeProgressError {
44 DefaultResponse(models::FabricError),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum MeshApplicationListError {
52 DefaultResponse(models::FabricError),
53 UnknownValue(serde_json::Value),
54}
55
56pub async fn mesh_application_create_or_update(
58 configuration: &configuration::Configuration,
59 api_version: &str,
60 application_resource_name: &str,
61 application_resource_description: models::ApplicationResourceDescription,
62) -> Result<models::ApplicationResourceDescription, Error<MeshApplicationCreateOrUpdateError>> {
63 let p_query_api_version = api_version;
65 let p_path_application_resource_name = application_resource_name;
66 let p_body_application_resource_description = application_resource_description;
67
68 let uri_str = format!(
69 "{}/Resources/Applications/{applicationResourceName}",
70 configuration.base_path,
71 applicationResourceName = crate::apis::urlencode(p_path_application_resource_name)
72 );
73 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
74
75 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
76 if let Some(ref user_agent) = configuration.user_agent {
77 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
78 }
79 req_builder = req_builder.json(&p_body_application_resource_description);
80
81 let req = req_builder.build()?;
82 let resp = configuration.client.execute(req).await?;
83
84 let status = resp.status();
85 let content_type = resp
86 .headers()
87 .get("content-type")
88 .and_then(|v| v.to_str().ok())
89 .unwrap_or("application/octet-stream");
90 let content_type = super::ContentType::from(content_type);
91
92 if !status.is_client_error() && !status.is_server_error() {
93 let content = resp.text().await?;
94 match content_type {
95 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
96 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApplicationResourceDescription`"))),
97 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::ApplicationResourceDescription`")))),
98 }
99 } else {
100 let content = resp.text().await?;
101 let entity: Option<MeshApplicationCreateOrUpdateError> =
102 serde_json::from_str(&content).ok();
103 Err(Error::ResponseError(ResponseContent {
104 status,
105 content,
106 entity,
107 }))
108 }
109}
110
111pub async fn mesh_application_delete(
113 configuration: &configuration::Configuration,
114 api_version: &str,
115 application_resource_name: &str,
116) -> Result<(), Error<MeshApplicationDeleteError>> {
117 let p_query_api_version = api_version;
119 let p_path_application_resource_name = application_resource_name;
120
121 let uri_str = format!(
122 "{}/Resources/Applications/{applicationResourceName}",
123 configuration.base_path,
124 applicationResourceName = crate::apis::urlencode(p_path_application_resource_name)
125 );
126 let mut req_builder = configuration
127 .client
128 .request(reqwest::Method::DELETE, &uri_str);
129
130 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
131 if let Some(ref user_agent) = configuration.user_agent {
132 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
133 }
134
135 let req = req_builder.build()?;
136 let resp = configuration.client.execute(req).await?;
137
138 let status = resp.status();
139
140 if !status.is_client_error() && !status.is_server_error() {
141 Ok(())
142 } else {
143 let content = resp.text().await?;
144 let entity: Option<MeshApplicationDeleteError> = serde_json::from_str(&content).ok();
145 Err(Error::ResponseError(ResponseContent {
146 status,
147 content,
148 entity,
149 }))
150 }
151}
152
153pub async fn mesh_application_get(
155 configuration: &configuration::Configuration,
156 api_version: &str,
157 application_resource_name: &str,
158) -> Result<models::ApplicationResourceDescription, Error<MeshApplicationGetError>> {
159 let p_query_api_version = api_version;
161 let p_path_application_resource_name = application_resource_name;
162
163 let uri_str = format!(
164 "{}/Resources/Applications/{applicationResourceName}",
165 configuration.base_path,
166 applicationResourceName = crate::apis::urlencode(p_path_application_resource_name)
167 );
168 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
169
170 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
171 if let Some(ref user_agent) = configuration.user_agent {
172 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
173 }
174
175 let req = req_builder.build()?;
176 let resp = configuration.client.execute(req).await?;
177
178 let status = resp.status();
179 let content_type = resp
180 .headers()
181 .get("content-type")
182 .and_then(|v| v.to_str().ok())
183 .unwrap_or("application/octet-stream");
184 let content_type = super::ContentType::from(content_type);
185
186 if !status.is_client_error() && !status.is_server_error() {
187 let content = resp.text().await?;
188 match content_type {
189 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
190 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApplicationResourceDescription`"))),
191 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::ApplicationResourceDescription`")))),
192 }
193 } else {
194 let content = resp.text().await?;
195 let entity: Option<MeshApplicationGetError> = serde_json::from_str(&content).ok();
196 Err(Error::ResponseError(ResponseContent {
197 status,
198 content,
199 entity,
200 }))
201 }
202}
203
204pub async fn mesh_application_get_upgrade_progress(
206 configuration: &configuration::Configuration,
207 api_version: &str,
208 application_resource_name: &str,
209) -> Result<
210 models::ApplicationResourceUpgradeProgressInfo,
211 Error<MeshApplicationGetUpgradeProgressError>,
212> {
213 let p_query_api_version = api_version;
215 let p_path_application_resource_name = application_resource_name;
216
217 let uri_str = format!(
218 "{}/Resources/Applications/{applicationResourceName}/$/GetUpgradeProgress",
219 configuration.base_path,
220 applicationResourceName = crate::apis::urlencode(p_path_application_resource_name)
221 );
222 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
223
224 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
225 if let Some(ref user_agent) = configuration.user_agent {
226 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
227 }
228
229 let req = req_builder.build()?;
230 let resp = configuration.client.execute(req).await?;
231
232 let status = resp.status();
233 let content_type = resp
234 .headers()
235 .get("content-type")
236 .and_then(|v| v.to_str().ok())
237 .unwrap_or("application/octet-stream");
238 let content_type = super::ContentType::from(content_type);
239
240 if !status.is_client_error() && !status.is_server_error() {
241 let content = resp.text().await?;
242 match content_type {
243 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
244 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApplicationResourceUpgradeProgressInfo`"))),
245 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::ApplicationResourceUpgradeProgressInfo`")))),
246 }
247 } else {
248 let content = resp.text().await?;
249 let entity: Option<MeshApplicationGetUpgradeProgressError> =
250 serde_json::from_str(&content).ok();
251 Err(Error::ResponseError(ResponseContent {
252 status,
253 content,
254 entity,
255 }))
256 }
257}
258
259pub async fn mesh_application_list(
261 configuration: &configuration::Configuration,
262 api_version: &str,
263) -> Result<models::PagedApplicationResourceDescriptionList, Error<MeshApplicationListError>> {
264 let p_query_api_version = api_version;
266
267 let uri_str = format!("{}/Resources/Applications", configuration.base_path);
268 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
269
270 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
271 if let Some(ref user_agent) = configuration.user_agent {
272 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
273 }
274
275 let req = req_builder.build()?;
276 let resp = configuration.client.execute(req).await?;
277
278 let status = resp.status();
279 let content_type = resp
280 .headers()
281 .get("content-type")
282 .and_then(|v| v.to_str().ok())
283 .unwrap_or("application/octet-stream");
284 let content_type = super::ContentType::from(content_type);
285
286 if !status.is_client_error() && !status.is_server_error() {
287 let content = resp.text().await?;
288 match content_type {
289 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
290 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagedApplicationResourceDescriptionList`"))),
291 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::PagedApplicationResourceDescriptionList`")))),
292 }
293 } else {
294 let content = resp.text().await?;
295 let entity: Option<MeshApplicationListError> = serde_json::from_str(&content).ok();
296 Err(Error::ResponseError(ResponseContent {
297 status,
298 content,
299 entity,
300 }))
301 }
302}