minio-rsc 0.2.6

rust for minio, api is compliant with the Amazon S3 protocol.
Documentation
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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
//! Data types

mod select_object_content;

pub use select_object_content::*;

use serde::{Deserialize, Serialize};

use crate::time::UtcTime;

#[derive(Clone, Debug, PartialEq)]
pub struct Region(pub String);

trait XmlSelf {}

macro_rules! impl_xmlself {
    ($($name:tt )*) => {
        $(
            impl XmlSelf for $name{}
        )*
    };
}

impl_xmlself!(
    CommonPrefix
    LegalHold
    VersioningConfiguration
    Retention
    CompleteMultipartUpload
    CompleteMultipartUploadResult
    InitiateMultipartUploadResult
    ListMultipartUploadsResult
    CopyPartResult
    ListPartsResult
    ListAllMyBucketsResult
    ListBucketResult
    ListVersionsResult
    ServerSideEncryptionConfiguration
    CORSConfiguration
    LocationConstraint
    PublicAccessBlockConfiguration
    AccessControlPolicy
    ReplicationConfiguration
    WebsiteConfiguration
    LifecycleConfiguration
    PolicyStatus
    AnalyticsConfiguration
);

pub trait ToXml {
    /// try get xml string
    fn to_xml(&self) -> crate::error::Result<String>;
}

impl<T: Serialize + XmlSelf> ToXml for T {
    fn to_xml(&self) -> crate::error::Result<String> {
        crate::xml::ser::to_string(&self).map_err(Into::into)
    }
}

pub trait FromXml: Sized {
    /// try from xml string
    fn from_xml(v: String) -> crate::error::Result<Self>;
}

impl<'de, T: Deserialize<'de> + XmlSelf> FromXml for T {
    fn from_xml(v: String) -> crate::error::Result<Self> {
        crate::xml::de::from_string(v).map_err(Into::into)
    }
}

impl Region {
    pub fn from<S>(region: S) -> Self
    where
        S: Into<String>,
    {
        return Self(region.into());
    }

    pub fn as_str(&self) -> &str {
        self.0.as_str()
    }
}

/// Specifies the days since the initiation of an incomplete multipart upload
/// that Amazon S3 will wait before permanently removing all parts of the upload.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct AbortIncompleteMultipartUpload {
    /// Specifies the number of days after which Amazon S3 aborts an incomplete multipart upload.
    pub days_after_initiation: i32,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct AccessControlList {
    /// Array of [Grant]
    pub grant: Vec<Grant>,
}

/// Contains the elements that set the ACL permissions for an object per grantee.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct AccessControlPolicy {
    pub access_control_list: AccessControlList,
    pub owner: Option<Owner>,
}

/// A container for information about access control for replicas.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct AccessControlTranslation {
    pub owner: String,
}

///A conjunction (logical AND) of predicates, which is used in evaluating a metrics filter.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct AnalyticsAndOperator {
    /// The prefix to use when evaluating an AND predicate:
    /// The prefix that an object must have to be included in the metrics results.
    pub prefix: Option<String>,
    /// The list of tags to use when evaluating an AND predicate.
    #[serde(rename = "tag", default)]
    pub tags: Vec<Tag>,
}

/// AnalyticsConfiguration parameters.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct AnalyticsConfiguration {
    /// The ID that identifies the analytics configuration.
    pub id: String,
    /// Contains data related to access patterns to be collected and made available to analyze the tradeoffs between different storage classes.
    pub storage_class_analysis: StorageClassAnalysis,
    /// The filter used to describe a set of objects for analyses.
    pub filter: AnalyticsFilter,
}

/// Where to publish the analytics results.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct AnalyticsExportDestination {
    pub s3_bucket_destination: AnalyticsS3BucketDestination,
}

