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
(* 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.inspector_scan
let apiVersion = "2023-08-08"
let endpointPrefix = "inspector-scan"
let serviceFullName = "Inspector Scan"
let signatureVersion = "v4"
let protocol = "rest_json"
let globalEndpoint = endpointPrefix ^ ".amazonaws.com"
let serviceAbbreviation = "inspector-scan"
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 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 ValidationExceptionField =
  struct
    type nonrec t =
      {
      name: String_.t option
        [@ocaml.doc "The name of the validation exception."];
      message: String_.t option
        [@ocaml.doc "The validation exception message."]}
    let make ?name = fun ?message -> fun () -> { name; message }
    let to_value x =
      structure_to_value
        [("name", (Option.map x.name ~f:String_.to_value));
        ("message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:String_.of_xml) (Xml.child xml_arg0 "message") in
      let name = (Option.map ~f:String_.of_xml) (Xml.child xml_arg0 "name") in
      make ?message ?name ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" String_.of_json in
      let name = field_map json__ "name" String_.of_json in
      make ?message ?name ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request has failed validation due to missing required fields or having invalid inputs."]
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 InternalServerExceptionReason =
  struct
    type nonrec t =
      | FAILED_TO_GENERATE_SBOM 
      | OTHER 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | FAILED_TO_GENERATE_SBOM -> "FAILED_TO_GENERATE_SBOM"
      | OTHER -> "OTHER"
      | Non_static_id s -> s
    let of_string =
      function
      | "FAILED_TO_GENERATE_SBOM" -> FAILED_TO_GENERATE_SBOM
      | "OTHER" -> OTHER
      | 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 InternalServerExceptionReason"
           xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"InternalServerExceptionReason" j)
    let to_json = simple_to_json to_value
  end
module ValidationExceptionFields =
  struct
    type nonrec t = ValidationExceptionField.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:ValidationExceptionField.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:ValidationExceptionField.of_xml)
    let of_json j =
      list_of_json ~kind:"ValidationExceptionFields"
        ~of_json:ValidationExceptionField.of_json j
    let to_json v = composed_to_json to_value v
  end
module ValidationExceptionReason =
  struct
    type nonrec t =
      | UNKNOWN_OPERATION 
      | CANNOT_PARSE 
      | FIELD_VALIDATION_FAILED 
      | UNSUPPORTED_SBOM_TYPE 
      | OTHER 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | UNKNOWN_OPERATION -> "UNKNOWN_OPERATION"
      | CANNOT_PARSE -> "CANNOT_PARSE"
      | FIELD_VALIDATION_FAILED -> "FIELD_VALIDATION_FAILED"
      | UNSUPPORTED_SBOM_TYPE -> "UNSUPPORTED_SBOM_TYPE"
      | OTHER -> "OTHER"
      | Non_static_id s -> s
    let of_string =
      function
      | "UNKNOWN_OPERATION" -> UNKNOWN_OPERATION
      | "CANNOT_PARSE" -> CANNOT_PARSE
      | "FIELD_VALIDATION_FAILED" -> FIELD_VALIDATION_FAILED
      | "UNSUPPORTED_SBOM_TYPE" -> UNSUPPORTED_SBOM_TYPE
      | "OTHER" -> OTHER
      | 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 ValidationExceptionReason" xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"ValidationExceptionReason" j)
    let to_json = simple_to_json to_value
  end
module AccessDeniedException =
  struct
    type nonrec t = {
      message: String_.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:String_.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f: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" String_.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "You do not have sufficient access to perform this action."]
module InternalServerException =
  struct
    type nonrec t =
      {
      message: String_.t option ;
      reason: InternalServerExceptionReason.t option
        [@ocaml.doc "The reason for the validation failure."];
      retryAfterSeconds: Integer.t option
        [@ocaml.doc
          "The number of seconds to wait before retrying the request."]}
    let make ?message =
      fun ?reason ->
        fun ?retryAfterSeconds ->
          fun () -> { message; reason; retryAfterSeconds }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:String_.to_value));
        ("reason",
          (Option.map x.reason ~f:InternalServerExceptionReason.to_value));
        ("Retry-After", (Option.map x.retryAfterSeconds ~f:Integer.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let retryAfterSeconds =
        (Option.map ~f:Integer.of_xml) (Xml.child xml_arg0 "Retry-After") in
      let reason =
        (Option.map ~f:InternalServerExceptionReason.of_xml)
          (Xml.child xml_arg0 "reason") in
      let message =
        (Option.map ~f:String_.of_xml) (Xml.child xml_arg0 "message") in
      make ?retryAfterSeconds ?reason ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let retryAfterSeconds =
        field_map json__ "retryAfterSeconds" Integer.of_json in
      let reason =
        field_map json__ "reason" InternalServerExceptionReason.of_json in
      let message = field_map json__ "message" String_.of_json in
      make ?retryAfterSeconds ?reason ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request processing has failed because of an unknown error, exception or failure."]
module Sbom =
  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
module ThrottlingException =
  struct
    type nonrec t =
      {
      message: String_.t option ;
      retryAfterSeconds: Integer.t option
        [@ocaml.doc
          "The number of seconds to wait before retrying the request."]}
    let make ?message =
      fun ?retryAfterSeconds -> fun () -> { message; retryAfterSeconds }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:String_.to_value));
        ("Retry-After", (Option.map x.retryAfterSeconds ~f:Integer.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let retryAfterSeconds =
        (Option.map ~f:Integer.of_xml) (Xml.child xml_arg0 "Retry-After") in
      let message =
        (Option.map ~f:String_.of_xml) (Xml.child xml_arg0 "message") in
      make ?retryAfterSeconds ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let retryAfterSeconds =
        field_map json__ "retryAfterSeconds" Integer.of_json in
      let message = field_map json__ "message" String_.of_json in
      make ?retryAfterSeconds ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "The request was denied due to request throttling."]
module ValidationException =
  struct
    type nonrec t =
      {
      message: String_.t option ;
      reason: ValidationExceptionReason.t option
        [@ocaml.doc "The reason for the validation failure."];
      fields: ValidationExceptionFields.t option
        [@ocaml.doc "The fields that failed validation."]}
    let make ?message =
      fun ?reason -> fun ?fields -> fun () -> { message; reason; fields }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:String_.to_value));
        ("reason",
          (Option.map x.reason ~f:ValidationExceptionReason.to_value));
        ("fields",
          (Option.map x.fields ~f:ValidationExceptionFields.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let fields =
        (Option.map ~f:ValidationExceptionFields.of_xml)
          (Xml.child xml_arg0 "fields") in
      let reason =
        (Option.map ~f:ValidationExceptionReason.of_xml)
          (Xml.child xml_arg0 "reason") in
      let message =
        (Option.map ~f:String_.of_xml) (Xml.child xml_arg0 "message") in
      make ?fields ?reason ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let fields =
        field_map json__ "fields" ValidationExceptionFields.of_json in
      let reason =
        field_map json__ "reason" ValidationExceptionReason.of_json in
      let message = field_map json__ "message" String_.of_json in
      make ?fields ?reason ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request has failed validation due to missing required fields or having invalid inputs."]
module OutputFormat =
  struct
    type nonrec t =
      | CYCLONE_DX_1_5 
      | INSPECTOR 
      | INSPECTOR_ALT 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | CYCLONE_DX_1_5 -> "CYCLONE_DX_1_5"
      | INSPECTOR -> "INSPECTOR"
      | INSPECTOR_ALT -> "INSPECTOR_ALT"
      | Non_static_id s -> s
    let of_string =
      function
      | "CYCLONE_DX_1_5" -> CYCLONE_DX_1_5
      | "INSPECTOR" -> INSPECTOR
      | "INSPECTOR_ALT" -> INSPECTOR_ALT
      | 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 OutputFormat" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"OutputFormat" j)
    let to_json = simple_to_json to_value
  end
module ScanSbomResponse =
  struct
    type nonrec t =
      {
      sbom: Sbom.t option
        [@ocaml.doc "The vulnerability report for the scanned SBOM."]}
    type nonrec error =
      [ `AccessDeniedException of AccessDeniedException.t 
      | `InternalServerException of InternalServerException.t 
      | `ThrottlingException of ThrottlingException.t 
      | `ValidationException of ValidationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?sbom = fun () -> { sbom }
    let error_of_json name json =
      match name with
      | "AccessDeniedException" ->
          `AccessDeniedException (AccessDeniedException.of_json json)
      | "InternalServerException" ->
          `InternalServerException (InternalServerException.of_json json)
      | "ThrottlingException" ->
          `ThrottlingException (ThrottlingException.of_json json)
      | "ValidationException" ->
          `ValidationException (ValidationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "AccessDeniedException" ->
          `AccessDeniedException (AccessDeniedException.of_xml xml)
      | "InternalServerException" ->
          `InternalServerException (InternalServerException.of_xml xml)
      | "ThrottlingException" ->
          `ThrottlingException (ThrottlingException.of_xml xml)
      | "ValidationException" ->
          `ValidationException (ValidationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `AccessDeniedException e ->
          `Assoc
            [("error", (`String "AccessDeniedException"));
            ("details", (AccessDeniedException.to_json e))]
      | `InternalServerException e ->
          `Assoc
            [("error", (`String "InternalServerException"));
            ("details", (InternalServerException.to_json e))]
      | `ThrottlingException e ->
          `Assoc
            [("error", (`String "ThrottlingException"));
            ("details", (ThrottlingException.to_json e))]
      | `ValidationException e ->
          `Assoc
            [("error", (`String "ValidationException"));
            ("details", (ValidationException.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 [("sbom", (Option.map x.sbom ~f:Sbom.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let sbom = (Option.map ~f:Sbom.of_xml) (Xml.child xml_arg0 "sbom") in
      make ?sbom ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let sbom = field_map json__ "sbom" Sbom.of_json in make ?sbom ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Scans a provided CycloneDX 1.5 SBOM and reports on any vulnerabilities discovered in that SBOM. You can generate compatible SBOMs for your resources using the Amazon Inspector SBOM generator. The output of this action reports NVD and CVSS scores when NVD and CVSS scores are available. Because the output reports both scores, you might notice a discrepency between them. However, you can triage the severity of either score depending on the vendor of your choosing."]
module ScanSbomRequest =
  struct
    type nonrec t =
      {
      sbom: Sbom.t
        [@ocaml.doc
          "The JSON file for the SBOM you want to scan. The SBOM must be in CycloneDX 1.5 format. This format limits you to passing 2000 components before throwing a ValidException error."];
      outputFormat: OutputFormat.t option
        [@ocaml.doc "The output format for the vulnerability report."]}
    let context_ = "ScanSbomRequest"
    let make ?outputFormat = fun ~sbom -> fun () -> { outputFormat; sbom }
    let to_value x =
      structure_to_value
        [("sbom", (Some (Sbom.to_value x.sbom)));
        ("outputFormat",
          (Option.map x.outputFormat ~f:OutputFormat.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let outputFormat =
        (Option.map ~f:OutputFormat.of_xml)
          (Xml.child xml_arg0 "outputFormat") in
      let sbom =
        Sbom.of_xml (Xml.child_exn ~context:context_ xml_arg0 "sbom") in
      make ?outputFormat ~sbom ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let outputFormat = field_map json__ "outputFormat" OutputFormat.of_json in
      let sbom = field_map_exn json__ "sbom" Sbom.of_json in
      make ?outputFormat ~sbom ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Scans a provided CycloneDX 1.5 SBOM and reports on any vulnerabilities discovered in that SBOM. You can generate compatible SBOMs for your resources using the Amazon Inspector SBOM generator. The output of this action reports NVD and CVSS scores when NVD and CVSS scores are available. Because the output reports both scores, you might notice a discrepency between them. However, you can triage the severity of either score depending on the vendor of your choosing."]