spiral-sdk 0.1.10

Rust SDK for Spiral resource and table APIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
// Generated by tools/service-contracts/rust.py. Do not edit.
#![doc = "Generated transport-independent contract objects."]

use std::collections::BTreeMap;
use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter};

use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_json::Value;
use spiral_contract::error::{ErrorEnvelope, ServiceError};
use spiral_contract::strict::{DeserializeStrict, Strict};
use uuid::Uuid;

/// AppAccessDecision contract value.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum AppAccessDecision {
    /// A known contract value.
    Allow,
    /// A known contract value.
    Block,
    /// A value introduced by a newer server.
    Unknown(String),
}
impl Serialize for AppAccessDecision {
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(match self {
            Self::Allow => "allow",
            Self::Block => "block",
            Self::Unknown(value) => value,
        })
    }
}
impl<'de> Deserialize<'de> for AppAccessDecision {
    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        Ok(match String::deserialize(deserializer)?.as_str() {
            "allow" => Self::Allow,
            "block" => Self::Block,
            value => Self::Unknown(value.to_owned()),
        })
    }
}
impl<'de> DeserializeStrict<'de> for AppAccessDecision {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        enum __Known {
            #[serde(rename = "allow")]
            Allow,
            #[serde(rename = "block")]
            Block,
        }
        Ok(match __Known::deserialize(deserializer)? {
            __Known::Allow => Self::Allow,
            __Known::Block => Self::Block,
        })
    }
}

/// The configuration and status of an Application. An Application belongs to one Project and cannot
/// move to another. You cannot use the ID of a deleted Application again.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Application {
    /// Contract field configuration.
    #[serde(rename = "configuration")]
    pub configuration: ApplicationConfiguration,
    /// Contract field id.
    #[serde(rename = "id")]
    pub id: String,
    /// Contract field organizationId.
    #[serde(rename = "organizationId")]
    pub organization_id: String,
    /// Contract field projectId.
    #[serde(rename = "projectId")]
    pub project_id: String,
    /// Contract field status.
    #[serde(rename = "status")]
    pub status: ApplicationStatus,
}
impl<'de> DeserializeStrict<'de> for Application {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "configuration")]
            configuration: Strict<ApplicationConfiguration>,
            #[serde(rename = "id")]
            id: Strict<String>,
            #[serde(rename = "organizationId")]
            organization_id: Strict<String>,
            #[serde(rename = "projectId")]
            project_id: Strict<String>,
            #[serde(rename = "status")]
            status: Strict<ApplicationStatus>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            configuration: wire.configuration.0,
            id: wire.id.0,
            organization_id: wire.organization_id.0,
            project_id: wire.project_id.0,
            status: wire.status.0,
        })
    }
}

/// Who can sign in to the Application. `internal` admits only users of the Organization that owns
/// the Application's Project. `public` also admits users of other Organizations after Spiral
/// reviews the Application, subject to the app access of each Organization.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ApplicationAudience {
    /// A known contract value.
    Internal,
    /// A known contract value.
    Public,
    /// A value introduced by a newer server.
    Unknown(String),
}
impl Serialize for ApplicationAudience {
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(match self {
            Self::Internal => "internal",
            Self::Public => "public",
            Self::Unknown(value) => value,
        })
    }
}
impl<'de> Deserialize<'de> for ApplicationAudience {
    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        Ok(match String::deserialize(deserializer)?.as_str() {
            "internal" => Self::Internal,
            "public" => Self::Public,
            value => Self::Unknown(value.to_owned()),
        })
    }
}
impl<'de> DeserializeStrict<'de> for ApplicationAudience {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        enum __Known {
            #[serde(rename = "internal")]
            Internal,
            #[serde(rename = "public")]
            Public,
        }
        Ok(match __Known::deserialize(deserializer)? {
            __Known::Internal => Self::Internal,
            __Known::Public => Self::Public,
        })
    }
}