/// The filter used to describe a set of objects for analyses.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct AnalyticsFilter {
    /// The prefix to use when evaluating an analytics filter.
    pub prefix: Option<String>,
    /// A conjunction (logical AND) of predicates, which is used in evaluating an analytics filter.
    /// The operator must have at least two predicates.
    pub and: Option<AnalyticsAndOperator>,
    /// The filter used to describe a set of objects for analyses.
    pub tag: Tag,
}
/// Contains information about where to publish the analytics results.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct AnalyticsS3BucketDestination {
    /// The Amazon Resource Name (ARN) of the bucket to which data is exported.
    pub bucket: String,
    /// Specifies the file format used when exporting data to Amazon S3.
    /// Valid Values: CSV
    pub format: String,
    /// The account ID that owns the destination bucket.
    pub bucket_account_id: Option<String>,
    /// The prefix to use when exporting data. The prefix is prepended to all results.
    pub prefix: Option<String>,
}

/// In terms of implementation, a Bucket is a resource.
/// An Amazon S3 bucket name is globally unique, and the namespace is shared by all AWS accounts.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Bucket {
    /// The name of the bucket.
    pub name: String,
    /// Date the bucket was created. This date can change when making changes to your bucket, such as editing its bucket policy.
    pub creation_date: String,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Buckets {
    #[serde(default)]
    pub bucket: Vec<Bucket>,
}

/// Container for all (if there are any) keys between Prefix and the next occurrence of the string specified by a delimiter.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct CommonPrefix {
    pub prefix: String,
}

/// The container for the completed multipart upload details.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct CompleteMultipartUpload {
    #[serde(default, rename = "Part")]
    pub parts: Vec<Part>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct CompleteMultipartUploadResult {
    pub bucket: String,
    pub key: String,
    pub e_tag: String,
    pub location: String,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Condition {
    pub http_error_code_returned_equals: Option<String>,
    pub key_prefix_equals: Option<String>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct CopyPartResult {
    pub e_tag: String,
}

/// Describes the cross-origin access configuration for objects in an Amazon S3 bucket.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct CORSConfiguration {
    #[serde(rename = "CORSRule")]
    pub rules: Vec<CORSRule>,
}

/// Specifies a cross-origin access rule for an Amazon S3 bucket.
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
#[serde(rename_all = "PascalCase")]
pub struct CORSRule {
    /// **Required**. Valid values are `GET`, `PUT`, `HEAD`, `POST`, and `DELETE`.
    #[serde(rename = "AllowedMethod", default)]
    pub allowed_methods: Vec<String>,
    /// **Required**
    #[serde(rename = "AllowedOrigin", default)]
    pub allowed_origins: Vec<String>,
    #[serde(rename = "AllowedHeader", default)]
    pub allowed_headers: Vec<String>,
    #[serde(rename = "ExposeHeader", default)]
    pub expose_headers: Vec<String>,
    #[serde(rename = "ID")]
    pub id: Option<String>,
    pub max_age_seconds: usize,
}

/// The container element for specifying the default Object Lock retention settings
/// for new objects placed in the specified bucket.
///
/// **Note**
/// - The DefaultRetention settings require **both** a `mode` and a `period`.
/// - The DefaultRetention period can be either Days or Years but you must select one.
///   You cannot specify Days and Years at the same time.
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
#[serde(rename_all = "PascalCase")]
pub struct DefaultRetention {
    pub days: Option<usize>,
    pub mode: RetentionMode,
    pub years: Option<usize>,
}

/// Information about the delete marker.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DeleteMarkerEntry {
    /// The object key.
    pub key: String,
    /// Date and time when the object was last modified.
    pub last_modified: String,
    /// Specifies whether the object is (true) or is not (false) the latest version of an object.
    pub is_latest: bool,
    /// The entity tag is an MD5 hash of that version of the object.
    pub owner: Option<Owner>,
    /// Version ID of an object.
    pub version_id: Option<String>,
}

/// Specifies whether Amazon S3 replicates delete markers.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DeleteMarkerReplication {
    pub status: Status,
}

/// Specifies information about where to publish analysis or configuration results for an Amazon S3 bucket and S3 Replication Time Control (S3 RTC).
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Destination {
    pub bucket: String,
    pub account: Option<String>,
    pub storage_class: StorageClass,
    pub access_control_translation: Option<AccessControlTranslation>,
    pub encryption_configuration: Option<EncryptionConfiguration>,
    pub replication_time: Option<ReplicationTime>,
    pub metrics: Option<Metrics>,
}

