diff --git a/.github/workflows/branch_alias.yml b/.github/workflows/branch_alias.yml deleted file mode 100644 index a7032e6..0000000 --- a/.github/workflows/branch_alias.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Update branch alias - -on: - push: - tags: ['*'] - -jobs: - branch-alias: - name: Update branch alias - runs-on: ubuntu-latest - - steps: - - name: Set up PHP - uses: shivammathur/setup-php@2.7.0 - with: - php-version: 7.4 - coverage: none - - - name: Find branch alias - id: find_alias - run: | - TAG=$(echo $GITHUB_REF | cut -d'/' -f 3) - echo "Last tag was $TAG" - ARR=(${TAG//./ }) - ARR[1]=$((${ARR[1]}+1)) - echo ::set-output name=alias::${ARR[0]}.${ARR[1]} - - - name: Checkout main repo - run: | - git clone --branch master https://${{ secrets.BOT_GITHUB_TOKEN }}:x-oauth-basic@github.com/async-aws/aws aws - - - name: Update branch alias - run: | - cd aws/src/Service/Lambda - CURRENT_ALIAS=$(composer config extra.branch-alias.dev-master | cut -d'-' -f 1) - - # If there is a current value on the branch alias - if [ ! -z $CURRENT_ALIAS ]; then - NEW_ALIAS=${{ steps.find_alias.outputs.alias }} - CURRENT_ARR=(${CURRENT_ALIAS//./ }) - NEW_ARR=(${NEW_ALIAS//./ }) - - if [ ${CURRENT_ARR[0]} -gt ${NEW_ARR[0]} ]; then - echo "The current value for major version is larger" - exit 1; - fi - - if [ ${CURRENT_ARR[0]} -eq ${NEW_ARR[0]} ] && [ ${CURRENT_ARR[1]} -gt ${NEW_ARR[1]} ]; then - echo "The current value for minor version is larger" - exit 1; - fi - fi - - composer config extra.branch-alias.dev-master ${{ steps.find_alias.outputs.alias }}-dev - - - name: Commit & push the new files - run: | - echo "::group::git status" - cd aws - git status - echo "::endgroup::" - - git add -N . - if [[ $(git diff --numstat | wc -l) -eq 0 ]]; then - echo "No changes found. Exiting." - exit 0; - fi - - git config --local user.email "github@async-aws.com" - git config --local user.name "AsyncAws Bot" - - echo "::group::git push" - git add . - git commit -m "Update branch alias" - git push - echo "::endgroup::" diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 1a72276..b9c47e8 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -12,7 +12,9 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Modify composer.json run: | @@ -23,5 +25,14 @@ jobs: git config --local user.name "AsyncAws Bot" git commit -am "Allow unstable dependencies" + - name: Install PHP with extensions + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + tools: composer:v2 + + - name: Install roave/backward-compatibility-check + run: composer require --dev roave/backward-compatibility-check + - name: Roave BC Check - uses: docker://nyholm/roave-bc-check-ga + run: vendor/bin/roave-backward-compatibility-check diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c4cfce..0778da5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,17 +13,20 @@ jobs: strategy: max-parallel: 10 matrix: - php: ['7.2', '7.3', '7.4'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] steps: - name: Set up PHP - uses: shivammathur/setup-php@2.7.0 + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} coverage: none - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + + - name: Initialize tests + run: make initialize - name: Download dependencies run: | @@ -31,8 +34,5 @@ jobs: composer req symfony/phpunit-bridge --no-update composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable - - name: Initialize tests - run: make initialize - - name: Run tests run: ./vendor/bin/simple-phpunit diff --git a/.gitignore b/.gitignore index b2c15b6..4ef8091 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ /vendor/ -.php_cs.cache -.phpunit.result.cache +*.cache composer.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index a41bc5e..9b20bed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,216 @@ ## NOT RELEASED +## 2.11.0 + +### Added + +- AWS api-change: Added `eu-isoe-west-1` region + +### Changed + +- Sort exception alphabetically. + +## 2.10.0 + +### Added + +- AWS api-change: Add Ruby 3.4 (ruby3.4) support to AWS Lambda. + +## 2.9.0 + +### Added + +- AWS api-change: Added `us-isof-east-1` and `us-isof-south-1` regions + +## 2.8.0 + +### Added + +- AWS api-change: Added `ap-southeast-7` region +- AWS api-change: Added `mx-central-1` region + +## 2.7.0 + +### Added + +- AWS api-change: Add Python 3.13 (python3.13) support to AWS Lambda +- AWS api-change: Add Node 22.x (node22.x) support to AWS Lambda + +### Changed + +- use strict comparison `null !==` instead of `!` +- AWS enhancement: Documentation updates. + +## 2.6.0 + +### Added + +- AWS api-change: Added `ap-southeast-5` region + +### Changed + +- Enable compiler optimization for the `sprintf` function. +- AWS enhancement: Documentation updates. + +## 2.5.1 + +### Changed + +- Add `Accept: application/json` header in request to fix incompatibility with 3rd party providers + +## 2.5.0 + +### Added + +- AWS api-change: Add Ruby 3.3 (ruby3.3) support to AWS Lambda + +### Changed + +- AWS enhancement: Documentation updates. + +## 2.4.0 + +### Added + +- AWS api-change: Add .NET 8 (dotnet8) Runtime support to AWS Lambda. + +### Changed + +- AWS enhancement: Documentation updates. + +## 2.3.0 + +### Added + +- AWS api-change: Added `ca-west-1` region + +## 2.2.0 + +### Added + +- AWS api-change: Adds support for Lambda functions to access Dual-Stack subnets over IPv6, via an opt-in flag in CreateFunction and UpdateFunctionConfiguration APIs +- AWS api-change: Adds support for logging configuration in Lambda Functions. Customers will have more control how their function logs are captured and to which cloud watch log group they are delivered also. +- AWS api-change: Add Java 21 (java21) support to AWS Lambda +- AWS api-change: Add Python 3.12 (python3.12) support to AWS Lambda +- AWS api-change: Add Custom runtime on Amazon Linux 2023 (provided.al2023) support to AWS Lambda. +- AWS api-change: Add Node 20 (nodejs20.x) support to AWS Lambda. + +## 2.1.0 + +### Added + +- Added operation `getFunctionConfiguration` and `updateFunctionConfiguration`. + +### Changed + +- Allow passing explicit null values for optional fields of input objects + +## 2.0.0 + +### BC-BREAK + +- The type for `\AsyncAws\Lambda\Input\AddLayerVersionPermissionRequest::getVersionNumber` and `\AsyncAws\Lambda\Input\AddLayerVersionPermissionRequest::setVersionNumber` uses `int` instead of `string` to reflect the AWS type. +- The return type for `\AsyncAws\Lambda\Result\PublishLayerVersionResponse::getVersion` uses `int` instead of `string` to reflect the AWS type. +- The return type for `\AsyncAws\Lambda\ValueObject\FunctionConfiguration::getCodeSize` uses `int` instead of `string` to reflect the AWS type. +- The return type for `\AsyncAws\Lambda\ValueObject\Layer::getCodeSize` uses `int` instead of `string` to reflect the AWS type. +- The return type for `\AsyncAws\Lambda\ValueObject\LayerVersionContentOutput::getCodeSize` uses `int` instead of `string` to reflect the AWS type. +- The return type for `\AsyncAws\Lambda\ValueObject\LayerVersionsListItem::getVersion` uses `int` instead of `string` to reflect the AWS type. + +### Added + +- AWS api-change: This release adds RecursiveInvocationException to the Invoke API and InvokeWithResponseStream API. +- AWS enhancement: Documentation updates. +- AWS api-change: Add Python 3.11 (python3.11) support to AWS Lambda +- AWS api-change: Add support for the `il-central-1` region +- Avoid overriding the exception message with the raw message +- Use int as the PHP representation of long fields in generated code + +### Changed + +- Improve parameter type and return type in phpdoc + +## 1.9.0 + +### Added + +- AWS enhancement: Documentation updates. +- AWS api-change: Release Lambda RuntimeManagementConfig, enabling customers to better manage runtime updates to their Lambda functions. This release adds two new APIs, GetRuntimeManagementConfig and PutRuntimeManagementConfig, as well as support on existing Create/Get/Update function APIs. +- AWS api-change: Added `ap-southeast-4` region. +- AWS api-change: Add Python 3.10 (python3.10) support to AWS Lambda +- AWS api-change: Add Ruby 3.2 (ruby3.2) Runtime support to AWS Lambda. +- AWS api-change: Add Java 17 (java17) support to AWS Lambda + +## 1.8.0 + +### Added + +- AWS api-change: Restrict the list of available regions. +- AWS api-change: Added `eu-central-2`, `eu-south-2` and `ap-south-2` regions +- AWS api-change: Add Node 18 (nodejs18.x) support to AWS Lambda. +- AWS api-change: Adds support for Lambda SnapStart, which helps improve the startup performance of functions. Customers can now manage SnapStart based functions via CreateFunction and UpdateFunctionConfiguration APIs + +## 1.7.0 + +### Added + +- AWS api-change: Adds support for increased ephemeral storage (/tmp) up to 10GB for Lambda functions. Customers can now provision up to 10 GB of ephemeral storage per function instance, a 20x increase over the previous limit of 512 MB. +- AWS api-change: Added NodeJs 16 managed runtime +- Lambda is available in all commercial regions + +## 1.6.0 + +### Added + +- AWS api-change: Added `us-iso-west-1` region +- AWS api-change: Use specific configuration for `us` regions +- AWS enhancement: Documentation updates. +- AWS api-change: Remove Lambda function url apis +- AWS api-change: Release Lambda event source filtering for SQS, Kinesis Streams, and DynamoDB Streams. +- AWS api-change: Add support for Lambda Function URLs. Customers can use Function URLs to create built-in HTTPS endpoints on their functions. +- AWS api-change: Added support for CLIENT_CERTIFICATE_TLS_AUTH and SERVER_ROOT_CA_CERTIFICATE as SourceAccessType for MSK and Kafka event source mappings. +- AWS api-change: Lambda releases .NET 6 managed runtime to be available in all commercial regions. + +## 1.5.0 + +### Added + +- AWS api-change: Lambda Python 3.9 runtime launch +- AWS api-change: Adds support for Lambda functions powered by AWS Graviton2 processors. Customers can now select the CPU architecture for their functions. + +### Changed + +- AWS enhancement: Documentation updates for Amazon Lambda. + +### Fixed + +- Assert the provided Input can be json-encoded. + +## 1.4.0 + +### Added + +- AWS api-change: Added constant for NodeJs 14. +- Added operation `deleteFunction`, `listFunctions`, and `listVersionsByFunction`. + +## 1.3.0 + +### Added + +- Changed case of object's properties to camelCase. +- Added documentation in class headers. +- Added domain exceptions. + +## 1.2.0 + +### Added + +- AWS api-change: This release includes support for new feature: Code Signing for AWS Lambda. This adds new resources and APIs to configure Lambda functions to accept and verify signed code artifacts at deployment. + +### Fixed + +- If provided an unrecognized region, then fallback to default region config + ## 1.1.1 ### Fixed @@ -39,6 +249,11 @@ ## 0.4.0 +### Removed + +- Dependency on `symfony/http-client-contracts` +- All `validate()` methods on the inputs. They are merged with `request()`. + ### Changed - Moved value objects to a dedicated namespace. @@ -46,11 +261,6 @@ - Using `DateTimeImmutable` instead of `DateTimeInterface` - The `AsyncAws\Lambda\Enum\*`, `AsyncAws\Lambda\Input\*` and `AsyncAws\Lambda\ValueObject*` classes are marked final. -### Removed - -- Dependency on `symfony/http-client-contracts` -- All `validate()` methods on the inputs. They are merged with `request()`. - ## 0.3.0 ### Added diff --git a/Makefile b/Makefile index 70fe44b..4864641 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,9 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) initialize: start-docker start-docker: - docker pull lambci/lambda - docker start async_aws_lambda || docker run -d -p 9001:9001 -e DOCKER_LAMBDA_STAY_OPEN=1 -v "$(ROOT_DIR)/tests/fixtures/lambda":/var/task:ro,delegated --name async_aws_lambda lambci/lambda:nodejs12.x index.handler + docker start async_aws_lambda && exit 0 || \ + docker pull lambci/lambda:nodejs12.x && \ + docker run -d -p 9001:9001 -e DOCKER_LAMBDA_STAY_OPEN=1 -v "$(ROOT_DIR)/tests/fixtures/lambda":/var/task:ro,delegated --name async_aws_lambda lambci/lambda:nodejs12.x index.handler test: initialize ./vendor/bin/simple-phpunit @@ -13,3 +14,4 @@ test: initialize clean: stop-docker stop-docker: docker stop async_aws_lambda || true + docker rm async_aws_lambda || true diff --git a/composer.json b/composer.json index a9c2cd2..303436f 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,8 @@ { "name": "async-aws/lambda", - "type": "library", "description": "Lambda client, part of the AWS SDK provided by AsyncAws.", + "license": "MIT", + "type": "library", "keywords": [ "aws", "amazon", @@ -9,16 +10,11 @@ "async-aws", "lambda" ], - "license": "MIT", "require": { "php": "^7.2.5 || ^8.0", + "ext-filter": "*", "ext-json": "*", - "async-aws/core": "^1.2" - }, - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } + "async-aws/core": "^1.9" }, "autoload": { "psr-4": { @@ -29,5 +25,10 @@ "psr-4": { "AsyncAws\\Lambda\\Tests\\": "tests/" } + }, + "extra": { + "branch-alias": { + "dev-master": "2.11-dev" + } } } diff --git a/src/Enum/ApplicationLogLevel.php b/src/Enum/ApplicationLogLevel.php new file mode 100644 index 0000000..2ee1013 --- /dev/null +++ b/src/Enum/ApplicationLogLevel.php @@ -0,0 +1,25 @@ + true, + self::ERROR => true, + self::FATAL => true, + self::INFO => true, + self::TRACE => true, + self::WARN => true, + ][$value]); + } +} diff --git a/src/Enum/Architecture.php b/src/Enum/Architecture.php new file mode 100644 index 0000000..0c686de --- /dev/null +++ b/src/Enum/Architecture.php @@ -0,0 +1,17 @@ + true, + self::X86_64 => true, + ][$value]); + } +} diff --git a/src/Enum/FunctionVersion.php b/src/Enum/FunctionVersion.php new file mode 100644 index 0000000..7f59b95 --- /dev/null +++ b/src/Enum/FunctionVersion.php @@ -0,0 +1,15 @@ + true, + ][$value]); + } +} diff --git a/src/Enum/LastUpdateStatus.php b/src/Enum/LastUpdateStatus.php new file mode 100644 index 0000000..c61b47c --- /dev/null +++ b/src/Enum/LastUpdateStatus.php @@ -0,0 +1,19 @@ + true, + self::IN_PROGRESS => true, + self::SUCCESSFUL => true, + ][$value]); + } +} diff --git a/src/Enum/LastUpdateStatusReasonCode.php b/src/Enum/LastUpdateStatusReasonCode.php new file mode 100644 index 0000000..8bd541c --- /dev/null +++ b/src/Enum/LastUpdateStatusReasonCode.php @@ -0,0 +1,55 @@ + true, + self::EFSIOERROR => true, + self::EFSMOUNT_CONNECTIVITY_ERROR => true, + self::EFSMOUNT_FAILURE => true, + self::EFSMOUNT_TIMEOUT => true, + self::ENI_LIMIT_EXCEEDED => true, + self::FUNCTION_ERROR => true, + self::IMAGE_ACCESS_DENIED => true, + self::IMAGE_DELETED => true, + self::INSUFFICIENT_ROLE_PERMISSIONS => true, + self::INTERNAL_ERROR => true, + self::INVALID_CONFIGURATION => true, + self::INVALID_IMAGE => true, + self::INVALID_RUNTIME => true, + self::INVALID_SECURITY_GROUP => true, + self::INVALID_STATE_KMSKEY => true, + self::INVALID_SUBNET => true, + self::INVALID_ZIP_FILE_EXCEPTION => true, + self::KMSKEY_ACCESS_DENIED => true, + self::KMSKEY_NOT_FOUND => true, + self::SUBNET_OUT_OF_IPADDRESSES => true, + ][$value]); + } +} diff --git a/src/Enum/LogFormat.php b/src/Enum/LogFormat.php new file mode 100644 index 0000000..ed250cd --- /dev/null +++ b/src/Enum/LogFormat.php @@ -0,0 +1,17 @@ + true, + self::TEXT => true, + ][$value]); + } +} diff --git a/src/Enum/PackageType.php b/src/Enum/PackageType.php new file mode 100644 index 0000000..361ee04 --- /dev/null +++ b/src/Enum/PackageType.php @@ -0,0 +1,17 @@ + true, + self::ZIP => true, + ][$value]); + } +} diff --git a/src/Enum/Runtime.php b/src/Enum/Runtime.php index b2ad275..b48bc38 100644 --- a/src/Enum/Runtime.php +++ b/src/Enum/Runtime.php @@ -8,25 +8,43 @@ final class Runtime public const DOTNETCORE_2_0 = 'dotnetcore2.0'; public const DOTNETCORE_2_1 = 'dotnetcore2.1'; public const DOTNETCORE_3_1 = 'dotnetcore3.1'; + public const DOTNET_6 = 'dotnet6'; + public const DOTNET_8 = 'dotnet8'; public const GO_1_X = 'go1.x'; public const JAVA_11 = 'java11'; + public const JAVA_17 = 'java17'; + public const JAVA_21 = 'java21'; public const JAVA_8 = 'java8'; public const JAVA_8_AL_2 = 'java8.al2'; public const NODEJS = 'nodejs'; public const NODEJS_10_X = 'nodejs10.x'; public const NODEJS_12_X = 'nodejs12.x'; + public const NODEJS_14_X = 'nodejs14.x'; + public const NODEJS_16_X = 'nodejs16.x'; + public const NODEJS_18_X = 'nodejs18.x'; + public const NODEJS_20_X = 'nodejs20.x'; + public const NODEJS_22_X = 'nodejs22.x'; public const NODEJS_4_3 = 'nodejs4.3'; public const NODEJS_4_3_EDGE = 'nodejs4.3-edge'; public const NODEJS_6_10 = 'nodejs6.10'; public const NODEJS_8_10 = 'nodejs8.10'; public const PROVIDED = 'provided'; public const PROVIDED_AL_2 = 'provided.al2'; + public const PROVIDED_AL_2023 = 'provided.al2023'; public const PYTHON_2_7 = 'python2.7'; + public const PYTHON_3_10 = 'python3.10'; + public const PYTHON_3_11 = 'python3.11'; + public const PYTHON_3_12 = 'python3.12'; + public const PYTHON_3_13 = 'python3.13'; public const PYTHON_3_6 = 'python3.6'; public const PYTHON_3_7 = 'python3.7'; public const PYTHON_3_8 = 'python3.8'; + public const PYTHON_3_9 = 'python3.9'; public const RUBY_2_5 = 'ruby2.5'; public const RUBY_2_7 = 'ruby2.7'; + public const RUBY_3_2 = 'ruby3.2'; + public const RUBY_3_3 = 'ruby3.3'; + public const RUBY_3_4 = 'ruby3.4'; public static function exists(string $value): bool { @@ -35,25 +53,43 @@ public static function exists(string $value): bool self::DOTNETCORE_2_0 => true, self::DOTNETCORE_2_1 => true, self::DOTNETCORE_3_1 => true, + self::DOTNET_6 => true, + self::DOTNET_8 => true, self::GO_1_X => true, self::JAVA_11 => true, + self::JAVA_17 => true, + self::JAVA_21 => true, self::JAVA_8 => true, self::JAVA_8_AL_2 => true, self::NODEJS => true, self::NODEJS_10_X => true, self::NODEJS_12_X => true, + self::NODEJS_14_X => true, + self::NODEJS_16_X => true, + self::NODEJS_18_X => true, + self::NODEJS_20_X => true, + self::NODEJS_22_X => true, self::NODEJS_4_3 => true, self::NODEJS_4_3_EDGE => true, self::NODEJS_6_10 => true, self::NODEJS_8_10 => true, self::PROVIDED => true, self::PROVIDED_AL_2 => true, + self::PROVIDED_AL_2023 => true, self::PYTHON_2_7 => true, + self::PYTHON_3_10 => true, + self::PYTHON_3_11 => true, + self::PYTHON_3_12 => true, + self::PYTHON_3_13 => true, self::PYTHON_3_6 => true, self::PYTHON_3_7 => true, self::PYTHON_3_8 => true, + self::PYTHON_3_9 => true, self::RUBY_2_5 => true, self::RUBY_2_7 => true, + self::RUBY_3_2 => true, + self::RUBY_3_3 => true, + self::RUBY_3_4 => true, ][$value]); } } diff --git a/src/Enum/SnapStartApplyOn.php b/src/Enum/SnapStartApplyOn.php new file mode 100644 index 0000000..3bfbaa6 --- /dev/null +++ b/src/Enum/SnapStartApplyOn.php @@ -0,0 +1,17 @@ + true, + self::PUBLISHED_VERSIONS => true, + ][$value]); + } +} diff --git a/src/Enum/SnapStartOptimizationStatus.php b/src/Enum/SnapStartOptimizationStatus.php new file mode 100644 index 0000000..b004e06 --- /dev/null +++ b/src/Enum/SnapStartOptimizationStatus.php @@ -0,0 +1,17 @@ + true, + self::ON => true, + ][$value]); + } +} diff --git a/src/Enum/State.php b/src/Enum/State.php new file mode 100644 index 0000000..000a08d --- /dev/null +++ b/src/Enum/State.php @@ -0,0 +1,21 @@ + true, + self::FAILED => true, + self::INACTIVE => true, + self::PENDING => true, + ][$value]); + } +} diff --git a/src/Enum/StateReasonCode.php b/src/Enum/StateReasonCode.php new file mode 100644 index 0000000..ff905bc --- /dev/null +++ b/src/Enum/StateReasonCode.php @@ -0,0 +1,61 @@ + true, + self::DISABLED_KMSKEY => true, + self::EFSIOERROR => true, + self::EFSMOUNT_CONNECTIVITY_ERROR => true, + self::EFSMOUNT_FAILURE => true, + self::EFSMOUNT_TIMEOUT => true, + self::ENI_LIMIT_EXCEEDED => true, + self::FUNCTION_ERROR => true, + self::IDLE => true, + self::IMAGE_ACCESS_DENIED => true, + self::IMAGE_DELETED => true, + self::INSUFFICIENT_ROLE_PERMISSIONS => true, + self::INTERNAL_ERROR => true, + self::INVALID_CONFIGURATION => true, + self::INVALID_IMAGE => true, + self::INVALID_RUNTIME => true, + self::INVALID_SECURITY_GROUP => true, + self::INVALID_STATE_KMSKEY => true, + self::INVALID_SUBNET => true, + self::INVALID_ZIP_FILE_EXCEPTION => true, + self::KMSKEY_ACCESS_DENIED => true, + self::KMSKEY_NOT_FOUND => true, + self::RESTORING => true, + self::SUBNET_OUT_OF_IPADDRESSES => true, + ][$value]); + } +} diff --git a/src/Enum/SystemLogLevel.php b/src/Enum/SystemLogLevel.php new file mode 100644 index 0000000..49cff1c --- /dev/null +++ b/src/Enum/SystemLogLevel.php @@ -0,0 +1,19 @@ + true, + self::INFO => true, + self::WARN => true, + ][$value]); + } +} diff --git a/src/Enum/ThrottleReason.php b/src/Enum/ThrottleReason.php new file mode 100644 index 0000000..a5e7e85 --- /dev/null +++ b/src/Enum/ThrottleReason.php @@ -0,0 +1,25 @@ + true, + self::CONCURRENT_INVOCATION_LIMIT_EXCEEDED => true, + self::CONCURRENT_SNAPSHOT_CREATE_LIMIT_EXCEEDED => true, + self::FUNCTION_INVOCATION_RATE_LIMIT_EXCEEDED => true, + self::RESERVED_FUNCTION_CONCURRENT_INVOCATION_LIMIT_EXCEEDED => true, + self::RESERVED_FUNCTION_INVOCATION_RATE_LIMIT_EXCEEDED => true, + ][$value]); + } +} diff --git a/src/Enum/TracingMode.php b/src/Enum/TracingMode.php new file mode 100644 index 0000000..421eac0 --- /dev/null +++ b/src/Enum/TracingMode.php @@ -0,0 +1,17 @@ + true, + self::PASS_THROUGH => true, + ][$value]); + } +} diff --git a/src/Exception/CodeSigningConfigNotFoundException.php b/src/Exception/CodeSigningConfigNotFoundException.php new file mode 100644 index 0000000..10858dd --- /dev/null +++ b/src/Exception/CodeSigningConfigNotFoundException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/CodeStorageExceededException.php b/src/Exception/CodeStorageExceededException.php new file mode 100644 index 0000000..3e41c57 --- /dev/null +++ b/src/Exception/CodeStorageExceededException.php @@ -0,0 +1,34 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/CodeVerificationFailedException.php b/src/Exception/CodeVerificationFailedException.php new file mode 100644 index 0000000..bf4edf2 --- /dev/null +++ b/src/Exception/CodeVerificationFailedException.php @@ -0,0 +1,30 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/EC2AccessDeniedException.php b/src/Exception/EC2AccessDeniedException.php new file mode 100644 index 0000000..ec50444 --- /dev/null +++ b/src/Exception/EC2AccessDeniedException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/EC2ThrottledException.php b/src/Exception/EC2ThrottledException.php new file mode 100644 index 0000000..0e92575 --- /dev/null +++ b/src/Exception/EC2ThrottledException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/EC2UnexpectedException.php b/src/Exception/EC2UnexpectedException.php new file mode 100644 index 0000000..df2193a --- /dev/null +++ b/src/Exception/EC2UnexpectedException.php @@ -0,0 +1,40 @@ +ec2ErrorCode; + } + + public function getType(): ?string + { + return $this->type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + $this->ec2ErrorCode = isset($data['EC2ErrorCode']) ? (string) $data['EC2ErrorCode'] : null; + } +} diff --git a/src/Exception/EFSIOException.php b/src/Exception/EFSIOException.php new file mode 100644 index 0000000..72a75ea --- /dev/null +++ b/src/Exception/EFSIOException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/EFSMountConnectivityException.php b/src/Exception/EFSMountConnectivityException.php new file mode 100644 index 0000000..d981e5e --- /dev/null +++ b/src/Exception/EFSMountConnectivityException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/EFSMountFailureException.php b/src/Exception/EFSMountFailureException.php new file mode 100644 index 0000000..f593a40 --- /dev/null +++ b/src/Exception/EFSMountFailureException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/EFSMountTimeoutException.php b/src/Exception/EFSMountTimeoutException.php new file mode 100644 index 0000000..88626e6 --- /dev/null +++ b/src/Exception/EFSMountTimeoutException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/ENILimitReachedException.php b/src/Exception/ENILimitReachedException.php new file mode 100644 index 0000000..d99d926 --- /dev/null +++ b/src/Exception/ENILimitReachedException.php @@ -0,0 +1,32 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/InvalidCodeSignatureException.php b/src/Exception/InvalidCodeSignatureException.php new file mode 100644 index 0000000..a62841b --- /dev/null +++ b/src/Exception/InvalidCodeSignatureException.php @@ -0,0 +1,30 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/InvalidParameterValueException.php b/src/Exception/InvalidParameterValueException.php new file mode 100644 index 0000000..2241186 --- /dev/null +++ b/src/Exception/InvalidParameterValueException.php @@ -0,0 +1,31 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/InvalidRequestContentException.php b/src/Exception/InvalidRequestContentException.php new file mode 100644 index 0000000..dedf6e8 --- /dev/null +++ b/src/Exception/InvalidRequestContentException.php @@ -0,0 +1,32 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/InvalidRuntimeException.php b/src/Exception/InvalidRuntimeException.php new file mode 100644 index 0000000..44e81db --- /dev/null +++ b/src/Exception/InvalidRuntimeException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/InvalidSecurityGroupIDException.php b/src/Exception/InvalidSecurityGroupIDException.php new file mode 100644 index 0000000..f9a6659 --- /dev/null +++ b/src/Exception/InvalidSecurityGroupIDException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/InvalidSubnetIDException.php b/src/Exception/InvalidSubnetIDException.php new file mode 100644 index 0000000..d7eefa3 --- /dev/null +++ b/src/Exception/InvalidSubnetIDException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/InvalidZipFileException.php b/src/Exception/InvalidZipFileException.php new file mode 100644 index 0000000..480105c --- /dev/null +++ b/src/Exception/InvalidZipFileException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/KMSAccessDeniedException.php b/src/Exception/KMSAccessDeniedException.php new file mode 100644 index 0000000..a4217e0 --- /dev/null +++ b/src/Exception/KMSAccessDeniedException.php @@ -0,0 +1,30 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/KMSDisabledException.php b/src/Exception/KMSDisabledException.php new file mode 100644 index 0000000..c34520e --- /dev/null +++ b/src/Exception/KMSDisabledException.php @@ -0,0 +1,30 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/KMSInvalidStateException.php b/src/Exception/KMSInvalidStateException.php new file mode 100644 index 0000000..ae15620 --- /dev/null +++ b/src/Exception/KMSInvalidStateException.php @@ -0,0 +1,30 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/KMSNotFoundException.php b/src/Exception/KMSNotFoundException.php new file mode 100644 index 0000000..32ae25e --- /dev/null +++ b/src/Exception/KMSNotFoundException.php @@ -0,0 +1,30 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/PolicyLengthExceededException.php b/src/Exception/PolicyLengthExceededException.php new file mode 100644 index 0000000..de44736 --- /dev/null +++ b/src/Exception/PolicyLengthExceededException.php @@ -0,0 +1,31 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/PreconditionFailedException.php b/src/Exception/PreconditionFailedException.php new file mode 100644 index 0000000..1798922 --- /dev/null +++ b/src/Exception/PreconditionFailedException.php @@ -0,0 +1,36 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/RecursiveInvocationException.php b/src/Exception/RecursiveInvocationException.php new file mode 100644 index 0000000..67152ef --- /dev/null +++ b/src/Exception/RecursiveInvocationException.php @@ -0,0 +1,32 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/RequestTooLargeException.php b/src/Exception/RequestTooLargeException.php new file mode 100644 index 0000000..d02dc8e --- /dev/null +++ b/src/Exception/RequestTooLargeException.php @@ -0,0 +1,32 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/ResourceConflictException.php b/src/Exception/ResourceConflictException.php new file mode 100644 index 0000000..bc83873 --- /dev/null +++ b/src/Exception/ResourceConflictException.php @@ -0,0 +1,31 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/ResourceNotFoundException.php b/src/Exception/ResourceNotFoundException.php new file mode 100644 index 0000000..dc1de9b --- /dev/null +++ b/src/Exception/ResourceNotFoundException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/ResourceNotReadyException.php b/src/Exception/ResourceNotReadyException.php new file mode 100644 index 0000000..083a06f --- /dev/null +++ b/src/Exception/ResourceNotReadyException.php @@ -0,0 +1,32 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/ServiceException.php b/src/Exception/ServiceException.php new file mode 100644 index 0000000..909f82c --- /dev/null +++ b/src/Exception/ServiceException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/SnapStartException.php b/src/Exception/SnapStartException.php new file mode 100644 index 0000000..dbfbed1 --- /dev/null +++ b/src/Exception/SnapStartException.php @@ -0,0 +1,31 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/SnapStartNotReadyException.php b/src/Exception/SnapStartNotReadyException.php new file mode 100644 index 0000000..988875d --- /dev/null +++ b/src/Exception/SnapStartNotReadyException.php @@ -0,0 +1,31 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/SnapStartTimeoutException.php b/src/Exception/SnapStartTimeoutException.php new file mode 100644 index 0000000..edba4d3 --- /dev/null +++ b/src/Exception/SnapStartTimeoutException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/SubnetIPAddressLimitReachedException.php b/src/Exception/SubnetIPAddressLimitReachedException.php new file mode 100644 index 0000000..9038733 --- /dev/null +++ b/src/Exception/SubnetIPAddressLimitReachedException.php @@ -0,0 +1,30 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Exception/TooManyRequestsException.php b/src/Exception/TooManyRequestsException.php new file mode 100644 index 0000000..06fc6b6 --- /dev/null +++ b/src/Exception/TooManyRequestsException.php @@ -0,0 +1,62 @@ +reason; + } + + public function getRetryAfterSeconds(): ?string + { + return $this->retryAfterSeconds; + } + + public function getType(): ?string + { + return $this->type; + } + + protected function populateResult(ResponseInterface $response): void + { + $headers = $response->getHeaders(); + + $this->retryAfterSeconds = $headers['retry-after'][0] ?? null; + + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + $this->reason = isset($data['Reason']) ? (string) $data['Reason'] : null; + } +} diff --git a/src/Exception/UnsupportedMediaTypeException.php b/src/Exception/UnsupportedMediaTypeException.php new file mode 100644 index 0000000..a78f708 --- /dev/null +++ b/src/Exception/UnsupportedMediaTypeException.php @@ -0,0 +1,29 @@ +type; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->type = isset($data['Type']) ? (string) $data['Type'] : null; + } +} diff --git a/src/Input/AddLayerVersionPermissionRequest.php b/src/Input/AddLayerVersionPermissionRequest.php index ec2aaf8..ecb7161 100644 --- a/src/Input/AddLayerVersionPermissionRequest.php +++ b/src/Input/AddLayerVersionPermissionRequest.php @@ -16,16 +16,16 @@ final class AddLayerVersionPermissionRequest extends Input * * @var string|null */ - private $LayerName; + private $layerName; /** * The version number. * * @required * - * @var string|null + * @var int|null */ - private $VersionNumber; + private $versionNumber; /** * An identifier that distinguishes the policy from others on the same layer version. @@ -34,7 +34,7 @@ final class AddLayerVersionPermissionRequest extends Input * * @var string|null */ - private $StatementId; + private $statementId; /** * The API action that grants access to the layer. For example, `lambda:GetLayerVersion`. @@ -43,23 +43,25 @@ final class AddLayerVersionPermissionRequest extends Input * * @var string|null */ - private $Action; + private $action; /** - * An account ID, or `*` to grant permission to all AWS accounts. + * An account ID, or `*` to grant layer usage permission to all accounts in an organization, or all Amazon Web Services + * accounts (if `organizationId` is not specified). For the last case, make sure that you really do want all Amazon Web + * Services accounts to have usage permission to this layer. * * @required * * @var string|null */ - private $Principal; + private $principal; /** * With the principal set to `*`, grant permission to all accounts in the specified organization. * * @var string|null */ - private $OrganizationId; + private $organizationId; /** * Only update the policy if the revision ID matches the ID specified. Use this option to avoid modifying a policy that @@ -67,32 +69,44 @@ final class AddLayerVersionPermissionRequest extends Input * * @var string|null */ - private $RevisionId; + private $revisionId; /** * @param array{ * LayerName?: string, - * VersionNumber?: string, + * VersionNumber?: int, * StatementId?: string, * Action?: string, * Principal?: string, - * OrganizationId?: string, - * RevisionId?: string, - * @region?: string, + * OrganizationId?: null|string, + * RevisionId?: null|string, + * '@region'?: string|null, * } $input */ public function __construct(array $input = []) { - $this->LayerName = $input['LayerName'] ?? null; - $this->VersionNumber = $input['VersionNumber'] ?? null; - $this->StatementId = $input['StatementId'] ?? null; - $this->Action = $input['Action'] ?? null; - $this->Principal = $input['Principal'] ?? null; - $this->OrganizationId = $input['OrganizationId'] ?? null; - $this->RevisionId = $input['RevisionId'] ?? null; + $this->layerName = $input['LayerName'] ?? null; + $this->versionNumber = $input['VersionNumber'] ?? null; + $this->statementId = $input['StatementId'] ?? null; + $this->action = $input['Action'] ?? null; + $this->principal = $input['Principal'] ?? null; + $this->organizationId = $input['OrganizationId'] ?? null; + $this->revisionId = $input['RevisionId'] ?? null; parent::__construct($input); } + /** + * @param array{ + * LayerName?: string, + * VersionNumber?: int, + * StatementId?: string, + * Action?: string, + * Principal?: string, + * OrganizationId?: null|string, + * RevisionId?: null|string, + * '@region'?: string|null, + * }|AddLayerVersionPermissionRequest $input + */ public static function create($input): self { return $input instanceof self ? $input : new self($input); @@ -100,37 +114,37 @@ public static function create($input): self public function getAction(): ?string { - return $this->Action; + return $this->action; } public function getLayerName(): ?string { - return $this->LayerName; + return $this->layerName; } public function getOrganizationId(): ?string { - return $this->OrganizationId; + return $this->organizationId; } public function getPrincipal(): ?string { - return $this->Principal; + return $this->principal; } public function getRevisionId(): ?string { - return $this->RevisionId; + return $this->revisionId; } public function getStatementId(): ?string { - return $this->StatementId; + return $this->statementId; } - public function getVersionNumber(): ?string + public function getVersionNumber(): ?int { - return $this->VersionNumber; + return $this->versionNumber; } /** @@ -139,29 +153,32 @@ public function getVersionNumber(): ?string public function request(): Request { // Prepare headers - $headers = ['content-type' => 'application/json']; + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; // Prepare query $query = []; - if (null !== $this->RevisionId) { - $query['RevisionId'] = $this->RevisionId; + if (null !== $this->revisionId) { + $query['RevisionId'] = $this->revisionId; } // Prepare URI $uri = []; - if (null === $v = $this->LayerName) { - throw new InvalidArgument(sprintf('Missing parameter "LayerName" for "%s". The value cannot be null.', __CLASS__)); + if (null === $v = $this->layerName) { + throw new InvalidArgument(\sprintf('Missing parameter "LayerName" for "%s". The value cannot be null.', __CLASS__)); } $uri['LayerName'] = $v; - if (null === $v = $this->VersionNumber) { - throw new InvalidArgument(sprintf('Missing parameter "VersionNumber" for "%s". The value cannot be null.', __CLASS__)); + if (null === $v = $this->versionNumber) { + throw new InvalidArgument(\sprintf('Missing parameter "VersionNumber" for "%s". The value cannot be null.', __CLASS__)); } - $uri['VersionNumber'] = $v; + $uri['VersionNumber'] = (string) $v; $uriString = '/2018-10-31/layers/' . rawurlencode($uri['LayerName']) . '/versions/' . rawurlencode($uri['VersionNumber']) . '/policy'; // Prepare Body $bodyPayload = $this->requestBody(); - $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); // Return the Request return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); @@ -169,49 +186,49 @@ public function request(): Request public function setAction(?string $value): self { - $this->Action = $value; + $this->action = $value; return $this; } public function setLayerName(?string $value): self { - $this->LayerName = $value; + $this->layerName = $value; return $this; } public function setOrganizationId(?string $value): self { - $this->OrganizationId = $value; + $this->organizationId = $value; return $this; } public function setPrincipal(?string $value): self { - $this->Principal = $value; + $this->principal = $value; return $this; } public function setRevisionId(?string $value): self { - $this->RevisionId = $value; + $this->revisionId = $value; return $this; } public function setStatementId(?string $value): self { - $this->StatementId = $value; + $this->statementId = $value; return $this; } - public function setVersionNumber(?string $value): self + public function setVersionNumber(?int $value): self { - $this->VersionNumber = $value; + $this->versionNumber = $value; return $this; } @@ -220,19 +237,19 @@ private function requestBody(): array { $payload = []; - if (null === $v = $this->StatementId) { - throw new InvalidArgument(sprintf('Missing parameter "StatementId" for "%s". The value cannot be null.', __CLASS__)); + if (null === $v = $this->statementId) { + throw new InvalidArgument(\sprintf('Missing parameter "StatementId" for "%s". The value cannot be null.', __CLASS__)); } $payload['StatementId'] = $v; - if (null === $v = $this->Action) { - throw new InvalidArgument(sprintf('Missing parameter "Action" for "%s". The value cannot be null.', __CLASS__)); + if (null === $v = $this->action) { + throw new InvalidArgument(\sprintf('Missing parameter "Action" for "%s". The value cannot be null.', __CLASS__)); } $payload['Action'] = $v; - if (null === $v = $this->Principal) { - throw new InvalidArgument(sprintf('Missing parameter "Principal" for "%s". The value cannot be null.', __CLASS__)); + if (null === $v = $this->principal) { + throw new InvalidArgument(\sprintf('Missing parameter "Principal" for "%s". The value cannot be null.', __CLASS__)); } $payload['Principal'] = $v; - if (null !== $v = $this->OrganizationId) { + if (null !== $v = $this->organizationId) { $payload['OrganizationId'] = $v; } diff --git a/src/Input/DeleteFunctionRequest.php b/src/Input/DeleteFunctionRequest.php new file mode 100644 index 0000000..4dd1047 --- /dev/null +++ b/src/Input/DeleteFunctionRequest.php @@ -0,0 +1,118 @@ +functionName = $input['FunctionName'] ?? null; + $this->qualifier = $input['Qualifier'] ?? null; + parent::__construct($input); + } + + /** + * @param array{ + * FunctionName?: string, + * Qualifier?: null|string, + * '@region'?: string|null, + * }|DeleteFunctionRequest $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getFunctionName(): ?string + { + return $this->functionName; + } + + public function getQualifier(): ?string + { + return $this->qualifier; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; + + // Prepare query + $query = []; + if (null !== $this->qualifier) { + $query['Qualifier'] = $this->qualifier; + } + + // Prepare URI + $uri = []; + if (null === $v = $this->functionName) { + throw new InvalidArgument(\sprintf('Missing parameter "FunctionName" for "%s". The value cannot be null.', __CLASS__)); + } + $uri['FunctionName'] = $v; + $uriString = '/2015-03-31/functions/' . rawurlencode($uri['FunctionName']); + + // Prepare Body + $body = ''; + + // Return the Request + return new Request('DELETE', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setFunctionName(?string $value): self + { + $this->functionName = $value; + + return $this; + } + + public function setQualifier(?string $value): self + { + $this->qualifier = $value; + + return $this; + } +} diff --git a/src/Input/GetFunctionConfigurationRequest.php b/src/Input/GetFunctionConfigurationRequest.php new file mode 100644 index 0000000..55d0c1e --- /dev/null +++ b/src/Input/GetFunctionConfigurationRequest.php @@ -0,0 +1,118 @@ +functionName = $input['FunctionName'] ?? null; + $this->qualifier = $input['Qualifier'] ?? null; + parent::__construct($input); + } + + /** + * @param array{ + * FunctionName?: string, + * Qualifier?: null|string, + * '@region'?: string|null, + * }|GetFunctionConfigurationRequest $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getFunctionName(): ?string + { + return $this->functionName; + } + + public function getQualifier(): ?string + { + return $this->qualifier; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; + + // Prepare query + $query = []; + if (null !== $this->qualifier) { + $query['Qualifier'] = $this->qualifier; + } + + // Prepare URI + $uri = []; + if (null === $v = $this->functionName) { + throw new InvalidArgument(\sprintf('Missing parameter "FunctionName" for "%s". The value cannot be null.', __CLASS__)); + } + $uri['FunctionName'] = $v; + $uriString = '/2015-03-31/functions/' . rawurlencode($uri['FunctionName']) . '/configuration'; + + // Prepare Body + $body = ''; + + // Return the Request + return new Request('GET', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setFunctionName(?string $value): self + { + $this->functionName = $value; + + return $this; + } + + public function setQualifier(?string $value): self + { + $this->qualifier = $value; + + return $this; + } +} diff --git a/src/Input/InvocationRequest.php b/src/Input/InvocationRequest.php index b56b4b0..551e46a 100644 --- a/src/Input/InvocationRequest.php +++ b/src/Input/InvocationRequest.php @@ -12,71 +12,101 @@ final class InvocationRequest extends Input { /** - * The name of the Lambda function, version, or alias. + * The name or ARN of the Lambda function, version, or alias. + * + * **Name formats** + * + * - **Function name** – `my-function` (name-only), `my-function:v1` (with alias). + * - **Function ARN** – `arn:aws:lambda:us-west-2:123456789012:function:my-function`. + * - **Partial ARN** – `123456789012:function:my-function`. + * + * You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. + * If you specify only the function name, it is limited to 64 characters in length. * * @required * * @var string|null */ - private $FunctionName; + private $functionName; /** * Choose from the following options. * - * @var null|InvocationType::* + * - `RequestResponse` (default) – Invoke the function synchronously. Keep the connection open until the function + * returns a response or times out. The API response includes the function response and additional data. + * - `Event` – Invoke the function asynchronously. Send events that fail multiple times to the function's dead-letter + * queue (if one is configured). The API response only includes a status code. + * - `DryRun` – Validate parameter values and verify that the user or role has permission to invoke the function. + * + * @var InvocationType::*|null */ - private $InvocationType; + private $invocationType; /** - * Set to `Tail` to include the execution log in the response. + * Set to `Tail` to include the execution log in the response. Applies to synchronously invoked functions only. * - * @var null|LogType::* + * @var LogType::*|null */ - private $LogType; + private $logType; /** - * Up to 3583 bytes of base64-encoded data about the invoking client to pass to the function in the context object. + * Up to 3,583 bytes of base64-encoded data about the invoking client to pass to the function in the context object. + * Lambda passes the `ClientContext` object to your function for synchronous invocations only. * * @var string|null */ - private $ClientContext; + private $clientContext; /** * The JSON that you want to provide to your Lambda function as input. * + * You can enter the JSON directly. For example, `--payload '{ "key": "value" }'`. You can also specify a file path. For + * example, `--payload file://payload.json`. + * * @var string|null */ - private $Payload; + private $payload; /** * Specify a version or alias to invoke a published version of the function. * * @var string|null */ - private $Qualifier; + private $qualifier; /** * @param array{ * FunctionName?: string, - * InvocationType?: InvocationType::*, - * LogType?: LogType::*, - * ClientContext?: string, - * Payload?: string, - * Qualifier?: string, - * @region?: string, + * InvocationType?: null|InvocationType::*, + * LogType?: null|LogType::*, + * ClientContext?: null|string, + * Payload?: null|string, + * Qualifier?: null|string, + * '@region'?: string|null, * } $input */ public function __construct(array $input = []) { - $this->FunctionName = $input['FunctionName'] ?? null; - $this->InvocationType = $input['InvocationType'] ?? null; - $this->LogType = $input['LogType'] ?? null; - $this->ClientContext = $input['ClientContext'] ?? null; - $this->Payload = $input['Payload'] ?? null; - $this->Qualifier = $input['Qualifier'] ?? null; + $this->functionName = $input['FunctionName'] ?? null; + $this->invocationType = $input['InvocationType'] ?? null; + $this->logType = $input['LogType'] ?? null; + $this->clientContext = $input['ClientContext'] ?? null; + $this->payload = $input['Payload'] ?? null; + $this->qualifier = $input['Qualifier'] ?? null; parent::__construct($input); } + /** + * @param array{ + * FunctionName?: string, + * InvocationType?: null|InvocationType::*, + * LogType?: null|LogType::*, + * ClientContext?: null|string, + * Payload?: null|string, + * Qualifier?: null|string, + * '@region'?: string|null, + * }|InvocationRequest $input + */ public static function create($input): self { return $input instanceof self ? $input : new self($input); @@ -84,12 +114,12 @@ public static function create($input): self public function getClientContext(): ?string { - return $this->ClientContext; + return $this->clientContext; } public function getFunctionName(): ?string { - return $this->FunctionName; + return $this->functionName; } /** @@ -97,7 +127,7 @@ public function getFunctionName(): ?string */ public function getInvocationType(): ?string { - return $this->InvocationType; + return $this->invocationType; } /** @@ -105,17 +135,17 @@ public function getInvocationType(): ?string */ public function getLogType(): ?string { - return $this->LogType; + return $this->logType; } public function getPayload(): ?string { - return $this->Payload; + return $this->payload; } public function getQualifier(): ?string { - return $this->Qualifier; + return $this->qualifier; } /** @@ -124,39 +154,42 @@ public function getQualifier(): ?string public function request(): Request { // Prepare headers - $headers = ['content-type' => 'application/json']; - if (null !== $this->InvocationType) { - if (!InvocationType::exists($this->InvocationType)) { - throw new InvalidArgument(sprintf('Invalid parameter "InvocationType" for "%s". The value "%s" is not a valid "InvocationType".', __CLASS__, $this->InvocationType)); + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; + if (null !== $this->invocationType) { + if (!InvocationType::exists($this->invocationType)) { + throw new InvalidArgument(\sprintf('Invalid parameter "InvocationType" for "%s". The value "%s" is not a valid "InvocationType".', __CLASS__, $this->invocationType)); } - $headers['X-Amz-Invocation-Type'] = $this->InvocationType; + $headers['X-Amz-Invocation-Type'] = $this->invocationType; } - if (null !== $this->LogType) { - if (!LogType::exists($this->LogType)) { - throw new InvalidArgument(sprintf('Invalid parameter "LogType" for "%s". The value "%s" is not a valid "LogType".', __CLASS__, $this->LogType)); + if (null !== $this->logType) { + if (!LogType::exists($this->logType)) { + throw new InvalidArgument(\sprintf('Invalid parameter "LogType" for "%s". The value "%s" is not a valid "LogType".', __CLASS__, $this->logType)); } - $headers['X-Amz-Log-Type'] = $this->LogType; + $headers['X-Amz-Log-Type'] = $this->logType; } - if (null !== $this->ClientContext) { - $headers['X-Amz-Client-Context'] = $this->ClientContext; + if (null !== $this->clientContext) { + $headers['X-Amz-Client-Context'] = $this->clientContext; } // Prepare query $query = []; - if (null !== $this->Qualifier) { - $query['Qualifier'] = $this->Qualifier; + if (null !== $this->qualifier) { + $query['Qualifier'] = $this->qualifier; } // Prepare URI $uri = []; - if (null === $v = $this->FunctionName) { - throw new InvalidArgument(sprintf('Missing parameter "FunctionName" for "%s". The value cannot be null.', __CLASS__)); + if (null === $v = $this->functionName) { + throw new InvalidArgument(\sprintf('Missing parameter "FunctionName" for "%s". The value cannot be null.', __CLASS__)); } $uri['FunctionName'] = $v; $uriString = '/2015-03-31/functions/' . rawurlencode($uri['FunctionName']) . '/invocations'; // Prepare Body - $body = $this->Payload ?? ''; + $body = $this->payload ?? ''; // Return the Request return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); @@ -164,14 +197,14 @@ public function request(): Request public function setClientContext(?string $value): self { - $this->ClientContext = $value; + $this->clientContext = $value; return $this; } public function setFunctionName(?string $value): self { - $this->FunctionName = $value; + $this->functionName = $value; return $this; } @@ -181,7 +214,7 @@ public function setFunctionName(?string $value): self */ public function setInvocationType(?string $value): self { - $this->InvocationType = $value; + $this->invocationType = $value; return $this; } @@ -191,21 +224,21 @@ public function setInvocationType(?string $value): self */ public function setLogType(?string $value): self { - $this->LogType = $value; + $this->logType = $value; return $this; } public function setPayload(?string $value): self { - $this->Payload = $value; + $this->payload = $value; return $this; } public function setQualifier(?string $value): self { - $this->Qualifier = $value; + $this->qualifier = $value; return $this; } diff --git a/src/Input/ListFunctionsRequest.php b/src/Input/ListFunctionsRequest.php new file mode 100644 index 0000000..da199a5 --- /dev/null +++ b/src/Input/ListFunctionsRequest.php @@ -0,0 +1,168 @@ +masterRegion = $input['MasterRegion'] ?? null; + $this->functionVersion = $input['FunctionVersion'] ?? null; + $this->marker = $input['Marker'] ?? null; + $this->maxItems = $input['MaxItems'] ?? null; + parent::__construct($input); + } + + /** + * @param array{ + * MasterRegion?: null|string, + * FunctionVersion?: null|FunctionVersion::*, + * Marker?: null|string, + * MaxItems?: null|int, + * '@region'?: string|null, + * }|ListFunctionsRequest $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return FunctionVersion::*|null + */ + public function getFunctionVersion(): ?string + { + return $this->functionVersion; + } + + public function getMarker(): ?string + { + return $this->marker; + } + + public function getMasterRegion(): ?string + { + return $this->masterRegion; + } + + public function getMaxItems(): ?int + { + return $this->maxItems; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; + + // Prepare query + $query = []; + if (null !== $this->masterRegion) { + $query['MasterRegion'] = $this->masterRegion; + } + if (null !== $this->functionVersion) { + if (!FunctionVersion::exists($this->functionVersion)) { + throw new InvalidArgument(\sprintf('Invalid parameter "FunctionVersion" for "%s". The value "%s" is not a valid "FunctionVersion".', __CLASS__, $this->functionVersion)); + } + $query['FunctionVersion'] = $this->functionVersion; + } + if (null !== $this->marker) { + $query['Marker'] = $this->marker; + } + if (null !== $this->maxItems) { + $query['MaxItems'] = (string) $this->maxItems; + } + + // Prepare URI + $uriString = '/2015-03-31/functions/'; + + // Prepare Body + $body = ''; + + // Return the Request + return new Request('GET', $uriString, $query, $headers, StreamFactory::create($body)); + } + + /** + * @param FunctionVersion::*|null $value + */ + public function setFunctionVersion(?string $value): self + { + $this->functionVersion = $value; + + return $this; + } + + public function setMarker(?string $value): self + { + $this->marker = $value; + + return $this; + } + + public function setMasterRegion(?string $value): self + { + $this->masterRegion = $value; + + return $this; + } + + public function setMaxItems(?int $value): self + { + $this->maxItems = $value; + + return $this; + } +} diff --git a/src/Input/ListLayerVersionsRequest.php b/src/Input/ListLayerVersionsRequest.php index 8dd92fa..e524355 100644 --- a/src/Input/ListLayerVersionsRequest.php +++ b/src/Input/ListLayerVersionsRequest.php @@ -6,16 +6,24 @@ use AsyncAws\Core\Input; use AsyncAws\Core\Request; use AsyncAws\Core\Stream\StreamFactory; +use AsyncAws\Lambda\Enum\Architecture; use AsyncAws\Lambda\Enum\Runtime; final class ListLayerVersionsRequest extends Input { /** - * A runtime identifier. For example, `go1.x`. + * A runtime identifier. * - * @var null|Runtime::* + * The following list includes deprecated runtimes. For more information, see Runtime use after deprecation [^1]. + * + * For a list of all currently supported runtimes, see Supported runtimes [^2]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtime-deprecation-levels + * [^2]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtimes-supported + * + * @var Runtime::*|null */ - private $CompatibleRuntime; + private $compatibleRuntime; /** * The name or Amazon Resource Name (ARN) of the layer. @@ -24,66 +32,95 @@ final class ListLayerVersionsRequest extends Input * * @var string|null */ - private $LayerName; + private $layerName; /** * A pagination token returned by a previous call. * * @var string|null */ - private $Marker; + private $marker; /** * The maximum number of versions to return. * * @var int|null */ - private $MaxItems; + private $maxItems; + + /** + * The compatible instruction set architecture [^1]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html + * + * @var Architecture::*|null + */ + private $compatibleArchitecture; /** * @param array{ - * CompatibleRuntime?: Runtime::*, + * CompatibleRuntime?: null|Runtime::*, * LayerName?: string, - * Marker?: string, - * MaxItems?: int, - * @region?: string, + * Marker?: null|string, + * MaxItems?: null|int, + * CompatibleArchitecture?: null|Architecture::*, + * '@region'?: string|null, * } $input */ public function __construct(array $input = []) { - $this->CompatibleRuntime = $input['CompatibleRuntime'] ?? null; - $this->LayerName = $input['LayerName'] ?? null; - $this->Marker = $input['Marker'] ?? null; - $this->MaxItems = $input['MaxItems'] ?? null; + $this->compatibleRuntime = $input['CompatibleRuntime'] ?? null; + $this->layerName = $input['LayerName'] ?? null; + $this->marker = $input['Marker'] ?? null; + $this->maxItems = $input['MaxItems'] ?? null; + $this->compatibleArchitecture = $input['CompatibleArchitecture'] ?? null; parent::__construct($input); } + /** + * @param array{ + * CompatibleRuntime?: null|Runtime::*, + * LayerName?: string, + * Marker?: null|string, + * MaxItems?: null|int, + * CompatibleArchitecture?: null|Architecture::*, + * '@region'?: string|null, + * }|ListLayerVersionsRequest $input + */ public static function create($input): self { return $input instanceof self ? $input : new self($input); } + /** + * @return Architecture::*|null + */ + public function getCompatibleArchitecture(): ?string + { + return $this->compatibleArchitecture; + } + /** * @return Runtime::*|null */ public function getCompatibleRuntime(): ?string { - return $this->CompatibleRuntime; + return $this->compatibleRuntime; } public function getLayerName(): ?string { - return $this->LayerName; + return $this->layerName; } public function getMarker(): ?string { - return $this->Marker; + return $this->marker; } public function getMaxItems(): ?int { - return $this->MaxItems; + return $this->maxItems; } /** @@ -92,27 +129,36 @@ public function getMaxItems(): ?int public function request(): Request { // Prepare headers - $headers = ['content-type' => 'application/json']; + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; // Prepare query $query = []; - if (null !== $this->CompatibleRuntime) { - if (!Runtime::exists($this->CompatibleRuntime)) { - throw new InvalidArgument(sprintf('Invalid parameter "CompatibleRuntime" for "%s". The value "%s" is not a valid "Runtime".', __CLASS__, $this->CompatibleRuntime)); + if (null !== $this->compatibleRuntime) { + if (!Runtime::exists($this->compatibleRuntime)) { + throw new InvalidArgument(\sprintf('Invalid parameter "CompatibleRuntime" for "%s". The value "%s" is not a valid "Runtime".', __CLASS__, $this->compatibleRuntime)); } - $query['CompatibleRuntime'] = $this->CompatibleRuntime; + $query['CompatibleRuntime'] = $this->compatibleRuntime; } - if (null !== $this->Marker) { - $query['Marker'] = $this->Marker; + if (null !== $this->marker) { + $query['Marker'] = $this->marker; } - if (null !== $this->MaxItems) { - $query['MaxItems'] = (string) $this->MaxItems; + if (null !== $this->maxItems) { + $query['MaxItems'] = (string) $this->maxItems; + } + if (null !== $this->compatibleArchitecture) { + if (!Architecture::exists($this->compatibleArchitecture)) { + throw new InvalidArgument(\sprintf('Invalid parameter "CompatibleArchitecture" for "%s". The value "%s" is not a valid "Architecture".', __CLASS__, $this->compatibleArchitecture)); + } + $query['CompatibleArchitecture'] = $this->compatibleArchitecture; } // Prepare URI $uri = []; - if (null === $v = $this->LayerName) { - throw new InvalidArgument(sprintf('Missing parameter "LayerName" for "%s". The value cannot be null.', __CLASS__)); + if (null === $v = $this->layerName) { + throw new InvalidArgument(\sprintf('Missing parameter "LayerName" for "%s". The value cannot be null.', __CLASS__)); } $uri['LayerName'] = $v; $uriString = '/2018-10-31/layers/' . rawurlencode($uri['LayerName']) . '/versions'; @@ -124,33 +170,43 @@ public function request(): Request return new Request('GET', $uriString, $query, $headers, StreamFactory::create($body)); } + /** + * @param Architecture::*|null $value + */ + public function setCompatibleArchitecture(?string $value): self + { + $this->compatibleArchitecture = $value; + + return $this; + } + /** * @param Runtime::*|null $value */ public function setCompatibleRuntime(?string $value): self { - $this->CompatibleRuntime = $value; + $this->compatibleRuntime = $value; return $this; } public function setLayerName(?string $value): self { - $this->LayerName = $value; + $this->layerName = $value; return $this; } public function setMarker(?string $value): self { - $this->Marker = $value; + $this->marker = $value; return $this; } public function setMaxItems(?int $value): self { - $this->MaxItems = $value; + $this->maxItems = $value; return $this; } diff --git a/src/Input/ListVersionsByFunctionRequest.php b/src/Input/ListVersionsByFunctionRequest.php new file mode 100644 index 0000000..c2d886f --- /dev/null +++ b/src/Input/ListVersionsByFunctionRequest.php @@ -0,0 +1,144 @@ +functionName = $input['FunctionName'] ?? null; + $this->marker = $input['Marker'] ?? null; + $this->maxItems = $input['MaxItems'] ?? null; + parent::__construct($input); + } + + /** + * @param array{ + * FunctionName?: string, + * Marker?: null|string, + * MaxItems?: null|int, + * '@region'?: string|null, + * }|ListVersionsByFunctionRequest $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getFunctionName(): ?string + { + return $this->functionName; + } + + public function getMarker(): ?string + { + return $this->marker; + } + + public function getMaxItems(): ?int + { + return $this->maxItems; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; + + // Prepare query + $query = []; + if (null !== $this->marker) { + $query['Marker'] = $this->marker; + } + if (null !== $this->maxItems) { + $query['MaxItems'] = (string) $this->maxItems; + } + + // Prepare URI + $uri = []; + if (null === $v = $this->functionName) { + throw new InvalidArgument(\sprintf('Missing parameter "FunctionName" for "%s". The value cannot be null.', __CLASS__)); + } + $uri['FunctionName'] = $v; + $uriString = '/2015-03-31/functions/' . rawurlencode($uri['FunctionName']) . '/versions'; + + // Prepare Body + $body = ''; + + // Return the Request + return new Request('GET', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setFunctionName(?string $value): self + { + $this->functionName = $value; + + return $this; + } + + public function setMarker(?string $value): self + { + $this->marker = $value; + + return $this; + } + + public function setMaxItems(?int $value): self + { + $this->maxItems = $value; + + return $this; + } +} diff --git a/src/Input/PublishLayerVersionRequest.php b/src/Input/PublishLayerVersionRequest.php index f32acc6..e846041 100644 --- a/src/Input/PublishLayerVersionRequest.php +++ b/src/Input/PublishLayerVersionRequest.php @@ -6,6 +6,7 @@ use AsyncAws\Core\Input; use AsyncAws\Core\Request; use AsyncAws\Core\Stream\StreamFactory; +use AsyncAws\Lambda\Enum\Architecture; use AsyncAws\Lambda\Enum\Runtime; use AsyncAws\Lambda\ValueObject\LayerVersionContentInput; @@ -18,14 +19,14 @@ final class PublishLayerVersionRequest extends Input * * @var string|null */ - private $LayerName; + private $layerName; /** * The description of the version. * * @var string|null */ - private $Description; + private $description; /** * The function layer archive. @@ -34,75 +35,114 @@ final class PublishLayerVersionRequest extends Input * * @var LayerVersionContentInput|null */ - private $Content; + private $content; /** - * A list of compatible function runtimes. Used for filtering with ListLayers and ListLayerVersions. + * A list of compatible function runtimes [^1]. Used for filtering with ListLayers and ListLayerVersions. * - * @see https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html + * The following list includes deprecated runtimes. For more information, see Runtime deprecation policy [^2]. * - * @var null|list + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html + * [^2]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtime-support-policy + * + * @var list|null */ - private $CompatibleRuntimes; + private $compatibleRuntimes; /** - * The layer's software license. It can be any of the following:. + * The layer's software license. It can be any of the following: + * + * - An SPDX license identifier [^1]. For example, `MIT`. + * - The URL of a license hosted on the internet. For example, `https://opensource.org/licenses/MIT`. + * - The full text of the license. + * + * [^1]: https://spdx.org/licenses/ * * @var string|null */ - private $LicenseInfo; + private $licenseInfo; + + /** + * A list of compatible instruction set architectures [^1]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html + * + * @var list|null + */ + private $compatibleArchitectures; /** * @param array{ * LayerName?: string, - * Description?: string, + * Description?: null|string, * Content?: LayerVersionContentInput|array, - * CompatibleRuntimes?: list, - * LicenseInfo?: string, - * @region?: string, + * CompatibleRuntimes?: null|array, + * LicenseInfo?: null|string, + * CompatibleArchitectures?: null|array, + * '@region'?: string|null, * } $input */ public function __construct(array $input = []) { - $this->LayerName = $input['LayerName'] ?? null; - $this->Description = $input['Description'] ?? null; - $this->Content = isset($input['Content']) ? LayerVersionContentInput::create($input['Content']) : null; - $this->CompatibleRuntimes = $input['CompatibleRuntimes'] ?? null; - $this->LicenseInfo = $input['LicenseInfo'] ?? null; + $this->layerName = $input['LayerName'] ?? null; + $this->description = $input['Description'] ?? null; + $this->content = isset($input['Content']) ? LayerVersionContentInput::create($input['Content']) : null; + $this->compatibleRuntimes = $input['CompatibleRuntimes'] ?? null; + $this->licenseInfo = $input['LicenseInfo'] ?? null; + $this->compatibleArchitectures = $input['CompatibleArchitectures'] ?? null; parent::__construct($input); } + /** + * @param array{ + * LayerName?: string, + * Description?: null|string, + * Content?: LayerVersionContentInput|array, + * CompatibleRuntimes?: null|array, + * LicenseInfo?: null|string, + * CompatibleArchitectures?: null|array, + * '@region'?: string|null, + * }|PublishLayerVersionRequest $input + */ public static function create($input): self { return $input instanceof self ? $input : new self($input); } + /** + * @return list + */ + public function getCompatibleArchitectures(): array + { + return $this->compatibleArchitectures ?? []; + } + /** * @return list */ public function getCompatibleRuntimes(): array { - return $this->CompatibleRuntimes ?? []; + return $this->compatibleRuntimes ?? []; } public function getContent(): ?LayerVersionContentInput { - return $this->Content; + return $this->content; } public function getDescription(): ?string { - return $this->Description; + return $this->description; } public function getLayerName(): ?string { - return $this->LayerName; + return $this->layerName; } public function getLicenseInfo(): ?string { - return $this->LicenseInfo; + return $this->licenseInfo; } /** @@ -111,61 +151,74 @@ public function getLicenseInfo(): ?string public function request(): Request { // Prepare headers - $headers = ['content-type' => 'application/json']; + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; // Prepare query $query = []; // Prepare URI $uri = []; - if (null === $v = $this->LayerName) { - throw new InvalidArgument(sprintf('Missing parameter "LayerName" for "%s". The value cannot be null.', __CLASS__)); + if (null === $v = $this->layerName) { + throw new InvalidArgument(\sprintf('Missing parameter "LayerName" for "%s". The value cannot be null.', __CLASS__)); } $uri['LayerName'] = $v; $uriString = '/2018-10-31/layers/' . rawurlencode($uri['LayerName']) . '/versions'; // Prepare Body $bodyPayload = $this->requestBody(); - $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); // Return the Request return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); } + /** + * @param list $value + */ + public function setCompatibleArchitectures(array $value): self + { + $this->compatibleArchitectures = $value; + + return $this; + } + /** * @param list $value */ public function setCompatibleRuntimes(array $value): self { - $this->CompatibleRuntimes = $value; + $this->compatibleRuntimes = $value; return $this; } public function setContent(?LayerVersionContentInput $value): self { - $this->Content = $value; + $this->content = $value; return $this; } public function setDescription(?string $value): self { - $this->Description = $value; + $this->description = $value; return $this; } public function setLayerName(?string $value): self { - $this->LayerName = $value; + $this->layerName = $value; return $this; } public function setLicenseInfo(?string $value): self { - $this->LicenseInfo = $value; + $this->licenseInfo = $value; return $this; } @@ -174,27 +227,38 @@ private function requestBody(): array { $payload = []; - if (null !== $v = $this->Description) { + if (null !== $v = $this->description) { $payload['Description'] = $v; } - if (null === $v = $this->Content) { - throw new InvalidArgument(sprintf('Missing parameter "Content" for "%s". The value cannot be null.', __CLASS__)); + if (null === $v = $this->content) { + throw new InvalidArgument(\sprintf('Missing parameter "Content" for "%s". The value cannot be null.', __CLASS__)); } $payload['Content'] = $v->requestBody(); - if (null !== $v = $this->CompatibleRuntimes) { + if (null !== $v = $this->compatibleRuntimes) { $index = -1; $payload['CompatibleRuntimes'] = []; foreach ($v as $listValue) { ++$index; if (!Runtime::exists($listValue)) { - throw new InvalidArgument(sprintf('Invalid parameter "CompatibleRuntimes" for "%s". The value "%s" is not a valid "Runtime".', __CLASS__, $listValue)); + throw new InvalidArgument(\sprintf('Invalid parameter "CompatibleRuntimes" for "%s". The value "%s" is not a valid "Runtime".', __CLASS__, $listValue)); } $payload['CompatibleRuntimes'][$index] = $listValue; } } - if (null !== $v = $this->LicenseInfo) { + if (null !== $v = $this->licenseInfo) { $payload['LicenseInfo'] = $v; } + if (null !== $v = $this->compatibleArchitectures) { + $index = -1; + $payload['CompatibleArchitectures'] = []; + foreach ($v as $listValue) { + ++$index; + if (!Architecture::exists($listValue)) { + throw new InvalidArgument(\sprintf('Invalid parameter "CompatibleArchitectures" for "%s". The value "%s" is not a valid "Architecture".', __CLASS__, $listValue)); + } + $payload['CompatibleArchitectures'][$index] = $listValue; + } + } return $payload; } diff --git a/src/Input/UpdateFunctionConfigurationRequest.php b/src/Input/UpdateFunctionConfigurationRequest.php new file mode 100644 index 0000000..fca09c4 --- /dev/null +++ b/src/Input/UpdateFunctionConfigurationRequest.php @@ -0,0 +1,651 @@ +, + * ImageConfig?: null|ImageConfig|array, + * EphemeralStorage?: null|EphemeralStorage|array, + * SnapStart?: null|SnapStart|array, + * LoggingConfig?: null|LoggingConfig|array, + * '@region'?: string|null, + * } $input + */ + public function __construct(array $input = []) + { + $this->functionName = $input['FunctionName'] ?? null; + $this->role = $input['Role'] ?? null; + $this->handler = $input['Handler'] ?? null; + $this->description = $input['Description'] ?? null; + $this->timeout = $input['Timeout'] ?? null; + $this->memorySize = $input['MemorySize'] ?? null; + $this->vpcConfig = isset($input['VpcConfig']) ? VpcConfig::create($input['VpcConfig']) : null; + $this->environment = isset($input['Environment']) ? Environment::create($input['Environment']) : null; + $this->runtime = $input['Runtime'] ?? null; + $this->deadLetterConfig = isset($input['DeadLetterConfig']) ? DeadLetterConfig::create($input['DeadLetterConfig']) : null; + $this->kmsKeyArn = $input['KMSKeyArn'] ?? null; + $this->tracingConfig = isset($input['TracingConfig']) ? TracingConfig::create($input['TracingConfig']) : null; + $this->revisionId = $input['RevisionId'] ?? null; + $this->layers = $input['Layers'] ?? null; + $this->fileSystemConfigs = isset($input['FileSystemConfigs']) ? array_map([FileSystemConfig::class, 'create'], $input['FileSystemConfigs']) : null; + $this->imageConfig = isset($input['ImageConfig']) ? ImageConfig::create($input['ImageConfig']) : null; + $this->ephemeralStorage = isset($input['EphemeralStorage']) ? EphemeralStorage::create($input['EphemeralStorage']) : null; + $this->snapStart = isset($input['SnapStart']) ? SnapStart::create($input['SnapStart']) : null; + $this->loggingConfig = isset($input['LoggingConfig']) ? LoggingConfig::create($input['LoggingConfig']) : null; + parent::__construct($input); + } + + /** + * @param array{ + * FunctionName?: string, + * Role?: null|string, + * Handler?: null|string, + * Description?: null|string, + * Timeout?: null|int, + * MemorySize?: null|int, + * VpcConfig?: null|VpcConfig|array, + * Environment?: null|Environment|array, + * Runtime?: null|Runtime::*, + * DeadLetterConfig?: null|DeadLetterConfig|array, + * KMSKeyArn?: null|string, + * TracingConfig?: null|TracingConfig|array, + * RevisionId?: null|string, + * Layers?: null|string[], + * FileSystemConfigs?: null|array, + * ImageConfig?: null|ImageConfig|array, + * EphemeralStorage?: null|EphemeralStorage|array, + * SnapStart?: null|SnapStart|array, + * LoggingConfig?: null|LoggingConfig|array, + * '@region'?: string|null, + * }|UpdateFunctionConfigurationRequest $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getDeadLetterConfig(): ?DeadLetterConfig + { + return $this->deadLetterConfig; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function getEnvironment(): ?Environment + { + return $this->environment; + } + + public function getEphemeralStorage(): ?EphemeralStorage + { + return $this->ephemeralStorage; + } + + /** + * @return FileSystemConfig[] + */ + public function getFileSystemConfigs(): array + { + return $this->fileSystemConfigs ?? []; + } + + public function getFunctionName(): ?string + { + return $this->functionName; + } + + public function getHandler(): ?string + { + return $this->handler; + } + + public function getImageConfig(): ?ImageConfig + { + return $this->imageConfig; + } + + public function getKmsKeyArn(): ?string + { + return $this->kmsKeyArn; + } + + /** + * @return string[] + */ + public function getLayers(): array + { + return $this->layers ?? []; + } + + public function getLoggingConfig(): ?LoggingConfig + { + return $this->loggingConfig; + } + + public function getMemorySize(): ?int + { + return $this->memorySize; + } + + public function getRevisionId(): ?string + { + return $this->revisionId; + } + + public function getRole(): ?string + { + return $this->role; + } + + /** + * @return Runtime::*|null + */ + public function getRuntime(): ?string + { + return $this->runtime; + } + + public function getSnapStart(): ?SnapStart + { + return $this->snapStart; + } + + public function getTimeout(): ?int + { + return $this->timeout; + } + + public function getTracingConfig(): ?TracingConfig + { + return $this->tracingConfig; + } + + public function getVpcConfig(): ?VpcConfig + { + return $this->vpcConfig; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uri = []; + if (null === $v = $this->functionName) { + throw new InvalidArgument(\sprintf('Missing parameter "FunctionName" for "%s". The value cannot be null.', __CLASS__)); + } + $uri['FunctionName'] = $v; + $uriString = '/2015-03-31/functions/' . rawurlencode($uri['FunctionName']) . '/configuration'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('PUT', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setDeadLetterConfig(?DeadLetterConfig $value): self + { + $this->deadLetterConfig = $value; + + return $this; + } + + public function setDescription(?string $value): self + { + $this->description = $value; + + return $this; + } + + public function setEnvironment(?Environment $value): self + { + $this->environment = $value; + + return $this; + } + + public function setEphemeralStorage(?EphemeralStorage $value): self + { + $this->ephemeralStorage = $value; + + return $this; + } + + /** + * @param FileSystemConfig[] $value + */ + public function setFileSystemConfigs(array $value): self + { + $this->fileSystemConfigs = $value; + + return $this; + } + + public function setFunctionName(?string $value): self + { + $this->functionName = $value; + + return $this; + } + + public function setHandler(?string $value): self + { + $this->handler = $value; + + return $this; + } + + public function setImageConfig(?ImageConfig $value): self + { + $this->imageConfig = $value; + + return $this; + } + + public function setKmsKeyArn(?string $value): self + { + $this->kmsKeyArn = $value; + + return $this; + } + + /** + * @param string[] $value + */ + public function setLayers(array $value): self + { + $this->layers = $value; + + return $this; + } + + public function setLoggingConfig(?LoggingConfig $value): self + { + $this->loggingConfig = $value; + + return $this; + } + + public function setMemorySize(?int $value): self + { + $this->memorySize = $value; + + return $this; + } + + public function setRevisionId(?string $value): self + { + $this->revisionId = $value; + + return $this; + } + + public function setRole(?string $value): self + { + $this->role = $value; + + return $this; + } + + /** + * @param Runtime::*|null $value + */ + public function setRuntime(?string $value): self + { + $this->runtime = $value; + + return $this; + } + + public function setSnapStart(?SnapStart $value): self + { + $this->snapStart = $value; + + return $this; + } + + public function setTimeout(?int $value): self + { + $this->timeout = $value; + + return $this; + } + + public function setTracingConfig(?TracingConfig $value): self + { + $this->tracingConfig = $value; + + return $this; + } + + public function setVpcConfig(?VpcConfig $value): self + { + $this->vpcConfig = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + + if (null !== $v = $this->role) { + $payload['Role'] = $v; + } + if (null !== $v = $this->handler) { + $payload['Handler'] = $v; + } + if (null !== $v = $this->description) { + $payload['Description'] = $v; + } + if (null !== $v = $this->timeout) { + $payload['Timeout'] = $v; + } + if (null !== $v = $this->memorySize) { + $payload['MemorySize'] = $v; + } + if (null !== $v = $this->vpcConfig) { + $payload['VpcConfig'] = $v->requestBody(); + } + if (null !== $v = $this->environment) { + $payload['Environment'] = $v->requestBody(); + } + if (null !== $v = $this->runtime) { + if (!Runtime::exists($v)) { + throw new InvalidArgument(\sprintf('Invalid parameter "Runtime" for "%s". The value "%s" is not a valid "Runtime".', __CLASS__, $v)); + } + $payload['Runtime'] = $v; + } + if (null !== $v = $this->deadLetterConfig) { + $payload['DeadLetterConfig'] = $v->requestBody(); + } + if (null !== $v = $this->kmsKeyArn) { + $payload['KMSKeyArn'] = $v; + } + if (null !== $v = $this->tracingConfig) { + $payload['TracingConfig'] = $v->requestBody(); + } + if (null !== $v = $this->revisionId) { + $payload['RevisionId'] = $v; + } + if (null !== $v = $this->layers) { + $index = -1; + $payload['Layers'] = []; + foreach ($v as $listValue) { + ++$index; + $payload['Layers'][$index] = $listValue; + } + } + if (null !== $v = $this->fileSystemConfigs) { + $index = -1; + $payload['FileSystemConfigs'] = []; + foreach ($v as $listValue) { + ++$index; + $payload['FileSystemConfigs'][$index] = $listValue->requestBody(); + } + } + if (null !== $v = $this->imageConfig) { + $payload['ImageConfig'] = $v->requestBody(); + } + if (null !== $v = $this->ephemeralStorage) { + $payload['EphemeralStorage'] = $v->requestBody(); + } + if (null !== $v = $this->snapStart) { + $payload['SnapStart'] = $v->requestBody(); + } + if (null !== $v = $this->loggingConfig) { + $payload['LoggingConfig'] = $v->requestBody(); + } + + return $payload; + } +} diff --git a/src/LambdaClient.php b/src/LambdaClient.php index 1b4f93c..0428eae 100644 --- a/src/LambdaClient.php +++ b/src/LambdaClient.php @@ -3,127 +3,551 @@ namespace AsyncAws\Lambda; use AsyncAws\Core\AbstractApi; +use AsyncAws\Core\AwsError\AwsErrorFactoryInterface; +use AsyncAws\Core\AwsError\JsonRestAwsErrorFactory; use AsyncAws\Core\Configuration; use AsyncAws\Core\Exception\UnsupportedRegion; use AsyncAws\Core\RequestContext; +use AsyncAws\Core\Result; +use AsyncAws\Lambda\Enum\Architecture; +use AsyncAws\Lambda\Enum\FunctionVersion; use AsyncAws\Lambda\Enum\InvocationType; use AsyncAws\Lambda\Enum\LogType; use AsyncAws\Lambda\Enum\Runtime; +use AsyncAws\Lambda\Exception\CodeSigningConfigNotFoundException; +use AsyncAws\Lambda\Exception\CodeStorageExceededException; +use AsyncAws\Lambda\Exception\CodeVerificationFailedException; +use AsyncAws\Lambda\Exception\EC2AccessDeniedException; +use AsyncAws\Lambda\Exception\EC2ThrottledException; +use AsyncAws\Lambda\Exception\EC2UnexpectedException; +use AsyncAws\Lambda\Exception\EFSIOException; +use AsyncAws\Lambda\Exception\EFSMountConnectivityException; +use AsyncAws\Lambda\Exception\EFSMountFailureException; +use AsyncAws\Lambda\Exception\EFSMountTimeoutException; +use AsyncAws\Lambda\Exception\ENILimitReachedException; +use AsyncAws\Lambda\Exception\InvalidCodeSignatureException; +use AsyncAws\Lambda\Exception\InvalidParameterValueException; +use AsyncAws\Lambda\Exception\InvalidRequestContentException; +use AsyncAws\Lambda\Exception\InvalidRuntimeException; +use AsyncAws\Lambda\Exception\InvalidSecurityGroupIDException; +use AsyncAws\Lambda\Exception\InvalidSubnetIDException; +use AsyncAws\Lambda\Exception\InvalidZipFileException; +use AsyncAws\Lambda\Exception\KMSAccessDeniedException; +use AsyncAws\Lambda\Exception\KMSDisabledException; +use AsyncAws\Lambda\Exception\KMSInvalidStateException; +use AsyncAws\Lambda\Exception\KMSNotFoundException; +use AsyncAws\Lambda\Exception\PolicyLengthExceededException; +use AsyncAws\Lambda\Exception\PreconditionFailedException; +use AsyncAws\Lambda\Exception\RecursiveInvocationException; +use AsyncAws\Lambda\Exception\RequestTooLargeException; +use AsyncAws\Lambda\Exception\ResourceConflictException; +use AsyncAws\Lambda\Exception\ResourceNotFoundException; +use AsyncAws\Lambda\Exception\ResourceNotReadyException; +use AsyncAws\Lambda\Exception\ServiceException; +use AsyncAws\Lambda\Exception\SnapStartException; +use AsyncAws\Lambda\Exception\SnapStartNotReadyException; +use AsyncAws\Lambda\Exception\SnapStartTimeoutException; +use AsyncAws\Lambda\Exception\SubnetIPAddressLimitReachedException; +use AsyncAws\Lambda\Exception\TooManyRequestsException; +use AsyncAws\Lambda\Exception\UnsupportedMediaTypeException; use AsyncAws\Lambda\Input\AddLayerVersionPermissionRequest; +use AsyncAws\Lambda\Input\DeleteFunctionRequest; +use AsyncAws\Lambda\Input\GetFunctionConfigurationRequest; use AsyncAws\Lambda\Input\InvocationRequest; +use AsyncAws\Lambda\Input\ListFunctionsRequest; use AsyncAws\Lambda\Input\ListLayerVersionsRequest; +use AsyncAws\Lambda\Input\ListVersionsByFunctionRequest; use AsyncAws\Lambda\Input\PublishLayerVersionRequest; +use AsyncAws\Lambda\Input\UpdateFunctionConfigurationRequest; use AsyncAws\Lambda\Result\AddLayerVersionPermissionResponse; +use AsyncAws\Lambda\Result\FunctionConfiguration; use AsyncAws\Lambda\Result\InvocationResponse; +use AsyncAws\Lambda\Result\ListFunctionsResponse; use AsyncAws\Lambda\Result\ListLayerVersionsResponse; +use AsyncAws\Lambda\Result\ListVersionsByFunctionResponse; use AsyncAws\Lambda\Result\PublishLayerVersionResponse; +use AsyncAws\Lambda\ValueObject\DeadLetterConfig; +use AsyncAws\Lambda\ValueObject\Environment; +use AsyncAws\Lambda\ValueObject\EphemeralStorage; +use AsyncAws\Lambda\ValueObject\FileSystemConfig; +use AsyncAws\Lambda\ValueObject\ImageConfig; use AsyncAws\Lambda\ValueObject\LayerVersionContentInput; +use AsyncAws\Lambda\ValueObject\LoggingConfig; +use AsyncAws\Lambda\ValueObject\SnapStart; +use AsyncAws\Lambda\ValueObject\TracingConfig; +use AsyncAws\Lambda\ValueObject\VpcConfig; class LambdaClient extends AbstractApi { /** - * Adds permissions to the resource-based policy of a version of an AWS Lambda layer. Use this action to grant layer - * usage permission to other accounts. You can grant permission to a single account, all AWS accounts, or all accounts - * in an organization. + * Adds permissions to the resource-based policy of a version of an Lambda layer [^1]. Use this action to grant layer + * usage permission to other accounts. You can grant permission to a single account, all accounts in an organization, or + * all Amazon Web Services accounts. + * + * To revoke permission, call RemoveLayerVersionPermission with the statement ID that you specified when you added it. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html * - * @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html * @see https://docs.aws.amazon.com/lambda/latest/APIReference/API_AddLayerVersionPermission.html * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-lambda-2015-03-31.html#addlayerversionpermission * * @param array{ * LayerName: string, - * VersionNumber: string, + * VersionNumber: int, * StatementId: string, * Action: string, * Principal: string, - * OrganizationId?: string, - * RevisionId?: string, - * @region?: string, + * OrganizationId?: null|string, + * RevisionId?: null|string, + * '@region'?: string|null, * }|AddLayerVersionPermissionRequest $input + * + * @throws InvalidParameterValueException + * @throws PolicyLengthExceededException + * @throws PreconditionFailedException + * @throws ResourceConflictException + * @throws ResourceNotFoundException + * @throws ServiceException + * @throws TooManyRequestsException */ public function addLayerVersionPermission($input): AddLayerVersionPermissionResponse { $input = AddLayerVersionPermissionRequest::create($input); - $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'AddLayerVersionPermission', 'region' => $input->getRegion()])); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'AddLayerVersionPermission', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InvalidParameterValueException' => InvalidParameterValueException::class, + 'PolicyLengthExceededException' => PolicyLengthExceededException::class, + 'PreconditionFailedException' => PreconditionFailedException::class, + 'ResourceConflictException' => ResourceConflictException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + 'ServiceException' => ServiceException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); return new AddLayerVersionPermissionResponse($response); } /** - * Invokes a Lambda function. You can invoke a function synchronously (and wait for the response), or asynchronously. To - * invoke a function asynchronously, set `InvocationType` to `Event`. + * Deletes a Lambda function. To delete a specific function version, use the `Qualifier` parameter. Otherwise, all + * versions and aliases are deleted. This doesn't require the user to have explicit permissions for DeleteAlias. + * + * To delete Lambda event source mappings that invoke a function, use DeleteEventSourceMapping. For Amazon Web Services + * services and resources that invoke your function directly, delete the trigger in the service where you originally + * configured it. + * + * @see https://docs.aws.amazon.com/lambda/latest/APIReference/API_DeleteFunction.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-lambda-2015-03-31.html#deletefunction + * + * @param array{ + * FunctionName: string, + * Qualifier?: null|string, + * '@region'?: string|null, + * }|DeleteFunctionRequest $input + * + * @throws InvalidParameterValueException + * @throws ResourceConflictException + * @throws ResourceNotFoundException + * @throws ServiceException + * @throws TooManyRequestsException + */ + public function deleteFunction($input): Result + { + $input = DeleteFunctionRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'DeleteFunction', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InvalidParameterValueException' => InvalidParameterValueException::class, + 'ResourceConflictException' => ResourceConflictException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + 'ServiceException' => ServiceException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); + + return new Result($response); + } + + /** + * Returns the version-specific settings of a Lambda function or version. The output includes only options that can vary + * between versions of a function. To modify these settings, use UpdateFunctionConfiguration. + * + * To get all of a function's details, including function-level settings, use GetFunction. + * + * @see https://docs.aws.amazon.com/lambda/latest/APIReference/API_GetFunctionConfiguration.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-lambda-2015-03-31.html#getfunctionconfiguration + * + * @param array{ + * FunctionName: string, + * Qualifier?: null|string, + * '@region'?: string|null, + * }|GetFunctionConfigurationRequest $input + * + * @throws InvalidParameterValueException + * @throws ResourceNotFoundException + * @throws ServiceException + * @throws TooManyRequestsException + */ + public function getFunctionConfiguration($input): FunctionConfiguration + { + $input = GetFunctionConfigurationRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetFunctionConfiguration', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InvalidParameterValueException' => InvalidParameterValueException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + 'ServiceException' => ServiceException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); + + return new FunctionConfiguration($response); + } + + /** + * Invokes a Lambda function. You can invoke a function synchronously (and wait for the response), or asynchronously. By + * default, Lambda invokes your function synchronously (i.e. the`InvocationType` is `RequestResponse`). To invoke a + * function asynchronously, set `InvocationType` to `Event`. Lambda passes the `ClientContext` object to your function + * for synchronous invocations only. + * + * For synchronous invocation [^1], details about the function response, including errors, are included in the response + * body and headers. For either invocation type, you can find more information in the execution log [^2] and trace [^3]. + * + * When an error occurs, your function may be invoked multiple times. Retry behavior varies by error type, client, event + * source, and invocation type. For example, if you invoke a function asynchronously and it returns an error, Lambda + * executes the function up to two more times. For more information, see Error handling and automatic retries in Lambda + * [^4]. + * + * For asynchronous invocation [^5], Lambda adds events to a queue before sending them to your function. If your + * function does not have enough capacity to keep up with the queue, events may be lost. Occasionally, your function may + * receive the same event multiple times, even if no error occurs. To retain events that were not processed, configure + * your function with a dead-letter queue [^6]. + * + * The status code in the API response doesn't reflect function errors. Error codes are reserved for errors that prevent + * your function from executing, such as permissions errors, quota [^7] errors, or issues with your function's code and + * configuration. For example, Lambda returns `TooManyRequestsException` if running the function would cause you to + * exceed a concurrency limit at either the account level (`ConcurrentInvocationLimitExceeded`) or function level + * (`ReservedFunctionConcurrentInvocationLimitExceeded`). + * + * For functions with a long timeout, your client might disconnect during synchronous invocation while it waits for a + * response. Configure your HTTP client, SDK, firewall, proxy, or operating system to allow for long connections with + * timeout or keep-alive settings. + * + * This operation requires permission for the lambda:InvokeFunction [^8] action. For details on how to set up + * permissions for cross-account invocations, see Granting function access to other accounts [^9]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/invocation-sync.html + * [^2]: https://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions.html + * [^3]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-x-ray.html + * [^4]: https://docs.aws.amazon.com/lambda/latest/dg/invocation-retries.html + * [^5]: https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html + * [^6]: https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq + * [^7]: https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html + * [^8]: https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awslambda.html + * [^9]: https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html#permissions-resource-xaccountinvoke * * @see https://docs.aws.amazon.com/lambda/latest/APIReference/API_Invoke.html * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-lambda-2015-03-31.html#invoke * * @param array{ * FunctionName: string, - * InvocationType?: InvocationType::*, - * LogType?: LogType::*, - * ClientContext?: string, - * Payload?: string, - * Qualifier?: string, - * @region?: string, + * InvocationType?: null|InvocationType::*, + * LogType?: null|LogType::*, + * ClientContext?: null|string, + * Payload?: null|string, + * Qualifier?: null|string, + * '@region'?: string|null, * }|InvocationRequest $input + * + * @throws EC2AccessDeniedException + * @throws EC2ThrottledException + * @throws EC2UnexpectedException + * @throws EFSIOException + * @throws EFSMountConnectivityException + * @throws EFSMountFailureException + * @throws EFSMountTimeoutException + * @throws ENILimitReachedException + * @throws InvalidParameterValueException + * @throws InvalidRequestContentException + * @throws InvalidRuntimeException + * @throws InvalidSecurityGroupIDException + * @throws InvalidSubnetIDException + * @throws InvalidZipFileException + * @throws KMSAccessDeniedException + * @throws KMSDisabledException + * @throws KMSInvalidStateException + * @throws KMSNotFoundException + * @throws RecursiveInvocationException + * @throws RequestTooLargeException + * @throws ResourceConflictException + * @throws ResourceNotFoundException + * @throws ResourceNotReadyException + * @throws ServiceException + * @throws SnapStartException + * @throws SnapStartNotReadyException + * @throws SnapStartTimeoutException + * @throws SubnetIPAddressLimitReachedException + * @throws TooManyRequestsException + * @throws UnsupportedMediaTypeException */ public function invoke($input): InvocationResponse { $input = InvocationRequest::create($input); - $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'Invoke', 'region' => $input->getRegion()])); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'Invoke', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'EC2AccessDeniedException' => EC2AccessDeniedException::class, + 'EC2ThrottledException' => EC2ThrottledException::class, + 'EC2UnexpectedException' => EC2UnexpectedException::class, + 'EFSIOException' => EFSIOException::class, + 'EFSMountConnectivityException' => EFSMountConnectivityException::class, + 'EFSMountFailureException' => EFSMountFailureException::class, + 'EFSMountTimeoutException' => EFSMountTimeoutException::class, + 'ENILimitReachedException' => ENILimitReachedException::class, + 'InvalidParameterValueException' => InvalidParameterValueException::class, + 'InvalidRequestContentException' => InvalidRequestContentException::class, + 'InvalidRuntimeException' => InvalidRuntimeException::class, + 'InvalidSecurityGroupIDException' => InvalidSecurityGroupIDException::class, + 'InvalidSubnetIDException' => InvalidSubnetIDException::class, + 'InvalidZipFileException' => InvalidZipFileException::class, + 'KMSAccessDeniedException' => KMSAccessDeniedException::class, + 'KMSDisabledException' => KMSDisabledException::class, + 'KMSInvalidStateException' => KMSInvalidStateException::class, + 'KMSNotFoundException' => KMSNotFoundException::class, + 'RecursiveInvocationException' => RecursiveInvocationException::class, + 'RequestTooLargeException' => RequestTooLargeException::class, + 'ResourceConflictException' => ResourceConflictException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + 'ResourceNotReadyException' => ResourceNotReadyException::class, + 'ServiceException' => ServiceException::class, + 'SnapStartException' => SnapStartException::class, + 'SnapStartNotReadyException' => SnapStartNotReadyException::class, + 'SnapStartTimeoutException' => SnapStartTimeoutException::class, + 'SubnetIPAddressLimitReachedException' => SubnetIPAddressLimitReachedException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + 'UnsupportedMediaTypeException' => UnsupportedMediaTypeException::class, + ]])); return new InvocationResponse($response); } /** - * Lists the versions of an AWS Lambda layer. Versions that have been deleted aren't listed. Specify a runtime - * identifier to list only versions that indicate that they're compatible with that runtime. + * Returns a list of Lambda functions, with the version-specific configuration of each. Lambda returns up to 50 + * functions per call. + * + * Set `FunctionVersion` to `ALL` to include all published versions of each function in addition to the unpublished + * version. + * + * > The `ListFunctions` operation returns a subset of the FunctionConfiguration fields. To get the additional fields + * > (State, StateReasonCode, StateReason, LastUpdateStatus, LastUpdateStatusReason, LastUpdateStatusReasonCode, + * > RuntimeVersionConfig) for a function or version, use GetFunction. + * + * @see https://docs.aws.amazon.com/lambda/latest/APIReference/API_ListFunctions.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-lambda-2015-03-31.html#listfunctions + * + * @param array{ + * MasterRegion?: null|string, + * FunctionVersion?: null|FunctionVersion::*, + * Marker?: null|string, + * MaxItems?: null|int, + * '@region'?: string|null, + * }|ListFunctionsRequest $input + * + * @throws InvalidParameterValueException + * @throws ServiceException + * @throws TooManyRequestsException + */ + public function listFunctions($input = []): ListFunctionsResponse + { + $input = ListFunctionsRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListFunctions', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InvalidParameterValueException' => InvalidParameterValueException::class, + 'ServiceException' => ServiceException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); + + return new ListFunctionsResponse($response, $this, $input); + } + + /** + * Lists the versions of an Lambda layer [^1]. Versions that have been deleted aren't listed. Specify a runtime + * identifier [^2] to list only versions that indicate that they're compatible with that runtime. Specify a compatible + * architecture to include only layer versions that are compatible with that architecture. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html + * [^2]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html * - * @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html - * @see https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html * @see https://docs.aws.amazon.com/lambda/latest/APIReference/API_ListLayerVersions.html * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-lambda-2015-03-31.html#listlayerversions * * @param array{ - * CompatibleRuntime?: Runtime::*, + * CompatibleRuntime?: null|Runtime::*, * LayerName: string, - * Marker?: string, - * MaxItems?: int, - * @region?: string, + * Marker?: null|string, + * MaxItems?: null|int, + * CompatibleArchitecture?: null|Architecture::*, + * '@region'?: string|null, * }|ListLayerVersionsRequest $input + * + * @throws InvalidParameterValueException + * @throws ResourceNotFoundException + * @throws ServiceException + * @throws TooManyRequestsException */ public function listLayerVersions($input): ListLayerVersionsResponse { $input = ListLayerVersionsRequest::create($input); - $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListLayerVersions', 'region' => $input->getRegion()])); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListLayerVersions', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InvalidParameterValueException' => InvalidParameterValueException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + 'ServiceException' => ServiceException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); return new ListLayerVersionsResponse($response, $this, $input); } /** - * Creates an AWS Lambda layer from a ZIP archive. Each time you call `PublishLayerVersion` with the same layer name, a + * Returns a list of versions [^1], with the version-specific configuration of each. Lambda returns up to 50 versions + * per call. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/versioning-aliases.html + * + * @see https://docs.aws.amazon.com/lambda/latest/APIReference/API_ListVersionsByFunction.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-lambda-2015-03-31.html#listversionsbyfunction + * + * @param array{ + * FunctionName: string, + * Marker?: null|string, + * MaxItems?: null|int, + * '@region'?: string|null, + * }|ListVersionsByFunctionRequest $input + * + * @throws InvalidParameterValueException + * @throws ResourceNotFoundException + * @throws ServiceException + * @throws TooManyRequestsException + */ + public function listVersionsByFunction($input): ListVersionsByFunctionResponse + { + $input = ListVersionsByFunctionRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListVersionsByFunction', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InvalidParameterValueException' => InvalidParameterValueException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + 'ServiceException' => ServiceException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); + + return new ListVersionsByFunctionResponse($response, $this, $input); + } + + /** + * Creates an Lambda layer [^1] from a ZIP archive. Each time you call `PublishLayerVersion` with the same layer name, a * new version is created. * - * @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html + * Add layers to your function with CreateFunction or UpdateFunctionConfiguration. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html + * * @see https://docs.aws.amazon.com/lambda/latest/APIReference/API_PublishLayerVersion.html * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-lambda-2015-03-31.html#publishlayerversion * * @param array{ * LayerName: string, - * Description?: string, + * Description?: null|string, * Content: LayerVersionContentInput|array, - * CompatibleRuntimes?: list, - * LicenseInfo?: string, - * @region?: string, + * CompatibleRuntimes?: null|array, + * LicenseInfo?: null|string, + * CompatibleArchitectures?: null|array, + * '@region'?: string|null, * }|PublishLayerVersionRequest $input + * + * @throws CodeStorageExceededException + * @throws InvalidParameterValueException + * @throws ResourceNotFoundException + * @throws ServiceException + * @throws TooManyRequestsException */ public function publishLayerVersion($input): PublishLayerVersionResponse { $input = PublishLayerVersionRequest::create($input); - $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'PublishLayerVersion', 'region' => $input->getRegion()])); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'PublishLayerVersion', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'CodeStorageExceededException' => CodeStorageExceededException::class, + 'InvalidParameterValueException' => InvalidParameterValueException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + 'ServiceException' => ServiceException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); return new PublishLayerVersionResponse($response); } + /** + * Modify the version-specific settings of a Lambda function. + * + * When you update a function, Lambda provisions an instance of the function and its supporting resources. If your + * function connects to a VPC, this process can take a minute. During this time, you can't modify the function, but you + * can still invoke it. The `LastUpdateStatus`, `LastUpdateStatusReason`, and `LastUpdateStatusReasonCode` fields in the + * response from GetFunctionConfiguration indicate when the update is complete and the function is processing events + * with the new configuration. For more information, see Lambda function states [^1]. + * + * These settings can vary between versions of a function and are locked when you publish a version. You can't modify + * the configuration of a published version, only the unpublished version. + * + * To configure function concurrency, use PutFunctionConcurrency. To grant invoke permissions to an Amazon Web Services + * account or Amazon Web Services service, use AddPermission. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/functions-states.html + * + * @see https://docs.aws.amazon.com/lambda/latest/APIReference/API_UpdateFunctionConfiguration.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-lambda-2015-03-31.html#updatefunctionconfiguration + * + * @param array{ + * FunctionName: string, + * Role?: null|string, + * Handler?: null|string, + * Description?: null|string, + * Timeout?: null|int, + * MemorySize?: null|int, + * VpcConfig?: null|VpcConfig|array, + * Environment?: null|Environment|array, + * Runtime?: null|Runtime::*, + * DeadLetterConfig?: null|DeadLetterConfig|array, + * KMSKeyArn?: null|string, + * TracingConfig?: null|TracingConfig|array, + * RevisionId?: null|string, + * Layers?: null|string[], + * FileSystemConfigs?: null|array, + * ImageConfig?: null|ImageConfig|array, + * EphemeralStorage?: null|EphemeralStorage|array, + * SnapStart?: null|SnapStart|array, + * LoggingConfig?: null|LoggingConfig|array, + * '@region'?: string|null, + * }|UpdateFunctionConfigurationRequest $input + * + * @throws CodeSigningConfigNotFoundException + * @throws CodeVerificationFailedException + * @throws InvalidCodeSignatureException + * @throws InvalidParameterValueException + * @throws PreconditionFailedException + * @throws ResourceConflictException + * @throws ResourceNotFoundException + * @throws ServiceException + * @throws TooManyRequestsException + */ + public function updateFunctionConfiguration($input): FunctionConfiguration + { + $input = UpdateFunctionConfigurationRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'UpdateFunctionConfiguration', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'CodeSigningConfigNotFoundException' => CodeSigningConfigNotFoundException::class, + 'CodeVerificationFailedException' => CodeVerificationFailedException::class, + 'InvalidCodeSignatureException' => InvalidCodeSignatureException::class, + 'InvalidParameterValueException' => InvalidParameterValueException::class, + 'PreconditionFailedException' => PreconditionFailedException::class, + 'ResourceConflictException' => ResourceConflictException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + 'ServiceException' => ServiceException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); + + return new FunctionConfiguration($response); + } + + protected function getAwsErrorFactory(): AwsErrorFactoryInterface + { + return new JsonRestAwsErrorFactory(); + } + protected function getEndpointMetadata(?string $region): array { if (null === $region) { @@ -135,20 +559,34 @@ protected function getEndpointMetadata(?string $region): array case 'ap-east-1': case 'ap-northeast-1': case 'ap-northeast-2': + case 'ap-northeast-3': case 'ap-south-1': + case 'ap-south-2': case 'ap-southeast-1': case 'ap-southeast-2': + case 'ap-southeast-3': + case 'ap-southeast-4': + case 'ap-southeast-5': + case 'ap-southeast-7': case 'ca-central-1': + case 'ca-west-1': case 'eu-central-1': + case 'eu-central-2': case 'eu-north-1': case 'eu-south-1': + case 'eu-south-2': case 'eu-west-1': case 'eu-west-2': case 'eu-west-3': + case 'il-central-1': + case 'me-central-1': case 'me-south-1': + case 'mx-central-1': case 'sa-east-1': case 'us-east-1': case 'us-east-2': + case 'us-gov-east-1': + case 'us-gov-west-1': case 'us-west-1': case 'us-west-2': return [ @@ -165,39 +603,31 @@ protected function getEndpointMetadata(?string $region): array 'signService' => 'lambda', 'signVersions' => ['v4'], ]; - case 'us-gov-east-1': - case 'us-gov-west-1': - return [ - 'endpoint' => "https://lambda.$region.amazonaws.com", - 'signRegion' => $region, - 'signService' => 'lambda', - 'signVersions' => ['v4'], - ]; - case 'us-iso-east-1': + case 'fips-us-east-1': return [ - 'endpoint' => "https://lambda.$region.c2s.ic.gov", - 'signRegion' => $region, + 'endpoint' => 'https://lambda-fips.us-east-1.amazonaws.com', + 'signRegion' => 'us-east-1', 'signService' => 'lambda', 'signVersions' => ['v4'], ]; - case 'us-isob-east-1': + case 'fips-us-east-2': return [ - 'endpoint' => "https://lambda.$region.sc2s.sgov.gov", - 'signRegion' => $region, + 'endpoint' => 'https://lambda-fips.us-east-2.amazonaws.com', + 'signRegion' => 'us-east-2', 'signService' => 'lambda', 'signVersions' => ['v4'], ]; - case 'fips-us-east-1': + case 'fips-us-west-1': return [ - 'endpoint' => 'https://lambda-fips.us-east-1.amazonaws.com', - 'signRegion' => 'us-east-1', + 'endpoint' => 'https://lambda-fips.us-west-1.amazonaws.com', + 'signRegion' => 'us-west-1', 'signService' => 'lambda', 'signVersions' => ['v4'], ]; - case 'fips-us-east-2': + case 'fips-us-west-2': return [ - 'endpoint' => 'https://lambda-fips.us-east-2.amazonaws.com', - 'signRegion' => 'us-east-2', + 'endpoint' => 'https://lambda-fips.us-west-2.amazonaws.com', + 'signRegion' => 'us-west-2', 'signService' => 'lambda', 'signVersions' => ['v4'], ]; @@ -215,22 +645,38 @@ protected function getEndpointMetadata(?string $region): array 'signService' => 'lambda', 'signVersions' => ['v4'], ]; - case 'fips-us-west-1': + case 'us-iso-east-1': + case 'us-iso-west-1': return [ - 'endpoint' => 'https://lambda-fips.us-west-1.amazonaws.com', - 'signRegion' => 'us-west-1', + 'endpoint' => "https://lambda.$region.c2s.ic.gov", + 'signRegion' => $region, 'signService' => 'lambda', 'signVersions' => ['v4'], ]; - case 'fips-us-west-2': + case 'us-isof-east-1': + case 'us-isof-south-1': return [ - 'endpoint' => 'https://lambda-fips.us-west-2.amazonaws.com', - 'signRegion' => 'us-west-2', + 'endpoint' => "https://lambda.$region.csp.hci.ic.gov", + 'signRegion' => $region, + 'signService' => 'lambda', + 'signVersions' => ['v4'], + ]; + case 'eu-isoe-west-1': + return [ + 'endpoint' => 'https://lambda.eu-isoe-west-1.cloud.adc-e.uk', + 'signRegion' => 'eu-isoe-west-1', + 'signService' => 'lambda', + 'signVersions' => ['v4'], + ]; + case 'us-isob-east-1': + return [ + 'endpoint' => 'https://lambda.us-isob-east-1.sc2s.sgov.gov', + 'signRegion' => 'us-isob-east-1', 'signService' => 'lambda', 'signVersions' => ['v4'], ]; } - throw new UnsupportedRegion(sprintf('The region "%s" is not supported by "Lambda".', $region)); + throw new UnsupportedRegion(\sprintf('The region "%s" is not supported by "Lambda".', $region)); } } diff --git a/src/Result/AddLayerVersionPermissionResponse.php b/src/Result/AddLayerVersionPermissionResponse.php index cc72530..bca1f9e 100644 --- a/src/Result/AddLayerVersionPermissionResponse.php +++ b/src/Result/AddLayerVersionPermissionResponse.php @@ -9,33 +9,37 @@ class AddLayerVersionPermissionResponse extends Result { /** * The permission statement. + * + * @var string|null */ - private $Statement; + private $statement; /** * A unique identifier for the current revision of the policy. + * + * @var string|null */ - private $RevisionId; + private $revisionId; public function getRevisionId(): ?string { $this->initialize(); - return $this->RevisionId; + return $this->revisionId; } public function getStatement(): ?string { $this->initialize(); - return $this->Statement; + return $this->statement; } protected function populateResult(Response $response): void { $data = $response->toArray(); - $this->Statement = isset($data['Statement']) ? (string) $data['Statement'] : null; - $this->RevisionId = isset($data['RevisionId']) ? (string) $data['RevisionId'] : null; + $this->statement = isset($data['Statement']) ? (string) $data['Statement'] : null; + $this->revisionId = isset($data['RevisionId']) ? (string) $data['RevisionId'] : null; } } diff --git a/src/Result/FunctionConfiguration.php b/src/Result/FunctionConfiguration.php new file mode 100644 index 0000000..164b525 --- /dev/null +++ b/src/Result/FunctionConfiguration.php @@ -0,0 +1,879 @@ + + */ + private $architectures; + + /** + * The size of the function's `/tmp` directory in MB. The default value is 512, but can be any whole number between 512 + * and 10,240 MB. For more information, see Configuring ephemeral storage (console) [^1]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-ephemeral-storage + * + * @var EphemeralStorage|null + */ + private $ephemeralStorage; + + /** + * Set `ApplyOn` to `PublishedVersions` to create a snapshot of the initialized execution environment when you publish a + * function version. For more information, see Improving startup performance with Lambda SnapStart [^1]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html + * + * @var SnapStartResponse|null + */ + private $snapStart; + + /** + * The ARN of the runtime and any errors that occured. + * + * @var RuntimeVersionConfig|null + */ + private $runtimeVersionConfig; + + /** + * The function's Amazon CloudWatch Logs configuration settings. + * + * @var LoggingConfig|null + */ + private $loggingConfig; + + /** + * @return list + */ + public function getArchitectures(): array + { + $this->initialize(); + + return $this->architectures; + } + + public function getCodeSha256(): ?string + { + $this->initialize(); + + return $this->codeSha256; + } + + public function getCodeSize(): ?int + { + $this->initialize(); + + return $this->codeSize; + } + + public function getDeadLetterConfig(): ?DeadLetterConfig + { + $this->initialize(); + + return $this->deadLetterConfig; + } + + public function getDescription(): ?string + { + $this->initialize(); + + return $this->description; + } + + public function getEnvironment(): ?EnvironmentResponse + { + $this->initialize(); + + return $this->environment; + } + + public function getEphemeralStorage(): ?EphemeralStorage + { + $this->initialize(); + + return $this->ephemeralStorage; + } + + /** + * @return FileSystemConfig[] + */ + public function getFileSystemConfigs(): array + { + $this->initialize(); + + return $this->fileSystemConfigs; + } + + public function getFunctionArn(): ?string + { + $this->initialize(); + + return $this->functionArn; + } + + public function getFunctionName(): ?string + { + $this->initialize(); + + return $this->functionName; + } + + public function getHandler(): ?string + { + $this->initialize(); + + return $this->handler; + } + + public function getImageConfigResponse(): ?ImageConfigResponse + { + $this->initialize(); + + return $this->imageConfigResponse; + } + + public function getKmsKeyArn(): ?string + { + $this->initialize(); + + return $this->kmsKeyArn; + } + + public function getLastModified(): ?string + { + $this->initialize(); + + return $this->lastModified; + } + + /** + * @return LastUpdateStatus::*|null + */ + public function getLastUpdateStatus(): ?string + { + $this->initialize(); + + return $this->lastUpdateStatus; + } + + public function getLastUpdateStatusReason(): ?string + { + $this->initialize(); + + return $this->lastUpdateStatusReason; + } + + /** + * @return LastUpdateStatusReasonCode::*|null + */ + public function getLastUpdateStatusReasonCode(): ?string + { + $this->initialize(); + + return $this->lastUpdateStatusReasonCode; + } + + /** + * @return Layer[] + */ + public function getLayers(): array + { + $this->initialize(); + + return $this->layers; + } + + public function getLoggingConfig(): ?LoggingConfig + { + $this->initialize(); + + return $this->loggingConfig; + } + + public function getMasterArn(): ?string + { + $this->initialize(); + + return $this->masterArn; + } + + public function getMemorySize(): ?int + { + $this->initialize(); + + return $this->memorySize; + } + + /** + * @return PackageType::*|null + */ + public function getPackageType(): ?string + { + $this->initialize(); + + return $this->packageType; + } + + public function getRevisionId(): ?string + { + $this->initialize(); + + return $this->revisionId; + } + + public function getRole(): ?string + { + $this->initialize(); + + return $this->role; + } + + /** + * @return Runtime::*|null + */ + public function getRuntime(): ?string + { + $this->initialize(); + + return $this->runtime; + } + + public function getRuntimeVersionConfig(): ?RuntimeVersionConfig + { + $this->initialize(); + + return $this->runtimeVersionConfig; + } + + public function getSigningJobArn(): ?string + { + $this->initialize(); + + return $this->signingJobArn; + } + + public function getSigningProfileVersionArn(): ?string + { + $this->initialize(); + + return $this->signingProfileVersionArn; + } + + public function getSnapStart(): ?SnapStartResponse + { + $this->initialize(); + + return $this->snapStart; + } + + /** + * @return State::*|null + */ + public function getState(): ?string + { + $this->initialize(); + + return $this->state; + } + + public function getStateReason(): ?string + { + $this->initialize(); + + return $this->stateReason; + } + + /** + * @return StateReasonCode::*|null + */ + public function getStateReasonCode(): ?string + { + $this->initialize(); + + return $this->stateReasonCode; + } + + public function getTimeout(): ?int + { + $this->initialize(); + + return $this->timeout; + } + + public function getTracingConfig(): ?TracingConfigResponse + { + $this->initialize(); + + return $this->tracingConfig; + } + + public function getVersion(): ?string + { + $this->initialize(); + + return $this->version; + } + + public function getVpcConfig(): ?VpcConfigResponse + { + $this->initialize(); + + return $this->vpcConfig; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->functionName = isset($data['FunctionName']) ? (string) $data['FunctionName'] : null; + $this->functionArn = isset($data['FunctionArn']) ? (string) $data['FunctionArn'] : null; + $this->runtime = isset($data['Runtime']) ? (string) $data['Runtime'] : null; + $this->role = isset($data['Role']) ? (string) $data['Role'] : null; + $this->handler = isset($data['Handler']) ? (string) $data['Handler'] : null; + $this->codeSize = isset($data['CodeSize']) ? (int) $data['CodeSize'] : null; + $this->description = isset($data['Description']) ? (string) $data['Description'] : null; + $this->timeout = isset($data['Timeout']) ? (int) $data['Timeout'] : null; + $this->memorySize = isset($data['MemorySize']) ? (int) $data['MemorySize'] : null; + $this->lastModified = isset($data['LastModified']) ? (string) $data['LastModified'] : null; + $this->codeSha256 = isset($data['CodeSha256']) ? (string) $data['CodeSha256'] : null; + $this->version = isset($data['Version']) ? (string) $data['Version'] : null; + $this->vpcConfig = empty($data['VpcConfig']) ? null : $this->populateResultVpcConfigResponse($data['VpcConfig']); + $this->deadLetterConfig = empty($data['DeadLetterConfig']) ? null : $this->populateResultDeadLetterConfig($data['DeadLetterConfig']); + $this->environment = empty($data['Environment']) ? null : $this->populateResultEnvironmentResponse($data['Environment']); + $this->kmsKeyArn = isset($data['KMSKeyArn']) ? (string) $data['KMSKeyArn'] : null; + $this->tracingConfig = empty($data['TracingConfig']) ? null : $this->populateResultTracingConfigResponse($data['TracingConfig']); + $this->masterArn = isset($data['MasterArn']) ? (string) $data['MasterArn'] : null; + $this->revisionId = isset($data['RevisionId']) ? (string) $data['RevisionId'] : null; + $this->layers = empty($data['Layers']) ? [] : $this->populateResultLayersReferenceList($data['Layers']); + $this->state = isset($data['State']) ? (string) $data['State'] : null; + $this->stateReason = isset($data['StateReason']) ? (string) $data['StateReason'] : null; + $this->stateReasonCode = isset($data['StateReasonCode']) ? (string) $data['StateReasonCode'] : null; + $this->lastUpdateStatus = isset($data['LastUpdateStatus']) ? (string) $data['LastUpdateStatus'] : null; + $this->lastUpdateStatusReason = isset($data['LastUpdateStatusReason']) ? (string) $data['LastUpdateStatusReason'] : null; + $this->lastUpdateStatusReasonCode = isset($data['LastUpdateStatusReasonCode']) ? (string) $data['LastUpdateStatusReasonCode'] : null; + $this->fileSystemConfigs = empty($data['FileSystemConfigs']) ? [] : $this->populateResultFileSystemConfigList($data['FileSystemConfigs']); + $this->packageType = isset($data['PackageType']) ? (string) $data['PackageType'] : null; + $this->imageConfigResponse = empty($data['ImageConfigResponse']) ? null : $this->populateResultImageConfigResponse($data['ImageConfigResponse']); + $this->signingProfileVersionArn = isset($data['SigningProfileVersionArn']) ? (string) $data['SigningProfileVersionArn'] : null; + $this->signingJobArn = isset($data['SigningJobArn']) ? (string) $data['SigningJobArn'] : null; + $this->architectures = empty($data['Architectures']) ? [] : $this->populateResultArchitecturesList($data['Architectures']); + $this->ephemeralStorage = empty($data['EphemeralStorage']) ? null : $this->populateResultEphemeralStorage($data['EphemeralStorage']); + $this->snapStart = empty($data['SnapStart']) ? null : $this->populateResultSnapStartResponse($data['SnapStart']); + $this->runtimeVersionConfig = empty($data['RuntimeVersionConfig']) ? null : $this->populateResultRuntimeVersionConfig($data['RuntimeVersionConfig']); + $this->loggingConfig = empty($data['LoggingConfig']) ? null : $this->populateResultLoggingConfig($data['LoggingConfig']); + } + + /** + * @return list + */ + private function populateResultArchitecturesList(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + private function populateResultDeadLetterConfig(array $json): DeadLetterConfig + { + return new DeadLetterConfig([ + 'TargetArn' => isset($json['TargetArn']) ? (string) $json['TargetArn'] : null, + ]); + } + + private function populateResultEnvironmentError(array $json): EnvironmentError + { + return new EnvironmentError([ + 'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null, + 'Message' => isset($json['Message']) ? (string) $json['Message'] : null, + ]); + } + + private function populateResultEnvironmentResponse(array $json): EnvironmentResponse + { + return new EnvironmentResponse([ + 'Variables' => !isset($json['Variables']) ? null : $this->populateResultEnvironmentVariables($json['Variables']), + 'Error' => empty($json['Error']) ? null : $this->populateResultEnvironmentError($json['Error']), + ]); + } + + /** + * @return array + */ + private function populateResultEnvironmentVariables(array $json): array + { + $items = []; + foreach ($json as $name => $value) { + $items[(string) $name] = (string) $value; + } + + return $items; + } + + private function populateResultEphemeralStorage(array $json): EphemeralStorage + { + return new EphemeralStorage([ + 'Size' => (int) $json['Size'], + ]); + } + + private function populateResultFileSystemConfig(array $json): FileSystemConfig + { + return new FileSystemConfig([ + 'Arn' => (string) $json['Arn'], + 'LocalMountPath' => (string) $json['LocalMountPath'], + ]); + } + + /** + * @return FileSystemConfig[] + */ + private function populateResultFileSystemConfigList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultFileSystemConfig($item); + } + + return $items; + } + + private function populateResultImageConfig(array $json): ImageConfig + { + return new ImageConfig([ + 'EntryPoint' => !isset($json['EntryPoint']) ? null : $this->populateResultStringList($json['EntryPoint']), + 'Command' => !isset($json['Command']) ? null : $this->populateResultStringList($json['Command']), + 'WorkingDirectory' => isset($json['WorkingDirectory']) ? (string) $json['WorkingDirectory'] : null, + ]); + } + + private function populateResultImageConfigError(array $json): ImageConfigError + { + return new ImageConfigError([ + 'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null, + 'Message' => isset($json['Message']) ? (string) $json['Message'] : null, + ]); + } + + private function populateResultImageConfigResponse(array $json): ImageConfigResponse + { + return new ImageConfigResponse([ + 'ImageConfig' => empty($json['ImageConfig']) ? null : $this->populateResultImageConfig($json['ImageConfig']), + 'Error' => empty($json['Error']) ? null : $this->populateResultImageConfigError($json['Error']), + ]); + } + + private function populateResultLayer(array $json): Layer + { + return new Layer([ + 'Arn' => isset($json['Arn']) ? (string) $json['Arn'] : null, + 'CodeSize' => isset($json['CodeSize']) ? (int) $json['CodeSize'] : null, + 'SigningProfileVersionArn' => isset($json['SigningProfileVersionArn']) ? (string) $json['SigningProfileVersionArn'] : null, + 'SigningJobArn' => isset($json['SigningJobArn']) ? (string) $json['SigningJobArn'] : null, + ]); + } + + /** + * @return Layer[] + */ + private function populateResultLayersReferenceList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultLayer($item); + } + + return $items; + } + + private function populateResultLoggingConfig(array $json): LoggingConfig + { + return new LoggingConfig([ + 'LogFormat' => isset($json['LogFormat']) ? (string) $json['LogFormat'] : null, + 'ApplicationLogLevel' => isset($json['ApplicationLogLevel']) ? (string) $json['ApplicationLogLevel'] : null, + 'SystemLogLevel' => isset($json['SystemLogLevel']) ? (string) $json['SystemLogLevel'] : null, + 'LogGroup' => isset($json['LogGroup']) ? (string) $json['LogGroup'] : null, + ]); + } + + private function populateResultRuntimeVersionConfig(array $json): RuntimeVersionConfig + { + return new RuntimeVersionConfig([ + 'RuntimeVersionArn' => isset($json['RuntimeVersionArn']) ? (string) $json['RuntimeVersionArn'] : null, + 'Error' => empty($json['Error']) ? null : $this->populateResultRuntimeVersionError($json['Error']), + ]); + } + + private function populateResultRuntimeVersionError(array $json): RuntimeVersionError + { + return new RuntimeVersionError([ + 'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null, + 'Message' => isset($json['Message']) ? (string) $json['Message'] : null, + ]); + } + + /** + * @return string[] + */ + private function populateResultSecurityGroupIds(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + private function populateResultSnapStartResponse(array $json): SnapStartResponse + { + return new SnapStartResponse([ + 'ApplyOn' => isset($json['ApplyOn']) ? (string) $json['ApplyOn'] : null, + 'OptimizationStatus' => isset($json['OptimizationStatus']) ? (string) $json['OptimizationStatus'] : null, + ]); + } + + /** + * @return string[] + */ + private function populateResultStringList(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + /** + * @return string[] + */ + private function populateResultSubnetIds(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + private function populateResultTracingConfigResponse(array $json): TracingConfigResponse + { + return new TracingConfigResponse([ + 'Mode' => isset($json['Mode']) ? (string) $json['Mode'] : null, + ]); + } + + private function populateResultVpcConfigResponse(array $json): VpcConfigResponse + { + return new VpcConfigResponse([ + 'SubnetIds' => !isset($json['SubnetIds']) ? null : $this->populateResultSubnetIds($json['SubnetIds']), + 'SecurityGroupIds' => !isset($json['SecurityGroupIds']) ? null : $this->populateResultSecurityGroupIds($json['SecurityGroupIds']), + 'VpcId' => isset($json['VpcId']) ? (string) $json['VpcId'] : null, + 'Ipv6AllowedForDualStack' => isset($json['Ipv6AllowedForDualStack']) ? filter_var($json['Ipv6AllowedForDualStack'], \FILTER_VALIDATE_BOOLEAN) : null, + ]); + } +} diff --git a/src/Result/InvocationResponse.php b/src/Result/InvocationResponse.php index 0872cc7..07719dd 100644 --- a/src/Result/InvocationResponse.php +++ b/src/Result/InvocationResponse.php @@ -11,75 +11,85 @@ class InvocationResponse extends Result * The HTTP status code is in the 200 range for a successful request. For the `RequestResponse` invocation type, this * status code is 200. For the `Event` invocation type, this status code is 202. For the `DryRun` invocation type, the * status code is 204. + * + * @var int|null */ - private $StatusCode; + private $statusCode; /** * If present, indicates that an error occurred during function execution. Details about the error are included in the * response payload. + * + * @var string|null */ - private $FunctionError; + private $functionError; /** - * The last 4 KB of the execution log, which is base64 encoded. + * The last 4 KB of the execution log, which is base64-encoded. + * + * @var string|null */ - private $LogResult; + private $logResult; /** * The response from the function, or an error object. + * + * @var string|null */ - private $Payload; + private $payload; /** * The version of the function that executed. When you invoke a function with an alias, this indicates which version the * alias resolved to. + * + * @var string|null */ - private $ExecutedVersion; + private $executedVersion; public function getExecutedVersion(): ?string { $this->initialize(); - return $this->ExecutedVersion; + return $this->executedVersion; } public function getFunctionError(): ?string { $this->initialize(); - return $this->FunctionError; + return $this->functionError; } public function getLogResult(): ?string { $this->initialize(); - return $this->LogResult; + return $this->logResult; } public function getPayload(): ?string { $this->initialize(); - return $this->Payload; + return $this->payload; } public function getStatusCode(): ?int { $this->initialize(); - return $this->StatusCode; + return $this->statusCode; } protected function populateResult(Response $response): void { - $this->StatusCode = $response->getStatusCode(); + $this->statusCode = $response->getStatusCode(); $headers = $response->getHeaders(); - $this->FunctionError = $headers['x-amz-function-error'][0] ?? null; - $this->LogResult = $headers['x-amz-log-result'][0] ?? null; - $this->ExecutedVersion = $headers['x-amz-executed-version'][0] ?? null; + $this->functionError = $headers['x-amz-function-error'][0] ?? null; + $this->logResult = $headers['x-amz-log-result'][0] ?? null; + $this->executedVersion = $headers['x-amz-executed-version'][0] ?? null; - $this->Payload = $response->getContent(); + $this->payload = $response->getContent(); } } diff --git a/src/Result/ListFunctionsResponse.php b/src/Result/ListFunctionsResponse.php new file mode 100644 index 0000000..b9d3567 --- /dev/null +++ b/src/Result/ListFunctionsResponse.php @@ -0,0 +1,399 @@ + + */ +class ListFunctionsResponse extends Result implements \IteratorAggregate +{ + /** + * The pagination token that's included if more results are available. + * + * @var string|null + */ + private $nextMarker; + + /** + * A list of Lambda functions. + * + * @var FunctionConfiguration[] + */ + private $functions; + + /** + * @param bool $currentPageOnly When true, iterates over items of the current page. Otherwise also fetch items in the next pages. + * + * @return iterable + */ + public function getFunctions(bool $currentPageOnly = false): iterable + { + if ($currentPageOnly) { + $this->initialize(); + yield from $this->functions; + + return; + } + + $client = $this->awsClient; + if (!$client instanceof LambdaClient) { + throw new InvalidArgument('missing client injected in paginated result'); + } + if (!$this->input instanceof ListFunctionsRequest) { + throw new InvalidArgument('missing last request injected in paginated result'); + } + $input = clone $this->input; + $page = $this; + while (true) { + $page->initialize(); + if (null !== $page->nextMarker) { + $input->setMarker($page->nextMarker); + + $this->registerPrefetch($nextPage = $client->listFunctions($input)); + } else { + $nextPage = null; + } + + yield from $page->functions; + + if (null === $nextPage) { + break; + } + + $this->unregisterPrefetch($nextPage); + $page = $nextPage; + } + } + + /** + * Iterates over Functions. + * + * @return \Traversable + */ + public function getIterator(): \Traversable + { + yield from $this->getFunctions(); + } + + public function getNextMarker(): ?string + { + $this->initialize(); + + return $this->nextMarker; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->nextMarker = isset($data['NextMarker']) ? (string) $data['NextMarker'] : null; + $this->functions = empty($data['Functions']) ? [] : $this->populateResultFunctionList($data['Functions']); + } + + /** + * @return list + */ + private function populateResultArchitecturesList(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + private function populateResultDeadLetterConfig(array $json): DeadLetterConfig + { + return new DeadLetterConfig([ + 'TargetArn' => isset($json['TargetArn']) ? (string) $json['TargetArn'] : null, + ]); + } + + private function populateResultEnvironmentError(array $json): EnvironmentError + { + return new EnvironmentError([ + 'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null, + 'Message' => isset($json['Message']) ? (string) $json['Message'] : null, + ]); + } + + private function populateResultEnvironmentResponse(array $json): EnvironmentResponse + { + return new EnvironmentResponse([ + 'Variables' => !isset($json['Variables']) ? null : $this->populateResultEnvironmentVariables($json['Variables']), + 'Error' => empty($json['Error']) ? null : $this->populateResultEnvironmentError($json['Error']), + ]); + } + + /** + * @return array + */ + private function populateResultEnvironmentVariables(array $json): array + { + $items = []; + foreach ($json as $name => $value) { + $items[(string) $name] = (string) $value; + } + + return $items; + } + + private function populateResultEphemeralStorage(array $json): EphemeralStorage + { + return new EphemeralStorage([ + 'Size' => (int) $json['Size'], + ]); + } + + private function populateResultFileSystemConfig(array $json): FileSystemConfig + { + return new FileSystemConfig([ + 'Arn' => (string) $json['Arn'], + 'LocalMountPath' => (string) $json['LocalMountPath'], + ]); + } + + /** + * @return FileSystemConfig[] + */ + private function populateResultFileSystemConfigList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultFileSystemConfig($item); + } + + return $items; + } + + private function populateResultFunctionConfiguration(array $json): FunctionConfiguration + { + return new FunctionConfiguration([ + 'FunctionName' => isset($json['FunctionName']) ? (string) $json['FunctionName'] : null, + 'FunctionArn' => isset($json['FunctionArn']) ? (string) $json['FunctionArn'] : null, + 'Runtime' => isset($json['Runtime']) ? (string) $json['Runtime'] : null, + 'Role' => isset($json['Role']) ? (string) $json['Role'] : null, + 'Handler' => isset($json['Handler']) ? (string) $json['Handler'] : null, + 'CodeSize' => isset($json['CodeSize']) ? (int) $json['CodeSize'] : null, + 'Description' => isset($json['Description']) ? (string) $json['Description'] : null, + 'Timeout' => isset($json['Timeout']) ? (int) $json['Timeout'] : null, + 'MemorySize' => isset($json['MemorySize']) ? (int) $json['MemorySize'] : null, + 'LastModified' => isset($json['LastModified']) ? (string) $json['LastModified'] : null, + 'CodeSha256' => isset($json['CodeSha256']) ? (string) $json['CodeSha256'] : null, + 'Version' => isset($json['Version']) ? (string) $json['Version'] : null, + 'VpcConfig' => empty($json['VpcConfig']) ? null : $this->populateResultVpcConfigResponse($json['VpcConfig']), + 'DeadLetterConfig' => empty($json['DeadLetterConfig']) ? null : $this->populateResultDeadLetterConfig($json['DeadLetterConfig']), + 'Environment' => empty($json['Environment']) ? null : $this->populateResultEnvironmentResponse($json['Environment']), + 'KMSKeyArn' => isset($json['KMSKeyArn']) ? (string) $json['KMSKeyArn'] : null, + 'TracingConfig' => empty($json['TracingConfig']) ? null : $this->populateResultTracingConfigResponse($json['TracingConfig']), + 'MasterArn' => isset($json['MasterArn']) ? (string) $json['MasterArn'] : null, + 'RevisionId' => isset($json['RevisionId']) ? (string) $json['RevisionId'] : null, + 'Layers' => !isset($json['Layers']) ? null : $this->populateResultLayersReferenceList($json['Layers']), + 'State' => isset($json['State']) ? (string) $json['State'] : null, + 'StateReason' => isset($json['StateReason']) ? (string) $json['StateReason'] : null, + 'StateReasonCode' => isset($json['StateReasonCode']) ? (string) $json['StateReasonCode'] : null, + 'LastUpdateStatus' => isset($json['LastUpdateStatus']) ? (string) $json['LastUpdateStatus'] : null, + 'LastUpdateStatusReason' => isset($json['LastUpdateStatusReason']) ? (string) $json['LastUpdateStatusReason'] : null, + 'LastUpdateStatusReasonCode' => isset($json['LastUpdateStatusReasonCode']) ? (string) $json['LastUpdateStatusReasonCode'] : null, + 'FileSystemConfigs' => !isset($json['FileSystemConfigs']) ? null : $this->populateResultFileSystemConfigList($json['FileSystemConfigs']), + 'PackageType' => isset($json['PackageType']) ? (string) $json['PackageType'] : null, + 'ImageConfigResponse' => empty($json['ImageConfigResponse']) ? null : $this->populateResultImageConfigResponse($json['ImageConfigResponse']), + 'SigningProfileVersionArn' => isset($json['SigningProfileVersionArn']) ? (string) $json['SigningProfileVersionArn'] : null, + 'SigningJobArn' => isset($json['SigningJobArn']) ? (string) $json['SigningJobArn'] : null, + 'Architectures' => !isset($json['Architectures']) ? null : $this->populateResultArchitecturesList($json['Architectures']), + 'EphemeralStorage' => empty($json['EphemeralStorage']) ? null : $this->populateResultEphemeralStorage($json['EphemeralStorage']), + 'SnapStart' => empty($json['SnapStart']) ? null : $this->populateResultSnapStartResponse($json['SnapStart']), + 'RuntimeVersionConfig' => empty($json['RuntimeVersionConfig']) ? null : $this->populateResultRuntimeVersionConfig($json['RuntimeVersionConfig']), + 'LoggingConfig' => empty($json['LoggingConfig']) ? null : $this->populateResultLoggingConfig($json['LoggingConfig']), + ]); + } + + /** + * @return FunctionConfiguration[] + */ + private function populateResultFunctionList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultFunctionConfiguration($item); + } + + return $items; + } + + private function populateResultImageConfig(array $json): ImageConfig + { + return new ImageConfig([ + 'EntryPoint' => !isset($json['EntryPoint']) ? null : $this->populateResultStringList($json['EntryPoint']), + 'Command' => !isset($json['Command']) ? null : $this->populateResultStringList($json['Command']), + 'WorkingDirectory' => isset($json['WorkingDirectory']) ? (string) $json['WorkingDirectory'] : null, + ]); + } + + private function populateResultImageConfigError(array $json): ImageConfigError + { + return new ImageConfigError([ + 'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null, + 'Message' => isset($json['Message']) ? (string) $json['Message'] : null, + ]); + } + + private function populateResultImageConfigResponse(array $json): ImageConfigResponse + { + return new ImageConfigResponse([ + 'ImageConfig' => empty($json['ImageConfig']) ? null : $this->populateResultImageConfig($json['ImageConfig']), + 'Error' => empty($json['Error']) ? null : $this->populateResultImageConfigError($json['Error']), + ]); + } + + private function populateResultLayer(array $json): Layer + { + return new Layer([ + 'Arn' => isset($json['Arn']) ? (string) $json['Arn'] : null, + 'CodeSize' => isset($json['CodeSize']) ? (int) $json['CodeSize'] : null, + 'SigningProfileVersionArn' => isset($json['SigningProfileVersionArn']) ? (string) $json['SigningProfileVersionArn'] : null, + 'SigningJobArn' => isset($json['SigningJobArn']) ? (string) $json['SigningJobArn'] : null, + ]); + } + + /** + * @return Layer[] + */ + private function populateResultLayersReferenceList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultLayer($item); + } + + return $items; + } + + private function populateResultLoggingConfig(array $json): LoggingConfig + { + return new LoggingConfig([ + 'LogFormat' => isset($json['LogFormat']) ? (string) $json['LogFormat'] : null, + 'ApplicationLogLevel' => isset($json['ApplicationLogLevel']) ? (string) $json['ApplicationLogLevel'] : null, + 'SystemLogLevel' => isset($json['SystemLogLevel']) ? (string) $json['SystemLogLevel'] : null, + 'LogGroup' => isset($json['LogGroup']) ? (string) $json['LogGroup'] : null, + ]); + } + + private function populateResultRuntimeVersionConfig(array $json): RuntimeVersionConfig + { + return new RuntimeVersionConfig([ + 'RuntimeVersionArn' => isset($json['RuntimeVersionArn']) ? (string) $json['RuntimeVersionArn'] : null, + 'Error' => empty($json['Error']) ? null : $this->populateResultRuntimeVersionError($json['Error']), + ]); + } + + private function populateResultRuntimeVersionError(array $json): RuntimeVersionError + { + return new RuntimeVersionError([ + 'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null, + 'Message' => isset($json['Message']) ? (string) $json['Message'] : null, + ]); + } + + /** + * @return string[] + */ + private function populateResultSecurityGroupIds(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + private function populateResultSnapStartResponse(array $json): SnapStartResponse + { + return new SnapStartResponse([ + 'ApplyOn' => isset($json['ApplyOn']) ? (string) $json['ApplyOn'] : null, + 'OptimizationStatus' => isset($json['OptimizationStatus']) ? (string) $json['OptimizationStatus'] : null, + ]); + } + + /** + * @return string[] + */ + private function populateResultStringList(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + /** + * @return string[] + */ + private function populateResultSubnetIds(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + private function populateResultTracingConfigResponse(array $json): TracingConfigResponse + { + return new TracingConfigResponse([ + 'Mode' => isset($json['Mode']) ? (string) $json['Mode'] : null, + ]); + } + + private function populateResultVpcConfigResponse(array $json): VpcConfigResponse + { + return new VpcConfigResponse([ + 'SubnetIds' => !isset($json['SubnetIds']) ? null : $this->populateResultSubnetIds($json['SubnetIds']), + 'SecurityGroupIds' => !isset($json['SecurityGroupIds']) ? null : $this->populateResultSecurityGroupIds($json['SecurityGroupIds']), + 'VpcId' => isset($json['VpcId']) ? (string) $json['VpcId'] : null, + 'Ipv6AllowedForDualStack' => isset($json['Ipv6AllowedForDualStack']) ? filter_var($json['Ipv6AllowedForDualStack'], \FILTER_VALIDATE_BOOLEAN) : null, + ]); + } +} diff --git a/src/Result/ListLayerVersionsResponse.php b/src/Result/ListLayerVersionsResponse.php index 8b44801..cc77d48 100644 --- a/src/Result/ListLayerVersionsResponse.php +++ b/src/Result/ListLayerVersionsResponse.php @@ -5,6 +5,7 @@ use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Core\Response; use AsyncAws\Core\Result; +use AsyncAws\Lambda\Enum\Architecture; use AsyncAws\Lambda\Enum\Runtime; use AsyncAws\Lambda\Input\ListLayerVersionsRequest; use AsyncAws\Lambda\LambdaClient; @@ -17,13 +18,17 @@ class ListLayerVersionsResponse extends Result implements \IteratorAggregate { /** * A pagination token returned when the response doesn't contain all versions. + * + * @var string|null */ - private $NextMarker; + private $nextMarker; /** * A list of versions. + * + * @var LayerVersionsListItem[] */ - private $LayerVersions = []; + private $layerVersions; /** * Iterates over LayerVersions. @@ -32,33 +37,7 @@ class ListLayerVersionsResponse extends Result implements \IteratorAggregate */ public function getIterator(): \Traversable { - $client = $this->awsClient; - if (!$client instanceof LambdaClient) { - throw new InvalidArgument('missing client injected in paginated result'); - } - if (!$this->input instanceof ListLayerVersionsRequest) { - throw new InvalidArgument('missing last request injected in paginated result'); - } - $input = clone $this->input; - $page = $this; - while (true) { - if ($page->getNextMarker()) { - $input->setMarker($page->getNextMarker()); - - $this->registerPrefetch($nextPage = $client->ListLayerVersions($input)); - } else { - $nextPage = null; - } - - yield from $page->getLayerVersions(true); - - if (null === $nextPage) { - break; - } - - $this->unregisterPrefetch($nextPage); - $page = $nextPage; - } + yield from $this->getLayerVersions(); } /** @@ -70,7 +49,7 @@ public function getLayerVersions(bool $currentPageOnly = false): iterable { if ($currentPageOnly) { $this->initialize(); - yield from $this->LayerVersions; + yield from $this->layerVersions; return; } @@ -85,15 +64,16 @@ public function getLayerVersions(bool $currentPageOnly = false): iterable $input = clone $this->input; $page = $this; while (true) { - if ($page->getNextMarker()) { - $input->setMarker($page->getNextMarker()); + $page->initialize(); + if (null !== $page->nextMarker) { + $input->setMarker($page->nextMarker); - $this->registerPrefetch($nextPage = $client->ListLayerVersions($input)); + $this->registerPrefetch($nextPage = $client->listLayerVersions($input)); } else { $nextPage = null; } - yield from $page->getLayerVersions(true); + yield from $page->layerVersions; if (null === $nextPage) { break; @@ -108,15 +88,31 @@ public function getNextMarker(): ?string { $this->initialize(); - return $this->NextMarker; + return $this->nextMarker; } protected function populateResult(Response $response): void { $data = $response->toArray(); - $this->NextMarker = isset($data['NextMarker']) ? (string) $data['NextMarker'] : null; - $this->LayerVersions = empty($data['LayerVersions']) ? [] : $this->populateResultLayerVersionsList($data['LayerVersions']); + $this->nextMarker = isset($data['NextMarker']) ? (string) $data['NextMarker'] : null; + $this->layerVersions = empty($data['LayerVersions']) ? [] : $this->populateResultLayerVersionsList($data['LayerVersions']); + } + + /** + * @return list + */ + private function populateResultCompatibleArchitectures(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; } /** @@ -142,16 +138,22 @@ private function populateResultLayerVersionsList(array $json): array { $items = []; foreach ($json as $item) { - $items[] = new LayerVersionsListItem([ - 'LayerVersionArn' => isset($item['LayerVersionArn']) ? (string) $item['LayerVersionArn'] : null, - 'Version' => isset($item['Version']) ? (string) $item['Version'] : null, - 'Description' => isset($item['Description']) ? (string) $item['Description'] : null, - 'CreatedDate' => isset($item['CreatedDate']) ? (string) $item['CreatedDate'] : null, - 'CompatibleRuntimes' => empty($item['CompatibleRuntimes']) ? [] : $this->populateResultCompatibleRuntimes($item['CompatibleRuntimes']), - 'LicenseInfo' => isset($item['LicenseInfo']) ? (string) $item['LicenseInfo'] : null, - ]); + $items[] = $this->populateResultLayerVersionsListItem($item); } return $items; } + + private function populateResultLayerVersionsListItem(array $json): LayerVersionsListItem + { + return new LayerVersionsListItem([ + 'LayerVersionArn' => isset($json['LayerVersionArn']) ? (string) $json['LayerVersionArn'] : null, + 'Version' => isset($json['Version']) ? (int) $json['Version'] : null, + 'Description' => isset($json['Description']) ? (string) $json['Description'] : null, + 'CreatedDate' => isset($json['CreatedDate']) ? (string) $json['CreatedDate'] : null, + 'CompatibleRuntimes' => !isset($json['CompatibleRuntimes']) ? null : $this->populateResultCompatibleRuntimes($json['CompatibleRuntimes']), + 'LicenseInfo' => isset($json['LicenseInfo']) ? (string) $json['LicenseInfo'] : null, + 'CompatibleArchitectures' => !isset($json['CompatibleArchitectures']) ? null : $this->populateResultCompatibleArchitectures($json['CompatibleArchitectures']), + ]); + } } diff --git a/src/Result/ListVersionsByFunctionResponse.php b/src/Result/ListVersionsByFunctionResponse.php new file mode 100644 index 0000000..8fc119f --- /dev/null +++ b/src/Result/ListVersionsByFunctionResponse.php @@ -0,0 +1,397 @@ + + */ +class ListVersionsByFunctionResponse extends Result implements \IteratorAggregate +{ + /** + * The pagination token that's included if more results are available. + * + * @var string|null + */ + private $nextMarker; + + /** + * A list of Lambda function versions. + * + * @var FunctionConfiguration[] + */ + private $versions; + + /** + * Iterates over Versions. + * + * @return \Traversable + */ + public function getIterator(): \Traversable + { + yield from $this->getVersions(); + } + + public function getNextMarker(): ?string + { + $this->initialize(); + + return $this->nextMarker; + } + + /** + * @param bool $currentPageOnly When true, iterates over items of the current page. Otherwise also fetch items in the next pages. + * + * @return iterable + */ + public function getVersions(bool $currentPageOnly = false): iterable + { + if ($currentPageOnly) { + $this->initialize(); + yield from $this->versions; + + return; + } + + $client = $this->awsClient; + if (!$client instanceof LambdaClient) { + throw new InvalidArgument('missing client injected in paginated result'); + } + if (!$this->input instanceof ListVersionsByFunctionRequest) { + throw new InvalidArgument('missing last request injected in paginated result'); + } + $input = clone $this->input; + $page = $this; + while (true) { + $page->initialize(); + if (null !== $page->nextMarker) { + $input->setMarker($page->nextMarker); + + $this->registerPrefetch($nextPage = $client->listVersionsByFunction($input)); + } else { + $nextPage = null; + } + + yield from $page->versions; + + if (null === $nextPage) { + break; + } + + $this->unregisterPrefetch($nextPage); + $page = $nextPage; + } + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->nextMarker = isset($data['NextMarker']) ? (string) $data['NextMarker'] : null; + $this->versions = empty($data['Versions']) ? [] : $this->populateResultFunctionList($data['Versions']); + } + + /** + * @return list + */ + private function populateResultArchitecturesList(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + private function populateResultDeadLetterConfig(array $json): DeadLetterConfig + { + return new DeadLetterConfig([ + 'TargetArn' => isset($json['TargetArn']) ? (string) $json['TargetArn'] : null, + ]); + } + + private function populateResultEnvironmentError(array $json): EnvironmentError + { + return new EnvironmentError([ + 'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null, + 'Message' => isset($json['Message']) ? (string) $json['Message'] : null, + ]); + } + + private function populateResultEnvironmentResponse(array $json): EnvironmentResponse + { + return new EnvironmentResponse([ + 'Variables' => !isset($json['Variables']) ? null : $this->populateResultEnvironmentVariables($json['Variables']), + 'Error' => empty($json['Error']) ? null : $this->populateResultEnvironmentError($json['Error']), + ]); + } + + /** + * @return array + */ + private function populateResultEnvironmentVariables(array $json): array + { + $items = []; + foreach ($json as $name => $value) { + $items[(string) $name] = (string) $value; + } + + return $items; + } + + private function populateResultEphemeralStorage(array $json): EphemeralStorage + { + return new EphemeralStorage([ + 'Size' => (int) $json['Size'], + ]); + } + + private function populateResultFileSystemConfig(array $json): FileSystemConfig + { + return new FileSystemConfig([ + 'Arn' => (string) $json['Arn'], + 'LocalMountPath' => (string) $json['LocalMountPath'], + ]); + } + + /** + * @return FileSystemConfig[] + */ + private function populateResultFileSystemConfigList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultFileSystemConfig($item); + } + + return $items; + } + + private function populateResultFunctionConfiguration(array $json): FunctionConfiguration + { + return new FunctionConfiguration([ + 'FunctionName' => isset($json['FunctionName']) ? (string) $json['FunctionName'] : null, + 'FunctionArn' => isset($json['FunctionArn']) ? (string) $json['FunctionArn'] : null, + 'Runtime' => isset($json['Runtime']) ? (string) $json['Runtime'] : null, + 'Role' => isset($json['Role']) ? (string) $json['Role'] : null, + 'Handler' => isset($json['Handler']) ? (string) $json['Handler'] : null, + 'CodeSize' => isset($json['CodeSize']) ? (int) $json['CodeSize'] : null, + 'Description' => isset($json['Description']) ? (string) $json['Description'] : null, + 'Timeout' => isset($json['Timeout']) ? (int) $json['Timeout'] : null, + 'MemorySize' => isset($json['MemorySize']) ? (int) $json['MemorySize'] : null, + 'LastModified' => isset($json['LastModified']) ? (string) $json['LastModified'] : null, + 'CodeSha256' => isset($json['CodeSha256']) ? (string) $json['CodeSha256'] : null, + 'Version' => isset($json['Version']) ? (string) $json['Version'] : null, + 'VpcConfig' => empty($json['VpcConfig']) ? null : $this->populateResultVpcConfigResponse($json['VpcConfig']), + 'DeadLetterConfig' => empty($json['DeadLetterConfig']) ? null : $this->populateResultDeadLetterConfig($json['DeadLetterConfig']), + 'Environment' => empty($json['Environment']) ? null : $this->populateResultEnvironmentResponse($json['Environment']), + 'KMSKeyArn' => isset($json['KMSKeyArn']) ? (string) $json['KMSKeyArn'] : null, + 'TracingConfig' => empty($json['TracingConfig']) ? null : $this->populateResultTracingConfigResponse($json['TracingConfig']), + 'MasterArn' => isset($json['MasterArn']) ? (string) $json['MasterArn'] : null, + 'RevisionId' => isset($json['RevisionId']) ? (string) $json['RevisionId'] : null, + 'Layers' => !isset($json['Layers']) ? null : $this->populateResultLayersReferenceList($json['Layers']), + 'State' => isset($json['State']) ? (string) $json['State'] : null, + 'StateReason' => isset($json['StateReason']) ? (string) $json['StateReason'] : null, + 'StateReasonCode' => isset($json['StateReasonCode']) ? (string) $json['StateReasonCode'] : null, + 'LastUpdateStatus' => isset($json['LastUpdateStatus']) ? (string) $json['LastUpdateStatus'] : null, + 'LastUpdateStatusReason' => isset($json['LastUpdateStatusReason']) ? (string) $json['LastUpdateStatusReason'] : null, + 'LastUpdateStatusReasonCode' => isset($json['LastUpdateStatusReasonCode']) ? (string) $json['LastUpdateStatusReasonCode'] : null, + 'FileSystemConfigs' => !isset($json['FileSystemConfigs']) ? null : $this->populateResultFileSystemConfigList($json['FileSystemConfigs']), + 'PackageType' => isset($json['PackageType']) ? (string) $json['PackageType'] : null, + 'ImageConfigResponse' => empty($json['ImageConfigResponse']) ? null : $this->populateResultImageConfigResponse($json['ImageConfigResponse']), + 'SigningProfileVersionArn' => isset($json['SigningProfileVersionArn']) ? (string) $json['SigningProfileVersionArn'] : null, + 'SigningJobArn' => isset($json['SigningJobArn']) ? (string) $json['SigningJobArn'] : null, + 'Architectures' => !isset($json['Architectures']) ? null : $this->populateResultArchitecturesList($json['Architectures']), + 'EphemeralStorage' => empty($json['EphemeralStorage']) ? null : $this->populateResultEphemeralStorage($json['EphemeralStorage']), + 'SnapStart' => empty($json['SnapStart']) ? null : $this->populateResultSnapStartResponse($json['SnapStart']), + 'RuntimeVersionConfig' => empty($json['RuntimeVersionConfig']) ? null : $this->populateResultRuntimeVersionConfig($json['RuntimeVersionConfig']), + 'LoggingConfig' => empty($json['LoggingConfig']) ? null : $this->populateResultLoggingConfig($json['LoggingConfig']), + ]); + } + + /** + * @return FunctionConfiguration[] + */ + private function populateResultFunctionList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultFunctionConfiguration($item); + } + + return $items; + } + + private function populateResultImageConfig(array $json): ImageConfig + { + return new ImageConfig([ + 'EntryPoint' => !isset($json['EntryPoint']) ? null : $this->populateResultStringList($json['EntryPoint']), + 'Command' => !isset($json['Command']) ? null : $this->populateResultStringList($json['Command']), + 'WorkingDirectory' => isset($json['WorkingDirectory']) ? (string) $json['WorkingDirectory'] : null, + ]); + } + + private function populateResultImageConfigError(array $json): ImageConfigError + { + return new ImageConfigError([ + 'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null, + 'Message' => isset($json['Message']) ? (string) $json['Message'] : null, + ]); + } + + private function populateResultImageConfigResponse(array $json): ImageConfigResponse + { + return new ImageConfigResponse([ + 'ImageConfig' => empty($json['ImageConfig']) ? null : $this->populateResultImageConfig($json['ImageConfig']), + 'Error' => empty($json['Error']) ? null : $this->populateResultImageConfigError($json['Error']), + ]); + } + + private function populateResultLayer(array $json): Layer + { + return new Layer([ + 'Arn' => isset($json['Arn']) ? (string) $json['Arn'] : null, + 'CodeSize' => isset($json['CodeSize']) ? (int) $json['CodeSize'] : null, + 'SigningProfileVersionArn' => isset($json['SigningProfileVersionArn']) ? (string) $json['SigningProfileVersionArn'] : null, + 'SigningJobArn' => isset($json['SigningJobArn']) ? (string) $json['SigningJobArn'] : null, + ]); + } + + /** + * @return Layer[] + */ + private function populateResultLayersReferenceList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultLayer($item); + } + + return $items; + } + + private function populateResultLoggingConfig(array $json): LoggingConfig + { + return new LoggingConfig([ + 'LogFormat' => isset($json['LogFormat']) ? (string) $json['LogFormat'] : null, + 'ApplicationLogLevel' => isset($json['ApplicationLogLevel']) ? (string) $json['ApplicationLogLevel'] : null, + 'SystemLogLevel' => isset($json['SystemLogLevel']) ? (string) $json['SystemLogLevel'] : null, + 'LogGroup' => isset($json['LogGroup']) ? (string) $json['LogGroup'] : null, + ]); + } + + private function populateResultRuntimeVersionConfig(array $json): RuntimeVersionConfig + { + return new RuntimeVersionConfig([ + 'RuntimeVersionArn' => isset($json['RuntimeVersionArn']) ? (string) $json['RuntimeVersionArn'] : null, + 'Error' => empty($json['Error']) ? null : $this->populateResultRuntimeVersionError($json['Error']), + ]); + } + + private function populateResultRuntimeVersionError(array $json): RuntimeVersionError + { + return new RuntimeVersionError([ + 'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null, + 'Message' => isset($json['Message']) ? (string) $json['Message'] : null, + ]); + } + + /** + * @return string[] + */ + private function populateResultSecurityGroupIds(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + private function populateResultSnapStartResponse(array $json): SnapStartResponse + { + return new SnapStartResponse([ + 'ApplyOn' => isset($json['ApplyOn']) ? (string) $json['ApplyOn'] : null, + 'OptimizationStatus' => isset($json['OptimizationStatus']) ? (string) $json['OptimizationStatus'] : null, + ]); + } + + /** + * @return string[] + */ + private function populateResultStringList(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + /** + * @return string[] + */ + private function populateResultSubnetIds(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + private function populateResultTracingConfigResponse(array $json): TracingConfigResponse + { + return new TracingConfigResponse([ + 'Mode' => isset($json['Mode']) ? (string) $json['Mode'] : null, + ]); + } + + private function populateResultVpcConfigResponse(array $json): VpcConfigResponse + { + return new VpcConfigResponse([ + 'SubnetIds' => !isset($json['SubnetIds']) ? null : $this->populateResultSubnetIds($json['SubnetIds']), + 'SecurityGroupIds' => !isset($json['SecurityGroupIds']) ? null : $this->populateResultSecurityGroupIds($json['SecurityGroupIds']), + 'VpcId' => isset($json['VpcId']) ? (string) $json['VpcId'] : null, + 'Ipv6AllowedForDualStack' => isset($json['Ipv6AllowedForDualStack']) ? filter_var($json['Ipv6AllowedForDualStack'], \FILTER_VALIDATE_BOOLEAN) : null, + ]); + } +} diff --git a/src/Result/PublishLayerVersionResponse.php b/src/Result/PublishLayerVersionResponse.php index 520dad7..53a53fa 100644 --- a/src/Result/PublishLayerVersionResponse.php +++ b/src/Result/PublishLayerVersionResponse.php @@ -4,6 +4,7 @@ use AsyncAws\Core\Response; use AsyncAws\Core\Result; +use AsyncAws\Lambda\Enum\Architecture; use AsyncAws\Lambda\Enum\Runtime; use AsyncAws\Lambda\ValueObject\LayerVersionContentOutput; @@ -11,45 +12,87 @@ class PublishLayerVersionResponse extends Result { /** * Details about the layer version. + * + * @var LayerVersionContentOutput|null */ - private $Content; + private $content; /** * The ARN of the layer. + * + * @var string|null */ - private $LayerArn; + private $layerArn; /** * The ARN of the layer version. + * + * @var string|null */ - private $LayerVersionArn; + private $layerVersionArn; /** * The description of the version. + * + * @var string|null */ - private $Description; + private $description; /** - * The date that the layer version was created, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD). + * The date that the layer version was created, in ISO-8601 format [^1] (YYYY-MM-DDThh:mm:ss.sTZD). + * + * [^1]: https://www.w3.org/TR/NOTE-datetime * - * @see https://www.w3.org/TR/NOTE-datetime + * @var string|null */ - private $CreatedDate; + private $createdDate; /** * The version number. + * + * @var int|null */ - private $Version; + private $version; /** * The layer's compatible runtimes. + * + * The following list includes deprecated runtimes. For more information, see Runtime use after deprecation [^1]. + * + * For a list of all currently supported runtimes, see Supported runtimes [^2]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtime-deprecation-levels + * [^2]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtimes-supported + * + * @var list */ - private $CompatibleRuntimes = []; + private $compatibleRuntimes; /** * The layer's software license. + * + * @var string|null */ - private $LicenseInfo; + private $licenseInfo; + + /** + * A list of compatible instruction set architectures [^1]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html + * + * @var list + */ + private $compatibleArchitectures; + + /** + * @return list + */ + public function getCompatibleArchitectures(): array + { + $this->initialize(); + + return $this->compatibleArchitectures; + } /** * @return list @@ -58,74 +101,87 @@ public function getCompatibleRuntimes(): array { $this->initialize(); - return $this->CompatibleRuntimes; + return $this->compatibleRuntimes; } public function getContent(): ?LayerVersionContentOutput { $this->initialize(); - return $this->Content; + return $this->content; } public function getCreatedDate(): ?string { $this->initialize(); - return $this->CreatedDate; + return $this->createdDate; } public function getDescription(): ?string { $this->initialize(); - return $this->Description; + return $this->description; } public function getLayerArn(): ?string { $this->initialize(); - return $this->LayerArn; + return $this->layerArn; } public function getLayerVersionArn(): ?string { $this->initialize(); - return $this->LayerVersionArn; + return $this->layerVersionArn; } public function getLicenseInfo(): ?string { $this->initialize(); - return $this->LicenseInfo; + return $this->licenseInfo; } - public function getVersion(): ?string + public function getVersion(): ?int { $this->initialize(); - return $this->Version; + return $this->version; } protected function populateResult(Response $response): void { $data = $response->toArray(); - $this->Content = empty($data['Content']) ? null : new LayerVersionContentOutput([ - 'Location' => isset($data['Content']['Location']) ? (string) $data['Content']['Location'] : null, - 'CodeSha256' => isset($data['Content']['CodeSha256']) ? (string) $data['Content']['CodeSha256'] : null, - 'CodeSize' => isset($data['Content']['CodeSize']) ? (string) $data['Content']['CodeSize'] : null, - ]); - $this->LayerArn = isset($data['LayerArn']) ? (string) $data['LayerArn'] : null; - $this->LayerVersionArn = isset($data['LayerVersionArn']) ? (string) $data['LayerVersionArn'] : null; - $this->Description = isset($data['Description']) ? (string) $data['Description'] : null; - $this->CreatedDate = isset($data['CreatedDate']) ? (string) $data['CreatedDate'] : null; - $this->Version = isset($data['Version']) ? (string) $data['Version'] : null; - $this->CompatibleRuntimes = empty($data['CompatibleRuntimes']) ? [] : $this->populateResultCompatibleRuntimes($data['CompatibleRuntimes']); - $this->LicenseInfo = isset($data['LicenseInfo']) ? (string) $data['LicenseInfo'] : null; + $this->content = empty($data['Content']) ? null : $this->populateResultLayerVersionContentOutput($data['Content']); + $this->layerArn = isset($data['LayerArn']) ? (string) $data['LayerArn'] : null; + $this->layerVersionArn = isset($data['LayerVersionArn']) ? (string) $data['LayerVersionArn'] : null; + $this->description = isset($data['Description']) ? (string) $data['Description'] : null; + $this->createdDate = isset($data['CreatedDate']) ? (string) $data['CreatedDate'] : null; + $this->version = isset($data['Version']) ? (int) $data['Version'] : null; + $this->compatibleRuntimes = empty($data['CompatibleRuntimes']) ? [] : $this->populateResultCompatibleRuntimes($data['CompatibleRuntimes']); + $this->licenseInfo = isset($data['LicenseInfo']) ? (string) $data['LicenseInfo'] : null; + $this->compatibleArchitectures = empty($data['CompatibleArchitectures']) ? [] : $this->populateResultCompatibleArchitectures($data['CompatibleArchitectures']); + } + + /** + * @return list + */ + private function populateResultCompatibleArchitectures(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; } /** @@ -143,4 +199,15 @@ private function populateResultCompatibleRuntimes(array $json): array return $items; } + + private function populateResultLayerVersionContentOutput(array $json): LayerVersionContentOutput + { + return new LayerVersionContentOutput([ + 'Location' => isset($json['Location']) ? (string) $json['Location'] : null, + 'CodeSha256' => isset($json['CodeSha256']) ? (string) $json['CodeSha256'] : null, + 'CodeSize' => isset($json['CodeSize']) ? (int) $json['CodeSize'] : null, + 'SigningProfileVersionArn' => isset($json['SigningProfileVersionArn']) ? (string) $json['SigningProfileVersionArn'] : null, + 'SigningJobArn' => isset($json['SigningJobArn']) ? (string) $json['SigningJobArn'] : null, + ]); + } } diff --git a/src/ValueObject/DeadLetterConfig.php b/src/ValueObject/DeadLetterConfig.php new file mode 100644 index 0000000..4ce46ea --- /dev/null +++ b/src/ValueObject/DeadLetterConfig.php @@ -0,0 +1,56 @@ +targetArn = $input['TargetArn'] ?? null; + } + + /** + * @param array{ + * TargetArn?: null|string, + * }|DeadLetterConfig $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getTargetArn(): ?string + { + return $this->targetArn; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->targetArn) { + $payload['TargetArn'] = $v; + } + + return $payload; + } +} diff --git a/src/ValueObject/Environment.php b/src/ValueObject/Environment.php new file mode 100644 index 0000000..28fb122 --- /dev/null +++ b/src/ValueObject/Environment.php @@ -0,0 +1,68 @@ +|null + */ + private $variables; + + /** + * @param array{ + * Variables?: null|array, + * } $input + */ + public function __construct(array $input) + { + $this->variables = $input['Variables'] ?? null; + } + + /** + * @param array{ + * Variables?: null|array, + * }|Environment $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return array + */ + public function getVariables(): array + { + return $this->variables ?? []; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->variables) { + if (empty($v)) { + $payload['Variables'] = new \stdClass(); + } else { + $payload['Variables'] = []; + foreach ($v as $name => $mv) { + $payload['Variables'][$name] = $mv; + } + } + } + + return $payload; + } +} diff --git a/src/ValueObject/EnvironmentError.php b/src/ValueObject/EnvironmentError.php new file mode 100644 index 0000000..0715019 --- /dev/null +++ b/src/ValueObject/EnvironmentError.php @@ -0,0 +1,56 @@ +errorCode = $input['ErrorCode'] ?? null; + $this->message = $input['Message'] ?? null; + } + + /** + * @param array{ + * ErrorCode?: null|string, + * Message?: null|string, + * }|EnvironmentError $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getErrorCode(): ?string + { + return $this->errorCode; + } + + public function getMessage(): ?string + { + return $this->message; + } +} diff --git a/src/ValueObject/EnvironmentResponse.php b/src/ValueObject/EnvironmentResponse.php new file mode 100644 index 0000000..31b991e --- /dev/null +++ b/src/ValueObject/EnvironmentResponse.php @@ -0,0 +1,60 @@ +|null + */ + private $variables; + + /** + * Error messages for environment variables that couldn't be applied. + * + * @var EnvironmentError|null + */ + private $error; + + /** + * @param array{ + * Variables?: null|array, + * Error?: null|EnvironmentError|array, + * } $input + */ + public function __construct(array $input) + { + $this->variables = $input['Variables'] ?? null; + $this->error = isset($input['Error']) ? EnvironmentError::create($input['Error']) : null; + } + + /** + * @param array{ + * Variables?: null|array, + * Error?: null|EnvironmentError|array, + * }|EnvironmentResponse $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getError(): ?EnvironmentError + { + return $this->error; + } + + /** + * @return array + */ + public function getVariables(): array + { + return $this->variables ?? []; + } +} diff --git a/src/ValueObject/EphemeralStorage.php b/src/ValueObject/EphemeralStorage.php new file mode 100644 index 0000000..f248fc4 --- /dev/null +++ b/src/ValueObject/EphemeralStorage.php @@ -0,0 +1,66 @@ +size = $input['Size'] ?? $this->throwException(new InvalidArgument('Missing required field "Size".')); + } + + /** + * @param array{ + * Size: int, + * }|EphemeralStorage $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getSize(): int + { + return $this->size; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + $v = $this->size; + $payload['Size'] = $v; + + return $payload; + } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } +} diff --git a/src/ValueObject/FileSystemConfig.php b/src/ValueObject/FileSystemConfig.php new file mode 100644 index 0000000..bd98983 --- /dev/null +++ b/src/ValueObject/FileSystemConfig.php @@ -0,0 +1,82 @@ +arn = $input['Arn'] ?? $this->throwException(new InvalidArgument('Missing required field "Arn".')); + $this->localMountPath = $input['LocalMountPath'] ?? $this->throwException(new InvalidArgument('Missing required field "LocalMountPath".')); + } + + /** + * @param array{ + * Arn: string, + * LocalMountPath: string, + * }|FileSystemConfig $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getArn(): string + { + return $this->arn; + } + + public function getLocalMountPath(): string + { + return $this->localMountPath; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + $v = $this->arn; + $payload['Arn'] = $v; + $v = $this->localMountPath; + $payload['LocalMountPath'] = $v; + + return $payload; + } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } +} diff --git a/src/ValueObject/FunctionConfiguration.php b/src/ValueObject/FunctionConfiguration.php new file mode 100644 index 0000000..c3ec754 --- /dev/null +++ b/src/ValueObject/FunctionConfiguration.php @@ -0,0 +1,646 @@ +|null + */ + private $architectures; + + /** + * The size of the function's `/tmp` directory in MB. The default value is 512, but can be any whole number between 512 + * and 10,240 MB. For more information, see Configuring ephemeral storage (console) [^1]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-ephemeral-storage + * + * @var EphemeralStorage|null + */ + private $ephemeralStorage; + + /** + * Set `ApplyOn` to `PublishedVersions` to create a snapshot of the initialized execution environment when you publish a + * function version. For more information, see Improving startup performance with Lambda SnapStart [^1]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html + * + * @var SnapStartResponse|null + */ + private $snapStart; + + /** + * The ARN of the runtime and any errors that occured. + * + * @var RuntimeVersionConfig|null + */ + private $runtimeVersionConfig; + + /** + * The function's Amazon CloudWatch Logs configuration settings. + * + * @var LoggingConfig|null + */ + private $loggingConfig; + + /** + * @param array{ + * FunctionName?: null|string, + * FunctionArn?: null|string, + * Runtime?: null|Runtime::*, + * Role?: null|string, + * Handler?: null|string, + * CodeSize?: null|int, + * Description?: null|string, + * Timeout?: null|int, + * MemorySize?: null|int, + * LastModified?: null|string, + * CodeSha256?: null|string, + * Version?: null|string, + * VpcConfig?: null|VpcConfigResponse|array, + * DeadLetterConfig?: null|DeadLetterConfig|array, + * Environment?: null|EnvironmentResponse|array, + * KMSKeyArn?: null|string, + * TracingConfig?: null|TracingConfigResponse|array, + * MasterArn?: null|string, + * RevisionId?: null|string, + * Layers?: null|array, + * State?: null|State::*, + * StateReason?: null|string, + * StateReasonCode?: null|StateReasonCode::*, + * LastUpdateStatus?: null|LastUpdateStatus::*, + * LastUpdateStatusReason?: null|string, + * LastUpdateStatusReasonCode?: null|LastUpdateStatusReasonCode::*, + * FileSystemConfigs?: null|array, + * PackageType?: null|PackageType::*, + * ImageConfigResponse?: null|ImageConfigResponse|array, + * SigningProfileVersionArn?: null|string, + * SigningJobArn?: null|string, + * Architectures?: null|array, + * EphemeralStorage?: null|EphemeralStorage|array, + * SnapStart?: null|SnapStartResponse|array, + * RuntimeVersionConfig?: null|RuntimeVersionConfig|array, + * LoggingConfig?: null|LoggingConfig|array, + * } $input + */ + public function __construct(array $input) + { + $this->functionName = $input['FunctionName'] ?? null; + $this->functionArn = $input['FunctionArn'] ?? null; + $this->runtime = $input['Runtime'] ?? null; + $this->role = $input['Role'] ?? null; + $this->handler = $input['Handler'] ?? null; + $this->codeSize = $input['CodeSize'] ?? null; + $this->description = $input['Description'] ?? null; + $this->timeout = $input['Timeout'] ?? null; + $this->memorySize = $input['MemorySize'] ?? null; + $this->lastModified = $input['LastModified'] ?? null; + $this->codeSha256 = $input['CodeSha256'] ?? null; + $this->version = $input['Version'] ?? null; + $this->vpcConfig = isset($input['VpcConfig']) ? VpcConfigResponse::create($input['VpcConfig']) : null; + $this->deadLetterConfig = isset($input['DeadLetterConfig']) ? DeadLetterConfig::create($input['DeadLetterConfig']) : null; + $this->environment = isset($input['Environment']) ? EnvironmentResponse::create($input['Environment']) : null; + $this->kmsKeyArn = $input['KMSKeyArn'] ?? null; + $this->tracingConfig = isset($input['TracingConfig']) ? TracingConfigResponse::create($input['TracingConfig']) : null; + $this->masterArn = $input['MasterArn'] ?? null; + $this->revisionId = $input['RevisionId'] ?? null; + $this->layers = isset($input['Layers']) ? array_map([Layer::class, 'create'], $input['Layers']) : null; + $this->state = $input['State'] ?? null; + $this->stateReason = $input['StateReason'] ?? null; + $this->stateReasonCode = $input['StateReasonCode'] ?? null; + $this->lastUpdateStatus = $input['LastUpdateStatus'] ?? null; + $this->lastUpdateStatusReason = $input['LastUpdateStatusReason'] ?? null; + $this->lastUpdateStatusReasonCode = $input['LastUpdateStatusReasonCode'] ?? null; + $this->fileSystemConfigs = isset($input['FileSystemConfigs']) ? array_map([FileSystemConfig::class, 'create'], $input['FileSystemConfigs']) : null; + $this->packageType = $input['PackageType'] ?? null; + $this->imageConfigResponse = isset($input['ImageConfigResponse']) ? ImageConfigResponse::create($input['ImageConfigResponse']) : null; + $this->signingProfileVersionArn = $input['SigningProfileVersionArn'] ?? null; + $this->signingJobArn = $input['SigningJobArn'] ?? null; + $this->architectures = $input['Architectures'] ?? null; + $this->ephemeralStorage = isset($input['EphemeralStorage']) ? EphemeralStorage::create($input['EphemeralStorage']) : null; + $this->snapStart = isset($input['SnapStart']) ? SnapStartResponse::create($input['SnapStart']) : null; + $this->runtimeVersionConfig = isset($input['RuntimeVersionConfig']) ? RuntimeVersionConfig::create($input['RuntimeVersionConfig']) : null; + $this->loggingConfig = isset($input['LoggingConfig']) ? LoggingConfig::create($input['LoggingConfig']) : null; + } + + /** + * @param array{ + * FunctionName?: null|string, + * FunctionArn?: null|string, + * Runtime?: null|Runtime::*, + * Role?: null|string, + * Handler?: null|string, + * CodeSize?: null|int, + * Description?: null|string, + * Timeout?: null|int, + * MemorySize?: null|int, + * LastModified?: null|string, + * CodeSha256?: null|string, + * Version?: null|string, + * VpcConfig?: null|VpcConfigResponse|array, + * DeadLetterConfig?: null|DeadLetterConfig|array, + * Environment?: null|EnvironmentResponse|array, + * KMSKeyArn?: null|string, + * TracingConfig?: null|TracingConfigResponse|array, + * MasterArn?: null|string, + * RevisionId?: null|string, + * Layers?: null|array, + * State?: null|State::*, + * StateReason?: null|string, + * StateReasonCode?: null|StateReasonCode::*, + * LastUpdateStatus?: null|LastUpdateStatus::*, + * LastUpdateStatusReason?: null|string, + * LastUpdateStatusReasonCode?: null|LastUpdateStatusReasonCode::*, + * FileSystemConfigs?: null|array, + * PackageType?: null|PackageType::*, + * ImageConfigResponse?: null|ImageConfigResponse|array, + * SigningProfileVersionArn?: null|string, + * SigningJobArn?: null|string, + * Architectures?: null|array, + * EphemeralStorage?: null|EphemeralStorage|array, + * SnapStart?: null|SnapStartResponse|array, + * RuntimeVersionConfig?: null|RuntimeVersionConfig|array, + * LoggingConfig?: null|LoggingConfig|array, + * }|FunctionConfiguration $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return list + */ + public function getArchitectures(): array + { + return $this->architectures ?? []; + } + + public function getCodeSha256(): ?string + { + return $this->codeSha256; + } + + public function getCodeSize(): ?int + { + return $this->codeSize; + } + + public function getDeadLetterConfig(): ?DeadLetterConfig + { + return $this->deadLetterConfig; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function getEnvironment(): ?EnvironmentResponse + { + return $this->environment; + } + + public function getEphemeralStorage(): ?EphemeralStorage + { + return $this->ephemeralStorage; + } + + /** + * @return FileSystemConfig[] + */ + public function getFileSystemConfigs(): array + { + return $this->fileSystemConfigs ?? []; + } + + public function getFunctionArn(): ?string + { + return $this->functionArn; + } + + public function getFunctionName(): ?string + { + return $this->functionName; + } + + public function getHandler(): ?string + { + return $this->handler; + } + + public function getImageConfigResponse(): ?ImageConfigResponse + { + return $this->imageConfigResponse; + } + + public function getKmsKeyArn(): ?string + { + return $this->kmsKeyArn; + } + + public function getLastModified(): ?string + { + return $this->lastModified; + } + + /** + * @return LastUpdateStatus::*|null + */ + public function getLastUpdateStatus(): ?string + { + return $this->lastUpdateStatus; + } + + public function getLastUpdateStatusReason(): ?string + { + return $this->lastUpdateStatusReason; + } + + /** + * @return LastUpdateStatusReasonCode::*|null + */ + public function getLastUpdateStatusReasonCode(): ?string + { + return $this->lastUpdateStatusReasonCode; + } + + /** + * @return Layer[] + */ + public function getLayers(): array + { + return $this->layers ?? []; + } + + public function getLoggingConfig(): ?LoggingConfig + { + return $this->loggingConfig; + } + + public function getMasterArn(): ?string + { + return $this->masterArn; + } + + public function getMemorySize(): ?int + { + return $this->memorySize; + } + + /** + * @return PackageType::*|null + */ + public function getPackageType(): ?string + { + return $this->packageType; + } + + public function getRevisionId(): ?string + { + return $this->revisionId; + } + + public function getRole(): ?string + { + return $this->role; + } + + /** + * @return Runtime::*|null + */ + public function getRuntime(): ?string + { + return $this->runtime; + } + + public function getRuntimeVersionConfig(): ?RuntimeVersionConfig + { + return $this->runtimeVersionConfig; + } + + public function getSigningJobArn(): ?string + { + return $this->signingJobArn; + } + + public function getSigningProfileVersionArn(): ?string + { + return $this->signingProfileVersionArn; + } + + public function getSnapStart(): ?SnapStartResponse + { + return $this->snapStart; + } + + /** + * @return State::*|null + */ + public function getState(): ?string + { + return $this->state; + } + + public function getStateReason(): ?string + { + return $this->stateReason; + } + + /** + * @return StateReasonCode::*|null + */ + public function getStateReasonCode(): ?string + { + return $this->stateReasonCode; + } + + public function getTimeout(): ?int + { + return $this->timeout; + } + + public function getTracingConfig(): ?TracingConfigResponse + { + return $this->tracingConfig; + } + + public function getVersion(): ?string + { + return $this->version; + } + + public function getVpcConfig(): ?VpcConfigResponse + { + return $this->vpcConfig; + } +} diff --git a/src/ValueObject/ImageConfig.php b/src/ValueObject/ImageConfig.php new file mode 100644 index 0000000..dff408a --- /dev/null +++ b/src/ValueObject/ImageConfig.php @@ -0,0 +1,109 @@ +entryPoint = $input['EntryPoint'] ?? null; + $this->command = $input['Command'] ?? null; + $this->workingDirectory = $input['WorkingDirectory'] ?? null; + } + + /** + * @param array{ + * EntryPoint?: null|string[], + * Command?: null|string[], + * WorkingDirectory?: null|string, + * }|ImageConfig $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return string[] + */ + public function getCommand(): array + { + return $this->command ?? []; + } + + /** + * @return string[] + */ + public function getEntryPoint(): array + { + return $this->entryPoint ?? []; + } + + public function getWorkingDirectory(): ?string + { + return $this->workingDirectory; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->entryPoint) { + $index = -1; + $payload['EntryPoint'] = []; + foreach ($v as $listValue) { + ++$index; + $payload['EntryPoint'][$index] = $listValue; + } + } + if (null !== $v = $this->command) { + $index = -1; + $payload['Command'] = []; + foreach ($v as $listValue) { + ++$index; + $payload['Command'][$index] = $listValue; + } + } + if (null !== $v = $this->workingDirectory) { + $payload['WorkingDirectory'] = $v; + } + + return $payload; + } +} diff --git a/src/ValueObject/ImageConfigError.php b/src/ValueObject/ImageConfigError.php new file mode 100644 index 0000000..1447d38 --- /dev/null +++ b/src/ValueObject/ImageConfigError.php @@ -0,0 +1,56 @@ +errorCode = $input['ErrorCode'] ?? null; + $this->message = $input['Message'] ?? null; + } + + /** + * @param array{ + * ErrorCode?: null|string, + * Message?: null|string, + * }|ImageConfigError $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getErrorCode(): ?string + { + return $this->errorCode; + } + + public function getMessage(): ?string + { + return $this->message; + } +} diff --git a/src/ValueObject/ImageConfigResponse.php b/src/ValueObject/ImageConfigResponse.php new file mode 100644 index 0000000..00fc325 --- /dev/null +++ b/src/ValueObject/ImageConfigResponse.php @@ -0,0 +1,56 @@ +imageConfig = isset($input['ImageConfig']) ? ImageConfig::create($input['ImageConfig']) : null; + $this->error = isset($input['Error']) ? ImageConfigError::create($input['Error']) : null; + } + + /** + * @param array{ + * ImageConfig?: null|ImageConfig|array, + * Error?: null|ImageConfigError|array, + * }|ImageConfigResponse $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getError(): ?ImageConfigError + { + return $this->error; + } + + public function getImageConfig(): ?ImageConfig + { + return $this->imageConfig; + } +} diff --git a/src/ValueObject/Layer.php b/src/ValueObject/Layer.php new file mode 100644 index 0000000..4db2382 --- /dev/null +++ b/src/ValueObject/Layer.php @@ -0,0 +1,88 @@ +arn = $input['Arn'] ?? null; + $this->codeSize = $input['CodeSize'] ?? null; + $this->signingProfileVersionArn = $input['SigningProfileVersionArn'] ?? null; + $this->signingJobArn = $input['SigningJobArn'] ?? null; + } + + /** + * @param array{ + * Arn?: null|string, + * CodeSize?: null|int, + * SigningProfileVersionArn?: null|string, + * SigningJobArn?: null|string, + * }|Layer $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getArn(): ?string + { + return $this->arn; + } + + public function getCodeSize(): ?int + { + return $this->codeSize; + } + + public function getSigningJobArn(): ?string + { + return $this->signingJobArn; + } + + public function getSigningProfileVersionArn(): ?string + { + return $this->signingProfileVersionArn; + } +} diff --git a/src/ValueObject/LayerVersionContentInput.php b/src/ValueObject/LayerVersionContentInput.php index 2f1545d..7ab5815 100644 --- a/src/ValueObject/LayerVersionContentInput.php +++ b/src/ValueObject/LayerVersionContentInput.php @@ -2,27 +2,42 @@ namespace AsyncAws\Lambda\ValueObject; +/** + * A ZIP archive that contains the contents of an Lambda layer [^1]. You can specify either an Amazon S3 location, or + * upload a layer archive directly. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html + */ final class LayerVersionContentInput { /** * The Amazon S3 bucket of the layer archive. + * + * @var string|null */ - private $S3Bucket; + private $s3Bucket; /** * The Amazon S3 key of the layer archive. + * + * @var string|null */ - private $S3Key; + private $s3Key; /** * For versioned objects, the version of the layer archive object to use. + * + * @var string|null */ - private $S3ObjectVersion; + private $s3ObjectVersion; /** - * The base64-encoded contents of the layer archive. AWS SDK and AWS CLI clients handle the encoding for you. + * The base64-encoded contents of the layer archive. Amazon Web Services SDK and Amazon Web Services CLI clients handle + * the encoding for you. + * + * @var string|null */ - private $ZipFile; + private $zipFile; /** * @param array{ @@ -34,12 +49,20 @@ final class LayerVersionContentInput */ public function __construct(array $input) { - $this->S3Bucket = $input['S3Bucket'] ?? null; - $this->S3Key = $input['S3Key'] ?? null; - $this->S3ObjectVersion = $input['S3ObjectVersion'] ?? null; - $this->ZipFile = $input['ZipFile'] ?? null; + $this->s3Bucket = $input['S3Bucket'] ?? null; + $this->s3Key = $input['S3Key'] ?? null; + $this->s3ObjectVersion = $input['S3ObjectVersion'] ?? null; + $this->zipFile = $input['ZipFile'] ?? null; } + /** + * @param array{ + * S3Bucket?: null|string, + * S3Key?: null|string, + * S3ObjectVersion?: null|string, + * ZipFile?: null|string, + * }|LayerVersionContentInput $input + */ public static function create($input): self { return $input instanceof self ? $input : new self($input); @@ -47,22 +70,22 @@ public static function create($input): self public function getS3Bucket(): ?string { - return $this->S3Bucket; + return $this->s3Bucket; } public function getS3Key(): ?string { - return $this->S3Key; + return $this->s3Key; } public function getS3ObjectVersion(): ?string { - return $this->S3ObjectVersion; + return $this->s3ObjectVersion; } public function getZipFile(): ?string { - return $this->ZipFile; + return $this->zipFile; } /** @@ -71,16 +94,16 @@ public function getZipFile(): ?string public function requestBody(): array { $payload = []; - if (null !== $v = $this->S3Bucket) { + if (null !== $v = $this->s3Bucket) { $payload['S3Bucket'] = $v; } - if (null !== $v = $this->S3Key) { + if (null !== $v = $this->s3Key) { $payload['S3Key'] = $v; } - if (null !== $v = $this->S3ObjectVersion) { + if (null !== $v = $this->s3ObjectVersion) { $payload['S3ObjectVersion'] = $v; } - if (null !== $v = $this->ZipFile) { + if (null !== $v = $this->zipFile) { $payload['ZipFile'] = base64_encode($v); } diff --git a/src/ValueObject/LayerVersionContentOutput.php b/src/ValueObject/LayerVersionContentOutput.php index a7fb7d1..9ae52bc 100644 --- a/src/ValueObject/LayerVersionContentOutput.php +++ b/src/ValueObject/LayerVersionContentOutput.php @@ -2,37 +2,75 @@ namespace AsyncAws\Lambda\ValueObject; +/** + * Details about a version of an Lambda layer [^1]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html + */ final class LayerVersionContentOutput { /** * A link to the layer archive in Amazon S3 that is valid for 10 minutes. + * + * @var string|null */ - private $Location; + private $location; /** * The SHA-256 hash of the layer archive. + * + * @var string|null */ - private $CodeSha256; + private $codeSha256; /** * The size of the layer archive in bytes. + * + * @var int|null */ - private $CodeSize; + private $codeSize; + + /** + * The Amazon Resource Name (ARN) for a signing profile version. + * + * @var string|null + */ + private $signingProfileVersionArn; + + /** + * The Amazon Resource Name (ARN) of a signing job. + * + * @var string|null + */ + private $signingJobArn; /** * @param array{ * Location?: null|string, * CodeSha256?: null|string, - * CodeSize?: null|string, + * CodeSize?: null|int, + * SigningProfileVersionArn?: null|string, + * SigningJobArn?: null|string, * } $input */ public function __construct(array $input) { - $this->Location = $input['Location'] ?? null; - $this->CodeSha256 = $input['CodeSha256'] ?? null; - $this->CodeSize = $input['CodeSize'] ?? null; + $this->location = $input['Location'] ?? null; + $this->codeSha256 = $input['CodeSha256'] ?? null; + $this->codeSize = $input['CodeSize'] ?? null; + $this->signingProfileVersionArn = $input['SigningProfileVersionArn'] ?? null; + $this->signingJobArn = $input['SigningJobArn'] ?? null; } + /** + * @param array{ + * Location?: null|string, + * CodeSha256?: null|string, + * CodeSize?: null|int, + * SigningProfileVersionArn?: null|string, + * SigningJobArn?: null|string, + * }|LayerVersionContentOutput $input + */ public static function create($input): self { return $input instanceof self ? $input : new self($input); @@ -40,16 +78,26 @@ public static function create($input): self public function getCodeSha256(): ?string { - return $this->CodeSha256; + return $this->codeSha256; } - public function getCodeSize(): ?string + public function getCodeSize(): ?int { - return $this->CodeSize; + return $this->codeSize; } public function getLocation(): ?string { - return $this->Location; + return $this->location; + } + + public function getSigningJobArn(): ?string + { + return $this->signingJobArn; + } + + public function getSigningProfileVersionArn(): ?string + { + return $this->signingProfileVersionArn; } } diff --git a/src/ValueObject/LayerVersionsListItem.php b/src/ValueObject/LayerVersionsListItem.php index 745bbe1..17d32ac 100644 --- a/src/ValueObject/LayerVersionsListItem.php +++ b/src/ValueObject/LayerVersionsListItem.php @@ -2,95 +2,150 @@ namespace AsyncAws\Lambda\ValueObject; +use AsyncAws\Lambda\Enum\Architecture; use AsyncAws\Lambda\Enum\Runtime; +/** + * Details about a version of an Lambda layer [^1]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html + */ final class LayerVersionsListItem { /** * The ARN of the layer version. + * + * @var string|null */ - private $LayerVersionArn; + private $layerVersionArn; /** * The version number. + * + * @var int|null */ - private $Version; + private $version; /** * The description of the version. + * + * @var string|null */ - private $Description; + private $description; /** * The date that the version was created, in ISO 8601 format. For example, `2018-11-27T15:10:45.123+0000`. + * + * @var string|null */ - private $CreatedDate; + private $createdDate; /** * The layer's compatible runtimes. + * + * The following list includes deprecated runtimes. For more information, see Runtime use after deprecation [^1]. + * + * For a list of all currently supported runtimes, see Supported runtimes [^2]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtime-deprecation-levels + * [^2]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtimes-supported + * + * @var list|null */ - private $CompatibleRuntimes; + private $compatibleRuntimes; /** * The layer's open-source license. + * + * @var string|null */ - private $LicenseInfo; + private $licenseInfo; + + /** + * A list of compatible instruction set architectures [^1]. + * + * [^1]: https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html + * + * @var list|null + */ + private $compatibleArchitectures; /** * @param array{ * LayerVersionArn?: null|string, - * Version?: null|string, + * Version?: null|int, * Description?: null|string, * CreatedDate?: null|string, - * CompatibleRuntimes?: null|list, + * CompatibleRuntimes?: null|array, * LicenseInfo?: null|string, + * CompatibleArchitectures?: null|array, * } $input */ public function __construct(array $input) { - $this->LayerVersionArn = $input['LayerVersionArn'] ?? null; - $this->Version = $input['Version'] ?? null; - $this->Description = $input['Description'] ?? null; - $this->CreatedDate = $input['CreatedDate'] ?? null; - $this->CompatibleRuntimes = $input['CompatibleRuntimes'] ?? null; - $this->LicenseInfo = $input['LicenseInfo'] ?? null; + $this->layerVersionArn = $input['LayerVersionArn'] ?? null; + $this->version = $input['Version'] ?? null; + $this->description = $input['Description'] ?? null; + $this->createdDate = $input['CreatedDate'] ?? null; + $this->compatibleRuntimes = $input['CompatibleRuntimes'] ?? null; + $this->licenseInfo = $input['LicenseInfo'] ?? null; + $this->compatibleArchitectures = $input['CompatibleArchitectures'] ?? null; } + /** + * @param array{ + * LayerVersionArn?: null|string, + * Version?: null|int, + * Description?: null|string, + * CreatedDate?: null|string, + * CompatibleRuntimes?: null|array, + * LicenseInfo?: null|string, + * CompatibleArchitectures?: null|array, + * }|LayerVersionsListItem $input + */ public static function create($input): self { return $input instanceof self ? $input : new self($input); } + /** + * @return list + */ + public function getCompatibleArchitectures(): array + { + return $this->compatibleArchitectures ?? []; + } + /** * @return list */ public function getCompatibleRuntimes(): array { - return $this->CompatibleRuntimes ?? []; + return $this->compatibleRuntimes ?? []; } public function getCreatedDate(): ?string { - return $this->CreatedDate; + return $this->createdDate; } public function getDescription(): ?string { - return $this->Description; + return $this->description; } public function getLayerVersionArn(): ?string { - return $this->LayerVersionArn; + return $this->layerVersionArn; } public function getLicenseInfo(): ?string { - return $this->LicenseInfo; + return $this->licenseInfo; } - public function getVersion(): ?string + public function getVersion(): ?int { - return $this->Version; + return $this->version; } } diff --git a/src/ValueObject/LoggingConfig.php b/src/ValueObject/LoggingConfig.php new file mode 100644 index 0000000..dd5e424 --- /dev/null +++ b/src/ValueObject/LoggingConfig.php @@ -0,0 +1,137 @@ +`. To use a different log group, enter an existing log + * group or enter a new log group name. + * + * @var string|null + */ + private $logGroup; + + /** + * @param array{ + * LogFormat?: null|LogFormat::*, + * ApplicationLogLevel?: null|ApplicationLogLevel::*, + * SystemLogLevel?: null|SystemLogLevel::*, + * LogGroup?: null|string, + * } $input + */ + public function __construct(array $input) + { + $this->logFormat = $input['LogFormat'] ?? null; + $this->applicationLogLevel = $input['ApplicationLogLevel'] ?? null; + $this->systemLogLevel = $input['SystemLogLevel'] ?? null; + $this->logGroup = $input['LogGroup'] ?? null; + } + + /** + * @param array{ + * LogFormat?: null|LogFormat::*, + * ApplicationLogLevel?: null|ApplicationLogLevel::*, + * SystemLogLevel?: null|SystemLogLevel::*, + * LogGroup?: null|string, + * }|LoggingConfig $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return ApplicationLogLevel::*|null + */ + public function getApplicationLogLevel(): ?string + { + return $this->applicationLogLevel; + } + + /** + * @return LogFormat::*|null + */ + public function getLogFormat(): ?string + { + return $this->logFormat; + } + + public function getLogGroup(): ?string + { + return $this->logGroup; + } + + /** + * @return SystemLogLevel::*|null + */ + public function getSystemLogLevel(): ?string + { + return $this->systemLogLevel; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->logFormat) { + if (!LogFormat::exists($v)) { + throw new InvalidArgument(\sprintf('Invalid parameter "LogFormat" for "%s". The value "%s" is not a valid "LogFormat".', __CLASS__, $v)); + } + $payload['LogFormat'] = $v; + } + if (null !== $v = $this->applicationLogLevel) { + if (!ApplicationLogLevel::exists($v)) { + throw new InvalidArgument(\sprintf('Invalid parameter "ApplicationLogLevel" for "%s". The value "%s" is not a valid "ApplicationLogLevel".', __CLASS__, $v)); + } + $payload['ApplicationLogLevel'] = $v; + } + if (null !== $v = $this->systemLogLevel) { + if (!SystemLogLevel::exists($v)) { + throw new InvalidArgument(\sprintf('Invalid parameter "SystemLogLevel" for "%s". The value "%s" is not a valid "SystemLogLevel".', __CLASS__, $v)); + } + $payload['SystemLogLevel'] = $v; + } + if (null !== $v = $this->logGroup) { + $payload['LogGroup'] = $v; + } + + return $payload; + } +} diff --git a/src/ValueObject/RuntimeVersionConfig.php b/src/ValueObject/RuntimeVersionConfig.php new file mode 100644 index 0000000..2d62a9f --- /dev/null +++ b/src/ValueObject/RuntimeVersionConfig.php @@ -0,0 +1,56 @@ +runtimeVersionArn = $input['RuntimeVersionArn'] ?? null; + $this->error = isset($input['Error']) ? RuntimeVersionError::create($input['Error']) : null; + } + + /** + * @param array{ + * RuntimeVersionArn?: null|string, + * Error?: null|RuntimeVersionError|array, + * }|RuntimeVersionConfig $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getError(): ?RuntimeVersionError + { + return $this->error; + } + + public function getRuntimeVersionArn(): ?string + { + return $this->runtimeVersionArn; + } +} diff --git a/src/ValueObject/RuntimeVersionError.php b/src/ValueObject/RuntimeVersionError.php new file mode 100644 index 0000000..1ca3781 --- /dev/null +++ b/src/ValueObject/RuntimeVersionError.php @@ -0,0 +1,56 @@ +errorCode = $input['ErrorCode'] ?? null; + $this->message = $input['Message'] ?? null; + } + + /** + * @param array{ + * ErrorCode?: null|string, + * Message?: null|string, + * }|RuntimeVersionError $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getErrorCode(): ?string + { + return $this->errorCode; + } + + public function getMessage(): ?string + { + return $this->message; + } +} diff --git a/src/ValueObject/SnapStart.php b/src/ValueObject/SnapStart.php new file mode 100644 index 0000000..bd50a7f --- /dev/null +++ b/src/ValueObject/SnapStart.php @@ -0,0 +1,67 @@ +applyOn = $input['ApplyOn'] ?? null; + } + + /** + * @param array{ + * ApplyOn?: null|SnapStartApplyOn::*, + * }|SnapStart $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return SnapStartApplyOn::*|null + */ + public function getApplyOn(): ?string + { + return $this->applyOn; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->applyOn) { + if (!SnapStartApplyOn::exists($v)) { + throw new InvalidArgument(\sprintf('Invalid parameter "ApplyOn" for "%s". The value "%s" is not a valid "SnapStartApplyOn".', __CLASS__, $v)); + } + $payload['ApplyOn'] = $v; + } + + return $payload; + } +} diff --git a/src/ValueObject/SnapStartResponse.php b/src/ValueObject/SnapStartResponse.php new file mode 100644 index 0000000..aa938fc --- /dev/null +++ b/src/ValueObject/SnapStartResponse.php @@ -0,0 +1,71 @@ +applyOn = $input['ApplyOn'] ?? null; + $this->optimizationStatus = $input['OptimizationStatus'] ?? null; + } + + /** + * @param array{ + * ApplyOn?: null|SnapStartApplyOn::*, + * OptimizationStatus?: null|SnapStartOptimizationStatus::*, + * }|SnapStartResponse $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return SnapStartApplyOn::*|null + */ + public function getApplyOn(): ?string + { + return $this->applyOn; + } + + /** + * @return SnapStartOptimizationStatus::*|null + */ + public function getOptimizationStatus(): ?string + { + return $this->optimizationStatus; + } +} diff --git a/src/ValueObject/TracingConfig.php b/src/ValueObject/TracingConfig.php new file mode 100644 index 0000000..f1a20e8 --- /dev/null +++ b/src/ValueObject/TracingConfig.php @@ -0,0 +1,65 @@ +mode = $input['Mode'] ?? null; + } + + /** + * @param array{ + * Mode?: null|TracingMode::*, + * }|TracingConfig $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return TracingMode::*|null + */ + public function getMode(): ?string + { + return $this->mode; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->mode) { + if (!TracingMode::exists($v)) { + throw new InvalidArgument(\sprintf('Invalid parameter "Mode" for "%s". The value "%s" is not a valid "TracingMode".', __CLASS__, $v)); + } + $payload['Mode'] = $v; + } + + return $payload; + } +} diff --git a/src/ValueObject/TracingConfigResponse.php b/src/ValueObject/TracingConfigResponse.php new file mode 100644 index 0000000..51387e7 --- /dev/null +++ b/src/ValueObject/TracingConfigResponse.php @@ -0,0 +1,46 @@ +mode = $input['Mode'] ?? null; + } + + /** + * @param array{ + * Mode?: null|TracingMode::*, + * }|TracingConfigResponse $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return TracingMode::*|null + */ + public function getMode(): ?string + { + return $this->mode; + } +} diff --git a/src/ValueObject/VpcConfig.php b/src/ValueObject/VpcConfig.php new file mode 100644 index 0000000..9930404 --- /dev/null +++ b/src/ValueObject/VpcConfig.php @@ -0,0 +1,109 @@ +subnetIds = $input['SubnetIds'] ?? null; + $this->securityGroupIds = $input['SecurityGroupIds'] ?? null; + $this->ipv6AllowedForDualStack = $input['Ipv6AllowedForDualStack'] ?? null; + } + + /** + * @param array{ + * SubnetIds?: null|string[], + * SecurityGroupIds?: null|string[], + * Ipv6AllowedForDualStack?: null|bool, + * }|VpcConfig $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getIpv6AllowedForDualStack(): ?bool + { + return $this->ipv6AllowedForDualStack; + } + + /** + * @return string[] + */ + public function getSecurityGroupIds(): array + { + return $this->securityGroupIds ?? []; + } + + /** + * @return string[] + */ + public function getSubnetIds(): array + { + return $this->subnetIds ?? []; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->subnetIds) { + $index = -1; + $payload['SubnetIds'] = []; + foreach ($v as $listValue) { + ++$index; + $payload['SubnetIds'][$index] = $listValue; + } + } + if (null !== $v = $this->securityGroupIds) { + $index = -1; + $payload['SecurityGroupIds'] = []; + foreach ($v as $listValue) { + ++$index; + $payload['SecurityGroupIds'][$index] = $listValue; + } + } + if (null !== $v = $this->ipv6AllowedForDualStack) { + $payload['Ipv6AllowedForDualStack'] = (bool) $v; + } + + return $payload; + } +} diff --git a/src/ValueObject/VpcConfigResponse.php b/src/ValueObject/VpcConfigResponse.php new file mode 100644 index 0000000..bcdeb2f --- /dev/null +++ b/src/ValueObject/VpcConfigResponse.php @@ -0,0 +1,92 @@ +subnetIds = $input['SubnetIds'] ?? null; + $this->securityGroupIds = $input['SecurityGroupIds'] ?? null; + $this->vpcId = $input['VpcId'] ?? null; + $this->ipv6AllowedForDualStack = $input['Ipv6AllowedForDualStack'] ?? null; + } + + /** + * @param array{ + * SubnetIds?: null|string[], + * SecurityGroupIds?: null|string[], + * VpcId?: null|string, + * Ipv6AllowedForDualStack?: null|bool, + * }|VpcConfigResponse $input + */ + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getIpv6AllowedForDualStack(): ?bool + { + return $this->ipv6AllowedForDualStack; + } + + /** + * @return string[] + */ + public function getSecurityGroupIds(): array + { + return $this->securityGroupIds ?? []; + } + + /** + * @return string[] + */ + public function getSubnetIds(): array + { + return $this->subnetIds ?? []; + } + + public function getVpcId(): ?string + { + return $this->vpcId; + } +} diff --git a/tests/Integration/LambdaClientTest.php b/tests/Integration/LambdaClientTest.php index 4024af9..657969f 100644 --- a/tests/Integration/LambdaClientTest.php +++ b/tests/Integration/LambdaClientTest.php @@ -4,14 +4,30 @@ use AsyncAws\Core\Credentials\NullProvider; use AsyncAws\Core\Result; +use AsyncAws\Core\Test\TestCase; +use AsyncAws\Lambda\Enum\Runtime; +use AsyncAws\Lambda\Enum\SnapStartApplyOn; +use AsyncAws\Lambda\Enum\TracingMode; use AsyncAws\Lambda\Input\AddLayerVersionPermissionRequest; +use AsyncAws\Lambda\Input\DeleteFunctionRequest; +use AsyncAws\Lambda\Input\GetFunctionConfigurationRequest; use AsyncAws\Lambda\Input\InvocationRequest; +use AsyncAws\Lambda\Input\ListFunctionsRequest; use AsyncAws\Lambda\Input\ListLayerVersionsRequest; +use AsyncAws\Lambda\Input\ListVersionsByFunctionRequest; use AsyncAws\Lambda\Input\PublishLayerVersionRequest; +use AsyncAws\Lambda\Input\UpdateFunctionConfigurationRequest; use AsyncAws\Lambda\LambdaClient; use AsyncAws\Lambda\Result\InvocationResponse; +use AsyncAws\Lambda\ValueObject\DeadLetterConfig; +use AsyncAws\Lambda\ValueObject\Environment; +use AsyncAws\Lambda\ValueObject\EphemeralStorage; +use AsyncAws\Lambda\ValueObject\FileSystemConfig; +use AsyncAws\Lambda\ValueObject\ImageConfig; use AsyncAws\Lambda\ValueObject\LayerVersionContentInput; -use PHPUnit\Framework\TestCase; +use AsyncAws\Lambda\ValueObject\SnapStart; +use AsyncAws\Lambda\ValueObject\TracingConfig; +use AsyncAws\Lambda\ValueObject\VpcConfig; class LambdaClientTest extends TestCase { @@ -38,6 +54,70 @@ public function testAddLayerVersionPermission(): void self::assertStringContainsString('change it', $result->getRevisionId()); } + public function testDeleteFunction(): void + { + self::markTestSkipped('The Lambda Docker image does not implement DeleteFunction.'); + + $client = $this->getClient(); + + $input = new DeleteFunctionRequest([ + 'FunctionName' => 'Index', + ]); + $result = $client->DeleteFunction($input); + + $result->resolve(); + } + + public function testGetFunctionConfiguration(): void + { + self::markTestSkipped('The Lambda Docker image does not implement GetFunctionConfiguration.'); + $client = $this->getClient(); + + $input = new GetFunctionConfigurationRequest([ + 'FunctionName' => 'change me', + 'Qualifier' => 'change me', + ]); + $result = $client->getFunctionConfiguration($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getFunctionName()); + self::assertSame('changeIt', $result->getFunctionArn()); + self::assertSame('changeIt', $result->getRuntime()); + self::assertSame('changeIt', $result->getRole()); + self::assertSame('changeIt', $result->getHandler()); + self::assertSame(1337, $result->getCodeSize()); + self::assertSame('changeIt', $result->getDescription()); + self::assertSame(1337, $result->getTimeout()); + self::assertSame(1337, $result->getMemorySize()); + self::assertSame('changeIt', $result->getLastModified()); + self::assertSame('changeIt', $result->getCodeSha256()); + self::assertSame('changeIt', $result->getVersion()); + // self::assertTODO(expected, $result->getVpcConfig()); + // self::assertTODO(expected, $result->getDeadLetterConfig()); + // self::assertTODO(expected, $result->getEnvironment()); + self::assertSame('changeIt', $result->getKmsKeyArn()); + // self::assertTODO(expected, $result->getTracingConfig()); + self::assertSame('changeIt', $result->getMasterArn()); + self::assertSame('changeIt', $result->getRevisionId()); + // self::assertTODO(expected, $result->getLayers()); + self::assertSame('changeIt', $result->getState()); + self::assertSame('changeIt', $result->getStateReason()); + self::assertSame('changeIt', $result->getStateReasonCode()); + self::assertSame('changeIt', $result->getLastUpdateStatus()); + self::assertSame('changeIt', $result->getLastUpdateStatusReason()); + self::assertSame('changeIt', $result->getLastUpdateStatusReasonCode()); + // self::assertTODO(expected, $result->getFileSystemConfigs()); + self::assertSame('changeIt', $result->getPackageType()); + // self::assertTODO(expected, $result->getImageConfigResponse()); + self::assertSame('changeIt', $result->getSigningProfileVersionArn()); + self::assertSame('changeIt', $result->getSigningJobArn()); + // self::assertTODO(expected, $result->getArchitectures()); + // self::assertTODO(expected, $result->getEphemeralStorage()); + // self::assertTODO(expected, $result->getSnapStart()); + // self::assertTODO(expected, $result->getRuntimeVersionConfig()); + } + public function testInvoke(): void { $client = $this->getClient(); @@ -59,7 +139,7 @@ public function testInvoke(): void public function testInvokeWait(): void { - if (!\method_exists(Result::class, 'wait')) { + if (!method_exists(Result::class, 'wait')) { self::markTestSkipped('Core does not contains the feature'); } @@ -71,7 +151,7 @@ public function testInvokeWait(): void $expected[] = '"hello ' . $i . '"'; $results[] = $client->Invoke(new InvocationRequest([ 'FunctionName' => 'Index', - 'Payload' => \json_encode(['name' => $i, 'delay' => 80 * ($i % 3)]), + 'Payload' => json_encode(['name' => $i, 'delay' => 80 * ($i % 3)]), ])); } @@ -86,6 +166,23 @@ public function testInvokeWait(): void self::assertEqualsCanonicalizing($expected, $resolves); } + public function testListFunctions(): void + { + self::markTestSkipped('The Lambda Docker image does not implement ListFunctions.'); + + $client = $this->getClient(); + + $input = new ListFunctionsRequest([ + 'MaxItems' => 1337, + ]); + $result = $client->ListFunctions($input); + + $result->resolve(); + + self::assertSame('Index', $result->getNextMarker()); + // self::assertTODO(expected, $result->getFunctions()); + } + public function testListLayerVersions(): void { self::markTestSkipped('The Lambda Docker image does not implement AddLayerVersionPermission.'); @@ -104,6 +201,23 @@ public function testListLayerVersions(): void // self::assertTODO(expected, $result->getLayerVersions()); } + public function testListVersionsByFunction(): void + { + self::markTestSkipped('The Lambda Docker image does not implement ListVersionsByFunction.'); + + $client = $this->getClient(); + + $input = new ListVersionsByFunctionRequest([ + 'FunctionName' => 'Index', + ]); + $result = $client->ListVersionsByFunction($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getNextMarker()); + // self::assertTODO(expected, $result->getVersions()); + } + public function testPublishLayerVersion(): void { self::markTestSkipped('The Lambda Docker image does not implement AddLayerVersionPermission.'); @@ -136,6 +250,93 @@ public function testPublishLayerVersion(): void self::assertStringContainsString('change it', $result->getLicenseInfo()); } + public function testUpdateFunctionConfiguration(): void + { + self::markTestSkipped('The Lambda Docker image does not implement UpdateFunctionConfiguration.'); + + $client = $this->getClient(); + + $input = new UpdateFunctionConfigurationRequest([ + 'FunctionName' => 'test-func', + 'Role' => 'testRole', + 'Handler' => 'testHandler', + 'Description' => 'testDescription', + 'Timeout' => 1337, + 'MemorySize' => 1337, + 'VpcConfig' => new VpcConfig([ + 'SubnetIds' => ['testSubnetId'], + 'SecurityGroupIds' => ['testSecurityGroupIds'], + ]), + 'Environment' => new Environment([ + 'Variables' => ['testEnvKey' => 'testEnvValue'], + ]), + 'Runtime' => Runtime::NODEJS_14_X, + 'DeadLetterConfig' => new DeadLetterConfig([ + 'TargetArn' => 'testDeadLetterConfig', + ]), + 'KMSKeyArn' => 'testKmsKeyArn', + 'TracingConfig' => new TracingConfig([ + 'Mode' => TracingMode::PASS_THROUGH, + ]), + 'RevisionId' => 'testRevisionId', + 'Layers' => ['testLayer'], + 'FileSystemConfigs' => [new FileSystemConfig([ + 'Arn' => 'testFileArn', + 'LocalMountPath' => 'testMountPoint', + ])], + 'ImageConfig' => new ImageConfig([ + 'EntryPoint' => ['testImageEntryPoint'], + 'Command' => ['testImageConfigCommand'], + 'WorkingDirectory' => 'testImageConfigWorkingDirectory', + ]), + 'EphemeralStorage' => new EphemeralStorage([ + 'Size' => 1337, + ]), + 'SnapStart' => new SnapStart([ + 'ApplyOn' => SnapStartApplyOn::NONE, + ]), + ]); + $result = $client->updateFunctionConfiguration($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getFunctionName()); + self::assertSame('changeIt', $result->getFunctionArn()); + self::assertSame('changeIt', $result->getRuntime()); + self::assertSame('changeIt', $result->getRole()); + self::assertSame('changeIt', $result->getHandler()); + self::assertSame(1337, $result->getCodeSize()); + self::assertSame('changeIt', $result->getDescription()); + self::assertSame(1337, $result->getTimeout()); + self::assertSame(1337, $result->getMemorySize()); + self::assertSame('changeIt', $result->getLastModified()); + self::assertSame('changeIt', $result->getCodeSha256()); + self::assertSame('changeIt', $result->getVersion()); + // self::assertTODO(expected, $result->getVpcConfig()); + // self::assertTODO(expected, $result->getDeadLetterConfig()); + // self::assertTODO(expected, $result->getEnvironment()); + self::assertSame('changeIt', $result->getKmsKeyArn()); + // self::assertTODO(expected, $result->getTracingConfig()); + self::assertSame('changeIt', $result->getMasterArn()); + self::assertSame('changeIt', $result->getRevisionId()); + // self::assertTODO(expected, $result->getLayers()); + self::assertSame('changeIt', $result->getState()); + self::assertSame('changeIt', $result->getStateReason()); + self::assertSame('changeIt', $result->getStateReasonCode()); + self::assertSame('changeIt', $result->getLastUpdateStatus()); + self::assertSame('changeIt', $result->getLastUpdateStatusReason()); + self::assertSame('changeIt', $result->getLastUpdateStatusReasonCode()); + // self::assertTODO(expected, $result->getFileSystemConfigs()); + self::assertSame('changeIt', $result->getPackageType()); + // self::assertTODO(expected, $result->getImageConfigResponse()); + self::assertSame('changeIt', $result->getSigningProfileVersionArn()); + self::assertSame('changeIt', $result->getSigningJobArn()); + // self::assertTODO(expected, $result->getArchitectures()); + // self::assertTODO(expected, $result->getEphemeralStorage()); + // self::assertTODO(expected, $result->getSnapStart()); + // self::assertTODO(expected, $result->getRuntimeVersionConfig()); + } + private function getClient(): LambdaClient { return new LambdaClient([ diff --git a/tests/Unit/Input/AddLayerVersionPermissionRequestTest.php b/tests/Unit/Input/AddLayerVersionPermissionRequestTest.php index edb1554..0b2a656 100644 --- a/tests/Unit/Input/AddLayerVersionPermissionRequestTest.php +++ b/tests/Unit/Input/AddLayerVersionPermissionRequestTest.php @@ -24,7 +24,8 @@ public function testRequest(): void $expected = ' POST /2018-10-31/layers/nodejs/versions/2/policy?RevisionId=123456 HTTP/1.0 - Content-Type: application/json + Content-type: application/json + Accept: application/json { "Action": "lambda:GetLayerVersion", diff --git a/tests/Unit/Input/DeleteFunctionRequestTest.php b/tests/Unit/Input/DeleteFunctionRequestTest.php new file mode 100644 index 0000000..1786d46 --- /dev/null +++ b/tests/Unit/Input/DeleteFunctionRequestTest.php @@ -0,0 +1,26 @@ + 'my-function', + 'Qualifier' => '4711', + ]); + + // see example-1.json from SDK + $expected = ' + DELETE /2015-03-31/functions/my-function?Qualifier=4711 HTTP/1.0 + Content-type: application/json + Accept: application/json +'; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/tests/Unit/Input/GetFunctionConfigurationRequestTest.php b/tests/Unit/Input/GetFunctionConfigurationRequestTest.php new file mode 100644 index 0000000..fd4dd42 --- /dev/null +++ b/tests/Unit/Input/GetFunctionConfigurationRequestTest.php @@ -0,0 +1,25 @@ + 'test-func', + 'Qualifier' => 'change', + ]); + + // see https://docs.aws.amazon.com/lambda/latest/APIReference/API_GetFunctionConfiguration.html + $expected = ' + GET /2015-03-31/functions/test-func/configuration?Qualifier=change HTTP/1.0 + Content-type: application/json + Accept: application/json + '; + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/tests/Unit/Input/InvocationRequestTest.php b/tests/Unit/Input/InvocationRequestTest.php index 21b5fbb..8927dd2 100644 --- a/tests/Unit/Input/InvocationRequestTest.php +++ b/tests/Unit/Input/InvocationRequestTest.php @@ -24,7 +24,8 @@ public function testRequest(): void $expected = ' POST /2015-03-31/functions/MyFunction/invocations?Qualifier=1 HTTP/1.0 - Content-Type: application/json + Content-type: application/json + Accept: application/json x-amz-invocation-type: Event x-amz-log-type: Tail x-amz-client-context: MyApp diff --git a/tests/Unit/Input/ListFunctionsRequestTest.php b/tests/Unit/Input/ListFunctionsRequestTest.php new file mode 100644 index 0000000..ede3a6d --- /dev/null +++ b/tests/Unit/Input/ListFunctionsRequestTest.php @@ -0,0 +1,28 @@ + 'eu-central-1', + 'FunctionVersion' => 'ALL', + 'Marker' => 'xxyy', + 'MaxItems' => 1337, + ]); + + // see https://docs.aws.amazon.com/lambda/latest/APIReference/API_ListFunctions.html + $expected = ' + GET /2015-03-31/functions/?FunctionVersion=ALL&Marker=xxyy&MasterRegion=eu-central-1&MaxItems=1337 HTTP/1.1 + Content-type: application/json + Accept: application/json + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/tests/Unit/Input/ListLayerVersionsRequestTest.php b/tests/Unit/Input/ListLayerVersionsRequestTest.php index 1f36db4..2f2a423 100644 --- a/tests/Unit/Input/ListLayerVersionsRequestTest.php +++ b/tests/Unit/Input/ListLayerVersionsRequestTest.php @@ -20,7 +20,8 @@ public function testRequest(): void $expected = ' GET /2018-10-31/layers/demo/versions?CompatibleRuntime=nodejs12.x HTTP/1.0 - Content-Type: application/json + Content-type: application/json + Accept: application/json '; self::assertRequestEqualsHttpRequest($expected, $input->request()); diff --git a/tests/Unit/Input/ListVersionsByFunctionRequestTest.php b/tests/Unit/Input/ListVersionsByFunctionRequestTest.php new file mode 100644 index 0000000..0e97388 --- /dev/null +++ b/tests/Unit/Input/ListVersionsByFunctionRequestTest.php @@ -0,0 +1,28 @@ + 'MyFunction', + 'Marker' => 'xxyy', + 'MaxItems' => 1337, + ]); + + // see example-1.json from SDK + $expected = ' + GET /2015-03-31/functions/MyFunction/versions?Marker=xxyy&MaxItems=1337 HTTP/1.0 + Content-type: application/json + Accept: application/json + + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/tests/Unit/Input/PublishLayerVersionRequestTest.php b/tests/Unit/Input/PublishLayerVersionRequestTest.php index 96ebdd7..bde8cfd 100644 --- a/tests/Unit/Input/PublishLayerVersionRequestTest.php +++ b/tests/Unit/Input/PublishLayerVersionRequestTest.php @@ -29,7 +29,8 @@ public function testRequest(): void // see https://docs.aws.amazon.com/lambda/latest/dg/API_PublishLayerVersion.html $expected = ' POST /2018-10-31/layers/demo/versions HTTP/1.0 - Content-Type: application/json + Content-type: application/json + Accept: application/json { "Description": "small description", diff --git a/tests/Unit/Input/UpdateFunctionConfigurationRequestTest.php b/tests/Unit/Input/UpdateFunctionConfigurationRequestTest.php new file mode 100644 index 0000000..7539955 --- /dev/null +++ b/tests/Unit/Input/UpdateFunctionConfigurationRequestTest.php @@ -0,0 +1,127 @@ + 'test-func', + 'Role' => 'testRole', + 'Handler' => 'testHandler', + 'Description' => 'testDescription', + 'Timeout' => 1337, + 'MemorySize' => 1337, + 'VpcConfig' => new VpcConfig([ + 'SubnetIds' => ['testSubnetId'], + 'SecurityGroupIds' => ['testSecurityGroupIds'], + ]), + 'Environment' => new Environment([ + 'Variables' => ['testEnvKey' => 'testEnvValue'], + ]), + 'Runtime' => Runtime::NODEJS_14_X, + 'DeadLetterConfig' => new DeadLetterConfig([ + 'TargetArn' => 'testDeadLetterConfig', + ]), + 'KMSKeyArn' => 'testKmsKeyArn', + 'TracingConfig' => new TracingConfig([ + 'Mode' => TracingMode::PASS_THROUGH, + ]), + 'RevisionId' => 'testRevisionId', + 'Layers' => ['testLayer'], + 'FileSystemConfigs' => [new FileSystemConfig([ + 'Arn' => 'testFileArn', + 'LocalMountPath' => 'testMountPoint', + ])], + 'ImageConfig' => new ImageConfig([ + 'EntryPoint' => ['testImageEntryPoint'], + 'Command' => ['testImageConfigCommand'], + 'WorkingDirectory' => 'testImageConfigWorkingDirectory', + ]), + 'EphemeralStorage' => new EphemeralStorage([ + 'Size' => 1337, + ]), + 'SnapStart' => new SnapStart([ + 'ApplyOn' => SnapStartApplyOn::NONE, + ]), + ]); + + // see https://docs.aws.amazon.com/lambda/latest/APIReference/API_UpdateFunctionConfiguration.html + $expected = ' + PUT /2015-03-31/functions/test-func/configuration HTTP/1.0 + Content-type: application/json + Accept: application/json + + { + "DeadLetterConfig": { + "TargetArn": "testDeadLetterConfig" + }, + "Description": "testDescription", + "Environment": { + "Variables": { + "testEnvKey": "testEnvValue" + } + }, + "EphemeralStorage": { + "Size": 1337 + }, + "FileSystemConfigs": [ + { + "Arn": "testFileArn", + "LocalMountPath": "testMountPoint" + } + ], + "Handler": "testHandler", + "ImageConfig": { + "Command": [ + "testImageConfigCommand" + ], + "EntryPoint": [ + "testImageEntryPoint" + ], + "WorkingDirectory": "testImageConfigWorkingDirectory" + }, + "KMSKeyArn": "testKmsKeyArn", + "Layers": [ + "testLayer" + ], + "MemorySize": 1337, + "RevisionId": "testRevisionId", + "Role": "testRole", + "Runtime": "nodejs14.x", + "SnapStart": { + "ApplyOn": "None" + }, + "Timeout": 1337, + "TracingConfig": { + "Mode": "PassThrough" + }, + "VpcConfig": { + "SecurityGroupIds": [ + "testSecurityGroupIds" + ], + "SubnetIds": [ + "testSubnetId" + ] + } + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/tests/Unit/LambdaClientTest.php b/tests/Unit/LambdaClientTest.php index 2e271c8..37b65ed 100644 --- a/tests/Unit/LambdaClientTest.php +++ b/tests/Unit/LambdaClientTest.php @@ -3,17 +3,26 @@ namespace AsyncAws\Lambda\Tests\Unit; use AsyncAws\Core\Credentials\NullProvider; +use AsyncAws\Core\Result; +use AsyncAws\Core\Test\TestCase; use AsyncAws\Lambda\Input\AddLayerVersionPermissionRequest; +use AsyncAws\Lambda\Input\DeleteFunctionRequest; +use AsyncAws\Lambda\Input\GetFunctionConfigurationRequest; use AsyncAws\Lambda\Input\InvocationRequest; +use AsyncAws\Lambda\Input\ListFunctionsRequest; use AsyncAws\Lambda\Input\ListLayerVersionsRequest; +use AsyncAws\Lambda\Input\ListVersionsByFunctionRequest; use AsyncAws\Lambda\Input\PublishLayerVersionRequest; +use AsyncAws\Lambda\Input\UpdateFunctionConfigurationRequest; use AsyncAws\Lambda\LambdaClient; use AsyncAws\Lambda\Result\AddLayerVersionPermissionResponse; +use AsyncAws\Lambda\Result\FunctionConfiguration; use AsyncAws\Lambda\Result\InvocationResponse; +use AsyncAws\Lambda\Result\ListFunctionsResponse; use AsyncAws\Lambda\Result\ListLayerVersionsResponse; +use AsyncAws\Lambda\Result\ListVersionsByFunctionResponse; use AsyncAws\Lambda\Result\PublishLayerVersionResponse; use AsyncAws\Lambda\ValueObject\LayerVersionContentInput; -use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\MockHttpClient; class LambdaClientTest extends TestCase @@ -28,7 +37,6 @@ public function testAddLayerVersionPermission(): void 'StatementId' => 'change me', 'Action' => 'change me', 'Principal' => 'change me', - ]); $result = $client->AddLayerVersionPermission($input); @@ -36,13 +44,38 @@ public function testAddLayerVersionPermission(): void self::assertFalse($result->info()['resolved']); } + public function testDeleteFunction(): void + { + $client = new LambdaClient([], new NullProvider(), new MockHttpClient()); + + $input = new DeleteFunctionRequest([ + 'FunctionName' => 'change me', + ]); + $result = $client->DeleteFunction($input); + + self::assertInstanceOf(Result::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetFunctionConfiguration(): void + { + $client = new LambdaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetFunctionConfigurationRequest([ + 'FunctionName' => 'change me', + ]); + $result = $client->getFunctionConfiguration($input); + + self::assertInstanceOf(FunctionConfiguration::class, $result); + self::assertFalse($result->info()['resolved']); + } + public function testInvoke(): void { $client = new LambdaClient([], new NullProvider(), new MockHttpClient()); $input = new InvocationRequest([ 'FunctionName' => 'change me', - ]); $result = $client->Invoke($input); @@ -50,14 +83,24 @@ public function testInvoke(): void self::assertFalse($result->info()['resolved']); } + public function testListFunctions(): void + { + $client = new LambdaClient([], new NullProvider(), new MockHttpClient()); + + $input = new ListFunctionsRequest([ + ]); + $result = $client->ListFunctions($input); + + self::assertInstanceOf(ListFunctionsResponse::class, $result); + self::assertFalse($result->info()['resolved']); + } + public function testListLayerVersions(): void { $client = new LambdaClient([], new NullProvider(), new MockHttpClient()); $input = new ListLayerVersionsRequest([ - 'LayerName' => 'change me', - ]); $result = $client->ListLayerVersions($input); @@ -65,6 +108,19 @@ public function testListLayerVersions(): void self::assertFalse($result->info()['resolved']); } + public function testListVersionsByFunction(): void + { + $client = new LambdaClient([], new NullProvider(), new MockHttpClient()); + + $input = new ListVersionsByFunctionRequest([ + 'FunctionName' => 'change me', + ]); + $result = $client->ListVersionsByFunction($input); + + self::assertInstanceOf(ListVersionsByFunctionResponse::class, $result); + self::assertFalse($result->info()['resolved']); + } + public function testPublishLayerVersion(): void { $client = new LambdaClient([], new NullProvider(), new MockHttpClient()); @@ -78,11 +134,23 @@ public function testPublishLayerVersion(): void 'S3ObjectVersion' => 'change me', 'ZipFile' => 'change me', ]), - ]); $result = $client->PublishLayerVersion($input); self::assertInstanceOf(PublishLayerVersionResponse::class, $result); self::assertFalse($result->info()['resolved']); } + + public function testUpdateFunctionConfiguration(): void + { + $client = new LambdaClient([], new NullProvider(), new MockHttpClient()); + + $input = new UpdateFunctionConfigurationRequest([ + 'FunctionName' => 'test-func', + ]); + $result = $client->updateFunctionConfiguration($input); + + self::assertInstanceOf(FunctionConfiguration::class, $result); + self::assertFalse($result->info()['resolved']); + } } diff --git a/tests/Unit/Result/FunctionConfigurationTest.php b/tests/Unit/Result/FunctionConfigurationTest.php new file mode 100644 index 0000000..957a490 --- /dev/null +++ b/tests/Unit/Result/FunctionConfigurationTest.php @@ -0,0 +1,134 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertSame('test-func', $result->getFunctionName()); + self::assertSame('arn:test-fun', $result->getFunctionArn()); + self::assertSame('nodejs14.x', $result->getRuntime()); + self::assertSame('testRole', $result->getRole()); + self::assertSame('testHandler', $result->getHandler()); + self::assertSame(1233, $result->getCodeSize()); + self::assertSame('testDescription', $result->getDescription()); + self::assertSame(1337, $result->getTimeout()); + self::assertSame(1337, $result->getMemorySize()); + self::assertSame('2023-08-22T18:01:12+0000', $result->getLastModified()); + self::assertSame('hash', $result->getCodeSha256()); + self::assertSame('90', $result->getVersion()); + self::assertSame(['testSubnetId'], $result->getVpcConfig()->getSubnetIds()); + self::assertSame(['testSecurityGroupIds'], $result->getVpcConfig()->getSecurityGroupIds()); + self::assertSame(null, $result->getVpcConfig()->getVpcId()); + self::assertSame('testDeadLetterConfig', $result->getDeadLetterConfig()->getTargetArn()); + self::assertSame([ + 'testEnvKey' => 'testEnvValue', + ], $result->getEnvironment()->getVariables()); + self::assertSame('testKmsKeyArn', $result->getKmsKeyArn()); + self::assertSame('PassThrough', $result->getTracingConfig()->getMode()); + self::assertSame('arn:master-test-func', $result->getMasterArn()); + self::assertSame('testRevisionId', $result->getRevisionId()); + self::assertSame('Active', $result->getState()); + self::assertSame(null, $result->getStateReason()); + self::assertSame(null, $result->getStateReasonCode()); + self::assertSame('Successful', $result->getLastUpdateStatus()); + self::assertSame('test', $result->getLastUpdateStatusReason()); + self::assertSame(null, $result->getLastUpdateStatusReasonCode()); + self::assertSame('zip', $result->getPackageType()); + self::assertSame(null, $result->getSigningProfileVersionArn()); + self::assertSame(null, $result->getSigningJobArn()); + self::assertCount(1, $result->getLayers()); + self::assertSame('testLayer', $result->getLayers()[0]->getArn()); + self::assertCount(1, $result->getFileSystemConfigs()); + self::assertSame([ + 'Arn' => 'testFileArn', + 'LocalMountPath' => 'testMountPoint', + ], $result->getFileSystemConfigs()[0]->requestBody()); + self::assertNull($result->getImageConfigResponse()); + self::assertCount(1, $result->getArchitectures()); + self::assertSame('x86_64', $result->getArchitectures()[0]); + self::assertSame(1337, $result->getEphemeralStorage()->getSize()); + self::assertSame('None', $result->getSnapStart()->getApplyOn()); + self::assertSame(null, $result->getSnapStart()->getOptimizationStatus()); + self::assertSame(null, $result->getRuntimeVersionConfig()); + } +} diff --git a/tests/Unit/Result/ListFunctionsResponseTest.php b/tests/Unit/Result/ListFunctionsResponseTest.php new file mode 100644 index 0000000..74f2ec3 --- /dev/null +++ b/tests/Unit/Result/ListFunctionsResponseTest.php @@ -0,0 +1,80 @@ +request('POST', 'http://localhost'), $client, new NullLogger()), new LambdaClient(), new ListFunctionsRequest([])); + + self::assertSame('xxyy', $result->getNextMarker()); + + foreach ($result->getFunctions(true) as $function) { + self::assertSame('helloworld', $function->getFunctionName()); + self::assertSame('arn:aws:lambda:us-west-2:123456789012:function:helloworld', $function->getFunctionArn()); + self::assertSame('$LATEST', $function->getVersion()); + self::assertSame(294, $function->getCodeSize()); + + break; + } + } +} diff --git a/tests/Unit/Result/ListVersionsByFunctionResponseTest.php b/tests/Unit/Result/ListVersionsByFunctionResponseTest.php new file mode 100644 index 0000000..06c0d2b --- /dev/null +++ b/tests/Unit/Result/ListVersionsByFunctionResponseTest.php @@ -0,0 +1,86 @@ +request('POST', 'http://localhost'), $client, new NullLogger()), new LambdaClient(), new ListVersionsByFunctionRequest([])); + + foreach ($result->getVersions(true) as $version) { + self::assertSame('my-function', $version->getFunctionName()); + self::assertSame('arn:aws:lambda:us-west-2:123456789012:function:my-function', $version->getFunctionArn()); + self::assertSame('$LATEST', $version->getVersion()); + self::assertSame(5797206, $version->getCodeSize()); + + break; + } + } +} diff --git a/tests/Unit/Result/PublishLayerVersionResponseTest.php b/tests/Unit/Result/PublishLayerVersionResponseTest.php index 37e401f..93471e9 100644 --- a/tests/Unit/Result/PublishLayerVersionResponseTest.php +++ b/tests/Unit/Result/PublishLayerVersionResponseTest.php @@ -37,7 +37,7 @@ public function testPublishLayerVersionResponse(): void self::assertSame('arn:::version:arn', $result->getLayerVersionArn()); self::assertSame('demo', $result->getDescription()); self::assertSame('1997-07-16T19:20:30+01:00', $result->getCreatedDate()); - self::assertSame('4', $result->getVersion()); + self::assertSame(4, $result->getVersion()); self::assertSame(['nodejs10.x', 'nodejs12.x'], $result->getCompatibleRuntimes()); self::assertSame('MIT', $result->getLicenseInfo()); }