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
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
(* 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.personalize_runtime
let apiVersion = "2018-05-22"
let endpointPrefix = "personalize-runtime"
let serviceFullName = "Amazon Personalize Runtime"
let signatureVersion = "v4"
let protocol = "rest_json"
let globalEndpoint = endpointPrefix ^ ".amazonaws.com"
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 ColumnName =
  struct
    type nonrec t = string
    let context_ = "ColumnName"
    let make i =
      let open Result in ok_or_failwith (check_string_max i ~max:150); 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:"ColumnName" j
    let to_json = simple_to_json to_value
  end
module ColumnValue =
  struct
    type nonrec t = string
    let context_ = "ColumnValue"
    let make i =
      let open Result in ok_or_failwith (check_string_max i ~max:20000); 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:"ColumnValue" j
    let to_json = simple_to_json to_value
  end
module Reason =
  struct
    type nonrec t = string
    let context_ = "Reason"
    let make i =
      let open Result in ok_or_failwith (check_string_max i ~max:256); 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:"Reason" j
    let to_json = simple_to_json to_value
  end
module FilterAttributeName =
  struct
    type nonrec t = string
    let context_ = "FilterAttributeName"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:50) >>=
             (fun () -> check_pattern i ~pattern:"[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:"FilterAttributeName" j
    let to_json = simple_to_json to_value
  end
module FilterAttributeValue =
  struct
    type nonrec t = string
    let context_ = "FilterAttributeValue"
    let make i =
      let open Result in ok_or_failwith (check_string_max i ~max:1000); 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:"FilterAttributeValue" j
    let to_json = simple_to_json to_value
  end
module ItemID =
  struct
    type nonrec t = string
    let context_ = "ItemID"
    let make i =
      let open Result in ok_or_failwith (check_string_max i ~max:256); 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:"ItemID" j
    let to_json = simple_to_json to_value
  end
module Metadata =
  struct
    type nonrec t = (ColumnName.t * ColumnValue.t) list
    let make i = i
    let of_header xs =
      make
        (List.filter_map xs
           ~f:(fun (k, v) ->
                 (Base.String.chop_prefix k ~prefix:"x-amz-meta-") |>
                   (Option.map
                      ~f:(fun chopped ->
                            ((ColumnName.of_string chopped),
                              (ColumnValue.of_string v))))))
    let to_value xs =
      (xs |>
         (List.map
            ~f:(fun (x, y) ->
                  (ColumnName.to_value x) |>
                    (fun x -> (ColumnValue.to_value y) |> (fun y -> (x, y))))))
        |> (fun x -> `Map x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for Map_shape objects" ()
    let of_xml _ =
      failwith "of_xml_converter_of_shape: Map_shape case not implemented"
    let of_json j =
      object_of_json ~key_of_string:ColumnName.of_string
        ~of_json:ColumnValue.of_json j
    let to_json v = composed_to_json to_value v
  end
module Name =
  struct
    type nonrec t = string
    let context_ = "Name"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:63) >>=
                  (fun () ->
                     check_pattern i ~pattern:"^[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:"Name" j
    let to_json = simple_to_json to_value
  end
module ReasonList =
  struct
    type nonrec t = Reason.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:Reason.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:Reason.of_xml)
    let of_json j = list_of_json ~kind:"ReasonList" ~of_json:Reason.of_json j
    let to_json v = composed_to_json to_value v
  end
module Score =
  struct
    type nonrec t = float
    let make i = i
    let of_string = Float.of_string
    let to_value x = `Double x
    let to_query v = to_query to_value v
    let to_header x = Stdlib.Float.to_string x
    let of_xml xml_arg0 =
      Float.of_string (string_of_xml ~kind:"a double" xml_arg0)
    let of_json j = float_of_json ~kind:"a double" j
    let to_json = simple_to_json to_value
  end
module Arn =
  struct
    type nonrec t = string
    let context_ = "Arn"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:256) >>=
             (fun () ->
                check_pattern i
                  ~pattern:"arn:([a-z\\d-]+):personalize:.*:.*:.+"));
        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:"Arn" j
    let to_json = simple_to_json to_value
  end
