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
(* 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.apigatewaymanagementapi
let apiVersion = "2018-11-29"
let endpointPrefix = "execute-api"
let serviceFullName = "AmazonApiGatewayManagementApi"
let signatureVersion = "v4"
let protocol = "rest_json"
let globalEndpoint = endpointPrefix ^ ".amazonaws.com"
let simple_to_json to_value x =
  Botodata.Json.value_to_json_scalar (to_value x)
let composed_to_json to_value x = Botodata.Json.value_to_json (to_value x)
let to_query to_value x = Client.Query.of_value (to_value x)
let structure_to_value_aux st ~f =
  let filter = function | (k, Some v) -> Some (k, v) | _ -> None in
  let pair k v = (k, v) in
  let defer_value (k, dv) = pair k dv in
  ((List.filter_map st ~f:filter) |> (List.map ~f:defer_value)) |>
    (fun x -> `Structure (f x))
let structure_to_value = structure_to_value_aux ~f:Fn.id
let structure_to_wrapped_value ~wrapper ~response =
  structure_to_value_aux
    ~f:(fun x -> [(wrapper, (`Structure x)); (response, (`Structure []))])
module Zz__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 Data =
  struct
    type nonrec t = string[@@ocaml.doc
                            "The data to be sent to the client specified by its connection id."]
    let make i = i
    let of_string x = x
    let to_value x = `Blob x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml xml_arg0 = string_of_xml ~kind:"a blob" xml_arg0
    let of_json j = string_of_json ~kind:"a blob" j
    let to_json = simple_to_json to_value
  end[@@ocaml.doc
       "The data to be sent to the client specified by its connection id."]
module ForbiddenException =
  struct
    type nonrec t = unit
    let make () = ()
    let of_header_and_body = ((fun (xs, pipe) -> make ())[@warning "-27"])
    let to_value _ = `Structure []
    let to_query v = to_query to_value v
    let of_xml _ = make ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json _ = make ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "The caller is not authorized to invoke this operation."]
module GoneException =
  struct
    type nonrec t = unit
    let make () = ()
    let of_header_and_body = ((fun (xs, pipe) -> make ())[@warning "-27"])
    let to_value _ = `Structure []
    let to_query v = to_query to_value v
    let of_xml _ = make ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json _ = make ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "The connection with the provided id no longer exists."]
module Identity =
  struct
    type nonrec t =
      {
      sourceIp: Zz__string.t option
        [@ocaml.doc
          "The source IP address of the TCP connection making the request to API Gateway."];
      userAgent: Zz__string.t option
        [@ocaml.doc "The User Agent of the API caller."]}
    let make ?sourceIp = fun ?userAgent -> fun () -> { sourceIp; userAgent }
    let to_value x =
      structure_to_value
        [("sourceIp", (Option.map x.sourceIp ~f:Zz__string.to_value));
        ("userAgent", (Option.map x.userAgent ~f:Zz__string.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let userAgent =
        (Option.map ~f:Zz__string.of_xml) (Xml.child xml_arg0 "userAgent") in
      let sourceIp =
        (Option.map ~f:Zz__string.of_xml) (Xml.child xml_arg0 "sourceIp") in
      make ?userAgent ?sourceIp ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let userAgent = field_map json__ "UserAgent" Zz__string.of_json in
      let sourceIp = field_map json__ "SourceIp" Zz__string.of_json in
      make ?userAgent ?sourceIp ()
    let to_json v = composed_to_json to_value v
  end
module LimitExceededException =
  struct
    type nonrec t = unit
    let make () = ()
    let of_header_and_body = ((fun (xs, pipe) -> make ())[@warning "-27"])
    let to_value _ = `Structure []
    let to_query v = to_query to_value v
    let of_xml _ = make ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json _ = make ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The client is sending more than the allowed number of requests per unit of time or the WebSocket client side buffer is full."]
module Zz__timestampIso8601 =
  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 PostToConnectionRequest =
  struct
    type nonrec t =
      {
      data: Data.t
        [@ocaml.doc
          "The data to be sent to the client specified by its connection id."];
      connectionId: Zz__string.t
        [@ocaml.doc
          "The identifier of the connection that a specific client is using."]}
    let context_ = "PostToConnectionRequest"
    let make ~data = fun ~connectionId -> fun () -> { data; connectionId }
    let of_header_and_body =
      ((fun (xs, pipe) ->
          make ~data:pipe
            ~connectionId:(Zz__string.of_string
                             ((List.Assoc.find_exn
                                 ~equal:String.Caseless.equal) xs
                                "connectionId")) ())
      [@warning "-27"])
    let to_value x =
      structure_to_value
        [("Data", (Some (Data.to_value x.data)));
        ("connectionId", (Some (Zz__string.to_value x.connectionId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let connectionId =
        Zz__string.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "connectionId") in
      let data =
        Data.of_xml (Xml.child_exn ~context:context_ xml_arg0 "Data") in
      make ~connectionId ~data ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let connectionId =
        field_map_exn json__ "ConnectionId" Zz__string.of_json in
      let data = field_map_exn json__ "Data" Data.of_json in
      make ~connectionId ~data ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Sends the provided data to the specified connection."]
module PayloadTooLargeException =
  struct
    type nonrec t = {
      message: Zz__string.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:Zz__string.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:Zz__string.of_xml) (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "Message" Zz__string.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "The data has exceeded the maximum size allowed."]
module GetConnectionResponse =
  struct
    type nonrec t =
      {
      connectedAt: Zz__timestampIso8601.t option
        [@ocaml.doc
          "The time in ISO 8601 format for when the connection was established."];
      identity: Identity.t option ;
      lastActiveAt: Zz__timestampIso8601.t option
        [@ocaml.doc
          "The time in ISO 8601 format for when the connection was last active."]}
    type nonrec error =
      [ `ForbiddenException of ForbiddenException.t 
      | `GoneException of GoneException.t 
      | `LimitExceededException of LimitExceededException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?connectedAt =
      fun ?identity ->
        fun ?lastActiveAt ->
          fun () -> { connectedAt; identity; lastActiveAt }
    let error_of_json name json =
      match name with
      | "ForbiddenException" ->
          `ForbiddenException (ForbiddenException.of_json json)
      | "GoneException" -> `GoneException (GoneException.of_json json)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "ForbiddenException" ->
          `ForbiddenException (ForbiddenException.of_xml xml)
      | "GoneException" -> `GoneException (GoneException.of_xml xml)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `ForbiddenException e ->
          `Assoc
            [("error", (`String "ForbiddenException"));
            ("details", (ForbiddenException.to_json e))]
      | `GoneException e ->
          `Assoc
            [("error", (`String "GoneException"));
            ("details", (GoneException.to_json e))]
      | `LimitExceededException e ->
          `Assoc
            [("error", (`String "LimitExceededException"));
            ("details", (LimitExceededException.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
        [("connectedAt",
           (Option.map x.connectedAt ~f:Zz__timestampIso8601.to_value));
        ("identity", (Option.map x.identity ~f:Identity.to_value));
        ("lastActiveAt",
          (Option.map x.lastActiveAt ~f:Zz__timestampIso8601.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let lastActiveAt =
        (Option.map ~f:Zz__timestampIso8601.of_xml)
          (Xml.child xml_arg0 "lastActiveAt") in
      let identity =
        (Option.map ~f:Identity.of_xml) (Xml.child xml_arg0 "identity") in
      let connectedAt =
        (Option.map ~f:Zz__timestampIso8601.of_xml)
          (Xml.child xml_arg0 "connectedAt") in
      make ?lastActiveAt ?identity ?connectedAt ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let lastActiveAt =
        field_map json__ "LastActiveAt" Zz__timestampIso8601.of_json in
      let identity = field_map json__ "Identity" Identity.of_json in
      let connectedAt =
        field_map json__ "ConnectedAt" Zz__timestampIso8601.of_json in
      make ?lastActiveAt ?identity ?connectedAt ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Get information about the connection with the provided id."]
module GetConnectionRequest =
  struct
    type nonrec t = {
      connectionId: Zz__string.t }
    let context_ = "GetConnectionRequest"
    let make ~connectionId = fun () -> { connectionId }
    let to_value x =
      structure_to_value
        [("connectionId", (Some (Zz__string.to_value x.connectionId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let connectionId =
        Zz__string.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "connectionId") in
      make ~connectionId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let connectionId =
        field_map_exn json__ "ConnectionId" Zz__string.of_json in
      make ~connectionId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Get information about the connection with the provided id."]
module DeleteConnectionRequest =
  struct
    type nonrec t = {
      connectionId: Zz__string.t }
    let context_ = "DeleteConnectionRequest"
    let make ~connectionId = fun () -> { connectionId }
    let to_value x =
      structure_to_value
        [("connectionId", (Some (Zz__string.to_value x.connectionId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let connectionId =
        Zz__string.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "connectionId") in
      make ~connectionId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let connectionId =
        field_map_exn json__ "ConnectionId" Zz__string.of_json in
      make ~connectionId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Delete the connection with the provided id."]