/// The exact redirect URIs and the resource scopes that the Application can request. The
/// Application calls the API of the stack that owns its Project. Each user still approves the
/// scopes, and the user's current permissions still apply. setupUrl returns the browser after
/// installation setup. It uses HTTPS (or HTTP on loopback) and receives installation_id,
/// setup_action and optional state; the Application checks the actual grant through the API.
/// redirectOnUpdate also returns after changes to an existing installation; it defaults to false
/// and requires setupUrl. installOnSignIn defaults to false. When enabled, sign-in requires an
/// active installation and lets an Organization owner install during user consent.
/// allowedCorsOrigins lists the exact browser origins (scheme, host and port) whose scripts may
/// obtain tokens and call ScanDAL as the Application.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ApplicationConfiguration {
    /// Contract field allowedCorsOrigins.
    #[serde(rename = "allowedCorsOrigins")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub allowed_cors_origins: Option<Vec<String>>,
    /// Contract field audience.
    #[serde(rename = "audience")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub audience: Option<ApplicationAudience>,
    /// Contract field backgroundIdentity.
    #[serde(rename = "backgroundIdentity")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub background_identity: Option<BackgroundIdentity>,
    /// Contract field enabled.
    #[serde(rename = "enabled")]
    pub enabled: bool,
    /// Contract field installOnSignIn.
    #[serde(rename = "installOnSignIn")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub install_on_sign_in: Option<bool>,
    /// Contract field jwks.
    #[serde(rename = "jwks")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub jwks: Option<Value>,
    /// Contract field jwtBearerIssuers.
    #[serde(rename = "jwtBearerIssuers")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub jwt_bearer_issuers: Option<Vec<BackgroundIdentity>>,
    /// Contract field name.
    #[serde(rename = "name")]
    pub name: String,
    /// Contract field redirectOnUpdate.
    #[serde(rename = "redirectOnUpdate")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub redirect_on_update: Option<bool>,
    /// Contract field redirectUris.
    #[serde(rename = "redirectUris")]
    pub redirect_uris: Vec<String>,
    /// Contract field scopes.
    #[serde(rename = "scopes")]
    pub scopes: Vec<String>,
    /// Contract field setupUrl.
    #[serde(rename = "setupUrl")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub setup_url: Option<String>,
}
impl<'de> DeserializeStrict<'de> for ApplicationConfiguration {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "allowedCorsOrigins")]
            #[serde(default)]
            allowed_cors_origins: Strict<Option<Vec<String>>>,
            #[serde(rename = "audience")]
            #[serde(default)]
            audience: Strict<Option<ApplicationAudience>>,
            #[serde(rename = "backgroundIdentity")]
            #[serde(default)]
            background_identity: Strict<Option<BackgroundIdentity>>,
            #[serde(rename = "enabled")]
            enabled: Strict<bool>,
            #[serde(rename = "installOnSignIn")]
            #[serde(default)]
            install_on_sign_in: Strict<Option<bool>>,
            #[serde(rename = "jwks")]
            #[serde(default)]
            jwks: Strict<Option<Value>>,
            #[serde(rename = "jwtBearerIssuers")]
            #[serde(default)]
            jwt_bearer_issuers: Strict<Option<Vec<BackgroundIdentity>>>,
            #[serde(rename = "name")]
            name: Strict<String>,
            #[serde(rename = "redirectOnUpdate")]
            #[serde(default)]
            redirect_on_update: Strict<Option<bool>>,
            #[serde(rename = "redirectUris")]
            redirect_uris: Strict<Vec<String>>,
            #[serde(rename = "scopes")]
            scopes: Strict<Vec<String>>,
            #[serde(rename = "setupUrl")]
            #[serde(default)]
            setup_url: Strict<Option<String>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            allowed_cors_origins: wire.allowed_cors_origins.0,
            audience: wire.audience.0,
            background_identity: wire.background_identity.0,
            enabled: wire.enabled.0,
            install_on_sign_in: wire.install_on_sign_in.0,
            jwks: wire.jwks.0,
            jwt_bearer_issuers: wire.jwt_bearer_issuers.0,
            name: wire.name.0,
            redirect_on_update: wire.redirect_on_update.0,
            redirect_uris: wire.redirect_uris.0,
            scopes: wire.scopes.0,
            setup_url: wire.setup_url.0,
        })
    }
}

/// ApplicationPage contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ApplicationPage {
    /// Contract field applications.
    #[serde(rename = "applications")]
    pub applications: Vec<Application>,
    /// Contract field nextPageToken.
    #[serde(rename = "nextPageToken")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_page_token: Option<String>,
}
impl<'de> DeserializeStrict<'de> for ApplicationPage {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "applications")]
            applications: Strict<Vec<Application>>,
            #[serde(rename = "nextPageToken")]
            #[serde(default)]
            next_page_token: Strict<Option<String>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            applications: wire.applications.0,
            next_page_token: wire.next_page_token.0,
        })
    }
}

/// ApplicationScope contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ApplicationScope {
    /// Contract field description.
    #[serde(rename = "description")]
    pub description: String,
    /// Contract field name.
    #[serde(rename = "name")]
    pub name: String,
}
impl<'de> DeserializeStrict<'de> for ApplicationScope {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "description")]
            description: Strict<String>,
            #[serde(rename = "name")]
            name: Strict<String>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            description: wire.description.0,
            name: wire.name.0,
        })
    }
}

/// ApplicationScopes contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ApplicationScopes {
    /// Contract field scopes.
    #[serde(rename = "scopes")]
    pub scopes: Vec<ApplicationScope>,
}
impl<'de> DeserializeStrict<'de> for ApplicationScopes {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "scopes")]
            scopes: Strict<Vec<ApplicationScope>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            scopes: wire.scopes.0,
        })
    }
}