/// Specifies encryption-related information for an Amazon S3 bucket that is a destination for replicated objects.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct EncryptionConfiguration {
    #[serde(rename = "ReplicaKmsKeyID")]
    pub replica_kms_key_id: String,
}

/// The error information.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ErrorDocument {
    /// The object key name to use when a 4XX class error occurs.
    /// Minimum length of 1.
    pub key: String,
}

/// Optional configuration to replicate existing source bucket objects.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ExistingObjectReplication {
    pub status: Status,
}

/// Container for grant information.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Grant {
    pub grantee: Option<Grantee>,
    pub permission: Option<Permission>,
}

/// Container for the person being granted permissions.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Grantee {
    pub display_name: Option<String>,
    pub email_address: Option<String>,
    pub id: Option<String>,
    #[serde(alias = "Type", alias = "type")]
    pub r#type: GranteeType,
    pub uri: Option<String>,
}

/// The name of the index document for the website.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct IndexDocument {
    /// A suffix that is appended to a request that is for a directory on the website endpoint.
    pub suffix: String,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub(crate) struct InitiateMultipartUploadResult {
    pub bucket: String,
    pub key: String,
    pub upload_id: String,
}

/// Container element that identifies who initiated the multipart upload.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Initiator {
    /// Name of the Principal.
    pub display_name: String,
    #[serde(rename = "ID")]
    pub id: String,
}

/// A legal hold configuration for an object.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct LegalHold {
    pub status: LegalHoldStatus,
}

///  LifecycleConfiguration parameters.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct LifecycleConfiguration {
    pub rule: Vec<LifecycleRule>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct LifecycleExpiration {
    pub date: Option<String>,
    /// Indicates the lifetime, in days, of the objects that are subject to the rule.
    /// The value must be a non-zero positive integer.
    pub days: u32,
    pub expired_object_delete_marker: Option<bool>,
}

/// A lifecycle rule for individual objects in an Amazon S3 bucket.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct LifecycleRule {
    /// Unique identifier for the rule. The value cannot be longer than 255 characters.
    #[serde(rename = "ID")]
    pub id: Option<String>,

    pub prefix: Option<String>,
    /// If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being applied.
    pub status: Status,
    /// Specifies the days since the initiation of an incomplete multipart upload
    /// that Amazon S3 will wait before permanently removing all parts of the upload.
    pub abort_incomplete_multipart_upload: Option<AbortIncompleteMultipartUpload>,
    /// Specifies the expiration for the lifecycle of the object in the form of date, days and, whether the object has a delete marker.
    pub expiration: Option<LifecycleExpiration>,
    /// The Filter is used to identify objects that a Lifecycle Rule applies to.
    pub filter: Option<LifecycleRuleFilter>,
    /// Specifies when noncurrent object versions expire.
    pub noncurrent_version_expiration: Option<NoncurrentVersionExpiration>,
    /// Specifies the transition rule for the lifecycle rule that describes when noncurrent objects transition to a specific storage class.
    #[serde(rename = "NoncurrentVersionTransition", default)]
    pub noncurrent_version_transitions: Vec<NoncurrentVersionTransition>,
    /// Specifies when an Amazon S3 object transitions to a specified storage class.
    #[serde(rename = "Transition", default)]
    pub transitions: Vec<Transition>,
}

/// This is used in a Lifecycle Rule Filter to apply a logical AND to two or more predicates.
/// The Lifecycle Rule will apply to any object matching all of the predicates configured inside the And operator.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct LifecycleRuleAndOperator {
    /// Minimum object size to which the rule applies.
    pub object_size_greater_than: Option<u32>,
    /// Maximum object size to which the rule applies.
    pub object_size_less_than: Option<u32>,
    /// Prefix identifying one or more objects to which the rule applies.
    pub prefix: Option<String>,
    /// All of these tags must exist in the object's tag set in order for the rule to apply.
    #[serde(rename = "tag", default)]
    pub tags: Vec<Tag>,
}

