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
//! Generated typed wire models. Unknown string enum values are retained.
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VPCAssociationRequestInput {
    /// Account-owned VPC UUID or network/vpc CRN to associate with this private zone. Bare names return 400 with "VPC references on DNS zones must be a UUID or a CRN, which carries the region". CRNs resolve in their named region; UUIDs search all regions enabled for DNS. Missing, foreign-account or unconfigured-region VPCs return 404. Incomplete UUID searches or duplicate regional UUID identities fail with a server error. The response contains the canonical VPC UUID.
    #[serde(rename = "vpc")]
    pub vpc: String,
}
impl VPCAssociationRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(vpc: String) -> Self {
        Self { vpc }
    }
}

pub type AssociateZoneVPCBody = VPCAssociationRequestInput;

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

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

pub type AssociateZoneVPCResponse = VPCAssociationAccepted;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RecordCreateRequestInput {
    /// Record name (FQDN).
    #[serde(rename = "name")]
    pub name: String,

    #[serde(rename = "type")]
    pub type_: RecordTypeInput,

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

    #[serde(rename = "values")]
    pub values: Vec<RecordValueInput>,
}
impl RecordCreateRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(name: String, type_: RecordTypeInput, values: Vec<RecordValueInput>) -> Self {
        Self {
            name,
            type_,
            ttl: None,
            values,
        }
    }
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum RecordTypeInput {
    A,
    AAAA,
    AFSDB,
    APL,
    CAA,
    CERT,
    CNAME,
    CSYNC,
    DHCID,
    DNAME,
    EUI48,
    EUI64,
    HINFO,
    HTTPS,
    IPSECKEY,
    KX,
    L32,
    L64,
    LOC,
    LP,
    MX,
    NAPTR,
    NID,
    NS,
    OPENPGPKEY,
    PTR,
    RKEY,
    RP,
    SMIMEA,
    SPF,
    SRV,
    SSHFP,
    SVCB,
    TLSA,
    TXT,
    URI,
    Unknown(String),
}
impl RecordTypeInput {
    pub fn as_str(&self) -> &str {
        match self {
            Self::A => "A",
            Self::AAAA => "AAAA",
            Self::AFSDB => "AFSDB",
            Self::APL => "APL",
            Self::CAA => "CAA",
            Self::CERT => "CERT",
            Self::CNAME => "CNAME",
            Self::CSYNC => "CSYNC",
            Self::DHCID => "DHCID",
            Self::DNAME => "DNAME",
            Self::EUI48 => "EUI48",
            Self::EUI64 => "EUI64",
            Self::HINFO => "HINFO",
            Self::HTTPS => "HTTPS",
            Self::IPSECKEY => "IPSECKEY",
            Self::KX => "KX",
            Self::L32 => "L32",
            Self::L64 => "L64",
            Self::LOC => "LOC",
            Self::LP => "LP",
            Self::MX => "MX",
            Self::NAPTR => "NAPTR",
            Self::NID => "NID",
            Self::NS => "NS",
            Self::OPENPGPKEY => "OPENPGPKEY",
            Self::PTR => "PTR",
            Self::RKEY => "RKEY",
            Self::RP => "RP",
            Self::SMIMEA => "SMIMEA",
            Self::SPF => "SPF",
            Self::SRV => "SRV",
            Self::SSHFP => "SSHFP",
            Self::SVCB => "SVCB",
            Self::TLSA => "TLSA",
            Self::TXT => "TXT",
            Self::URI => "URI",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for RecordTypeInput {
    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 RecordTypeInput {
    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() {
            "A" => Self::A,
            "AAAA" => Self::AAAA,
            "AFSDB" => Self::AFSDB,
            "APL" => Self::APL,
            "CAA" => Self::CAA,
            "CERT" => Self::CERT,
            "CNAME" => Self::CNAME,
            "CSYNC" => Self::CSYNC,
            "DHCID" => Self::DHCID,
            "DNAME" => Self::DNAME,
            "EUI48" => Self::EUI48,
            "EUI64" => Self::EUI64,
            "HINFO" => Self::HINFO,
            "HTTPS" => Self::HTTPS,
            "IPSECKEY" => Self::IPSECKEY,
            "KX" => Self::KX,
            "L32" => Self::L32,
            "L64" => Self::L64,
            "LOC" => Self::LOC,
            "LP" => Self::LP,
            "MX" => Self::MX,
            "NAPTR" => Self::NAPTR,
            "NID" => Self::NID,
            "NS" => Self::NS,
            "OPENPGPKEY" => Self::OPENPGPKEY,
            "PTR" => Self::PTR,
            "RKEY" => Self::RKEY,
            "RP" => Self::RP,
            "SMIMEA" => Self::SMIMEA,
            "SPF" => Self::SPF,
            "SRV" => Self::SRV,
            "SSHFP" => Self::SSHFP,
            "SVCB" => Self::SVCB,
            "TLSA" => Self::TLSA,
            "TXT" => Self::TXT,
            "URI" => Self::URI,
            _ => Self::Unknown(value),
        })
    }
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RecordValueInput {
    /// RDATA — wire representation per record type.
    #[serde(rename = "content")]
    pub content: String,
    /// Must be `false`. `true` is **refused**. There is nowhere to keep a value that is not served, so a disabled value used to be accepted, echoed back in the response, and then dropped — the staged value was gone by the next read, with the write having reported success. Refusing is the honest version. The field remains on the schema because the console and CLI send it on every value; only `true` is rejected. To take a value out of an RRset, remove it from `values`.
    #[serde(rename = "disabled", default, skip_serializing_if = "Option::is_none")]
    pub disabled: Option<bool>,
}
impl RecordValueInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(content: String) -> Self {
        Self {
            content,
            disabled: None,
        }
    }
}

pub type CreateRecordBody = RecordCreateRequestInput;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RecordResponse {
    #[serde(rename = "record")]
    pub record: Record,
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Record {
    #[serde(rename = "id")]
    pub id: String,
    /// Cloud Resource Name.
    #[serde(rename = "crn")]
    pub crn: String,
    /// Record name (FQDN).
    #[serde(rename = "name")]
    pub name: String,
    /// Record type. Customer records use one of the creatable RecordType values; reads also surface the platform-managed apex/DNSSEC types (SOA, NS, DNSKEY, DS, NSEC, RRSIG).
    #[serde(rename = "type")]
    pub type_: String,

    #[serde(rename = "ttl")]
    pub ttl: i64,
    /// True for platform-managed records (SOA, apex NS, and the DNSSEC set). Managed records are read-only — they cannot be updated or deleted through the API.
    #[serde(rename = "managed", default, skip_serializing_if = "Option::is_none")]
    pub managed: Option<bool>,

    #[serde(rename = "values")]
    pub values: Vec<RecordValue>,
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RecordValue {
    /// RDATA — wire representation per record type.
    #[serde(rename = "content")]
    pub content: String,
    /// Must be `false`. `true` is **refused**. There is nowhere to keep a value that is not served, so a disabled value used to be accepted, echoed back in the response, and then dropped — the staged value was gone by the next read, with the write having reported success. Refusing is the honest version. The field remains on the schema because the console and CLI send it on every value; only `true` is rejected. To take a value out of an RRset, remove it from `values`.
    #[serde(rename = "disabled", default, skip_serializing_if = "Option::is_none")]
    pub disabled: Option<bool>,
}

pub type CreateRecordResponse = RecordResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ZoneCreateRequestInput {
    /// Zone FQDN. 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,
    /// Free-form note stored with and returned on the zone.
    #[serde(
        rename = "description",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub description: Option<String>,
    /// `private` restricts the zone to the VPCs named in `vpcs` and requires at least one; `public` (the default) rejects `vpcs` outright rather than ignoring them. Cannot be changed afterwards.
    #[serde(
        rename = "visibility",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub visibility: Option<ZoneCreateRequestInputVisibility>,
    /// Sign the zone with DNSSEC. On unless you say otherwise, and almost every zone should leave it on. **Turn it off only if this domain is served by another DNS provider at the same time as us.** A signed zone puts our DS record at the parent, and that DS covers only the answers WE sign — so a validating resolver that happens to ask the other provider gets a signature it cannot verify and fails the lookup. Roughly half your queries, unpredictably, which is worse than either provider on its own. Unsigned is the only configuration that works for that setup today. Fixed at creation. Turning signing off later breaks the domain until the DS is withdrawn at the registrar and that withdrawal has propagated, which is a sequence this API cannot drive for you.
    #[serde(rename = "dnssec", default, skip_serializing_if = "Option::is_none")]
    pub dnssec: Option<bool>,
    /// Read the domain's records from the nameservers that serve it TODAY and copy them into this zone, before you move the delegation here. Worth asking for when you are migrating a live domain. The delegation is the ownership proof, so the moment you point your registrar at this zone is the moment we start answering for it — and an empty zone answers with nothing, which takes the site and the mail down until you have retyped everything. Runs in the background; the zone is created immediately. Poll GET /v1/zones/{zone_id}/record-import for the outcome. Best effort, and the result says how good it was. A zone transfer is exhaustive and almost always refused; the fallback queries a list of common names and cannot find a record it did not think to ask for. Check `record_import.complete` before you switch your old provider off. Records you have already created are never overwritten, and records this platform manages itself — the SOA, the DNSSEC chain, the zone's nameservers — are never imported.
    #[serde(
        rename = "import_existing_records",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub import_existing_records: Option<bool>,
    /// Account-owned VPC UUIDs or network/vpc CRNs the zone resolves in. Bare names are rejected with 400 because the request fixes no region. CRNs resolve in their named region; UUIDs search all regions enabled for DNS. Missing, foreign-account or unconfigured-region VPCs return 404. Incomplete UUID searches or duplicate regional UUID identities fail with a server error. References are deduplicated by UUID. Required when visibility=private, rejected when visibility=public. More can be associated later via POST /v1/zones/{zone_id}/vpc-associations.
    #[serde(rename = "vpcs", default, skip_serializing_if = "Option::is_none")]
    pub vpcs: Option<Vec<String>>,

    #[serde(rename = "tags", default, skip_serializing_if = "Option::is_none")]
    pub tags: Option<TagsInput>,
}
impl ZoneCreateRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(name: String) -> Self {
        Self {
            name,
            description: None,
            visibility: None,
            dnssec: None,
            import_existing_records: None,
            vpcs: None,
            tags: None,
        }
    }
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ZoneCreateRequestInputVisibility {
    Public,
    Private,
    Unknown(String),
}
impl ZoneCreateRequestInputVisibility {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Public => "public",
            Self::Private => "private",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for ZoneCreateRequestInputVisibility {
    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 ZoneCreateRequestInputVisibility {
    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() {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Unknown(value),
        })
    }
}

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

pub type CreateZoneBody = ZoneCreateRequestInput;

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

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct Zone {
    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    /// Cloud Resource Name.
    #[serde(rename = "crn", default, skip_serializing_if = "Option::is_none")]
    pub crn: Option<String>,
    /// Zone FQDN. 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", default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Free-form description, editable with PATCH.
    #[serde(
        rename = "description",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub description: Option<String>,
    /// Authoritative nameservers for the zone — the apex NS set. Copy this list verbatim into your registrar's nameserver configuration to delegate the zone to the platform. These names are unique to THIS zone: each carries a per-zone label, which is what makes the delegation double as the ownership proof (see `ownership`). Two zones for the same domain get different names, and the one the registrar points at is the one that serves. Use them exactly as written — Basaltic's bare nameserver names will not verify the zone.
    #[serde(
        rename = "nameservers",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub nameservers: Option<Vec<String>>,

    #[serde(rename = "soa", default, skip_serializing_if = "Option::is_none")]
    pub soa: Option<SOA>,
    /// `public` zones answer on the internet-facing nameservers; `private` zones answer only inside the VPCs associated with them (see the vpc-associations endpoints). Fixed at creation.
    #[serde(
        rename = "visibility",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub visibility: Option<ZoneVisibility>,

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

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

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

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct SOA {
    /// SOA `mname` — first authoritative nameserver for the zone.
    #[serde(
        rename = "primary_ns",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub primary_ns: Option<String>,
    /// SOA `rname` — the platform's DNS-operations contact. Stamped server-side; not customer-configurable.
    #[serde(
        rename = "admin_email",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub admin_email: Option<String>,

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

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

    #[serde(rename = "expire", default, skip_serializing_if = "Option::is_none")]
    pub expire: Option<i64>,
    /// NXDOMAIN cache TTL.
    #[serde(rename = "minimum", default, skip_serializing_if = "Option::is_none")]
    pub minimum: Option<i64>,
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ZoneVisibility {
    Public,
    Private,
    Unknown(String),
}
impl ZoneVisibility {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Public => "public",
            Self::Private => "private",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for ZoneVisibility {
    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 ZoneVisibility {
    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() {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Unknown(value),
        })
    }
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ZoneDNSSEC {
    #[serde(rename = "enabled")]
    pub enabled: bool,
    /// Key tag of the key-signing key — matches the DS records below.
    #[serde(
        rename = "ksk_key_tag",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub ksk_key_tag: Option<i64>,
    /// Key tag of the zone-signing key.
    #[serde(
        rename = "zsk_key_tag",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub zsk_key_tag: Option<i64>,
    /// DNSSEC algorithm number. 13 = ECDSA P-256 SHA-256.
    #[serde(rename = "algorithm", default, skip_serializing_if = "Option::is_none")]
    pub algorithm: Option<i64>,

    #[serde(
        rename = "ds_records",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub ds_records: Option<Vec<ZoneDSRecord>>,
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ZoneDSRecord {
    #[serde(rename = "key_tag")]
    pub key_tag: i64,

    #[serde(rename = "algorithm")]
    pub algorithm: i64,
    /// 2 = SHA-256.
    #[serde(rename = "digest_type")]
    pub digest_type: i64,

    #[serde(rename = "digest")]
    pub digest: String,
    /// Full zone-file form — `<key_tag> <algorithm> <digest_type> <digest>`.
    #[serde(rename = "rdata")]
    pub rdata: String,
}

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

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct ZoneOwnership {
    /// Whether the zone has proved ownership. Unverified zones do not resolve.
    #[serde(rename = "verified", default, skip_serializing_if = "Option::is_none")]
    pub verified: Option<bool>,
    /// When ownership was first proved. Absent while unverified.
    #[serde(
        rename = "verified_at",
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::response::present_nullable"
    )]
    pub verified_at: Option<crate::Nullable<String>>,
    /// When the proof was last re-confirmed. `verified_at` keeps meaning "first demonstrated" and does not move; this does, on every pass that passes. Absent until the zone has been re-confirmed at least once.
    #[serde(
        rename = "checked_at",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub checked_at: Option<String>,
    /// Present ONLY while the periodic re-proof is failing: the instant the zone stops answering unless it passes again. Absent means healthy. Each pass re-checks a failing zone, so reaching this date takes sustained failure, not one bad afternoon — a transient resolver problem clears itself on the next pass. To clear it deliberately, point the domain's delegation back at this zone's `nameservers` and POST /v1/zones/{zone_id}/verify-ownership. The organization's owner is emailed when this date is set, and again if the zone does stop resolving. A zone is never taken off the air before that message has gone out, so the date here is the earliest the zone can stop answering and never the only warning.
    #[serde(
        rename = "recheck_deadline",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub recheck_deadline: Option<String>,
}

pub type CreateZoneResponse = ZoneResponse;

pub type GetRecordResponse = RecordResponse;

pub type GetRecordResource = Record;

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

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

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

pub type GetZoneResponse = ZoneResponse;

pub type GetZoneResource = Zone;

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

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

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct ZoneRecordImport {
    /// `pending` while the background job runs. `complete` means the scan ran and what it found was applied — not that everything the domain has is now here; see `complete`. `pending` is bounded. A scan is capped well below the point at which this stops reporting it, so a job that dies without recording an outcome is reported as `failed` rather than staying `pending` for the life of the zone. There is no state that means "still importing" after that bound, and nothing you can poll for that would ever change.
    #[serde(rename = "state", default, skip_serializing_if = "Option::is_none")]
    pub state: Option<ZoneRecordImportState>,
    /// How the records were found, in descending order of how much the result is worth. `axfr` is a zone transfer: the whole zone, exactly. `nsec-walk` follows the zone's own DNSSEC NSEC chain, which names every record set in it — also exact, and available on signed zones whose provider refuses transfers. `query` is a list of common names, which finds what it thought to ask for and cannot know what it missed. Absent while pending.
    #[serde(rename = "source", default, skip_serializing_if = "Option::is_none")]
    pub source: Option<ZoneRecordImportSource>,
    /// True for the two sources that enumerate the zone — `axfr` and `nsec-walk` — and false for `query`. **This is the field to read before switching your old provider off.** A false here means records may exist that we did not find, not that none do.
    #[serde(rename = "complete", default, skip_serializing_if = "Option::is_none")]
    pub complete: Option<bool>,
    /// Record sets the scan turned up.
    #[serde(rename = "found", default, skip_serializing_if = "Option::is_none")]
    pub found: Option<i64>,
    /// Record sets actually written. Lower than `found` for records you had already created — yours win — and for the ones this platform manages itself.
    #[serde(rename = "imported", default, skip_serializing_if = "Option::is_none")]
    pub imported: Option<i64>,
    /// What could not be established, and what was deliberately not imported.
    #[serde(rename = "notes", default, skip_serializing_if = "Option::is_none")]
    pub notes: Option<Vec<String>>,
    /// Present only when state is `failed`, and says what could not be done.
    #[serde(rename = "error", default, skip_serializing_if = "Option::is_none")]
    pub error: Option<String>,

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

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ZoneRecordImportState {
    Pending,
    Complete,
    Failed,
    Unknown(String),
}
impl ZoneRecordImportState {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Pending => "pending",
            Self::Complete => "complete",
            Self::Failed => "failed",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for ZoneRecordImportState {
    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 ZoneRecordImportState {
    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,
            "complete" => Self::Complete,
            "failed" => Self::Failed,
            _ => Self::Unknown(value),
        })
    }
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ZoneRecordImportSource {
    Axfr,
    NsecWalk,
    Query,
    Unknown(String),
}
impl ZoneRecordImportSource {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Axfr => "axfr",
            Self::NsecWalk => "nsec-walk",
            Self::Query => "query",
            Self::Unknown(value) => value,
        }
    }
}
impl serde::Serialize for ZoneRecordImportSource {
    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 ZoneRecordImportSource {
    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() {
            "axfr" => Self::Axfr,
            "nsec-walk" => Self::NsecWalk,
            "query" => Self::Query,
            _ => Self::Unknown(value),
        })
    }
}

pub type GetZoneRecordImportResponse = ZoneRecordImportResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ZoneImportRequestInput {
    /// The zone file, as text. `$ORIGIN`, `$TTL`, `$GENERATE`, relative names and parenthesised multi-line records are all honoured; `$INCLUDE` is refused, because the path it names would be read on our filesystem rather than yours.
    #[serde(rename = "zone_file")]
    pub zone_file: String,
}
impl ZoneImportRequestInput {
    /// Set the required fields; optional fields start omitted.
    #[allow(clippy::too_many_arguments)]
    pub fn new(zone_file: String) -> Self {
        Self { zone_file }
    }
}

pub type ImportZoneFileBody = ZoneImportRequestInput;

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

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct ZoneImportResult {
    /// RRsets in the file that the zone did not already have.
    #[serde(
        rename = "records_created",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub records_created: Option<i64>,
    /// RRsets that existed at the same name and type and were replaced wholesale by the file's values.
    #[serde(
        rename = "records_replaced",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub records_replaced: Option<i64>,
    /// Imported RRset count per record type.
    #[serde(
        rename = "records_by_type",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub records_by_type: Option<std::collections::BTreeMap<String, i64>>,

    #[serde(rename = "skipped", default, skip_serializing_if = "Option::is_none")]
    pub skipped: Option<Vec<ZoneImportSkipped>>,
    /// Records that were imported, but not exactly as written — an RRset the file gave more than one TTL, for instance.
    #[serde(rename = "warnings", default, skip_serializing_if = "Option::is_none")]
    pub warnings: Option<Vec<String>>,
}

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

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

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

pub type ImportZoneFileResponse = ZoneImportResponse;

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

    #[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>,

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

    #[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 ListRecordsQuery = ListRecordsParameters;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RecordListResponse {
    #[serde(rename = "records")]
    pub records: Vec<Record>,

    #[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 ListRecordsResponse = RecordListResponse;

pub type ListRecordsItem = Record;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct ListZoneVPCAssociationsParameters {
    #[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 ListZoneVPCAssociationsQuery = ListZoneVPCAssociationsParameters;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VPCAssociationsResponse {
    #[serde(rename = "vpcs")]
    pub vpcs: Vec<Vpc>,

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

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Vpc {
    #[serde(rename = "id")]
    pub id: String,
    /// Cloud Resource Name (name-based, region+account-scoped).
    #[serde(rename = "crn")]
    pub crn: String,
    /// 1-63 chars, lowercase alphanumeric + hyphen 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>,
    /// IPv4 CIDR block carved up by subnets. Must be private (RFC 1918): within 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Immutable after create.
    #[serde(rename = "cidr_ipv4")]
    pub cidr_ipv4: String,
    /// Associated regional GUA or private ULA prefix.
    #[serde(
        rename = "cidr_ipv6",
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::response::present_nullable"
    )]
    pub cidr_ipv6: Option<crate::Nullable<String>>,

    #[serde(rename = "tags")]
    pub tags: std::collections::BTreeMap<String, String>,

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

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

pub type ListZoneVPCAssociationsResponse = VPCAssociationsResponse;

pub type ListZoneVPCAssociationsItem = Vpc;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct ListZonesParameters {
    #[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>,

    #[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 ListZonesQuery = ListZonesParameters;

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

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

pub type ListZonesResponse = ZoneListResponse;

pub type ListZonesItem = Zone;

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

    #[serde(rename = "values", default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<RecordValueInput>>,
}

pub type UpdateRecordBody = RecordUpdateRequestInput;

pub type UpdateRecordResponse = RecordResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct ZoneUpdateRequestInput {
    /// Omit to preserve the description; send an empty string to clear it.
    #[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<std::collections::BTreeMap<String, serde_json::Value>>,
}

pub type UpdateZoneBody = ZoneUpdateRequestInput;

pub type UpdateZoneResponse = ZoneResponse;

pub type VerifyZoneOwnershipResponse = ZoneResponse;