/// ApplicationStatus contract value.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ApplicationStatus {
    /// A known contract value.
    Active,
    /// A known contract value.
    Suspended,
    /// A known contract value.
    Deleted,
    /// A value introduced by a newer server.
    Unknown(String),
}
impl Serialize for ApplicationStatus {
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(match self {
            Self::Active => "active",
            Self::Suspended => "suspended",
            Self::Deleted => "deleted",
            Self::Unknown(value) => value,
        })
    }
}
impl<'de> Deserialize<'de> for ApplicationStatus {
    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        Ok(match String::deserialize(deserializer)?.as_str() {
            "active" => Self::Active,
            "suspended" => Self::Suspended,
            "deleted" => Self::Deleted,
            value => Self::Unknown(value.to_owned()),
        })
    }
}
impl<'de> DeserializeStrict<'de> for ApplicationStatus {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        enum __Known {
            #[serde(rename = "active")]
            Active,
            #[serde(rename = "suspended")]
            Suspended,
            #[serde(rename = "deleted")]
            Deleted,
        }
        Ok(match __Known::deserialize(deserializer)? {
            __Known::Active => Self::Active,
            __Known::Suspended => Self::Suspended,
            __Known::Deleted => Self::Deleted,
        })
    }
}

/// An OpenID Connect identity of the Application's backend, such as a cloud service account.
/// backgroundIdentity applies to installation tokens; jwtBearerIssuers applies to app tokens. A
/// token must come from issuer and carry every listed claim value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BackgroundIdentity {
    /// Contract field audience.
    #[serde(rename = "audience")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub audience: Option<String>,
    /// Contract field claims.
    #[serde(rename = "claims")]
    pub claims: BTreeMap<String, String>,
    /// Contract field issuer.
    #[serde(rename = "issuer")]
    pub issuer: String,
}
impl<'de> DeserializeStrict<'de> for BackgroundIdentity {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "audience")]
            #[serde(default)]
            audience: Strict<Option<String>>,
            #[serde(rename = "claims")]
            claims: Strict<BTreeMap<String, String>>,
            #[serde(rename = "issuer")]
            issuer: Strict<String>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            audience: wire.audience.0,
            claims: wire.claims.0,
            issuer: wire.issuer.0,
        })
    }
}

/// ClientAppAccess contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ClientAppAccess {
    /// Contract field clientId.
    #[serde(rename = "clientId")]
    pub client_id: String,
    /// Contract field decision.
    #[serde(rename = "decision")]
    pub decision: AppAccessDecision,
}
impl<'de> DeserializeStrict<'de> for ClientAppAccess {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "clientId")]
            client_id: Strict<String>,
            #[serde(rename = "decision")]
            decision: Strict<AppAccessDecision>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            client_id: wire.client_id.0,
            decision: wire.decision.0,
        })
    }
}

/// The verified OAuth client and callback shown by the consent application.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConsentClient {
    /// Contract field id.
    #[serde(rename = "id")]
    pub id: String,
    /// Contract field loopbackOnly.
    #[serde(rename = "loopbackOnly")]
    pub loopback_only: bool,
    /// Contract field managed.
    #[serde(rename = "managed")]
    pub managed: bool,
    /// Contract field name.
    #[serde(rename = "name")]
    pub name: String,
    /// Contract field publisher.
    #[serde(rename = "publisher")]
    pub publisher: String,
    /// Contract field publisherName.
    #[serde(rename = "publisherName")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub publisher_name: Option<String>,
    /// Contract field redirectHost.
    #[serde(rename = "redirectHost")]
    pub redirect_host: String,
}
impl<'de> DeserializeStrict<'de> for ConsentClient {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "id")]
            id: Strict<String>,
            #[serde(rename = "loopbackOnly")]
            loopback_only: Strict<bool>,
            #[serde(rename = "managed")]
            managed: Strict<bool>,
            #[serde(rename = "name")]
            name: Strict<String>,
            #[serde(rename = "publisher")]
            publisher: Strict<String>,
            #[serde(rename = "publisherName")]
            #[serde(default)]
            publisher_name: Strict<Option<String>>,
            #[serde(rename = "redirectHost")]
            redirect_host: Strict<String>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            id: wire.id.0,
            loopback_only: wire.loopback_only.0,
            managed: wire.managed.0,
            name: wire.name.0,
            publisher: wire.publisher.0,
            publisher_name: wire.publisher_name.0,
            redirect_host: wire.redirect_host.0,
        })
    }
}

/// Accept only the listed requested scopes, or reject the authorization.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConsentDecision {
    /// Contract field approve.
    #[serde(rename = "approve")]
    pub approve: bool,
    /// Contract field scopes.
    #[serde(rename = "scopes")]
    pub scopes: Vec<String>,
}
impl<'de> DeserializeStrict<'de> for ConsentDecision {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "approve")]
            approve: Strict<bool>,
            #[serde(rename = "scopes")]
            scopes: Strict<Vec<String>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            approve: wire.approve.0,
            scopes: wire.scopes.0,
        })
    }
}