/// The Filter is used to identify objects that a Lifecycle Rule applies to.
/// A Filter can have exactly one of Prefix, Tag, ObjectSizeGreaterThan,
/// ObjectSizeLessThan, or And specified. If the Filter element is left empty,
/// the Lifecycle Rule applies to all objects in the bucket.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct LifecycleRuleFilter {
    /// This is used in a Lifecycle Rule Filter to apply a logical AND to two or more predicates.
    /// The Lifecycle Rule will apply to any object matching all of the predicates configured inside the And operator.
    pub and: Option<LifecycleRuleAndOperator>,
    /// Minimum object size to which the rule applies.
    pub object_size_greater_than: Option<u32>,
    /// Maximum object size to which the rule applies.
    pub object_size_less_than: Option<u32>,
    /// Prefix identifying one or more objects to which the rule applies.
    pub prefix: Option<String>,
    /// This tag must exist in the object's tag set in order for the rule to apply.
    pub tag: Option<Tag>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ListAllMyBucketsResult {
    #[serde(default)]
    pub buckets: Buckets,
    pub owner: Owner,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ListBucketResult {
    pub name: String,
    pub prefix: String,
    pub key_count: usize,
    pub max_keys: usize,
    #[serde(default)]
    pub delimiter: String,
    pub is_truncated: bool,
    pub start_after: Option<String>,
    #[serde(default)]
    pub contents: Vec<Object>,
    #[serde(default)]
    pub common_prefixes: Vec<CommonPrefix>,
    #[serde(default)]
    pub next_continuation_token: String,
    #[serde(default)]
    pub continuation_token: String,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ListMultipartUploadsResult {
    pub bucket: String,
    pub key_marker: String,
    pub upload_id_marker: String,
    pub next_key_marker: String,
    pub prefix: String,
    pub delimiter: String,
    pub next_upload_id_marker: String,
    pub max_uploads: usize,
    pub is_truncated: bool,
    #[serde(default, rename = "Upload")]
    pub uploads: Vec<MultipartUpload>,
    #[serde(default)]
    pub common_prefixes: Vec<CommonPrefix>,
    pub encoding_type: Option<String>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ListPartsResult {
    pub bucket: String,
    pub key: String,
    pub upload_id: String,
    pub part_number_marker: usize,
    pub max_parts: usize,
    pub next_part_number_marker: usize,
    pub is_truncated: bool,
    #[serde(default, rename = "Part")]
    pub parts: Vec<Part>,
    pub storage_class: String,
    pub checksum_algorithm: String,
    pub initiator: Initiator,
    pub owner: Owner,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ListVersionsResult {
    /// A flag that indicates whether Amazon S3 returned all of the results
    /// that satisfied the search criteria. If your results were truncated,
    /// you can make a follow-up paginated request by using the `NextKeyMarker`
    /// and `NextVersionIdMarker` response parameters as a starting place in
    /// another request to return the rest of the results.
    pub is_truncated: bool,
    /// All of the keys rolled up into a common prefix count as a single return when calculating the number of returns.
    #[serde(default)]
    pub common_prefixes: Vec<CommonPrefix>,
    #[serde(default, rename = "Version")]
    pub versions: Vec<ObjectVersion>,
    /// Container for an object that is a delete marker.
    #[serde(default, rename = "DeleteMarker")]
    pub delete_markers: Vec<DeleteMarkerEntry>,
    pub name: String,
    pub prefix: String,
    pub max_keys: usize,
    #[serde(default)]
    pub delimiter: String,
    pub encoding_type: Option<String>,
    /// Marks the last key returned in a truncated response.
    #[serde(default)]
    pub key_marker: String,
    /// When the number of responses exceeds the value of `MaxKeys`,
    /// `NextKeyMarker` specifies the first key not returned that
    /// satisfies the search criteria. Use this value for the `key-marker`
    /// request parameter in a subsequent request.
    #[serde(default)]
    pub next_key_marker: String,
    /// Marks the last version of the key returned in a truncated response.
    #[serde(default)]
    pub version_id_marker: String,
    /// When the number of responses exceeds the value of `MaxKeys`,
    /// `NextVersionIdMarker` specifies the first object version not
    /// returned that satisfies the search criteria. Use this value
    /// for the `version-id-marker` request parameter in a subsequent request.
    #[serde(default)]
    pub next_version_id_marker: String,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct LocationConstraint {
    pub location_constraint: String,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Metrics {
    pub status: Status,
    pub event_threshold: Option<ReplicationTimeValue>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct MultipartUpload {
    pub checksum_algorithm: String,
    pub upload_id: String,
    pub storage_class: String,
    pub key: String,
    pub initiated: String,
}

/// Specifies when noncurrent object versions expire.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct NoncurrentVersionExpiration {
    /// Specifies how many noncurrent versions Amazon S3 will retain.
    pub newer_noncurrent_versions: Option<i32>,
    /// Specifies the number of days an object is noncurrent before Amazon S3 can perform the associated action.
    pub noncurrent_days: Option<i32>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct NoncurrentVersionTransition {
    /// Specifies how many noncurrent versions Amazon S3 will retain.
    pub newer_noncurrent_versions: Option<i32>,
    /// Specifies the number of days an object is noncurrent before Amazon S3 can perform the associated action.
    pub noncurrent_days: Option<i32>,
    pub storage_class: Option<StorageClass>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Object {
    pub key: String,
    pub last_modified: String,
    pub e_tag: String,
    pub size: u64,
    pub storage_class: String,
    pub owner: Option<Owner>,
    pub checksum_algorithm: Option<String>,
}

/// The container element for an Object Lock rule.
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
#[serde(rename_all = "PascalCase")]
pub struct ObjectLockRule {
    pub default_retention: DefaultRetention,
}

/// Object representation of
/// - request XML of `put_object_lock_configuration` API
/// - response XML of `get_object_lock_configuration` API.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ObjectLockConfiguration {
    /// Indicates whether this bucket has an Object Lock configuration enabled.
    /// Enable ObjectLockEnabled when you apply ObjectLockConfiguration to a bucket.
    ///
    /// Valid Values: `Enabled`
    /// Required: No
    pub object_lock_enabled: String,
    pub rule: Option<ObjectLockRule>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ObjectVersion {
    /// The object key.
    pub key: String,
    /// Date and time when the object was last modified.
    pub last_modified: String,
    /// Specifies whether the object is (true) or is not (false) the latest version of an object.
    pub is_latest: bool,
    /// The entity tag is an MD5 hash of that version of the object.
    pub e_tag: String,
    pub size: u64,
    pub storage_class: String,
    pub owner: Option<Owner>,
    /// Version ID of an object.
    pub version_id: Option<String>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Owner {
    pub display_name: String,
    #[serde(rename = "ID")]
    pub id: String,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Part {
    pub e_tag: String,
    pub part_number: usize,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Policy {
    version: String,
    id: String,
    statement: Vec<PolicyStatement>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct PolicyPrincipal {
    #[serde(rename = "AWS", default)]
    aws: Vec<String>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct PolicyStatement {
    sid: String,
    principal: PolicyPrincipal,
    effect: String,
    action: Vec<String>,
    resource: Vec<String>,
    condition: Option<String>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct PolicyStatus {
    /// The policy status for this bucket.
    pub is_public: bool,
}

/// This data type contains information about progress of an operation.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Progress {
    pub bytes_processed: u64,
    pub bytes_returned: u64,
    pub bytes_scanned: u64,
}

/// PublicAccessBlockConfiguration parameters
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct PublicAccessBlockConfiguration {
    pub block_public_acls: bool,
    pub block_public_policy: bool,
    pub ignore_public_acls: bool,
    pub restrict_public_buckets: bool,
}

/// Specifies how requests are redirected.
/// In the event of an error, you can specify a different error code to return.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Redirect {
    pub host_name: Option<String>,
    pub http_redirect_code: Option<String>,
    pub protocol: Option<Protocol>,
    pub replace_key_prefix_with: Option<String>,
    pub replace_key_with: Option<String>,
}

/// Specifies the redirect behavior of all requests to a website endpoint of an Amazon S3 bucket.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct RedirectAllRequestsTo {
    pub host_name: String,
    pub protocol: Option<Protocol>,
}

/// ReplicationConfiguration parameters.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ReplicationConfiguration {
    pub role: Option<String>,
    #[serde(rename = "Rule", default)]
    pub rules: Vec<ReplicationRule>,
}

/// A filter that you can specify for selection for modifications on replicas.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ReplicaModifications {
    pub status: Status,
}

/// Specifies which Amazon S3 objects to replicate and where to store the replicas.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ReplicationRule {
    #[serde(rename = "ID", default)]
    pub id: Option<String>,
    pub prefix: Option<String>,
    pub priority: Option<i64>,
    pub delete_marker_replication: Option<DeleteMarkerReplication>,
    pub existing_object_replication: Option<ExistingObjectReplication>,
    /// Specifies whether the rule is enabled.
    pub status: Status,
    pub destination: Destination,
    pub source_selection_criteria: Option<SourceSelectionCriteria>,
    pub filter: Option<ReplicationRuleFilter>,
}

/// A container for specifying rule filters.
/// The filters determine the subset of objects to which the rule applies.
/// This element is required only if you specify more than one filter.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ReplicationRuleAndOperator {
    pub prefix: Option<String>,
    #[serde(rename = "tag")]
    pub tags: Option<Vec<Tag>>,
}

/// A filter that identifies the subset of objects to which the replication rule applies.
/// A Filter must specify exactly one Prefix, Tag, or an And child element.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ReplicationRuleFilter {
    pub prefix: Option<String>,
    pub tag: Option<Tag>,
    pub and: Option<ReplicationRuleAndOperator>,
}

/// A container specifying S3 Replication Time Control (S3 RTC) related information,
/// including whether S3 RTC is enabled and the time when all objects and operations on objects must be replicated.
/// Must be specified together with a Metrics block.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ReplicationTime {
    pub status: Status,
    pub time: ReplicationTimeValue,
}

/// A container specifying the time value for S3 Replication Time Control (S3 RTC) and replication metrics EventThreshold.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ReplicationTimeValue {
    pub minutes: Option<i32>,
}

/// Object representation of request XML of `put_object_retention` API
/// and response XML of `get_object_retention` API.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Retention {
    /// Valid Values: GOVERNANCE | COMPLIANCE
    pub mode: RetentionMode,
    /// The date on which this Object Lock Retention will expire.
    #[serde(deserialize_with = "crate::time::deserialize_with_str")]
    pub retain_until_date: UtcTime,
}

/// Specifies the redirect behavior and when a redirect is applied.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct RoutingRule {
    pub redirect: Redirect,
    pub condition: Option<Condition>,
}

/// Rules that define when a redirect is applied and the redirect behavior.
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
#[serde(rename_all = "PascalCase")]
pub struct RoutingRules {
    pub routing_rule: Vec<RoutingRule>,
}

/// A container for filter information for the selection of S3 objects encrypted with AWS KMS.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct SseKmsEncryptedObjects {
    pub status: Status,
}

/// Specifies data related to access patterns to be collected and made available to analyze
/// the tradeoffs between different storage classes for an Amazon S3 bucket.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct StorageClassAnalysis {
    /// Specifies how data related to the storage class analysis for an Amazon S3 bucket should be exported.
    pub data_export: Option<StorageClassAnalysisDataExport>,
}

