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
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! CloudFiles 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::*;
/// `CloudFiles` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct CloudFilesService<'a> {
client: &'a AccountClient,
}
impl<'a> CloudFilesService<'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
}
/// Get a single cloud file by id
///
/// `GET /cloud_files/{cloudFileId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn cloud_file(
&self,
cloud_file_id: i64,
) -> Result<GetCloudFileResponseContent, Error> {
let operation = self
.client
.operation(&routes::GET_CLOUD_FILE, &[&cloud_file_id]);
self.client.send(operation).await
}
/// Create a new cloud file in a vault.
/// `url` is validated against the selected service's patterns, so it must be a
/// real link for that service; use service "other" for anything that matches no
/// recognized service. Omitting `title` is allowed and reads back as
/// "Untitled".
///
/// `POST /buckets/{bucketId}/vaults/{vaultId}/cloud_files.json` — not idempotent, sent exactly once.
pub async fn create_cloud_file(
&self,
bucket_id: i64,
vault_id: i64,
body: &CreateCloudFileRequestContent,
) -> Result<CreateCloudFileResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::CREATE_CLOUD_FILE, &[&bucket_id, &vault_id]);
operation.json(body)?;
self.client.send(operation).await
}
/// Replace a cloud file with a new complete representation.
/// BC3 builds a brand-new CloudFile from the permitted params and swaps the
/// recordable wholesale, so the request body is the full writable state:
/// omitting `title` clears it (and the cloud file then reads back as
/// "Untitled"), and omitting `description` clears it. `url` and `service` carry
/// presence/format validations, so they are required here rather than
/// clearable — a request without them is a 422, not a silent wipe.
/// Updating a drafted cloud file also publishes it.
/// Subscribers are the exception to omission-clears: a drafted cloud file keeps
/// its current subscribers when the request addresses neither `subscriptions`
/// nor `notify`. The creator is always on the list.
/// The legacy bucket-scoped path PUT /buckets/{bucketId}/cloud_files/{id}.json
/// is also accepted by BC3; this flat spelling is the documented one.
///
/// `PUT /cloud_files/{cloudFileId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update_cloud_file(
&self,
cloud_file_id: i64,
body: &UpdateCloudFileRequestContent,
) -> Result<UpdateCloudFileResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::UPDATE_CLOUD_FILE, &[&cloud_file_id]);
operation.json(body)?;
self.client.send(operation).await
}
}