/// Return the initiating browser to this authorization-server URL to finish consent.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConsentRedirect {
    /// Contract field redirectTo.
    #[serde(rename = "redirectTo")]
    pub redirect_to: String,
}
impl<'de> DeserializeStrict<'de> for ConsentRedirect {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "redirectTo")]
            redirect_to: Strict<String>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            redirect_to: wire.redirect_to.0,
        })
    }
}

/// The requested delegation. A challenge contains no access or refresh token.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConsentRequest {
    /// Contract field client.
    #[serde(rename = "client")]
    pub client: ConsentClient,
    /// Contract field resource.
    #[serde(rename = "resource")]
    pub resource: String,
    /// Contract field scopes.
    #[serde(rename = "scopes")]
    pub scopes: Vec<String>,
    /// Contract field skip.
    #[serde(rename = "skip")]
    pub skip: bool,
    /// Contract field subject.
    #[serde(rename = "subject")]
    pub subject: ConsentSubject,
}
impl<'de> DeserializeStrict<'de> for ConsentRequest {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "client")]
            client: Strict<ConsentClient>,
            #[serde(rename = "resource")]
            resource: Strict<String>,
            #[serde(rename = "scopes")]
            scopes: Strict<Vec<String>>,
            #[serde(rename = "skip")]
            skip: Strict<bool>,
            #[serde(rename = "subject")]
            subject: Strict<ConsentSubject>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            client: wire.client.0,
            resource: wire.resource.0,
            scopes: wire.scopes.0,
            skip: wire.skip.0,
            subject: wire.subject.0,
        })
    }
}

/// The authenticated user and Organization bound to this authorization.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConsentSubject {
    /// Contract field organizationId.
    #[serde(rename = "organizationId")]
    pub organization_id: String,
    /// Contract field organizationName.
    #[serde(rename = "organizationName")]
    pub organization_name: String,
    /// Contract field userId.
    #[serde(rename = "userId")]
    pub user_id: String,
}
impl<'de> DeserializeStrict<'de> for ConsentSubject {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "organizationId")]
            organization_id: Strict<String>,
            #[serde(rename = "organizationName")]
            organization_name: Strict<String>,
            #[serde(rename = "userId")]
            user_id: Strict<String>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            organization_id: wire.organization_id.0,
            organization_name: wire.organization_name.0,
            user_id: wire.user_id.0,
        })
    }
}

/// Application details for an Organization member to review before installation. Credentials,
/// sign-in callbacks and developer Project configuration are not included. The registered setup URL
/// identifies where the browser returns after setup.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallableApplication {
    /// Contract field id.
    #[serde(rename = "id")]
    pub id: String,
    /// Contract field installOnSignIn.
    #[serde(rename = "installOnSignIn")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub install_on_sign_in: Option<bool>,
    /// Contract field installation.
    #[serde(rename = "installation")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub installation: Option<Installation>,
    /// Contract field name.
    #[serde(rename = "name")]
    pub name: String,
    /// Contract field organizationId.
    #[serde(rename = "organizationId")]
    pub organization_id: String,
    /// Contract field redirectOnUpdate.
    #[serde(rename = "redirectOnUpdate")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub redirect_on_update: Option<bool>,
    /// Contract field scopes.
    #[serde(rename = "scopes")]
    pub scopes: Vec<String>,
    /// Contract field setupUrl.
    #[serde(rename = "setupUrl")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub setup_url: Option<String>,
    /// Contract field status.
    #[serde(rename = "status")]
    pub status: ApplicationStatus,
}
impl<'de> DeserializeStrict<'de> for InstallableApplication {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "id")]
            id: Strict<String>,
            #[serde(rename = "installOnSignIn")]
            #[serde(default)]
            install_on_sign_in: Strict<Option<bool>>,
            #[serde(rename = "installation")]
            #[serde(default)]
            installation: Strict<Option<Installation>>,
            #[serde(rename = "name")]
            name: Strict<String>,
            #[serde(rename = "organizationId")]
            organization_id: Strict<String>,
            #[serde(rename = "redirectOnUpdate")]
            #[serde(default)]
            redirect_on_update: Strict<Option<bool>>,
            #[serde(rename = "scopes")]
            scopes: Strict<Vec<String>>,
            #[serde(rename = "setupUrl")]
            #[serde(default)]
            setup_url: Strict<Option<String>>,
            #[serde(rename = "status")]
            status: Strict<ApplicationStatus>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            id: wire.id.0,
            install_on_sign_in: wire.install_on_sign_in.0,
            installation: wire.installation.0,
            name: wire.name.0,
            organization_id: wire.organization_id.0,
            redirect_on_update: wire.redirect_on_update.0,
            scopes: wire.scopes.0,
            setup_url: wire.setup_url.0,
            status: wire.status.0,
        })
    }
}