module FilterValues =
  struct
    type nonrec t = (FilterAttributeName.t * FilterAttributeValue.t) list
    let make i =
      let open Result in ok_or_failwith (check_list_max i ~max:25); i
    let of_header xs =
      make
        (List.filter_map xs
           ~f:(fun (k, v) ->
                 (Base.String.chop_prefix k ~prefix:"x-amz-meta-") |>
                   (Option.map
                      ~f:(fun chopped ->
                            ((FilterAttributeName.of_string chopped),
                              (FilterAttributeValue.of_string v))))))
    let to_value xs =
      (xs |>
         (List.map
            ~f:(fun (x, y) ->
                  (FilterAttributeName.to_value x) |>
                    (fun x ->
                       (FilterAttributeValue.to_value y) |> (fun y -> (x, y))))))
        |> (fun x -> `Map x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for Map_shape objects" ()
    let of_xml _ =
      failwith "of_xml_converter_of_shape: Map_shape case not implemented"
    let of_json j =
      object_of_json ~key_of_string:FilterAttributeName.of_string
        ~of_json:FilterAttributeValue.of_json j
    let to_json v = composed_to_json to_value v
  end
module PercentPromotedItems =
  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 PercentPromotedItems" 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 ActionID =
  struct
    type nonrec t = string
    let context_ = "ActionID"
    let make i =
      let open Result in ok_or_failwith (check_string_max i ~max:256); 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:"ActionID" j
    let to_json = simple_to_json to_value
  end
module ErrorMessage =
  struct
    type nonrec t = string
    let context_ = "ErrorMessage"
    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:"ErrorMessage" j
    let to_json = simple_to_json to_value
  end
module PredictedItem =
  struct
    type nonrec t =
      {
      itemId: ItemID.t option [@ocaml.doc "The recommended item ID."];
      score: Score.t option
        [@ocaml.doc
          "A numeric representation of the model's certainty that the item will be the next user selection. For more information on scoring logic, see how-scores-work."];
      promotionName: Name.t option
        [@ocaml.doc
          "The name of the promotion that included the predicted item."];
      metadata: Metadata.t option
        [@ocaml.doc "Metadata about the item from your Items dataset."];
      reason: ReasonList.t option
        [@ocaml.doc
          "If you use User-Personalization-v2, a list of reasons for why the item was included in recommendations. Possible reasons include the following: Promoted item - Indicates the item was included as part of a promotion that you applied in your recommendation request. Exploration - Indicates the item was included with exploration. With exploration, recommendations include items with less interactions data or relevance for the user. For more information about exploration, see Exploration. Popular item - Indicates the item was included as a placeholder popular item. If you use a filter, depending on how many recommendations the filter removes, Amazon Personalize might add placeholder items to meet the numResults for your recommendation request. These items are popular items, based on interactions data, that satisfy your filter criteria. They don't have a relevance score for the user."]}
    let make ?itemId =
      fun ?score ->
        fun ?promotionName ->
          fun ?metadata ->
            fun ?reason ->
              fun () -> { itemId; score; promotionName; metadata; reason }
    let to_value x =
      structure_to_value
        [("itemId", (Option.map x.itemId ~f:ItemID.to_value));
        ("score", (Option.map x.score ~f:Score.to_value));
        ("promotionName", (Option.map x.promotionName ~f:Name.to_value));
        ("metadata", (Option.map x.metadata ~f:Metadata.to_value));
        ("reason", (Option.map x.reason ~f:ReasonList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let reason =
        (Option.map ~f:ReasonList.of_xml) (Xml.child xml_arg0 "reason") in
      let metadata =
        (Option.map ~f:Metadata.of_xml) (Xml.child xml_arg0 "metadata") in
      let promotionName =
        (Option.map ~f:Name.of_xml) (Xml.child xml_arg0 "promotionName") in
      let score = (Option.map ~f:Score.of_xml) (Xml.child xml_arg0 "score") in
      let itemId =
        (Option.map ~f:ItemID.of_xml) (Xml.child xml_arg0 "itemId") in
      make ?reason ?metadata ?promotionName ?score ?itemId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let reason = field_map json__ "reason" ReasonList.of_json in
      let metadata = field_map json__ "metadata" Metadata.of_json in
      let promotionName = field_map json__ "promotionName" Name.of_json in
      let score = field_map json__ "score" Score.of_json in
      let itemId = field_map json__ "itemId" ItemID.of_json in
      make ?reason ?metadata ?promotionName ?score ?itemId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "An object that identifies an item. The and APIs return a list of PredictedItems."]
module AttributeName =
  struct
    type nonrec t = string
    let context_ = "AttributeName"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:150) >>=
             (fun () -> check_pattern i ~pattern:"[A-Za-z\\d_]+"));
        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:"AttributeName" j
    let to_json = simple_to_json to_value
  end
module AttributeValue =
  struct
    type nonrec t = string
    let context_ = "AttributeValue"
    let make i =
      let open Result in ok_or_failwith (check_string_max i ~max:1000); 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:"AttributeValue" j
    let to_json = simple_to_json to_value
  end
module ColumnNamesList =
  struct
    type nonrec t = ColumnName.t list
    let make i =
      let open Result in ok_or_failwith (check_list_max i ~max:99); i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:ColumnName.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:ColumnName.of_xml)
    let of_json j =
      list_of_json ~kind:"ColumnNamesList" ~of_json:ColumnName.of_json j
    let to_json v = composed_to_json to_value v
  end
module DatasetType =
  struct
    type nonrec t = string
    let context_ = "DatasetType"
    let make i =
      let open Result in ok_or_failwith (check_string_max i ~max:256); 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:"DatasetType" j
    let to_json = simple_to_json to_value
  end
module Promotion =
  struct
    type nonrec t =
      {
      name: Name.t option [@ocaml.doc "The name of the promotion."];
      percentPromotedItems: PercentPromotedItems.t option
        [@ocaml.doc
          "The percentage of recommended items to apply the promotion to."];
      filterArn: Arn.t option
        [@ocaml.doc
          "The Amazon Resource Name (ARN) of the filter used by the promotion. This filter defines the criteria for promoted items. For more information, see Promotion filters."];
      filterValues: FilterValues.t option
        [@ocaml.doc
          "The values to use when promoting items. For each placeholder parameter in your promotion's filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. For filter expressions that use an INCLUDE element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an EXCLUDE element to exclude items, you can omit the filter-values. In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations. For more information on creating filters, see Filtering recommendations and user segments."]}
    let make ?name =
      fun ?percentPromotedItems ->
        fun ?filterArn ->
          fun ?filterValues ->
            fun () -> { name; percentPromotedItems; filterArn; filterValues }
    let to_value x =
      structure_to_value
        [("name", (Option.map x.name ~f:Name.to_value));
        ("percentPromotedItems",
          (Option.map x.percentPromotedItems ~f:PercentPromotedItems.to_value));
        ("filterArn", (Option.map x.filterArn ~f:Arn.to_value));
        ("filterValues",
          (Option.map x.filterValues ~f:FilterValues.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let filterValues =
        (Option.map ~f:FilterValues.of_xml)
          (Xml.child xml_arg0 "filterValues") in
      let filterArn =
        (Option.map ~f:Arn.of_xml) (Xml.child xml_arg0 "filterArn") in
      let percentPromotedItems =
        (Option.map ~f:PercentPromotedItems.of_xml)
          (Xml.child xml_arg0 "percentPromotedItems") in
      let name = (Option.map ~f:Name.of_xml) (Xml.child xml_arg0 "name") in
      make ?filterValues ?filterArn ?percentPromotedItems ?name ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let filterValues = field_map json__ "filterValues" FilterValues.of_json in
      let filterArn = field_map json__ "filterArn" Arn.of_json in
      let percentPromotedItems =
        field_map json__ "percentPromotedItems" PercentPromotedItems.of_json in
      let name = field_map json__ "name" Name.of_json in
      make ?filterValues ?filterArn ?percentPromotedItems ?name ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Contains information on a promotion. A promotion defines additional business rules that apply to a configurable subset of recommended items."]
module PredictedAction =
  struct
    type nonrec t =
      {
      actionId: ActionID.t option
        [@ocaml.doc "The ID of the recommended action."];
      score: Score.t option
        [@ocaml.doc
          "The score of the recommended action. For information about action scores, see How action recommendation scoring works."]}
    let make ?actionId = fun ?score -> fun () -> { actionId; score }
    let to_value x =
      structure_to_value
        [("actionId", (Option.map x.actionId ~f:ActionID.to_value));
        ("score", (Option.map x.score ~f:Score.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let score = (Option.map ~f:Score.of_xml) (Xml.child xml_arg0 "score") in
      let actionId =
        (Option.map ~f:ActionID.of_xml) (Xml.child xml_arg0 "actionId") in
      make ?score ?actionId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let score = field_map json__ "score" Score.of_json in
      let actionId = field_map json__ "actionId" ActionID.of_json in
      make ?score ?actionId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "An object that identifies an action. The API returns a list of PredictedActions."]
module InvalidInputException =
  struct
    type nonrec t = {
      message: ErrorMessage.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessage.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessage.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" ErrorMessage.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Provide a valid value for the field or parameter."]
module ItemList =
  struct
    type nonrec t = PredictedItem.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:PredictedItem.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:PredictedItem.of_xml)
    let of_json j =
      list_of_json ~kind:"ItemList" ~of_json:PredictedItem.of_json j
    let to_json v = composed_to_json to_value v
  end
module RecommendationID =
  struct
    type nonrec t = string
    let context_ = "RecommendationID"
    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:"RecommendationID" j
    let to_json = simple_to_json to_value
  end
module ResourceNotFoundException =
  struct
    type nonrec t = {
      message: ErrorMessage.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessage.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessage.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" ErrorMessage.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "The specified resource does not exist."]
module Context =
  struct
    type nonrec t = (AttributeName.t * AttributeValue.t) list
    let make i =
      let open Result in ok_or_failwith (check_list_max i ~max:150); i
    let of_header xs =
      make
        (List.filter_map xs
           ~f:(fun (k, v) ->
                 (Base.String.chop_prefix k ~prefix:"x-amz-meta-") |>
                   (Option.map
                      ~f:(fun chopped ->
                            ((AttributeName.of_string chopped),
                              (AttributeValue.of_string v))))))
    let to_value xs =
      (xs |>
         (List.map
            ~f:(fun (x, y) ->
                  (AttributeName.to_value x) |>
                    (fun x ->
                       (AttributeValue.to_value y) |> (fun y -> (x, y))))))
        |> (fun x -> `Map x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for Map_shape objects" ()
    let of_xml _ =
      failwith "of_xml_converter_of_shape: Map_shape case not implemented"
    let of_json j =
      object_of_json ~key_of_string:AttributeName.of_string
        ~of_json:AttributeValue.of_json j
    let to_json v = composed_to_json to_value v
  end
module MetadataColumns =
  struct
    type nonrec t = (DatasetType.t * ColumnNamesList.t) list
    let make i =
      let open Result in ok_or_failwith (check_list_max i ~max:1); i
    let of_header xs =
      make
        (List.filter_map xs
           ~f:(fun (k, v) ->
                 (Base.String.chop_prefix k ~prefix:"x-amz-meta-") |>
                   (Option.map
                      ~f:(fun chopped ->
                            let (_ : string) = v in
                            let (_ : string) = chopped in
                            failwith
                              "no of_header for complex types DatasetType ColumnNamesList"))))
    let to_value xs =
      (xs |>
         (List.map
            ~f:(fun (x, y) ->
                  (DatasetType.to_value x) |>
                    (fun x ->
                       (ColumnNamesList.to_value y) |> (fun y -> (x, y))))))
        |> (fun x -> `Map x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for Map_shape objects" ()
    let of_xml _ =
      failwith "of_xml_converter_of_shape: Map_shape case not implemented"
    let of_json j =
      object_of_json ~key_of_string:DatasetType.of_string
        ~of_json:ColumnNamesList.of_json j
    let to_json v = composed_to_json to_value v
  end
module NumResults =
  struct
    type nonrec t = int
    let make i =
      let open Result in ok_or_failwith (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 NumResults" 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 PromotionList =
  struct
    type nonrec t = Promotion.t list
    let make i =
      let open Result in ok_or_failwith (check_list_max i ~max:1); i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:Promotion.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:Promotion.of_xml)
    let of_json j =
      list_of_json ~kind:"PromotionList" ~of_json:Promotion.of_json j
    let to_json v = composed_to_json to_value v
  end
module UserID =
  struct
    type nonrec t = string
    let context_ = "UserID"
    let make i =
      let open Result in ok_or_failwith (check_string_max i ~max:256); 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:"UserID" j
    let to_json = simple_to_json to_value
  end
module InputList =
  struct
    type nonrec t = ItemID.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:ItemID.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:ItemID.of_xml)
    let of_json j = list_of_json ~kind:"InputList" ~of_json:ItemID.of_json j
    let to_json v = composed_to_json to_value v
  end
module ActionList =
  struct
    type nonrec t = PredictedAction.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:PredictedAction.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:PredictedAction.of_xml)
    let of_json j =
      list_of_json ~kind:"ActionList" ~of_json:PredictedAction.of_json j
    let to_json v = composed_to_json to_value v
  end
module GetRecommendationsResponse =
  struct
    type nonrec t =
      {
      itemList: ItemList.t option
        [@ocaml.doc
          "A list of recommendations sorted in descending order by prediction score. There can be a maximum of 500 items in the list."];
      recommendationId: RecommendationID.t option
        [@ocaml.doc "The ID of the recommendation."]}
    type nonrec error =
      [ `InvalidInputException of InvalidInputException.t 
      | `ResourceNotFoundException of ResourceNotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?itemList =
      fun ?recommendationId -> fun () -> { itemList; recommendationId }
    let error_of_json name json =
      match name with
      | "InvalidInputException" ->
          `InvalidInputException (InvalidInputException.of_json json)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "InvalidInputException" ->
          `InvalidInputException (InvalidInputException.of_xml xml)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `InvalidInputException e ->
          `Assoc
            [("error", (`String "InvalidInputException"));
            ("details", (InvalidInputException.to_json e))]
      | `ResourceNotFoundException e ->
          `Assoc
            [("error", (`String "ResourceNotFoundException"));
            ("details", (ResourceNotFoundException.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
        [("itemList", (Option.map x.itemList ~f:ItemList.to_value));
        ("recommendationId",
          (Option.map x.recommendationId ~f:RecommendationID.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let recommendationId =
        (Option.map ~f:RecommendationID.of_xml)
          (Xml.child xml_arg0 "recommendationId") in
      let itemList =
        (Option.map ~f:ItemList.of_xml) (Xml.child xml_arg0 "itemList") in
      make ?recommendationId ?itemList ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let recommendationId =
        field_map json__ "recommendationId" RecommendationID.of_json in
      let itemList = field_map json__ "itemList" ItemList.of_json in
      make ?recommendationId ?itemList ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a list of recommended items. For campaigns, the campaign's Amazon Resource Name (ARN) is required and the required user and item input depends on the recipe type used to create the solution backing the campaign as follows: USER_PERSONALIZATION - userId required, itemId not used RELATED_ITEMS - itemId required, userId not used Campaigns that are backed by a solution created using a recipe of type PERSONALIZED_RANKING use the API. For recommenders, the recommender's ARN is required and the required item and user input depends on the use case (domain-based recipe) backing the recommender. For information on use case requirements see Choosing recommender use cases."]
module GetRecommendationsRequest =
  struct
    type nonrec t =
      {
      campaignArn: Arn.t option
        [@ocaml.doc
          "The Amazon Resource Name (ARN) of the campaign to use for getting recommendations."];
      itemId: ItemID.t option
        [@ocaml.doc
          "The item ID to provide recommendations for. Required for RELATED_ITEMS recipe type."];
      userId: UserID.t option
        [@ocaml.doc
          "The user ID to provide recommendations for. Required for USER_PERSONALIZATION recipe type."];
      numResults: NumResults.t option
        [@ocaml.doc
          "The number of results to return. The default is 25. If you are including metadata in recommendations, the maximum is 50. Otherwise, the maximum is 500."];
      context: Context.t option
        [@ocaml.doc
          "The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction information that might be relevant when getting a user's recommendations, such as the user's current location or device type."];
      filterArn: Arn.t option
        [@ocaml.doc
          "The ARN of the filter to apply to the returned recommendations. For more information, see Filtering Recommendations. When using this parameter, be sure the filter resource is ACTIVE."];
      filterValues: FilterValues.t option
        [@ocaml.doc
          "The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. For filter expressions that use an INCLUDE element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an EXCLUDE element to exclude items, you can omit the filter-values.In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations. For more information, see Filtering recommendations and user segments."];
      recommenderArn: Arn.t option
        [@ocaml.doc
          "The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender ARN if you created a Domain dataset group with a recommender for a domain use case."];
      promotions: PromotionList.t option
        [@ocaml.doc
          "The promotions to apply to the recommendation request. A promotion defines additional business rules that apply to a configurable subset of recommended items."];
      metadataColumns: MetadataColumns.t option
        [@ocaml.doc
          "If you enabled metadata in recommendations when you created or updated the campaign or recommender, specify the metadata columns from your Items dataset to include in item recommendations. The map key is ITEMS and the value is a list of column names from your Items dataset. The maximum number of columns you can provide is 10. For information about enabling metadata for a campaign, see Enabling metadata in recommendations for a campaign. For information about enabling metadata for a recommender, see Enabling metadata in recommendations for a recommender."]}
    let make ?campaignArn =
      fun ?itemId ->
        fun ?userId ->
          fun ?numResults ->
            fun ?context ->
              fun ?filterArn ->
                fun ?filterValues ->
                  fun ?recommenderArn ->
                    fun ?promotions ->
                      fun ?metadataColumns ->
                        fun () ->
                          {
                            campaignArn;
                            itemId;
                            userId;
                            numResults;
                            context;
                            filterArn;
                            filterValues;
                            recommenderArn;
                            promotions;
                            metadataColumns
                          }
    let to_value x =
      structure_to_value
        [("campaignArn", (Option.map x.campaignArn ~f:Arn.to_value));
        ("itemId", (Option.map x.itemId ~f:ItemID.to_value));
        ("userId", (Option.map x.userId ~f:UserID.to_value));
        ("numResults", (Option.map x.numResults ~f:NumResults.to_value));
        ("context", (Option.map x.context ~f:Context.to_value));
        ("filterArn", (Option.map x.filterArn ~f:Arn.to_value));
        ("filterValues",
          (Option.map x.filterValues ~f:FilterValues.to_value));
        ("recommenderArn", (Option.map x.recommenderArn ~f:Arn.to_value));
        ("promotions", (Option.map x.promotions ~f:PromotionList.to_value));
        ("metadataColumns",
          (Option.map x.metadataColumns ~f:MetadataColumns.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let metadataColumns =
        (Option.map ~f:MetadataColumns.of_xml)
          (Xml.child xml_arg0 "metadataColumns") in
      let promotions =
        (Option.map ~f:PromotionList.of_xml)
          (Xml.child xml_arg0 "promotions") in
      let recommenderArn =
        (Option.map ~f:Arn.of_xml) (Xml.child xml_arg0 "recommenderArn") in
      let filterValues =
        (Option.map ~f:FilterValues.of_xml)
          (Xml.child xml_arg0 "filterValues") in
      let filterArn =
        (Option.map ~f:Arn.of_xml) (Xml.child xml_arg0 "filterArn") in
      let context =
        (Option.map ~f:Context.of_xml) (Xml.child xml_arg0 "context") in
      let numResults =
        (Option.map ~f:NumResults.of_xml) (Xml.child xml_arg0 "numResults") in
      let userId =
        (Option.map ~f:UserID.of_xml) (Xml.child xml_arg0 "userId") in
      let itemId =
        (Option.map ~f:ItemID.of_xml) (Xml.child xml_arg0 "itemId") in
      let campaignArn =
        (Option.map ~f:Arn.of_xml) (Xml.child xml_arg0 "campaignArn") in
      make ?metadataColumns ?promotions ?recommenderArn ?filterValues
        ?filterArn ?context ?numResults ?userId ?itemId ?campaignArn ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let metadataColumns =
        field_map json__ "metadataColumns" MetadataColumns.of_json in
      let promotions = field_map json__ "promotions" PromotionList.of_json in
      let recommenderArn = field_map json__ "recommenderArn" Arn.of_json in
      let filterValues = field_map json__ "filterValues" FilterValues.of_json in
      let filterArn = field_map json__ "filterArn" Arn.of_json in
      let context = field_map json__ "context" Context.of_json in
      let numResults = field_map json__ "numResults" NumResults.of_json in
      let userId = field_map json__ "userId" UserID.of_json in
      let itemId = field_map json__ "itemId" ItemID.of_json in
      let campaignArn = field_map json__ "campaignArn" Arn.of_json in
      make ?metadataColumns ?promotions ?recommenderArn ?filterValues
        ?filterArn ?context ?numResults ?userId ?itemId ?campaignArn ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a list of recommended items. For campaigns, the campaign's Amazon Resource Name (ARN) is required and the required user and item input depends on the recipe type used to create the solution backing the campaign as follows: USER_PERSONALIZATION - userId required, itemId not used RELATED_ITEMS - itemId required, userId not used Campaigns that are backed by a solution created using a recipe of type PERSONALIZED_RANKING use the API. For recommenders, the recommender's ARN is required and the required item and user input depends on the use case (domain-based recipe) backing the recommender. For information on use case requirements see Choosing recommender use cases."]
module GetPersonalizedRankingResponse =
  struct
    type nonrec t =
      {
      personalizedRanking: ItemList.t option
        [@ocaml.doc
          "A list of items in order of most likely interest to the user. The maximum is 500."];
      recommendationId: RecommendationID.t option
        [@ocaml.doc "The ID of the recommendation."]}
    type nonrec error =
      [ `InvalidInputException of InvalidInputException.t 
      | `ResourceNotFoundException of ResourceNotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?personalizedRanking =
      fun ?recommendationId ->
        fun () -> { personalizedRanking; recommendationId }
    let error_of_json name json =
      match name with
      | "InvalidInputException" ->
          `InvalidInputException (InvalidInputException.of_json json)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "InvalidInputException" ->
          `InvalidInputException (InvalidInputException.of_xml xml)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `InvalidInputException e ->
          `Assoc
            [("error", (`String "InvalidInputException"));
            ("details", (InvalidInputException.to_json e))]
      | `ResourceNotFoundException e ->
          `Assoc
            [("error", (`String "ResourceNotFoundException"));
            ("details", (ResourceNotFoundException.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
        [("personalizedRanking",
           (Option.map x.personalizedRanking ~f:ItemList.to_value));
        ("recommendationId",
          (Option.map x.recommendationId ~f:RecommendationID.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let recommendationId =
        (Option.map ~f:RecommendationID.of_xml)
          (Xml.child xml_arg0 "recommendationId") in
      let personalizedRanking =
        (Option.map ~f:ItemList.of_xml)
          (Xml.child xml_arg0 "personalizedRanking") in
      make ?recommendationId ?personalizedRanking ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let recommendationId =
        field_map json__ "recommendationId" RecommendationID.of_json in
      let personalizedRanking =
        field_map json__ "personalizedRanking" ItemList.of_json in
      make ?recommendationId ?personalizedRanking ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Re-ranks a list of recommended items for the given user. The first item in the list is deemed the most likely item to be of interest to the user. The solution backing the campaign must have been created using a recipe of type PERSONALIZED_RANKING."]
module GetPersonalizedRankingRequest =
  struct
    type nonrec t =
      {
      campaignArn: Arn.t
        [@ocaml.doc
          "The Amazon Resource Name (ARN) of the campaign to use for generating the personalized ranking."];
      inputList: InputList.t
        [@ocaml.doc
          "A list of items (by itemId) to rank. If an item was not included in the training dataset, the item is appended to the end of the reranked list. If you are including metadata in recommendations, the maximum is 50. Otherwise, the maximum is 500."];
      userId: UserID.t
        [@ocaml.doc
          "The user for which you want the campaign to provide a personalized ranking."];
      context: Context.t option
        [@ocaml.doc
          "The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction information that might be relevant when getting a user's recommendations, such as the user's current location or device type."];
      filterArn: Arn.t option
        [@ocaml.doc
          "The Amazon Resource Name (ARN) of a filter you created to include items or exclude items from recommendations for a given user. For more information, see Filtering Recommendations."];
      filterValues: FilterValues.t option
        [@ocaml.doc
          "The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. For filter expressions that use an INCLUDE element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an EXCLUDE element to exclude items, you can omit the filter-values.In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations. For more information, see Filtering Recommendations."];
      metadataColumns: MetadataColumns.t option
        [@ocaml.doc
          "If you enabled metadata in recommendations when you created or updated the campaign, specify metadata columns from your Items dataset to include in the personalized ranking. The map key is ITEMS and the value is a list of column names from your Items dataset. The maximum number of columns you can provide is 10. For information about enabling metadata for a campaign, see Enabling metadata in recommendations for a campaign."]}
    let context_ = "GetPersonalizedRankingRequest"
    let make ?context =
      fun ?filterArn ->
        fun ?filterValues ->
          fun ?metadataColumns ->
            fun ~campaignArn ->
              fun ~inputList ->
                fun ~userId ->
                  fun () ->
                    {
                      context;
                      filterArn;
                      filterValues;
                      metadataColumns;
                      campaignArn;
                      inputList;
                      userId
                    }
    let to_value x =
      structure_to_value
        [("campaignArn", (Some (Arn.to_value x.campaignArn)));
        ("inputList", (Some (InputList.to_value x.inputList)));
        ("userId", (Some (UserID.to_value x.userId)));
        ("context", (Option.map x.context ~f:Context.to_value));
        ("filterArn", (Option.map x.filterArn ~f:Arn.to_value));
        ("filterValues",
          (Option.map x.filterValues ~f:FilterValues.to_value));
        ("metadataColumns",
          (Option.map x.metadataColumns ~f:MetadataColumns.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let metadataColumns =
        (Option.map ~f:MetadataColumns.of_xml)
          (Xml.child xml_arg0 "metadataColumns") in
      let filterValues =
        (Option.map ~f:FilterValues.of_xml)
          (Xml.child xml_arg0 "filterValues") in
      let filterArn =
        (Option.map ~f:Arn.of_xml) (Xml.child xml_arg0 "filterArn") in
      let context =
        (Option.map ~f:Context.of_xml) (Xml.child xml_arg0 "context") in
      let userId =
        UserID.of_xml (Xml.child_exn ~context:context_ xml_arg0 "userId") in
      let inputList =
        InputList.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "inputList") in
      let campaignArn =
        Arn.of_xml (Xml.child_exn ~context:context_ xml_arg0 "campaignArn") in
      make ?metadataColumns ?filterValues ?filterArn ?context ~userId
        ~inputList ~campaignArn ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let metadataColumns =
        field_map json__ "metadataColumns" MetadataColumns.of_json in
      let filterValues = field_map json__ "filterValues" FilterValues.of_json in
      let filterArn = field_map json__ "filterArn" Arn.of_json in
      let context = field_map json__ "context" Context.of_json in
      let userId = field_map_exn json__ "userId" UserID.of_json in
      let inputList = field_map_exn json__ "inputList" InputList.of_json in
      let campaignArn = field_map_exn json__ "campaignArn" Arn.of_json in
      make ?metadataColumns ?filterValues ?filterArn ?context ~userId
        ~inputList ~campaignArn ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Re-ranks a list of recommended items for the given user. The first item in the list is deemed the most likely item to be of interest to the user. The solution backing the campaign must have been created using a recipe of type PERSONALIZED_RANKING."]
module GetActionRecommendationsResponse =
  struct
    type nonrec t =
      {
      actionList: ActionList.t option
        [@ocaml.doc
          "A list of action recommendations sorted in descending order by prediction score. There can be a maximum of 100 actions in the list. For information about action scores, see How action recommendation scoring works."];
      recommendationId: RecommendationID.t option
        [@ocaml.doc "The ID of the recommendation."]}
    type nonrec error =
      [ `InvalidInputException of InvalidInputException.t 
      | `ResourceNotFoundException of ResourceNotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?actionList =
      fun ?recommendationId -> fun () -> { actionList; recommendationId }
    let error_of_json name json =
      match name with
      | "InvalidInputException" ->
          `InvalidInputException (InvalidInputException.of_json json)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "InvalidInputException" ->
          `InvalidInputException (InvalidInputException.of_xml xml)
      | "ResourceNotFoundException" ->
          `ResourceNotFoundException (ResourceNotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `InvalidInputException e ->
          `Assoc
            [("error", (`String "InvalidInputException"));
            ("details", (InvalidInputException.to_json e))]
      | `ResourceNotFoundException e ->
          `Assoc
            [("error", (`String "ResourceNotFoundException"));
            ("details", (ResourceNotFoundException.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
        [("actionList", (Option.map x.actionList ~f:ActionList.to_value));
        ("recommendationId",
          (Option.map x.recommendationId ~f:RecommendationID.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let recommendationId =
        (Option.map ~f:RecommendationID.of_xml)
          (Xml.child xml_arg0 "recommendationId") in
      let actionList =
        (Option.map ~f:ActionList.of_xml) (Xml.child xml_arg0 "actionList") in
      make ?recommendationId ?actionList ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let recommendationId =
        field_map json__ "recommendationId" RecommendationID.of_json in
      let actionList = field_map json__ "actionList" ActionList.of_json in
      make ?recommendationId ?actionList ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a list of recommended actions in sorted in descending order by prediction score. Use the GetActionRecommendations API if you have a custom campaign that deploys a solution version trained with a PERSONALIZED_ACTIONS recipe. For more information about PERSONALIZED_ACTIONS recipes, see PERSONALIZED_ACTIONS recipes. For more information about getting action recommendations, see Getting action recommendations."]
module GetActionRecommendationsRequest =
  struct
    type nonrec t =
      {
      campaignArn: Arn.t option
        [@ocaml.doc
          "The Amazon Resource Name (ARN) of the campaign to use for getting action recommendations. This campaign must deploy a solution version trained with a PERSONALIZED_ACTIONS recipe."];
      userId: UserID.t option
        [@ocaml.doc
          "The user ID of the user to provide action recommendations for."];
      numResults: NumResults.t option
        [@ocaml.doc
          "The number of results to return. The default is 5. The maximum is 100."];
      filterArn: Arn.t option
        [@ocaml.doc
          "The ARN of the filter to apply to the returned recommendations. For more information, see Filtering Recommendations. When using this parameter, be sure the filter resource is ACTIVE."];
      filterValues: FilterValues.t option
        [@ocaml.doc
          "The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. For filter expressions that use an INCLUDE element to include actions, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an EXCLUDE element to exclude actions, you can omit the filter-values. In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations. For more information, see Filtering recommendations and user segments."]}
    let make ?campaignArn =
      fun ?userId ->
        fun ?numResults ->
          fun ?filterArn ->
            fun ?filterValues ->
              fun () ->
                { campaignArn; userId; numResults; filterArn; filterValues }
    let to_value x =
      structure_to_value
        [("campaignArn", (Option.map x.campaignArn ~f:Arn.to_value));
        ("userId", (Option.map x.userId ~f:UserID.to_value));
        ("numResults", (Option.map x.numResults ~f:NumResults.to_value));
        ("filterArn", (Option.map x.filterArn ~f:Arn.to_value));
        ("filterValues",
          (Option.map x.filterValues ~f:FilterValues.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let filterValues =
        (Option.map ~f:FilterValues.of_xml)
          (Xml.child xml_arg0 "filterValues") in
      let filterArn =
        (Option.map ~f:Arn.of_xml) (Xml.child xml_arg0 "filterArn") in
      let numResults =
        (Option.map ~f:NumResults.of_xml) (Xml.child xml_arg0 "numResults") in
      let userId =
        (Option.map ~f:UserID.of_xml) (Xml.child xml_arg0 "userId") in
      let campaignArn =
        (Option.map ~f:Arn.of_xml) (Xml.child xml_arg0 "campaignArn") in
      make ?filterValues ?filterArn ?numResults ?userId ?campaignArn ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let filterValues = field_map json__ "filterValues" FilterValues.of_json in
      let filterArn = field_map json__ "filterArn" Arn.of_json in
      let numResults = field_map json__ "numResults" NumResults.of_json in
      let userId = field_map json__ "userId" UserID.of_json in
      let campaignArn = field_map json__ "campaignArn" Arn.of_json in
      make ?filterValues ?filterArn ?numResults ?userId ?campaignArn ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a list of recommended actions in sorted in descending order by prediction score. Use the GetActionRecommendations API if you have a custom campaign that deploys a solution version trained with a PERSONALIZED_ACTIONS recipe. For more information about PERSONALIZED_ACTIONS recipes, see PERSONALIZED_ACTIONS recipes. For more information about getting action recommendations, see Getting action recommendations."]