basaltic-sdk-rust 0.9.1

Official typed asynchronous Rust SDK for Basaltic
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
//! Generated typed wire models. Unknown string enum values are retained.
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct KeyResponse {
    #[serde(rename = "key", default, skip_serializing_if = "Option::is_none")]
    pub key: Option<Key>,
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Key {
    #[serde(rename = "id")]
    pub id: String,

    #[serde(rename = "crn")]
    pub crn: String,
    /// Resource names must not start with the literal crn: prefix or be UUIDs (canonical, compact, braced, or urn:uuid: forms, in either case).
    #[serde(rename = "name")]
    pub name: String,

    #[serde(
        rename = "description",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub description: Option<String>,

    #[serde(rename = "tags")]
    pub tags: Tags,

    #[serde(rename = "key_spec")]
    pub key_spec: KeySpec,

    #[serde(rename = "key_usage")]
    pub key_usage: KeyUsage,

    #[serde(rename = "state")]
    pub state: KeyState,
    /// Present and true on platform-owned envelope keys (credential master, JWT signer, …), which are visible but not yours to operate on. Omitted on customer keys. Console and CLI read it to hide the destructive actions.
    #[serde(rename = "system", default, skip_serializing_if = "Option::is_none")]
    pub system: Option<bool>,
    /// When deletion was requested. Null for active keys and historical pending deletions whose request time is unknown.
    #[serde(
        rename = "deleted_at",
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::response::present_nullable"
    )]
    pub deleted_at: Option<crate::Nullable<String>>,
    /// Chosen whole-day window. Null for active keys and historical pending deletions whose window is unknown.
    #[serde(
        rename = "recovery_window_days",
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::response::present_nullable"
    )]
    pub recovery_window_days: Option<crate::Nullable<i64>>,
    /// Set only while state=pending_deletion. The key (and its cryptographic material) is hard-deleted once now() reaches this timestamp; CancelKeyDeletion before then returns the key to state=disabled.
    #[serde(
        rename = "scheduled_purge_at",
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::response::present_nullable"
    )]
    pub scheduled_purge_at: Option<crate::Nullable<String>>,

    #[serde(rename = "created_at")]
    pub created_at: String,

    #[serde(rename = "updated_at")]
    pub updated_at: String,
}