/// An Application installed in one Organization, where it acts as its own identity. `requested` is
/// the latest request. `approved` is what an Organization owner approved, and it is the only grant
/// that Spiral enforces. A request for more access takes effect only when an owner approves it.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Installation {
    /// Contract field applicationId.
    #[serde(rename = "applicationId")]
    pub application_id: String,
    /// Contract field approved.
    #[serde(rename = "approved")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub approved: Option<InstallationGrant>,
    /// Contract field id.
    #[serde(rename = "id")]
    pub id: String,
    /// Contract field organizationId.
    #[serde(rename = "organizationId")]
    pub organization_id: String,
    /// Contract field requested.
    #[serde(rename = "requested")]
    pub requested: InstallationGrant,
    /// Contract field status.
    #[serde(rename = "status")]
    pub status: InstallationStatus,
}
impl<'de> DeserializeStrict<'de> for Installation {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "applicationId")]
            application_id: Strict<String>,
            #[serde(rename = "approved")]
            #[serde(default)]
            approved: Strict<Option<InstallationGrant>>,
            #[serde(rename = "id")]
            id: Strict<String>,
            #[serde(rename = "organizationId")]
            organization_id: Strict<String>,
            #[serde(rename = "requested")]
            requested: Strict<InstallationGrant>,
            #[serde(rename = "status")]
            status: Strict<InstallationStatus>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            application_id: wire.application_id.0,
            approved: wire.approved.0,
            id: wire.id.0,
            organization_id: wire.organization_id.0,
            requested: wire.requested.0,
            status: wire.status.0,
        })
    }
}

/// Installation metadata and its API audience. configurationUrl is absent until the deployment
/// supplies an installation management UI.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationDetails {
    /// Contract field apiUrl.
    #[serde(rename = "apiUrl")]
    pub api_url: String,
    /// Contract field configurationUrl.
    #[serde(rename = "configurationUrl")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub configuration_url: Option<String>,
    /// Contract field installation.
    #[serde(rename = "installation")]
    pub installation: Installation,
}
impl<'de> DeserializeStrict<'de> for InstallationDetails {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "apiUrl")]
            api_url: Strict<String>,
            #[serde(rename = "configurationUrl")]
            #[serde(default)]
            configuration_url: Strict<Option<String>>,
            #[serde(rename = "installation")]
            installation: Strict<Installation>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            api_url: wire.api_url.0,
            configuration_url: wire.configuration_url.0,
            installation: wire.installation.0,
        })
    }
}

/// InstallationGrant contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationGrant {
    /// Contract field projects.
    #[serde(rename = "projects")]
    pub projects: InstallationProjects,
    /// Contract field scopes.
    #[serde(rename = "scopes")]
    pub scopes: Vec<String>,
}
impl<'de> DeserializeStrict<'de> for InstallationGrant {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "projects")]
            projects: Strict<InstallationProjects>,
            #[serde(rename = "scopes")]
            scopes: Strict<Vec<String>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            projects: wire.projects.0,
            scopes: wire.scopes.0,
        })
    }
}

/// InstallationPage contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationPage {
    /// Contract field installations.
    #[serde(rename = "installations")]
    pub installations: Vec<Installation>,
    /// Contract field nextPageToken.
    #[serde(rename = "nextPageToken")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_page_token: Option<String>,
}
impl<'de> DeserializeStrict<'de> for InstallationPage {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "installations")]
            installations: Strict<Vec<Installation>>,
            #[serde(rename = "nextPageToken")]
            #[serde(default)]
            next_page_token: Strict<Option<String>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            installations: wire.installations.0,
            next_page_token: wire.next_page_token.0,
        })
    }
}

/// InstallationProject contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationProject {
    /// Contract field description.
    #[serde(rename = "description")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// Contract field id.
    #[serde(rename = "id")]
    pub id: String,
    /// Contract field organizationId.
    #[serde(rename = "organizationId")]
    pub organization_id: String,
}
impl<'de> DeserializeStrict<'de> for InstallationProject {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "description")]
            #[serde(default)]
            description: Strict<Option<String>>,
            #[serde(rename = "id")]
            id: Strict<String>,
            #[serde(rename = "organizationId")]
            organization_id: Strict<String>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            description: wire.description.0,
            id: wire.id.0,
            organization_id: wire.organization_id.0,
        })
    }
}

/// InstallationProjectPage contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationProjectPage {
    /// Contract field nextPageToken.
    #[serde(rename = "nextPageToken")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_page_token: Option<String>,
    /// Contract field projects.
    #[serde(rename = "projects")]
    pub projects: Vec<InstallationProject>,
}
impl<'de> DeserializeStrict<'de> for InstallationProjectPage {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "nextPageToken")]
            #[serde(default)]
            next_page_token: Strict<Option<String>>,
            #[serde(rename = "projects")]
            projects: Strict<Vec<InstallationProject>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            next_page_token: wire.next_page_token.0,
            projects: wire.projects.0,
        })
    }
}