/// Container for data related to the storage class analysis for an Amazon S3 bucket for export.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct StorageClassAnalysisDataExport {
    /// The place to store the data for an analysis.
    pub destination: AnalyticsExportDestination,
    /// The version of the output schema to use when exporting data. Must be V_1.
    pub output_schema_version: String,
}

/// Describes the default server-side encryption to apply to new objects in the bucket.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ServerSideEncryptionByDefault {
    #[serde(rename = "SSEAlgorithm")]
    pub ssealgorithm: String,
    #[serde(rename = " KMSMasterKeyID")]
    pub kmsmaster_key_id: Option<String>,
}

/// Root level tag for the ServerSideEncryptionConfiguration parameters
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ServerSideEncryptionConfiguration {
    #[serde(rename = "Rule")]
    pub rules: Vec<ServerSideEncryptionRule>,
}

/// Specifies the default server-side encryption configuration.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ServerSideEncryptionRule {
    pub apply_server_side_encryption_by_default: ServerSideEncryptionByDefault,
    #[serde(default)]
    pub bucket_key_enabled: bool,
}

/// A container that describes additional filters for identifying the source objects that you want to replicate.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct SourceSelectionCriteria {
    pub replica_modifications: Option<ReplicaModifications>,
    pub sse_kms_encrypted_objects: Option<SseKmsEncryptedObjects>,
}

