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
(* 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.sagemaker_metrics
let apiVersion = "2022-09-30"
let endpointPrefix = "metrics.sagemaker"
let serviceFullName = "Amazon SageMaker Metrics Service"
let signatureVersion = "v4"
let protocol = "rest_json"
let globalEndpoint = endpointPrefix ^ ".amazonaws.com"
let serviceAbbreviation = "SageMaker Metrics"
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 Double =
  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 Long =
  struct
    type nonrec t = Int64.t
    let make i = i
    let of_string = Int64.of_string
    let to_value x = `Long x
    let to_query v = to_query to_value v
    let to_header x = Int64.to_string x
    let of_xml xml_arg0 =
      Int64.of_string (string_of_xml ~kind:"a long" xml_arg0)
    let of_json j = Int64.of_float (float_of_json ~kind:"a long" j)
    let to_json = simple_to_json to_value
  end
module Integer =
  struct
    type nonrec t = int
    let make i = 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 Integer" 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 PutMetricsErrorCode =
  struct
    type nonrec t =
      | METRIC_LIMIT_EXCEEDED 
      | INTERNAL_ERROR 
      | VALIDATION_ERROR 
      | CONFLICT_ERROR 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | METRIC_LIMIT_EXCEEDED -> "METRIC_LIMIT_EXCEEDED"
      | INTERNAL_ERROR -> "INTERNAL_ERROR"
      | VALIDATION_ERROR -> "VALIDATION_ERROR"
      | CONFLICT_ERROR -> "CONFLICT_ERROR"
      | Non_static_id s -> s
    let of_string =
      function
      | "METRIC_LIMIT_EXCEEDED" -> METRIC_LIMIT_EXCEEDED
      | "INTERNAL_ERROR" -> INTERNAL_ERROR
      | "VALIDATION_ERROR" -> VALIDATION_ERROR
      | "CONFLICT_ERROR" -> CONFLICT_ERROR
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration PutMetricsErrorCode" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"PutMetricsErrorCode" j)
    let to_json = simple_to_json to_value
  end
module MetricName =
  struct
    type nonrec t = string
    let context_ = "MetricName"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:255) >>=
                  (fun () -> check_pattern i ~pattern:".+")));
        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:"MetricName" j
    let to_json = simple_to_json to_value
  end
module Step =
  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 Step" 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 Timestamp =
  struct
    type nonrec t = string
    let make i = i
    let of_string x = x
    let to_value x = `Timestamp x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = string_of_xml ~kind:"a timestamp"
    let of_json = timestamp_of_json
    let to_json = simple_to_json to_value
  end
module Message =
  struct
    type nonrec t = string
    let context_ = "Message"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:2048) >>=
             (fun () -> check_pattern i ~pattern:".*"));
        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:"Message" j
    let to_json = simple_to_json to_value
  end
module MetricQueryResultStatus =
  struct
    type nonrec t =
      | Complete 
      | Truncated 
      | InternalError 
      | ValidationError 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | Complete -> "Complete"
      | Truncated -> "Truncated"
      | InternalError -> "InternalError"
      | ValidationError -> "ValidationError"
      | Non_static_id s -> s
    let of_string =
      function
      | "Complete" -> Complete
      | "Truncated" -> Truncated
      | "InternalError" -> InternalError
      | "ValidationError" -> ValidationError
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration MetricQueryResultStatus" xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"MetricQueryResultStatus" j)
    let to_json = simple_to_json to_value
  end
module MetricValues =
  struct
    type nonrec t = Double.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:Double.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:Double.of_xml)
    let of_json j =
      list_of_json ~kind:"MetricValues" ~of_json:Double.of_json j
    let to_json v = composed_to_json to_value v
  end
module XAxisValues =
  struct
    type nonrec t = Long.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:Long.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:Long.of_xml)
    let of_json j = list_of_json ~kind:"XAxisValues" ~of_json:Long.of_json j
    let to_json v = composed_to_json to_value v
  end