/// Every Project in the Organization, including Projects created later, when `all` is true.
/// Otherwise, only the listed Projects.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationProjects {
    /// Contract field all.
    #[serde(rename = "all")]
    pub all: bool,
    /// Contract field projectIds.
    #[serde(rename = "projectIds")]
    pub project_ids: Vec<String>,
}
impl<'de> DeserializeStrict<'de> for InstallationProjects {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "all")]
            all: Strict<bool>,
            #[serde(rename = "projectIds")]
            project_ids: Strict<Vec<String>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            all: wire.all.0,
            project_ids: wire.project_ids.0,
        })
    }
}

/// InstallationRequest contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationRequest {
    /// Contract field applicationId.
    #[serde(rename = "applicationId")]
    pub application_id: String,
    /// Contract field projects.
    #[serde(rename = "projects")]
    pub projects: InstallationProjects,
    /// Contract field scopes.
    #[serde(rename = "scopes")]
    pub scopes: Vec<String>,
}
impl<'de> DeserializeStrict<'de> for InstallationRequest {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "applicationId")]
            application_id: Strict<String>,
            #[serde(rename = "projects")]
            projects: Strict<InstallationProjects>,
            #[serde(rename = "scopes")]
            scopes: Strict<Vec<String>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            application_id: wire.application_id.0,
            projects: wire.projects.0,
            scopes: wire.scopes.0,
        })
    }
}

/// Approve or decline the exact request shown to an Organization owner. A changed request returns
/// Conflict and must be reviewed again. Declining an update preserves the existing approval;
/// declining a new installation removes the request.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationReview {
    /// Contract field approve.
    #[serde(rename = "approve")]
    pub approve: bool,
    /// Contract field requested.
    #[serde(rename = "requested")]
    pub requested: InstallationGrant,
}
impl<'de> DeserializeStrict<'de> for InstallationReview {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "approve")]
            approve: Strict<bool>,
            #[serde(rename = "requested")]
            requested: Strict<InstallationGrant>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            approve: wire.approve.0,
            requested: wire.requested.0,
        })
    }
}

/// InstallationStatus contract value.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum InstallationStatus {
    /// A known contract value.
    Requested,
    /// A known contract value.
    Active,
    /// A known contract value.
    Suspended,
    /// A value introduced by a newer server.
    Unknown(String),
}
impl Serialize for InstallationStatus {
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(match self {
            Self::Requested => "requested",
            Self::Active => "active",
            Self::Suspended => "suspended",
            Self::Unknown(value) => value,
        })
    }
}
impl<'de> Deserialize<'de> for InstallationStatus {
    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        Ok(match String::deserialize(deserializer)?.as_str() {
            "requested" => Self::Requested,
            "active" => Self::Active,
            "suspended" => Self::Suspended,
            value => Self::Unknown(value.to_owned()),
        })
    }
}
impl<'de> DeserializeStrict<'de> for InstallationStatus {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        enum __Known {
            #[serde(rename = "requested")]
            Requested,
            #[serde(rename = "active")]
            Active,
            #[serde(rename = "suspended")]
            Suspended,
        }
        Ok(match __Known::deserialize(deserializer)? {
            __Known::Requested => Self::Requested,
            __Known::Active => Self::Active,
            __Known::Suspended => Self::Suspended,
        })
    }
}

/// InstallationStatusChange contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationStatusChange {
    /// Contract field enabled.
    #[serde(rename = "enabled")]
    pub enabled: bool,
}
impl<'de> DeserializeStrict<'de> for InstallationStatusChange {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "enabled")]
            enabled: Strict<bool>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            enabled: wire.enabled.0,
        })
    }
}

/// InstallationSummary contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationSummary {
    /// Contract field apiUrl.
    #[serde(rename = "apiUrl")]
    pub api_url: String,
    /// Contract field applicationId.
    #[serde(rename = "applicationId")]
    pub application_id: String,
    /// Contract field approvedScopes.
    #[serde(rename = "approvedScopes")]
    pub approved_scopes: Vec<String>,
    /// Contract field configurationUrl.
    #[serde(rename = "configurationUrl")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub configuration_url: Option<String>,
    /// Contract field id.
    #[serde(rename = "id")]
    pub id: String,
    /// Contract field organizationId.
    #[serde(rename = "organizationId")]
    pub organization_id: String,
    /// Contract field requestedScopes.
    #[serde(rename = "requestedScopes")]
    pub requested_scopes: Vec<String>,
    /// Contract field status.
    #[serde(rename = "status")]
    pub status: InstallationStatus,
}
impl<'de> DeserializeStrict<'de> for InstallationSummary {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "apiUrl")]
            api_url: Strict<String>,
            #[serde(rename = "applicationId")]
            application_id: Strict<String>,
            #[serde(rename = "approvedScopes")]
            approved_scopes: Strict<Vec<String>>,
            #[serde(rename = "configurationUrl")]
            #[serde(default)]
            configuration_url: Strict<Option<String>>,
            #[serde(rename = "id")]
            id: Strict<String>,
            #[serde(rename = "organizationId")]
            organization_id: Strict<String>,
            #[serde(rename = "requestedScopes")]
            requested_scopes: Strict<Vec<String>>,
            #[serde(rename = "status")]
            status: Strict<InstallationStatus>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            api_url: wire.api_url.0,
            application_id: wire.application_id.0,
            approved_scopes: wire.approved_scopes.0,
            configuration_url: wire.configuration_url.0,
            id: wire.id.0,
            organization_id: wire.organization_id.0,
            requested_scopes: wire.requested_scopes.0,
            status: wire.status.0,
        })
    }
}

