rusoto_ebs 0.48.0

AWS SDK for Rust - Amazon Elastic Block Store @ 2019-11-02
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
// =================================================================
//
//                           * WARNING *
//
//                    This file is generated!
//
//  Changes made to this file will be overwritten. If changes are
//  required to the generated code, the service_crategen project
//  must be updated to generate the changes.
//
// =================================================================

use std::error::Error;
use std::fmt;

use async_trait::async_trait;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError};

use rusoto_core::param::{Params, ServiceParams};
use rusoto_core::proto;
use rusoto_core::signature::SignedRequest;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
use serde_json;
/// <p>A block of data in an Amazon Elastic Block Store snapshot.</p>
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct Block {
    /// <p>The block index.</p>
    #[serde(rename = "BlockIndex")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub block_index: Option<i64>,
    /// <p>The block token for the block index.</p>
    #[serde(rename = "BlockToken")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub block_token: Option<String>,
}

/// <p>A block of data in an Amazon Elastic Block Store snapshot that is different from another snapshot of the same volume/snapshot lineage.</p>
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ChangedBlock {
    /// <p>The block index.</p>
    #[serde(rename = "BlockIndex")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub block_index: Option<i64>,
    /// <p>The block token for the block index of the <code>FirstSnapshotId</code> specified in the <code>ListChangedBlocks</code> operation. This value is absent if the first snapshot does not have the changed block that is on the second snapshot.</p>
    #[serde(rename = "FirstBlockToken")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first_block_token: Option<String>,
    /// <p>The block token for the block index of the <code>SecondSnapshotId</code> specified in the <code>ListChangedBlocks</code> operation.</p>
    #[serde(rename = "SecondBlockToken")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub second_block_token: Option<String>,
}

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct CompleteSnapshotRequest {
    /// <p>The number of blocks that were written to the snapshot.</p>
    #[serde(rename = "ChangedBlocksCount")]
    pub changed_blocks_count: i64,
    /// <p>An aggregated Base-64 SHA256 checksum based on the checksums of each written block.</p> <p>To generate the aggregated checksum using the linear aggregation method, arrange the checksums for each written block in ascending order of their block index, concatenate them to form a single string, and then generate the checksum on the entire string using the SHA256 algorithm.</p>
    #[serde(rename = "Checksum")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub checksum: Option<String>,
    /// <p>The aggregation method used to generate the checksum. Currently, the only supported aggregation method is <code>LINEAR</code>.</p>
    #[serde(rename = "ChecksumAggregationMethod")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub checksum_aggregation_method: Option<String>,
    /// <p>The algorithm used to generate the checksum. Currently, the only supported algorithm is <code>SHA256</code>.</p>
    #[serde(rename = "ChecksumAlgorithm")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub checksum_algorithm: Option<String>,
    /// <p>The ID of the snapshot.</p>
    #[serde(rename = "SnapshotId")]
    pub snapshot_id: String,
}

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct CompleteSnapshotResponse {
    /// <p>The status of the snapshot.</p>
    #[serde(rename = "Status")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,
}

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct GetSnapshotBlockRequest {
    /// <p>The block index of the block from which to get data.</p> <p>Obtain the <code>BlockIndex</code> by running the <code>ListChangedBlocks</code> or <code>ListSnapshotBlocks</code> operations.</p>
    #[serde(rename = "BlockIndex")]
    pub block_index: i64,
    /// <p>The block token of the block from which to get data.</p> <p>Obtain the <code>BlockToken</code> by running the <code>ListChangedBlocks</code> or <code>ListSnapshotBlocks</code> operations.</p>
    #[serde(rename = "BlockToken")]
    pub block_token: String,
    /// <p>The ID of the snapshot containing the block from which to get data.</p>
    #[serde(rename = "SnapshotId")]
    pub snapshot_id: String,
}

