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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
//! This module implements the shares DRACOON API.
//! Documentation can be found here: <https://download.dracoon.com/api/swagger-ui/index.html?configUrl=/api/spec_v4/swagger-config#/shares>
use async_trait::async_trait;
pub use models::*;
use crate::{models::ListAllParams, DracoonClientError};
mod download;
mod models;
mod upload;
/// This trait provides all methods to manage download shares.
#[async_trait]
pub trait DownloadShares {
/// Get a list shares (download shares).
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, DownloadShares, shares::{DownloadSharesFilter, DownloadSharesSortBy}, models::{ListAllParams, SortOrder}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// // Params are optional
/// let params = ListAllParams::builder()
/// .with_filter(DownloadSharesFilter::name_contains("test"))
/// .with_sort(DownloadSharesSortBy::name(SortOrder::Desc))
/// .build();
/// // pass None if you don't want to use any params
/// let shares = dracoon.shares().get_download_shares(Some(params)).await.unwrap();
///
/// # }
/// ```
async fn get_download_shares(
&self,
params: Option<ListAllParams>,
) -> Result<DownloadSharesList, DracoonClientError>;
/// Update list shares (download shares).
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, DownloadShares, shares::{UpdateDownloadSharesBulkRequest}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let ids = vec![1, 2, 3];
/// let update = UpdateDownloadSharesBulkRequest::builder(ids)
/// .with_show_creator_name(true)
/// .build();
/// dracoon.shares().update_download_shares(update).await.unwrap();
/// # }
/// ```
async fn update_download_shares(
&self,
update: UpdateDownloadSharesBulkRequest,
) -> Result<(), DracoonClientError>;
/// Delete a list of shares (download shares).
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, DownloadShares, shares::{DeleteDownloadSharesRequest}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let ids = vec![1, 2, 3];
/// dracoon.shares().delete_download_shares(ids.into()).await.unwrap();
/// // you can also use the DeleteDownloadSharesRequest::new() method
/// let ids = vec![1, 2, 3];
/// let delete = DeleteDownloadSharesRequest::new(ids);
/// dracoon.shares().delete_download_shares(delete).await.unwrap();
/// # }
/// ```
async fn delete_download_shares(
&self,
delete: DeleteDownloadSharesRequest,
) -> Result<(), DracoonClientError>;
/// Create a download share (share a node).
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, DownloadShares, shares::{CreateDownloadShareRequest}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let share = CreateDownloadShareRequest::builder(1)
/// .with_name("test")
/// .build();
/// dracoon.shares().create_download_share(share).await.unwrap();
/// # }
/// ```
async fn create_download_share(
&self,
create: CreateDownloadShareRequest,
) -> Result<DownloadShare, DracoonClientError>;
/// Get download share
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, DownloadShares};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let file_request = dracoon.shares().get_download_share(1).await.unwrap();
/// # }
/// ```
async fn get_download_share(&self, share_id: u64) -> Result<DownloadShare, DracoonClientError>;
/// Update download share
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, DownloadShares, shares::{UpdateDownloadShareRequest}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let update = UpdateDownloadShareRequest::builder()
/// .with_name("test")
/// .build();
/// let file_request = dracoon.shares().update_download_share(123, update).await.unwrap();
/// # }
/// ```
async fn update_download_share(
&self,
share_id: u64,
update: UpdateDownloadShareRequest,
) -> Result<DownloadShare, DracoonClientError>;
/// Delete upload share
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, UploadShares};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// dracoon.shares().delete_upload_share(1).await.unwrap();
/// # }
/// ```
async fn delete_download_share(&self, share_id: u64) -> Result<(), DracoonClientError>;
/// Send download share via email
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, DownloadShares, shares::{DownloadShareLinkEmail}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let recipients = vec!["test@test.foo".to_string(), "test2@test.foo".to_string()];
/// let send_mail = DownloadShareLinkEmail::new("Test email", recipients, None);
/// dracoon.shares().send_download_share_email(123, send_mail).await.unwrap();
/// # }
/// ```
async fn send_download_share_email(
&self,
share_id: u64,
email: DownloadShareLinkEmail,
) -> Result<(), DracoonClientError>;
}
/// This trait provides all methods to manage upload shares.
#[async_trait]
pub trait UploadShares {
/// Get a list file requests (upload shares).
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, UploadShares, shares::{UploadSharesFilter, UploadSharesSortBy}, models::{ListAllParams, SortOrder}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// // Params are optional
/// let params = ListAllParams::builder()
/// .with_filter(UploadSharesFilter::name_contains("test"))
/// .with_sort(UploadSharesSortBy::name(SortOrder::Desc))
/// .build();
/// // pass None if you don't want to use any params
/// let file_requests = dracoon.shares().get_upload_shares(Some(params)).await.unwrap();
///
/// # }
/// ```
async fn get_upload_shares(
&self,
params: Option<ListAllParams>,
) -> Result<UploadSharesList, DracoonClientError>;
/// Update a list of file requests (upload shares).
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, UploadShares, shares::{UpdateUploadSharesBulkRequest}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let ids = vec![1, 2, 3];
/// let update = UpdateUploadSharesBulkRequest::builder(ids)
/// .with_max_size(1024)
/// .with_reset_max_size(true)
/// .build();
/// dracoon.shares().update_upload_shares(update).await.unwrap();
/// # }
/// ```
async fn update_upload_shares(
&self,
update: UpdateUploadSharesBulkRequest,
) -> Result<(), DracoonClientError>;
/// Delete a list of file requests (upload shares).
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, UploadShares, shares::{DeleteUploadSharesRequest}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let ids = vec![1, 2, 3];
/// dracoon.shares().delete_upload_shares(ids.into()).await.unwrap();
/// // you can also use the DeleteUploadSharesRequest::new() method
/// let ids = vec![1, 2, 3];
/// let delete = DeleteUploadSharesRequest::new(ids);
/// dracoon.shares().delete_upload_shares(delete).await.unwrap();
/// # }
/// ```
async fn delete_upload_shares(
&self,
delete: DeleteUploadSharesRequest,
) -> Result<(), DracoonClientError>;
/// Create an upload share (request files into a node).
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, UploadShares, shares::{CreateUploadShareRequest}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let share = CreateUploadShareRequest::builder(1)
/// .with_name("test")
/// .build();
/// dracoon.shares().create_upload_share(share).await.unwrap();
/// # }
/// ```
async fn create_upload_share(
&self,
create: CreateUploadShareRequest,
) -> Result<UploadShare, DracoonClientError>;
/// Get upload share
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, UploadShares};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let file_request = dracoon.shares().get_upload_share(1).await.unwrap();
/// # }
/// ```
async fn get_upload_share(
&self,
upload_share_id: u64,
) -> Result<UploadShare, DracoonClientError>;
/// Update upload share
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, UploadShares, shares::{UpdateUploadShareRequest}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let update = UpdateUploadShareRequest::builder()
/// .with_name("test")
/// .build();
/// let file_request = dracoon.shares().update_upload_share(123, update).await.unwrap();
/// # }
/// ```
async fn update_upload_share(
&self,
upload_share_id: u64,
update: UpdateUploadShareRequest,
) -> Result<UploadShare, DracoonClientError>;
/// Delete upload share
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, UploadShares};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// dracoon.shares().delete_upload_share(1).await.unwrap();
/// # }
/// ```
async fn delete_upload_share(&self, upload_share_id: u64) -> Result<(), DracoonClientError>;
/// Send upload share via email
/// ```no_run
/// # use dco3::{Dracoon, auth::OAuth2Flow, UploadShares, shares::{UploadShareLinkEmail}};
/// # #[tokio::main]
/// # async fn main() {
/// # let dracoon = Dracoon::builder()
/// # .with_base_url("https://dracoon.team")
/// # .with_client_id("client_id")
/// # .with_client_secret("client_secret")
/// # .build()
/// # .unwrap()
/// # .connect(OAuth2Flow::PasswordFlow("username".into(), "password".into()))
/// # .await
/// # .unwrap();
/// let recipients = vec!["test@test.foo".to_string(), "test2@test.foo".to_string()];
/// let send_mail = UploadShareLinkEmail::new("Test email", recipients, None);
/// dracoon.shares().send_upload_share_email(123, send_mail).await.unwrap();
/// # }
/// ```
async fn send_upload_share_email(
&self,
upload_share_id: u64,
email: UploadShareLinkEmail,
) -> Result<(), DracoonClientError>;
}