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
(* 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.ec2_instance_connect
let apiVersion = "2018-04-02"
let endpointPrefix = "ec2-instance-connect"
let serviceFullName = "AWS EC2 Instance Connect"
let signatureVersion = "v4"
let protocol = "json"
let globalEndpoint = endpointPrefix ^ ".amazonaws.com"
let serviceAbbreviation = "EC2 Instance Connect"
let targetPrefix = "AWSEC2InstanceConnectService"
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 String_ =
  struct
    type nonrec t = string
    let context_ = "String"
    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:"String" j
    let to_json = simple_to_json to_value
  end
module AuthException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Either your AWS credentials are not valid or you do not have access to the EC2 instance."]
module EC2InstanceNotFoundException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "The specified instance was not found."]
module EC2InstanceStateInvalidException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Unable to connect because the instance is not in a valid state. Connecting to a stopped or terminated instance is not supported. If the instance is stopped, start your instance, and try to connect again."]
module EC2InstanceTypeInvalidException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The instance type is not supported for connecting via the serial console. Only Nitro instance types are currently supported."]
module EC2InstanceUnavailableException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The instance is currently unavailable. Wait a few minutes and try again."]
module InvalidArgsException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "One of the parameters is not valid."]
module RequestId =
  struct
    type nonrec t = string
    let context_ = "RequestId"
    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:"RequestId" j
    let to_json = simple_to_json to_value
  end