/// Container for the stats details.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Stats {
    /// The total number of uncompressed object bytes processed.
    pub bytes_processed: u64,
    /// The total number of bytes of records payload data returned.
    pub bytes_returned: u64,
    /// The total number of object bytes scanned.
    pub bytes_scanned: u64,
}

/// A container of a key value name pair.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Tag {
    /// Name of the tag.
    pub key: String,
    /// Value of the tag.
    pub value: String,
}

/// A collection for a set of tags
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct TagSet {
    /// Array of [Tag]
    #[serde(rename = "Tag", default)]
    pub tags: Vec<Tag>,
}

/// Container for TagSet elements.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Tagging {
    /// A collection for a set of tags.
    pub tag_set: TagSet,
}

/// Specifies when an object transitions to a specified storage class.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Transition {
    /// Indicates when objects are transitioned to the specified storage class.
    /// The date value must be in ISO 8601 format. The time is always midnight UTC.
    pub date: Option<String>,
    /// Indicates the number of days after creation when objects are transitioned to the specified storage class.
    pub days: Option<i32>,
    /// The storage class to which you want the object to transition.
    pub storage_class: Option<StorageClass>,
}

/// Describes the versioning state of an Amazon S3 bucket.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct VersioningConfiguration {
    /// Specifies whether MFA delete is enabled in the bucket versioning configuration.
    /// This element is only returned if the bucket has been configured with MFA delete.
    /// If the bucket has never been so configured, this element is not returned.
    ///
    /// Valid Values: Enabled | Disabled
    pub mfa_delete: Option<MFADelete>,

    /// The versioning state of the bucket.
    ///
    /// Valid Values: Enabled | Suspended
    pub status: Option<VersioningStatus>,
}

