1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! Uploads operations.
#![allow(
clippy::too_many_arguments,
clippy::wildcard_imports,
clippy::doc_markdown
)]
use crate::client::AccountClient;
use crate::error::Error;
use crate::generated::routes;
#[allow(unused_imports)]
use crate::generated::types::*;
use crate::pagination::Page;
/// Optional query parameters for `ListUploads`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListUploadsParams {
/// Page number for paginating through results. Defaults to 1. A positive value selects exactly that page, not a starting offset; see SPEC section 8.
pub page: Option<i32>,
}
/// `Uploads` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct UploadsService<'a> {
client: &'a AccountClient,
}
impl<'a> UploadsService<'a> {
pub(crate) fn new(client: &'a AccountClient) -> Self {
Self { client }
}
/// The client this service sends through.
pub fn client(&self) -> &'a AccountClient {
self.client
}
/// Create a new upload in a vault
///
/// `POST /vaults/{vaultId}/uploads.json` — not idempotent, sent exactly once.
pub async fn create(
&self,
vault_id: i64,
body: &CreateUploadRequestContent,
) -> Result<CreateUploadResponseContent, Error> {
let mut operation = self.client.operation(&routes::CREATE_UPLOAD, &[&vault_id]);
operation.json(body)?;
self.client.send(operation).await
}
/// Replace an upload's file with a new version
///
/// The recording keeps its id, its URL and its comments; the previous file becomes a
/// past version. Use this instead of CreateUpload when publishing a new release of the
/// same file, so its published link keeps working.
///
/// `POST /uploads/{uploadId}/versions.json` — not idempotent, sent exactly once.
pub async fn create_version(
&self,
upload_id: i64,
body: &CreateUploadVersionRequestContent,
) -> Result<CreateUploadVersionResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::CREATE_UPLOAD_VERSION, &[&upload_id]);
operation.json(body)?;
self.client.send(operation).await
}
/// Get a single upload by id
///
/// `GET /uploads/{uploadId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get(&self, upload_id: i64) -> Result<GetUploadResponseContent, Error> {
let operation = self.client.operation(&routes::GET_UPLOAD, &[&upload_id]);
self.client.send(operation).await
}
/// List uploads in a vault
///
/// **Pagination**: Uses Link header (RFC5988). Follow the `next` rel URL
/// to fetch additional pages. X-Total-Count header provides total count.
///
/// `GET /vaults/{vaultId}/uploads.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list(
&self,
vault_id: i64,
params: &ListUploadsParams,
) -> Result<Page<ListUploadsResponseContent>, Error> {
let mut operation = self.client.operation(&routes::LIST_UPLOADS, &[&vault_id]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
/// List versions of an upload
///
/// **Pagination**: Uses Link header (RFC5988). Follow the `next` rel URL
/// to fetch additional pages. X-Total-Count header provides total count.
///
/// `GET /uploads/{uploadId}/versions.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list_versions(
&self,
upload_id: i64,
) -> Result<Page<ListUploadVersionsResponseContent>, Error> {
let operation = self
.client
.operation(&routes::LIST_UPLOAD_VERSIONS, &[&upload_id]);
self.client.send_page(operation).await
}
/// Update an existing upload
///
/// `PUT /uploads/{uploadId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update(
&self,
upload_id: i64,
body: &UpdateUploadRequestContent,
) -> Result<UpdateUploadResponseContent, Error> {
let mut operation = self.client.operation(&routes::UPDATE_UPLOAD, &[&upload_id]);
operation.json(body)?;
self.client.send(operation).await
}
}