openapi_service_fabric/apis/
code_package_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 GetContainerLogsDeployedOnNodeError {
20 DefaultResponse(models::FabricError),
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum GetDeployedCodePackageInfoListError {
28 DefaultResponse(models::FabricError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum InvokeContainerApiError {
36 DefaultResponse(models::FabricError),
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum RestartDeployedCodePackageError {
44 DefaultResponse(models::FabricError),
45 UnknownValue(serde_json::Value),
46}
47
48pub async fn get_container_logs_deployed_on_node(
50 configuration: &configuration::Configuration,
51 api_version: &str,
52 node_name: &str,
53 application_id: &str,
54 service_manifest_name: &str,
55 code_package_name: &str,
56 tail: Option<&str>,
57 previous: Option<bool>,
58 timeout: Option<i64>,
59) -> Result<models::ContainerLogs, Error<GetContainerLogsDeployedOnNodeError>> {
60 let p_query_api_version = api_version;
62 let p_path_node_name = node_name;
63 let p_path_application_id = application_id;
64 let p_query_service_manifest_name = service_manifest_name;
65 let p_query_code_package_name = code_package_name;
66 let p_query_tail = tail;
67 let p_query_previous = previous;
68 let p_query_timeout = timeout;
69
70 let uri_str = format!(
71 "{}/Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetCodePackages/$/ContainerLogs",
72 configuration.base_path,
73 nodeName = crate::apis::urlencode(p_path_node_name),
74 applicationId = crate::apis::urlencode(p_path_application_id)
75 );
76 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
77
78 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
79 req_builder = req_builder.query(&[(
80 "ServiceManifestName",
81 &p_query_service_manifest_name.to_string(),
82 )]);
83 req_builder = req_builder.query(&[("CodePackageName", &p_query_code_package_name.to_string())]);
84 if let Some(ref param_value) = p_query_tail {
85 req_builder = req_builder.query(&[("Tail", ¶m_value.to_string())]);
86 }
87 if let Some(ref param_value) = p_query_previous {
88 req_builder = req_builder.query(&[("Previous", ¶m_value.to_string())]);
89 }
90 if let Some(ref param_value) = p_query_timeout {
91 req_builder = req_builder.query(&[("timeout", ¶m_value.to_string())]);
92 }
93 if let Some(ref user_agent) = configuration.user_agent {
94 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
95 }
96
97 let req = req_builder.build()?;
98 let resp = configuration.client.execute(req).await?;
99
100 let status = resp.status();
101 let content_type = resp
102 .headers()
103 .get("content-type")
104 .and_then(|v| v.to_str().ok())
105 .unwrap_or("application/octet-stream");
106 let content_type = super::ContentType::from(content_type);
107
108 if !status.is_client_error() && !status.is_server_error() {
109 let content = resp.text().await?;
110 match content_type {
111 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
112 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContainerLogs`"))),
113 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::ContainerLogs`")))),
114 }
115 } else {
116 let content = resp.text().await?;
117 let entity: Option<GetContainerLogsDeployedOnNodeError> =
118 serde_json::from_str(&content).ok();
119 Err(Error::ResponseError(ResponseContent {
120 status,
121 content,
122 entity,
123 }))
124 }
125}
126
127pub async fn get_deployed_code_package_info_list(
129 configuration: &configuration::Configuration,
130 api_version: &str,
131 node_name: &str,
132 application_id: &str,
133 service_manifest_name: Option<&str>,
134 code_package_name: Option<&str>,
135 timeout: Option<i64>,
136) -> Result<Vec<models::DeployedCodePackageInfo>, Error<GetDeployedCodePackageInfoListError>> {
137 let p_query_api_version = api_version;
139 let p_path_node_name = node_name;
140 let p_path_application_id = application_id;
141 let p_query_service_manifest_name = service_manifest_name;
142 let p_query_code_package_name = code_package_name;
143 let p_query_timeout = timeout;
144
145 let uri_str = format!(
146 "{}/Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetCodePackages",
147 configuration.base_path,
148 nodeName = crate::apis::urlencode(p_path_node_name),
149 applicationId = crate::apis::urlencode(p_path_application_id)
150 );
151 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
152
153 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
154 if let Some(ref param_value) = p_query_service_manifest_name {
155 req_builder = req_builder.query(&[("ServiceManifestName", ¶m_value.to_string())]);
156 }
157 if let Some(ref param_value) = p_query_code_package_name {
158 req_builder = req_builder.query(&[("CodePackageName", ¶m_value.to_string())]);
159 }
160 if let Some(ref param_value) = p_query_timeout {
161 req_builder = req_builder.query(&[("timeout", ¶m_value.to_string())]);
162 }
163 if let Some(ref user_agent) = configuration.user_agent {
164 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
165 }
166
167 let req = req_builder.build()?;
168 let resp = configuration.client.execute(req).await?;
169
170 let status = resp.status();
171 let content_type = resp
172 .headers()
173 .get("content-type")
174 .and_then(|v| v.to_str().ok())
175 .unwrap_or("application/octet-stream");
176 let content_type = super::ContentType::from(content_type);
177
178 if !status.is_client_error() && !status.is_server_error() {
179 let content = resp.text().await?;
180 match content_type {
181 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
182 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::DeployedCodePackageInfo>`"))),
183 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::DeployedCodePackageInfo>`")))),
184 }
185 } else {
186 let content = resp.text().await?;
187 let entity: Option<GetDeployedCodePackageInfoListError> =
188 serde_json::from_str(&content).ok();
189 Err(Error::ResponseError(ResponseContent {
190 status,
191 content,
192 entity,
193 }))
194 }
195}
196
197pub async fn invoke_container_api(
199 configuration: &configuration::Configuration,
200 api_version: &str,
201 node_name: &str,
202 application_id: &str,
203 service_manifest_name: &str,
204 code_package_name: &str,
205 code_package_instance_id: &str,
206 container_api_request_body: models::ContainerApiRequestBody,
207 timeout: Option<i64>,
208) -> Result<models::ContainerApiResponse, Error<InvokeContainerApiError>> {
209 let p_query_api_version = api_version;
211 let p_path_node_name = node_name;
212 let p_path_application_id = application_id;
213 let p_query_service_manifest_name = service_manifest_name;
214 let p_query_code_package_name = code_package_name;
215 let p_query_code_package_instance_id = code_package_instance_id;
216 let p_body_container_api_request_body = container_api_request_body;
217 let p_query_timeout = timeout;
218
219 let uri_str = format!(
220 "{}/Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetCodePackages/$/ContainerApi",
221 configuration.base_path,
222 nodeName = crate::apis::urlencode(p_path_node_name),
223 applicationId = crate::apis::urlencode(p_path_application_id)
224 );
225 let mut req_builder = configuration
226 .client
227 .request(reqwest::Method::POST, &uri_str);
228
229 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
230 req_builder = req_builder.query(&[(
231 "ServiceManifestName",
232 &p_query_service_manifest_name.to_string(),
233 )]);
234 req_builder = req_builder.query(&[("CodePackageName", &p_query_code_package_name.to_string())]);
235 req_builder = req_builder.query(&[(
236 "CodePackageInstanceId",
237 &p_query_code_package_instance_id.to_string(),
238 )]);
239 if let Some(ref param_value) = p_query_timeout {
240 req_builder = req_builder.query(&[("timeout", ¶m_value.to_string())]);
241 }
242 if let Some(ref user_agent) = configuration.user_agent {
243 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
244 }
245 req_builder = req_builder.json(&p_body_container_api_request_body);
246
247 let req = req_builder.build()?;
248 let resp = configuration.client.execute(req).await?;
249
250 let status = resp.status();
251 let content_type = resp
252 .headers()
253 .get("content-type")
254 .and_then(|v| v.to_str().ok())
255 .unwrap_or("application/octet-stream");
256 let content_type = super::ContentType::from(content_type);
257
258 if !status.is_client_error() && !status.is_server_error() {
259 let content = resp.text().await?;
260 match content_type {
261 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
262 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContainerApiResponse`"))),
263 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::ContainerApiResponse`")))),
264 }
265 } else {
266 let content = resp.text().await?;
267 let entity: Option<InvokeContainerApiError> = serde_json::from_str(&content).ok();
268 Err(Error::ResponseError(ResponseContent {
269 status,
270 content,
271 entity,
272 }))
273 }
274}
275
276pub async fn restart_deployed_code_package(
278 configuration: &configuration::Configuration,
279 api_version: &str,
280 node_name: &str,
281 application_id: &str,
282 restart_deployed_code_package_description: models::RestartDeployedCodePackageDescription,
283 timeout: Option<i64>,
284) -> Result<(), Error<RestartDeployedCodePackageError>> {
285 let p_query_api_version = api_version;
287 let p_path_node_name = node_name;
288 let p_path_application_id = application_id;
289 let p_body_restart_deployed_code_package_description =
290 restart_deployed_code_package_description;
291 let p_query_timeout = timeout;
292
293 let uri_str = format!(
294 "{}/Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetCodePackages/$/Restart",
295 configuration.base_path,
296 nodeName = crate::apis::urlencode(p_path_node_name),
297 applicationId = crate::apis::urlencode(p_path_application_id)
298 );
299 let mut req_builder = configuration
300 .client
301 .request(reqwest::Method::POST, &uri_str);
302
303 req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
304 if let Some(ref param_value) = p_query_timeout {
305 req_builder = req_builder.query(&[("timeout", ¶m_value.to_string())]);
306 }
307 if let Some(ref user_agent) = configuration.user_agent {
308 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
309 }
310 req_builder = req_builder.json(&p_body_restart_deployed_code_package_description);
311
312 let req = req_builder.build()?;
313 let resp = configuration.client.execute(req).await?;
314
315 let status = resp.status();
316
317 if !status.is_client_error() && !status.is_server_error() {
318 Ok(())
319 } else {
320 let content = resp.text().await?;
321 let entity: Option<RestartDeployedCodePackageError> = serde_json::from_str(&content).ok();
322 Err(Error::ResponseError(ResponseContent {
323 status,
324 content,
325 entity,
326 }))
327 }
328}