Source file values.ml

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
(* generated by: awso-codegen generate-all --botocore-data vendor/botocore/botocore/data -o aws --runtime-dir lib/runtime/awso --cli-dir awso-cli *)
open Awso
open! Import
[@@@warning "-32"]
let service = Service.sso
let apiVersion = "2019-06-10"
let endpointPrefix = "portal.sso"
let serviceFullName = "AWS Single Sign-On"
let signatureVersion = "v4"
let protocol = "rest_json"
let globalEndpoint = endpointPrefix ^ ".amazonaws.com"
let serviceAbbreviation = "SSO"
let simple_to_json to_value x =
  Botodata.Json.value_to_json_scalar (to_value x)
let composed_to_json to_value x = Botodata.Json.value_to_json (to_value x)
let to_query to_value x = Client.Query.of_value (to_value x)
let structure_to_value_aux st ~f =
  let filter = function | (k, Some v) -> Some (k, v) | _ -> None in
  let pair k v = (k, v) in
  let defer_value (k, dv) = pair k dv in
  ((List.filter_map st ~f:filter) |> (List.map ~f:defer_value)) |>
    (fun x -> `Structure (f x))
let structure_to_value = structure_to_value_aux ~f:Fn.id
let structure_to_wrapped_value ~wrapper ~response =
  structure_to_value_aux
    ~f:(fun x -> [(wrapper, (`Structure x)); (response, (`Structure []))])
module AccountIdType =
  struct
    type nonrec t = string
    let context_ = "AccountIdType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"AccountIdType" j
    let to_json = simple_to_json to_value
  end
module AccountNameType =
  struct
    type nonrec t = string
    let context_ = "AccountNameType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"AccountNameType" j
    let to_json = simple_to_json to_value
  end
module EmailAddressType =
  struct
    type nonrec t = string
    let context_ = "EmailAddressType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:254) >>=
             (fun () -> check_string_min i ~min:1));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"EmailAddressType" j
    let to_json = simple_to_json to_value
  end
module RoleNameType =
  struct
    type nonrec t = string
    let context_ = "RoleNameType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"RoleNameType" j
    let to_json = simple_to_json to_value
  end
module AccountInfo =
  struct
    type nonrec t =
      {
      accountId: AccountIdType.t option
        [@ocaml.doc
          "The identifier of the AWS account that is assigned to the user."];
      accountName: AccountNameType.t option
        [@ocaml.doc
          "The display name of the AWS account that is assigned to the user."];
      emailAddress: EmailAddressType.t option
        [@ocaml.doc
          "The email address of the AWS account that is assigned to the user."]}
    let make ?accountId =
      fun ?accountName ->
        fun ?emailAddress ->
          fun () -> { accountId; accountName; emailAddress }
    let to_value x =
      structure_to_value
        [("accountId", (Option.map x.accountId ~f:AccountIdType.to_value));
        ("accountName",
          (Option.map x.accountName ~f:AccountNameType.to_value));
        ("emailAddress",
          (Option.map x.emailAddress ~f:EmailAddressType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let emailAddress =
        (Option.map ~f:EmailAddressType.of_xml)
          (Xml.child xml_arg0 "emailAddress") in
      let accountName =
        (Option.map ~f:AccountNameType.of_xml)
          (Xml.child xml_arg0 "accountName") in
      let accountId =
        (Option.map ~f:AccountIdType.of_xml) (Xml.child xml_arg0 "accountId") in
      make ?emailAddress ?accountName ?accountId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let emailAddress =
        field_map json__ "emailAddress" EmailAddressType.of_json in
      let accountName =
        field_map json__ "accountName" AccountNameType.of_json in
      let accountId = field_map json__ "accountId" AccountIdType.of_json in
      make ?emailAddress ?accountName ?accountId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Provides information about your AWS account."]
module ErrorDescription =
  struct
    type nonrec t = string
    let context_ = "ErrorDescription"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"ErrorDescription" j
    let to_json = simple_to_json to_value
  end
module RoleInfo =
  struct
    type nonrec t =
      {
      roleName: RoleNameType.t option
        [@ocaml.doc
          "The friendly name of the role that is assigned to the user."];
      accountId: AccountIdType.t option
        [@ocaml.doc
          "The identifier of the AWS account assigned to the user."]}
    let make ?roleName = fun ?accountId -> fun () -> { roleName; accountId }
    let to_value x =
      structure_to_value
        [("roleName", (Option.map x.roleName ~f:RoleNameType.to_value));
        ("accountId", (Option.map x.accountId ~f:AccountIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let accountId =
        (Option.map ~f:AccountIdType.of_xml) (Xml.child xml_arg0 "accountId") in
      let roleName =
        (Option.map ~f:RoleNameType.of_xml) (Xml.child xml_arg0 "roleName") in
      make ?accountId ?roleName ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let accountId = field_map json__ "accountId" AccountIdType.of_json in
      let roleName = field_map json__ "roleName" RoleNameType.of_json in
      make ?accountId ?roleName ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Provides information about the role that is assigned to the user."]
module AccessKeyType =
  struct
    type nonrec t = string
    let context_ = "AccessKeyType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"AccessKeyType" j
    let to_json = simple_to_json to_value
  end
module ExpirationTimestampType =
  struct
    type nonrec t = Int64.t
    let make i = i
    let of_string = Int64.of_string
    let to_value x = `Long x
    let to_query v = to_query to_value v
    let to_header x = Int64.to_string x
    let of_xml xml_arg0 =
      Int64.of_string (string_of_xml ~kind:"a long" xml_arg0)
    let of_json j = Int64.of_float (float_of_json ~kind:"a long" j)
    let to_json = simple_to_json to_value
  end
module SecretAccessKeyType =
  struct
    type nonrec t = string
    let context_ = "SecretAccessKeyType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"SecretAccessKeyType" j
    let to_json = simple_to_json to_value
  end
module SessionTokenType =
  struct
    type nonrec t = string
    let context_ = "SessionTokenType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"SessionTokenType" j
    let to_json = simple_to_json to_value
  end
module AccessTokenType =
  struct
    type nonrec t = string
    let context_ = "AccessTokenType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"AccessTokenType" j
    let to_json = simple_to_json to_value
  end
module AccountListType =
  struct
    type nonrec t = AccountInfo.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:AccountInfo.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:AccountInfo.of_xml)
    let of_json j =
      list_of_json ~kind:"AccountListType" ~of_json:AccountInfo.of_json j
    let to_json v = composed_to_json to_value v
  end
module InvalidRequestException =
  struct
    type nonrec t = {
      message: ErrorDescription.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorDescription.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorDescription.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorDescription.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Indicates that a problem occurred with the input to the request. For example, a required parameter might be missing or out of range."]
module NextTokenType =
  struct
    type nonrec t = string
    let context_ = "NextTokenType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"NextTokenType" j
    let to_json = simple_to_json to_value
  end
module ResourceNotFoundException =
  struct
    type nonrec t = {
      message: ErrorDescription.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorDescription.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorDescription.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorDescription.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "The specified resource doesn't exist."]
module TooManyRequestsException =
  struct
    type nonrec t = {
      message: ErrorDescription.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorDescription.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorDescription.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorDescription.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Indicates that the request is being made too frequently and is more than what the server can handle."]
module UnauthorizedException =
  struct
    type nonrec t = {
      message: ErrorDescription.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorDescription.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorDescription.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorDescription.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Indicates that the request is not authorized. This can happen due to an invalid access token in the request."]
module MaxResultType =
  struct
    type nonrec t = int
    let make i =
      let open Result in
        ok_or_failwith
          ((check_int_max i ~max:100) >>= (fun () -> check_int_min i ~min:1));
        i
    let of_string = Int.of_string
    let to_value x = `Integer x
    let to_query v = to_query to_value v
    let to_header x = Int.to_string x
    let of_xml xml_arg0 =
      Int.of_string
        (string_of_xml ~kind:"an integer for MaxResultType" xml_arg0)
    let of_json j = Int.of_float (float_of_json ~kind:"an integer" j)
    let to_json = simple_to_json to_value
  end
module RoleListType =
  struct
    type nonrec t = RoleInfo.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:RoleInfo.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:RoleInfo.of_xml)
    let of_json j =
      list_of_json ~kind:"RoleListType" ~of_json:RoleInfo.of_json j
    let to_json v = composed_to_json to_value v
  end
module RoleCredentials =
  struct
    type nonrec t =
      {
      accessKeyId: AccessKeyType.t option
        [@ocaml.doc
          "The identifier used for the temporary security credentials. For more information, see Using Temporary Security Credentials to Request Access to AWS Resources in the AWS IAM User Guide."];
      secretAccessKey: SecretAccessKeyType.t option
        [@ocaml.doc
          "The key that is used to sign the request. For more information, see Using Temporary Security Credentials to Request Access to AWS Resources in the AWS IAM User Guide."];
      sessionToken: SessionTokenType.t option
        [@ocaml.doc
          "The token used for temporary credentials. For more information, see Using Temporary Security Credentials to Request Access to AWS Resources in the AWS IAM User Guide."];
      expiration: ExpirationTimestampType.t option
        [@ocaml.doc
          "The date on which temporary security credentials expire."]}
    let make ?accessKeyId =
      fun ?secretAccessKey ->
        fun ?sessionToken ->
          fun ?expiration ->
            fun () ->
              { accessKeyId; secretAccessKey; sessionToken; expiration }
    let to_value x =
      structure_to_value
        [("accessKeyId",
           (Option.map x.accessKeyId ~f:AccessKeyType.to_value));
        ("secretAccessKey",
          (Option.map x.secretAccessKey ~f:SecretAccessKeyType.to_value));
        ("sessionToken",
          (Option.map x.sessionToken ~f:SessionTokenType.to_value));
        ("expiration",
          (Option.map x.expiration ~f:ExpirationTimestampType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let expiration =
        (Option.map ~f:ExpirationTimestampType.of_xml)
          (Xml.child xml_arg0 "expiration") in
      let sessionToken =
        (Option.map ~f:SessionTokenType.of_xml)
          (Xml.child xml_arg0 "sessionToken") in
      let secretAccessKey =
        (Option.map ~f:SecretAccessKeyType.of_xml)
          (Xml.child xml_arg0 "secretAccessKey") in
      let accessKeyId =
        (Option.map ~f:AccessKeyType.of_xml)
          (Xml.child xml_arg0 "accessKeyId") in
      make ?expiration ?sessionToken ?secretAccessKey ?accessKeyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let expiration =
        field_map json__ "expiration" ExpirationTimestampType.of_json in
      let sessionToken =
        field_map json__ "sessionToken" SessionTokenType.of_json in
      let secretAccessKey =
        field_map json__ "secretAccessKey" SecretAccessKeyType.of_json in
      let accessKeyId = field_map json__ "accessKeyId" AccessKeyType.of_json in
      make ?expiration ?sessionToken ?secretAccessKey ?accessKeyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Provides information about the role credentials that are assigned to the user."]
module LogoutRequest =
  struct
    type nonrec t =
      {
      accessToken: AccessTokenType.t
        [@ocaml.doc
          "The token issued by the CreateToken API call. For more information, see CreateToken in the IAM Identity Center OIDC API Reference Guide."]}
    let context_ = "LogoutRequest"
    let make ~accessToken = fun () -> { accessToken }
    let of_header_and_body =
      ((fun (xs, pipe) ->
          make
            ~accessToken:(AccessTokenType.of_string
                            ((List.Assoc.find_exn
                                ~equal:String.Caseless.equal) xs
                               "x-amz-sso_bearer_token")) ())
      [@warning "-27"])
    let to_value x =
      structure_to_value
        [("x-amz-sso_bearer_token",
           (Some (AccessTokenType.to_value x.accessToken)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let accessToken =
        AccessTokenType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "x-amz-sso_bearer_token") in
      make ~accessToken ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let accessToken =
        field_map_exn json__ "accessToken" AccessTokenType.of_json in
      make ~accessToken ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Removes the locally stored SSO tokens from the client-side cache and sends an API call to the IAM Identity Center service to invalidate the corresponding server-side IAM Identity Center sign in session. If a user uses IAM Identity Center to access the AWS CLI, the user\226\128\153s IAM Identity Center sign in session is used to obtain an IAM session, as specified in the corresponding IAM Identity Center permission set. More specifically, IAM Identity Center assumes an IAM role in the target account on behalf of the user, and the corresponding temporary AWS credentials are returned to the client. After user logout, any existing IAM role sessions that were created by using IAM Identity Center permission sets continue based on the duration configured in the permission set. For more information, see User authentications in the IAM Identity Center User Guide."]
module ListAccountsResponse =
  struct
    type nonrec t =
      {
      nextToken: NextTokenType.t option
        [@ocaml.doc
          "The page token client that is used to retrieve the list of accounts."];
      accountList: AccountListType.t option
        [@ocaml.doc
          "A paginated response with the list of account information and the next token if more results are available."]}
    type nonrec error =
      [ `InvalidRequestException of InvalidRequestException.t 
      | `ResourceNotFoundException of ResourceNotFoundException.t 
      | `TooManyRequestsException of TooManyRequestsException.t 
      | `UnauthorizedException of UnauthorizedException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?nextToken =
      fun ?accountList -> fun () -> { nextToken; accountList }
    let error_of_json name json =
      match name with
      | "InvalidRequestException" ->
          `InvalidRequestException (InvalidRequestException.of_json json)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_json json)
      | "TooManyRequestsException" ->
          `TooManyRequestsException (TooManyRequestsException.of_json json)
      | "UnauthorizedException" ->
          `UnauthorizedException (UnauthorizedException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "InvalidRequestException" ->
          `InvalidRequestException (InvalidRequestException.of_xml xml)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_xml xml)
      | "TooManyRequestsException" ->
          `TooManyRequestsException (TooManyRequestsException.of_xml xml)
      | "UnauthorizedException" ->
          `UnauthorizedException (UnauthorizedException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `InvalidRequestException e ->
          `Assoc
            [("error", (`String "InvalidRequestException"));
            ("details", (InvalidRequestException.to_json e))]
      | `ResourceNotFoundException e ->
          `Assoc
            [("error", (`String "ResourceNotFoundException"));
            ("details", (ResourceNotFoundException.to_json e))]
      | `TooManyRequestsException e ->
          `Assoc
            [("error", (`String "TooManyRequestsException"));
            ("details", (TooManyRequestsException.to_json e))]
      | `UnauthorizedException e ->
          `Assoc
            [("error", (`String "UnauthorizedException"));
            ("details", (UnauthorizedException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("nextToken", (Option.map x.nextToken ~f:NextTokenType.to_value));
        ("accountList",
          (Option.map x.accountList ~f:AccountListType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let accountList =
        (Option.map ~f:AccountListType.of_xml)
          (Xml.child xml_arg0 "accountList") in
      let nextToken =
        (Option.map ~f:NextTokenType.of_xml) (Xml.child xml_arg0 "nextToken") in
      make ?accountList ?nextToken ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let accountList =
        field_map json__ "accountList" AccountListType.of_json in
      let nextToken = field_map json__ "nextToken" NextTokenType.of_json in
      make ?accountList ?nextToken ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Lists all AWS accounts assigned to the user. These AWS accounts are assigned by the administrator of the account. For more information, see Assign User Access in the IAM Identity Center User Guide. This operation returns a paginated response."]
module ListAccountsRequest =
  struct
    type nonrec t =
      {
      nextToken: NextTokenType.t option
        [@ocaml.doc
          "(Optional) When requesting subsequent pages, this is the page token from the previous response output."];
      maxResults: MaxResultType.t option
        [@ocaml.doc
          "This is the number of items clients can request per page."];
      accessToken: AccessTokenType.t
        [@ocaml.doc
          "The token issued by the CreateToken API call. For more information, see CreateToken in the IAM Identity Center OIDC API Reference Guide."]}
    let context_ = "ListAccountsRequest"
    let make ?nextToken =
      fun ?maxResults ->
        fun ~accessToken -> fun () -> { nextToken; maxResults; accessToken }
    let to_value x =
      structure_to_value
        [("next_token", (Option.map x.nextToken ~f:NextTokenType.to_value));
        ("max_result", (Option.map x.maxResults ~f:MaxResultType.to_value));
        ("x-amz-sso_bearer_token",
          (Some (AccessTokenType.to_value x.accessToken)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let accessToken =
        AccessTokenType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "x-amz-sso_bearer_token") in
      let maxResults =
        (Option.map ~f:MaxResultType.of_xml)
          (Xml.child xml_arg0 "max_result") in
      let nextToken =
        (Option.map ~f:NextTokenType.of_xml)
          (Xml.child xml_arg0 "next_token") in
      make ~accessToken ?maxResults ?nextToken ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let accessToken =
        field_map_exn json__ "accessToken" AccessTokenType.of_json in
      let maxResults = field_map json__ "maxResults" MaxResultType.of_json in
      let nextToken = field_map json__ "nextToken" NextTokenType.of_json in
      make ~accessToken ?maxResults ?nextToken ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Lists all AWS accounts assigned to the user. These AWS accounts are assigned by the administrator of the account. For more information, see Assign User Access in the IAM Identity Center User Guide. This operation returns a paginated response."]
module ListAccountRolesResponse =
  struct
    type nonrec t =
      {
      nextToken: NextTokenType.t option
        [@ocaml.doc
          "The page token client that is used to retrieve the list of accounts."];
      roleList: RoleListType.t option
        [@ocaml.doc
          "A paginated response with the list of roles and the next token if more results are available."]}
    type nonrec error =
      [ `InvalidRequestException of InvalidRequestException.t 
      | `ResourceNotFoundException of ResourceNotFoundException.t 
      | `TooManyRequestsException of TooManyRequestsException.t 
      | `UnauthorizedException of UnauthorizedException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?nextToken = fun ?roleList -> fun () -> { nextToken; roleList }
    let error_of_json name json =
      match name with
      | "InvalidRequestException" ->
          `InvalidRequestException (InvalidRequestException.of_json json)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_json json)
      | "TooManyRequestsException" ->
          `TooManyRequestsException (TooManyRequestsException.of_json json)
      | "UnauthorizedException" ->
          `UnauthorizedException (UnauthorizedException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "InvalidRequestException" ->
          `InvalidRequestException (InvalidRequestException.of_xml xml)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_xml xml)
      | "TooManyRequestsException" ->
          `TooManyRequestsException (TooManyRequestsException.of_xml xml)
      | "UnauthorizedException" ->
          `UnauthorizedException (UnauthorizedException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `InvalidRequestException e ->
          `Assoc
            [("error", (`String "InvalidRequestException"));
            ("details", (InvalidRequestException.to_json e))]
      | `ResourceNotFoundException e ->
          `Assoc
            [("error", (`String "ResourceNotFoundException"));
            ("details", (ResourceNotFoundException.to_json e))]
      | `TooManyRequestsException e ->
          `Assoc
            [("error", (`String "TooManyRequestsException"));
            ("details", (TooManyRequestsException.to_json e))]
      | `UnauthorizedException e ->
          `Assoc
            [("error", (`String "UnauthorizedException"));
            ("details", (UnauthorizedException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("nextToken", (Option.map x.nextToken ~f:NextTokenType.to_value));
        ("roleList", (Option.map x.roleList ~f:RoleListType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let roleList =
        (Option.map ~f:RoleListType.of_xml) (Xml.child xml_arg0 "roleList") in
      let nextToken =
        (Option.map ~f:NextTokenType.of_xml) (Xml.child xml_arg0 "nextToken") in
      make ?roleList ?nextToken ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let roleList = field_map json__ "roleList" RoleListType.of_json in
      let nextToken = field_map json__ "nextToken" NextTokenType.of_json in
      make ?roleList ?nextToken ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Lists all roles that are assigned to the user for a given AWS account."]
module ListAccountRolesRequest =
  struct
    type nonrec t =
      {
      nextToken: NextTokenType.t option
        [@ocaml.doc
          "The page token from the previous response output when you request subsequent pages."];
      maxResults: MaxResultType.t option
        [@ocaml.doc "The number of items that clients can request per page."];
      accessToken: AccessTokenType.t
        [@ocaml.doc
          "The token issued by the CreateToken API call. For more information, see CreateToken in the IAM Identity Center OIDC API Reference Guide."];
      accountId: AccountIdType.t
        [@ocaml.doc
          "The identifier for the AWS account that is assigned to the user."]}
    let context_ = "ListAccountRolesRequest"
    let make ?nextToken =
      fun ?maxResults ->
        fun ~accessToken ->
          fun ~accountId ->
            fun () -> { nextToken; maxResults; accessToken; accountId }
    let to_value x =
      structure_to_value
        [("next_token", (Option.map x.nextToken ~f:NextTokenType.to_value));
        ("max_result", (Option.map x.maxResults ~f:MaxResultType.to_value));
        ("x-amz-sso_bearer_token",
          (Some (AccessTokenType.to_value x.accessToken)));
        ("account_id", (Some (AccountIdType.to_value x.accountId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let accountId =
        AccountIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "account_id") in
      let accessToken =
        AccessTokenType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "x-amz-sso_bearer_token") in
      let maxResults =
        (Option.map ~f:MaxResultType.of_xml)
          (Xml.child xml_arg0 "max_result") in
      let nextToken =
        (Option.map ~f:NextTokenType.of_xml)
          (Xml.child xml_arg0 "next_token") in
      make ~accountId ~accessToken ?maxResults ?nextToken ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let accountId = field_map_exn json__ "accountId" AccountIdType.of_json in
      let accessToken =
        field_map_exn json__ "accessToken" AccessTokenType.of_json in
      let maxResults = field_map json__ "maxResults" MaxResultType.of_json in
      let nextToken = field_map json__ "nextToken" NextTokenType.of_json in
      make ~accountId ~accessToken ?maxResults ?nextToken ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Lists all roles that are assigned to the user for a given AWS account."]
module GetRoleCredentialsResponse =
  struct
    type nonrec t =
      {
      roleCredentials: RoleCredentials.t option
        [@ocaml.doc
          "The credentials for the role that is assigned to the user."]}
    type nonrec error =
      [ `InvalidRequestException of InvalidRequestException.t 
      | `ResourceNotFoundException of ResourceNotFoundException.t 
      | `TooManyRequestsException of TooManyRequestsException.t 
      | `UnauthorizedException of UnauthorizedException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?roleCredentials = fun () -> { roleCredentials }
    let error_of_json name json =
      match name with
      | "InvalidRequestException" ->
          `InvalidRequestException (InvalidRequestException.of_json json)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_json json)
      | "TooManyRequestsException" ->
          `TooManyRequestsException (TooManyRequestsException.of_json json)
      | "UnauthorizedException" ->
          `UnauthorizedException (UnauthorizedException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "InvalidRequestException" ->
          `InvalidRequestException (InvalidRequestException.of_xml xml)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_xml xml)
      | "TooManyRequestsException" ->
          `TooManyRequestsException (TooManyRequestsException.of_xml xml)
      | "UnauthorizedException" ->
          `UnauthorizedException (UnauthorizedException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `InvalidRequestException e ->
          `Assoc
            [("error", (`String "InvalidRequestException"));
            ("details", (InvalidRequestException.to_json e))]
      | `ResourceNotFoundException e ->
          `Assoc
            [("error", (`String "ResourceNotFoundException"));
            ("details", (ResourceNotFoundException.to_json e))]
      | `TooManyRequestsException e ->
          `Assoc
            [("error", (`String "TooManyRequestsException"));
            ("details", (TooManyRequestsException.to_json e))]
      | `UnauthorizedException e ->
          `Assoc
            [("error", (`String "UnauthorizedException"));
            ("details", (UnauthorizedException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("roleCredentials",
           (Option.map x.roleCredentials ~f:RoleCredentials.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let roleCredentials =
        (Option.map ~f:RoleCredentials.of_xml)
          (Xml.child xml_arg0 "roleCredentials") in
      make ?roleCredentials ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let roleCredentials =
        field_map json__ "roleCredentials" RoleCredentials.of_json in
      make ?roleCredentials ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns the STS short-term credentials for a given role name that is assigned to the user."]
module GetRoleCredentialsRequest =
  struct
    type nonrec t =
      {
      roleName: RoleNameType.t
        [@ocaml.doc
          "The friendly name of the role that is assigned to the user."];
      accountId: AccountIdType.t
        [@ocaml.doc
          "The identifier for the AWS account that is assigned to the user."];
      accessToken: AccessTokenType.t
        [@ocaml.doc
          "The token issued by the CreateToken API call. For more information, see CreateToken in the IAM Identity Center OIDC API Reference Guide."]}
    let context_ = "GetRoleCredentialsRequest"
    let make ~roleName =
      fun ~accountId ->
        fun ~accessToken -> fun () -> { roleName; accountId; accessToken }
    let to_value x =
      structure_to_value
        [("role_name", (Some (RoleNameType.to_value x.roleName)));
        ("account_id", (Some (AccountIdType.to_value x.accountId)));
        ("x-amz-sso_bearer_token",
          (Some (AccessTokenType.to_value x.accessToken)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let accessToken =
        AccessTokenType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "x-amz-sso_bearer_token") in
      let accountId =
        AccountIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "account_id") in
      let roleName =
        RoleNameType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "role_name") in
      make ~accessToken ~accountId ~roleName ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let accessToken =
        field_map_exn json__ "accessToken" AccessTokenType.of_json in
      let accountId = field_map_exn json__ "accountId" AccountIdType.of_json in
      let roleName = field_map_exn json__ "roleName" RoleNameType.of_json in
      make ~accessToken ~accountId ~roleName ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns the STS short-term credentials for a given role name that is assigned to the user."]