From fcf17c7f10248f261ebc6e7cd9cee10f03437131 Mon Sep 17 00:00:00 2001 From: Tim McGilchrist Date: Sat, 27 Mar 2021 11:40:49 +1100 Subject: [PATCH 1/3] Setup generation of AWS Lambda API. --- Makefile | 1 + aws-lambda.opam | 22 ++++++++++++++++++++++ input/lambda/latest | 1 + 3 files changed, 24 insertions(+) create mode 100644 aws-lambda.opam create mode 120000 input/lambda/latest diff --git a/Makefile b/Makefile index 8273992c1..9e3d25c18 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ LIBRARIES := \ aws-sts \ aws-route53 \ aws-sqs \ + aws-lambda \ .PHONY: $(LIBRARIES) $(LIBRARIES): aws-%: diff --git a/aws-lambda.opam b/aws-lambda.opam new file mode 100644 index 000000000..975bf4d38 --- /dev/null +++ b/aws-lambda.opam @@ -0,0 +1,22 @@ +opam-version: "2.0" +maintainer: "Tim McGilchrist " +authors: [ "Spiros Eliopoulos " + "Daniel Patterson " + "Tim McGilchrist " + ] +synopsis: "Amazon Web Services SDK bindings to AWS Lambda" +description: "Amazon Web Services SDK bindings to AWS Lambda" +version: "1.1" +license: "BSD-3-clause" +homepage: "https://github.com/inhabitedtype/ocaml-aws" +dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git" +bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues" +doc: "https://github.com/inhabitedtype/ocaml-aws" +build: [ + ["dune" "subst"] {dev} + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "aws" {>= version} + "dune" {>= "2.7"} +] diff --git a/input/lambda/latest b/input/lambda/latest new file mode 120000 index 000000000..29e703de7 --- /dev/null +++ b/input/lambda/latest @@ -0,0 +1 @@ +2015-03-31 \ No newline at end of file From bb70eee23e1757a8e03948fda5977de10cd4541e Mon Sep 17 00:00:00 2001 From: Tim McGilchrist Date: Sat, 27 Mar 2021 11:41:19 +1100 Subject: [PATCH 2/3] Run code generation for AWS Lambda. --- libraries/lambda/lib/addPermission.ml | 58 + libraries/lambda/lib/addPermission.mli | 7 + .../lambda/lib/createEventSourceMapping.ml | 61 + .../lambda/lib/createEventSourceMapping.mli | 7 + libraries/lambda/lib/createFunction.ml | 58 + libraries/lambda/lib/createFunction.mli | 7 + .../lambda/lib/deleteEventSourceMapping.ml | 61 + .../lambda/lib/deleteEventSourceMapping.mli | 7 + libraries/lambda/lib/deleteFunction.ml | 31 + libraries/lambda/lib/deleteFunction.mli | 7 + libraries/lambda/lib/dune | 6 + libraries/lambda/lib/errors_internal.ml | 183 ++ libraries/lambda/lib/getEventSourceMapping.ml | 60 + .../lambda/lib/getEventSourceMapping.mli | 7 + libraries/lambda/lib/getFunction.ml | 57 + libraries/lambda/lib/getFunction.mli | 7 + .../lambda/lib/getFunctionConfiguration.ml | 59 + .../lambda/lib/getFunctionConfiguration.mli | 7 + libraries/lambda/lib/getPolicy.ml | 57 + libraries/lambda/lib/getPolicy.mli | 7 + libraries/lambda/lib/invoke.ml | 57 + libraries/lambda/lib/invoke.mli | 7 + libraries/lambda/lib/invokeAsync.ml | 57 + libraries/lambda/lib/invokeAsync.mli | 7 + .../lambda/lib/listEventSourceMappings.ml | 61 + .../lambda/lib/listEventSourceMappings.mli | 7 + libraries/lambda/lib/listFunctions.ml | 58 + libraries/lambda/lib/listFunctions.mli | 7 + libraries/lambda/lib/removePermission.ml | 31 + libraries/lambda/lib/removePermission.mli | 7 + libraries/lambda/lib/types.ml | 1853 +++++++++++++++++ .../lambda/lib/updateEventSourceMapping.ml | 61 + .../lambda/lib/updateEventSourceMapping.mli | 7 + libraries/lambda/lib/updateFunctionCode.ml | 58 + libraries/lambda/lib/updateFunctionCode.mli | 7 + .../lambda/lib/updateFunctionConfiguration.ml | 60 + .../lib/updateFunctionConfiguration.mli | 7 + libraries/lambda/lib_test/aws_lambda_test.ml | 39 + libraries/lambda/lib_test/dune | 18 + libraries/lambda/lib_test/test_async.ml | 12 + libraries/lambda/lib_test/test_lwt.ml | 12 + 41 files changed, 3187 insertions(+) create mode 100644 libraries/lambda/lib/addPermission.ml create mode 100644 libraries/lambda/lib/addPermission.mli create mode 100644 libraries/lambda/lib/createEventSourceMapping.ml create mode 100644 libraries/lambda/lib/createEventSourceMapping.mli create mode 100644 libraries/lambda/lib/createFunction.ml create mode 100644 libraries/lambda/lib/createFunction.mli create mode 100644 libraries/lambda/lib/deleteEventSourceMapping.ml create mode 100644 libraries/lambda/lib/deleteEventSourceMapping.mli create mode 100644 libraries/lambda/lib/deleteFunction.ml create mode 100644 libraries/lambda/lib/deleteFunction.mli create mode 100644 libraries/lambda/lib/dune create mode 100644 libraries/lambda/lib/errors_internal.ml create mode 100644 libraries/lambda/lib/getEventSourceMapping.ml create mode 100644 libraries/lambda/lib/getEventSourceMapping.mli create mode 100644 libraries/lambda/lib/getFunction.ml create mode 100644 libraries/lambda/lib/getFunction.mli create mode 100644 libraries/lambda/lib/getFunctionConfiguration.ml create mode 100644 libraries/lambda/lib/getFunctionConfiguration.mli create mode 100644 libraries/lambda/lib/getPolicy.ml create mode 100644 libraries/lambda/lib/getPolicy.mli create mode 100644 libraries/lambda/lib/invoke.ml create mode 100644 libraries/lambda/lib/invoke.mli create mode 100644 libraries/lambda/lib/invokeAsync.ml create mode 100644 libraries/lambda/lib/invokeAsync.mli create mode 100644 libraries/lambda/lib/listEventSourceMappings.ml create mode 100644 libraries/lambda/lib/listEventSourceMappings.mli create mode 100644 libraries/lambda/lib/listFunctions.ml create mode 100644 libraries/lambda/lib/listFunctions.mli create mode 100644 libraries/lambda/lib/removePermission.ml create mode 100644 libraries/lambda/lib/removePermission.mli create mode 100644 libraries/lambda/lib/types.ml create mode 100644 libraries/lambda/lib/updateEventSourceMapping.ml create mode 100644 libraries/lambda/lib/updateEventSourceMapping.mli create mode 100644 libraries/lambda/lib/updateFunctionCode.ml create mode 100644 libraries/lambda/lib/updateFunctionCode.mli create mode 100644 libraries/lambda/lib/updateFunctionConfiguration.ml create mode 100644 libraries/lambda/lib/updateFunctionConfiguration.mli create mode 100644 libraries/lambda/lib_test/aws_lambda_test.ml create mode 100644 libraries/lambda/lib_test/dune create mode 100644 libraries/lambda/lib_test/test_async.ml create mode 100644 libraries/lambda/lib_test/test_lwt.ml diff --git a/libraries/lambda/lib/addPermission.ml b/libraries/lambda/lib/addPermission.ml new file mode 100644 index 000000000..06a01ba51 --- /dev/null +++ b/libraries/lambda/lib/addPermission.ml @@ -0,0 +1,58 @@ +open Types +open Aws +type input = AddPermissionRequest.t +type output = AddPermissionResponse.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); ("Action", ["AddPermission"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (AddPermissionRequest.to_query req))))) in + (`POST, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "AddPermissionResponse" (snd xml) in + try + Util.or_error (Util.option_bind resp AddPermissionResponse.parse) + (let open Error in + BadResponse + { + body; + message = "Could not find well formed AddPermissionResponse." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing AddPermissionResponse - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/addPermission.mli b/libraries/lambda/lib/addPermission.mli new file mode 100644 index 000000000..1a848de83 --- /dev/null +++ b/libraries/lambda/lib/addPermission.mli @@ -0,0 +1,7 @@ +open Types +type input = AddPermissionRequest.t +type output = AddPermissionResponse.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/createEventSourceMapping.ml b/libraries/lambda/lib/createEventSourceMapping.ml new file mode 100644 index 000000000..1695a7964 --- /dev/null +++ b/libraries/lambda/lib/createEventSourceMapping.ml @@ -0,0 +1,61 @@ +open Types +open Aws +type input = CreateEventSourceMappingRequest.t +type output = EventSourceMappingConfiguration.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); + ("Action", ["CreateEventSourceMapping"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (CreateEventSourceMappingRequest.to_query req))))) in + (`POST, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "CreateEventSourceMappingResponse" (snd xml) in + try + Util.or_error + (Util.option_bind resp EventSourceMappingConfiguration.parse) + (let open Error in + BadResponse + { + body; + message = + "Could not find well formed EventSourceMappingConfiguration." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing EventSourceMappingConfiguration - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/createEventSourceMapping.mli b/libraries/lambda/lib/createEventSourceMapping.mli new file mode 100644 index 000000000..b8612cea1 --- /dev/null +++ b/libraries/lambda/lib/createEventSourceMapping.mli @@ -0,0 +1,7 @@ +open Types +type input = CreateEventSourceMappingRequest.t +type output = EventSourceMappingConfiguration.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/createFunction.ml b/libraries/lambda/lib/createFunction.ml new file mode 100644 index 000000000..a86696616 --- /dev/null +++ b/libraries/lambda/lib/createFunction.ml @@ -0,0 +1,58 @@ +open Types +open Aws +type input = CreateFunctionRequest.t +type output = FunctionConfiguration.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); ("Action", ["CreateFunction"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (CreateFunctionRequest.to_query req))))) in + (`POST, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "CreateFunctionResponse" (snd xml) in + try + Util.or_error (Util.option_bind resp FunctionConfiguration.parse) + (let open Error in + BadResponse + { + body; + message = "Could not find well formed FunctionConfiguration." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing FunctionConfiguration - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/createFunction.mli b/libraries/lambda/lib/createFunction.mli new file mode 100644 index 000000000..fd7f9cd41 --- /dev/null +++ b/libraries/lambda/lib/createFunction.mli @@ -0,0 +1,7 @@ +open Types +type input = CreateFunctionRequest.t +type output = FunctionConfiguration.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/deleteEventSourceMapping.ml b/libraries/lambda/lib/deleteEventSourceMapping.ml new file mode 100644 index 000000000..c97880d9a --- /dev/null +++ b/libraries/lambda/lib/deleteEventSourceMapping.ml @@ -0,0 +1,61 @@ +open Types +open Aws +type input = DeleteEventSourceMappingRequest.t +type output = EventSourceMappingConfiguration.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); + ("Action", ["DeleteEventSourceMapping"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (DeleteEventSourceMappingRequest.to_query req))))) in + (`DELETE, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "DeleteEventSourceMappingResponse" (snd xml) in + try + Util.or_error + (Util.option_bind resp EventSourceMappingConfiguration.parse) + (let open Error in + BadResponse + { + body; + message = + "Could not find well formed EventSourceMappingConfiguration." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing EventSourceMappingConfiguration - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/deleteEventSourceMapping.mli b/libraries/lambda/lib/deleteEventSourceMapping.mli new file mode 100644 index 000000000..97d3299a7 --- /dev/null +++ b/libraries/lambda/lib/deleteEventSourceMapping.mli @@ -0,0 +1,7 @@ +open Types +type input = DeleteEventSourceMappingRequest.t +type output = EventSourceMappingConfiguration.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/deleteFunction.ml b/libraries/lambda/lib/deleteFunction.ml new file mode 100644 index 000000000..29fdbeb1f --- /dev/null +++ b/libraries/lambda/lib/deleteFunction.ml @@ -0,0 +1,31 @@ +open Types +open Aws +type input = DeleteFunctionRequest.t +type output = unit +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); ("Action", ["DeleteFunction"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (DeleteFunctionRequest.to_query req))))) in + (`DELETE, uri, []) +let of_http body = `Ok () +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/deleteFunction.mli b/libraries/lambda/lib/deleteFunction.mli new file mode 100644 index 000000000..b31e27f0b --- /dev/null +++ b/libraries/lambda/lib/deleteFunction.mli @@ -0,0 +1,7 @@ +open Types +type input = DeleteFunctionRequest.t +type output = unit +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/dune b/libraries/lambda/lib/dune new file mode 100644 index 000000000..64381a99f --- /dev/null +++ b/libraries/lambda/lib/dune @@ -0,0 +1,6 @@ +(library + (name aws_lambda) + (public_name aws-lambda) + (synopsis "aws-AWS Lambda") + (flags (:standard -w -27)) + (libraries aws)) diff --git a/libraries/lambda/lib/errors_internal.ml b/libraries/lambda/lib/errors_internal.ml new file mode 100644 index 000000000..ed215e93e --- /dev/null +++ b/libraries/lambda/lib/errors_internal.ml @@ -0,0 +1,183 @@ +type t = + | AuthFailure + | Blocked + | CodeStorageExceededException + | DryRunOperation + | IdempotentParameterMismatch + | IncompleteSignature + | InternalFailure + | InvalidAction + | InvalidClientTokenId + | InvalidParameter + | InvalidParameterCombination + | InvalidParameterValue + | InvalidParameterValueException + | InvalidQueryParameter + | InvalidRequestContentException + | MalformedQueryString + | MissingAction + | MissingAuthenticationToken + | MissingParameter + | OptInRequired + | PendingVerification + | PolicyLengthExceededException + | RequestExpired + | RequestLimitExceeded + | RequestTooLargeException + | ResourceConflictException + | ResourceNotFoundException + | ServiceException + | ServiceUnavailable + | Throttling + | TooManyRequestsException + | UnauthorizedOperation + | UnknownParameter + | UnsupportedMediaTypeException + | UnsupportedProtocol + | ValidationError + | Uninhabited +let common = + [UnsupportedProtocol; + UnknownParameter; + UnauthorizedOperation; + RequestLimitExceeded; + PendingVerification; + InvalidParameter; + IdempotentParameterMismatch; + DryRunOperation; + Blocked; + AuthFailure; + ValidationError; + Throttling; + ServiceUnavailable; + RequestExpired; + OptInRequired; + MissingParameter; + MissingAuthenticationToken; + MissingAction; + MalformedQueryString; + InvalidQueryParameter; + InvalidParameterValue; + InvalidParameterCombination; + InvalidClientTokenId; + InvalidAction; + InternalFailure; + IncompleteSignature] +let to_http_code e = + match e with + | AuthFailure -> None + | Blocked -> None + | CodeStorageExceededException -> Some 400 + | DryRunOperation -> None + | IdempotentParameterMismatch -> None + | IncompleteSignature -> Some 400 + | InternalFailure -> Some 500 + | InvalidAction -> Some 400 + | InvalidClientTokenId -> Some 403 + | InvalidParameter -> None + | InvalidParameterCombination -> Some 400 + | InvalidParameterValue -> Some 400 + | InvalidParameterValueException -> Some 400 + | InvalidQueryParameter -> Some 400 + | InvalidRequestContentException -> Some 400 + | MalformedQueryString -> Some 404 + | MissingAction -> Some 400 + | MissingAuthenticationToken -> Some 403 + | MissingParameter -> Some 400 + | OptInRequired -> Some 403 + | PendingVerification -> None + | PolicyLengthExceededException -> Some 400 + | RequestExpired -> Some 400 + | RequestLimitExceeded -> None + | RequestTooLargeException -> Some 413 + | ResourceConflictException -> Some 409 + | ResourceNotFoundException -> Some 404 + | ServiceException -> Some 500 + | ServiceUnavailable -> Some 503 + | Throttling -> Some 400 + | TooManyRequestsException -> Some 429 + | UnauthorizedOperation -> None + | UnknownParameter -> None + | UnsupportedMediaTypeException -> Some 415 + | UnsupportedProtocol -> None + | ValidationError -> Some 400 + | Uninhabited -> None +let to_string e = + match e with + | AuthFailure -> "AuthFailure" + | Blocked -> "Blocked" + | CodeStorageExceededException -> "CodeStorageExceededException" + | DryRunOperation -> "DryRunOperation" + | IdempotentParameterMismatch -> "IdempotentParameterMismatch" + | IncompleteSignature -> "IncompleteSignature" + | InternalFailure -> "InternalFailure" + | InvalidAction -> "InvalidAction" + | InvalidClientTokenId -> "InvalidClientTokenId" + | InvalidParameter -> "InvalidParameter" + | InvalidParameterCombination -> "InvalidParameterCombination" + | InvalidParameterValue -> "InvalidParameterValue" + | InvalidParameterValueException -> "InvalidParameterValueException" + | InvalidQueryParameter -> "InvalidQueryParameter" + | InvalidRequestContentException -> "InvalidRequestContentException" + | MalformedQueryString -> "MalformedQueryString" + | MissingAction -> "MissingAction" + | MissingAuthenticationToken -> "MissingAuthenticationToken" + | MissingParameter -> "MissingParameter" + | OptInRequired -> "OptInRequired" + | PendingVerification -> "PendingVerification" + | PolicyLengthExceededException -> "PolicyLengthExceededException" + | RequestExpired -> "RequestExpired" + | RequestLimitExceeded -> "RequestLimitExceeded" + | RequestTooLargeException -> "RequestTooLargeException" + | ResourceConflictException -> "ResourceConflictException" + | ResourceNotFoundException -> "ResourceNotFoundException" + | ServiceException -> "ServiceException" + | ServiceUnavailable -> "ServiceUnavailable" + | Throttling -> "Throttling" + | TooManyRequestsException -> "TooManyRequestsException" + | UnauthorizedOperation -> "UnauthorizedOperation" + | UnknownParameter -> "UnknownParameter" + | UnsupportedMediaTypeException -> "UnsupportedMediaTypeException" + | UnsupportedProtocol -> "UnsupportedProtocol" + | ValidationError -> "ValidationError" + | Uninhabited -> "Uninhabited" +let of_string e = + match e with + | "AuthFailure" -> Some AuthFailure + | "Blocked" -> Some Blocked + | "CodeStorageExceededException" -> Some CodeStorageExceededException + | "DryRunOperation" -> Some DryRunOperation + | "IdempotentParameterMismatch" -> Some IdempotentParameterMismatch + | "IncompleteSignature" -> Some IncompleteSignature + | "InternalFailure" -> Some InternalFailure + | "InvalidAction" -> Some InvalidAction + | "InvalidClientTokenId" -> Some InvalidClientTokenId + | "InvalidParameter" -> Some InvalidParameter + | "InvalidParameterCombination" -> Some InvalidParameterCombination + | "InvalidParameterValue" -> Some InvalidParameterValue + | "InvalidParameterValueException" -> Some InvalidParameterValueException + | "InvalidQueryParameter" -> Some InvalidQueryParameter + | "InvalidRequestContentException" -> Some InvalidRequestContentException + | "MalformedQueryString" -> Some MalformedQueryString + | "MissingAction" -> Some MissingAction + | "MissingAuthenticationToken" -> Some MissingAuthenticationToken + | "MissingParameter" -> Some MissingParameter + | "OptInRequired" -> Some OptInRequired + | "PendingVerification" -> Some PendingVerification + | "PolicyLengthExceededException" -> Some PolicyLengthExceededException + | "RequestExpired" -> Some RequestExpired + | "RequestLimitExceeded" -> Some RequestLimitExceeded + | "RequestTooLargeException" -> Some RequestTooLargeException + | "ResourceConflictException" -> Some ResourceConflictException + | "ResourceNotFoundException" -> Some ResourceNotFoundException + | "ServiceException" -> Some ServiceException + | "ServiceUnavailable" -> Some ServiceUnavailable + | "Throttling" -> Some Throttling + | "TooManyRequestsException" -> Some TooManyRequestsException + | "UnauthorizedOperation" -> Some UnauthorizedOperation + | "UnknownParameter" -> Some UnknownParameter + | "UnsupportedMediaTypeException" -> Some UnsupportedMediaTypeException + | "UnsupportedProtocol" -> Some UnsupportedProtocol + | "ValidationError" -> Some ValidationError + | "Uninhabited" -> Some Uninhabited + | _ -> None \ No newline at end of file diff --git a/libraries/lambda/lib/getEventSourceMapping.ml b/libraries/lambda/lib/getEventSourceMapping.ml new file mode 100644 index 000000000..18dca5ae8 --- /dev/null +++ b/libraries/lambda/lib/getEventSourceMapping.ml @@ -0,0 +1,60 @@ +open Types +open Aws +type input = GetEventSourceMappingRequest.t +type output = EventSourceMappingConfiguration.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); ("Action", ["GetEventSourceMapping"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (GetEventSourceMappingRequest.to_query req))))) in + (`GET, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "GetEventSourceMappingResponse" (snd xml) in + try + Util.or_error + (Util.option_bind resp EventSourceMappingConfiguration.parse) + (let open Error in + BadResponse + { + body; + message = + "Could not find well formed EventSourceMappingConfiguration." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing EventSourceMappingConfiguration - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/getEventSourceMapping.mli b/libraries/lambda/lib/getEventSourceMapping.mli new file mode 100644 index 000000000..b73e37c39 --- /dev/null +++ b/libraries/lambda/lib/getEventSourceMapping.mli @@ -0,0 +1,7 @@ +open Types +type input = GetEventSourceMappingRequest.t +type output = EventSourceMappingConfiguration.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/getFunction.ml b/libraries/lambda/lib/getFunction.ml new file mode 100644 index 000000000..412f70186 --- /dev/null +++ b/libraries/lambda/lib/getFunction.ml @@ -0,0 +1,57 @@ +open Types +open Aws +type input = GetFunctionRequest.t +type output = GetFunctionResponse.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append [("Version", ["2015-03-31"]); ("Action", ["GetFunction"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (GetFunctionRequest.to_query req))))) in + (`GET, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "GetFunctionResponse" (snd xml) in + try + Util.or_error (Util.option_bind resp GetFunctionResponse.parse) + (let open Error in + BadResponse + { + body; + message = "Could not find well formed GetFunctionResponse." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing GetFunctionResponse - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/getFunction.mli b/libraries/lambda/lib/getFunction.mli new file mode 100644 index 000000000..3ace1354f --- /dev/null +++ b/libraries/lambda/lib/getFunction.mli @@ -0,0 +1,7 @@ +open Types +type input = GetFunctionRequest.t +type output = GetFunctionResponse.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/getFunctionConfiguration.ml b/libraries/lambda/lib/getFunctionConfiguration.ml new file mode 100644 index 000000000..62ce319ab --- /dev/null +++ b/libraries/lambda/lib/getFunctionConfiguration.ml @@ -0,0 +1,59 @@ +open Types +open Aws +type input = GetFunctionConfigurationRequest.t +type output = FunctionConfiguration.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); + ("Action", ["GetFunctionConfiguration"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (GetFunctionConfigurationRequest.to_query req))))) in + (`GET, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "GetFunctionConfigurationResponse" (snd xml) in + try + Util.or_error (Util.option_bind resp FunctionConfiguration.parse) + (let open Error in + BadResponse + { + body; + message = "Could not find well formed FunctionConfiguration." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing FunctionConfiguration - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/getFunctionConfiguration.mli b/libraries/lambda/lib/getFunctionConfiguration.mli new file mode 100644 index 000000000..cf33b94e6 --- /dev/null +++ b/libraries/lambda/lib/getFunctionConfiguration.mli @@ -0,0 +1,7 @@ +open Types +type input = GetFunctionConfigurationRequest.t +type output = FunctionConfiguration.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/getPolicy.ml b/libraries/lambda/lib/getPolicy.ml new file mode 100644 index 000000000..08184c048 --- /dev/null +++ b/libraries/lambda/lib/getPolicy.ml @@ -0,0 +1,57 @@ +open Types +open Aws +type input = GetPolicyRequest.t +type output = GetPolicyResponse.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append [("Version", ["2015-03-31"]); ("Action", ["GetPolicy"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (GetPolicyRequest.to_query req))))) in + (`GET, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "GetPolicyResponse" (snd xml) in + try + Util.or_error (Util.option_bind resp GetPolicyResponse.parse) + (let open Error in + BadResponse + { + body; + message = "Could not find well formed GetPolicyResponse." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing GetPolicyResponse - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/getPolicy.mli b/libraries/lambda/lib/getPolicy.mli new file mode 100644 index 000000000..8d1d5c2fc --- /dev/null +++ b/libraries/lambda/lib/getPolicy.mli @@ -0,0 +1,7 @@ +open Types +type input = GetPolicyRequest.t +type output = GetPolicyResponse.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/invoke.ml b/libraries/lambda/lib/invoke.ml new file mode 100644 index 000000000..8bb12a486 --- /dev/null +++ b/libraries/lambda/lib/invoke.ml @@ -0,0 +1,57 @@ +open Types +open Aws +type input = InvocationRequest.t +type output = InvocationResponse.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append [("Version", ["2015-03-31"]); ("Action", ["Invoke"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (InvocationRequest.to_query req))))) in + (`POST, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "InvokeResponse" (snd xml) in + try + Util.or_error (Util.option_bind resp InvocationResponse.parse) + (let open Error in + BadResponse + { + body; + message = "Could not find well formed InvocationResponse." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing InvocationResponse - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/invoke.mli b/libraries/lambda/lib/invoke.mli new file mode 100644 index 000000000..254df5486 --- /dev/null +++ b/libraries/lambda/lib/invoke.mli @@ -0,0 +1,7 @@ +open Types +type input = InvocationRequest.t +type output = InvocationResponse.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/invokeAsync.ml b/libraries/lambda/lib/invokeAsync.ml new file mode 100644 index 000000000..9b00ed485 --- /dev/null +++ b/libraries/lambda/lib/invokeAsync.ml @@ -0,0 +1,57 @@ +open Types +open Aws +type input = InvokeAsyncRequest.t +type output = InvokeAsyncResponse.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append [("Version", ["2015-03-31"]); ("Action", ["InvokeAsync"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (InvokeAsyncRequest.to_query req))))) in + (`POST, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "InvokeAsyncResponse" (snd xml) in + try + Util.or_error (Util.option_bind resp InvokeAsyncResponse.parse) + (let open Error in + BadResponse + { + body; + message = "Could not find well formed InvokeAsyncResponse." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing InvokeAsyncResponse - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/invokeAsync.mli b/libraries/lambda/lib/invokeAsync.mli new file mode 100644 index 000000000..81fe2833e --- /dev/null +++ b/libraries/lambda/lib/invokeAsync.mli @@ -0,0 +1,7 @@ +open Types +type input = InvokeAsyncRequest.t +type output = InvokeAsyncResponse.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/listEventSourceMappings.ml b/libraries/lambda/lib/listEventSourceMappings.ml new file mode 100644 index 000000000..2598ee1af --- /dev/null +++ b/libraries/lambda/lib/listEventSourceMappings.ml @@ -0,0 +1,61 @@ +open Types +open Aws +type input = ListEventSourceMappingsRequest.t +type output = ListEventSourceMappingsResponse.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); + ("Action", ["ListEventSourceMappings"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (ListEventSourceMappingsRequest.to_query req))))) in + (`GET, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "ListEventSourceMappingsResponse" (snd xml) in + try + Util.or_error + (Util.option_bind resp ListEventSourceMappingsResponse.parse) + (let open Error in + BadResponse + { + body; + message = + "Could not find well formed ListEventSourceMappingsResponse." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing ListEventSourceMappingsResponse - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/listEventSourceMappings.mli b/libraries/lambda/lib/listEventSourceMappings.mli new file mode 100644 index 000000000..ce9dfd0f1 --- /dev/null +++ b/libraries/lambda/lib/listEventSourceMappings.mli @@ -0,0 +1,7 @@ +open Types +type input = ListEventSourceMappingsRequest.t +type output = ListEventSourceMappingsResponse.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/listFunctions.ml b/libraries/lambda/lib/listFunctions.ml new file mode 100644 index 000000000..49664554b --- /dev/null +++ b/libraries/lambda/lib/listFunctions.ml @@ -0,0 +1,58 @@ +open Types +open Aws +type input = ListFunctionsRequest.t +type output = ListFunctionsResponse.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); ("Action", ["ListFunctions"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (ListFunctionsRequest.to_query req))))) in + (`GET, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "ListFunctionsResponse" (snd xml) in + try + Util.or_error (Util.option_bind resp ListFunctionsResponse.parse) + (let open Error in + BadResponse + { + body; + message = "Could not find well formed ListFunctionsResponse." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing ListFunctionsResponse - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/listFunctions.mli b/libraries/lambda/lib/listFunctions.mli new file mode 100644 index 000000000..758226c4a --- /dev/null +++ b/libraries/lambda/lib/listFunctions.mli @@ -0,0 +1,7 @@ +open Types +type input = ListFunctionsRequest.t +type output = ListFunctionsResponse.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/removePermission.ml b/libraries/lambda/lib/removePermission.ml new file mode 100644 index 000000000..f7ed2fc1b --- /dev/null +++ b/libraries/lambda/lib/removePermission.ml @@ -0,0 +1,31 @@ +open Types +open Aws +type input = RemovePermissionRequest.t +type output = unit +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); ("Action", ["RemovePermission"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (RemovePermissionRequest.to_query req))))) in + (`DELETE, uri, []) +let of_http body = `Ok () +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/removePermission.mli b/libraries/lambda/lib/removePermission.mli new file mode 100644 index 000000000..acd610d93 --- /dev/null +++ b/libraries/lambda/lib/removePermission.mli @@ -0,0 +1,7 @@ +open Types +type input = RemovePermissionRequest.t +type output = unit +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/types.ml b/libraries/lambda/lib/types.ml new file mode 100644 index 000000000..01e03cb70 --- /dev/null +++ b/libraries/lambda/lib/types.ml @@ -0,0 +1,1853 @@ +open Aws +open Aws.BaseTypes +open CalendarLib +type calendar = Calendar.t +module Runtime = + struct + type t = + | Nodejs + | Java8 + let str_to_t = [("java8", Java8); ("nodejs", Nodejs)] + let t_to_str = [(Java8, "java8"); (Nodejs, "nodejs")] + let to_string e = Util.of_option_exn (Util.list_find t_to_str e) + let of_string s = Util.of_option_exn (Util.list_find str_to_t s) + let make v () = v + let parse xml = + Util.option_bind (String.parse xml) + (fun s -> Util.list_find str_to_t s) + let to_query v = + Query.Value (Some (Util.of_option_exn (Util.list_find t_to_str v))) + let to_json v = + String.to_json (Util.of_option_exn (Util.list_find t_to_str v)) + let of_json j = + Util.of_option_exn (Util.list_find str_to_t (String.of_json j)) + end +module FunctionConfiguration = + struct + type t = + { + function_name: String.t option ; + function_arn: String.t option ; + runtime: Runtime.t option ; + role: String.t option ; + handler: String.t option ; + code_size: Long.t option ; + description: String.t option ; + timeout: Integer.t option ; + memory_size: Integer.t option ; + last_modified: String.t option } + let make ?function_name ?function_arn ?runtime ?role ?handler + ?code_size ?description ?timeout ?memory_size ?last_modified () = + { + function_name; + function_arn; + runtime; + role; + handler; + code_size; + description; + timeout; + memory_size; + last_modified + } + let parse xml = + Some + { + function_name = + (Util.option_bind (Xml.member "FunctionName" xml) String.parse); + function_arn = + (Util.option_bind (Xml.member "FunctionArn" xml) String.parse); + runtime = + (Util.option_bind (Xml.member "Runtime" xml) Runtime.parse); + role = (Util.option_bind (Xml.member "Role" xml) String.parse); + handler = + (Util.option_bind (Xml.member "Handler" xml) String.parse); + code_size = + (Util.option_bind (Xml.member "CodeSize" xml) Long.parse); + description = + (Util.option_bind (Xml.member "Description" xml) String.parse); + timeout = + (Util.option_bind (Xml.member "Timeout" xml) Integer.parse); + memory_size = + (Util.option_bind (Xml.member "MemorySize" xml) Integer.parse); + last_modified = + (Util.option_bind (Xml.member "LastModified" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.last_modified + (fun f -> Query.Pair ("LastModified", (String.to_query f))); + Util.option_map v.memory_size + (fun f -> Query.Pair ("MemorySize", (Integer.to_query f))); + Util.option_map v.timeout + (fun f -> Query.Pair ("Timeout", (Integer.to_query f))); + Util.option_map v.description + (fun f -> Query.Pair ("Description", (String.to_query f))); + Util.option_map v.code_size + (fun f -> Query.Pair ("CodeSize", (Long.to_query f))); + Util.option_map v.handler + (fun f -> Query.Pair ("Handler", (String.to_query f))); + Util.option_map v.role + (fun f -> Query.Pair ("Role", (String.to_query f))); + Util.option_map v.runtime + (fun f -> Query.Pair ("Runtime", (Runtime.to_query f))); + Util.option_map v.function_arn + (fun f -> Query.Pair ("FunctionArn", (String.to_query f))); + Util.option_map v.function_name + (fun f -> Query.Pair ("FunctionName", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.last_modified + (fun f -> ("last_modified", (String.to_json f))); + Util.option_map v.memory_size + (fun f -> ("memory_size", (Integer.to_json f))); + Util.option_map v.timeout + (fun f -> ("timeout", (Integer.to_json f))); + Util.option_map v.description + (fun f -> ("description", (String.to_json f))); + Util.option_map v.code_size + (fun f -> ("code_size", (Long.to_json f))); + Util.option_map v.handler + (fun f -> ("handler", (String.to_json f))); + Util.option_map v.role (fun f -> ("role", (String.to_json f))); + Util.option_map v.runtime + (fun f -> ("runtime", (Runtime.to_json f))); + Util.option_map v.function_arn + (fun f -> ("function_arn", (String.to_json f))); + Util.option_map v.function_name + (fun f -> ("function_name", (String.to_json f)))]) + let of_json j = + { + function_name = + (Util.option_map (Json.lookup j "function_name") String.of_json); + function_arn = + (Util.option_map (Json.lookup j "function_arn") String.of_json); + runtime = (Util.option_map (Json.lookup j "runtime") Runtime.of_json); + role = (Util.option_map (Json.lookup j "role") String.of_json); + handler = (Util.option_map (Json.lookup j "handler") String.of_json); + code_size = + (Util.option_map (Json.lookup j "code_size") Long.of_json); + description = + (Util.option_map (Json.lookup j "description") String.of_json); + timeout = (Util.option_map (Json.lookup j "timeout") Integer.of_json); + memory_size = + (Util.option_map (Json.lookup j "memory_size") Integer.of_json); + last_modified = + (Util.option_map (Json.lookup j "last_modified") String.of_json) + } + end +module EventSourceMappingConfiguration = + struct + type t = + { + u_u_i_d: String.t option ; + batch_size: Integer.t option ; + event_source_arn: String.t option ; + function_arn: String.t option ; + last_modified: DateTime.t option ; + last_processing_result: String.t option ; + state: String.t option ; + state_transition_reason: String.t option } + let make ?u_u_i_d ?batch_size ?event_source_arn ?function_arn + ?last_modified ?last_processing_result ?state + ?state_transition_reason () = + { + u_u_i_d; + batch_size; + event_source_arn; + function_arn; + last_modified; + last_processing_result; + state; + state_transition_reason + } + let parse xml = + Some + { + u_u_i_d = (Util.option_bind (Xml.member "UUID" xml) String.parse); + batch_size = + (Util.option_bind (Xml.member "BatchSize" xml) Integer.parse); + event_source_arn = + (Util.option_bind (Xml.member "EventSourceArn" xml) String.parse); + function_arn = + (Util.option_bind (Xml.member "FunctionArn" xml) String.parse); + last_modified = + (Util.option_bind (Xml.member "LastModified" xml) DateTime.parse); + last_processing_result = + (Util.option_bind (Xml.member "LastProcessingResult" xml) + String.parse); + state = (Util.option_bind (Xml.member "State" xml) String.parse); + state_transition_reason = + (Util.option_bind (Xml.member "StateTransitionReason" xml) + String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.state_transition_reason + (fun f -> + Query.Pair ("StateTransitionReason", (String.to_query f))); + Util.option_map v.state + (fun f -> Query.Pair ("State", (String.to_query f))); + Util.option_map v.last_processing_result + (fun f -> + Query.Pair ("LastProcessingResult", (String.to_query f))); + Util.option_map v.last_modified + (fun f -> Query.Pair ("LastModified", (DateTime.to_query f))); + Util.option_map v.function_arn + (fun f -> Query.Pair ("FunctionArn", (String.to_query f))); + Util.option_map v.event_source_arn + (fun f -> Query.Pair ("EventSourceArn", (String.to_query f))); + Util.option_map v.batch_size + (fun f -> Query.Pair ("BatchSize", (Integer.to_query f))); + Util.option_map v.u_u_i_d + (fun f -> Query.Pair ("UUID", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.state_transition_reason + (fun f -> ("state_transition_reason", (String.to_json f))); + Util.option_map v.state (fun f -> ("state", (String.to_json f))); + Util.option_map v.last_processing_result + (fun f -> ("last_processing_result", (String.to_json f))); + Util.option_map v.last_modified + (fun f -> ("last_modified", (DateTime.to_json f))); + Util.option_map v.function_arn + (fun f -> ("function_arn", (String.to_json f))); + Util.option_map v.event_source_arn + (fun f -> ("event_source_arn", (String.to_json f))); + Util.option_map v.batch_size + (fun f -> ("batch_size", (Integer.to_json f))); + Util.option_map v.u_u_i_d + (fun f -> ("u_u_i_d", (String.to_json f)))]) + let of_json j = + { + u_u_i_d = (Util.option_map (Json.lookup j "u_u_i_d") String.of_json); + batch_size = + (Util.option_map (Json.lookup j "batch_size") Integer.of_json); + event_source_arn = + (Util.option_map (Json.lookup j "event_source_arn") String.of_json); + function_arn = + (Util.option_map (Json.lookup j "function_arn") String.of_json); + last_modified = + (Util.option_map (Json.lookup j "last_modified") DateTime.of_json); + last_processing_result = + (Util.option_map (Json.lookup j "last_processing_result") + String.of_json); + state = (Util.option_map (Json.lookup j "state") String.of_json); + state_transition_reason = + (Util.option_map (Json.lookup j "state_transition_reason") + String.of_json) + } + end +module EventSourcePosition = + struct + type t = + | TRIM_HORIZON + | LATEST + let str_to_t = [("LATEST", LATEST); ("TRIM_HORIZON", TRIM_HORIZON)] + let t_to_str = [(LATEST, "LATEST"); (TRIM_HORIZON, "TRIM_HORIZON")] + let to_string e = Util.of_option_exn (Util.list_find t_to_str e) + let of_string s = Util.of_option_exn (Util.list_find str_to_t s) + let make v () = v + let parse xml = + Util.option_bind (String.parse xml) + (fun s -> Util.list_find str_to_t s) + let to_query v = + Query.Value (Some (Util.of_option_exn (Util.list_find t_to_str v))) + let to_json v = + String.to_json (Util.of_option_exn (Util.list_find t_to_str v)) + let of_json j = + Util.of_option_exn (Util.list_find str_to_t (String.of_json j)) + end +module FunctionCodeLocation = + struct + type t = { + repository_type: String.t option ; + location: String.t option } + let make ?repository_type ?location () = { repository_type; location } + let parse xml = + Some + { + repository_type = + (Util.option_bind (Xml.member "RepositoryType" xml) String.parse); + location = + (Util.option_bind (Xml.member "Location" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.location + (fun f -> Query.Pair ("Location", (String.to_query f))); + Util.option_map v.repository_type + (fun f -> Query.Pair ("RepositoryType", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.location + (fun f -> ("location", (String.to_json f))); + Util.option_map v.repository_type + (fun f -> ("repository_type", (String.to_json f)))]) + let of_json j = + { + repository_type = + (Util.option_map (Json.lookup j "repository_type") String.of_json); + location = + (Util.option_map (Json.lookup j "location") String.of_json) + } + end +module FunctionList = + struct + type t = FunctionConfiguration.t list + let make elems () = elems + let parse xml = + Util.option_all + (List.map FunctionConfiguration.parse (Xml.members "member" xml)) + let to_query v = Query.to_query_list FunctionConfiguration.to_query v + let to_json v = `List (List.map FunctionConfiguration.to_json v) + let of_json j = Json.to_list FunctionConfiguration.of_json j + end +module EventSourceMappingsList = + struct + type t = EventSourceMappingConfiguration.t list + let make elems () = elems + let parse xml = + Util.option_all + (List.map EventSourceMappingConfiguration.parse + (Xml.members "member" xml)) + let to_query v = + Query.to_query_list EventSourceMappingConfiguration.to_query v + let to_json v = + `List (List.map EventSourceMappingConfiguration.to_json v) + let of_json j = Json.to_list EventSourceMappingConfiguration.of_json j + end +module InvocationType = + struct + type t = + | Event + | RequestResponse + | DryRun + let str_to_t = + [("DryRun", DryRun); + ("RequestResponse", RequestResponse); + ("Event", Event)] + let t_to_str = + [(DryRun, "DryRun"); + (RequestResponse, "RequestResponse"); + (Event, "Event")] + let to_string e = Util.of_option_exn (Util.list_find t_to_str e) + let of_string s = Util.of_option_exn (Util.list_find str_to_t s) + let make v () = v + let parse xml = + Util.option_bind (String.parse xml) + (fun s -> Util.list_find str_to_t s) + let to_query v = + Query.Value (Some (Util.of_option_exn (Util.list_find t_to_str v))) + let to_json v = + String.to_json (Util.of_option_exn (Util.list_find t_to_str v)) + let of_json j = + Util.of_option_exn (Util.list_find str_to_t (String.of_json j)) + end +module LogType = + struct + type t = + | None + | Tail + let str_to_t = [("Tail", Tail); ("None", None)] + let t_to_str = [(Tail, "Tail"); (None, "None")] + let to_string e = Util.of_option_exn (Util.list_find t_to_str e) + let of_string s = Util.of_option_exn (Util.list_find str_to_t s) + let make v () = v + let parse xml = + Util.option_bind (String.parse xml) + (fun s -> Util.list_find str_to_t s) + let to_query v = + Query.Value (Some (Util.of_option_exn (Util.list_find t_to_str v))) + let to_json v = + String.to_json (Util.of_option_exn (Util.list_find t_to_str v)) + let of_json j = + Util.of_option_exn (Util.list_find str_to_t (String.of_json j)) + end +module FunctionCode = + struct + type t = + { + zip_file: Blob.t option ; + s3_bucket: String.t option ; + s3_key: String.t option ; + s3_object_version: String.t option } + let make ?zip_file ?s3_bucket ?s3_key ?s3_object_version () = + { zip_file; s3_bucket; s3_key; s3_object_version } + let parse xml = + Some + { + zip_file = (Util.option_bind (Xml.member "ZipFile" xml) Blob.parse); + s3_bucket = + (Util.option_bind (Xml.member "S3Bucket" xml) String.parse); + s3_key = (Util.option_bind (Xml.member "S3Key" xml) String.parse); + s3_object_version = + (Util.option_bind (Xml.member "S3ObjectVersion" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.s3_object_version + (fun f -> Query.Pair ("S3ObjectVersion", (String.to_query f))); + Util.option_map v.s3_key + (fun f -> Query.Pair ("S3Key", (String.to_query f))); + Util.option_map v.s3_bucket + (fun f -> Query.Pair ("S3Bucket", (String.to_query f))); + Util.option_map v.zip_file + (fun f -> Query.Pair ("ZipFile", (Blob.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.s3_object_version + (fun f -> ("s3_object_version", (String.to_json f))); + Util.option_map v.s3_key (fun f -> ("s3_key", (String.to_json f))); + Util.option_map v.s3_bucket + (fun f -> ("s3_bucket", (String.to_json f))); + Util.option_map v.zip_file + (fun f -> ("zip_file", (Blob.to_json f)))]) + let of_json j = + { + zip_file = (Util.option_map (Json.lookup j "zip_file") Blob.of_json); + s3_bucket = + (Util.option_map (Json.lookup j "s3_bucket") String.of_json); + s3_key = (Util.option_map (Json.lookup j "s3_key") String.of_json); + s3_object_version = + (Util.option_map (Json.lookup j "s3_object_version") String.of_json) + } + end +module GetFunctionRequest = + struct + type t = { + function_name: String.t } + let make ~function_name () = { function_name } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))) + } + end +module InvalidRequestContentException = + struct + type t = { + type_: String.t option ; + message: String.t option } + let make ?type_ ?message () = { type_; message } + let parse xml = + Some + { + type_ = (Util.option_bind (Xml.member "Type" xml) String.parse); + message = + (Util.option_bind (Xml.member "message" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> Query.Pair ("message", (String.to_query f))); + Util.option_map v.type_ + (fun f -> Query.Pair ("Type", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> ("message", (String.to_json f))); + Util.option_map v.type_ (fun f -> ("type_", (String.to_json f)))]) + let of_json j = + { + type_ = (Util.option_map (Json.lookup j "type_") String.of_json); + message = (Util.option_map (Json.lookup j "message") String.of_json) + } + end +module ListEventSourceMappingsRequest = + struct + type t = + { + event_source_arn: String.t option ; + function_name: String.t option ; + marker: String.t option ; + max_items: Integer.t option } + let make ?event_source_arn ?function_name ?marker ?max_items () = + { event_source_arn; function_name; marker; max_items } + let parse xml = + Some + { + event_source_arn = + (Util.option_bind (Xml.member "EventSourceArn" xml) String.parse); + function_name = + (Util.option_bind (Xml.member "FunctionName" xml) String.parse); + marker = (Util.option_bind (Xml.member "Marker" xml) String.parse); + max_items = + (Util.option_bind (Xml.member "MaxItems" xml) Integer.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.max_items + (fun f -> Query.Pair ("MaxItems", (Integer.to_query f))); + Util.option_map v.marker + (fun f -> Query.Pair ("Marker", (String.to_query f))); + Util.option_map v.function_name + (fun f -> Query.Pair ("FunctionName", (String.to_query f))); + Util.option_map v.event_source_arn + (fun f -> Query.Pair ("EventSourceArn", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.max_items + (fun f -> ("max_items", (Integer.to_json f))); + Util.option_map v.marker (fun f -> ("marker", (String.to_json f))); + Util.option_map v.function_name + (fun f -> ("function_name", (String.to_json f))); + Util.option_map v.event_source_arn + (fun f -> ("event_source_arn", (String.to_json f)))]) + let of_json j = + { + event_source_arn = + (Util.option_map (Json.lookup j "event_source_arn") String.of_json); + function_name = + (Util.option_map (Json.lookup j "function_name") String.of_json); + marker = (Util.option_map (Json.lookup j "marker") String.of_json); + max_items = + (Util.option_map (Json.lookup j "max_items") Integer.of_json) + } + end +module AddPermissionResponse = + struct + type t = { + statement: String.t option } + let make ?statement () = { statement } + let parse xml = + Some + { + statement = + (Util.option_bind (Xml.member "Statement" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.statement + (fun f -> Query.Pair ("Statement", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.statement + (fun f -> ("statement", (String.to_json f)))]) + let of_json j = + { + statement = + (Util.option_map (Json.lookup j "statement") String.of_json) + } + end +module CodeStorageExceededException = + struct + type t = { + type_: String.t option ; + message: String.t option } + let make ?type_ ?message () = { type_; message } + let parse xml = + Some + { + type_ = (Util.option_bind (Xml.member "Type" xml) String.parse); + message = + (Util.option_bind (Xml.member "message" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> Query.Pair ("message", (String.to_query f))); + Util.option_map v.type_ + (fun f -> Query.Pair ("Type", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> ("message", (String.to_json f))); + Util.option_map v.type_ (fun f -> ("type_", (String.to_json f)))]) + let of_json j = + { + type_ = (Util.option_map (Json.lookup j "type_") String.of_json); + message = (Util.option_map (Json.lookup j "message") String.of_json) + } + end +module UpdateEventSourceMappingRequest = + struct + type t = + { + u_u_i_d: String.t ; + function_name: String.t option ; + enabled: Boolean.t option ; + batch_size: Integer.t option } + let make ~u_u_i_d ?function_name ?enabled ?batch_size () = + { u_u_i_d; function_name; enabled; batch_size } + let parse xml = + Some + { + u_u_i_d = + (Xml.required "UUID" + (Util.option_bind (Xml.member "UUID" xml) String.parse)); + function_name = + (Util.option_bind (Xml.member "FunctionName" xml) String.parse); + enabled = + (Util.option_bind (Xml.member "Enabled" xml) Boolean.parse); + batch_size = + (Util.option_bind (Xml.member "BatchSize" xml) Integer.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.batch_size + (fun f -> Query.Pair ("BatchSize", (Integer.to_query f))); + Util.option_map v.enabled + (fun f -> Query.Pair ("Enabled", (Boolean.to_query f))); + Util.option_map v.function_name + (fun f -> Query.Pair ("FunctionName", (String.to_query f))); + Some (Query.Pair ("UUID", (String.to_query v.u_u_i_d)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.batch_size + (fun f -> ("batch_size", (Integer.to_json f))); + Util.option_map v.enabled + (fun f -> ("enabled", (Boolean.to_json f))); + Util.option_map v.function_name + (fun f -> ("function_name", (String.to_json f))); + Some ("u_u_i_d", (String.to_json v.u_u_i_d))]) + let of_json j = + { + u_u_i_d = + (String.of_json (Util.of_option_exn (Json.lookup j "u_u_i_d"))); + function_name = + (Util.option_map (Json.lookup j "function_name") String.of_json); + enabled = (Util.option_map (Json.lookup j "enabled") Boolean.of_json); + batch_size = + (Util.option_map (Json.lookup j "batch_size") Integer.of_json) + } + end +module InvokeAsyncResponse = + struct + type t = { + status: Integer.t } + let make ~status () = { status } + let parse xml = + Some + { + status = + (Xml.required "Status" + (Util.option_bind (Xml.member "Status" xml) Integer.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some (Query.Pair ("Status", (Integer.to_query v.status)))]) + let to_json v = + `Assoc + (Util.list_filter_opt [Some ("status", (Integer.to_json v.status))]) + let of_json j = + { + status = + (Integer.of_json (Util.of_option_exn (Json.lookup j "status"))) + } + end +module ResourceConflictException = + struct + type t = { + type_: String.t option ; + message: String.t option } + let make ?type_ ?message () = { type_; message } + let parse xml = + Some + { + type_ = (Util.option_bind (Xml.member "Type" xml) String.parse); + message = + (Util.option_bind (Xml.member "message" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> Query.Pair ("message", (String.to_query f))); + Util.option_map v.type_ + (fun f -> Query.Pair ("Type", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> ("message", (String.to_json f))); + Util.option_map v.type_ (fun f -> ("type_", (String.to_json f)))]) + let of_json j = + { + type_ = (Util.option_map (Json.lookup j "type_") String.of_json); + message = (Util.option_map (Json.lookup j "message") String.of_json) + } + end +module UpdateFunctionCodeRequest = + struct + type t = + { + function_name: String.t ; + zip_file: Blob.t option ; + s3_bucket: String.t option ; + s3_key: String.t option ; + s3_object_version: String.t option } + let make ~function_name ?zip_file ?s3_bucket ?s3_key + ?s3_object_version () = + { function_name; zip_file; s3_bucket; s3_key; s3_object_version } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)); + zip_file = (Util.option_bind (Xml.member "ZipFile" xml) Blob.parse); + s3_bucket = + (Util.option_bind (Xml.member "S3Bucket" xml) String.parse); + s3_key = (Util.option_bind (Xml.member "S3Key" xml) String.parse); + s3_object_version = + (Util.option_bind (Xml.member "S3ObjectVersion" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.s3_object_version + (fun f -> Query.Pair ("S3ObjectVersion", (String.to_query f))); + Util.option_map v.s3_key + (fun f -> Query.Pair ("S3Key", (String.to_query f))); + Util.option_map v.s3_bucket + (fun f -> Query.Pair ("S3Bucket", (String.to_query f))); + Util.option_map v.zip_file + (fun f -> Query.Pair ("ZipFile", (Blob.to_query f))); + Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.s3_object_version + (fun f -> ("s3_object_version", (String.to_json f))); + Util.option_map v.s3_key (fun f -> ("s3_key", (String.to_json f))); + Util.option_map v.s3_bucket + (fun f -> ("s3_bucket", (String.to_json f))); + Util.option_map v.zip_file + (fun f -> ("zip_file", (Blob.to_json f))); + Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))); + zip_file = (Util.option_map (Json.lookup j "zip_file") Blob.of_json); + s3_bucket = + (Util.option_map (Json.lookup j "s3_bucket") String.of_json); + s3_key = (Util.option_map (Json.lookup j "s3_key") String.of_json); + s3_object_version = + (Util.option_map (Json.lookup j "s3_object_version") String.of_json) + } + end +module CreateEventSourceMappingRequest = + struct + type t = + { + event_source_arn: String.t ; + function_name: String.t ; + enabled: Boolean.t option ; + batch_size: Integer.t option ; + starting_position: EventSourcePosition.t } + let make ~event_source_arn ~function_name ?enabled ?batch_size + ~starting_position () = + { + event_source_arn; + function_name; + enabled; + batch_size; + starting_position + } + let parse xml = + Some + { + event_source_arn = + (Xml.required "EventSourceArn" + (Util.option_bind (Xml.member "EventSourceArn" xml) + String.parse)); + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)); + enabled = + (Util.option_bind (Xml.member "Enabled" xml) Boolean.parse); + batch_size = + (Util.option_bind (Xml.member "BatchSize" xml) Integer.parse); + starting_position = + (Xml.required "StartingPosition" + (Util.option_bind (Xml.member "StartingPosition" xml) + EventSourcePosition.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some + (Query.Pair + ("StartingPosition", + (EventSourcePosition.to_query v.starting_position))); + Util.option_map v.batch_size + (fun f -> Query.Pair ("BatchSize", (Integer.to_query f))); + Util.option_map v.enabled + (fun f -> Query.Pair ("Enabled", (Boolean.to_query f))); + Some + (Query.Pair ("FunctionName", (String.to_query v.function_name))); + Some + (Query.Pair + ("EventSourceArn", (String.to_query v.event_source_arn)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Some + ("starting_position", + (EventSourcePosition.to_json v.starting_position)); + Util.option_map v.batch_size + (fun f -> ("batch_size", (Integer.to_json f))); + Util.option_map v.enabled + (fun f -> ("enabled", (Boolean.to_json f))); + Some ("function_name", (String.to_json v.function_name)); + Some ("event_source_arn", (String.to_json v.event_source_arn))]) + let of_json j = + { + event_source_arn = + (String.of_json + (Util.of_option_exn (Json.lookup j "event_source_arn"))); + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))); + enabled = (Util.option_map (Json.lookup j "enabled") Boolean.of_json); + batch_size = + (Util.option_map (Json.lookup j "batch_size") Integer.of_json); + starting_position = + (EventSourcePosition.of_json + (Util.of_option_exn (Json.lookup j "starting_position"))) + } + end +module UnsupportedMediaTypeException = + struct + type t = { + type_: String.t option ; + message: String.t option } + let make ?type_ ?message () = { type_; message } + let parse xml = + Some + { + type_ = (Util.option_bind (Xml.member "Type" xml) String.parse); + message = + (Util.option_bind (Xml.member "message" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> Query.Pair ("message", (String.to_query f))); + Util.option_map v.type_ + (fun f -> Query.Pair ("Type", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> ("message", (String.to_json f))); + Util.option_map v.type_ (fun f -> ("type_", (String.to_json f)))]) + let of_json j = + { + type_ = (Util.option_map (Json.lookup j "type_") String.of_json); + message = (Util.option_map (Json.lookup j "message") String.of_json) + } + end +module RemovePermissionRequest = + struct + type t = { + function_name: String.t ; + statement_id: String.t } + let make ~function_name ~statement_id () = + { function_name; statement_id } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)); + statement_id = + (Xml.required "StatementId" + (Util.option_bind (Xml.member "StatementId" xml) String.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some + (Query.Pair ("StatementId", (String.to_query v.statement_id))); + Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Some ("statement_id", (String.to_json v.statement_id)); + Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))); + statement_id = + (String.of_json (Util.of_option_exn (Json.lookup j "statement_id"))) + } + end +module GetFunctionResponse = + struct + type t = + { + configuration: FunctionConfiguration.t option ; + code: FunctionCodeLocation.t option } + let make ?configuration ?code () = { configuration; code } + let parse xml = + Some + { + configuration = + (Util.option_bind (Xml.member "Configuration" xml) + FunctionConfiguration.parse); + code = + (Util.option_bind (Xml.member "Code" xml) + FunctionCodeLocation.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.code + (fun f -> + Query.Pair ("Code", (FunctionCodeLocation.to_query f))); + Util.option_map v.configuration + (fun f -> + Query.Pair + ("Configuration", (FunctionConfiguration.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.code + (fun f -> ("code", (FunctionCodeLocation.to_json f))); + Util.option_map v.configuration + (fun f -> ("configuration", (FunctionConfiguration.to_json f)))]) + let of_json j = + { + configuration = + (Util.option_map (Json.lookup j "configuration") + FunctionConfiguration.of_json); + code = + (Util.option_map (Json.lookup j "code") + FunctionCodeLocation.of_json) + } + end +module TooManyRequestsException = + struct + type t = + { + retry_after_seconds: String.t option ; + type_: String.t option ; + message: String.t option } + let make ?retry_after_seconds ?type_ ?message () = + { retry_after_seconds; type_; message } + let parse xml = + Some + { + retry_after_seconds = + (Util.option_bind (Xml.member "Retry-After" xml) String.parse); + type_ = (Util.option_bind (Xml.member "Type" xml) String.parse); + message = + (Util.option_bind (Xml.member "message" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> Query.Pair ("message", (String.to_query f))); + Util.option_map v.type_ + (fun f -> Query.Pair ("Type", (String.to_query f))); + Util.option_map v.retry_after_seconds + (fun f -> Query.Pair ("Retry-After", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> ("message", (String.to_json f))); + Util.option_map v.type_ (fun f -> ("type_", (String.to_json f))); + Util.option_map v.retry_after_seconds + (fun f -> ("retry_after_seconds", (String.to_json f)))]) + let of_json j = + { + retry_after_seconds = + (Util.option_map (Json.lookup j "retry_after_seconds") + String.of_json); + type_ = (Util.option_map (Json.lookup j "type_") String.of_json); + message = (Util.option_map (Json.lookup j "message") String.of_json) + } + end +module AddPermissionRequest = + struct + type t = + { + function_name: String.t ; + statement_id: String.t ; + action: String.t ; + principal: String.t ; + source_arn: String.t option ; + source_account: String.t option } + let make ~function_name ~statement_id ~action ~principal ?source_arn + ?source_account () = + { + function_name; + statement_id; + action; + principal; + source_arn; + source_account + } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)); + statement_id = + (Xml.required "StatementId" + (Util.option_bind (Xml.member "StatementId" xml) String.parse)); + action = + (Xml.required "Action" + (Util.option_bind (Xml.member "Action" xml) String.parse)); + principal = + (Xml.required "Principal" + (Util.option_bind (Xml.member "Principal" xml) String.parse)); + source_arn = + (Util.option_bind (Xml.member "SourceArn" xml) String.parse); + source_account = + (Util.option_bind (Xml.member "SourceAccount" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.source_account + (fun f -> Query.Pair ("SourceAccount", (String.to_query f))); + Util.option_map v.source_arn + (fun f -> Query.Pair ("SourceArn", (String.to_query f))); + Some (Query.Pair ("Principal", (String.to_query v.principal))); + Some (Query.Pair ("Action", (String.to_query v.action))); + Some + (Query.Pair ("StatementId", (String.to_query v.statement_id))); + Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.source_account + (fun f -> ("source_account", (String.to_json f))); + Util.option_map v.source_arn + (fun f -> ("source_arn", (String.to_json f))); + Some ("principal", (String.to_json v.principal)); + Some ("action", (String.to_json v.action)); + Some ("statement_id", (String.to_json v.statement_id)); + Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))); + statement_id = + (String.of_json (Util.of_option_exn (Json.lookup j "statement_id"))); + action = + (String.of_json (Util.of_option_exn (Json.lookup j "action"))); + principal = + (String.of_json (Util.of_option_exn (Json.lookup j "principal"))); + source_arn = + (Util.option_map (Json.lookup j "source_arn") String.of_json); + source_account = + (Util.option_map (Json.lookup j "source_account") String.of_json) + } + end +module GetFunctionConfigurationRequest = + struct + type t = { + function_name: String.t } + let make ~function_name () = { function_name } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))) + } + end +module InvokeAsyncRequest = + struct + type t = { + function_name: String.t ; + invoke_args: Blob.t } + let make ~function_name ~invoke_args () = + { function_name; invoke_args } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)); + invoke_args = + (Xml.required "InvokeArgs" + (Util.option_bind (Xml.member "InvokeArgs" xml) Blob.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some (Query.Pair ("InvokeArgs", (Blob.to_query v.invoke_args))); + Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Some ("invoke_args", (Blob.to_json v.invoke_args)); + Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))); + invoke_args = + (Blob.of_json (Util.of_option_exn (Json.lookup j "invoke_args"))) + } + end +module InvalidParameterValueException = + struct + type t = { + type_: String.t option ; + message: String.t option } + let make ?type_ ?message () = { type_; message } + let parse xml = + Some + { + type_ = (Util.option_bind (Xml.member "Type" xml) String.parse); + message = + (Util.option_bind (Xml.member "message" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> Query.Pair ("message", (String.to_query f))); + Util.option_map v.type_ + (fun f -> Query.Pair ("Type", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> ("message", (String.to_json f))); + Util.option_map v.type_ (fun f -> ("type_", (String.to_json f)))]) + let of_json j = + { + type_ = (Util.option_map (Json.lookup j "type_") String.of_json); + message = (Util.option_map (Json.lookup j "message") String.of_json) + } + end +module ListFunctionsResponse = + struct + type t = { + next_marker: String.t option ; + functions: FunctionList.t } + let make ?next_marker ?(functions= []) () = { next_marker; functions } + let parse xml = + Some + { + next_marker = + (Util.option_bind (Xml.member "NextMarker" xml) String.parse); + functions = + (Util.of_option [] + (Util.option_bind (Xml.member "Functions" xml) + FunctionList.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some + (Query.Pair + ("Functions.member", (FunctionList.to_query v.functions))); + Util.option_map v.next_marker + (fun f -> Query.Pair ("NextMarker", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Some ("functions", (FunctionList.to_json v.functions)); + Util.option_map v.next_marker + (fun f -> ("next_marker", (String.to_json f)))]) + let of_json j = + { + next_marker = + (Util.option_map (Json.lookup j "next_marker") String.of_json); + functions = + (FunctionList.of_json + (Util.of_option_exn (Json.lookup j "functions"))) + } + end +module UpdateFunctionConfigurationRequest = + struct + type t = + { + function_name: String.t ; + role: String.t option ; + handler: String.t option ; + description: String.t option ; + timeout: Integer.t option ; + memory_size: Integer.t option } + let make ~function_name ?role ?handler ?description ?timeout + ?memory_size () = + { function_name; role; handler; description; timeout; memory_size } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)); + role = (Util.option_bind (Xml.member "Role" xml) String.parse); + handler = + (Util.option_bind (Xml.member "Handler" xml) String.parse); + description = + (Util.option_bind (Xml.member "Description" xml) String.parse); + timeout = + (Util.option_bind (Xml.member "Timeout" xml) Integer.parse); + memory_size = + (Util.option_bind (Xml.member "MemorySize" xml) Integer.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.memory_size + (fun f -> Query.Pair ("MemorySize", (Integer.to_query f))); + Util.option_map v.timeout + (fun f -> Query.Pair ("Timeout", (Integer.to_query f))); + Util.option_map v.description + (fun f -> Query.Pair ("Description", (String.to_query f))); + Util.option_map v.handler + (fun f -> Query.Pair ("Handler", (String.to_query f))); + Util.option_map v.role + (fun f -> Query.Pair ("Role", (String.to_query f))); + Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.memory_size + (fun f -> ("memory_size", (Integer.to_json f))); + Util.option_map v.timeout + (fun f -> ("timeout", (Integer.to_json f))); + Util.option_map v.description + (fun f -> ("description", (String.to_json f))); + Util.option_map v.handler + (fun f -> ("handler", (String.to_json f))); + Util.option_map v.role (fun f -> ("role", (String.to_json f))); + Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))); + role = (Util.option_map (Json.lookup j "role") String.of_json); + handler = (Util.option_map (Json.lookup j "handler") String.of_json); + description = + (Util.option_map (Json.lookup j "description") String.of_json); + timeout = (Util.option_map (Json.lookup j "timeout") Integer.of_json); + memory_size = + (Util.option_map (Json.lookup j "memory_size") Integer.of_json) + } + end +module RequestTooLargeException = + struct + type t = { + type_: String.t option ; + message: String.t option } + let make ?type_ ?message () = { type_; message } + let parse xml = + Some + { + type_ = (Util.option_bind (Xml.member "Type" xml) String.parse); + message = + (Util.option_bind (Xml.member "message" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> Query.Pair ("message", (String.to_query f))); + Util.option_map v.type_ + (fun f -> Query.Pair ("Type", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> ("message", (String.to_json f))); + Util.option_map v.type_ (fun f -> ("type_", (String.to_json f)))]) + let of_json j = + { + type_ = (Util.option_map (Json.lookup j "type_") String.of_json); + message = (Util.option_map (Json.lookup j "message") String.of_json) + } + end +module GetPolicyRequest = + struct + type t = { + function_name: String.t } + let make ~function_name () = { function_name } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))) + } + end +module ListEventSourceMappingsResponse = + struct + type t = + { + next_marker: String.t option ; + event_source_mappings: EventSourceMappingsList.t } + let make ?next_marker ?(event_source_mappings= []) () = + { next_marker; event_source_mappings } + let parse xml = + Some + { + next_marker = + (Util.option_bind (Xml.member "NextMarker" xml) String.parse); + event_source_mappings = + (Util.of_option [] + (Util.option_bind (Xml.member "EventSourceMappings" xml) + EventSourceMappingsList.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some + (Query.Pair + ("EventSourceMappings.member", + (EventSourceMappingsList.to_query v.event_source_mappings))); + Util.option_map v.next_marker + (fun f -> Query.Pair ("NextMarker", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Some + ("event_source_mappings", + (EventSourceMappingsList.to_json v.event_source_mappings)); + Util.option_map v.next_marker + (fun f -> ("next_marker", (String.to_json f)))]) + let of_json j = + { + next_marker = + (Util.option_map (Json.lookup j "next_marker") String.of_json); + event_source_mappings = + (EventSourceMappingsList.of_json + (Util.of_option_exn (Json.lookup j "event_source_mappings"))) + } + end +module InvocationRequest = + struct + type t = + { + function_name: String.t ; + invocation_type: InvocationType.t option ; + log_type: LogType.t option ; + client_context: String.t option ; + payload: Blob.t option } + let make ~function_name ?invocation_type ?log_type ?client_context + ?payload () = + { function_name; invocation_type; log_type; client_context; payload } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)); + invocation_type = + (Util.option_bind (Xml.member "X-Amz-Invocation-Type" xml) + InvocationType.parse); + log_type = + (Util.option_bind (Xml.member "X-Amz-Log-Type" xml) LogType.parse); + client_context = + (Util.option_bind (Xml.member "X-Amz-Client-Context" xml) + String.parse); + payload = (Util.option_bind (Xml.member "Payload" xml) Blob.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.payload + (fun f -> Query.Pair ("Payload", (Blob.to_query f))); + Util.option_map v.client_context + (fun f -> + Query.Pair ("X-Amz-Client-Context", (String.to_query f))); + Util.option_map v.log_type + (fun f -> Query.Pair ("X-Amz-Log-Type", (LogType.to_query f))); + Util.option_map v.invocation_type + (fun f -> + Query.Pair + ("X-Amz-Invocation-Type", (InvocationType.to_query f))); + Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.payload + (fun f -> ("payload", (Blob.to_json f))); + Util.option_map v.client_context + (fun f -> ("client_context", (String.to_json f))); + Util.option_map v.log_type + (fun f -> ("log_type", (LogType.to_json f))); + Util.option_map v.invocation_type + (fun f -> ("invocation_type", (InvocationType.to_json f))); + Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))); + invocation_type = + (Util.option_map (Json.lookup j "invocation_type") + InvocationType.of_json); + log_type = + (Util.option_map (Json.lookup j "log_type") LogType.of_json); + client_context = + (Util.option_map (Json.lookup j "client_context") String.of_json); + payload = (Util.option_map (Json.lookup j "payload") Blob.of_json) + } + end +module CreateFunctionRequest = + struct + type t = + { + function_name: String.t ; + runtime: Runtime.t ; + role: String.t ; + handler: String.t ; + description: String.t option ; + timeout: Integer.t option ; + memory_size: Integer.t option ; + code: FunctionCode.t } + let make ~function_name ~runtime ~role ~handler ?description + ?timeout ?memory_size ~code () = + { + function_name; + runtime; + role; + handler; + description; + timeout; + memory_size; + code + } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)); + runtime = + (Xml.required "Runtime" + (Util.option_bind (Xml.member "Runtime" xml) Runtime.parse)); + role = + (Xml.required "Role" + (Util.option_bind (Xml.member "Role" xml) String.parse)); + handler = + (Xml.required "Handler" + (Util.option_bind (Xml.member "Handler" xml) String.parse)); + description = + (Util.option_bind (Xml.member "Description" xml) String.parse); + timeout = + (Util.option_bind (Xml.member "Timeout" xml) Integer.parse); + memory_size = + (Util.option_bind (Xml.member "MemorySize" xml) Integer.parse); + code = + (Xml.required "Code" + (Util.option_bind (Xml.member "Code" xml) FunctionCode.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some (Query.Pair ("Code", (FunctionCode.to_query v.code))); + Util.option_map v.memory_size + (fun f -> Query.Pair ("MemorySize", (Integer.to_query f))); + Util.option_map v.timeout + (fun f -> Query.Pair ("Timeout", (Integer.to_query f))); + Util.option_map v.description + (fun f -> Query.Pair ("Description", (String.to_query f))); + Some (Query.Pair ("Handler", (String.to_query v.handler))); + Some (Query.Pair ("Role", (String.to_query v.role))); + Some (Query.Pair ("Runtime", (Runtime.to_query v.runtime))); + Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Some ("code", (FunctionCode.to_json v.code)); + Util.option_map v.memory_size + (fun f -> ("memory_size", (Integer.to_json f))); + Util.option_map v.timeout + (fun f -> ("timeout", (Integer.to_json f))); + Util.option_map v.description + (fun f -> ("description", (String.to_json f))); + Some ("handler", (String.to_json v.handler)); + Some ("role", (String.to_json v.role)); + Some ("runtime", (Runtime.to_json v.runtime)); + Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))); + runtime = + (Runtime.of_json (Util.of_option_exn (Json.lookup j "runtime"))); + role = (String.of_json (Util.of_option_exn (Json.lookup j "role"))); + handler = + (String.of_json (Util.of_option_exn (Json.lookup j "handler"))); + description = + (Util.option_map (Json.lookup j "description") String.of_json); + timeout = (Util.option_map (Json.lookup j "timeout") Integer.of_json); + memory_size = + (Util.option_map (Json.lookup j "memory_size") Integer.of_json); + code = + (FunctionCode.of_json (Util.of_option_exn (Json.lookup j "code"))) + } + end +module ListFunctionsRequest = + struct + type t = { + marker: String.t option ; + max_items: Integer.t option } + let make ?marker ?max_items () = { marker; max_items } + let parse xml = + Some + { + marker = (Util.option_bind (Xml.member "Marker" xml) String.parse); + max_items = + (Util.option_bind (Xml.member "MaxItems" xml) Integer.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.max_items + (fun f -> Query.Pair ("MaxItems", (Integer.to_query f))); + Util.option_map v.marker + (fun f -> Query.Pair ("Marker", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.max_items + (fun f -> ("max_items", (Integer.to_json f))); + Util.option_map v.marker (fun f -> ("marker", (String.to_json f)))]) + let of_json j = + { + marker = (Util.option_map (Json.lookup j "marker") String.of_json); + max_items = + (Util.option_map (Json.lookup j "max_items") Integer.of_json) + } + end +module ServiceException = + struct + type t = { + type_: String.t option ; + message: String.t option } + let make ?type_ ?message () = { type_; message } + let parse xml = + Some + { + type_ = (Util.option_bind (Xml.member "Type" xml) String.parse); + message = + (Util.option_bind (Xml.member "Message" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> Query.Pair ("Message", (String.to_query f))); + Util.option_map v.type_ + (fun f -> Query.Pair ("Type", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> ("message", (String.to_json f))); + Util.option_map v.type_ (fun f -> ("type_", (String.to_json f)))]) + let of_json j = + { + type_ = (Util.option_map (Json.lookup j "type_") String.of_json); + message = (Util.option_map (Json.lookup j "message") String.of_json) + } + end +module GetEventSourceMappingRequest = + struct + type t = { + u_u_i_d: String.t } + let make ~u_u_i_d () = { u_u_i_d } + let parse xml = + Some + { + u_u_i_d = + (Xml.required "UUID" + (Util.option_bind (Xml.member "UUID" xml) String.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some (Query.Pair ("UUID", (String.to_query v.u_u_i_d)))]) + let to_json v = + `Assoc + (Util.list_filter_opt [Some ("u_u_i_d", (String.to_json v.u_u_i_d))]) + let of_json j = + { + u_u_i_d = + (String.of_json (Util.of_option_exn (Json.lookup j "u_u_i_d"))) + } + end +module DeleteFunctionRequest = + struct + type t = { + function_name: String.t } + let make ~function_name () = { function_name } + let parse xml = + Some + { + function_name = + (Xml.required "FunctionName" + (Util.option_bind (Xml.member "FunctionName" xml) String.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some + (Query.Pair ("FunctionName", (String.to_query v.function_name)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Some ("function_name", (String.to_json v.function_name))]) + let of_json j = + { + function_name = + (String.of_json + (Util.of_option_exn (Json.lookup j "function_name"))) + } + end +module ResourceNotFoundException = + struct + type t = { + type_: String.t option ; + message: String.t option } + let make ?type_ ?message () = { type_; message } + let parse xml = + Some + { + type_ = (Util.option_bind (Xml.member "Type" xml) String.parse); + message = + (Util.option_bind (Xml.member "Message" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> Query.Pair ("Message", (String.to_query f))); + Util.option_map v.type_ + (fun f -> Query.Pair ("Type", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> ("message", (String.to_json f))); + Util.option_map v.type_ (fun f -> ("type_", (String.to_json f)))]) + let of_json j = + { + type_ = (Util.option_map (Json.lookup j "type_") String.of_json); + message = (Util.option_map (Json.lookup j "message") String.of_json) + } + end +module PolicyLengthExceededException = + struct + type t = { + type_: String.t option ; + message: String.t option } + let make ?type_ ?message () = { type_; message } + let parse xml = + Some + { + type_ = (Util.option_bind (Xml.member "Type" xml) String.parse); + message = + (Util.option_bind (Xml.member "message" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> Query.Pair ("message", (String.to_query f))); + Util.option_map v.type_ + (fun f -> Query.Pair ("Type", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.message + (fun f -> ("message", (String.to_json f))); + Util.option_map v.type_ (fun f -> ("type_", (String.to_json f)))]) + let of_json j = + { + type_ = (Util.option_map (Json.lookup j "type_") String.of_json); + message = (Util.option_map (Json.lookup j "message") String.of_json) + } + end +module DeleteEventSourceMappingRequest = + struct + type t = { + u_u_i_d: String.t } + let make ~u_u_i_d () = { u_u_i_d } + let parse xml = + Some + { + u_u_i_d = + (Xml.required "UUID" + (Util.option_bind (Xml.member "UUID" xml) String.parse)) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Some (Query.Pair ("UUID", (String.to_query v.u_u_i_d)))]) + let to_json v = + `Assoc + (Util.list_filter_opt [Some ("u_u_i_d", (String.to_json v.u_u_i_d))]) + let of_json j = + { + u_u_i_d = + (String.of_json (Util.of_option_exn (Json.lookup j "u_u_i_d"))) + } + end +module GetPolicyResponse = + struct + type t = { + policy: String.t option } + let make ?policy () = { policy } + let parse xml = + Some + { policy = (Util.option_bind (Xml.member "Policy" xml) String.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.policy + (fun f -> Query.Pair ("Policy", (String.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.policy + (fun f -> ("policy", (String.to_json f)))]) + let of_json j = + { policy = (Util.option_map (Json.lookup j "policy") String.of_json) } + end +module InvocationResponse = + struct + type t = + { + status_code: Integer.t option ; + function_error: String.t option ; + log_result: String.t option ; + payload: Blob.t option } + let make ?status_code ?function_error ?log_result ?payload () = + { status_code; function_error; log_result; payload } + let parse xml = + Some + { + status_code = + (Util.option_bind (Xml.member "StatusCode" xml) Integer.parse); + function_error = + (Util.option_bind (Xml.member "X-Amz-Function-Error" xml) + String.parse); + log_result = + (Util.option_bind (Xml.member "X-Amz-Log-Result" xml) + String.parse); + payload = (Util.option_bind (Xml.member "Payload" xml) Blob.parse) + } + let to_query v = + Query.List + (Util.list_filter_opt + [Util.option_map v.payload + (fun f -> Query.Pair ("Payload", (Blob.to_query f))); + Util.option_map v.log_result + (fun f -> Query.Pair ("X-Amz-Log-Result", (String.to_query f))); + Util.option_map v.function_error + (fun f -> + Query.Pair ("X-Amz-Function-Error", (String.to_query f))); + Util.option_map v.status_code + (fun f -> Query.Pair ("StatusCode", (Integer.to_query f)))]) + let to_json v = + `Assoc + (Util.list_filter_opt + [Util.option_map v.payload + (fun f -> ("payload", (Blob.to_json f))); + Util.option_map v.log_result + (fun f -> ("log_result", (String.to_json f))); + Util.option_map v.function_error + (fun f -> ("function_error", (String.to_json f))); + Util.option_map v.status_code + (fun f -> ("status_code", (Integer.to_json f)))]) + let of_json j = + { + status_code = + (Util.option_map (Json.lookup j "status_code") Integer.of_json); + function_error = + (Util.option_map (Json.lookup j "function_error") String.of_json); + log_result = + (Util.option_map (Json.lookup j "log_result") String.of_json); + payload = (Util.option_map (Json.lookup j "payload") Blob.of_json) + } + end \ No newline at end of file diff --git a/libraries/lambda/lib/updateEventSourceMapping.ml b/libraries/lambda/lib/updateEventSourceMapping.ml new file mode 100644 index 000000000..029783e9d --- /dev/null +++ b/libraries/lambda/lib/updateEventSourceMapping.ml @@ -0,0 +1,61 @@ +open Types +open Aws +type input = UpdateEventSourceMappingRequest.t +type output = EventSourceMappingConfiguration.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); + ("Action", ["UpdateEventSourceMapping"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (UpdateEventSourceMappingRequest.to_query req))))) in + (`PUT, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "UpdateEventSourceMappingResponse" (snd xml) in + try + Util.or_error + (Util.option_bind resp EventSourceMappingConfiguration.parse) + (let open Error in + BadResponse + { + body; + message = + "Could not find well formed EventSourceMappingConfiguration." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing EventSourceMappingConfiguration - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/updateEventSourceMapping.mli b/libraries/lambda/lib/updateEventSourceMapping.mli new file mode 100644 index 000000000..fe55b04e8 --- /dev/null +++ b/libraries/lambda/lib/updateEventSourceMapping.mli @@ -0,0 +1,7 @@ +open Types +type input = UpdateEventSourceMappingRequest.t +type output = EventSourceMappingConfiguration.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/updateFunctionCode.ml b/libraries/lambda/lib/updateFunctionCode.ml new file mode 100644 index 000000000..89c7b2ed2 --- /dev/null +++ b/libraries/lambda/lib/updateFunctionCode.ml @@ -0,0 +1,58 @@ +open Types +open Aws +type input = UpdateFunctionCodeRequest.t +type output = FunctionConfiguration.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); ("Action", ["UpdateFunctionCode"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render (UpdateFunctionCodeRequest.to_query req))))) in + (`PUT, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "UpdateFunctionCodeResponse" (snd xml) in + try + Util.or_error (Util.option_bind resp FunctionConfiguration.parse) + (let open Error in + BadResponse + { + body; + message = "Could not find well formed FunctionConfiguration." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing FunctionConfiguration - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/updateFunctionCode.mli b/libraries/lambda/lib/updateFunctionCode.mli new file mode 100644 index 000000000..abd9156ee --- /dev/null +++ b/libraries/lambda/lib/updateFunctionCode.mli @@ -0,0 +1,7 @@ +open Types +type input = UpdateFunctionCodeRequest.t +type output = FunctionConfiguration.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib/updateFunctionConfiguration.ml b/libraries/lambda/lib/updateFunctionConfiguration.ml new file mode 100644 index 000000000..a8b8412ce --- /dev/null +++ b/libraries/lambda/lib/updateFunctionConfiguration.ml @@ -0,0 +1,60 @@ +open Types +open Aws +type input = UpdateFunctionConfigurationRequest.t +type output = FunctionConfiguration.t +type error = Errors_internal.t +let service = "lambda" +let signature_version = Request.V4 +let to_http service region req = + let uri = + Uri.add_query_params + (Uri.of_string + (Aws.Util.of_option_exn (Endpoints.url_of service region))) + (List.append + [("Version", ["2015-03-31"]); + ("Action", ["UpdateFunctionConfiguration"])] + (Util.drop_empty + (Uri.query_of_encoded + (Query.render + (UpdateFunctionConfigurationRequest.to_query req))))) in + (`PUT, uri, []) +let of_http body = + try + let xml = Ezxmlm.from_string body in + let resp = Xml.member "UpdateFunctionConfigurationResponse" (snd xml) in + try + Util.or_error (Util.option_bind resp FunctionConfiguration.parse) + (let open Error in + BadResponse + { + body; + message = "Could not find well formed FunctionConfiguration." + }) + with + | Xml.RequiredFieldMissing msg -> + let open Error in + `Error + (BadResponse + { + body; + message = + ("Error parsing FunctionConfiguration - missing field in body or children: " + ^ msg) + }) + with + | Failure msg -> + `Error + (let open Error in + BadResponse { body; message = ("Error parsing xml: " ^ msg) }) +let parse_error code err = + let errors = [] @ Errors_internal.common in + match Errors_internal.of_string err with + | Some var -> + if + (List.mem var errors) && + ((match Errors_internal.to_http_code var with + | Some var -> var = code + | None -> true)) + then Some var + else None + | None -> None \ No newline at end of file diff --git a/libraries/lambda/lib/updateFunctionConfiguration.mli b/libraries/lambda/lib/updateFunctionConfiguration.mli new file mode 100644 index 000000000..11903a6ec --- /dev/null +++ b/libraries/lambda/lib/updateFunctionConfiguration.mli @@ -0,0 +1,7 @@ +open Types +type input = UpdateFunctionConfigurationRequest.t +type output = FunctionConfiguration.t +type error = Errors_internal.t +include + Aws.Call with type input := input and type output := output and type + error := error \ No newline at end of file diff --git a/libraries/lambda/lib_test/aws_lambda_test.ml b/libraries/lambda/lib_test/aws_lambda_test.ml new file mode 100644 index 000000000..dde635cd4 --- /dev/null +++ b/libraries/lambda/lib_test/aws_lambda_test.ml @@ -0,0 +1,39 @@ +open OUnit +open Aws_lambda + +module type Runtime = sig + type 'a m + + val run_request : + (module Aws.Call + with type input = 'input + and type output = 'output + and type error = 'error) + -> 'input + -> [ `Ok of 'output | `Error of 'error Aws.Error.t ] m + + val un_m : 'a m -> 'a +end + +module TestSuite = +functor + (Runtime : Runtime) + -> + struct + let test_cases = [] + + let rec was_successful = function + | [] -> true + | RSuccess _ :: t | RSkip _ :: t -> was_successful t + | RFailure _ :: _ | RError _ :: _ | RTodo _ :: _ -> false + + let _ = + let suite = "Tests" >::: test_cases in + let verbose = ref false in + let set_verbose _ = verbose := true in + Arg.parse + [ "-verbose", Arg.Unit set_verbose, "Run the test in verbose mode." ] + (fun x -> raise (Arg.Bad ("Bad argument : " ^ x))) + ("Usage: " ^ Sys.argv.(0) ^ " [-verbose]"); + if not (was_successful (run_test_tt ~verbose:!verbose suite)) then exit 1 + end diff --git a/libraries/lambda/lib_test/dune b/libraries/lambda/lib_test/dune new file mode 100644 index 000000000..099c0c700 --- /dev/null +++ b/libraries/lambda/lib_test/dune @@ -0,0 +1,18 @@ +(executables + (names test_async test_lwt) + (flags (:standard -w -27 -w -33)) + (modules test_async test_lwt aws_lambda_test) + (libraries aws aws_lambda aws-async aws-lwt + ounit2 yojson + async cohttp-async + lwt cohttp-lwt cohttp-lwt-unix)) + +(rule + (alias runtest) + (deps test_async.exe) + (action (run %{deps}))) + +(rule + (alias runtest) + (deps test_lwt.exe) + (action (run %{deps}))) diff --git a/libraries/lambda/lib_test/test_async.ml b/libraries/lambda/lib_test/test_async.ml new file mode 100644 index 000000000..e8d43bedd --- /dev/null +++ b/libraries/lambda/lib_test/test_async.ml @@ -0,0 +1,12 @@ +open Aws_lambda_test + +module T = TestSuite(struct + type 'a m = 'a Async.Deferred.t + + let access_key = Unix.getenv "AWS_ACCESS_KEY" + let secret_key = Unix.getenv "AWS_SECRET_KEY" + let region = Unix.getenv "AWS_DEFAULT_REGION" + + let run_request x = Aws_async.Runtime.run_request ~region ~access_key ~secret_key x + let un_m v = Async.Thread_safe.block_on_async_exn (fun () -> v) + end) diff --git a/libraries/lambda/lib_test/test_lwt.ml b/libraries/lambda/lib_test/test_lwt.ml new file mode 100644 index 000000000..b751191d6 --- /dev/null +++ b/libraries/lambda/lib_test/test_lwt.ml @@ -0,0 +1,12 @@ +open Aws_lambda_test + +module T = TestSuite(struct + type 'a m = 'a Lwt.t + + let access_key = Unix.getenv "AWS_ACCESS_KEY" + let secret_key = Unix.getenv "AWS_SECRET_KEY" + let region = Unix.getenv "AWS_DEFAULT_REGION" + + let run_request x = Aws_lwt.Runtime.run_request ~region ~access_key ~secret_key x + let un_m = Lwt_main.run + end) From 09255277cb23fb67a86dd6ece5811d126fdaa61d Mon Sep 17 00:00:00 2001 From: Tim McGilchrist Date: Sat, 27 Mar 2021 11:43:21 +1100 Subject: [PATCH 3/3] Add changelog entry for AWS Lambda. --- CHANGES.md | 13 ++-- libraries/lambda/lib_test/aws_lambda_test.ml | 62 +++++++++++++------- libraries/lambda/lib_test/test_async.ml | 13 ++-- libraries/lambda/lib_test/test_lwt.ml | 13 ++-- 4 files changed, 55 insertions(+), 46 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4898873dc..b8141595c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,13 +1,12 @@ -Unreleased +1.2.1 ---------- + - Add KMS support (#118 @zbaylin) - Drop dependency on ocaml-migrate-parsetree and use ocaml-compiler-libs (#126 @Nymphium) - -1.2.1 ----------- -- Increase lower bound on OCaml to 4.08. https://github.com/inhabitedtype/ocaml-aws/pull/104 -- Migrate CI to github actions https://github.com/inhabitedtype/ocaml-aws/pull/104 -- Add STS `assume_role` token support https://github.com/inhabitedtype/ocaml-aws/pull/117 +- Increase lower bound on OCaml to 4.08. (#104 @tmcgilchrist) +- Migrate CI to github actions (#104 @tmcgilchrist) +- Add STS `assume_role` token support (#117 @zbaylin @UnrealAkama @bleepbloopsify) +- Initial AWS Lambda support (#108 @tmcgilchrist) 1.2: (24-01-2020) ---------- diff --git a/libraries/lambda/lib_test/aws_lambda_test.ml b/libraries/lambda/lib_test/aws_lambda_test.ml index dde635cd4..1ce5dbe93 100644 --- a/libraries/lambda/lib_test/aws_lambda_test.ml +++ b/libraries/lambda/lib_test/aws_lambda_test.ml @@ -1,14 +1,26 @@ -open OUnit +open OUnit2 open Aws_lambda +type config = + { access_key : string + ; secret_key : string + ; region : string + } + +let ( @? ) = assert_bool + module type Runtime = sig type 'a m val run_request : - (module Aws.Call - with type input = 'input - and type output = 'output - and type error = 'error) + region:string + -> access_key:string + -> secret_key:string + -> ?token:string + -> (module Aws.Call + with type input = 'input + and type output = 'output + and type error = 'error) -> 'input -> [ `Ok of 'output | `Error of 'error Aws.Error.t ] m @@ -17,23 +29,31 @@ end module TestSuite = functor - (Runtime : Runtime) + (Runtime : Runtime) -> struct - let test_cases = [] + let noop_test config _ = + "Noop lambda test succeeds" + @?false - let rec was_successful = function - | [] -> true - | RSuccess _ :: t | RSkip _ :: t -> was_successful t - | RFailure _ :: _ | RError _ :: _ | RTodo _ :: _ -> false + let suite config = + "Test Lambda" >::: [ "Lambda noop" >:: noop_test config ] - let _ = - let suite = "Tests" >::: test_cases in - let verbose = ref false in - let set_verbose _ = verbose := true in - Arg.parse - [ "-verbose", Arg.Unit set_verbose, "Run the test in verbose mode." ] - (fun x -> raise (Arg.Bad ("Bad argument : " ^ x))) - ("Usage: " ^ Sys.argv.(0) ^ " [-verbose]"); - if not (was_successful (run_test_tt ~verbose:!verbose suite)) then exit 1 - end + let () = + let access_key = + try Some (Unix.getenv "AWS_ACCESS_KEY_ID") with Not_found -> None + in + let secret_key = + try Some (Unix.getenv "AWS_SECRET_ACCESS_KEY") with Not_found -> None + in + let region = try Some (Unix.getenv "AWS_DEFAULT_REGION") with Not_found -> None in + + match access_key, secret_key, region with + | Some access_key, Some secret_key, Some region -> + run_test_tt_main (suite { access_key; secret_key; region }) + | _, _, _ -> + Printf.eprintf + "Skipping running tests. Environment variables AWS_ACCESS_KEY_ID, \ + AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION not available. "; + exit 0 +end \ No newline at end of file diff --git a/libraries/lambda/lib_test/test_async.ml b/libraries/lambda/lib_test/test_async.ml index e8d43bedd..30eab0534 100644 --- a/libraries/lambda/lib_test/test_async.ml +++ b/libraries/lambda/lib_test/test_async.ml @@ -1,12 +1,7 @@ open Aws_lambda_test module T = TestSuite(struct - type 'a m = 'a Async.Deferred.t - - let access_key = Unix.getenv "AWS_ACCESS_KEY" - let secret_key = Unix.getenv "AWS_SECRET_KEY" - let region = Unix.getenv "AWS_DEFAULT_REGION" - - let run_request x = Aws_async.Runtime.run_request ~region ~access_key ~secret_key x - let un_m v = Async.Thread_safe.block_on_async_exn (fun () -> v) - end) + type 'a m = 'a Async.Deferred.t + let run_request = Aws_async.Runtime.run_request + let un_m v = Async.Thread_safe.block_on_async_exn (fun () -> v) + end) \ No newline at end of file diff --git a/libraries/lambda/lib_test/test_lwt.ml b/libraries/lambda/lib_test/test_lwt.ml index b751191d6..1d7b99dfa 100644 --- a/libraries/lambda/lib_test/test_lwt.ml +++ b/libraries/lambda/lib_test/test_lwt.ml @@ -1,12 +1,7 @@ open Aws_lambda_test module T = TestSuite(struct - type 'a m = 'a Lwt.t - - let access_key = Unix.getenv "AWS_ACCESS_KEY" - let secret_key = Unix.getenv "AWS_SECRET_KEY" - let region = Unix.getenv "AWS_DEFAULT_REGION" - - let run_request x = Aws_lwt.Runtime.run_request ~region ~access_key ~secret_key x - let un_m = Lwt_main.run - end) + type 'a m = 'a Lwt.t + let run_request = Aws_lwt.Runtime.run_request + let un_m = Lwt_main.run + end) \ No newline at end of file