backblaze_b2_client/definitions/
shared.rs

1use serde::{
2    de::{self, MapAccess, Visitor},
3    ser::SerializeMap,
4    Deserialize, Deserializer, Serialize, Serializer,
5};
6use std::{collections::HashMap, fmt};
7use strum_macros::Display;
8
9use crate::util::B2FileStream;
10
11#[derive(Debug, Display, Clone, PartialEq, Serialize, Deserialize)]
12#[serde(rename_all = "snake_case")]
13#[strum(serialize_all = "snake_case")]
14pub enum B2Endpoint {
15    B2AuthorizeAccount,
16    B2CancelLargeFile,
17    B2CopyFile,
18    B2CopyPart,
19    B2CreateBucket,
20    B2CreateKey,
21    B2DeleteBucket,
22    B2DeleteFileVersion,
23    B2DeleteKey,
24    B2DownloadFileById,
25    B2DownloadFileByName,
26    B2FinishLargeFile,
27    B2GetBucketNotificationRules,
28    B2GetDownloadAuthorization,
29    B2GetFileInfo,
30    B2GetUploadPartUrl,
31    B2GetUploadUrl,
32    B2HideFile,
33    B2ListBuckets,
34    B2ListFileNames,
35    B2ListFileVersions,
36    B2ListKeys,
37    B2ListParts,
38    B2ListUnfinishedLargeFiles,
39    B2SetBucketNotificationRules,
40    B2StartLargeFile,
41    B2UpdateBucket,
42    B2UpdateFileLegalHold,
43    B2UpdateFileRetention,
44    B2UploadFile,
45    B2UploadPart,
46}
47
48#[derive(Debug, Display, Clone, PartialEq, Serialize, Deserialize)]
49#[serde(rename_all = "camelCase")]
50pub enum B2KeyCapability {
51    ListKeys,
52    WriteKeys,
53    DeleteKeys,
54    ListBuckets,
55    ListAllBucketNames,
56    ReadBuckets,
57    WriteBuckets,
58    DeleteBuckets,
59    ReadBucketRetentions,
60    WriteBucketRetentions,
61    ReadBucketEncryption,
62    WriteBucketEncryption,
63    ListFiles,
64    ReadFiles,
65    ShareFiles,
66    WriteFiles,
67    DeleteFiles,
68    ReadFileLegalHolds,
69    WriteFileLegalHolds,
70    ReadFileRetentions,
71    WriteFileRetentions,
72    BypassGovernance,
73    ReadBucketReplications,
74    WriteBucketReplications,
75    WriteBucketNotifications,
76    ReadBucketNotifications,
77    ReadBucketLogging,
78    WriteBucketLogging,
79}
80
81#[derive(Debug, Display, Clone, PartialEq, Serialize, Deserialize)]
82#[serde(rename_all = "camelCase")]
83pub enum B2Action {
84    /// file that was uploaded to B2 Cloud Storage.
85    Upload,
86    /// large file has been started, but not finished or canceled.
87    Start,
88    /// file version marking the file as hidden, so that it will not show up in b2_list_file_names.
89    Hide,
90    /// is used to indicate a virtual folder when listing files.
91    Folder,
92}
93
94#[derive(Clone, Deserialize, Serialize, Debug)]
95#[serde(rename_all = "camelCase")]
96pub struct B2LifeCycleRules {
97    pub days_from_hiding_to_deleting: Option<u32>,
98    pub days_from_uploading_to_hiding: Option<u32>,
99    pub file_name_prefix: Box<str>,
100}
101
102// According to b2 docs https://www.backblaze.com/docs/cloud-storage-create-a-cloud-replication-rule-with-the-native-api#check-replication-status
103// these should be lower case unlike what they show in the api
104// wrong api: https://www.backblaze.com/apidocs/b2-get-file-info#:~:text=true%2C%20%22value%22%3A%20null%20%7D-,replicationstatus,-string
105#[derive(Clone, Deserialize, Debug, Serialize)]
106#[serde(rename_all = "lowercase")]
107pub enum B2ReplicationStatus {
108    Pending,
109    Completed,
110    Failed,
111    Replica,
112}
113
114// #[derive(Clone, Deserialize, Debug, Serialize)]
115// #[serde(rename_all = "camelCase")]
116// pub struct B2ServerSideEncryption {
117//     pub mode: Option<String>,
118//     pub algorithm: Option<B2ServerSideEncryptionAlgorithm>,
119// }
120
121#[derive(Clone, Debug)]
122pub enum B2ServerSideEncryption {
123    /// Disable SSC, similar to
124    Disabled,
125    SseB2 {
126        algorithm: B2ServerSideEncryptionAlgorithm,
127    },
128    SseC {
129        algorithm: B2ServerSideEncryptionAlgorithm,
130        customer_key: String,
131        customer_key_md5: String,
132    },
133}
134
135impl Serialize for B2ServerSideEncryption {
136    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
137    where
138        S: Serializer,
139    {
140        use B2ServerSideEncryption::*;
141
142        match self {
143            Disabled => {
144                let mut map = serializer.serialize_map(Some(1))?;
145                map.serialize_entry("mode", &Option::<String>::None)?;
146                map.end()
147            }
148            SseB2 { algorithm } => {
149                let mut map = serializer.serialize_map(Some(2))?;
150                map.serialize_entry("mode", "SSE-B2")?;
151                map.serialize_entry("algorithm", algorithm)?;
152                map.end()
153            }
154            SseC {
155                algorithm,
156                customer_key,
157                customer_key_md5,
158            } => {
159                let mut map = serializer.serialize_map(Some(4))?;
160                map.serialize_entry("mode", "SSE-C")?;
161                map.serialize_entry("algorithm", algorithm)?;
162                map.serialize_entry("customerKey", customer_key)?;
163                map.serialize_entry("customerKeyMd5", customer_key_md5)?;
164                map.end()
165            }
166        }
167    }
168}
169
170impl<'de> Deserialize<'de> for B2ServerSideEncryption {
171    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
172    where
173        D: Deserializer<'de>,
174    {
175        struct B2ServerSideEncryptionVisitor;
176
177        impl<'de> Visitor<'de> for B2ServerSideEncryptionVisitor {
178            type Value = B2ServerSideEncryption;
179
180            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
181                formatter.write_str("a B2ServerSideEncryption object")
182            }
183
184            fn visit_map<M>(self, mut map: M) -> Result<B2ServerSideEncryption, M::Error>
185            where
186                M: MapAccess<'de>,
187            {
188                let mut mode: Option<String> = None;
189                let mut algorithm = None;
190                let mut customer_key = None;
191                let mut customer_key_md5 = None;
192
193                while let Some(key) = map.next_key()? {
194                    match key {
195                        "mode" => mode = map.next_value()?,
196                        "algorithm" => algorithm = map.next_value()?,
197                        "customerKey" => customer_key = map.next_value()?,
198                        "customerKeyMd5" => customer_key_md5 = map.next_value()?,
199                        _ => continue,
200                    }
201                }
202
203                match mode {
204                    Some(mode_str) => match mode_str.as_str() {
205                        "SSE-B2" => {
206                            let algorithm =
207                                algorithm.ok_or_else(|| de::Error::missing_field("algorithm"))?;
208                            Ok(B2ServerSideEncryption::SseB2 { algorithm })
209                        }
210                        "SSE-C" => {
211                            let algorithm =
212                                algorithm.ok_or_else(|| de::Error::missing_field("algorithm"))?;
213                            let customer_key = customer_key
214                                .ok_or_else(|| de::Error::missing_field("customerKey"))?;
215                            let customer_key_md5 = customer_key_md5
216                                .ok_or_else(|| de::Error::missing_field("customerKeyMd5"))?;
217                            Ok(B2ServerSideEncryption::SseC {
218                                algorithm,
219                                customer_key,
220                                customer_key_md5,
221                            })
222                        }
223                        _ => Err(de::Error::unknown_variant(
224                            mode_str.as_str(),
225                            &["SSE-B2", "SSE-C"],
226                        )),
227                    },
228                    None => Ok(B2ServerSideEncryption::Disabled),
229                }
230            }
231        }
232
233        deserializer.deserialize_map(B2ServerSideEncryptionVisitor)
234    }
235}
236
237#[derive(Clone, Deserialize, Debug, Serialize)]
238#[serde(rename_all = "camelCase")]
239pub struct B2FileRetentionPeriod {
240    pub duration: u64,
241    pub unit: String,
242}
243
244pub struct B2DownloadFileContent {
245    pub file: B2FileStream,
246    pub file_details: B2FileDownloadDetails,
247    pub remaining_headers: HashMap<String, String>,
248}
249
250#[derive(Clone, Deserialize, Serialize, Debug)]
251#[serde(rename_all = "camelCase")]
252pub struct B2BucketRetention {
253    pub mode: Option<String>,
254    #[serde(skip_serializing_if = "Option::is_none")]
255    pub period: Option<B2FileRetentionPeriod>,
256}
257
258#[derive(Clone, Deserialize, Debug, Serialize)]
259#[serde(rename_all = "camelCase")]
260pub struct B2ObjectLockValue {
261    pub default_retention: B2BucketRetention,
262    pub is_file_lock_enabled: bool,
263}
264
265#[derive(Clone, Deserialize, Debug, Serialize)]
266#[serde(rename_all = "camelCase")]
267pub struct B2BucketFileRetention {
268    /// Retention mode
269    pub mode: Option<B2FileRetentionMode>,
270    /// Timestamp for time in the future, in milliseconds
271    pub retain_until_timestamp: Option<u64>,
272}
273
274#[derive(Clone, Deserialize, Debug, Serialize)]
275#[serde(rename_all = "camelCase")]
276pub struct B2ObjectLock<T> {
277    pub is_client_authorized_to_read: bool,
278    pub value: Option<T>,
279}
280
281#[derive(Clone, Deserialize, Debug, Serialize)]
282#[serde(rename_all = "camelCase")]
283pub enum B2FileAction {
284    Start,
285    Upload,
286    Hide,
287    Folder,
288}
289
290#[derive(Clone, Deserialize, Debug, Serialize)]
291#[serde(rename_all = "camelCase")]
292pub struct B2File {
293    /// The account that owns the file.
294    pub account_id: String,
295    // The B2 file action
296    pub action: B2Action,
297    /// The unique identifier of the bucket.
298    pub bucket_id: String,
299    /// The number of bytes stored in the file. Only useful when the action is ["upload"](B2Action::Upload).
300    /// Always 0 when the action is ["start"](B2Action::Start), ["hide"](B2Action::Hide), or ["folder"](B2Action::Folder).
301    pub content_length: u64,
302    /// The SHA1 of the bytes stored in the file as a 40-digit hex string.
303    /// 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).
304    pub content_sha1: Option<String>,
305    /// The MD5 of the bytes stored in the file as a 32-digit hex string.
306    /// Not all files have an MD5 checksum, so this field is optional, and set to null for files that do not have one.
307    /// Large files do not have MD5 checksums, and the value is null. The value is also null when the action is ["hide"](B2Action::Hide), or ["folder"](B2Action::Folder).
308    pub content_md5: Option<String>,
309    /// When the action is ["upload"](B2Action::Upload) or ["start"](B2Action::Start), the MIME type of the file, as specified when the file was uploaded.
310    /// For ["hide"](B2Action::Hide) action, always "application/x-bz-hide-marker". For ["folder"](B2Action::Folder) action, always null.
311    pub content_type: Option<String>,
312    /// The unique identifier for this version of this file.
313    /// Used with b2_get_file_info, b2_download_file_by_id, and b2_delete_file_version.
314    /// The value is null when for action ["folder"](B2Action::Folder).
315    pub file_id: String,
316    /// The custom information that was uploaded with the file. This is a JSON object, holding the name/value pairs that were uploaded with the file.
317    pub file_info: HashMap<String, String>,
318    /// The name of this file, which can be used with b2_download_file_by_name.
319    pub file_name: String,
320    /// The Object Lock retention settings for this file, if any.
321    /// This field is filtered based on application key capabilities; the [`readFileRetentions`](B2KeyCapability::ReadFileRetentions) capability is required to access the value.
322    /// See [Object Lock](https://www.backblaze.com/docs/cloud-storage-enable-object-lock-with-the-native-api)
323    /// for more details on response structure. This field is omitted when the action is ["hide"](B2Action::Hide), or ["folder"](B2Action::Folder).
324    pub file_retention: Option<B2ObjectLock<B2BucketFileRetention>>,
325    /// The Object Lock legal hold status for this file, if any.
326    /// This field is filtered based on application key capabilities; the [`readFileLegalHolds`](B2KeyCapability::ReadFileLegalHolds) capability is required to access the value.
327    /// See [Object Lock](https://www.backblaze.com/docs/cloud-storage-enable-object-lock-with-the-native-api)
328    /// for more details on response structure. This field is omitted when the action is ["hide"](B2Action::Hide), or ["folder"](B2Action::Folder).
329    pub legal_hold: Option<B2ObjectLock<B2FileLegalHold>>,
330    /// The Replication Status for this file, if any. This field is omitted when the file is not part of a replication rule.
331    pub replication_status: Option<B2ReplicationStatus>,
332    /// When the file is encrypted with [Server-Side Encryption](https://www.backblaze.com/docs/cloud-storage-enable-server-side-encryption-with-the-native-api),
333    /// the mode ("SSE-B2" or "SSE-C") and algorithm used to encrypt the data.
334    /// If the file is not encrypted with Server-Side Encryption, then both mode and algorithm will be null.
335    /// This field is omitted when the action is ["hide"](B2Action::Hide), or ["folder"](B2Action::Folder).
336    pub server_side_encryption: Option<B2ServerSideEncryption>,
337    /// This is a UTC time when this file was uploaded.
338    /// It is a base 10 number of milliseconds since midnight, January 1, 1970 UTC.
339    /// This fits in a 64 bit integer such as the type "long" in the programming language Java.
340    /// It is intended to be compatible with Java's time long.
341    /// For example, it can be passed directly into the java call Date.setTime(long time).
342    /// Always 0 when the action is ["folder"](B2Action::Folder).
343    pub upload_timestamp: u64,
344}
345
346#[derive(Clone, Deserialize, Serialize, Debug)]
347pub enum B2ServerSideEncryptionAlgorithm {
348    AES256,
349}
350
351#[derive(Clone, Deserialize, Serialize, Debug)]
352#[serde(rename_all = "camelCase")]
353pub enum B2FileRetentionMode {
354    Governance,
355    Compliance,
356}
357
358#[derive(Clone, Serialize, Debug, Deserialize)]
359#[serde(rename_all = "camelCase")]
360pub enum B2FileLegalHold {
361    On,
362    Off,
363}
364
365#[derive(Clone, Serialize, Debug, Deserialize)]
366#[serde(rename_all = "camelCase")]
367pub enum B2BucketType {
368    /// Anybody can download the files is the bucket
369    AllPublic,
370    /// You need an authorization token to download the files is the bucket
371    AllPrivate,
372    Restricted,
373    /// Private bucket containing snapshots created in the Backblaze web UI
374    Snapshot,
375    Shared,
376}
377
378#[derive(Clone, Serialize, Debug, Deserialize)]
379#[serde(rename_all = "camelCase")]
380pub enum B2BucketTypeUpdate {
381    /// Anybody can download the files is the bucket
382    AllPublic,
383    /// You need an authorization token to download the files is the bucket
384    AllPrivate,
385}
386
387#[derive(Clone, Serialize, Debug, Deserialize)]
388#[serde(rename_all = "camelCase")]
389pub struct B2CorsRule {
390    pub cors_rule_name: String,
391    pub allowed_origins: Vec<String>,
392    pub allowed_operations: Vec<B2Endpoint>,
393    pub expose_headers: Vec<String>,
394    pub max_age_seconds: u32,
395}
396
397#[derive(Clone, Serialize, Debug, Deserialize)]
398#[serde(rename_all = "camelCase")]
399pub struct B2ReplicationRule {
400    pub destination_bucket_id: String,
401    pub file_name_prefix: String,
402    pub include_existing_files: bool,
403    pub is_enabled: bool,
404    pub priority: u16,
405    pub replication_rule_name: String,
406}
407
408#[derive(Clone, Serialize, Debug, Deserialize)]
409#[serde(rename_all = "camelCase")]
410pub enum B2ReplicationConfig {
411    #[serde(rename_all = "camelCase")]
412    AsReplicationSource {
413        replication_rules: Vec<B2ReplicationRule>,
414        source_application_key_id: String,
415    },
416    #[serde(rename_all = "camelCase")]
417    AsReplicationDestination {
418        source_application_key_id: HashMap<String, String>,
419    },
420}
421
422#[derive(Clone, Serialize, Debug, Deserialize)]
423#[serde(rename_all = "camelCase")]
424/// At least one of the two keys must be set
425pub enum B2BucketOption {
426    S3,
427    #[serde(untagged)]
428    Unknown(String),
429}
430
431#[derive(Clone, Serialize, Debug, Deserialize)]
432/// References https://www.backblaze.com/docs/cloud-storage-event-notifications-reference-guide#:~:text=for%20more%20details.-,event%20types,-Backblaze%20B2%20currently
433pub enum B2EventNotificationEventType {
434    /// A new object that is uploaded to Backblaze B2 that is not copied or replicated. This does not include multipart objects.
435    /// <br> Resolves to `b2:ObjectCreated:Upload`
436    #[serde(rename = "b2:ObjectCreated:Upload")]
437    ObjectCreatedUpload,
438    /// A multipart object that was completed in Backblaze B2 that was not replicated.
439    /// <br> Resolves to `b2:ObjectCreated:MultipartUpload`
440    #[serde(rename = "b2:ObjectCreated:MultipartUpload")]
441    ObjectCreatedMultipartUpload,
442    /// A copied object in Backblaze B2.
443    /// <br> Resolves to `b2:ObjectCreated:Copy`
444    #[serde(rename = "b2:ObjectCreated:Copy")]
445    ObjectCreatedCopy,
446    /// An object that was replicated in Backblaze B2. This does not include multipart objects. This is the replicated object, and not the source object.
447    /// <br> Resolves to `b2:ObjectCreated:Replica`
448    #[serde(rename = "b2:ObjectCreated:Replica")]
449    ObjectCreatedReplica,
450    /// A multipart object that was replicated in Backblaze B2. This is the replicated object, and not the source object.
451    /// <br> Resolves to `b2:ObjectCreated:MultipartReplica`
452    #[serde(rename = "b2:ObjectCreated:MultipartReplica")]
453    ObjectMultipartReplica,
454    /// Listens to all object creation events.
455    /// <br> Resolves to `b2:ObjectCreated:*`
456    #[serde(rename = "b2:ObjectCreated:*")]
457    ObjectCreatedAll,
458    /// An object that was deleted by user action, such as with an API call or by using the Backblaze web console.
459    /// <br> Resolves to `b2:ObjectDeleted:Delete`
460    #[serde(rename = "b2:ObjectDeleted:Delete")]
461    ObjectDeleted,
462    /// An object that was deleted by a Lifecycle Rule.
463    /// <br> Resolves to `b2:ObjectDeleted:LifecycleRule`
464    #[serde(rename = "b2:ObjectDeleted:LifecycleRule")]
465    ObjectDeletedLifecycle,
466    /// Listens to all object deletion events.
467    /// <br> Resolves to `b2:ObjectCreated:*`
468    #[serde(rename = "b2:ObjectDeleted:*")]
469    ObjectDeletedAll,
470    /// A hide marker that was created by user action, such as with an API call.
471    /// <br> Resolves to `b2:HideMarkerCreated:Hide`
472    #[serde(rename = "b2:HideMarkerCreated:Hide")]
473    HideMarkerCreated,
474    /// A hide marker that was created by a Lifecycle Rule.
475    /// <br> Resolves to `b2:ObjectCreated:*`
476    #[serde(rename = "b2:HideMarkerCreated:LifecycleRule")]
477    HideMarkerCreatedLifeCycle,
478    /// Listens to all object hide marker creation events.
479    /// <br> Resolves to `b2:HideMarkerCreated:*`
480    #[serde(rename = "b2:HideMarkerCreated:*")]
481    HideMarkerAll,
482    /// A multipart upload that was started from the S3-Compatible API with Live Read enabled.
483    /// <br> Resolves to `b2:MultipartUploadCreated:LiveRead`
484    #[serde(rename = "b2:MultipartUploadCreated:LiveRead")]
485    MultiPartUploadCreatedLiveRead,
486    /// Listens to all object hide marker creation events.
487    /// <br> Resolves to `b2:MultipartUploadCreated:*`
488    #[serde(rename = "b2:MultipartUploadCreated:*")]
489    MultiPartUploadCreatedAll,
490}
491
492#[derive(Clone, Serialize, Debug, Deserialize)]
493#[serde(rename_all = "camelCase")]
494pub enum B2EventNotificationTargetType {
495    Webhook,
496}
497
498#[derive(Clone, Serialize, Debug, Deserialize)]
499#[serde(rename_all = "camelCase")]
500pub struct B2EventNotificationRule {
501    /// The list of event types for the event notification rule.
502    pub event_types: Vec<B2EventNotificationEventType>,
503    /// Whether the event notification rule is enabled.
504    pub is_enabled: bool,
505    /// A name for the event notification rule. The name must be unique among the bucket's notification rules.
506    pub name: String,
507    /// Specifies which object(s) in the bucket the event notification rule applies to.
508    pub object_name_prefix: String,
509    /// Whether the event notification rule is suspended.
510    pub is_suspended: Option<bool>,
511    /// Represents the maximum number of events a user will receive per webhook invocation. The value must be a number between 1 and 50. The default value is 1.
512    pub max_events_per_batch: Option<u8>,
513    /// A brief description of why the event notification rule was suspended.
514    pub suspension_reason: Option<String>,
515    /// The target configuration for the event notification rule.
516    /// <br><br>This object will always contain the `targetType`` field. Currently, the only valid value for `targetType`` is "webhook."
517    /// <br><br>The fields for "webhook" objects are defined below. However, other `targetType`` values and collections of fields will be available in the future.
518    pub target_configuration: B2NotificationConfiguration,
519}
520
521#[derive(Clone, Serialize, Debug, Deserialize)]
522#[serde(rename_all = "camelCase")]
523pub struct B2NotificationConfiguration {
524    /// The URL for the webhook.
525    pub url: String,
526    /// The type of the target configuration, currently "webhook" only.
527    pub target_type: B2EventNotificationTargetType,
528    /// The signing secret for use in verifying the `X-Bz-Event-Notification-Signature``.
529    pub hmac_sha256_signing_secret: Option<String>,
530    /// When present, additional header name/value pairs to be sent on the webhook invocation.
531    pub custom_headers: Option<HashMap<String, String>>,
532}
533
534#[derive(Clone, Serialize, Debug, Deserialize)]
535#[serde(rename_all = "camelCase")]
536pub struct B2FilePart {
537    pub file_id: String,
538    pub part_number: u32,
539    pub content_length: u64,
540    pub content_sha1: String,
541    pub content_md5: Option<String>,
542    pub server_side_encryption: B2ServerSideEncryption,
543    pub upload_timestamp: u64,
544}
545
546#[derive(Clone, Serialize, Debug, Deserialize)]
547#[serde(rename_all = "camelCase")]
548pub struct B2AppKey {
549    /// Your account ID.
550    pub account_id: String,
551    /// The ID of the newly created key.
552    pub application_key_id: String,
553    /// The secret part of the key. Only returned when creating a new key with [b2_create_key](crate::simple_client::B2SimpleClient::create_key).
554    pub application_key: Option<String>,
555    /// When present, restricts access to one bucket.
556    pub bucket_id: Option<String>,
557    /// The list of capabilities this key has.
558    pub capabilities: Vec<B2KeyCapability>,
559    /// When present, says when this key will expire, in milliseconds since 1970.
560    pub expiration_timestamp: Option<u64>,
561    /// The name assigned when the key was created.
562    pub key_name: String,
563    /// When present, restricts access to files whose names start with the prefix.
564    pub name_prefix: Option<String>,
565    /// When present and set to s3, the key can be used to sign requests to the [S3 Compatible API](https://www.backblaze.com/apidocs/introduction-to-the-s3-compatible-api).
566    pub options: Option<Vec<B2BucketOption>>,
567}
568
569#[derive(Clone, Debug, Deserialize)]
570#[serde(rename_all = "camelCase")]
571pub struct B2Bucket {
572    /// Your account ID.
573    pub account_id: String,
574    /// The unique identifier of the bucket.
575    pub bucket_id: String,
576    /// The unique name of the bucket.
577    pub bucket_name: String,
578    /// The bucket type.
579    pub bucket_type: B2BucketType,
580    /// The user data stored with this bucket.
581    pub bucket_info: HashMap<String, String>,
582    /// The initial list of CORS rules for this bucket.
583    /// See [CORS Rules](https://www.backblaze.com/docs/cloud-storage-cross-origin-resource-sharing-rules) for an overview and the rule structure.
584    pub cors_rules: Vec<B2CorsRule>,
585    /// The Object Lock configuration for this bucket.
586    /// This field is filtered based on application key capabilities; the [`readBucketRetentions`](B2KeyCapability::ReadBucketRetentions) capability is required to access the value.
587    /// See [Object Lock](https://www.backblaze.com/docs/cloud-storage-enable-object-lock-with-the-native-api) for more details on response structure.
588    pub file_lock_configuration: B2ObjectLock<B2BucketFileRetention>,
589    /// The default bucket Server-Side Encryption settings for new files uploaded to this bucket.
590    /// This field is filtered based on application key capabilities; the [`readBucketEncryption`](B2KeyCapability::ReadBucketEncryption) capability is required to access the value.
591    /// See [ Server-Side Encryption](https://www.backblaze.com/docs/cloud-storage-enable-server-side-encryption-with-the-native-api) for more details on response structure
592    pub default_server_side_encryption: B2ServerSideEncryption,
593    /// The initial list of lifecycle rules for this bucket.
594    /// See [Lifecycle Rules](https://www.backblaze.com/docs/cloud-storage-lifecycle-rules) for an overview and the rule structure.
595    pub life_cycle_rules: Option<Vec<B2LifeCycleRules>>,
596    /// The list of replication rules for this bucket. See [Cloud Replication](https://www.backblaze.com/docs/cloud-storage-create-a-cloud-replication-rule-with-the-native-api) Rules.
597    /// <br><br> NOTE: The first time that you configure Cloud Replication, complete the following tasks to ensure that you have the correct permission:
598    /// - Verify your email address.
599    /// - Have a payment history on file or make a payment.
600    pub replication_configuration: B2ReplicationConfig,
601    /// A counter that is updated every time the bucket is modified,
602    /// and can be used with the [`ifRevisionIs`](super::bodies::B2UpdateBucketBody::if_revision_is) parameter to b2_update_bucket to prevent colliding, simultaneous updates.
603    pub revision: u32,
604    /// When present and set to s3, the bucket can be accessed through the [`S3 Compatible API`](https://www.backblaze.com/apidocs/introduction-to-the-s3-compatible-api).
605    pub options: Option<Vec<B2BucketOption>>,
606}
607
608#[derive(Clone, Debug, Deserialize, Serialize)]
609#[serde(rename_all = "camelCase")]
610pub struct B2CustomerAgnosticServerSideEncryption {
611    pub customer_key: String,
612    pub customer_key_md5: String,
613    #[serde(flatten)]
614    pub server_side_encryption: B2ServerSideEncryption,
615}
616
617#[derive(Clone, Debug, Deserialize, Serialize)]
618#[serde(rename_all = "UPPERCASE")]
619pub enum B2MetadataDirective {
620    Copy,
621}
622
623#[derive(Clone, Debug, Deserialize, Serialize)]
624#[serde(rename_all = "camelCase")]
625pub struct B2FileDownloadDetails {
626    pub content_length: u64,
627    pub content_type: String,
628    pub file_id: String,
629    pub file_name: String,
630    pub content_sha1: Option<String>,
631    pub upload_timestamp: u64,
632    pub file_info: Option<HashMap<String, String>>,
633}