#[derive(Clone, Debug, Default, PartialEq)]
pub struct GetSnapshotBlockResponse {
    /// <p>The data content of the block.</p>
    pub block_data: Option<bytes::Bytes>,
    /// <p>The checksum generated for the block, which is Base64 encoded.</p>
    pub checksum: Option<String>,
    /// <p>The algorithm used to generate the checksum for the block, such as SHA256.</p>
    pub checksum_algorithm: Option<String>,
    /// <p>The size of the data in the block.</p>
    pub data_length: Option<i64>,
}

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ListChangedBlocksRequest {
    /// <p><p>The ID of the first snapshot to use for the comparison.</p> <important> <p>The <code>FirstSnapshotID</code> parameter must be specified with a <code>SecondSnapshotId</code> parameter; otherwise, an error occurs.</p> </important></p>
    #[serde(rename = "FirstSnapshotId")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first_snapshot_id: Option<String>,
    /// <p>The number of results to return.</p>
    #[serde(rename = "MaxResults")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_results: Option<i64>,
    /// <p>The token to request the next page of results.</p>
    #[serde(rename = "NextToken")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_token: Option<String>,
    /// <p><p>The ID of the second snapshot to use for the comparison.</p> <important> <p>The <code>SecondSnapshotId</code> parameter must be specified with a <code>FirstSnapshotID</code> parameter; otherwise, an error occurs.</p> </important></p>
    #[serde(rename = "SecondSnapshotId")]
    pub second_snapshot_id: String,
    /// <p>The block index from which the comparison should start.</p> <p>The list in the response will start from this block index or the next valid block index in the snapshots.</p>
    #[serde(rename = "StartingBlockIndex")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub starting_block_index: Option<i64>,
}

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ListChangedBlocksResponse {
    /// <p>The size of the block.</p>
    #[serde(rename = "BlockSize")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub block_size: Option<i64>,
    /// <p>An array of objects containing information about the changed blocks.</p>
    #[serde(rename = "ChangedBlocks")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub changed_blocks: Option<Vec<ChangedBlock>>,
    /// <p>The time when the <code>BlockToken</code> expires.</p>
    #[serde(rename = "ExpiryTime")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expiry_time: Option<f64>,
    /// <p>The token to use to retrieve the next page of results. This value is null when there are no more results to return.</p>
    #[serde(rename = "NextToken")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_token: Option<String>,
    /// <p>The size of the volume in GB.</p>
    #[serde(rename = "VolumeSize")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_size: Option<i64>,
}

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ListSnapshotBlocksRequest {
    /// <p>The number of results to return.</p>
    #[serde(rename = "MaxResults")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_results: Option<i64>,
    /// <p>The token to request the next page of results.</p>
    #[serde(rename = "NextToken")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_token: Option<String>,
    /// <p>The ID of the snapshot from which to get block indexes and block tokens.</p>
    #[serde(rename = "SnapshotId")]
    pub snapshot_id: String,
    /// <p>The block index from which the list should start. The list in the response will start from this block index or the next valid block index in the snapshot.</p>
    #[serde(rename = "StartingBlockIndex")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub starting_block_index: Option<i64>,
}

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ListSnapshotBlocksResponse {
    /// <p>The size of the block.</p>
    #[serde(rename = "BlockSize")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub block_size: Option<i64>,
    /// <p>An array of objects containing information about the blocks.</p>
    #[serde(rename = "Blocks")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub blocks: Option<Vec<Block>>,
    /// <p>The time when the <code>BlockToken</code> expires.</p>
    #[serde(rename = "ExpiryTime")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expiry_time: Option<f64>,
    /// <p>The token to use to retrieve the next page of results. This value is null when there are no more results to return.</p>
    #[serde(rename = "NextToken")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_token: Option<String>,
    /// <p>The size of the volume in GB.</p>
    #[serde(rename = "VolumeSize")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_size: Option<i64>,
}

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct PutSnapshotBlockRequest {
    /// <p>The data to write to the block.</p> <p>The block data is not signed as part of the Signature Version 4 signing process. As a result, you must generate and provide a Base64-encoded SHA256 checksum for the block data using the <b>x-amz-Checksum</b> header. Also, you must specify the checksum algorithm using the <b>x-amz-Checksum-Algorithm</b> header. The checksum that you provide is part of the Signature Version 4 signing process. It is validated against a checksum generated by Amazon EBS to ensure the validity and authenticity of the data. If the checksums do not correspond, the request fails. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html#ebsapis-using-checksums"> Using checksums with the EBS direct APIs</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
    #[serde(rename = "BlockData")]
    #[serde(
        deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
        serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
        default
    )]
    pub block_data: bytes::Bytes,
    /// <p>The block index of the block in which to write the data. A block index is a logical index in units of <code>512</code> KiB blocks. To identify the block index, divide the logical offset of the data in the logical volume by the block size (logical offset of data/<code>524288</code>). The logical offset of the data must be <code>512</code> KiB aligned.</p>
    #[serde(rename = "BlockIndex")]
    pub block_index: i64,
    /// <p>A Base64-encoded SHA256 checksum of the data. Only SHA256 checksums are supported.</p>
    #[serde(rename = "Checksum")]
    pub checksum: String,
    /// <p>The algorithm used to generate the checksum. Currently, the only supported algorithm is <code>SHA256</code>.</p>
    #[serde(rename = "ChecksumAlgorithm")]
    pub checksum_algorithm: String,
    /// <p>The size of the data to write to the block, in bytes. Currently, the only supported size is <code>524288</code>.</p> <p>Valid values: <code>524288</code> </p>
    #[serde(rename = "DataLength")]
    pub data_length: i64,
    /// <p>The progress of the write process, as a percentage.</p>
    #[serde(rename = "Progress")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub progress: Option<i64>,
    /// <p>The ID of the snapshot.</p>
    #[serde(rename = "SnapshotId")]
    pub snapshot_id: String,
}

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct PutSnapshotBlockResponse {
    /// <p>The SHA256 checksum generated for the block data by Amazon EBS.</p>
    #[serde(rename = "Checksum")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub checksum: Option<String>,
    /// <p>The algorithm used by Amazon EBS to generate the checksum.</p>
    #[serde(rename = "ChecksumAlgorithm")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub checksum_algorithm: Option<String>,
}

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct StartSnapshotRequest {
    /// <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency ensures that an API request completes only once. With an idempotent request, if the original request completes successfully. The subsequent retries with the same client token return the result from the original successful request and they have no additional effect.</p> <p>If you do not specify a client token, one is automatically generated by the AWS SDK.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-direct-api-idempotency.html"> Idempotency for StartSnapshot API</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
    #[serde(rename = "ClientToken")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_token: Option<String>,
    /// <p>A description for the snapshot.</p>
    #[serde(rename = "Description")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// <p>Indicates whether to encrypt the snapshot. To create an encrypted snapshot, specify <code>true</code>. To create an unencrypted snapshot, omit this parameter.</p> <p>If you specify a value for <b>ParentSnapshotId</b>, omit this parameter.</p> <p>If you specify <code>true</code>, the snapshot is encrypted using the CMK specified using the <b>KmsKeyArn</b> parameter. If no value is specified for <b>KmsKeyArn</b>, the default CMK for your account is used. If no default CMK has been specified for your account, the AWS managed CMK is used. To set a default CMK for your account, use <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyEbsDefaultKmsKeyId.html"> ModifyEbsDefaultKmsKeyId</a>.</p> <p>If your account is enabled for encryption by default, you cannot set this parameter to <code>false</code>. In this case, you can omit this parameter.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html#ebsapis-using-encryption"> Using encryption</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
    #[serde(rename = "Encrypted")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub encrypted: Option<bool>,
    /// <p>The Amazon Resource Name (ARN) of the AWS Key Management Service (AWS KMS) customer master key (CMK) to be used to encrypt the snapshot. If you do not specify a CMK, the default AWS managed CMK is used.</p> <p>If you specify a <b>ParentSnapshotId</b>, omit this parameter; the snapshot will be encrypted using the same CMK that was used to encrypt the parent snapshot.</p> <p>If <b>Encrypted</b> is set to <code>true</code>, you must specify a CMK ARN. </p>
    #[serde(rename = "KmsKeyArn")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub kms_key_arn: Option<String>,
    /// <p>The ID of the parent snapshot. If there is no parent snapshot, or if you are creating the first snapshot for an on-premises volume, omit this parameter.</p> <p>If your account is enabled for encryption by default, you cannot use an unencrypted snapshot as a parent snapshot. You must first create an encrypted copy of the parent snapshot using <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CopySnapshot.html">CopySnapshot</a>.</p>
    #[serde(rename = "ParentSnapshotId")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_snapshot_id: Option<String>,
    /// <p>The tags to apply to the snapshot.</p>
    #[serde(rename = "Tags")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<Vec<Tag>>,
    /// <p>The amount of time (in minutes) after which the snapshot is automatically cancelled if:</p> <ul> <li> <p>No blocks are written to the snapshot.</p> </li> <li> <p>The snapshot is not completed after writing the last block of data.</p> </li> </ul> <p>If no value is specified, the timeout defaults to <code>60</code> minutes.</p>
    #[serde(rename = "Timeout")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timeout: Option<i64>,
    /// <p>The size of the volume, in GiB. The maximum size is <code>16384</code> GiB (16 TiB).</p>
    #[serde(rename = "VolumeSize")]
    pub volume_size: i64,
}

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct StartSnapshotResponse {
    /// <p>The size of the blocks in the snapshot, in bytes.</p>
    #[serde(rename = "BlockSize")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub block_size: Option<i64>,
    /// <p>The description of the snapshot.</p>
    #[serde(rename = "Description")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// <p>The Amazon Resource Name (ARN) of the AWS Key Management Service (AWS KMS) customer master key (CMK) used to encrypt the snapshot.</p>
    #[serde(rename = "KmsKeyArn")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub kms_key_arn: Option<String>,
    /// <p>The AWS account ID of the snapshot owner.</p>
    #[serde(rename = "OwnerId")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub owner_id: Option<String>,
    /// <p>The ID of the parent snapshot.</p>
    #[serde(rename = "ParentSnapshotId")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_snapshot_id: Option<String>,
    /// <p>The ID of the snapshot.</p>
    #[serde(rename = "SnapshotId")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub snapshot_id: Option<String>,
    /// <p>The timestamp when the snapshot was created.</p>
    #[serde(rename = "StartTime")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_time: Option<f64>,
    /// <p>The status of the snapshot.</p>
    #[serde(rename = "Status")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,
    /// <p>The tags applied to the snapshot. You can specify up to 50 tags per snapshot. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html"> Tagging your Amazon EC2 resources</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
    #[serde(rename = "Tags")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<Vec<Tag>>,
    /// <p>The size of the volume, in GiB.</p>
    #[serde(rename = "VolumeSize")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_size: Option<i64>,
}

