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
(* 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.forecastquery
let apiVersion = "2018-06-26"
let endpointPrefix = "forecastquery"
let serviceFullName = "Amazon Forecast Query Service"
let signatureVersion = "v4"
let protocol = "json"
let globalEndpoint = endpointPrefix ^ ".amazonaws.com"
let targetPrefix = "AmazonForecastRuntime"
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 Timestamp =
  struct
    type nonrec t = string
    let context_ = "Timestamp"
    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:"Timestamp" j
    let to_json = simple_to_json to_value
  end
module DataPoint =
  struct
    type nonrec t =
      {
      timestamp: Timestamp.t option
        [@ocaml.doc "The timestamp of the specific forecast."];
      value: Double.t option [@ocaml.doc "The forecast value."]}
    let make ?timestamp = fun ?value -> fun () -> { timestamp; value }
    let to_value x =
      structure_to_value
        [("Timestamp", (Option.map x.timestamp ~f:Timestamp.to_value));
        ("Value", (Option.map x.value ~f:Double.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let value = (Option.map ~f:Double.of_xml) (Xml.child xml_arg0 "Value") in
      let timestamp =
        (Option.map ~f:Timestamp.of_xml) (Xml.child xml_arg0 "Timestamp") in
      make ?value ?timestamp ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let value = field_map json__ "Value" Double.of_json in
      let timestamp = field_map json__ "Timestamp" Timestamp.of_json in
      make ?value ?timestamp ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The forecast value for a specific date. Part of the Forecast object."]
module Statistic =
  struct
    type nonrec t = string
    let context_ = "Statistic"
    let make i =
      let open Result in ok_or_failwith (check_string_max i ~max:4); 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:"Statistic" j
    let to_json = simple_to_json to_value
  end
module TimeSeries =
  struct
    type nonrec t = DataPoint.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:DataPoint.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:DataPoint.of_xml)
    let of_json j =
      list_of_json ~kind:"TimeSeries" ~of_json:DataPoint.of_json j
    let to_json v = composed_to_json to_value v
  end
module Predictions =
  struct
    type nonrec t = (Statistic.t * TimeSeries.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 ->
                            let (_ : string) = v in
                            let (_ : string) = chopped in
                            failwith
                              "no of_header for complex types Statistic TimeSeries"))))
    let to_value xs =
      (xs |>
         (List.map
            ~f:(fun (x, y) ->
                  (Statistic.to_value x) |>
                    (fun x -> (TimeSeries.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:Statistic.of_string
        ~of_json:TimeSeries.of_json j
    let to_json v = composed_to_json to_value v
  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 AttributeName =
  struct
    type nonrec t = string
    let context_ = "AttributeName"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:256) >>=
             (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:"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: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:"AttributeValue" j
    let to_json = simple_to_json to_value
  end
module Forecast =
  struct
    type nonrec t =
      {
      predictions: Predictions.t option
        [@ocaml.doc
          "The forecast. The string of the string-to-array map is one of the following values: p10 p50 p90 The default setting is \\[\"0.1\", \"0.5\", \"0.9\"\\]. Use the optional ForecastTypes parameter of the CreateForecast operation to change the values. The values will vary depending on how this is set, with a minimum of 1 and a maximum of 5."]}
    let make ?predictions = fun () -> { predictions }
    let to_value x =
      structure_to_value
        [("Predictions", (Option.map x.predictions ~f:Predictions.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let predictions =
        (Option.map ~f:Predictions.of_xml) (Xml.child xml_arg0 "Predictions") in
      make ?predictions ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let predictions = field_map json__ "Predictions" Predictions.of_json in
      make ?predictions ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Provides information about a forecast. Returned as part of the QueryForecast response."]
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 "The value is invalid or is too long."]
module InvalidNextTokenException =
  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 token is not valid. Tokens expire after 24 hours."]
module LimitExceededException =
  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 limit on the number of requests per second has been exceeded."]
module ResourceInUseException =
  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 is in use."]
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
       "We can't find that resource. Check the information that you've provided and try again."]
module DateTime =
  struct
    type nonrec t = string
    let context_ = "DateTime"
    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:"DateTime" j
    let to_json = simple_to_json to_value
  end
module Filters =
  struct
    type nonrec t = (AttributeName.t * AttributeValue.t) list
    let make i =
      let open Result in
        ok_or_failwith
          ((check_list_max i ~max:50) >>= (fun () -> check_list_min i ~min: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 ->
                            ((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 LongArn =
  struct
    type nonrec t = string
    let context_ = "LongArn"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:300) >>=
             (fun () ->
                check_pattern i ~pattern:"arn:([a-z\\d-]+):forecast:.*:.*:.+"));
        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:"LongArn" j
    let to_json = simple_to_json to_value
  end
module NextToken =
  struct
    type nonrec t = string
    let context_ = "NextToken"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:3000) >>=
             (fun () -> check_string_min i ~min:1));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"NextToken" 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-]+):forecast:.*:.*:.+"));
        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 QueryWhatIfForecastResponse =
  struct
    type nonrec t = {
      forecast: Forecast.t option }
    type nonrec error =
      [ `InvalidInputException of InvalidInputException.t 
      | `InvalidNextTokenException of InvalidNextTokenException.t 
      | `LimitExceededException of LimitExceededException.t 
      | `ResourceInUseException of ResourceInUseException.t 
      | `ResourceNotFoundException of ResourceNotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?forecast = fun () -> { forecast }
    let error_of_json name json =
      match name with
      | "InvalidInputException" ->
          `InvalidInputException (InvalidInputException.of_json json)
      | "InvalidNextTokenException" ->
          `InvalidNextTokenException (InvalidNextTokenException.of_json json)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_json json)
      | "ResourceInUseException" ->
          `ResourceInUseException (ResourceInUseException.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)
      | "InvalidNextTokenException" ->
          `InvalidNextTokenException (InvalidNextTokenException.of_xml xml)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_xml xml)
      | "ResourceInUseException" ->
          `ResourceInUseException (ResourceInUseException.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))]
      | `InvalidNextTokenException e ->
          `Assoc
            [("error", (`String "InvalidNextTokenException"));
            ("details", (InvalidNextTokenException.to_json e))]
      | `LimitExceededException e ->
          `Assoc
            [("error", (`String "LimitExceededException"));
            ("details", (LimitExceededException.to_json e))]
      | `ResourceInUseException e ->
          `Assoc
            [("error", (`String "ResourceInUseException"));
            ("details", (ResourceInUseException.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
        [("Forecast", (Option.map x.forecast ~f:Forecast.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let forecast =
        (Option.map ~f:Forecast.of_xml) (Xml.child xml_arg0 "Forecast") in
      make ?forecast ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let forecast = field_map json__ "Forecast" Forecast.of_json in
      make ?forecast ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Retrieves a what-if forecast."]
module QueryWhatIfForecastRequest =
  struct
    type nonrec t =
      {
      whatIfForecastArn: LongArn.t
        [@ocaml.doc
          "The Amazon Resource Name (ARN) of the what-if forecast to query."];
      startDate: DateTime.t option
        [@ocaml.doc
          "The start date for the what-if forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T08:00:00."];
      endDate: DateTime.t option
        [@ocaml.doc
          "The end date for the what-if forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T20:00:00."];
      filters: Filters.t
        [@ocaml.doc
          "The filtering criteria to apply when retrieving the forecast. For example, to get the forecast for client_21 in the electricity usage dataset, specify the following: \\{\"item_id\" : \"client_21\"\\} To get the full what-if forecast, use the CreateForecastExportJob operation."];
      nextToken: NextToken.t option
        [@ocaml.doc
          "If the result of the previous request was truncated, the response includes a NextToken. To retrieve the next set of results, use the token in the next request. Tokens expire after 24 hours."]}
    let context_ = "QueryWhatIfForecastRequest"
    let make ?startDate =
      fun ?endDate ->
        fun ?nextToken ->
          fun ~whatIfForecastArn ->
            fun ~filters ->
              fun () ->
                { startDate; endDate; nextToken; whatIfForecastArn; filters }
    let to_value x =
      structure_to_value
        [("WhatIfForecastArn", (Some (LongArn.to_value x.whatIfForecastArn)));
        ("StartDate", (Option.map x.startDate ~f:DateTime.to_value));
        ("EndDate", (Option.map x.endDate ~f:DateTime.to_value));
        ("Filters", (Some (Filters.to_value x.filters)));
        ("NextToken", (Option.map x.nextToken ~f:NextToken.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let nextToken =
        (Option.map ~f:NextToken.of_xml) (Xml.child xml_arg0 "NextToken") in
      let filters =
        Filters.of_xml (Xml.child_exn ~context:context_ xml_arg0 "Filters") in
      let endDate =
        (Option.map ~f:DateTime.of_xml) (Xml.child xml_arg0 "EndDate") in
      let startDate =
        (Option.map ~f:DateTime.of_xml) (Xml.child xml_arg0 "StartDate") in
      let whatIfForecastArn =
        LongArn.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "WhatIfForecastArn") in
      make ?nextToken ~filters ?endDate ?startDate ~whatIfForecastArn ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let nextToken = field_map json__ "NextToken" NextToken.of_json in
      let filters = field_map_exn json__ "Filters" Filters.of_json in
      let endDate = field_map json__ "EndDate" DateTime.of_json in
      let startDate = field_map json__ "StartDate" DateTime.of_json in
      let whatIfForecastArn =
        field_map_exn json__ "WhatIfForecastArn" LongArn.of_json in
      make ?nextToken ~filters ?endDate ?startDate ~whatIfForecastArn ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Retrieves a what-if forecast."]
module QueryForecastResponse =
  struct
    type nonrec t =
      {
      forecast: Forecast.t option [@ocaml.doc "The forecast."]}
    type nonrec error =
      [ `InvalidInputException of InvalidInputException.t 
      | `InvalidNextTokenException of InvalidNextTokenException.t 
      | `LimitExceededException of LimitExceededException.t 
      | `ResourceInUseException of ResourceInUseException.t 
      | `ResourceNotFoundException of ResourceNotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?forecast = fun () -> { forecast }
    let error_of_json name json =
      match name with
      | "InvalidInputException" ->
          `InvalidInputException (InvalidInputException.of_json json)
      | "InvalidNextTokenException" ->
          `InvalidNextTokenException (InvalidNextTokenException.of_json json)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_json json)
      | "ResourceInUseException" ->
          `ResourceInUseException (ResourceInUseException.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)
      | "InvalidNextTokenException" ->
          `InvalidNextTokenException (InvalidNextTokenException.of_xml xml)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_xml xml)
      | "ResourceInUseException" ->
          `ResourceInUseException (ResourceInUseException.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))]
      | `InvalidNextTokenException e ->
          `Assoc
            [("error", (`String "InvalidNextTokenException"));
            ("details", (InvalidNextTokenException.to_json e))]
      | `LimitExceededException e ->
          `Assoc
            [("error", (`String "LimitExceededException"));
            ("details", (LimitExceededException.to_json e))]
      | `ResourceInUseException e ->
          `Assoc
            [("error", (`String "ResourceInUseException"));
            ("details", (ResourceInUseException.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
        [("Forecast", (Option.map x.forecast ~f:Forecast.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let forecast =
        (Option.map ~f:Forecast.of_xml) (Xml.child xml_arg0 "Forecast") in
      make ?forecast ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let forecast = field_map json__ "Forecast" Forecast.of_json in
      make ?forecast ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Retrieves a forecast for a single item, filtered by the supplied criteria. The criteria is a key-value pair. The key is either item_id (or the equivalent non-timestamp, non-target field) from the TARGET_TIME_SERIES dataset, or one of the forecast dimensions specified as part of the FeaturizationConfig object. By default, QueryForecast returns the complete date range for the filtered forecast. You can request a specific date range. To get the full forecast, use the CreateForecastExportJob operation. The forecasts generated by Amazon Forecast are in the same timezone as the dataset that was used to create the predictor."]
module QueryForecastRequest =
  struct
    type nonrec t =
      {
      forecastArn: Arn.t
        [@ocaml.doc
          "The Amazon Resource Name (ARN) of the forecast to query."];
      startDate: DateTime.t option
        [@ocaml.doc
          "The start date for the forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T08:00:00."];
      endDate: DateTime.t option
        [@ocaml.doc
          "The end date for the forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T20:00:00."];
      filters: Filters.t
        [@ocaml.doc
          "The filtering criteria to apply when retrieving the forecast. For example, to get the forecast for client_21 in the electricity usage dataset, specify the following: \\{\"item_id\" : \"client_21\"\\} To get the full forecast, use the CreateForecastExportJob operation."];
      nextToken: NextToken.t option
        [@ocaml.doc
          "If the result of the previous request was truncated, the response includes a NextToken. To retrieve the next set of results, use the token in the next request. Tokens expire after 24 hours."]}
    let context_ = "QueryForecastRequest"
    let make ?startDate =
      fun ?endDate ->
        fun ?nextToken ->
          fun ~forecastArn ->
            fun ~filters ->
              fun () ->
                { startDate; endDate; nextToken; forecastArn; filters }
    let to_value x =
      structure_to_value
        [("ForecastArn", (Some (Arn.to_value x.forecastArn)));
        ("StartDate", (Option.map x.startDate ~f:DateTime.to_value));
        ("EndDate", (Option.map x.endDate ~f:DateTime.to_value));
        ("Filters", (Some (Filters.to_value x.filters)));
        ("NextToken", (Option.map x.nextToken ~f:NextToken.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let nextToken =
        (Option.map ~f:NextToken.of_xml) (Xml.child xml_arg0 "NextToken") in
      let filters =
        Filters.of_xml (Xml.child_exn ~context:context_ xml_arg0 "Filters") in
      let endDate =
        (Option.map ~f:DateTime.of_xml) (Xml.child xml_arg0 "EndDate") in
      let startDate =
        (Option.map ~f:DateTime.of_xml) (Xml.child xml_arg0 "StartDate") in
      let forecastArn =
        Arn.of_xml (Xml.child_exn ~context:context_ xml_arg0 "ForecastArn") in
      make ?nextToken ~filters ?endDate ?startDate ~forecastArn ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let nextToken = field_map json__ "NextToken" NextToken.of_json in
      let filters = field_map_exn json__ "Filters" Filters.of_json in
      let endDate = field_map json__ "EndDate" DateTime.of_json in
      let startDate = field_map json__ "StartDate" DateTime.of_json in
      let forecastArn = field_map_exn json__ "ForecastArn" Arn.of_json in
      make ?nextToken ~filters ?endDate ?startDate ~forecastArn ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Retrieves a forecast for a single item, filtered by the supplied criteria. The criteria is a key-value pair. The key is either item_id (or the equivalent non-timestamp, non-target field) from the TARGET_TIME_SERIES dataset, or one of the forecast dimensions specified as part of the FeaturizationConfig object. By default, QueryForecast returns the complete date range for the filtered forecast. You can request a specific date range. To get the full forecast, use the CreateForecastExportJob operation. The forecasts generated by Amazon Forecast are in the same timezone as the dataset that was used to create the predictor."]