module MetricStatistic =
  struct
    type nonrec t =
      | Min 
      | Max 
      | Avg 
      | Count 
      | StdDev 
      | Last 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | Min -> "Min"
      | Max -> "Max"
      | Avg -> "Avg"
      | Count -> "Count"
      | StdDev -> "StdDev"
      | Last -> "Last"
      | Non_static_id s -> s
    let of_string =
      function
      | "Min" -> Min
      | "Max" -> Max
      | "Avg" -> Avg
      | "Count" -> Count
      | "StdDev" -> StdDev
      | "Last" -> Last
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration MetricStatistic" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"MetricStatistic" j)
    let to_json = simple_to_json to_value
  end
module Period =
  struct
    type nonrec t =
      | OneMinute 
      | FiveMinute 
      | OneHour 
      | IterationNumber 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | OneMinute -> "OneMinute"
      | FiveMinute -> "FiveMinute"
      | OneHour -> "OneHour"
      | IterationNumber -> "IterationNumber"
      | Non_static_id s -> s
    let of_string =
      function
      | "OneMinute" -> OneMinute
      | "FiveMinute" -> FiveMinute
      | "OneHour" -> OneHour
      | "IterationNumber" -> IterationNumber
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration Period" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"Period" j)
    let to_json = simple_to_json to_value
  end
module SageMakerResourceArn =
  struct
    type nonrec t = string
    let context_ = "SageMakerResourceArn"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:2048) >>=
             (fun () ->
                check_pattern i
                  ~pattern:"arn:aws[a-z\\-]*:sagemaker:[a-z0-9\\-]*:[0-9]{12}:[a-z\\-].*/.*"));
        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:"SageMakerResourceArn" j
    let to_json = simple_to_json to_value
  end
module XAxisType =
  struct
    type nonrec t =
      | IterationNumber 
      | Timestamp 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | IterationNumber -> "IterationNumber"
      | Timestamp -> "Timestamp"
      | Non_static_id s -> s
    let of_string =
      function
      | "IterationNumber" -> IterationNumber
      | "Timestamp" -> Timestamp
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration XAxisType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"XAxisType" j)
    let to_json = simple_to_json to_value
  end