/// ListApplicationsRequest contract value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ListApplicationsRequest {
    /// Contract field pageSize.
    #[serde(rename = "pageSize")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page_size: Option<u32>,
    /// Contract field pageToken.
    #[serde(rename = "pageToken")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page_token: Option<String>,
}
impl<'de> DeserializeStrict<'de> for ListApplicationsRequest {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "pageSize")]
            #[serde(default)]
            page_size: Strict<Option<u32>>,
            #[serde(rename = "pageToken")]
            #[serde(default)]
            page_token: Strict<Option<String>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            page_size: wire.page_size.0,
            page_token: wire.page_token.0,
        })
    }
}

/// The Applications and MCP clients that the users of an Organization can sign in to. The decision
/// for a listed client applies first. `unlisted` applies to every other client.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrganizationAppAccess {
    /// Contract field clients.
    #[serde(rename = "clients")]
    pub clients: Vec<ClientAppAccess>,
    /// Contract field unlisted.
    #[serde(rename = "unlisted")]
    pub unlisted: UnlistedAppAccess,
}
impl<'de> DeserializeStrict<'de> for OrganizationAppAccess {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "clients")]
            clients: Strict<Vec<ClientAppAccess>>,
            #[serde(rename = "unlisted")]
            unlisted: Strict<UnlistedAppAccess>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            clients: wire.clients.0,
            unlisted: wire.unlisted.0,
        })
    }
}

/// What happens to an Application that the Organization did not list. `allow_reviewed` allows
/// Applications that Spiral reviewed. `block` blocks all of them.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum UnlistedAppAccess {
    /// A known contract value.
    AllowReviewed,
    /// A known contract value.
    Block,
    /// A value introduced by a newer server.
    Unknown(String),
}
impl Serialize for UnlistedAppAccess {
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(match self {
            Self::AllowReviewed => "allow_reviewed",
            Self::Block => "block",
            Self::Unknown(value) => value,
        })
    }
}
impl<'de> Deserialize<'de> for UnlistedAppAccess {
    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        Ok(match String::deserialize(deserializer)?.as_str() {
            "allow_reviewed" => Self::AllowReviewed,
            "block" => Self::Block,
            value => Self::Unknown(value.to_owned()),
        })
    }
}
impl<'de> DeserializeStrict<'de> for UnlistedAppAccess {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        enum __Known {
            #[serde(rename = "allow_reviewed")]
            AllowReviewed,
            #[serde(rename = "block")]
            Block,
        }
        Ok(match __Known::deserialize(deserializer)? {
            __Known::AllowReviewed => Self::AllowReviewed,
            __Known::Block => Self::Block,
        })
    }
}

/// Setup state for the caller's app and Organization. An absent installation means setup has not
/// started. Project enumeration uses the user installation project list.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct UserInstallation {
    /// Contract field installation.
    #[serde(rename = "installation")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub installation: Option<InstallationSummary>,
}
impl<'de> DeserializeStrict<'de> for UserInstallation {
    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        #[derive(Deserialize)]
        #[serde(deny_unknown_fields)]
        struct __Wire {
            #[serde(rename = "installation")]
            #[serde(default)]
            installation: Strict<Option<InstallationSummary>>,
        }
        let wire = __Wire::deserialize(deserializer)?;
        Ok(Self {
            installation: wire.installation.0,
        })
    }
}

