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 DeployServicePackageToNodeError {
20 DefaultResponse(models::FabricError),
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum GetDeployedServicePackageHealthError {
28 DefaultResponse(models::FabricError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetDeployedServicePackageHealthUsingPolicyError {
36 DefaultResponse(models::FabricError),
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetDeployedServicePackageInfoListError {
44 DefaultResponse(models::FabricError),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetDeployedServicePackageInfoListByNameError {
52 DefaultResponse(models::FabricError),
53 UnknownValue(serde_json::Value),
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum ReportDeployedServicePackageHealthError {
60 DefaultResponse(models::FabricError),
61 UnknownValue(serde_json::Value),
62}
63
64pub async fn deploy_service_package_to_node(
66 configuration: &configuration::Configuration,
67 api_version: &str,
68 node_name: &str,
69 deploy_service_package_to_node_description: models::DeployServicePackageToNodeDescription,
70 timeout: Option<i64>,
71) -> Result<(), Error<DeployServicePackageToNodeError>> {
72 let p_query_api_version = api_version;
74 let p_path_node_name = node_name;
75 let p_body_deploy_service_package_to_node_description =
76 deploy_service_package_to_node_description;
77 let p_query_timeout = timeout;
78
79 let uri_str = format!(
80 "{}/Nodes/{nodeName}/$/DeployServicePackage",
81 configuration.base_path,
82 nodeName = crate::apis::urlencode(p_path_node_name)
83 );
84 let mut req_builder = configuration
85 .client
86 .request(reqwest::Method::POST, &uri_str);
87
88 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
89 if let Some(ref param_value) = p_query_timeout {
90 req_builder = req_builder.query(&[("timeout", ¶m_value.to_string())]);
91 }
92 if let Some(ref user_agent) = configuration.user_agent {
93 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
94 }
95 req_builder = req_builder.json(&p_body_deploy_service_package_to_node_description);
96
97 let req = req_builder.build()?;
98 let resp = configuration.client.execute(req).await?;
99
100 let status = resp.status();
101
102 if !status.is_client_error() && !status.is_server_error() {
103 Ok(())
104 } else {
105 let content = resp.text().await?;
106 let entity: Option<DeployServicePackageToNodeError> = serde_json::from_str(&content).ok();
107 Err(Error::ResponseError(ResponseContent {
108 status,
109 content,
110 entity,
111 }))
112 }
113}
114
115pub async fn get_deployed_service_package_health(
117 configuration: &configuration::Configuration,
118 api_version: &str,
119 node_name: &str,
120 application_id: &str,
121 service_package_name: &str,
122 events_health_state_filter: Option<i32>,
123 timeout: Option<i64>,
124) -> Result<models::DeployedServicePackageHealth, Error<GetDeployedServicePackageHealthError>> {
125 let p_query_api_version = api_version;
127 let p_path_node_name = node_name;
128 let p_path_application_id = application_id;
129 let p_path_service_package_name = service_package_name;
130 let p_query_events_health_state_filter = events_health_state_filter;
131 let p_query_timeout = timeout;
132
133 let uri_str = format!("{}/Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetServicePackages/{servicePackageName}/$/GetHealth", configuration.base_path, nodeName=crate::apis::urlencode(p_path_node_name), applicationId=crate::apis::urlencode(p_path_application_id), servicePackageName=crate::apis::urlencode(p_path_service_package_name));
134 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
135
136 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
137 if let Some(ref param_value) = p_query_events_health_state_filter {
138 req_builder = req_builder.query(&[("EventsHealthStateFilter", ¶m_value.to_string())]);
139 }
140 if let Some(ref param_value) = p_query_timeout {
141 req_builder = req_builder.query(&[("timeout", ¶m_value.to_string())]);
142 }
143 if let Some(ref user_agent) = configuration.user_agent {
144 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
145 }
146
147 let req = req_builder.build()?;
148 let resp = configuration.client.execute(req).await?;
149
150 let status = resp.status();
151 let content_type = resp
152 .headers()
153 .get("content-type")
154 .and_then(|v| v.to_str().ok())
155 .unwrap_or("application/octet-stream");
156 let content_type = super::ContentType::from(content_type);
157
158 if !status.is_client_error() && !status.is_server_error() {
159 let content = resp.text().await?;
160 match content_type {
161 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
162 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeployedServicePackageHealth`"))),
163 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::DeployedServicePackageHealth`")))),
164 }
165 } else {
166 let content = resp.text().await?;
167 let entity: Option<GetDeployedServicePackageHealthError> =
168 serde_json::from_str(&content).ok();
169 Err(Error::ResponseError(ResponseContent {
170 status,
171 content,
172 entity,
173 }))
174 }
175}
176
177pub async fn get_deployed_service_package_health_using_policy(
179 configuration: &configuration::Configuration,
180 api_version: &str,
181 node_name: &str,
182 application_id: &str,
183 service_package_name: &str,
184 events_health_state_filter: Option<i32>,
185 timeout: Option<i64>,
186 application_health_policy: Option<models::ApplicationHealthPolicy>,
187) -> Result<
188 models::DeployedServicePackageHealth,
189 Error<GetDeployedServicePackageHealthUsingPolicyError>,
190> {
191 let p_query_api_version = api_version;
193 let p_path_node_name = node_name;
194 let p_path_application_id = application_id;
195 let p_path_service_package_name = service_package_name;
196 let p_query_events_health_state_filter = events_health_state_filter;
197 let p_query_timeout = timeout;
198 let p_body_application_health_policy = application_health_policy;
199
200 let uri_str = format!("{}/Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetServicePackages/{servicePackageName}/$/GetHealth", configuration.base_path, nodeName=crate::apis::urlencode(p_path_node_name), applicationId=crate::apis::urlencode(p_path_application_id), servicePackageName=crate::apis::urlencode(p_path_service_package_name));
201 let mut req_builder = configuration
202 .client
203 .request(reqwest::Method::POST, &uri_str);
204
205 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
206 if let Some(ref param_value) = p_query_events_health_state_filter {
207 req_builder = req_builder.query(&[("EventsHealthStateFilter", ¶m_value.to_string())]);
208 }
209 if let Some(ref param_value) = p_query_timeout {
210 req_builder = req_builder.query(&[("timeout", ¶m_value.to_string())]);
211 }
212 if let Some(ref user_agent) = configuration.user_agent {
213 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
214 }
215 req_builder = req_builder.json(&p_body_application_health_policy);
216
217 let req = req_builder.build()?;
218 let resp = configuration.client.execute(req).await?;
219
220 let status = resp.status();
221 let content_type = resp
222 .headers()
223 .get("content-type")
224 .and_then(|v| v.to_str().ok())
225 .unwrap_or("application/octet-stream");
226 let content_type = super::ContentType::from(content_type);
227
228 if !status.is_client_error() && !status.is_server_error() {
229 let content = resp.text().await?;
230 match content_type {
231 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
232 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeployedServicePackageHealth`"))),
233 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::DeployedServicePackageHealth`")))),
234 }
235 } else {
236 let content = resp.text().await?;
237 let entity: Option<GetDeployedServicePackageHealthUsingPolicyError> =
238 serde_json::from_str(&content).ok();
239 Err(Error::ResponseError(ResponseContent {
240 status,
241 content,
242 entity,
243 }))
244 }
245}
246
247pub async fn get_deployed_service_package_info_list(
249 configuration: &configuration::Configuration,
250 api_version: &str,
251 node_name: &str,
252 application_id: &str,
253 timeout: Option<i64>,
254) -> Result<Vec<models::DeployedServicePackageInfo>, Error<GetDeployedServicePackageInfoListError>>
255{
256 let p_query_api_version = api_version;
258 let p_path_node_name = node_name;
259 let p_path_application_id = application_id;
260 let p_query_timeout = timeout;
261
262 let uri_str = format!(
263 "{}/Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetServicePackages",
264 configuration.base_path,
265 nodeName = crate::apis::urlencode(p_path_node_name),
266 applicationId = crate::apis::urlencode(p_path_application_id)
267 );
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 param_value) = p_query_timeout {
272 req_builder = req_builder.query(&[("timeout", ¶m_value.to_string())]);
273 }
274 if let Some(ref user_agent) = configuration.user_agent {
275 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
276 }
277
278 let req = req_builder.build()?;
279 let resp = configuration.client.execute(req).await?;
280
281 let status = resp.status();
282 let content_type = resp
283 .headers()
284 .get("content-type")
285 .and_then(|v| v.to_str().ok())
286 .unwrap_or("application/octet-stream");
287 let content_type = super::ContentType::from(content_type);
288
289 if !status.is_client_error() && !status.is_server_error() {
290 let content = resp.text().await?;
291 match content_type {
292 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
293 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::DeployedServicePackageInfo>`"))),
294 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::DeployedServicePackageInfo>`")))),
295 }
296 } else {
297 let content = resp.text().await?;
298 let entity: Option<GetDeployedServicePackageInfoListError> =
299 serde_json::from_str(&content).ok();
300 Err(Error::ResponseError(ResponseContent {
301 status,
302 content,
303 entity,
304 }))
305 }
306}
307
308pub async fn get_deployed_service_package_info_list_by_name(
310 configuration: &configuration::Configuration,
311 api_version: &str,
312 node_name: &str,
313 application_id: &str,
314 service_package_name: &str,
315 timeout: Option<i64>,
316) -> Result<
317 Vec<models::DeployedServicePackageInfo>,
318 Error<GetDeployedServicePackageInfoListByNameError>,
319> {
320 let p_query_api_version = api_version;
322 let p_path_node_name = node_name;
323 let p_path_application_id = application_id;
324 let p_path_service_package_name = service_package_name;
325 let p_query_timeout = timeout;
326
327 let uri_str = format!("{}/Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetServicePackages/{servicePackageName}", configuration.base_path, nodeName=crate::apis::urlencode(p_path_node_name), applicationId=crate::apis::urlencode(p_path_application_id), servicePackageName=crate::apis::urlencode(p_path_service_package_name));
328 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
329
330 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
331 if let Some(ref param_value) = p_query_timeout {
332 req_builder = req_builder.query(&[("timeout", ¶m_value.to_string())]);
333 }
334 if let Some(ref user_agent) = configuration.user_agent {
335 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
336 }
337
338 let req = req_builder.build()?;
339 let resp = configuration.client.execute(req).await?;
340
341 let status = resp.status();
342 let content_type = resp
343 .headers()
344 .get("content-type")
345 .and_then(|v| v.to_str().ok())
346 .unwrap_or("application/octet-stream");
347 let content_type = super::ContentType::from(content_type);
348
349 if !status.is_client_error() && !status.is_server_error() {
350 let content = resp.text().await?;
351 match content_type {
352 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
353 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::DeployedServicePackageInfo>`"))),
354 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::DeployedServicePackageInfo>`")))),
355 }
356 } else {
357 let content = resp.text().await?;
358 let entity: Option<GetDeployedServicePackageInfoListByNameError> =
359 serde_json::from_str(&content).ok();
360 Err(Error::ResponseError(ResponseContent {
361 status,
362 content,
363 entity,
364 }))
365 }
366}
367
368pub async fn report_deployed_service_package_health(
370 configuration: &configuration::Configuration,
371 api_version: &str,
372 node_name: &str,
373 application_id: &str,
374 service_package_name: &str,
375 health_information: models::HealthInformation,
376 immediate: Option<bool>,
377 timeout: Option<i64>,
378) -> Result<(), Error<ReportDeployedServicePackageHealthError>> {
379 let p_query_api_version = api_version;
381 let p_path_node_name = node_name;
382 let p_path_application_id = application_id;
383 let p_path_service_package_name = service_package_name;
384 let p_body_health_information = health_information;
385 let p_query_immediate = immediate;
386 let p_query_timeout = timeout;
387
388 let uri_str = format!("{}/Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetServicePackages/{servicePackageName}/$/ReportHealth", configuration.base_path, nodeName=crate::apis::urlencode(p_path_node_name), applicationId=crate::apis::urlencode(p_path_application_id), servicePackageName=crate::apis::urlencode(p_path_service_package_name));
389 let mut req_builder = configuration
390 .client
391 .request(reqwest::Method::POST, &uri_str);
392
393 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
394 if let Some(ref param_value) = p_query_immediate {
395 req_builder = req_builder.query(&[("Immediate", ¶m_value.to_string())]);
396 }
397 if let Some(ref param_value) = p_query_timeout {
398 req_builder = req_builder.query(&[("timeout", ¶m_value.to_string())]);
399 }
400 if let Some(ref user_agent) = configuration.user_agent {
401 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
402 }
403 req_builder = req_builder.json(&p_body_health_information);
404
405 let req = req_builder.build()?;
406 let resp = configuration.client.execute(req).await?;
407
408 let status = resp.status();
409
410 if !status.is_client_error() && !status.is_server_error() {
411 Ok(())
412 } else {
413 let content = resp.text().await?;
414 let entity: Option<ReportDeployedServicePackageHealthError> =
415 serde_json::from_str(&content).ok();
416 Err(Error::ResponseError(ResponseContent {
417 status,
418 content,
419 entity,
420 }))
421 }
422}