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
(* 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.marketplace_entitlement
let apiVersion = "2017-01-11"
let endpointPrefix = "entitlement.marketplace"
let serviceFullName = "AWS Marketplace Entitlement Service"
let signatureVersion = "v4"
let protocol = "json"
let globalEndpoint = endpointPrefix ^ ".amazonaws.com"
let targetPrefix = "AWSMPEntitlementService"
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 Boolean =
  struct
    type nonrec t = bool
    let make i = i
    let of_string = Bool.of_string
    let to_value x = `Boolean x
    let to_query v = to_query to_value v
    let to_header x = Bool.to_string x
    let of_xml xml_arg0 =
      Bool.of_string (string_of_xml ~kind:"a boolean" xml_arg0)
    let of_json = bool_of_json
    let to_json = simple_to_json to_value
  end
module 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 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 String_ =
  struct
    type nonrec t = string
    let context_ = "String"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"String" j
    let to_json = simple_to_json to_value
  end
module EntitlementValue =
  struct
    type nonrec t =
      {
      integerValue: Integer.t option
        [@ocaml.doc
          "The IntegerValue field will be populated with an integer value when the entitlement is an integer type. Otherwise, the field will not be set."];
      doubleValue: Double.t option
        [@ocaml.doc
          "The DoubleValue field will be populated with a double value when the entitlement is a double type. Otherwise, the field will not be set."];
      booleanValue: Boolean.t option
        [@ocaml.doc
          "The BooleanValue field will be populated with a boolean value when the entitlement is a boolean type. Otherwise, the field will not be set."];
      stringValue: String_.t option
        [@ocaml.doc
          "The StringValue field will be populated with a string value when the entitlement is a string type. Otherwise, the field will not be set."]}
    let make ?integerValue =
      fun ?doubleValue ->
        fun ?booleanValue ->
          fun ?stringValue ->
            fun () ->
              { integerValue; doubleValue; booleanValue; stringValue }
    let to_value x =
      structure_to_value
        [("IntegerValue", (Option.map x.integerValue ~f:Integer.to_value));
        ("DoubleValue", (Option.map x.doubleValue ~f:Double.to_value));
        ("BooleanValue", (Option.map x.booleanValue ~f:Boolean.to_value));
        ("StringValue", (Option.map x.stringValue ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let stringValue =
        (Option.map ~f:String_.of_xml) (Xml.child xml_arg0 "StringValue") in
      let booleanValue =
        (Option.map ~f:Boolean.of_xml) (Xml.child xml_arg0 "BooleanValue") in
      let doubleValue =
        (Option.map ~f:Double.of_xml) (Xml.child xml_arg0 "DoubleValue") in
      let integerValue =
        (Option.map ~f:Integer.of_xml) (Xml.child xml_arg0 "IntegerValue") in
      make ?stringValue ?booleanValue ?doubleValue ?integerValue ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let stringValue = field_map json__ "StringValue" String_.of_json in
      let booleanValue = field_map json__ "BooleanValue" Boolean.of_json in
      let doubleValue = field_map json__ "DoubleValue" Double.of_json in
      let integerValue = field_map json__ "IntegerValue" Integer.of_json in
      make ?stringValue ?booleanValue ?doubleValue ?integerValue ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The EntitlementValue represents the amount of capacity that the customer is entitled to for the product."]
module NonEmptyString =
  struct
    type nonrec t = string
    let context_ = "NonEmptyString"
    let make i =
      let open Result in ok_or_failwith (check_pattern i ~pattern:"\\S+"); 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:"NonEmptyString" j
    let to_json = simple_to_json to_value
  end
module ProductCode =
  struct
    type nonrec t = string
    let context_ = "ProductCode"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:255) >>=
             (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:"ProductCode" 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 FilterValue =
  struct
    type nonrec t = string
    let context_ = "FilterValue"
    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:"FilterValue" j
    let to_json = simple_to_json to_value
  end
module Entitlement =
  struct
    type nonrec t =
      {
      productCode: ProductCode.t option
        [@ocaml.doc
          "The product code for which the given entitlement applies. Product codes are provided by AWS Marketplace when the product listing is created."];
      dimension: NonEmptyString.t option
        [@ocaml.doc
          "The dimension for which the given entitlement applies. Dimensions represent categories of capacity in a product and are specified when the product is listed in AWS Marketplace."];
      customerIdentifier: NonEmptyString.t option
        [@ocaml.doc
          "The customer identifier is a handle to each unique customer in an application. Customer identifiers are obtained through the ResolveCustomer operation in AWS Marketplace Metering Service."];
      customerAWSAccountId: NonEmptyString.t option
        [@ocaml.doc
          "The CustomerAWSAccountId parameter specifies the AWS account ID of the buyer."];
      value: EntitlementValue.t option
        [@ocaml.doc
          "The EntitlementValue represents the amount of capacity that the customer is entitled to for the product."];
      expirationDate: Timestamp.t option
        [@ocaml.doc
          "The expiration date represents the minimum date through which this entitlement is expected to remain valid. For contractual products listed on AWS Marketplace, the expiration date is the date at which the customer will renew or cancel their contract. Customers who are opting to renew their contract will still have entitlements with an expiration date."];
      licenseArn: String_.t option
        [@ocaml.doc
          "The LicenseArn is a unique identifier for a specific granted license. These are used for software purchased through AWS Marketplace."]}
    let make ?productCode =
      fun ?dimension ->
        fun ?customerIdentifier ->
          fun ?customerAWSAccountId ->
            fun ?value ->
              fun ?expirationDate ->
                fun ?licenseArn ->
                  fun () ->
                    {
                      productCode;
                      dimension;
                      customerIdentifier;
                      customerAWSAccountId;
                      value;
                      expirationDate;
                      licenseArn
                    }
    let to_value x =
      structure_to_value
        [("ProductCode", (Option.map x.productCode ~f:ProductCode.to_value));
        ("Dimension", (Option.map x.dimension ~f:NonEmptyString.to_value));
        ("CustomerIdentifier",
          (Option.map x.customerIdentifier ~f:NonEmptyString.to_value));
        ("CustomerAWSAccountId",
          (Option.map x.customerAWSAccountId ~f:NonEmptyString.to_value));
        ("Value", (Option.map x.value ~f:EntitlementValue.to_value));
        ("ExpirationDate",
          (Option.map x.expirationDate ~f:Timestamp.to_value));
        ("LicenseArn", (Option.map x.licenseArn ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let licenseArn =
        (Option.map ~f:String_.of_xml) (Xml.child xml_arg0 "LicenseArn") in
      let expirationDate =
        (Option.map ~f:Timestamp.of_xml)
          (Xml.child xml_arg0 "ExpirationDate") in
      let value =
        (Option.map ~f:EntitlementValue.of_xml) (Xml.child xml_arg0 "Value") in
      let customerAWSAccountId =
        (Option.map ~f:NonEmptyString.of_xml)
          (Xml.child xml_arg0 "CustomerAWSAccountId") in
      let customerIdentifier =
        (Option.map ~f:NonEmptyString.of_xml)
          (Xml.child xml_arg0 "CustomerIdentifier") in
      let dimension =
        (Option.map ~f:NonEmptyString.of_xml)
          (Xml.child xml_arg0 "Dimension") in
      let productCode =
        (Option.map ~f:ProductCode.of_xml) (Xml.child xml_arg0 "ProductCode") in
      make ?licenseArn ?expirationDate ?value ?customerAWSAccountId
        ?customerIdentifier ?dimension ?productCode ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let licenseArn = field_map json__ "LicenseArn" String_.of_json in
      let expirationDate =
        field_map json__ "ExpirationDate" Timestamp.of_json in
      let value = field_map json__ "Value" EntitlementValue.of_json in
      let customerAWSAccountId =
        field_map json__ "CustomerAWSAccountId" NonEmptyString.of_json in
      let customerIdentifier =
        field_map json__ "CustomerIdentifier" NonEmptyString.of_json in
      let dimension = field_map json__ "Dimension" NonEmptyString.of_json in
      let productCode = field_map json__ "ProductCode" ProductCode.of_json in
      make ?licenseArn ?expirationDate ?value ?customerAWSAccountId
        ?customerIdentifier ?dimension ?productCode ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "An entitlement represents capacity in a product owned by the customer. For example, a customer might own some number of users or seats in an SaaS application or some amount of data capacity in a multi-tenant database."]
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 FilterValueList =
  struct
    type nonrec t = FilterValue.t list
    let make i =
      let open Result in ok_or_failwith (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:FilterValue.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:FilterValue.of_xml)
    let of_json j =
      list_of_json ~kind:"FilterValueList" ~of_json:FilterValue.of_json j
    let to_json v = composed_to_json to_value v
  end
module GetEntitlementFilterName =
  struct
    type nonrec t =
      | CUSTOMER_IDENTIFIER 
      | DIMENSION 
      | CUSTOMER_AWS_ACCOUNT_ID 
      | LICENSE_ARN 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | CUSTOMER_IDENTIFIER -> "CUSTOMER_IDENTIFIER"
      | DIMENSION -> "DIMENSION"
      | CUSTOMER_AWS_ACCOUNT_ID -> "CUSTOMER_AWS_ACCOUNT_ID"
      | LICENSE_ARN -> "LICENSE_ARN"
      | Non_static_id s -> s
    let of_string =
      function
      | "CUSTOMER_IDENTIFIER" -> CUSTOMER_IDENTIFIER
      | "DIMENSION" -> DIMENSION
      | "CUSTOMER_AWS_ACCOUNT_ID" -> CUSTOMER_AWS_ACCOUNT_ID
      | "LICENSE_ARN" -> LICENSE_ARN
      | 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 GetEntitlementFilterName" xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"GetEntitlementFilterName" j)
    let to_json = simple_to_json to_value
  end
module EntitlementList =
  struct
    type nonrec t = Entitlement.t list
    let make i =
      let open Result in ok_or_failwith (check_list_min i ~min:0); i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:Entitlement.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:Entitlement.of_xml)
    let of_json j =
      list_of_json ~kind:"EntitlementList" ~of_json:Entitlement.of_json j
    let to_json v = composed_to_json to_value v
  end
module InternalServiceErrorException =
  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
       "An internal error has occurred. Retry your request. If the problem persists, post a message with details on the AWS forums."]
module InvalidParameterException =
  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 "One or more parameters in your request was invalid."]
module ThrottlingException =
  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 calls to the GetEntitlements API are throttled."]
module GetEntitlementFilters =
  struct
    type nonrec t = (GetEntitlementFilterName.t * FilterValueList.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 GetEntitlementFilterName FilterValueList"))))
    let to_value xs =
      (xs |>
         (List.map
            ~f:(fun (x, y) ->
                  (GetEntitlementFilterName.to_value x) |>
                    (fun x ->
                       (FilterValueList.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:GetEntitlementFilterName.of_string
        ~of_json:FilterValueList.of_json j
    let to_json v = composed_to_json to_value v
  end
module PageSizeInteger =
  struct
    type nonrec t = int
    let make i =
      let open Result in
        ok_or_failwith
          ((check_int_max i ~max:25) >>= (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 PageSizeInteger" 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 GetEntitlementsResult =
  struct
    type nonrec t =
      {
      entitlements: EntitlementList.t option
        [@ocaml.doc
          "The set of entitlements found through the GetEntitlements operation. If the result contains an empty set of entitlements, NextToken might still be present and should be used."];
      nextToken: NonEmptyString.t option
        [@ocaml.doc
          "For paginated results, use NextToken in subsequent calls to GetEntitlements. If the result contains an empty set of entitlements, NextToken might still be present and should be used."]}
    type nonrec error =
      [ `InternalServiceErrorException of InternalServiceErrorException.t 
      | `InvalidParameterException of InvalidParameterException.t 
      | `ThrottlingException of ThrottlingException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?entitlements =
      fun ?nextToken -> fun () -> { entitlements; nextToken }
    let error_of_json name json =
      match name with
      | "InternalServiceErrorException" ->
          `InternalServiceErrorException
            (InternalServiceErrorException.of_json json)
      | "InvalidParameterException" ->
          `InvalidParameterException (InvalidParameterException.of_json json)
      | "ThrottlingException" ->
          `ThrottlingException (ThrottlingException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "InternalServiceErrorException" ->
          `InternalServiceErrorException
            (InternalServiceErrorException.of_xml xml)
      | "InvalidParameterException" ->
          `InvalidParameterException (InvalidParameterException.of_xml xml)
      | "ThrottlingException" ->
          `ThrottlingException (ThrottlingException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `InternalServiceErrorException e ->
          `Assoc
            [("error", (`String "InternalServiceErrorException"));
            ("details", (InternalServiceErrorException.to_json e))]
      | `InvalidParameterException e ->
          `Assoc
            [("error", (`String "InvalidParameterException"));
            ("details", (InvalidParameterException.to_json e))]
      | `ThrottlingException e ->
          `Assoc
            [("error", (`String "ThrottlingException"));
            ("details", (ThrottlingException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("Entitlements",
           (Option.map x.entitlements ~f:EntitlementList.to_value));
        ("NextToken", (Option.map x.nextToken ~f:NonEmptyString.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let nextToken =
        (Option.map ~f:NonEmptyString.of_xml)
          (Xml.child xml_arg0 "NextToken") in
      let entitlements =
        (Option.map ~f:EntitlementList.of_xml)
          (Xml.child xml_arg0 "Entitlements") in
      make ?nextToken ?entitlements ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let nextToken = field_map json__ "NextToken" NonEmptyString.of_json in
      let entitlements =
        field_map json__ "Entitlements" EntitlementList.of_json in
      make ?nextToken ?entitlements ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The GetEntitlementsRequest contains results from the GetEntitlements operation."]
module GetEntitlementsRequest =
  struct
    type nonrec t =
      {
      productCode: ProductCode.t
        [@ocaml.doc
          "Product code is used to uniquely identify a product in AWS Marketplace. The product code will be provided by AWS Marketplace when the product listing is created."];
      filter: GetEntitlementFilters.t option
        [@ocaml.doc
          "Filter is used to return entitlements for a specific customer or for a specific dimension. Filters are described as keys mapped to a lists of values. Filtered requests are unioned for each value in the value list, and then intersected for each filter key. CustomerIdentifier and CustomerAWSAccountId are mutually exclusive parameters. You must use one or the other, but not both in the same request. If you're migrating an existing integration, use Account Feeds to map CustomerIdentifier to CustomerAWSAccountId, and Agreements Feeds to map CustomerAWSAccountId and LicenseArn."];
      nextToken: NonEmptyString.t option
        [@ocaml.doc
          "For paginated calls to GetEntitlements, pass the NextToken from the previous GetEntitlementsResult."];
      maxResults: PageSizeInteger.t option
        [@ocaml.doc
          "The maximum number of items to retrieve from the GetEntitlements operation. For pagination, use the NextToken field in subsequent calls to GetEntitlements."]}
    let context_ = "GetEntitlementsRequest"
    let make ?filter =
      fun ?nextToken ->
        fun ?maxResults ->
          fun ~productCode ->
            fun () -> { filter; nextToken; maxResults; productCode }
    let to_value x =
      structure_to_value
        [("ProductCode", (Some (ProductCode.to_value x.productCode)));
        ("Filter", (Option.map x.filter ~f:GetEntitlementFilters.to_value));
        ("NextToken", (Option.map x.nextToken ~f:NonEmptyString.to_value));
        ("MaxResults", (Option.map x.maxResults ~f:PageSizeInteger.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let maxResults =
        (Option.map ~f:PageSizeInteger.of_xml)
          (Xml.child xml_arg0 "MaxResults") in
      let nextToken =
        (Option.map ~f:NonEmptyString.of_xml)
          (Xml.child xml_arg0 "NextToken") in
      let filter =
        (Option.map ~f:GetEntitlementFilters.of_xml)
          (Xml.child xml_arg0 "Filter") in
      let productCode =
        ProductCode.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "ProductCode") in
      make ?maxResults ?nextToken ?filter ~productCode ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let maxResults = field_map json__ "MaxResults" PageSizeInteger.of_json in
      let nextToken = field_map json__ "NextToken" NonEmptyString.of_json in
      let filter = field_map json__ "Filter" GetEntitlementFilters.of_json in
      let productCode =
        field_map_exn json__ "ProductCode" ProductCode.of_json in
      make ?maxResults ?nextToken ?filter ~productCode ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The GetEntitlementsRequest contains parameters for the GetEntitlements operation."]