/// <p>Describes a tag.</p>
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct Tag {
    /// <p>The key of the tag.</p>
    #[serde(rename = "Key")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub key: Option<String>,
    /// <p>The value of the tag.</p>
    #[serde(rename = "Value")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
}

/// Errors returned by CompleteSnapshot
#[derive(Debug, PartialEq)]
pub enum CompleteSnapshotError {
    /// <p>You do not have sufficient access to perform this action.</p>
    AccessDenied(String),
    /// <p>An internal error has occurred.</p>
    InternalServer(String),
    /// <p>The number of API requests has exceed the maximum allowed API request throttling limit.</p>
    RequestThrottled(String),
    /// <p>The specified resource does not exist.</p>
    ResourceNotFound(String),
    /// <p>Your current service quotas do not allow you to perform this action.</p>
    ServiceQuotaExceeded(String),
}

impl CompleteSnapshotError {
    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CompleteSnapshotError> {
        if let Some(err) = proto::json::Error::parse_rest(&res) {
            match err.typ.as_str() {
                "AccessDeniedException" => {
                    return RusotoError::Service(CompleteSnapshotError::AccessDenied(err.msg))
                }
                "InternalServerException" => {
                    return RusotoError::Service(CompleteSnapshotError::InternalServer(err.msg))
                }
                "RequestThrottledException" => {
                    return RusotoError::Service(CompleteSnapshotError::RequestThrottled(err.msg))
                }
                "ResourceNotFoundException" => {
                    return RusotoError::Service(CompleteSnapshotError::ResourceNotFound(err.msg))
                }
                "ServiceQuotaExceededException" => {
                    return RusotoError::Service(CompleteSnapshotError::ServiceQuotaExceeded(
                        err.msg,
                    ))
                }
                "ValidationException" => return RusotoError::Validation(err.msg),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for CompleteSnapshotError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            CompleteSnapshotError::AccessDenied(ref cause) => write!(f, "{}", cause),
            CompleteSnapshotError::InternalServer(ref cause) => write!(f, "{}", cause),
            CompleteSnapshotError::RequestThrottled(ref cause) => write!(f, "{}", cause),
            CompleteSnapshotError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
            CompleteSnapshotError::ServiceQuotaExceeded(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for CompleteSnapshotError {}
/// Errors returned by GetSnapshotBlock
#[derive(Debug, PartialEq)]
pub enum GetSnapshotBlockError {
    /// <p>You do not have sufficient access to perform this action.</p>
    AccessDenied(String),
    /// <p>An internal error has occurred.</p>
    InternalServer(String),
    /// <p>The number of API requests has exceed the maximum allowed API request throttling limit.</p>
    RequestThrottled(String),
    /// <p>The specified resource does not exist.</p>
    ResourceNotFound(String),
    /// <p>Your current service quotas do not allow you to perform this action.</p>
    ServiceQuotaExceeded(String),
}

impl GetSnapshotBlockError {
    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetSnapshotBlockError> {
        if let Some(err) = proto::json::Error::parse_rest(&res) {
            match err.typ.as_str() {
                "AccessDeniedException" => {
                    return RusotoError::Service(GetSnapshotBlockError::AccessDenied(err.msg))
                }
                "InternalServerException" => {
                    return RusotoError::Service(GetSnapshotBlockError::InternalServer(err.msg))
                }
                "RequestThrottledException" => {
                    return RusotoError::Service(GetSnapshotBlockError::RequestThrottled(err.msg))
                }
                "ResourceNotFoundException" => {
                    return RusotoError::Service(GetSnapshotBlockError::ResourceNotFound(err.msg))
                }
                "ServiceQuotaExceededException" => {
                    return RusotoError::Service(GetSnapshotBlockError::ServiceQuotaExceeded(
                        err.msg,
                    ))
                }
                "ValidationException" => return RusotoError::Validation(err.msg),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for GetSnapshotBlockError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            GetSnapshotBlockError::AccessDenied(ref cause) => write!(f, "{}", cause),
            GetSnapshotBlockError::InternalServer(ref cause) => write!(f, "{}", cause),
            GetSnapshotBlockError::RequestThrottled(ref cause) => write!(f, "{}", cause),
            GetSnapshotBlockError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
            GetSnapshotBlockError::ServiceQuotaExceeded(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for GetSnapshotBlockError {}
/// Errors returned by ListChangedBlocks
#[derive(Debug, PartialEq)]
pub enum ListChangedBlocksError {
    /// <p>You do not have sufficient access to perform this action.</p>
    AccessDenied(String),
    /// <p>An internal error has occurred.</p>
    InternalServer(String),
    /// <p>The number of API requests has exceed the maximum allowed API request throttling limit.</p>
    RequestThrottled(String),
    /// <p>The specified resource does not exist.</p>
    ResourceNotFound(String),
    /// <p>Your current service quotas do not allow you to perform this action.</p>
    ServiceQuotaExceeded(String),
}

impl ListChangedBlocksError {
    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListChangedBlocksError> {
        if let Some(err) = proto::json::Error::parse_rest(&res) {
            match err.typ.as_str() {
                "AccessDeniedException" => {
                    return RusotoError::Service(ListChangedBlocksError::AccessDenied(err.msg))
                }
                "InternalServerException" => {
                    return RusotoError::Service(ListChangedBlocksError::InternalServer(err.msg))
                }
                "RequestThrottledException" => {
                    return RusotoError::Service(ListChangedBlocksError::RequestThrottled(err.msg))
                }
                "ResourceNotFoundException" => {
                    return RusotoError::Service(ListChangedBlocksError::ResourceNotFound(err.msg))
                }
                "ServiceQuotaExceededException" => {
                    return RusotoError::Service(ListChangedBlocksError::ServiceQuotaExceeded(
                        err.msg,
                    ))
                }
                "ValidationException" => return RusotoError::Validation(err.msg),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for ListChangedBlocksError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            ListChangedBlocksError::AccessDenied(ref cause) => write!(f, "{}", cause),
            ListChangedBlocksError::InternalServer(ref cause) => write!(f, "{}", cause),
            ListChangedBlocksError::RequestThrottled(ref cause) => write!(f, "{}", cause),
            ListChangedBlocksError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
            ListChangedBlocksError::ServiceQuotaExceeded(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for ListChangedBlocksError {}
/// Errors returned by ListSnapshotBlocks
#[derive(Debug, PartialEq)]
pub enum ListSnapshotBlocksError {
    /// <p>You do not have sufficient access to perform this action.</p>
    AccessDenied(String),
    /// <p>An internal error has occurred.</p>
    InternalServer(String),
    /// <p>The number of API requests has exceed the maximum allowed API request throttling limit.</p>
    RequestThrottled(String),
    /// <p>The specified resource does not exist.</p>
    ResourceNotFound(String),
    /// <p>Your current service quotas do not allow you to perform this action.</p>
    ServiceQuotaExceeded(String),
}

impl ListSnapshotBlocksError {
    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListSnapshotBlocksError> {
        if let Some(err) = proto::json::Error::parse_rest(&res) {
            match err.typ.as_str() {
                "AccessDeniedException" => {
                    return RusotoError::Service(ListSnapshotBlocksError::AccessDenied(err.msg))
                }
                "InternalServerException" => {
                    return RusotoError::Service(ListSnapshotBlocksError::InternalServer(err.msg))
                }
                "RequestThrottledException" => {
                    return RusotoError::Service(ListSnapshotBlocksError::RequestThrottled(err.msg))
                }
                "ResourceNotFoundException" => {
                    return RusotoError::Service(ListSnapshotBlocksError::ResourceNotFound(err.msg))
                }
                "ServiceQuotaExceededException" => {
                    return RusotoError::Service(ListSnapshotBlocksError::ServiceQuotaExceeded(
                        err.msg,
                    ))
                }
                "ValidationException" => return RusotoError::Validation(err.msg),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for ListSnapshotBlocksError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            ListSnapshotBlocksError::AccessDenied(ref cause) => write!(f, "{}", cause),
            ListSnapshotBlocksError::InternalServer(ref cause) => write!(f, "{}", cause),
            ListSnapshotBlocksError::RequestThrottled(ref cause) => write!(f, "{}", cause),
            ListSnapshotBlocksError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
            ListSnapshotBlocksError::ServiceQuotaExceeded(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for ListSnapshotBlocksError {}
/// Errors returned by PutSnapshotBlock
#[derive(Debug, PartialEq)]
pub enum PutSnapshotBlockError {
    /// <p>You do not have sufficient access to perform this action.</p>
    AccessDenied(String),
    /// <p>An internal error has occurred.</p>
    InternalServer(String),
    /// <p>The number of API requests has exceed the maximum allowed API request throttling limit.</p>
    RequestThrottled(String),
    /// <p>The specified resource does not exist.</p>
    ResourceNotFound(String),
    /// <p>Your current service quotas do not allow you to perform this action.</p>
    ServiceQuotaExceeded(String),
}

impl PutSnapshotBlockError {
    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PutSnapshotBlockError> {
        if let Some(err) = proto::json::Error::parse_rest(&res) {
            match err.typ.as_str() {
                "AccessDeniedException" => {
                    return RusotoError::Service(PutSnapshotBlockError::AccessDenied(err.msg))
                }
                "InternalServerException" => {
                    return RusotoError::Service(PutSnapshotBlockError::InternalServer(err.msg))
                }
                "RequestThrottledException" => {
                    return RusotoError::Service(PutSnapshotBlockError::RequestThrottled(err.msg))
                }
                "ResourceNotFoundException" => {
                    return RusotoError::Service(PutSnapshotBlockError::ResourceNotFound(err.msg))
                }
                "ServiceQuotaExceededException" => {
                    return RusotoError::Service(PutSnapshotBlockError::ServiceQuotaExceeded(
                        err.msg,
                    ))
                }
                "ValidationException" => return RusotoError::Validation(err.msg),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for PutSnapshotBlockError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            PutSnapshotBlockError::AccessDenied(ref cause) => write!(f, "{}", cause),
            PutSnapshotBlockError::InternalServer(ref cause) => write!(f, "{}", cause),
            PutSnapshotBlockError::RequestThrottled(ref cause) => write!(f, "{}", cause),
            PutSnapshotBlockError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
            PutSnapshotBlockError::ServiceQuotaExceeded(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for PutSnapshotBlockError {}
/// Errors returned by StartSnapshot
#[derive(Debug, PartialEq)]
pub enum StartSnapshotError {
    /// <p>You do not have sufficient access to perform this action.</p>
    AccessDenied(String),
    /// <p>You have reached the limit for concurrent API requests. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html#ebsapi-performance">Optimizing performance of the EBS direct APIs</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
    ConcurrentLimitExceeded(String),
    /// <p>The request uses the same client token as a previous, but non-identical request.</p>
    Conflict(String),
    /// <p>An internal error has occurred.</p>
    InternalServer(String),
    /// <p>The number of API requests has exceed the maximum allowed API request throttling limit.</p>
    RequestThrottled(String),
    /// <p>The specified resource does not exist.</p>
    ResourceNotFound(String),
    /// <p>Your current service quotas do not allow you to perform this action.</p>
    ServiceQuotaExceeded(String),
}

impl StartSnapshotError {
    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<StartSnapshotError> {
        if let Some(err) = proto::json::Error::parse_rest(&res) {
            match err.typ.as_str() {
                "AccessDeniedException" => {
                    return RusotoError::Service(StartSnapshotError::AccessDenied(err.msg))
                }
                "ConcurrentLimitExceededException" => {
                    return RusotoError::Service(StartSnapshotError::ConcurrentLimitExceeded(
                        err.msg,
                    ))
                }
                "ConflictException" => {
                    return RusotoError::Service(StartSnapshotError::Conflict(err.msg))
                }
                "InternalServerException" => {
                    return RusotoError::Service(StartSnapshotError::InternalServer(err.msg))
                }
                "RequestThrottledException" => {
                    return RusotoError::Service(StartSnapshotError::RequestThrottled(err.msg))
                }
                "ResourceNotFoundException" => {
                    return RusotoError::Service(StartSnapshotError::ResourceNotFound(err.msg))
                }
                "ServiceQuotaExceededException" => {
                    return RusotoError::Service(StartSnapshotError::ServiceQuotaExceeded(err.msg))
                }
                "ValidationException" => return RusotoError::Validation(err.msg),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for StartSnapshotError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            StartSnapshotError::AccessDenied(ref cause) => write!(f, "{}", cause),
            StartSnapshotError::ConcurrentLimitExceeded(ref cause) => write!(f, "{}", cause),
            StartSnapshotError::Conflict(ref cause) => write!(f, "{}", cause),
            StartSnapshotError::InternalServer(ref cause) => write!(f, "{}", cause),
            StartSnapshotError::RequestThrottled(ref cause) => write!(f, "{}", cause),
            StartSnapshotError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
            StartSnapshotError::ServiceQuotaExceeded(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for StartSnapshotError {}
/// Trait representing the capabilities of the Amazon EBS API. Amazon EBS clients implement this trait.
#[async_trait]
pub trait Ebs {
    /// <p>Seals and completes the snapshot after all of the required blocks of data have been written to it. Completing the snapshot changes the status to <code>completed</code>. You cannot write new blocks to a snapshot after it has been completed.</p>
    async fn complete_snapshot(
        &self,
        input: CompleteSnapshotRequest,
    ) -> Result<CompleteSnapshotResponse, RusotoError<CompleteSnapshotError>>;

    /// <p>Returns the data in a block in an Amazon Elastic Block Store snapshot.</p>
    async fn get_snapshot_block(
        &self,
        input: GetSnapshotBlockRequest,
    ) -> Result<GetSnapshotBlockResponse, RusotoError<GetSnapshotBlockError>>;

    /// <p>Returns information about the blocks that are different between two Amazon Elastic Block Store snapshots of the same volume/snapshot lineage.</p>
    async fn list_changed_blocks(
        &self,
        input: ListChangedBlocksRequest,
    ) -> Result<ListChangedBlocksResponse, RusotoError<ListChangedBlocksError>>;

    /// <p>Returns information about the blocks in an Amazon Elastic Block Store snapshot.</p>
    async fn list_snapshot_blocks(
        &self,
        input: ListSnapshotBlocksRequest,
    ) -> Result<ListSnapshotBlocksResponse, RusotoError<ListSnapshotBlocksError>>;

    /// <p>Writes a block of data to a snapshot. If the specified block contains data, the existing data is overwritten. The target snapshot must be in the <code>pending</code> state.</p> <p>Data written to a snapshot must be aligned with 512-byte sectors.</p>
    async fn put_snapshot_block(
        &self,
        input: PutSnapshotBlockRequest,
    ) -> Result<PutSnapshotBlockResponse, RusotoError<PutSnapshotBlockError>>;

    /// <p>Creates a new Amazon EBS snapshot. The new snapshot enters the <code>pending</code> state after the request completes. </p> <p>After creating the snapshot, use <a href="https://docs.aws.amazon.com/ebs/latest/APIReference/API_PutSnapshotBlock.html"> PutSnapshotBlock</a> to write blocks of data to the snapshot.</p>
    async fn start_snapshot(
        &self,
        input: StartSnapshotRequest,
    ) -> Result<StartSnapshotResponse, RusotoError<StartSnapshotError>>;
}
/// A client for the Amazon EBS API.
#[derive(Clone)]
pub struct EbsClient {
    client: Client,
    region: region::Region,
}

impl EbsClient {
    /// Creates a client backed by the default tokio event loop.
    ///
    /// The client will use the default credentials provider and tls client.
    pub fn new(region: region::Region) -> EbsClient {
        EbsClient {
            client: Client::shared(),
            region,
        }
    }

    pub fn new_with<P, D>(
        request_dispatcher: D,
        credentials_provider: P,
        region: region::Region,
    ) -> EbsClient
    where
        P: ProvideAwsCredentials + Send + Sync + 'static,
        D: DispatchSignedRequest + Send + Sync + 'static,
    {
        EbsClient {
            client: Client::new_with(credentials_provider, request_dispatcher),
            region,
        }
    }

    pub fn new_with_client(client: Client, region: region::Region) -> EbsClient {
        EbsClient { client, region }
    }
}

#[async_trait]
impl Ebs for EbsClient {
    /// <p>Seals and completes the snapshot after all of the required blocks of data have been written to it. Completing the snapshot changes the status to <code>completed</code>. You cannot write new blocks to a snapshot after it has been completed.</p>
    #[allow(unused_mut)]
    async fn complete_snapshot(
        &self,
        input: CompleteSnapshotRequest,
    ) -> Result<CompleteSnapshotResponse, RusotoError<CompleteSnapshotError>> {
        let request_uri = format!(
            "/snapshots/completion/{snapshot_id}",
            snapshot_id = input.snapshot_id
        );

        let mut request = SignedRequest::new("POST", "ebs", &self.region, &request_uri);
        request.set_content_type("application/x-amz-json-1.1".to_owned());

        request.add_header(
            "x-amz-ChangedBlocksCount",
            &input.changed_blocks_count.to_string(),
        );
        request.add_optional_header("x-amz-Checksum", input.checksum.as_ref());
        request.add_optional_header(
            "x-amz-Checksum-Aggregation-Method",
            input.checksum_aggregation_method.as_ref(),
        );
        request.add_optional_header(
            "x-amz-Checksum-Algorithm",
            input.checksum_algorithm.as_ref(),
        );

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.as_u16() == 202 {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let result = proto::json::ResponsePayload::new(&response)
                .deserialize::<CompleteSnapshotResponse, _>()?;

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(CompleteSnapshotError::from_response(response))
        }
    }

    /// <p>Returns the data in a block in an Amazon Elastic Block Store snapshot.</p>
    #[allow(unused_mut)]
    async fn get_snapshot_block(
        &self,
        input: GetSnapshotBlockRequest,
    ) -> Result<GetSnapshotBlockResponse, RusotoError<GetSnapshotBlockError>> {
        let request_uri = format!(
            "/snapshots/{snapshot_id}/blocks/{block_index}",
            block_index = input.block_index,
            snapshot_id = input.snapshot_id
        );

        let mut request = SignedRequest::new("GET", "ebs", &self.region, &request_uri);
        request.set_content_type("application/x-amz-json-1.1".to_owned());

        let mut params = Params::new();
        params.put("blockToken", &input.block_token);
        request.set_params(params);

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.is_success() {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;

            let mut result = GetSnapshotBlockResponse::default();
            result.block_data = Some(response.body);

            result.checksum = response.headers.remove("x-amz-Checksum");
            result.checksum_algorithm = response.headers.remove("x-amz-Checksum-Algorithm");
            result.data_length = response
                .headers
                .remove("x-amz-Data-Length")
                .map(|value| value.parse::<i64>().unwrap());

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(GetSnapshotBlockError::from_response(response))
        }
    }

    /// <p>Returns information about the blocks that are different between two Amazon Elastic Block Store snapshots of the same volume/snapshot lineage.</p>
    #[allow(unused_mut)]
    async fn list_changed_blocks(
        &self,
        input: ListChangedBlocksRequest,
    ) -> Result<ListChangedBlocksResponse, RusotoError<ListChangedBlocksError>> {
        let request_uri = format!(
            "/snapshots/{second_snapshot_id}/changedblocks",
            second_snapshot_id = input.second_snapshot_id
        );

        let mut request = SignedRequest::new("GET", "ebs", &self.region, &request_uri);
        request.set_content_type("application/x-amz-json-1.1".to_owned());

        let mut params = Params::new();
        if let Some(ref x) = input.first_snapshot_id {
            params.put("firstSnapshotId", x);
        }
        if let Some(ref x) = input.max_results {
            params.put("maxResults", x);
        }
        if let Some(ref x) = input.next_token {
            params.put("pageToken", x);
        }
        if let Some(ref x) = input.starting_block_index {
            params.put("startingBlockIndex", x);
        }
        request.set_params(params);

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.is_success() {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let result = proto::json::ResponsePayload::new(&response)
                .deserialize::<ListChangedBlocksResponse, _>()?;

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(ListChangedBlocksError::from_response(response))
        }
    }

    /// <p>Returns information about the blocks in an Amazon Elastic Block Store snapshot.</p>
    #[allow(unused_mut)]
    async fn list_snapshot_blocks(
        &self,
        input: ListSnapshotBlocksRequest,
    ) -> Result<ListSnapshotBlocksResponse, RusotoError<ListSnapshotBlocksError>> {
        let request_uri = format!(
            "/snapshots/{snapshot_id}/blocks",
            snapshot_id = input.snapshot_id
        );

        let mut request = SignedRequest::new("GET", "ebs", &self.region, &request_uri);
        request.set_content_type("application/x-amz-json-1.1".to_owned());

        let mut params = Params::new();
        if let Some(ref x) = input.max_results {
            params.put("maxResults", x);
        }
        if let Some(ref x) = input.next_token {
            params.put("pageToken", x);
        }
        if let Some(ref x) = input.starting_block_index {
            params.put("startingBlockIndex", x);
        }
        request.set_params(params);

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.is_success() {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let result = proto::json::ResponsePayload::new(&response)
                .deserialize::<ListSnapshotBlocksResponse, _>()?;

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(ListSnapshotBlocksError::from_response(response))
        }
    }

    /// <p>Writes a block of data to a snapshot. If the specified block contains data, the existing data is overwritten. The target snapshot must be in the <code>pending</code> state.</p> <p>Data written to a snapshot must be aligned with 512-byte sectors.</p>
    #[allow(unused_mut)]
    async fn put_snapshot_block(
        &self,
        input: PutSnapshotBlockRequest,
    ) -> Result<PutSnapshotBlockResponse, RusotoError<PutSnapshotBlockError>> {
        let request_uri = format!(
            "/snapshots/{snapshot_id}/blocks/{block_index}",
            block_index = input.block_index,
            snapshot_id = input.snapshot_id
        );

        let mut request = SignedRequest::new("PUT", "ebs", &self.region, &request_uri);
        request.set_content_type("application/x-amz-json-1.1".to_owned());

        let encoded = Some(input.block_data.to_owned());
        request.set_payload(encoded);
        request.add_header("x-amz-Checksum", &input.checksum.to_string());
        request.add_header(
            "x-amz-Checksum-Algorithm",
            &input.checksum_algorithm.to_string(),
        );
        request.add_header("x-amz-Data-Length", &input.data_length.to_string());
        request.add_optional_header("x-amz-Progress", input.progress.as_ref());

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.as_u16() == 201 {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let mut result = proto::json::ResponsePayload::new(&response)
                .deserialize::<PutSnapshotBlockResponse, _>()?;
            result.checksum = response.headers.remove("x-amz-Checksum");
            result.checksum_algorithm = response.headers.remove("x-amz-Checksum-Algorithm");

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(PutSnapshotBlockError::from_response(response))
        }
    }

    /// <p>Creates a new Amazon EBS snapshot. The new snapshot enters the <code>pending</code> state after the request completes. </p> <p>After creating the snapshot, use <a href="https://docs.aws.amazon.com/ebs/latest/APIReference/API_PutSnapshotBlock.html"> PutSnapshotBlock</a> to write blocks of data to the snapshot.</p>
    #[allow(unused_mut)]
    async fn start_snapshot(
        &self,
        input: StartSnapshotRequest,
    ) -> Result<StartSnapshotResponse, RusotoError<StartSnapshotError>> {
        let request_uri = "/snapshots";

        let mut request = SignedRequest::new("POST", "ebs", &self.region, &request_uri);
        request.set_content_type("application/x-amz-json-1.1".to_owned());

        let encoded = Some(serde_json::to_vec(&input).unwrap());
        request.set_payload(encoded);

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.as_u16() == 201 {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let result = proto::json::ResponsePayload::new(&response)
                .deserialize::<StartSnapshotResponse, _>()?;

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(StartSnapshotError::from_response(response))
        }
    }
}