/// Typed errors declared by this service contract.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum AppsError {
    /// Apps:Conflict.
    Conflict { application_id: String },
    /// Apps:ConsentConflict.
    ConsentConflict { reason: String },
    /// Apps:InvalidArgument.
    InvalidArgument { reason: String },
    /// Apps:InvalidConsent.
    InvalidConsent { reason: String },
    /// Apps:NotFound.
    NotFound { application_id: String },
    /// Apps:RegistrationUnavailable.
    RegistrationUnavailable { application_id: String },
}
impl AppsError {
    /// HTTP status for this declared error.
    pub fn status(&self) -> u16 {
        match self {
            Self::Conflict { .. } => 409,
            Self::ConsentConflict { .. } => 409,
            Self::InvalidArgument { .. } => 400,
            Self::InvalidConsent { .. } => 400,
            Self::NotFound { .. } => 404,
            Self::RegistrationUnavailable { .. } => 500,
        }
    }
    /// Serialize only contract-declared error parameters.
    pub fn envelope(&self, instance: String) -> ErrorEnvelope {
        match self {
            Self::Conflict { application_id } => {
                let mut envelope = ErrorEnvelope::new("CONFLICT", "Apps:Conflict", instance);
                envelope
                    .parameters
                    .insert("applicationId".into(), application_id.to_string());
                envelope
            }
            Self::ConsentConflict { reason } => {
                let mut envelope = ErrorEnvelope::new("CONFLICT", "Apps:ConsentConflict", instance);
                envelope
                    .parameters
                    .insert("reason".into(), reason.to_string());
                envelope
            }
            Self::InvalidArgument { reason } => {
                let mut envelope =
                    ErrorEnvelope::new("INVALID_ARGUMENT", "Apps:InvalidArgument", instance);
                envelope
                    .parameters
                    .insert("reason".into(), reason.to_string());
                envelope
            }
            Self::InvalidConsent { reason } => {
                let mut envelope =
                    ErrorEnvelope::new("INVALID_ARGUMENT", "Apps:InvalidConsent", instance);
                envelope
                    .parameters
                    .insert("reason".into(), reason.to_string());
                envelope
            }
            Self::NotFound { application_id } => {
                let mut envelope = ErrorEnvelope::new("NOT_FOUND", "Apps:NotFound", instance);
                envelope
                    .parameters
                    .insert("applicationId".into(), application_id.to_string());
                envelope
            }
            Self::RegistrationUnavailable { application_id } => {
                let mut envelope =
                    ErrorEnvelope::new("INTERNAL", "Apps:RegistrationUnavailable", instance);
                envelope
                    .parameters
                    .insert("applicationId".into(), application_id.to_string());
                envelope
            }
        }
    }
    /// Decode a declared error and its typed error parameters.
    pub fn decode_envelope(envelope: &ErrorEnvelope) -> Option<Self> {
        if envelope.error_instance_id.len() != 36
            || Uuid::parse_str(&envelope.error_instance_id).is_err()
        {
            return None;
        }
        match envelope.error_name.as_str() {
            "Apps:Conflict" => {
                if envelope.error_code != "CONFLICT" {
                    return None;
                }
                let application_id = envelope.parameters.get("applicationId")?.clone();
                Some(Self::Conflict { application_id })
            }
            "Apps:ConsentConflict" => {
                if envelope.error_code != "CONFLICT" {
                    return None;
                }
                let reason = envelope.parameters.get("reason")?.clone();
                Some(Self::ConsentConflict { reason })
            }
            "Apps:InvalidArgument" => {
                if envelope.error_code != "INVALID_ARGUMENT" {
                    return None;
                }
                let reason = envelope.parameters.get("reason")?.clone();
                Some(Self::InvalidArgument { reason })
            }
            "Apps:InvalidConsent" => {
                if envelope.error_code != "INVALID_ARGUMENT" {
                    return None;
                }
                let reason = envelope.parameters.get("reason")?.clone();
                Some(Self::InvalidConsent { reason })
            }
            "Apps:NotFound" => {
                if envelope.error_code != "NOT_FOUND" {
                    return None;
                }
                let application_id = envelope.parameters.get("applicationId")?.clone();
                Some(Self::NotFound { application_id })
            }
            "Apps:RegistrationUnavailable" => {
                if envelope.error_code != "INTERNAL" {
                    return None;
                }
                let application_id = envelope.parameters.get("applicationId")?.clone();
                Some(Self::RegistrationUnavailable { application_id })
            }
            _ => None,
        }
    }
}
impl Display for AppsError {
    fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
        match self {
            Self::Conflict { application_id } => write!(
                formatter,
                "Apps:Conflict (applicationId: {})",
                application_id
            ),
            Self::ConsentConflict { reason } => {
                write!(formatter, "Apps:ConsentConflict (reason: {})", reason)
            }
            Self::InvalidArgument { reason } => {
                write!(formatter, "Apps:InvalidArgument (reason: {})", reason)
            }
            Self::InvalidConsent { reason } => {
                write!(formatter, "Apps:InvalidConsent (reason: {})", reason)
            }
            Self::NotFound { application_id } => write!(
                formatter,
                "Apps:NotFound (applicationId: {})",
                application_id
            ),
            Self::RegistrationUnavailable { application_id } => write!(
                formatter,
                "Apps:RegistrationUnavailable (applicationId: {})",
                application_id
            ),
        }
    }
}
impl StdError for AppsError {}
impl ServiceError for AppsError {
    fn to_envelope(&self, instance: String) -> ErrorEnvelope {
        Self::envelope(self, instance)
    }
    fn from_envelope(envelope: &ErrorEnvelope) -> Option<Self> {
        Self::decode_envelope(envelope)
    }
}
#[automatically_derived]
impl Default for ListApplicationsRequest {
    fn default() -> Self {
        Self {
            page_size: None,
            page_token: None,
        }
    }
}