///  WebsiteConfiguration parameters.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct WebsiteConfiguration {
    pub error_document: Option<ErrorDocument>,
    pub index_document: IndexDocument,
    pub redirect_all_requests_to: Option<RedirectAllRequestsTo>,
    #[serde(default)]
    pub routing_rules: RoutingRules,
}

//////////////////  Enum Type

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub enum ChecksumAlgorithm {
    CRC32,
    CRC32C,
    SHA1,
    SHA256,
}

/// Type of grantee
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub enum GranteeType {
    CanonicalUser,
    AmazonCustomerByEmail,
    Group,
}

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub enum LegalHoldStatus {
    ON,
    OFF,
}

/// Specifies whether MFA delete is enabled in the bucket versioning configuration.
/// This element is only returned if the bucket has been configured with MFA delete.
/// If the bucket has never been so configured, this element is not returned.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub enum MFADelete {
    Enabled,
    Disabled,
}

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub enum Protocol {
    http,
    https,
}

/// Retention mode, Valid Values: `GOVERNANCE | COMPLIANCE`
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Default)]
pub enum RetentionMode {
    #[default]
    GOVERNANCE,
    COMPLIANCE,
}

/// The permission given to the grantee.. Valid Values: `FULL_CONTROL | WRITE | WRITE_ACP | READ | READ_ACP`
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub enum Permission {
    FULL_CONTROL,
    WRITE,
    WRITE_ACP,
    READ,
    READ_ACP,
}

/// Valid Values: `Enabled | Disabled`
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub enum Status {
    Enabled,
    Disabled,
}

/// The storage class to use when replicating objects, such as S3 Standard or reduced redundancy.
/// By default, Amazon S3 uses the storage class of the source object to create the object replica.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub enum StorageClass {
    STANDARD,
    REDUCED_REDUNDANCY,
    STANDARD_IA,
    ONEZONE_IA,
    INTELLIGENT_TIERING,
    GLACIER,
    DEEP_ARCHIVE,
    OUTPOSTS,
    GLACIER_IR,
    SNOW,
    EXPRESS_ONEZONE,
}

/// The versioning state of the bucket.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub enum VersioningStatus {
    Enabled,
    Suspended,
}