module BatchPutMetricsError =
  struct
    type nonrec t =
      {
      code: PutMetricsErrorCode.t option
        [@ocaml.doc
          "The error code of an error that occured when attempting to put metrics. METRIC_LIMIT_EXCEEDED: The maximum amount of metrics per resource is exceeded. INTERNAL_ERROR: An internal error occured. VALIDATION_ERROR: The metric data failed validation. CONFLICT_ERROR: Multiple requests attempted to modify the same data simultaneously."];
      metricIndex: Integer.t option
        [@ocaml.doc
          "An index that corresponds to the metric in the request."]}
    let make ?code = fun ?metricIndex -> fun () -> { code; metricIndex }
    let to_value x =
      structure_to_value
        [("Code", (Option.map x.code ~f:PutMetricsErrorCode.to_value));
        ("MetricIndex", (Option.map x.metricIndex ~f:Integer.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let metricIndex =
        (Option.map ~f:Integer.of_xml) (Xml.child xml_arg0 "MetricIndex") in
      let code =
        (Option.map ~f:PutMetricsErrorCode.of_xml)
          (Xml.child xml_arg0 "Code") in
      make ?metricIndex ?code ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let metricIndex = field_map json__ "MetricIndex" Integer.of_json in
      let code = field_map json__ "Code" PutMetricsErrorCode.of_json in
      make ?metricIndex ?code ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "An error that occured when putting the metric data."]
module RawMetricData =
  struct
    type nonrec t =
      {
      metricName: MetricName.t [@ocaml.doc "The name of the metric."];
      timestamp: Timestamp.t
        [@ocaml.doc "The time that the metric was recorded."];
      step: Step.t option [@ocaml.doc "The metric step (epoch)."];
      value: Double.t [@ocaml.doc "The metric value."]}
    let context_ = "RawMetricData"
    let make ?step =
      fun ~metricName ->
        fun ~timestamp ->
          fun ~value -> fun () -> { step; metricName; timestamp; value }
    let to_value x =
      structure_to_value
        [("MetricName", (Some (MetricName.to_value x.metricName)));
        ("Timestamp", (Some (Timestamp.to_value x.timestamp)));
        ("Step", (Option.map x.step ~f:Step.to_value));
        ("Value", (Some (Double.to_value x.value)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let value =
        Double.of_xml (Xml.child_exn ~context:context_ xml_arg0 "Value") in
      let step = (Option.map ~f:Step.of_xml) (Xml.child xml_arg0 "Step") in
      let timestamp =
        Timestamp.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "Timestamp") in
      let metricName =
        MetricName.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "MetricName") in
      make ~value ?step ~timestamp ~metricName ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let value = field_map_exn json__ "Value" Double.of_json in
      let step = field_map json__ "Step" Step.of_json in
      let timestamp = field_map_exn json__ "Timestamp" Timestamp.of_json in
      let metricName = field_map_exn json__ "MetricName" MetricName.of_json in
      make ~value ?step ~timestamp ~metricName ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "The raw metric data to associate with the resource."]
module MetricQueryResult =
  struct
    type nonrec t =
      {
      status: MetricQueryResultStatus.t option
        [@ocaml.doc "The status of the metric query."];
      message: Message.t option
        [@ocaml.doc "A message describing the status of the metric query."];
      xAxisValues: XAxisValues.t option
        [@ocaml.doc "The values for the x-axis of the metrics."];
      metricValues: MetricValues.t option
        [@ocaml.doc "The metric values retrieved by the query."]}
    let make ?status =
      fun ?message ->
        fun ?xAxisValues ->
          fun ?metricValues ->
            fun () -> { status; message; xAxisValues; metricValues }
    let to_value x =
      structure_to_value
        [("Status",
           (Option.map x.status ~f:MetricQueryResultStatus.to_value));
        ("Message", (Option.map x.message ~f:Message.to_value));
        ("XAxisValues", (Option.map x.xAxisValues ~f:XAxisValues.to_value));
        ("MetricValues",
          (Option.map x.metricValues ~f:MetricValues.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let metricValues =
        (Option.map ~f:MetricValues.of_xml)
          (Xml.child xml_arg0 "MetricValues") in
      let xAxisValues =
        (Option.map ~f:XAxisValues.of_xml) (Xml.child xml_arg0 "XAxisValues") in
      let message =
        (Option.map ~f:Message.of_xml) (Xml.child xml_arg0 "Message") in
      let status =
        (Option.map ~f:MetricQueryResultStatus.of_xml)
          (Xml.child xml_arg0 "Status") in
      make ?metricValues ?xAxisValues ?message ?status ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let metricValues = field_map json__ "MetricValues" MetricValues.of_json in
      let xAxisValues = field_map json__ "XAxisValues" XAxisValues.of_json in
      let message = field_map json__ "Message" Message.of_json in
      let status = field_map json__ "Status" MetricQueryResultStatus.of_json in
      make ?metricValues ?xAxisValues ?message ?status ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The result of a query to retrieve training metrics from SageMaker."]
module MetricQuery =
  struct
    type nonrec t =
      {
      metricName: MetricName.t
        [@ocaml.doc "The name of the metric to retrieve."];
      resourceArn: SageMakerResourceArn.t
        [@ocaml.doc
          "The ARN of the SageMaker resource to retrieve metrics for."];
      metricStat: MetricStatistic.t
        [@ocaml.doc "The metrics stat type of metrics to retrieve."];
      period: Period.t [@ocaml.doc "The time period of metrics to retrieve."];
      xAxisType: XAxisType.t
        [@ocaml.doc "The x-axis type of metrics to retrieve."];
      start: Long.t option
        [@ocaml.doc "The start time of metrics to retrieve."];
      end_: Long.t option [@ocaml.doc "The end time of metrics to retrieve."]}
    let context_ = "MetricQuery"
    let make ?start =
      fun ?end_ ->
        fun ~metricName ->
          fun ~resourceArn ->
            fun ~metricStat ->
              fun ~period ->
                fun ~xAxisType ->
                  fun () ->
                    {
                      start;
                      end_;
                      metricName;
                      resourceArn;
                      metricStat;
                      period;
                      xAxisType
                    }
    let to_value x =
      structure_to_value
        [("MetricName", (Some (MetricName.to_value x.metricName)));
        ("ResourceArn", (Some (SageMakerResourceArn.to_value x.resourceArn)));
        ("MetricStat", (Some (MetricStatistic.to_value x.metricStat)));
        ("Period", (Some (Period.to_value x.period)));
        ("XAxisType", (Some (XAxisType.to_value x.xAxisType)));
        ("Start", (Option.map x.start ~f:Long.to_value));
        ("End", (Option.map x.end_ ~f:Long.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let end_ = (Option.map ~f:Long.of_xml) (Xml.child xml_arg0 "End") in
      let start = (Option.map ~f:Long.of_xml) (Xml.child xml_arg0 "Start") in
      let xAxisType =
        XAxisType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "XAxisType") in
      let period =
        Period.of_xml (Xml.child_exn ~context:context_ xml_arg0 "Period") in
      let metricStat =
        MetricStatistic.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "MetricStat") in
      let resourceArn =
        SageMakerResourceArn.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "ResourceArn") in
      let metricName =
        MetricName.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "MetricName") in
      make ?end_ ?start ~xAxisType ~period ~metricStat ~resourceArn
        ~metricName ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let end_ = field_map json__ "End" Long.of_json in
      let start = field_map json__ "Start" Long.of_json in
      let xAxisType = field_map_exn json__ "XAxisType" XAxisType.of_json in
      let period = field_map_exn json__ "Period" Period.of_json in
      let metricStat =
        field_map_exn json__ "MetricStat" MetricStatistic.of_json in
      let resourceArn =
        field_map_exn json__ "ResourceArn" SageMakerResourceArn.of_json in
      let metricName = field_map_exn json__ "MetricName" MetricName.of_json in
      make ?end_ ?start ~xAxisType ~period ~metricStat ~resourceArn
        ~metricName ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Specifies a query to retrieve training metrics from SageMaker."]
module BatchPutMetricsErrorList =
  struct
    type nonrec t = BatchPutMetricsError.t list
    let make i =
      let open Result in
        ok_or_failwith
          ((check_list_max i ~max:10) >>= (fun () -> check_list_min i ~min: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:BatchPutMetricsError.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:BatchPutMetricsError.of_xml)
    let of_json j =
      list_of_json ~kind:"BatchPutMetricsErrorList"
        ~of_json:BatchPutMetricsError.of_json j
    let to_json v = composed_to_json to_value v
  end
module ExperimentEntityName =
  struct
    type nonrec t = string
    let context_ = "ExperimentEntityName"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:120) >>=
                  (fun () ->
                     check_pattern i ~pattern:"^[a-z0-9](-*[a-z0-9]){0,119}")));
        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:"ExperimentEntityName" j
    let to_json = simple_to_json to_value
  end
module RawMetricDataList =
  struct
    type nonrec t = RawMetricData.t list
    let make i =
      let open Result in
        ok_or_failwith
          ((check_list_max i ~max:10) >>= (fun () -> check_list_min i ~min: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:RawMetricData.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:RawMetricData.of_xml)
    let of_json j =
      list_of_json ~kind:"RawMetricDataList" ~of_json:RawMetricData.of_json j
    let to_json v = composed_to_json to_value v
  end
module MetricQueryResultList =
  struct
    type nonrec t = MetricQueryResult.t list
    let make i =
      let open Result in
        ok_or_failwith
          ((check_list_max i ~max:100) >>=
             (fun () -> check_list_min i ~min: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:MetricQueryResult.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:MetricQueryResult.of_xml)
    let of_json j =
      list_of_json ~kind:"MetricQueryResultList"
        ~of_json:MetricQueryResult.of_json j
    let to_json v = composed_to_json to_value v
  end
module MetricQueryList =
  struct
    type nonrec t = MetricQuery.t list
    let make i =
      let open Result in
        ok_or_failwith
          ((check_list_max i ~max:100) >>=
             (fun () -> check_list_min i ~min: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:MetricQuery.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:MetricQuery.of_xml)
    let of_json j =
      list_of_json ~kind:"MetricQueryList" ~of_json:MetricQuery.of_json j
    let to_json v = composed_to_json to_value v
  end
module BatchPutMetricsResponse =
  struct
    type nonrec t =
      {
      errors: BatchPutMetricsErrorList.t option
        [@ocaml.doc
          "Lists any errors that occur when inserting metric data."]}
    type nonrec error =
      [ `Unknown_operation_error of (string * string option) ]
    let make ?errors = fun () -> { errors }
    let error_of_json name json =
      match name with
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `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
        [("Errors",
           (Option.map x.errors ~f:BatchPutMetricsErrorList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let errors =
        (Option.map ~f:BatchPutMetricsErrorList.of_xml)
          (Xml.child xml_arg0 "Errors") in
      make ?errors ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let errors = field_map json__ "Errors" BatchPutMetricsErrorList.of_json in
      make ?errors ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Used to ingest training metrics into SageMaker. These metrics can be visualized in SageMaker Studio."]
module BatchPutMetricsRequest =
  struct
    type nonrec t =
      {
      trialComponentName: ExperimentEntityName.t
        [@ocaml.doc
          "The name of the Trial Component to associate with the metrics. The Trial Component name must be entirely lowercase."];
      metricData: RawMetricDataList.t
        [@ocaml.doc "A list of raw metric values to put."]}
    let context_ = "BatchPutMetricsRequest"
    let make ~trialComponentName =
      fun ~metricData -> fun () -> { trialComponentName; metricData }
    let to_value x =
      structure_to_value
        [("TrialComponentName",
           (Some (ExperimentEntityName.to_value x.trialComponentName)));
        ("MetricData", (Some (RawMetricDataList.to_value x.metricData)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let metricData =
        RawMetricDataList.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "MetricData") in
      let trialComponentName =
        ExperimentEntityName.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "TrialComponentName") in
      make ~metricData ~trialComponentName ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let metricData =
        field_map_exn json__ "MetricData" RawMetricDataList.of_json in
      let trialComponentName =
        field_map_exn json__ "TrialComponentName"
          ExperimentEntityName.of_json in
      make ~metricData ~trialComponentName ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Used to ingest training metrics into SageMaker. These metrics can be visualized in SageMaker Studio."]
module BatchGetMetricsResponse =
  struct
    type nonrec t =
      {
      metricQueryResults: MetricQueryResultList.t option
        [@ocaml.doc
          "The results of a query to retrieve training metrics from SageMaker."]}
    type nonrec error =
      [ `Unknown_operation_error of (string * string option) ]
    let make ?metricQueryResults = fun () -> { metricQueryResults }
    let error_of_json name json =
      match name with
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `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
        [("MetricQueryResults",
           (Option.map x.metricQueryResults ~f:MetricQueryResultList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let metricQueryResults =
        (Option.map ~f:MetricQueryResultList.of_xml)
          (Xml.child xml_arg0 "MetricQueryResults") in
      make ?metricQueryResults ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let metricQueryResults =
        field_map json__ "MetricQueryResults" MetricQueryResultList.of_json in
      make ?metricQueryResults ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Used to retrieve training metrics from SageMaker."]
module BatchGetMetricsRequest =
  struct
    type nonrec t =
      {
      metricQueries: MetricQueryList.t
        [@ocaml.doc
          "Queries made to retrieve training metrics from SageMaker."]}
    let context_ = "BatchGetMetricsRequest"
    let make ~metricQueries = fun () -> { metricQueries }
    let to_value x =
      structure_to_value
        [("MetricQueries", (Some (MetricQueryList.to_value x.metricQueries)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let metricQueries =
        MetricQueryList.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "MetricQueries") in
      make ~metricQueries ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let metricQueries =
        field_map_exn json__ "MetricQueries" MetricQueryList.of_json in
      make ~metricQueries ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Used to retrieve training metrics from SageMaker."]