Skip to main content

openapi_service_fabric/apis/
image_store_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 [`commit_image_store_upload_session`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CommitImageStoreUploadSessionError {
20    DefaultResponse(models::FabricError),
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`copy_image_store_content`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum CopyImageStoreContentError {
28    DefaultResponse(models::FabricError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`delete_image_store_content`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteImageStoreContentError {
36    DefaultResponse(models::FabricError),
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`delete_image_store_upload_session`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum DeleteImageStoreUploadSessionError {
44    DefaultResponse(models::FabricError),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`get_image_store_content`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetImageStoreContentError {
52    DefaultResponse(models::FabricError),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method [`get_image_store_folder_size`]
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum GetImageStoreFolderSizeError {
60    DefaultResponse(models::FabricError),
61    UnknownValue(serde_json::Value),
62}
63
64/// struct for typed errors of method [`get_image_store_info`]
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum GetImageStoreInfoError {
68    DefaultResponse(models::FabricError),
69    UnknownValue(serde_json::Value),
70}
71
72/// struct for typed errors of method [`get_image_store_root_content`]
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum GetImageStoreRootContentError {
76    DefaultResponse(models::FabricError),
77    UnknownValue(serde_json::Value),
78}
79
80/// struct for typed errors of method [`get_image_store_root_folder_size`]
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum GetImageStoreRootFolderSizeError {
84    DefaultResponse(models::FabricError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`get_image_store_upload_session_by_id`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetImageStoreUploadSessionByIdError {
92    DefaultResponse(models::FabricError),
93    UnknownValue(serde_json::Value),
94}
95
96/// struct for typed errors of method [`get_image_store_upload_session_by_path`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum GetImageStoreUploadSessionByPathError {
100    DefaultResponse(models::FabricError),
101    UnknownValue(serde_json::Value),
102}
103
104/// struct for typed errors of method [`upload_file`]
105#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum UploadFileError {
108    DefaultResponse(models::FabricError),
109    UnknownValue(serde_json::Value),
110}
111
112/// struct for typed errors of method [`upload_file_chunk`]
113#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum UploadFileChunkError {
116    DefaultResponse(models::FabricError),
117    UnknownValue(serde_json::Value),
118}
119
120/// When all file chunks have been uploaded, the upload session needs to be committed explicitly to complete the upload. Image store preserves the upload session until the expiration time, which is 30 minutes after the last chunk received.
121pub async fn commit_image_store_upload_session(
122    configuration: &configuration::Configuration,
123    api_version: &str,
124    session_id: &str,
125    timeout: Option<i64>,
126) -> Result<(), Error<CommitImageStoreUploadSessionError>> {
127    // add a prefix to parameters to efficiently prevent name collisions
128    let p_query_api_version = api_version;
129    let p_query_session_id = session_id;
130    let p_query_timeout = timeout;
131
132    let uri_str = format!(
133        "{}/ImageStore/$/CommitUploadSession",
134        configuration.base_path
135    );
136    let mut req_builder = configuration
137        .client
138        .request(reqwest::Method::POST, &uri_str);
139
140    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
141    req_builder = req_builder.query(&[("session-id", &p_query_session_id.to_string())]);
142    if let Some(ref param_value) = p_query_timeout {
143        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
144    }
145    if let Some(ref user_agent) = configuration.user_agent {
146        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
147    }
148
149    let req = req_builder.build()?;
150    let resp = configuration.client.execute(req).await?;
151
152    let status = resp.status();
153
154    if !status.is_client_error() && !status.is_server_error() {
155        Ok(())
156    } else {
157        let content = resp.text().await?;
158        let entity: Option<CommitImageStoreUploadSessionError> =
159            serde_json::from_str(&content).ok();
160        Err(Error::ResponseError(ResponseContent {
161            status,
162            content,
163            entity,
164        }))
165    }
166}
167
168/// Copies the image store content from the source image store relative path to the destination image store relative path.
169pub async fn copy_image_store_content(
170    configuration: &configuration::Configuration,
171    api_version: &str,
172    image_store_copy_description: models::ImageStoreCopyDescription,
173    timeout: Option<i64>,
174) -> Result<(), Error<CopyImageStoreContentError>> {
175    // add a prefix to parameters to efficiently prevent name collisions
176    let p_query_api_version = api_version;
177    let p_body_image_store_copy_description = image_store_copy_description;
178    let p_query_timeout = timeout;
179
180    let uri_str = format!("{}/ImageStore/$/Copy", configuration.base_path);
181    let mut req_builder = configuration
182        .client
183        .request(reqwest::Method::POST, &uri_str);
184
185    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
186    if let Some(ref param_value) = p_query_timeout {
187        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
188    }
189    if let Some(ref user_agent) = configuration.user_agent {
190        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
191    }
192    req_builder = req_builder.json(&p_body_image_store_copy_description);
193
194    let req = req_builder.build()?;
195    let resp = configuration.client.execute(req).await?;
196
197    let status = resp.status();
198
199    if !status.is_client_error() && !status.is_server_error() {
200        Ok(())
201    } else {
202        let content = resp.text().await?;
203        let entity: Option<CopyImageStoreContentError> = serde_json::from_str(&content).ok();
204        Err(Error::ResponseError(ResponseContent {
205            status,
206            content,
207            entity,
208        }))
209    }
210}
211
212/// Deletes existing image store content being found within the given image store relative path. This command can be used to delete uploaded application packages once they are provisioned.
213pub async fn delete_image_store_content(
214    configuration: &configuration::Configuration,
215    api_version: &str,
216    content_path: &str,
217    timeout: Option<i64>,
218) -> Result<(), Error<DeleteImageStoreContentError>> {
219    // add a prefix to parameters to efficiently prevent name collisions
220    let p_query_api_version = api_version;
221    let p_path_content_path = content_path;
222    let p_query_timeout = timeout;
223
224    let uri_str = format!(
225        "{}/ImageStore/{contentPath}",
226        configuration.base_path,
227        contentPath = crate::apis::urlencode(p_path_content_path)
228    );
229    let mut req_builder = configuration
230        .client
231        .request(reqwest::Method::DELETE, &uri_str);
232
233    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
234    if let Some(ref param_value) = p_query_timeout {
235        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
236    }
237    if let Some(ref user_agent) = configuration.user_agent {
238        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
239    }
240
241    let req = req_builder.build()?;
242    let resp = configuration.client.execute(req).await?;
243
244    let status = resp.status();
245
246    if !status.is_client_error() && !status.is_server_error() {
247        Ok(())
248    } else {
249        let content = resp.text().await?;
250        let entity: Option<DeleteImageStoreContentError> = serde_json::from_str(&content).ok();
251        Err(Error::ResponseError(ResponseContent {
252            status,
253            content,
254            entity,
255        }))
256    }
257}
258
259/// The DELETE request will cause the existing upload session to expire and remove any previously uploaded file chunks.
260pub async fn delete_image_store_upload_session(
261    configuration: &configuration::Configuration,
262    api_version: &str,
263    session_id: &str,
264    timeout: Option<i64>,
265) -> Result<(), Error<DeleteImageStoreUploadSessionError>> {
266    // add a prefix to parameters to efficiently prevent name collisions
267    let p_query_api_version = api_version;
268    let p_query_session_id = session_id;
269    let p_query_timeout = timeout;
270
271    let uri_str = format!(
272        "{}/ImageStore/$/DeleteUploadSession",
273        configuration.base_path
274    );
275    let mut req_builder = configuration
276        .client
277        .request(reqwest::Method::DELETE, &uri_str);
278
279    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
280    req_builder = req_builder.query(&[("session-id", &p_query_session_id.to_string())]);
281    if let Some(ref param_value) = p_query_timeout {
282        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
283    }
284    if let Some(ref user_agent) = configuration.user_agent {
285        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
286    }
287
288    let req = req_builder.build()?;
289    let resp = configuration.client.execute(req).await?;
290
291    let status = resp.status();
292
293    if !status.is_client_error() && !status.is_server_error() {
294        Ok(())
295    } else {
296        let content = resp.text().await?;
297        let entity: Option<DeleteImageStoreUploadSessionError> =
298            serde_json::from_str(&content).ok();
299        Err(Error::ResponseError(ResponseContent {
300            status,
301            content,
302            entity,
303        }))
304    }
305}
306
307/// Returns the information about the image store content at the specified contentPath. The contentPath is relative to the root of the image store.
308pub async fn get_image_store_content(
309    configuration: &configuration::Configuration,
310    api_version: &str,
311    content_path: &str,
312    timeout: Option<i64>,
313) -> Result<models::ImageStoreContent, Error<GetImageStoreContentError>> {
314    // add a prefix to parameters to efficiently prevent name collisions
315    let p_query_api_version = api_version;
316    let p_path_content_path = content_path;
317    let p_query_timeout = timeout;
318
319    let uri_str = format!(
320        "{}/ImageStore/{contentPath}",
321        configuration.base_path,
322        contentPath = crate::apis::urlencode(p_path_content_path)
323    );
324    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
325
326    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
327    if let Some(ref param_value) = p_query_timeout {
328        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
329    }
330    if let Some(ref user_agent) = configuration.user_agent {
331        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
332    }
333
334    let req = req_builder.build()?;
335    let resp = configuration.client.execute(req).await?;
336
337    let status = resp.status();
338    let content_type = resp
339        .headers()
340        .get("content-type")
341        .and_then(|v| v.to_str().ok())
342        .unwrap_or("application/octet-stream");
343    let content_type = super::ContentType::from(content_type);
344
345    if !status.is_client_error() && !status.is_server_error() {
346        let content = resp.text().await?;
347        match content_type {
348            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
349            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImageStoreContent`"))),
350            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::ImageStoreContent`")))),
351        }
352    } else {
353        let content = resp.text().await?;
354        let entity: Option<GetImageStoreContentError> = serde_json::from_str(&content).ok();
355        Err(Error::ResponseError(ResponseContent {
356            status,
357            content,
358            entity,
359        }))
360    }
361}
362
363/// Gets the total size of file under a image store folder, specified by contentPath. The contentPath is relative to the root of the image store.
364pub async fn get_image_store_folder_size(
365    configuration: &configuration::Configuration,
366    api_version: &str,
367    content_path: &str,
368    timeout: Option<i64>,
369) -> Result<models::FolderSizeInfo, Error<GetImageStoreFolderSizeError>> {
370    // add a prefix to parameters to efficiently prevent name collisions
371    let p_query_api_version = api_version;
372    let p_path_content_path = content_path;
373    let p_query_timeout = timeout;
374
375    let uri_str = format!(
376        "{}/ImageStore/{contentPath}/$/FolderSize",
377        configuration.base_path,
378        contentPath = crate::apis::urlencode(p_path_content_path)
379    );
380    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
381
382    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
383    if let Some(ref param_value) = p_query_timeout {
384        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
385    }
386    if let Some(ref user_agent) = configuration.user_agent {
387        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
388    }
389
390    let req = req_builder.build()?;
391    let resp = configuration.client.execute(req).await?;
392
393    let status = resp.status();
394    let content_type = resp
395        .headers()
396        .get("content-type")
397        .and_then(|v| v.to_str().ok())
398        .unwrap_or("application/octet-stream");
399    let content_type = super::ContentType::from(content_type);
400
401    if !status.is_client_error() && !status.is_server_error() {
402        let content = resp.text().await?;
403        match content_type {
404            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
405            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderSizeInfo`"))),
406            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::FolderSizeInfo`")))),
407        }
408    } else {
409        let content = resp.text().await?;
410        let entity: Option<GetImageStoreFolderSizeError> = serde_json::from_str(&content).ok();
411        Err(Error::ResponseError(ResponseContent {
412            status,
413            content,
414            entity,
415        }))
416    }
417}
418
419/// Returns information about the primary ImageStore replica, such as disk capacity and available disk space at the node it is on, and several categories of the ImageStore's file system usage.
420pub async fn get_image_store_info(
421    configuration: &configuration::Configuration,
422    api_version: &str,
423    timeout: Option<i64>,
424) -> Result<models::ImageStoreInfo, Error<GetImageStoreInfoError>> {
425    // add a prefix to parameters to efficiently prevent name collisions
426    let p_query_api_version = api_version;
427    let p_query_timeout = timeout;
428
429    let uri_str = format!("{}/ImageStore/$/Info", configuration.base_path);
430    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
431
432    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
433    if let Some(ref param_value) = p_query_timeout {
434        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
435    }
436    if let Some(ref user_agent) = configuration.user_agent {
437        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
438    }
439
440    let req = req_builder.build()?;
441    let resp = configuration.client.execute(req).await?;
442
443    let status = resp.status();
444    let content_type = resp
445        .headers()
446        .get("content-type")
447        .and_then(|v| v.to_str().ok())
448        .unwrap_or("application/octet-stream");
449    let content_type = super::ContentType::from(content_type);
450
451    if !status.is_client_error() && !status.is_server_error() {
452        let content = resp.text().await?;
453        match content_type {
454            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
455            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImageStoreInfo`"))),
456            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::ImageStoreInfo`")))),
457        }
458    } else {
459        let content = resp.text().await?;
460        let entity: Option<GetImageStoreInfoError> = serde_json::from_str(&content).ok();
461        Err(Error::ResponseError(ResponseContent {
462            status,
463            content,
464            entity,
465        }))
466    }
467}
468
469/// Returns the information about the image store content at the root of the image store.
470pub async fn get_image_store_root_content(
471    configuration: &configuration::Configuration,
472    api_version: &str,
473    timeout: Option<i64>,
474) -> Result<models::ImageStoreContent, Error<GetImageStoreRootContentError>> {
475    // add a prefix to parameters to efficiently prevent name collisions
476    let p_query_api_version = api_version;
477    let p_query_timeout = timeout;
478
479    let uri_str = format!("{}/ImageStore", configuration.base_path);
480    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
481
482    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
483    if let Some(ref param_value) = p_query_timeout {
484        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
485    }
486    if let Some(ref user_agent) = configuration.user_agent {
487        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
488    }
489
490    let req = req_builder.build()?;
491    let resp = configuration.client.execute(req).await?;
492
493    let status = resp.status();
494    let content_type = resp
495        .headers()
496        .get("content-type")
497        .and_then(|v| v.to_str().ok())
498        .unwrap_or("application/octet-stream");
499    let content_type = super::ContentType::from(content_type);
500
501    if !status.is_client_error() && !status.is_server_error() {
502        let content = resp.text().await?;
503        match content_type {
504            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
505            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImageStoreContent`"))),
506            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::ImageStoreContent`")))),
507        }
508    } else {
509        let content = resp.text().await?;
510        let entity: Option<GetImageStoreRootContentError> = serde_json::from_str(&content).ok();
511        Err(Error::ResponseError(ResponseContent {
512            status,
513            content,
514            entity,
515        }))
516    }
517}
518
519/// Returns the total size of files at the root and children folders in image store.
520pub async fn get_image_store_root_folder_size(
521    configuration: &configuration::Configuration,
522    api_version: &str,
523    timeout: Option<i64>,
524) -> Result<models::FolderSizeInfo, Error<GetImageStoreRootFolderSizeError>> {
525    // add a prefix to parameters to efficiently prevent name collisions
526    let p_query_api_version = api_version;
527    let p_query_timeout = timeout;
528
529    let uri_str = format!("{}/ImageStore/$/FolderSize", configuration.base_path);
530    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
531
532    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
533    if let Some(ref param_value) = p_query_timeout {
534        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
535    }
536    if let Some(ref user_agent) = configuration.user_agent {
537        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
538    }
539
540    let req = req_builder.build()?;
541    let resp = configuration.client.execute(req).await?;
542
543    let status = resp.status();
544    let content_type = resp
545        .headers()
546        .get("content-type")
547        .and_then(|v| v.to_str().ok())
548        .unwrap_or("application/octet-stream");
549    let content_type = super::ContentType::from(content_type);
550
551    if !status.is_client_error() && !status.is_server_error() {
552        let content = resp.text().await?;
553        match content_type {
554            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
555            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderSizeInfo`"))),
556            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::FolderSizeInfo`")))),
557        }
558    } else {
559        let content = resp.text().await?;
560        let entity: Option<GetImageStoreRootFolderSizeError> = serde_json::from_str(&content).ok();
561        Err(Error::ResponseError(ResponseContent {
562            status,
563            content,
564            entity,
565        }))
566    }
567}
568
569/// Gets the image store upload session identified by the given ID. User can query the upload session at any time during uploading.
570pub async fn get_image_store_upload_session_by_id(
571    configuration: &configuration::Configuration,
572    api_version: &str,
573    session_id: &str,
574    timeout: Option<i64>,
575) -> Result<models::UploadSession, Error<GetImageStoreUploadSessionByIdError>> {
576    // add a prefix to parameters to efficiently prevent name collisions
577    let p_query_api_version = api_version;
578    let p_query_session_id = session_id;
579    let p_query_timeout = timeout;
580
581    let uri_str = format!("{}/ImageStore/$/GetUploadSession", configuration.base_path);
582    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
583
584    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
585    req_builder = req_builder.query(&[("session-id", &p_query_session_id.to_string())]);
586    if let Some(ref param_value) = p_query_timeout {
587        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
588    }
589    if let Some(ref user_agent) = configuration.user_agent {
590        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
591    }
592
593    let req = req_builder.build()?;
594    let resp = configuration.client.execute(req).await?;
595
596    let status = resp.status();
597    let content_type = resp
598        .headers()
599        .get("content-type")
600        .and_then(|v| v.to_str().ok())
601        .unwrap_or("application/octet-stream");
602    let content_type = super::ContentType::from(content_type);
603
604    if !status.is_client_error() && !status.is_server_error() {
605        let content = resp.text().await?;
606        match content_type {
607            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
608            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UploadSession`"))),
609            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::UploadSession`")))),
610        }
611    } else {
612        let content = resp.text().await?;
613        let entity: Option<GetImageStoreUploadSessionByIdError> =
614            serde_json::from_str(&content).ok();
615        Err(Error::ResponseError(ResponseContent {
616            status,
617            content,
618            entity,
619        }))
620    }
621}
622
623/// Gets the image store upload session associated with the given image store relative path. User can query the upload session at any time during uploading.
624pub async fn get_image_store_upload_session_by_path(
625    configuration: &configuration::Configuration,
626    api_version: &str,
627    content_path: &str,
628    timeout: Option<i64>,
629) -> Result<models::UploadSession, Error<GetImageStoreUploadSessionByPathError>> {
630    // add a prefix to parameters to efficiently prevent name collisions
631    let p_query_api_version = api_version;
632    let p_path_content_path = content_path;
633    let p_query_timeout = timeout;
634
635    let uri_str = format!(
636        "{}/ImageStore/{contentPath}/$/GetUploadSession",
637        configuration.base_path,
638        contentPath = crate::apis::urlencode(p_path_content_path)
639    );
640    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
641
642    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
643    if let Some(ref param_value) = p_query_timeout {
644        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
645    }
646    if let Some(ref user_agent) = configuration.user_agent {
647        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
648    }
649
650    let req = req_builder.build()?;
651    let resp = configuration.client.execute(req).await?;
652
653    let status = resp.status();
654    let content_type = resp
655        .headers()
656        .get("content-type")
657        .and_then(|v| v.to_str().ok())
658        .unwrap_or("application/octet-stream");
659    let content_type = super::ContentType::from(content_type);
660
661    if !status.is_client_error() && !status.is_server_error() {
662        let content = resp.text().await?;
663        match content_type {
664            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
665            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UploadSession`"))),
666            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::UploadSession`")))),
667        }
668    } else {
669        let content = resp.text().await?;
670        let entity: Option<GetImageStoreUploadSessionByPathError> =
671            serde_json::from_str(&content).ok();
672        Err(Error::ResponseError(ResponseContent {
673            status,
674            content,
675            entity,
676        }))
677    }
678}
679
680/// Uploads contents of the file to the image store. Use this API if the file is small enough to upload again if the connection fails. The file's data needs to be added to the request body. The contents will be uploaded to the specified path. Image store service uses a mark file to indicate the availability of the folder. The mark file is an empty file named \"_.dir\". The mark file is generated by the image store service when all files in a folder are uploaded. When using File-by-File approach to upload application package in REST, the image store service isn't aware of the file hierarchy of the application package; you need to create a mark file per folder and upload it last, to let the image store service know that the folder is complete.
681pub async fn upload_file(
682    configuration: &configuration::Configuration,
683    api_version: &str,
684    content_path: &str,
685    timeout: Option<i64>,
686) -> Result<(), Error<UploadFileError>> {
687    // add a prefix to parameters to efficiently prevent name collisions
688    let p_query_api_version = api_version;
689    let p_path_content_path = content_path;
690    let p_query_timeout = timeout;
691
692    let uri_str = format!(
693        "{}/ImageStore/{contentPath}",
694        configuration.base_path,
695        contentPath = crate::apis::urlencode(p_path_content_path)
696    );
697    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
698
699    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
700    if let Some(ref param_value) = p_query_timeout {
701        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
702    }
703    if let Some(ref user_agent) = configuration.user_agent {
704        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
705    }
706
707    let req = req_builder.build()?;
708    let resp = configuration.client.execute(req).await?;
709
710    let status = resp.status();
711
712    if !status.is_client_error() && !status.is_server_error() {
713        Ok(())
714    } else {
715        let content = resp.text().await?;
716        let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
717        Err(Error::ResponseError(ResponseContent {
718            status,
719            content,
720            entity,
721        }))
722    }
723}
724
725/// Uploads a file chunk to the image store with the specified upload session ID and image store relative path. This API allows user to resume the file upload operation. user doesn't have to restart the file upload from scratch whenever there is a network interruption. Use this option if the file size is large.  To perform a resumable file upload, user need to break the file into multiple chunks and upload these chunks to the image store one-by-one. Chunks don't have to be uploaded in order. If the file represented by the image store relative path already exists, it will be overwritten when the upload session commits.
726pub async fn upload_file_chunk(
727    configuration: &configuration::Configuration,
728    api_version: &str,
729    content_path: &str,
730    session_id: &str,
731    content_range: &str,
732    timeout: Option<i64>,
733) -> Result<(), Error<UploadFileChunkError>> {
734    // add a prefix to parameters to efficiently prevent name collisions
735    let p_query_api_version = api_version;
736    let p_path_content_path = content_path;
737    let p_query_session_id = session_id;
738    let p_header_content_range = content_range;
739    let p_query_timeout = timeout;
740
741    let uri_str = format!(
742        "{}/ImageStore/{contentPath}/$/UploadChunk",
743        configuration.base_path,
744        contentPath = crate::apis::urlencode(p_path_content_path)
745    );
746    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
747
748    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
749    req_builder = req_builder.query(&[("session-id", &p_query_session_id.to_string())]);
750    if let Some(ref param_value) = p_query_timeout {
751        req_builder = req_builder.query(&[("timeout", &param_value.to_string())]);
752    }
753    if let Some(ref user_agent) = configuration.user_agent {
754        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
755    }
756    req_builder = req_builder.header("Content-Range", p_header_content_range.to_string());
757
758    let req = req_builder.build()?;
759    let resp = configuration.client.execute(req).await?;
760
761    let status = resp.status();
762
763    if !status.is_client_error() && !status.is_server_error() {
764        Ok(())
765    } else {
766        let content = resp.text().await?;
767        let entity: Option<UploadFileChunkError> = serde_json::from_str(&content).ok();
768        Err(Error::ResponseError(ResponseContent {
769            status,
770            content,
771            entity,
772        }))
773    }
774}