module SerialConsoleAccessDisabledException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Your account is not authorized to use the EC2 Serial Console. To authorize your account, run the EnableSerialConsoleAccess API. For more information, see EnableSerialConsoleAccess in the Amazon EC2 API Reference."]
module SerialConsoleSessionLimitExceededException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The instance currently has 1 active serial console session. Only 1 session is supported at a time."]
module SerialConsoleSessionUnavailableException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Unable to start a serial console session. Please try again."]
module SerialConsoleSessionUnsupportedException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Your instance's BIOS version is unsupported for serial console connection. Reboot your instance to update its BIOS, and then try again to connect."]
module ServiceException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The service encountered an error. Follow the instructions in the error message and try again."]
module Success =
  struct
    type nonrec t = bool
    let make i = i
    let of_string = Bool.of_string
    let to_value x = `Boolean x
    let to_query v = to_query to_value v
    let to_header x = Bool.to_string x
    let of_xml xml_arg0 =
      Bool.of_string (string_of_xml ~kind:"a boolean" xml_arg0)
    let of_json = bool_of_json
    let to_json = simple_to_json to_value
  end
module ThrottlingException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("Message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The requests were made too frequently and have been throttled. Wait a while and try again. To increase the limit on your request frequency, contact AWS Support."]
module InstanceId =
  struct
    type nonrec t = string
    let context_ = "InstanceId"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:10) >>=
             (fun () ->
                (check_string_max i ~max:32) >>=
                  (fun () -> check_pattern i ~pattern:"^i-[a-f0-9]+$")));
        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:"InstanceId" j
    let to_json = simple_to_json to_value
  end
module SSHPublicKey =
  struct
    type nonrec t = string
    let context_ = "SSHPublicKey"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:4096) >>=
             (fun () -> check_string_min i ~min:80));
        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:"SSHPublicKey" j
    let to_json = simple_to_json to_value
  end
module SerialPort =
  struct
    type nonrec t = int
    let make i =
      let open Result in
        ok_or_failwith
          ((check_int_max i ~max:0) >>= (fun () -> check_int_min i ~min:0));
        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 SerialPort" 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 AvailabilityZone =
  struct
    type nonrec t = string
    let context_ = "AvailabilityZone"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:6) >>=
             (fun () ->
                (check_string_max i ~max:32) >>=
                  (fun () ->
                     check_pattern i ~pattern:"^(\\w+-){2,3}\\d+\\w+$")));
        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:"AvailabilityZone" j
    let to_json = simple_to_json to_value
  end
module InstanceOSUser =
  struct
    type nonrec t = string
    let context_ = "InstanceOSUser"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:32) >>=
                  (fun () ->
                     check_pattern i
                       ~pattern:"(^[A-Za-z_][A-Za-z0-9\\@\\._-]{0,30}[A-Za-z0-9\\$_-]?$)|(^(?=.{2,32}$)[0-9]{1,32}[A-Za-z\\@\\._-][A-Za-z0-9\\@\\._-]*[A-Za-z0-9\\$_-]?$)")));
        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:"InstanceOSUser" j
    let to_json = simple_to_json to_value
  end
module SendSerialConsoleSSHPublicKeyResponse =
  struct
    type nonrec t =
      {
      requestId: RequestId.t option
        [@ocaml.doc
          "The ID of the request. Please provide this ID when contacting AWS Support for assistance."];
      success: Success.t option
        [@ocaml.doc
          "Is true if the request succeeds and an error otherwise."]}
    type nonrec error =
      [ `AuthException of AuthException.t 
      | `EC2InstanceNotFoundException of EC2InstanceNotFoundException.t 
      | `EC2InstanceStateInvalidException of
          EC2InstanceStateInvalidException.t 
      | `EC2InstanceTypeInvalidException of EC2InstanceTypeInvalidException.t 
      | `EC2InstanceUnavailableException of EC2InstanceUnavailableException.t 
      | `InvalidArgsException of InvalidArgsException.t 
      | `SerialConsoleAccessDisabledException of
          SerialConsoleAccessDisabledException.t 
      | `SerialConsoleSessionLimitExceededException of
          SerialConsoleSessionLimitExceededException.t 
      | `SerialConsoleSessionUnavailableException of
          SerialConsoleSessionUnavailableException.t 
      | `SerialConsoleSessionUnsupportedException of
          SerialConsoleSessionUnsupportedException.t 
      | `ServiceException of ServiceException.t 
      | `ThrottlingException of ThrottlingException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?requestId = fun ?success -> fun () -> { requestId; success }
    let error_of_json name json =
      match name with
      | "AuthException" -> `AuthException (AuthException.of_json json)
      | "EC2InstanceNotFoundException" ->
          `EC2InstanceNotFoundException
            (EC2InstanceNotFoundException.of_json json)
      | "EC2InstanceStateInvalidException" ->
          `EC2InstanceStateInvalidException
            (EC2InstanceStateInvalidException.of_json json)
      | "EC2InstanceTypeInvalidException" ->
          `EC2InstanceTypeInvalidException
            (EC2InstanceTypeInvalidException.of_json json)
      | "EC2InstanceUnavailableException" ->
          `EC2InstanceUnavailableException
            (EC2InstanceUnavailableException.of_json json)
      | "InvalidArgsException" ->
          `InvalidArgsException (InvalidArgsException.of_json json)
      | "SerialConsoleAccessDisabledException" ->
          `SerialConsoleAccessDisabledException
            (SerialConsoleAccessDisabledException.of_json json)
      | "SerialConsoleSessionLimitExceededException" ->
          `SerialConsoleSessionLimitExceededException
            (SerialConsoleSessionLimitExceededException.of_json json)
      | "SerialConsoleSessionUnavailableException" ->
          `SerialConsoleSessionUnavailableException
            (SerialConsoleSessionUnavailableException.of_json json)
      | "SerialConsoleSessionUnsupportedException" ->
          `SerialConsoleSessionUnsupportedException
            (SerialConsoleSessionUnsupportedException.of_json json)
      | "ServiceException" ->
          `ServiceException (ServiceException.of_json json)
      | "ThrottlingException" ->
          `ThrottlingException (ThrottlingException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "AuthException" -> `AuthException (AuthException.of_xml xml)
      | "EC2InstanceNotFoundException" ->
          `EC2InstanceNotFoundException
            (EC2InstanceNotFoundException.of_xml xml)
      | "EC2InstanceStateInvalidException" ->
          `EC2InstanceStateInvalidException
            (EC2InstanceStateInvalidException.of_xml xml)
      | "EC2InstanceTypeInvalidException" ->
          `EC2InstanceTypeInvalidException
            (EC2InstanceTypeInvalidException.of_xml xml)
      | "EC2InstanceUnavailableException" ->
          `EC2InstanceUnavailableException
            (EC2InstanceUnavailableException.of_xml xml)
      | "InvalidArgsException" ->
          `InvalidArgsException (InvalidArgsException.of_xml xml)
      | "SerialConsoleAccessDisabledException" ->
          `SerialConsoleAccessDisabledException
            (SerialConsoleAccessDisabledException.of_xml xml)
      | "SerialConsoleSessionLimitExceededException" ->
          `SerialConsoleSessionLimitExceededException
            (SerialConsoleSessionLimitExceededException.of_xml xml)
      | "SerialConsoleSessionUnavailableException" ->
          `SerialConsoleSessionUnavailableException
            (SerialConsoleSessionUnavailableException.of_xml xml)
      | "SerialConsoleSessionUnsupportedException" ->
          `SerialConsoleSessionUnsupportedException
            (SerialConsoleSessionUnsupportedException.of_xml xml)
      | "ServiceException" -> `ServiceException (ServiceException.of_xml xml)
      | "ThrottlingException" ->
          `ThrottlingException (ThrottlingException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `AuthException e ->
          `Assoc
            [("error", (`String "AuthException"));
            ("details", (AuthException.to_json e))]
      | `EC2InstanceNotFoundException e ->
          `Assoc
            [("error", (`String "EC2InstanceNotFoundException"));
            ("details", (EC2InstanceNotFoundException.to_json e))]
      | `EC2InstanceStateInvalidException e ->
          `Assoc
            [("error", (`String "EC2InstanceStateInvalidException"));
            ("details", (EC2InstanceStateInvalidException.to_json e))]
      | `EC2InstanceTypeInvalidException e ->
          `Assoc
            [("error", (`String "EC2InstanceTypeInvalidException"));
            ("details", (EC2InstanceTypeInvalidException.to_json e))]
      | `EC2InstanceUnavailableException e ->
          `Assoc
            [("error", (`String "EC2InstanceUnavailableException"));
            ("details", (EC2InstanceUnavailableException.to_json e))]
      | `InvalidArgsException e ->
          `Assoc
            [("error", (`String "InvalidArgsException"));
            ("details", (InvalidArgsException.to_json e))]
      | `SerialConsoleAccessDisabledException e ->
          `Assoc
            [("error", (`String "SerialConsoleAccessDisabledException"));
            ("details", (SerialConsoleAccessDisabledException.to_json e))]
      | `SerialConsoleSessionLimitExceededException e ->
          `Assoc
            [("error",
               (`String "SerialConsoleSessionLimitExceededException"));
            ("details",
              (SerialConsoleSessionLimitExceededException.to_json e))]
      | `SerialConsoleSessionUnavailableException e ->
          `Assoc
            [("error", (`String "SerialConsoleSessionUnavailableException"));
            ("details", (SerialConsoleSessionUnavailableException.to_json e))]
      | `SerialConsoleSessionUnsupportedException e ->
          `Assoc
            [("error", (`String "SerialConsoleSessionUnsupportedException"));
            ("details", (SerialConsoleSessionUnsupportedException.to_json e))]
      | `ServiceException e ->
          `Assoc
            [("error", (`String "ServiceException"));
            ("details", (ServiceException.to_json e))]
      | `ThrottlingException e ->
          `Assoc
            [("error", (`String "ThrottlingException"));
            ("details", (ThrottlingException.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
        [("RequestId", (Option.map x.requestId ~f:RequestId.to_value));
        ("Success", (Option.map x.success ~f:Success.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let success =
        (Option.map ~f:Success.of_xml) (Xml.child xml_arg0 "Success") in
      let requestId =
        (Option.map ~f:RequestId.of_xml) (Xml.child xml_arg0 "RequestId") in
      make ?success ?requestId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let success = field_map json__ "Success" Success.of_json in
      let requestId = field_map json__ "RequestId" RequestId.of_json in
      make ?success ?requestId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Pushes an SSH public key to the specified EC2 instance. The key remains for 60 seconds, which gives you 60 seconds to establish a serial console connection to the instance using SSH. For more information, see EC2 Serial Console in the Amazon EC2 User Guide."]
module SendSerialConsoleSSHPublicKeyRequest =
  struct
    type nonrec t =
      {
      instanceId: InstanceId.t [@ocaml.doc "The ID of the EC2 instance."];
      serialPort: SerialPort.t option
        [@ocaml.doc
          "The serial port of the EC2 instance. Currently only port 0 is supported. Default: 0"];
      sSHPublicKey: SSHPublicKey.t
        [@ocaml.doc
          "The public key material. To use the public key, you must have the matching private key. For information about the supported key formats and lengths, see Requirements for key pairs in the Amazon EC2 User Guide."]}
    let context_ = "SendSerialConsoleSSHPublicKeyRequest"
    let make ?serialPort =
      fun ~instanceId ->
        fun ~sSHPublicKey ->
          fun () -> { serialPort; instanceId; sSHPublicKey }
    let to_value x =
      structure_to_value
        [("InstanceId", (Some (InstanceId.to_value x.instanceId)));
        ("SerialPort", (Option.map x.serialPort ~f:SerialPort.to_value));
        ("SSHPublicKey", (Some (SSHPublicKey.to_value x.sSHPublicKey)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let sSHPublicKey =
        SSHPublicKey.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "SSHPublicKey") in
      let serialPort =
        (Option.map ~f:SerialPort.of_xml) (Xml.child xml_arg0 "SerialPort") in
      let instanceId =
        InstanceId.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "InstanceId") in
      make ~sSHPublicKey ?serialPort ~instanceId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let sSHPublicKey =
        field_map_exn json__ "SSHPublicKey" SSHPublicKey.of_json in
      let serialPort = field_map json__ "SerialPort" SerialPort.of_json in
      let instanceId = field_map_exn json__ "InstanceId" InstanceId.of_json in
      make ~sSHPublicKey ?serialPort ~instanceId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Pushes an SSH public key to the specified EC2 instance. The key remains for 60 seconds, which gives you 60 seconds to establish a serial console connection to the instance using SSH. For more information, see EC2 Serial Console in the Amazon EC2 User Guide."]
module SendSSHPublicKeyResponse =
  struct
    type nonrec t =
      {
      requestId: RequestId.t option
        [@ocaml.doc
          "The ID of the request. Please provide this ID when contacting AWS Support for assistance."];
      success: Success.t option
        [@ocaml.doc
          "Is true if the request succeeds and an error otherwise."]}
    type nonrec error =
      [ `AuthException of AuthException.t 
      | `EC2InstanceNotFoundException of EC2InstanceNotFoundException.t 
      | `EC2InstanceStateInvalidException of
          EC2InstanceStateInvalidException.t 
      | `EC2InstanceUnavailableException of EC2InstanceUnavailableException.t 
      | `InvalidArgsException of InvalidArgsException.t 
      | `ServiceException of ServiceException.t 
      | `ThrottlingException of ThrottlingException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?requestId = fun ?success -> fun () -> { requestId; success }
    let error_of_json name json =
      match name with
      | "AuthException" -> `AuthException (AuthException.of_json json)
      | "EC2InstanceNotFoundException" ->
          `EC2InstanceNotFoundException
            (EC2InstanceNotFoundException.of_json json)
      | "EC2InstanceStateInvalidException" ->
          `EC2InstanceStateInvalidException
            (EC2InstanceStateInvalidException.of_json json)
      | "EC2InstanceUnavailableException" ->
          `EC2InstanceUnavailableException
            (EC2InstanceUnavailableException.of_json json)
      | "InvalidArgsException" ->
          `InvalidArgsException (InvalidArgsException.of_json json)
      | "ServiceException" ->
          `ServiceException (ServiceException.of_json json)
      | "ThrottlingException" ->
          `ThrottlingException (ThrottlingException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "AuthException" -> `AuthException (AuthException.of_xml xml)
      | "EC2InstanceNotFoundException" ->
          `EC2InstanceNotFoundException
            (EC2InstanceNotFoundException.of_xml xml)
      | "EC2InstanceStateInvalidException" ->
          `EC2InstanceStateInvalidException
            (EC2InstanceStateInvalidException.of_xml xml)
      | "EC2InstanceUnavailableException" ->
          `EC2InstanceUnavailableException
            (EC2InstanceUnavailableException.of_xml xml)
      | "InvalidArgsException" ->
          `InvalidArgsException (InvalidArgsException.of_xml xml)
      | "ServiceException" -> `ServiceException (ServiceException.of_xml xml)
      | "ThrottlingException" ->
          `ThrottlingException (ThrottlingException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `AuthException e ->
          `Assoc
            [("error", (`String "AuthException"));
            ("details", (AuthException.to_json e))]
      | `EC2InstanceNotFoundException e ->
          `Assoc
            [("error", (`String "EC2InstanceNotFoundException"));
            ("details", (EC2InstanceNotFoundException.to_json e))]
      | `EC2InstanceStateInvalidException e ->
          `Assoc
            [("error", (`String "EC2InstanceStateInvalidException"));
            ("details", (EC2InstanceStateInvalidException.to_json e))]
      | `EC2InstanceUnavailableException e ->
          `Assoc
            [("error", (`String "EC2InstanceUnavailableException"));
            ("details", (EC2InstanceUnavailableException.to_json e))]
      | `InvalidArgsException e ->
          `Assoc
            [("error", (`String "InvalidArgsException"));
            ("details", (InvalidArgsException.to_json e))]
      | `ServiceException e ->
          `Assoc
            [("error", (`String "ServiceException"));
            ("details", (ServiceException.to_json e))]
      | `ThrottlingException e ->
          `Assoc
            [("error", (`String "ThrottlingException"));
            ("details", (ThrottlingException.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
        [("RequestId", (Option.map x.requestId ~f:RequestId.to_value));
        ("Success", (Option.map x.success ~f:Success.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let success =
        (Option.map ~f:Success.of_xml) (Xml.child xml_arg0 "Success") in
      let requestId =
        (Option.map ~f:RequestId.of_xml) (Xml.child xml_arg0 "RequestId") in
      make ?success ?requestId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let success = field_map json__ "Success" Success.of_json in
      let requestId = field_map json__ "RequestId" RequestId.of_json in
      make ?success ?requestId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Pushes an SSH public key to the specified EC2 instance for use by the specified user. The key remains for 60 seconds. For more information, see Connect to your Linux instance using EC2 Instance Connect in the Amazon EC2 User Guide."]
module SendSSHPublicKeyRequest =
  struct
    type nonrec t =
      {
      instanceId: InstanceId.t [@ocaml.doc "The ID of the EC2 instance."];
      instanceOSUser: InstanceOSUser.t
        [@ocaml.doc
          "The OS user on the EC2 instance for whom the key can be used to authenticate."];
      sSHPublicKey: SSHPublicKey.t
        [@ocaml.doc
          "The public key material. To use the public key, you must have the matching private key."];
      availabilityZone: AvailabilityZone.t option
        [@ocaml.doc
          "The Availability Zone in which the EC2 instance was launched."]}
    let context_ = "SendSSHPublicKeyRequest"
    let make ?availabilityZone =
      fun ~instanceId ->
        fun ~instanceOSUser ->
          fun ~sSHPublicKey ->
            fun () ->
              { availabilityZone; instanceId; instanceOSUser; sSHPublicKey }
    let to_value x =
      structure_to_value
        [("InstanceId", (Some (InstanceId.to_value x.instanceId)));
        ("InstanceOSUser", (Some (InstanceOSUser.to_value x.instanceOSUser)));
        ("SSHPublicKey", (Some (SSHPublicKey.to_value x.sSHPublicKey)));
        ("AvailabilityZone",
          (Option.map x.availabilityZone ~f:AvailabilityZone.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let availabilityZone =
        (Option.map ~f:AvailabilityZone.of_xml)
          (Xml.child xml_arg0 "AvailabilityZone") in
      let sSHPublicKey =
        SSHPublicKey.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "SSHPublicKey") in
      let instanceOSUser =
        InstanceOSUser.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "InstanceOSUser") in
      let instanceId =
        InstanceId.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "InstanceId") in
      make ?availabilityZone ~sSHPublicKey ~instanceOSUser ~instanceId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let availabilityZone =
        field_map json__ "AvailabilityZone" AvailabilityZone.of_json in
      let sSHPublicKey =
        field_map_exn json__ "SSHPublicKey" SSHPublicKey.of_json in
      let instanceOSUser =
        field_map_exn json__ "InstanceOSUser" InstanceOSUser.of_json in
      let instanceId = field_map_exn json__ "InstanceId" InstanceId.of_json in
      make ?availabilityZone ~sSHPublicKey ~instanceOSUser ~instanceId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Pushes an SSH public key to the specified EC2 instance for use by the specified user. The key remains for 60 seconds. For more information, see Connect to your Linux instance using EC2 Instance Connect in the Amazon EC2 User Guide."]