pub type Tags = std::collections::BTreeMap<String, String>;

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum KeySpec {
    Aes256,
    Rsa2048,
    Rsa4096,
    EcdsaP256,
    Unknown(String),
}
impl KeySpec {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Aes256 => "aes-256",
            Self::Rsa2048 => "rsa-2048",
            Self::Rsa4096 => "rsa-4096",
            Self::EcdsaP256 => "ecdsa-p256",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for KeySpec {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for KeySpec {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(match value.as_str() {
            "aes-256" => Self::Aes256,
            "rsa-2048" => Self::Rsa2048,
            "rsa-4096" => Self::Rsa4096,
            "ecdsa-p256" => Self::EcdsaP256,
            _ => Self::Unknown(value),
        })
    }
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum KeyUsage {
    EncryptDecrypt,
    SignVerify,
    Unknown(String),
}
impl KeyUsage {
    pub fn as_str(&self) -> &str {
        match self {
            Self::EncryptDecrypt => "encrypt_decrypt",
            Self::SignVerify => "sign_verify",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for KeyUsage {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for KeyUsage {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(match value.as_str() {
            "encrypt_decrypt" => Self::EncryptDecrypt,
            "sign_verify" => Self::SignVerify,
            _ => Self::Unknown(value),
        })
    }
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum KeyState {
    Enabled,
    Disabled,
    PendingDeletion,
    Unknown(String),
}
impl KeyState {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Enabled => "enabled",
            Self::Disabled => "disabled",
            Self::PendingDeletion => "pending_deletion",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for KeyState {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for KeyState {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(match value.as_str() {
            "enabled" => Self::Enabled,
            "disabled" => Self::Disabled,
            "pending_deletion" => Self::PendingDeletion,
            _ => Self::Unknown(value),
        })
    }
}

pub type CancelKeyDeletionResponse = KeyResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CreateKeyRequestInput {
    /// Unique per account. Surfaces in the CRN (crn:kms:&lt;region&gt;:&lt;account&gt;:key/&lt;name&gt;) — letters, digits, dot, dash, underscore. Resource names must not start with the literal crn: prefix or be UUIDs (canonical, compact, braced, or urn:uuid: forms, in either case).
    #[serde(rename = "name")]
    pub name: String,

    #[serde(
        rename = "description",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub description: Option<String>,

    #[serde(rename = "tags", default, skip_serializing_if = "Option::is_none")]
    pub tags: Option<TagsInput>,

    #[serde(rename = "key_spec")]
    pub key_spec: KeySpecInput,
    /// Required for RSA specs (both encrypt_decrypt and sign_verify are valid). Defaults to encrypt_decrypt for AES, sign_verify for ECDSA.
    #[serde(rename = "key_usage", default, skip_serializing_if = "Option::is_none")]
    pub key_usage: Option<KeyUsageInput>,
}
impl CreateKeyRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(name: String, key_spec: KeySpecInput) -> Self {
        Self {
            name,
            description: None,
            tags: None,
            key_spec,
            key_usage: None,
        }
    }
}

pub type TagsInput = std::collections::BTreeMap<String, String>;

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum KeySpecInput {
    Aes256,
    Rsa2048,
    Rsa4096,
    EcdsaP256,
    Unknown(String),
}
impl KeySpecInput {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Aes256 => "aes-256",
            Self::Rsa2048 => "rsa-2048",
            Self::Rsa4096 => "rsa-4096",
            Self::EcdsaP256 => "ecdsa-p256",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for KeySpecInput {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for KeySpecInput {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(match value.as_str() {
            "aes-256" => Self::Aes256,
            "rsa-2048" => Self::Rsa2048,
            "rsa-4096" => Self::Rsa4096,
            "ecdsa-p256" => Self::EcdsaP256,
            _ => Self::Unknown(value),
        })
    }
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum KeyUsageInput {
    EncryptDecrypt,
    SignVerify,
    Unknown(String),
}
impl KeyUsageInput {
    pub fn as_str(&self) -> &str {
        match self {
            Self::EncryptDecrypt => "encrypt_decrypt",
            Self::SignVerify => "sign_verify",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for KeyUsageInput {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for KeyUsageInput {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(match value.as_str() {
            "encrypt_decrypt" => Self::EncryptDecrypt,
            "sign_verify" => Self::SignVerify,
            _ => Self::Unknown(value),
        })
    }
}

pub type CreateKeyBody = CreateKeyRequestInput;

pub type CreateKeyResponse = KeyResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct DecryptRequestInput {
    /// Base64-encoded ciphertext produced by Encrypt.
    #[serde(rename = "ciphertext")]
    pub ciphertext: String,
    /// Optional base64-encoded AAD. Must match what was supplied at Encrypt — different value fails the tag check.
    #[serde(rename = "aad", default, skip_serializing_if = "Option::is_none")]
    pub aad: Option<String>,
}
impl DecryptRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(ciphertext: String) -> Self {
        Self {
            ciphertext,
            aad: None,
        }
    }
}

pub type DecryptBody = DecryptRequestInput;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct DecryptResponse2 {
    /// Base64-encoded plaintext.
    #[serde(rename = "plaintext", default, skip_serializing_if = "Option::is_none")]
    pub plaintext: Option<String>,
}

pub type DecryptResponse = DecryptResponse2;

pub type DisableKeyResponse = KeyResponse;

pub type EnableKeyResponse = KeyResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct EncryptRequestInput {
    /// Base64-encoded plaintext.
    #[serde(rename = "plaintext")]
    pub plaintext: String,
    /// Optional base64-encoded additional authenticated data (AES-GCM AEAD). Must be supplied verbatim to Decrypt; mismatch fails the auth tag check. Ignored for asymmetric keys.
    #[serde(rename = "aad", default, skip_serializing_if = "Option::is_none")]
    pub aad: Option<String>,
}
impl EncryptRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(plaintext: String) -> Self {
        Self {
            plaintext,
            aad: None,
        }
    }
}

pub type EncryptBody = EncryptRequestInput;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct EncryptResponse2 {
    /// Base64-encoded opaque, versioned ciphertext. Store verbatim; do not parse its internal layout. Decrypt selects the original material version automatically after rotation.
    #[serde(
        rename = "ciphertext",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub ciphertext: Option<String>,
    /// CRN of the key the ciphertext was sealed under.
    #[serde(rename = "key_crn", default, skip_serializing_if = "Option::is_none")]
    pub key_crn: Option<String>,
}

pub type EncryptResponse = EncryptResponse2;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct GenerateDataKeyRequestInput {
    /// Size of the generated data key in bytes: 16 (AES-128), 32 (AES-256, the default) or 64 (HMAC-SHA512). No other size is supported; any other value fails the operation.
    #[serde(
        rename = "number_of_bytes",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub number_of_bytes: Option<i64>,
}

pub type GenerateDataKeyBody = GenerateDataKeyRequestInput;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct GenerateDataKeyResponse2 {
    /// Base64-encoded plaintext data key. Use immediately, then drop — callers must NOT persist this. Re-derive it on demand by calling Decrypt with the stored ciphertext.
    #[serde(rename = "plaintext", default, skip_serializing_if = "Option::is_none")]
    pub plaintext: Option<String>,
    /// Base64-encoded data key wrapped under the KMS key. Safe to store at rest alongside the data the key protects.
    #[serde(
        rename = "ciphertext",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub ciphertext: Option<String>,
}

pub type GenerateDataKeyResponse = GenerateDataKeyResponse2;

pub type GetKeyResponse = KeyResponse;

pub type GetKeyResource = Key;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct GetKeyScope {
    #[serde(rename = "limit", default, skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,

    #[serde(rename = "state", default, skip_serializing_if = "Option::is_none")]
    pub state: Option<KeyStateInput>,
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum KeyStateInput {
    Enabled,
    Disabled,
    PendingDeletion,
    Unknown(String),
}
impl KeyStateInput {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Enabled => "enabled",
            Self::Disabled => "disabled",
            Self::PendingDeletion => "pending_deletion",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for KeyStateInput {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for KeyStateInput {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(match value.as_str() {
            "enabled" => Self::Enabled,
            "disabled" => Self::Disabled,
            "pending_deletion" => Self::PendingDeletion,
            _ => Self::Unknown(value),
        })
    }
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct KeyRotationResponse {
    #[serde(rename = "rotation")]
    pub rotation: KeyRotation,
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct KeyRotation {
    #[serde(rename = "id")]
    pub id: String,

    #[serde(rename = "key_id")]
    pub key_id: String,

    #[serde(rename = "trigger")]
    pub trigger: KeyRotationTrigger,
    /// Pending work is durable. Reconciliation_required means the backend outcome is unknown; no second rotation is sent and further requests are blocked until resolved. Failed means the request was cancelled before dispatch.
    #[serde(rename = "status")]
    pub status: KeyRotationStatus,

    #[serde(rename = "previous_version")]
    pub previous_version: crate::Nullable<i64>,
    /// New material version, populated only on success.
    #[serde(rename = "key_version")]
    pub key_version: crate::Nullable<i64>,

    #[serde(rename = "requested_at")]
    pub requested_at: String,

    #[serde(rename = "started_at")]
    pub started_at: crate::Nullable<String>,

    #[serde(rename = "completed_at")]
    pub completed_at: crate::Nullable<String>,
    /// Machine-readable cancellation or reconciliation reason. Null on success.
    #[serde(rename = "error_code")]
    pub error_code: crate::Nullable<String>,
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum KeyRotationTrigger {
    OnDemand,
    Automatic,
    Unknown(String),
}
impl KeyRotationTrigger {
    pub fn as_str(&self) -> &str {
        match self {
            Self::OnDemand => "on_demand",
            Self::Automatic => "automatic",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for KeyRotationTrigger {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for KeyRotationTrigger {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(match value.as_str() {
            "on_demand" => Self::OnDemand,
            "automatic" => Self::Automatic,
            _ => Self::Unknown(value),
        })
    }
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum KeyRotationStatus {
    Pending,
    InProgress,
    ReconciliationRequired,
    Succeeded,
    Failed,
    Unknown(String),
}
impl KeyRotationStatus {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Pending => "pending",
            Self::InProgress => "in_progress",
            Self::ReconciliationRequired => "reconciliation_required",
            Self::Succeeded => "succeeded",
            Self::Failed => "failed",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for KeyRotationStatus {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for KeyRotationStatus {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(match value.as_str() {
            "pending" => Self::Pending,
            "in_progress" => Self::InProgress,
            "reconciliation_required" => Self::ReconciliationRequired,
            "succeeded" => Self::Succeeded,
            "failed" => Self::Failed,
            _ => Self::Unknown(value),
        })
    }
}

pub type GetKeyRotationResponse = KeyRotationResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct KeyRotationStatusResponse {
    #[serde(rename = "rotation")]
    pub rotation: KeyRotationStatus2,
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct KeyRotationStatus2 {
    /// Automatic rotation is opt-in and defaults to false.
    #[serde(rename = "enabled")]
    pub enabled: bool,

    #[serde(rename = "rotation_period_days")]
    pub rotation_period_days: i64,
    /// Next scheduled rotation, or null when automatic rotation is disabled. Disabled keys are skipped until re-enabled.
    #[serde(rename = "next_rotation_at")]
    pub next_rotation_at: crate::Nullable<String>,
    /// Current material version used for new cryptographic operations.
    #[serde(rename = "current_version")]
    pub current_version: i64,
}

pub type GetKeyRotationStatusResponse = KeyRotationStatusResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct GetPublicKeyParameters {
    #[serde(
        rename = "key_version",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub key_version: Option<i64>,
}

pub type GetPublicKeyQuery = GetPublicKeyParameters;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PublicKeyResponse {
    #[serde(rename = "key_crn")]
    pub key_crn: String,

    #[serde(rename = "key_version")]
    pub key_version: i64,

    #[serde(rename = "key_spec")]
    pub key_spec: KeySpec,

    #[serde(rename = "key_usage")]
    pub key_usage: KeyUsage,
    /// PEM-encoded SubjectPublicKeyInfo for the requested asymmetric material version. No private material is exported.
    #[serde(rename = "public_key")]
    pub public_key: String,
}

pub type GetPublicKeyResponse = PublicKeyResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct ListKeyRotationsParameters {
    #[serde(rename = "limit", default, skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,

    #[serde(rename = "marker", default, skip_serializing_if = "Option::is_none")]
    pub marker: Option<String>,
}

pub type ListKeyRotationsQuery = ListKeyRotationsParameters;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct KeyRotationListResponse {
    #[serde(rename = "rotations")]
    pub rotations: Vec<KeyRotation>,

    #[serde(rename = "meta")]
    pub meta: PaginationMeta,
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct PaginationMeta {
    /// Total number of items
    #[serde(rename = "total", default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    /// Number of items per page
    #[serde(rename = "limit", default, skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
    /// Opaque cursor for the next page. Pass it back as the `marker` query parameter; treat it as a token, not a value to parse.
    #[serde(rename = "marker", default, skip_serializing_if = "Option::is_none")]
    pub marker: Option<String>,
    /// Whether there are more items
    #[serde(rename = "has_more", default, skip_serializing_if = "Option::is_none")]
    pub has_more: Option<bool>,
}

pub type ListKeyRotationsResponse = KeyRotationListResponse;

pub type ListKeyRotationsItem = KeyRotation;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct ListKeysParameters {
    #[serde(rename = "limit", default, skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,

    #[serde(rename = "marker", default, skip_serializing_if = "Option::is_none")]
    pub marker: Option<String>,

    #[serde(rename = "state", default, skip_serializing_if = "Option::is_none")]
    pub state: Option<KeyStateInput>,

    #[serde(rename = "name", default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,

    #[serde(rename = "crn", default, skip_serializing_if = "Option::is_none")]
    pub crn: Option<String>,
}

pub type ListKeysQuery = ListKeysParameters;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct KeyListResponse {
    #[serde(rename = "keys", default, skip_serializing_if = "Option::is_none")]
    pub keys: Option<Vec<Key>>,

    #[serde(rename = "meta", default, skip_serializing_if = "Option::is_none")]
    pub meta: Option<PaginationMeta>,
}

pub type ListKeysResponse = KeyListResponse;

pub type ListKeysItem = Key;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RewrapRequestInput {
    /// Base64-encoded ciphertext or wrapped data key produced by this KMS key. AAD is neither required nor changed.
    #[serde(rename = "ciphertext")]
    pub ciphertext: String,
}
impl RewrapRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(ciphertext: String) -> Self {
        Self { ciphertext }
    }
}

pub type RewrapBody = RewrapRequestInput;

pub type RewrapResponse = EncryptResponse2;

pub type RotateKeyOnDemandResponse = KeyRotationResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct ScheduleKeyDeletionRequestInput {
    /// How long the key sits in pending_deletion before it is hard-deleted. Matches AWS KMS bounds; the deletion can be cancelled at any point inside the window.
    #[serde(
        rename = "recovery_window_days",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub recovery_window_days: Option<i64>,
}

pub type ScheduleKeyDeletionBody = ScheduleKeyDeletionRequestInput;

pub type ScheduleKeyDeletionResponse = KeyResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SetKeyRotationRequestInput {
    #[serde(rename = "enabled")]
    pub enabled: bool,
    /// Whole days between rotations. Omission selects 365 days.
    #[serde(
        rename = "rotation_period_days",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub rotation_period_days: Option<i64>,
}
impl SetKeyRotationRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(enabled: bool) -> Self {
        Self {
            enabled,
            rotation_period_days: None,
        }
    }
}

pub type SetKeyRotationBody = SetKeyRotationRequestInput;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct KeyRotationPolicyResponse {
    #[serde(rename = "rotation")]
    pub rotation: KeyRotationPolicy,
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct KeyRotationPolicy {
    /// Automatic rotation is opt-in and defaults to false.
    #[serde(rename = "enabled")]
    pub enabled: bool,

    #[serde(rename = "rotation_period_days")]
    pub rotation_period_days: i64,
    /// Next scheduled rotation, or null when automatic rotation is disabled. Disabled keys are skipped until re-enabled.
    #[serde(rename = "next_rotation_at")]
    pub next_rotation_at: crate::Nullable<String>,
}

pub type SetKeyRotationResponse = KeyRotationPolicyResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SignRequestInput {
    /// Base64-encoded message to sign. The service hashes it via SHA-256 server-side, so pass the raw payload — do not pre-hash.
    #[serde(rename = "message")]
    pub message: String,

    #[serde(
        rename = "signing_algorithm",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub signing_algorithm: Option<SigningAlgorithmInput>,
}
impl SignRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(message: String) -> Self {
        Self {
            message,
            signing_algorithm: None,
        }
    }
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum SigningAlgorithmInput {
    RSASSAPSSSHA256,
    RSASSAPKCS1V15SHA256,
    ECDSASHA256,
    Unknown(String),
}
impl SigningAlgorithmInput {
    pub fn as_str(&self) -> &str {
        match self {
            Self::RSASSAPSSSHA256 => "RSASSA_PSS_SHA_256",
            Self::RSASSAPKCS1V15SHA256 => "RSASSA_PKCS1_V1_5_SHA_256",
            Self::ECDSASHA256 => "ECDSA_SHA_256",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for SigningAlgorithmInput {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for SigningAlgorithmInput {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(match value.as_str() {
            "RSASSA_PSS_SHA_256" => Self::RSASSAPSSSHA256,
            "RSASSA_PKCS1_V1_5_SHA_256" => Self::RSASSAPKCS1V15SHA256,
            "ECDSA_SHA_256" => Self::ECDSASHA256,
            _ => Self::Unknown(value),
        })
    }
}

pub type SignBody = SignRequestInput;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct SignResponse2 {
    /// Material version that produced this signature. Persist with the signature for explicit verification and public-key retrieval.
    #[serde(
        rename = "key_version",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub key_version: Option<i64>,
    /// Base64-encoded signature. RSA-PSS: PKCS#1 octet string with saltLen=hashLen=32. ECDSA: ASN.1 DER (r,s) tuple per ANSI X9.62.
    #[serde(rename = "signature", default, skip_serializing_if = "Option::is_none")]
    pub signature: Option<String>,

    #[serde(
        rename = "signing_algorithm",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub signing_algorithm: Option<SigningAlgorithm>,
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum SigningAlgorithm {
    RSASSAPSSSHA256,
    RSASSAPKCS1V15SHA256,
    ECDSASHA256,
    Unknown(String),
}
impl SigningAlgorithm {
    pub fn as_str(&self) -> &str {
        match self {
            Self::RSASSAPSSSHA256 => "RSASSA_PSS_SHA_256",
            Self::RSASSAPKCS1V15SHA256 => "RSASSA_PKCS1_V1_5_SHA_256",
            Self::ECDSASHA256 => "ECDSA_SHA_256",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for SigningAlgorithm {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for SigningAlgorithm {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(match value.as_str() {
            "RSASSA_PSS_SHA_256" => Self::RSASSAPSSSHA256,
            "RSASSA_PKCS1_V1_5_SHA_256" => Self::RSASSAPKCS1V15SHA256,
            "ECDSA_SHA_256" => Self::ECDSASHA256,
            _ => Self::Unknown(value),
        })
    }
}

pub type SignResponse = SignResponse2;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct UpdateKeyRequestInput {
    #[serde(
        rename = "description",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub description: Option<String>,

    #[serde(rename = "tags", default, skip_serializing_if = "Option::is_none")]
    pub tags: Option<TagsInput>,
}

pub type UpdateKeyBody = UpdateKeyRequestInput;

pub type UpdateKeyResponse = KeyResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VerifyRequestInput {
    /// Optional material version returned by Sign. When omitted, all retained public-key versions are tried for compatibility with older signatures.
    #[serde(
        rename = "key_version",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub key_version: Option<i64>,
    /// Base64-encoded original message.
    #[serde(rename = "message")]
    pub message: String,
    /// Base64-encoded signature produced by Sign.
    #[serde(rename = "signature")]
    pub signature: String,

    #[serde(
        rename = "signing_algorithm",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub signing_algorithm: Option<SigningAlgorithmInput>,
}
impl VerifyRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(message: String, signature: String) -> Self {
        Self {
            key_version: None,
            message,
            signature,
            signing_algorithm: None,
        }
    }
}

pub type VerifyBody = VerifyRequestInput;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct VerifyResponse2 {
    /// True if the signature verifies against the supplied message under the key's public half. A clean mismatch returns false with no error; backend / parameter failures surface as a normal error response.
    #[serde(
        rename = "signature_valid",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub signature_valid: Option<bool>,
}

pub type VerifyResponse = VerifyResponse2;