backblaze_b2_client/definitions/responses.rs
1use std::num::NonZeroU64;
2
3use serde::{Deserialize, Serialize};
4
5use super::shared::{
6 B2AppKey, B2Bucket, B2EventNotificationRule, B2File, B2BucketFileRetention, B2KeyCapability,
7 B2ServerSideEncryption,
8};
9
10#[derive(Clone, Debug, Deserialize)]
11#[serde(rename_all = "camelCase")]
12pub struct B2UpdateFileRetentionResponse {
13 /// The unique identifier for this version of this file.
14 pub file_id: String,
15 /// The name of this file.
16 pub file_name: String,
17 /// The updated file retention settings.
18 pub file_retention: B2BucketFileRetention,
19}
20
21#[derive(Clone, Debug, Deserialize)]
22#[serde(rename_all = "camelCase")]
23pub struct B2GetUploadPartUrlResponse {
24 /// The unique ID of file being uploaded.
25 pub file_id: String,
26 /// The URL that can be used to upload parts of this file, see [b2_upload_part](crate::simple_client::B2SimpleClient::upload_part).
27 pub upload_url: String,
28 /// The `authorizationToken` that must be used when uploading files with this URL.
29 /// This token is valid for 24 hours or until the `uploadUrl` endpoint rejects an upload, see [b2_upload_part](crate::simple_client::B2SimpleClient::upload_part).
30 pub authorization_token: String,
31}
32
33#[derive(Clone, Deserialize, Debug)]
34#[serde(rename_all = "camelCase")]
35pub struct B2ListFilesResponse {
36 /// The array of files
37 pub files: Vec<B2File>,
38 /// What to pass in to [`startFileName`](super::query_params::B2ListFileNamesQueryParameters::start_file_name) for the next search to continue where this one left off,
39 /// or null if there are no more files. Note this this may not be the name of an actual file, but using it is guaranteed to find the next file in the bucket.
40 pub next_file_name: Option<String>,
41}
42
43#[derive(Clone, Deserialize, Debug)]
44#[serde(rename_all = "camelCase")]
45pub struct B2GetUploadUrlResponse {
46 /// The identifier for the bucket.
47 pub bucket_id: String,
48 /// The URL that can be used to upload files to this bucket, see [b2_upload_file](crate::simple_client::B2SimpleClient::upload_file).
49 pub upload_url: String,
50 /// The `authorizationToken` that must be used when uploading files with this URL.
51 /// This token is valid for 24 hours or until the `uploadUrl` endpoint rejects an upload, see [b2_upload_file](crate::simple_client::B2SimpleClient::upload_file).
52 pub authorization_token: String,
53}
54
55#[derive(Clone, Deserialize, Debug)]
56#[serde(rename_all = "camelCase")]
57pub struct B2ListFileVersionsResponse {
58 /// Array of B2 files.
59 pub files: Vec<B2File>,
60 /// What to pass in to startFileName for the next search to continue where this one left off, or null if there are no more files.
61 /// Note this this may not be the name of an actual file, but using it is guaranteed to find the next file version in the bucket.
62 pub next_file_name: Option<String>,
63 /// What to pass in to startFileId for the next search to continue where this one left off, or null if there are no more files.
64 /// Note this this may not be the ID of an actual file, but using it is guaranteed to find the next file version in the bucket.
65 pub next_file_id: Option<String>,
66}
67
68#[derive(Clone, Deserialize, Debug)]
69#[serde(rename_all = "camelCase")]
70pub struct B2FilePart {
71 /// The file ID for uploading this file.
72 pub file_id: String,
73 /// Which part this is.
74 pub part_number: u16,
75 /// The number of bytes stored in the part.
76 pub content_length: u64,
77 /// The SHA1 of the bytes stored in the file as a 40-digit hex string.
78 /// Large files do not have SHA1 checksums, and the value is "none". The value is null when the action is ["hide"](B2Action::Hide), or ["folder"](B2Action::Folder).
79 pub content_sha1: String,
80 /// The MD5 of the bytes stored in the part. Not all parts have an MD5 checksum, so this field is optional, and set to null for parts that do not have one.
81 pub content_md5: Option<String>,
82 /// When the part is encrypted with [Server-Side Encryption](https://www.backblaze.com/docs/cloud-storage-enable-server-side-encryption-with-the-native-api),
83 /// the mode ("SSE-B2" or "SSE-C") and algorithm used to encrypt the data.
84 pub server_side_encryption: B2ServerSideEncryption,
85 /// This is a UTC time when this file was uploaded.
86 /// It is a base 10 number of milliseconds since midnight, January 1, 1970 UTC.
87 /// This fits in a 64 bit integer such as the type "long" in the programming language Java.
88 /// It is intended to be compatible with Java's time long.
89 /// For example, it can be passed directly into the java call Date.setTime(long time).
90 /// Always 0 when the action is ["folder"](B2Action::Folder).
91 pub upload_timestamp: u64,
92}
93
94#[derive(Clone, Deserialize, Debug)]
95#[serde(rename_all = "camelCase")]
96pub enum B2AuthDataApiInfoType {
97 GroupsApi,
98 StorageApi,
99 BackupApi,
100}
101
102#[derive(Clone, Deserialize, Debug)]
103#[serde(rename_all = "camelCase")]
104pub struct B2AuthDataStorageApiInfo {
105 pub absolute_minimum_part_size: NonZeroU64,
106 pub api_url: String,
107 pub bucket_id: Option<String>,
108 pub bucket_name: Option<String>,
109 pub capabilities: Vec<B2KeyCapability>,
110 pub download_url: String,
111 pub info_type: B2AuthDataApiInfoType,
112 pub name_prefix: Option<String>,
113 pub recommended_part_size: NonZeroU64,
114 pub s3_api_url: String,
115}
116
117#[derive(Clone, Deserialize, Debug)]
118#[serde(rename_all = "camelCase")]
119pub struct B2AuthDataGroupsApiInfo {
120 pub capabilities: Vec<String>,
121 pub groups_api_url: String,
122 pub info_type: B2AuthDataApiInfoType,
123}
124
125#[derive(Clone, Deserialize, Debug)]
126#[serde(rename_all = "camelCase")]
127pub struct B2AuthDataBackupApiInfo {
128 pub capabilities: Vec<String>,
129 pub backup_api_url: String,
130 pub info_type: B2AuthDataApiInfoType,
131}
132
133#[derive(Clone, Deserialize, Debug)]
134#[serde(rename_all = "camelCase")]
135pub struct B2AuthDataApiInfo {
136 // pub groups_api: B2AuthDataGroupsApiInfo,
137 /// A data structure that contains the information you need for the B2 Native API.
138 pub storage_api: B2AuthDataStorageApiInfo,
139 // pub backup_api: B2AuthDataBackupApiInfo,
140}
141
142#[derive(Clone, Deserialize, Debug)]
143#[serde(rename_all = "camelCase")]
144pub struct B2AuthData {
145 /// The identifier for the account.
146 pub account_id: String,
147 /// A data structure that groups the information you need by API suite.
148 pub api_info: B2AuthDataApiInfo,
149 /// An authorization token to use with all calls, other than b2_authorize_account, that need an Authorization header. This authorization token is valid for at most 24 hours.
150 pub authorization_token: String,
151 /// Expiration timestamp for the application key.
152 pub application_key_expiration_timestamp: Option<u64>,
153}
154
155#[derive(Clone, Deserialize, Debug)]
156#[serde(rename_all = "camelCase")]
157pub struct B2ListUnfinishedLargeFilesResponse {
158 /// An array of objects, each one describing one unfinished file.
159 pub files: Vec<B2File>,
160 /// What to pass in to [`startFileId`](super::query_params::B2ListUnfinishedLargeFilesQueryParameters::start_file_id) for the next search to continue where this one left off, or null if there are no more files.
161 /// Note this this may not be the ID of an actual upload, but using it is guaranteed to find the next upload.
162 pub next_file_id: Option<String>,
163}
164
165#[derive(Clone, Deserialize, Debug)]
166#[serde(rename_all = "camelCase")]
167pub struct B2ListPartsResponse {
168 /// What to pass in to [`startPartNumber`](super::query_params::B2ListPartsQueryParameters::start_part_number)
169 /// for the next search to continue where this one left off, or null if there are no more files.
170 /// Note this this may not be the number of an actual part, but using it is guaranteed to find the next file in the bucket.
171 pub next_part_number: Vec<u32>,
172 /// Array of B2 file parts
173 pub parts: Option<B2FilePart>,
174}
175
176#[derive(Clone, Deserialize, Debug)]
177#[serde(rename_all = "camelCase")]
178pub struct B2ListKeysResponse {
179 /// An array of keys.
180 pub keys: Vec<B2AppKey>,
181 /// Set if there are more keys beyond the ones that were returned. Pass this value the startApplicationKeyId in the next query to continue listing keys.
182 /// <br>Note that this value may not be a valid application key ID, but can still be used as the starting point for the next query.
183 pub next_application_key_id: Option<String>,
184}
185
186#[derive(Clone, Debug, Deserialize)]
187#[serde(rename_all = "camelCase")]
188pub struct B2ListBucketsResponse {
189 pub buckets: Vec<B2Bucket>,
190}
191
192#[derive(Clone, Debug, Deserialize)]
193#[serde(rename_all = "camelCase")]
194pub struct B2GetDownloadAuthorizationBodyResponse {
195 /// The identifier for the bucket.
196 pub bucket_id: String,
197 /// The prefix for files the authorization token will allow [b2_download_file_by_name](crate::simple_client::B2SimpleClient::download_file_by_name) to access.
198 pub file_name_prefix: String,
199 /// The authorization token that can be passed in the Authorization header or as an Authorization parameter to
200 /// [b2_download_file_by_name](crate::simple_client::B2SimpleClient::download_file_by_name) to access files beginning with the file name prefix.
201 pub authorization_token: String,
202}
203
204#[derive(Clone, Debug, Deserialize, Serialize)]
205#[serde(rename_all = "camelCase")]
206pub struct B2BucketNotificationRulesResponseBody {
207 /// The unique identifier for the bucket containing the event notification rules.
208 pub bucket_id: String,
209 /// An array containing event notification rules.
210 /// <br><br>The event notification rules in this array replace the bucket’s existing rules.
211 pub event_notification_rules: Vec<B2EventNotificationRule>,
212}
213
214#[derive(Clone, Debug, Deserialize)]
215#[serde(rename_all = "camelCase")]
216pub struct B2DeleteFileVersionResponse {
217 /// The unique ID of the file version that was deleted.
218 pub file_id: String,
219 /// The name of the file.
220 pub file_name: String,
221}
222
223#[derive(Clone, Debug, Deserialize)]
224#[serde(rename_all = "camelCase")]
225pub struct B2CancelLargeFileResponse {
226 /// The ID of the file whose upload that was canceled.
227 pub file_id: String,
228 /// The account that the bucket is in.
229 pub account_id: String,
230 /// The unique identifier of the bucket.
231 pub bucket_id: String,
232 /// The name of the file that was canceled.
233 pub file_name: String,
234}