diff --git a/README.md b/README.md index 6ec8ce1cc..7a252dfad 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ See full documentation on [https://async-aws.com](https://async-aws.com). | --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | [async-aws/core](https://github.com/async-aws/core) | [![Latest Stable Version](https://poser.pugx.org/async-aws/core/v/stable)](https://packagist.org/packages/async-aws/core) [![Total Downloads](https://poser.pugx.org/async-aws/core/downloads)](https://packagist.org/packages/async-aws/core) | [![](https://github.com/async-aws/core/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/core/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/core.svg)](https://github.com/async-aws/core/releases) | | [async-aws/app-sync](https://github.com/async-aws/app-sync) | [![Latest Stable Version](https://poser.pugx.org/async-aws/app-sync/v/stable)](https://packagist.org/packages/async-aws/app-sync) [![Total Downloads](https://poser.pugx.org/async-aws/app-sync/downloads)](https://packagist.org/packages/async-aws/app-sync) | [![](https://github.com/async-aws/app-sync/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/app-sync/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/app-sync.svg)](https://github.com/async-aws/app-sync/releases) | +| [async-aws/athena](https://github.com/async-aws/athena) | [![Latest Stable Version](https://poser.pugx.org/async-aws/athena/v/stable)](https://packagist.org/packages/async-aws/athena) [![Total Downloads](https://poser.pugx.org/async-aws/athena/downloads)](https://packagist.org/packages/async-aws/athena) | [![](https://github.com/async-aws/athena/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/athena/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/athena.svg)](https://github.com/async-aws/athena/releases) | | [async-aws/cloud-formation](https://github.com/async-aws/cloud-formation) | [![Latest Stable Version](https://poser.pugx.org/async-aws/cloud-formation/v/stable)](https://packagist.org/packages/async-aws/cloud-formation) [![Total Downloads](https://poser.pugx.org/async-aws/cloud-formation/downloads)](https://packagist.org/packages/async-aws/cloud-formation) | [![](https://github.com/async-aws/cloud-formation/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/cloud-formation/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/cloud-formation.svg)](https://github.com/async-aws/cloud-formation/releases) | | [async-aws/cloud-front](https://github.com/async-aws/cloud-front) | [![Latest Stable Version](https://poser.pugx.org/async-aws/cloud-front/v/stable)](https://packagist.org/packages/async-aws/cloud-front) [![Total Downloads](https://poser.pugx.org/async-aws/cloud-front/downloads)](https://packagist.org/packages/async-aws/cloud-front) | [![](https://github.com/async-aws/cloud-front/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/cloud-front/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/cloud-front.svg)](https://github.com/async-aws/cloud-front/releases) | | [async-aws/cloud-watch](https://github.com/async-aws/cloud-watch) | [![Latest Stable Version](https://poser.pugx.org/async-aws/cloud-watch/v/stable)](https://packagist.org/packages/async-aws/cloud-watch) [![Total Downloads](https://poser.pugx.org/async-aws/cloud-watch/downloads)](https://packagist.org/packages/async-aws/cloud-watch) | [![](https://github.com/async-aws/cloud-watch/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/cloud-watch/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/cloud-watch.svg)](https://github.com/async-aws/cloud-watch/releases) | diff --git a/composer.json b/composer.json index c297befca..cf8271177 100644 --- a/composer.json +++ b/composer.json @@ -49,6 +49,7 @@ "autoload": { "psr-4": { "AsyncAws\\AppSync\\": "src/Service/AppSync/src", + "AsyncAws\\Athena\\": "src/Service/Athena/src", "AsyncAws\\CloudFormation\\": "src/Service/CloudFormation/src", "AsyncAws\\CloudFront\\": "src/Service/CloudFront/src", "AsyncAws\\CloudWatchLogs\\": "src/Service/CloudWatchLogs/src", @@ -100,6 +101,7 @@ "autoload-dev": { "psr-4": { "AsyncAws\\AppSync\\Tests\\": "src/Service/AppSync/tests", + "AsyncAws\\Athena\\Tests\\": "src/Service/Athena/tests", "AsyncAws\\CloudFormation\\Tests\\": "src/Service/CloudFormation/tests", "AsyncAws\\CloudFront\\Tests\\": "src/Service/CloudFront/tests", "AsyncAws\\CloudWatchLogs\\Tests\\": "src/Service/CloudWatchLogs/tests", diff --git a/couscous.yml b/couscous.yml index 4c616aac7..009656d76 100644 --- a/couscous.yml +++ b/couscous.yml @@ -34,6 +34,9 @@ menu: app-sync: text: AppSync url: /clients/app-sync.html + athena: + text: Athena + url: /clients/athena.html cf: text: Cloud Formation url: /clients/cf.html diff --git a/docs/clients/athena.md b/docs/clients/athena.md new file mode 100644 index 000000000..515ba4fb3 --- /dev/null +++ b/docs/clients/athena.md @@ -0,0 +1,104 @@ +--- +layout: client +category: clients +name: Athena +package: async-aws/athena +--- + +## Usage + +### List Databases + +```php +use AsyncAws\Athena\AthenaClient; +use AsyncAws\Athena\Input\ListDatabasesInput; + +$athena = new AthenaClient(); + +$result = $athena->listDatabases(new ListDatabasesInput([ + 'CatalogName' => 'my_catalog' +])); + +foreach ($result->getDatabaseList() as $database) { + echo 'Database name : ' . $database->getName(); + echo 'Database description : ' . $database->getDescription(); + echo 'Database parameter : '.PHP_EOL; + print_r($database->getParameters()); +} + +``` +more information [listDatabases](https://docs.aws.amazon.com/athena/latest/APIReference/API_ListDatabases.html) + +### Query to Amazon Athena + +```php +use AsyncAws\Athena\AthenaClient; +use AsyncAws\Athena\Input\StartQueryExecutionInput; +use AsyncAws\Athena\Input\DescribeTableInput; +use AsyncAws\Athena\ValueObject\QueryExecutionContext; +use AsyncAws\Athena\ValueObject\ResultConfiguration; +use AsyncAws\Athena\ValueObject\EncryptionConfiguration; +use AsyncAws\Athena\ValueObject\AclConfiguration; +use AsyncAws\Athena\ValueObject\ResultReuseByAgeConfiguration; +use AsyncAws\Athena\Input\GetQueryExecutionInput; +use AsyncAws\Athena\Input\GetQueryResultsInput; +use AsyncAws\Athena\ValueObject\Row; +use AsyncAws\Athena\ValueObject\Datum; +use AsyncAws\Athena\Enum\QueryExecutionState; + +$athena = new AthenaClient(); + +// Submits a sample query to Amazon Athena and returns the execution ID of the query. +$startQueryResult = $athena->startQueryExecution(new StartQueryExecutionInput([ + 'QueryString' => 'select * from product limit 30', + 'QueryExecutionContext' => new QueryExecutionContext([ + 'Database' => 'production_db', // REQUIRED + ]), + 'ResultConfiguration' => new ResultConfiguration([ + 'OutputLocation' => 's3://test_output_bucket', // REQUIRED + 'EncryptionConfiguration' => new EncryptionConfiguration([ + 'EncryptionOption' => 'SSE_S3', // REQUIRED + ]) + ]), +])); + + +// Wait for an Amazon Athena query to complete, fail or to be cancelled. +$isQueryStillRunning = true; +while ($isQueryStillRunning) { + $queryExecutionResult = $athena->getQueryExecution( new GetQueryExecutionInput([ + 'QueryExecutionId' => $startQueryResult->getQueryExecutionId(), // REQUIRED + ])); + $queryState=$queryExecutionResult->getQueryExecution()->getStatus()->getState(); + if($queryState === QueryExecutionState::FAILED) { + throw new \Exception( + 'Athena query failed to run with error message: '.$queryExecutionResult->getQueryExecution()->getStatus()->getStateChangeReason() + ) + } elseif ($queryState === QueryExecutionState::CANCELLED) { + throw new \Exception('Athena query was cancelled.') + } elseif ($queryState === QueryExecutionState::SUCCEEDED) { + $isQueryStillRunning = false; + } + echo 'The current status is: : ' . $queryState; +} + + +// retrieves the results of a query +$results = $athena->getQueryResults(new GetQueryResultsInput([ + 'QueryExecutionId' => $startQueryResult->getQueryExecutionId(), + 'MaxResults' => 10000 +])); + +/** @var Row $row */ +foreach ($results => $row) { + if ($index === 0) { + $columnLabels = array_column($row->getData(), 'VarCharValue'); // $row->getData() return [ 'VarCharValue' => value, ...] + } + $columnValues[] = array_column($row->getData(), 'VarCharValue'); +} + +// retrieves the results column structure details +$columnsDetail = $result->getResultSet()->getResultSetMetadata()->getColumnInfo(); + +print_r($columnsDetail); +``` diff --git a/docs/clients/index.md b/docs/clients/index.md index d36f9a17c..4cc4532d1 100644 --- a/docs/clients/index.md +++ b/docs/clients/index.md @@ -138,6 +138,7 @@ for more information. | Api Client | Package name | | ------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | [AppSync](./app-sync.md) | [async-aws/app-sync](https://packagist.org/packages/async-aws/app-sync) | +| [Athena](./athena.md) | [async-aws/athena](https://packagist.org/packages/async-aws/athena) | | [CloudFormation](./cf.md) | [async-aws/cloud-formation](https://packagist.org/packages/async-aws/cloud-formation) | | [CloudFront](./cloud-front.md) | [async-aws/cloud-front](https://packagist.org/packages/async-aws/cloud-front) | | [CloudWatch](./cloud-watch.md) | [async-aws/cloud-watch](https://packagist.org/packages/async-aws/cloud-watch) | diff --git a/manifest.json b/manifest.json index be1993a6e..c8854e868 100644 --- a/manifest.json +++ b/manifest.json @@ -22,6 +22,48 @@ "UpdateResolver" ] }, + "Athena": { + "source": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/api-2.json", + "documentation": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/docs-2.json", + "pagination": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/paginators-1.json", + "endpoint-rule-set": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/endpoint-rule-set-1.json", + "endpoint-tests": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/endpoint-tests-1.json", + "example": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/examples-1.json", + "smoke": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/smoke.json", + "api-reference": "https://docs.aws.amazon.com/athena/latest/APIReference", + "methods": [ + "GetCalculationExecution", + "GetCalculationExecutionStatus", + "GetDataCatalog", + "GetDatabase", + "GetNamedQuery", + "GetQueryExecution", + "GetQueryResults", + "GetSession", + "GetSessionStatus", + "GetTableMetadata", + "GetWorkGroup", + "ListDatabases", + "ListNamedQueries", + "ListQueryExecutions", + "ListTableMetadata", + "StartCalculationExecution", + "StartQueryExecution", + "StartSession", + "StopCalculationExecution", + "StopQueryExecution", + "TerminateSession" + ], + "patches": { + "pagination": [ + { + "value": "ResultSet.Rows", + "op": "add", + "path": "/pagination/GetQueryResults/result_key" + } + ] + } + }, "CloudFormation": { "source": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/cloudformation/2010-05-15/api-2.json", "documentation": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/cloudformation/2010-05-15/docs-2.json", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 99dfbe7cb..9f0fe1bea 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -31,6 +31,7 @@ parameters: paths: - src/Core/src/Sts/ValueObject - src/Service/AppSync/src/ValueObject + - src/Service/Athena/src/ValueObject - src/Service/CodeBuild/src/ValueObject - src/Service/CodeCommit/src/ValueObject - src/Service/CloudFormation/src/ValueObject diff --git a/psalm.baseline.xml b/psalm.baseline.xml index aaf0100d2..d348e04c6 100644 --- a/psalm.baseline.xml +++ b/psalm.baseline.xml @@ -551,4 +551,12 @@ uuid_create(\UUID_TYPE_RANDOM) + + + \Traversable<Row> + + + getRows + + diff --git a/src/Core/CHANGELOG.md b/src/Core/CHANGELOG.md index d144aa176..60da36064 100644 --- a/src/Core/CHANGELOG.md +++ b/src/Core/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Added + +- Support for Athena + ## 1.18.1 ### Changed diff --git a/src/Core/src/AwsClientFactory.php b/src/Core/src/AwsClientFactory.php index 4f746bb92..a4f446a7f 100644 --- a/src/Core/src/AwsClientFactory.php +++ b/src/Core/src/AwsClientFactory.php @@ -5,6 +5,7 @@ namespace AsyncAws\Core; use AsyncAws\AppSync\AppSyncClient; +use AsyncAws\Athena\AthenaClient; use AsyncAws\CloudFormation\CloudFormationClient; use AsyncAws\CloudFront\CloudFrontClient; use AsyncAws\CloudWatch\CloudWatchClient; @@ -576,4 +577,17 @@ public function cognitoIdentityProvider(): CognitoIdentityProviderClient return $this->serviceCache[__METHOD__]; } + + public function athena(): AthenaClient + { + if (!class_exists(AthenaClient::class)) { + throw MissingDependency::create('async-aws/athena', 'Athena'); + } + + if (!isset($this->serviceCache[__METHOD__])) { + $this->serviceCache[__METHOD__] = new AthenaClient($this->configuration, $this->credentialProvider, $this->httpClient, $this->logger); + } + + return $this->serviceCache[__METHOD__]; + } } diff --git a/src/Integration/Symfony/Bundle/CHANGELOG.md b/src/Integration/Symfony/Bundle/CHANGELOG.md index 6661d7a60..02751d9d5 100644 --- a/src/Integration/Symfony/Bundle/CHANGELOG.md +++ b/src/Integration/Symfony/Bundle/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Added + +- Support for Athena + ## 1.10.0 ### Added diff --git a/src/Integration/Symfony/Bundle/src/DependencyInjection/AwsPackagesProvider.php b/src/Integration/Symfony/Bundle/src/DependencyInjection/AwsPackagesProvider.php index fbf287c8f..2ddd1f667 100644 --- a/src/Integration/Symfony/Bundle/src/DependencyInjection/AwsPackagesProvider.php +++ b/src/Integration/Symfony/Bundle/src/DependencyInjection/AwsPackagesProvider.php @@ -13,6 +13,10 @@ public static function getAllServices(): array 'class' => \AsyncAws\AppSync\AppSyncClient::class, 'package' => 'async-aws/app-sync', ], + 'athena' => [ + 'class' => \AsyncAws\Athena\AthenaClient::class, + 'package' => 'async-aws/athena', + ], 'cloud_formation' => [ 'class' => \AsyncAws\CloudFormation\CloudFormationClient::class, 'package' => 'async-aws/cloud-formation', diff --git a/src/Service/Athena/.gitattributes b/src/Service/Athena/.gitattributes new file mode 100644 index 000000000..410d4a1a6 --- /dev/null +++ b/src/Service/Athena/.gitattributes @@ -0,0 +1,5 @@ +/.github export-ignore +/tests export-ignore +/.gitignore export-ignore +/Makefile export-ignore +/phpunit.xml.dist export-ignore diff --git a/src/Service/Athena/.github/FUNDING.yml b/src/Service/Athena/.github/FUNDING.yml new file mode 100644 index 000000000..ef7eb6190 --- /dev/null +++ b/src/Service/Athena/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: [nyholm, jderusse] diff --git a/src/Service/Athena/.github/workflows/.editorconfig b/src/Service/Athena/.github/workflows/.editorconfig new file mode 100644 index 000000000..7bd3346f2 --- /dev/null +++ b/src/Service/Athena/.github/workflows/.editorconfig @@ -0,0 +1,2 @@ +[*.yml] +indent_size = 2 diff --git a/src/Service/Athena/.github/workflows/branch_alias.yml b/src/Service/Athena/.github/workflows/branch_alias.yml new file mode 100644 index 000000000..4a82cf2a1 --- /dev/null +++ b/src/Service/Athena/.github/workflows/branch_alias.yml @@ -0,0 +1,76 @@ +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@v2 + with: + php-version: 8.1 + 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/Athena + 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/src/Service/Athena/.github/workflows/checks.yml b/src/Service/Athena/.github/workflows/checks.yml new file mode 100644 index 000000000..1a7227685 --- /dev/null +++ b/src/Service/Athena/.github/workflows/checks.yml @@ -0,0 +1,27 @@ +name: BC Check + +on: + push: + branches: + - master + +jobs: + roave-bc-check: + name: Roave BC Check + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Modify composer.json + run: | + sed -i -re 's/"require": \{/"minimum-stability": "dev","prefer-stable": true,"require": \{/' composer.json + cat composer.json + + git config --local user.email "github@async-aws.com" + git config --local user.name "AsyncAws Bot" + git commit -am "Allow unstable dependencies" + + - name: Roave BC Check + uses: docker://nyholm/roave-bc-check-ga diff --git a/src/Service/Athena/.github/workflows/ci.yml b/src/Service/Athena/.github/workflows/ci.yml new file mode 100644 index 000000000..45dfe7be5 --- /dev/null +++ b/src/Service/Athena/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: Tests + +on: + push: + branches: + - master + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + strategy: + max-parallel: 10 + matrix: + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + + steps: + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Initialize tests + run: make initialize + + - name: Download dependencies + run: | + composer config minimum-stability dev + composer req symfony/phpunit-bridge --no-update + composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable + + - name: Run tests + run: ./vendor/bin/simple-phpunit diff --git a/src/Service/Athena/.gitignore b/src/Service/Athena/.gitignore new file mode 100644 index 000000000..4ef8091e0 --- /dev/null +++ b/src/Service/Athena/.gitignore @@ -0,0 +1,3 @@ +/vendor/ +*.cache +composer.lock diff --git a/src/Service/Athena/CHANGELOG.md b/src/Service/Athena/CHANGELOG.md new file mode 100644 index 000000000..457d4177c --- /dev/null +++ b/src/Service/Athena/CHANGELOG.md @@ -0,0 +1,7 @@ +# Change Log + +## NOT RELEASED + +## 0.1.0 + +First version diff --git a/src/Service/Athena/LICENSE b/src/Service/Athena/LICENSE new file mode 100644 index 000000000..c924ee5c6 --- /dev/null +++ b/src/Service/Athena/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 Jérémy Derussé, Tobias Nyholm + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/Service/Athena/Makefile b/src/Service/Athena/Makefile new file mode 100644 index 000000000..850dffccd --- /dev/null +++ b/src/Service/Athena/Makefile @@ -0,0 +1,12 @@ +.EXPORT_ALL_VARIABLES: + +initialize: start-docker +start-docker: + echo "Noop" + +test: initialize + ./vendor/bin/simple-phpunit + +clean: stop-docker +stop-docker: + echo "Noop" diff --git a/src/Service/Athena/README.md b/src/Service/Athena/README.md new file mode 100644 index 000000000..dcf12c0a2 --- /dev/null +++ b/src/Service/Athena/README.md @@ -0,0 +1,20 @@ +# AsyncAws Athena Client + +![](https://github.com/async-aws/athena/workflows/Tests/badge.svg?branch=master) +![](https://github.com/async-aws/athena/workflows/BC%20Check/badge.svg?branch=master) + +An API client for Athena. + +## Install + +```cli +composer require async-aws/athena +``` + +## Documentation + +See https://async-aws.com/clients/athena.html for documentation. + +## Contribute + +Contributions are welcome and appreciated. Please read https://async-aws.com/contribute/ diff --git a/src/Service/Athena/composer.json b/src/Service/Athena/composer.json new file mode 100644 index 000000000..ff117b9c5 --- /dev/null +++ b/src/Service/Athena/composer.json @@ -0,0 +1,35 @@ +{ + "name": "async-aws/athena", + "description": "Athena client, part of the AWS SDK provided by AsyncAws.", + "license": "MIT", + "type": "library", + "keywords": [ + "aws", + "amazon", + "sdk", + "async-aws", + "athena" + ], + "require": { + "php": "^7.2.5 || ^8.0", + "ext-filter": "*", + "ext-json": "*", + "async-aws/core": "^1.9", + "symfony/polyfill-uuid": "^1.0" + }, + "autoload": { + "psr-4": { + "AsyncAws\\Athena\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AsyncAws\\Athena\\Tests\\": "tests/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "0.1-dev" + } + } +} diff --git a/src/Service/Athena/phpunit.xml.dist b/src/Service/Athena/phpunit.xml.dist new file mode 100644 index 000000000..9894ce353 --- /dev/null +++ b/src/Service/Athena/phpunit.xml.dist @@ -0,0 +1,23 @@ + + + + + ./src + + + + + + + + ./tests/ + + + diff --git a/src/Service/Athena/src/AthenaClient.php b/src/Service/Athena/src/AthenaClient.php new file mode 100644 index 000000000..9693bb6cf --- /dev/null +++ b/src/Service/Athena/src/AthenaClient.php @@ -0,0 +1,788 @@ +getResponse($input->request(), new RequestContext(['operation' => 'GetCalculationExecution', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + ]])); + + return new GetCalculationExecutionResponse($response); + } + + /** + * Gets the status of a current calculation. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetCalculationExecutionStatus.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#getcalculationexecutionstatus + * + * @param array{ + * CalculationExecutionId: string, + * + * @region?: string, + * }|GetCalculationExecutionStatusRequest $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws ResourceNotFoundException + */ + public function getCalculationExecutionStatus($input): GetCalculationExecutionStatusResponse + { + $input = GetCalculationExecutionStatusRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetCalculationExecutionStatus', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + ]])); + + return new GetCalculationExecutionStatusResponse($response); + } + + /** + * Returns the specified data catalog. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetDataCatalog.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#getdatacatalog + * + * @param array{ + * Name: string, + * + * @region?: string, + * }|GetDataCatalogInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + */ + public function getDataCatalog($input): GetDataCatalogOutput + { + $input = GetDataCatalogInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetDataCatalog', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + ]])); + + return new GetDataCatalogOutput($response); + } + + /** + * Returns a database object for the specified database and data catalog. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetDatabase.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#getdatabase + * + * @param array{ + * CatalogName: string, + * DatabaseName: string, + * + * @region?: string, + * }|GetDatabaseInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws MetadataException + */ + public function getDatabase($input): GetDatabaseOutput + { + $input = GetDatabaseInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetDatabase', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'MetadataException' => MetadataException::class, + ]])); + + return new GetDatabaseOutput($response); + } + + /** + * Returns information about a single query. Requires that you have access to the workgroup in which the query was + * saved. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetNamedQuery.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#getnamedquery + * + * @param array{ + * NamedQueryId: string, + * + * @region?: string, + * }|GetNamedQueryInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + */ + public function getNamedQuery($input): GetNamedQueryOutput + { + $input = GetNamedQueryInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetNamedQuery', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + ]])); + + return new GetNamedQueryOutput($response); + } + + /** + * Returns information about a single execution of a query if you have access to the workgroup in which the query ran. + * Each time a query executes, information about the query execution is saved with a unique ID. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetQueryExecution.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#getqueryexecution + * + * @param array{ + * QueryExecutionId: string, + * + * @region?: string, + * }|GetQueryExecutionInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + */ + public function getQueryExecution($input): GetQueryExecutionOutput + { + $input = GetQueryExecutionInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetQueryExecution', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + ]])); + + return new GetQueryExecutionOutput($response); + } + + /** + * Streams the results of a single query execution specified by `QueryExecutionId` from the Athena query results + * location in Amazon S3. For more information, see Working with query results, recent queries, and output files in the + * *Amazon Athena User Guide*. This request does not execute the query but returns results. Use StartQueryExecution to + * run a query. + * + * @see https://docs.aws.amazon.com/athena/latest/ug/querying.html + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetQueryResults.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#getqueryresults + * + * @param array{ + * QueryExecutionId: string, + * NextToken?: string, + * MaxResults?: int, + * + * @region?: string, + * }|GetQueryResultsInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws TooManyRequestsException + */ + public function getQueryResults($input): GetQueryResultsOutput + { + $input = GetQueryResultsInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetQueryResults', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); + + return new GetQueryResultsOutput($response, $this, $input); + } + + /** + * Gets the full details of a previously created session, including the session status and configuration. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetSession.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#getsession + * + * @param array{ + * SessionId: string, + * + * @region?: string, + * }|GetSessionRequest $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws ResourceNotFoundException + */ + public function getSession($input): GetSessionResponse + { + $input = GetSessionRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetSession', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + ]])); + + return new GetSessionResponse($response); + } + + /** + * Gets the current status of a session. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetSessionStatus.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#getsessionstatus + * + * @param array{ + * SessionId: string, + * + * @region?: string, + * }|GetSessionStatusRequest $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws ResourceNotFoundException + */ + public function getSessionStatus($input): GetSessionStatusResponse + { + $input = GetSessionStatusRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetSessionStatus', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + ]])); + + return new GetSessionStatusResponse($response); + } + + /** + * Returns table metadata for the specified catalog, database, and table. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetTableMetadata.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#gettablemetadata + * + * @param array{ + * CatalogName: string, + * DatabaseName: string, + * TableName: string, + * + * @region?: string, + * }|GetTableMetadataInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws MetadataException + */ + public function getTableMetadata($input): GetTableMetadataOutput + { + $input = GetTableMetadataInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetTableMetadata', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'MetadataException' => MetadataException::class, + ]])); + + return new GetTableMetadataOutput($response); + } + + /** + * Returns information about the workgroup with the specified name. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetWorkGroup.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#getworkgroup + * + * @param array{ + * WorkGroup: string, + * + * @region?: string, + * }|GetWorkGroupInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + */ + public function getWorkGroup($input): GetWorkGroupOutput + { + $input = GetWorkGroupInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetWorkGroup', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + ]])); + + return new GetWorkGroupOutput($response); + } + + /** + * Lists the databases in the specified data catalog. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_ListDatabases.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#listdatabases + * + * @param array{ + * CatalogName: string, + * NextToken?: string, + * MaxResults?: int, + * + * @region?: string, + * }|ListDatabasesInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws MetadataException + */ + public function listDatabases($input): ListDatabasesOutput + { + $input = ListDatabasesInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListDatabases', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'MetadataException' => MetadataException::class, + ]])); + + return new ListDatabasesOutput($response, $this, $input); + } + + /** + * Provides a list of available query IDs only for queries saved in the specified workgroup. Requires that you have + * access to the specified workgroup. If a workgroup is not specified, lists the saved queries for the primary + * workgroup. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_ListNamedQueries.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#listnamedqueries + * + * @param array{ + * NextToken?: string, + * MaxResults?: int, + * WorkGroup?: string, + * + * @region?: string, + * }|ListNamedQueriesInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + */ + public function listNamedQueries($input = []): ListNamedQueriesOutput + { + $input = ListNamedQueriesInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListNamedQueries', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + ]])); + + return new ListNamedQueriesOutput($response, $this, $input); + } + + /** + * Provides a list of available query execution IDs for the queries in the specified workgroup. If a workgroup is not + * specified, returns a list of query execution IDs for the primary workgroup. Requires you to have access to the + * workgroup in which the queries ran. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_ListQueryExecutions.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#listqueryexecutions + * + * @param array{ + * NextToken?: string, + * MaxResults?: int, + * WorkGroup?: string, + * + * @region?: string, + * }|ListQueryExecutionsInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + */ + public function listQueryExecutions($input = []): ListQueryExecutionsOutput + { + $input = ListQueryExecutionsInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListQueryExecutions', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + ]])); + + return new ListQueryExecutionsOutput($response, $this, $input); + } + + /** + * Lists the metadata for the tables in the specified data catalog database. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_ListTableMetadata.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#listtablemetadata + * + * @param array{ + * CatalogName: string, + * DatabaseName: string, + * Expression?: string, + * NextToken?: string, + * MaxResults?: int, + * + * @region?: string, + * }|ListTableMetadataInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws MetadataException + */ + public function listTableMetadata($input): ListTableMetadataOutput + { + $input = ListTableMetadataInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListTableMetadata', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'MetadataException' => MetadataException::class, + ]])); + + return new ListTableMetadataOutput($response, $this, $input); + } + + /** + * Submits calculations for execution within a session. You can supply the code to run as an inline code block within + * the request. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_StartCalculationExecution.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#startcalculationexecution + * + * @param array{ + * SessionId: string, + * Description?: string, + * CalculationConfiguration?: CalculationConfiguration|array, + * CodeBlock?: string, + * ClientRequestToken?: string, + * + * @region?: string, + * }|StartCalculationExecutionRequest $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws ResourceNotFoundException + */ + public function startCalculationExecution($input): StartCalculationExecutionResponse + { + $input = StartCalculationExecutionRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'StartCalculationExecution', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + ]])); + + return new StartCalculationExecutionResponse($response); + } + + /** + * Runs the SQL query statements contained in the `Query`. Requires you to have access to the workgroup in which the + * query ran. Running queries against an external catalog requires GetDataCatalog permission to the catalog. For code + * samples using the Amazon Web Services SDK for Java, see Examples and Code Samples in the *Amazon Athena User Guide*. + * + * @see http://docs.aws.amazon.com/athena/latest/ug/code-samples.html + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_StartQueryExecution.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#startqueryexecution + * + * @param array{ + * QueryString: string, + * ClientRequestToken?: string, + * QueryExecutionContext?: QueryExecutionContext|array, + * ResultConfiguration?: ResultConfiguration|array, + * WorkGroup?: string, + * ExecutionParameters?: string[], + * ResultReuseConfiguration?: ResultReuseConfiguration|array, + * + * @region?: string, + * }|StartQueryExecutionInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws TooManyRequestsException + */ + public function startQueryExecution($input): StartQueryExecutionOutput + { + $input = StartQueryExecutionInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'StartQueryExecution', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); + + return new StartQueryExecutionOutput($response); + } + + /** + * Creates a session for running calculations within a workgroup. The session is ready when it reaches an `IDLE` state. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_StartSession.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#startsession + * + * @param array{ + * Description?: string, + * WorkGroup: string, + * EngineConfiguration: EngineConfiguration|array, + * NotebookVersion?: string, + * SessionIdleTimeoutInMinutes?: int, + * ClientRequestToken?: string, + * + * @region?: string, + * }|StartSessionRequest $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws ResourceNotFoundException + * @throws SessionAlreadyExistsException + * @throws TooManyRequestsException + */ + public function startSession($input): StartSessionResponse + { + $input = StartSessionRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'StartSession', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + 'SessionAlreadyExistsException' => SessionAlreadyExistsException::class, + 'TooManyRequestsException' => TooManyRequestsException::class, + ]])); + + return new StartSessionResponse($response); + } + + /** + * Requests the cancellation of a calculation. A `StopCalculationExecution` call on a calculation that is already in a + * terminal state (for example, `STOPPED`, `FAILED`, or `COMPLETED`) succeeds but has no effect. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_StopCalculationExecution.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#stopcalculationexecution + * + * @param array{ + * CalculationExecutionId: string, + * + * @region?: string, + * }|StopCalculationExecutionRequest $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws ResourceNotFoundException + */ + public function stopCalculationExecution($input): StopCalculationExecutionResponse + { + $input = StopCalculationExecutionRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'StopCalculationExecution', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + ]])); + + return new StopCalculationExecutionResponse($response); + } + + /** + * Stops a query execution. Requires you to have access to the workgroup in which the query ran. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_StopQueryExecution.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#stopqueryexecution + * + * @param array{ + * QueryExecutionId: string, + * + * @region?: string, + * }|StopQueryExecutionInput $input + * + * @throws InternalServerException + * @throws InvalidRequestException + */ + public function stopQueryExecution($input): StopQueryExecutionOutput + { + $input = StopQueryExecutionInput::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'StopQueryExecution', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + ]])); + + return new StopQueryExecutionOutput($response); + } + + /** + * Terminates an active session. A `TerminateSession` call on a session that is already inactive (for example, in a + * `FAILED`, `TERMINATED` or `TERMINATING` state) succeeds but has no effect. Calculations running in the session when + * `TerminateSession` is called are forcefully stopped, but may display as `FAILED` instead of `STOPPED`. + * + * @see https://docs.aws.amazon.com/athena/latest/APIReference/API_TerminateSession.html + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-athena-2017-05-18.html#terminatesession + * + * @param array{ + * SessionId: string, + * + * @region?: string, + * }|TerminateSessionRequest $input + * + * @throws InternalServerException + * @throws InvalidRequestException + * @throws ResourceNotFoundException + */ + public function terminateSession($input): TerminateSessionResponse + { + $input = TerminateSessionRequest::create($input); + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'TerminateSession', 'region' => $input->getRegion(), 'exceptionMapping' => [ + 'InternalServerException' => InternalServerException::class, + 'InvalidRequestException' => InvalidRequestException::class, + 'ResourceNotFoundException' => ResourceNotFoundException::class, + ]])); + + return new TerminateSessionResponse($response); + } + + protected function getAwsErrorFactory(): AwsErrorFactoryInterface + { + return new JsonRpcAwsErrorFactory(); + } + + protected function getEndpointMetadata(?string $region): array + { + if (null === $region) { + $region = Configuration::DEFAULT_REGION; + } + + switch ($region) { + case 'af-south-1': + case 'ap-east-1': + case 'ap-northeast-1': + case 'ap-northeast-2': + case 'ap-northeast-3': + case 'ap-south-1': + case 'ap-southeast-1': + case 'ap-southeast-2': + case 'ap-southeast-3': + case 'ca-central-1': + case 'eu-central-1': + case 'eu-north-1': + case 'eu-south-1': + case 'eu-west-1': + case 'eu-west-2': + case 'eu-west-3': + case 'me-south-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 [ + 'endpoint' => "https://athena.$region.amazonaws.com", + 'signRegion' => $region, + 'signService' => 'athena', + 'signVersions' => ['v4'], + ]; + case 'cn-north-1': + case 'cn-northwest-1': + return [ + 'endpoint' => "https://athena.$region.amazonaws.com.cn", + 'signRegion' => $region, + 'signService' => 'athena', + 'signVersions' => ['v4'], + ]; + case 'fips-us-east-1': + return [ + 'endpoint' => 'https://athena-fips.us-east-1.amazonaws.com', + 'signRegion' => 'us-east-1', + 'signService' => 'athena', + 'signVersions' => ['v4'], + ]; + case 'fips-us-east-2': + return [ + 'endpoint' => 'https://athena-fips.us-east-2.amazonaws.com', + 'signRegion' => 'us-east-2', + 'signService' => 'athena', + 'signVersions' => ['v4'], + ]; + case 'fips-us-west-1': + return [ + 'endpoint' => 'https://athena-fips.us-west-1.amazonaws.com', + 'signRegion' => 'us-west-1', + 'signService' => 'athena', + 'signVersions' => ['v4'], + ]; + case 'fips-us-west-2': + return [ + 'endpoint' => 'https://athena-fips.us-west-2.amazonaws.com', + 'signRegion' => 'us-west-2', + 'signService' => 'athena', + 'signVersions' => ['v4'], + ]; + case 'fips-us-gov-east-1': + return [ + 'endpoint' => 'https://athena-fips.us-gov-east-1.amazonaws.com', + 'signRegion' => 'us-gov-east-1', + 'signService' => 'athena', + 'signVersions' => ['v4'], + ]; + case 'fips-us-gov-west-1': + return [ + 'endpoint' => 'https://athena-fips.us-gov-west-1.amazonaws.com', + 'signRegion' => 'us-gov-west-1', + 'signService' => 'athena', + 'signVersions' => ['v4'], + ]; + } + + throw new UnsupportedRegion(sprintf('The region "%s" is not supported by "Athena".', $region)); + } +} diff --git a/src/Service/Athena/src/Enum/CalculationExecutionState.php b/src/Service/Athena/src/Enum/CalculationExecutionState.php new file mode 100644 index 000000000..0b46ac427 --- /dev/null +++ b/src/Service/Athena/src/Enum/CalculationExecutionState.php @@ -0,0 +1,40 @@ + true, + self::CANCELING => true, + self::COMPLETED => true, + self::CREATED => true, + self::CREATING => true, + self::FAILED => true, + self::QUEUED => true, + self::RUNNING => true, + ][$value]); + } +} diff --git a/src/Service/Athena/src/Enum/ColumnNullable.php b/src/Service/Athena/src/Enum/ColumnNullable.php new file mode 100644 index 000000000..ffe5d481d --- /dev/null +++ b/src/Service/Athena/src/Enum/ColumnNullable.php @@ -0,0 +1,22 @@ + true, + self::NULLABLE => true, + self::UNKNOWN => true, + ][$value]); + } +} diff --git a/src/Service/Athena/src/Enum/DataCatalogType.php b/src/Service/Athena/src/Enum/DataCatalogType.php new file mode 100644 index 000000000..11ae2e465 --- /dev/null +++ b/src/Service/Athena/src/Enum/DataCatalogType.php @@ -0,0 +1,23 @@ + true, + self::HIVE => true, + self::LAMBDA => true, + ][$value]); + } +} diff --git a/src/Service/Athena/src/Enum/EncryptionOption.php b/src/Service/Athena/src/Enum/EncryptionOption.php new file mode 100644 index 000000000..7682c6679 --- /dev/null +++ b/src/Service/Athena/src/Enum/EncryptionOption.php @@ -0,0 +1,25 @@ + true, + self::SSE_KMS => true, + self::SSE_S3 => true, + ][$value]); + } +} diff --git a/src/Service/Athena/src/Enum/QueryExecutionState.php b/src/Service/Athena/src/Enum/QueryExecutionState.php new file mode 100644 index 000000000..117d82d6e --- /dev/null +++ b/src/Service/Athena/src/Enum/QueryExecutionState.php @@ -0,0 +1,32 @@ + Athena automatically retries your queries in cases of certain transient errors. As a result, you may see the query + * > state transition from `RUNNING` or `FAILED` to `QUEUED`. + */ +final class QueryExecutionState +{ + public const CANCELLED = 'CANCELLED'; + public const FAILED = 'FAILED'; + public const QUEUED = 'QUEUED'; + public const RUNNING = 'RUNNING'; + public const SUCCEEDED = 'SUCCEEDED'; + + public static function exists(string $value): bool + { + return isset([ + self::CANCELLED => true, + self::FAILED => true, + self::QUEUED => true, + self::RUNNING => true, + self::SUCCEEDED => true, + ][$value]); + } +} diff --git a/src/Service/Athena/src/Enum/S3AclOption.php b/src/Service/Athena/src/Enum/S3AclOption.php new file mode 100644 index 000000000..86e303fe1 --- /dev/null +++ b/src/Service/Athena/src/Enum/S3AclOption.php @@ -0,0 +1,23 @@ + true, + ][$value]); + } +} diff --git a/src/Service/Athena/src/Enum/SessionState.php b/src/Service/Athena/src/Enum/SessionState.php new file mode 100644 index 000000000..dd08f8567 --- /dev/null +++ b/src/Service/Athena/src/Enum/SessionState.php @@ -0,0 +1,40 @@ + true, + self::CREATED => true, + self::CREATING => true, + self::DEGRADED => true, + self::FAILED => true, + self::IDLE => true, + self::TERMINATED => true, + self::TERMINATING => true, + ][$value]); + } +} diff --git a/src/Service/Athena/src/Enum/StatementType.php b/src/Service/Athena/src/Enum/StatementType.php new file mode 100644 index 000000000..0736af98d --- /dev/null +++ b/src/Service/Athena/src/Enum/StatementType.php @@ -0,0 +1,24 @@ + true, + self::DML => true, + self::UTILITY => true, + ][$value]); + } +} diff --git a/src/Service/Athena/src/Enum/ThrottleReason.php b/src/Service/Athena/src/Enum/ThrottleReason.php new file mode 100644 index 000000000..2ca8d329b --- /dev/null +++ b/src/Service/Athena/src/Enum/ThrottleReason.php @@ -0,0 +1,15 @@ + true, + ][$value]); + } +} diff --git a/src/Service/Athena/src/Enum/WorkGroupState.php b/src/Service/Athena/src/Enum/WorkGroupState.php new file mode 100644 index 000000000..954c85995 --- /dev/null +++ b/src/Service/Athena/src/Enum/WorkGroupState.php @@ -0,0 +1,20 @@ + true, + self::ENABLED => true, + ][$value]); + } +} diff --git a/src/Service/Athena/src/Exception/InternalServerException.php b/src/Service/Athena/src/Exception/InternalServerException.php new file mode 100644 index 000000000..073a2f89e --- /dev/null +++ b/src/Service/Athena/src/Exception/InternalServerException.php @@ -0,0 +1,21 @@ +toArray(false); + + if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) { + $this->message = $v; + } + } +} diff --git a/src/Service/Athena/src/Exception/InvalidRequestException.php b/src/Service/Athena/src/Exception/InvalidRequestException.php new file mode 100644 index 000000000..c09e92578 --- /dev/null +++ b/src/Service/Athena/src/Exception/InvalidRequestException.php @@ -0,0 +1,30 @@ +athenaErrorCode; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + $this->athenaErrorCode = isset($data['AthenaErrorCode']) ? (string) $data['AthenaErrorCode'] : null; + if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) { + $this->message = $v; + } + } +} diff --git a/src/Service/Athena/src/Exception/MetadataException.php b/src/Service/Athena/src/Exception/MetadataException.php new file mode 100644 index 000000000..25dbf8113 --- /dev/null +++ b/src/Service/Athena/src/Exception/MetadataException.php @@ -0,0 +1,23 @@ +toArray(false); + + if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) { + $this->message = $v; + } + } +} diff --git a/src/Service/Athena/src/Exception/ResourceNotFoundException.php b/src/Service/Athena/src/Exception/ResourceNotFoundException.php new file mode 100644 index 000000000..a5e8ecc58 --- /dev/null +++ b/src/Service/Athena/src/Exception/ResourceNotFoundException.php @@ -0,0 +1,32 @@ +resourceName; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) { + $this->message = $v; + } + $this->resourceName = isset($data['ResourceName']) ? (string) $data['ResourceName'] : null; + } +} diff --git a/src/Service/Athena/src/Exception/SessionAlreadyExistsException.php b/src/Service/Athena/src/Exception/SessionAlreadyExistsException.php new file mode 100644 index 000000000..565a29454 --- /dev/null +++ b/src/Service/Athena/src/Exception/SessionAlreadyExistsException.php @@ -0,0 +1,21 @@ +toArray(false); + + if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) { + $this->message = $v; + } + } +} diff --git a/src/Service/Athena/src/Exception/TooManyRequestsException.php b/src/Service/Athena/src/Exception/TooManyRequestsException.php new file mode 100644 index 000000000..b74a5d284 --- /dev/null +++ b/src/Service/Athena/src/Exception/TooManyRequestsException.php @@ -0,0 +1,33 @@ +reason; + } + + protected function populateResult(ResponseInterface $response): void + { + $data = $response->toArray(false); + + if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) { + $this->message = $v; + } + $this->reason = isset($data['Reason']) ? (string) $data['Reason'] : null; + } +} diff --git a/src/Service/Athena/src/Input/GetCalculationExecutionRequest.php b/src/Service/Athena/src/Input/GetCalculationExecutionRequest.php new file mode 100644 index 000000000..2d09a9dc3 --- /dev/null +++ b/src/Service/Athena/src/Input/GetCalculationExecutionRequest.php @@ -0,0 +1,86 @@ +calculationExecutionId = $input['CalculationExecutionId'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCalculationExecutionId(): ?string + { + return $this->calculationExecutionId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetCalculationExecution', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setCalculationExecutionId(?string $value): self + { + $this->calculationExecutionId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->calculationExecutionId) { + throw new InvalidArgument(sprintf('Missing parameter "CalculationExecutionId" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['CalculationExecutionId'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/GetCalculationExecutionStatusRequest.php b/src/Service/Athena/src/Input/GetCalculationExecutionStatusRequest.php new file mode 100644 index 000000000..83718c04c --- /dev/null +++ b/src/Service/Athena/src/Input/GetCalculationExecutionStatusRequest.php @@ -0,0 +1,86 @@ +calculationExecutionId = $input['CalculationExecutionId'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCalculationExecutionId(): ?string + { + return $this->calculationExecutionId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetCalculationExecutionStatus', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setCalculationExecutionId(?string $value): self + { + $this->calculationExecutionId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->calculationExecutionId) { + throw new InvalidArgument(sprintf('Missing parameter "CalculationExecutionId" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['CalculationExecutionId'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/GetDataCatalogInput.php b/src/Service/Athena/src/Input/GetDataCatalogInput.php new file mode 100644 index 000000000..045326292 --- /dev/null +++ b/src/Service/Athena/src/Input/GetDataCatalogInput.php @@ -0,0 +1,86 @@ +name = $input['Name'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getName(): ?string + { + return $this->name; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetDataCatalog', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setName(?string $value): self + { + $this->name = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->name) { + throw new InvalidArgument(sprintf('Missing parameter "Name" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['Name'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/GetDatabaseInput.php b/src/Service/Athena/src/Input/GetDatabaseInput.php new file mode 100644 index 000000000..9f9c1afe5 --- /dev/null +++ b/src/Service/Athena/src/Input/GetDatabaseInput.php @@ -0,0 +1,113 @@ +catalogName = $input['CatalogName'] ?? null; + $this->databaseName = $input['DatabaseName'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCatalogName(): ?string + { + return $this->catalogName; + } + + public function getDatabaseName(): ?string + { + return $this->databaseName; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetDatabase', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setCatalogName(?string $value): self + { + $this->catalogName = $value; + + return $this; + } + + public function setDatabaseName(?string $value): self + { + $this->databaseName = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->catalogName) { + throw new InvalidArgument(sprintf('Missing parameter "CatalogName" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['CatalogName'] = $v; + if (null === $v = $this->databaseName) { + throw new InvalidArgument(sprintf('Missing parameter "DatabaseName" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['DatabaseName'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/GetNamedQueryInput.php b/src/Service/Athena/src/Input/GetNamedQueryInput.php new file mode 100644 index 000000000..5ac9eacee --- /dev/null +++ b/src/Service/Athena/src/Input/GetNamedQueryInput.php @@ -0,0 +1,86 @@ +namedQueryId = $input['NamedQueryId'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getNamedQueryId(): ?string + { + return $this->namedQueryId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetNamedQuery', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setNamedQueryId(?string $value): self + { + $this->namedQueryId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->namedQueryId) { + throw new InvalidArgument(sprintf('Missing parameter "NamedQueryId" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['NamedQueryId'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/GetQueryExecutionInput.php b/src/Service/Athena/src/Input/GetQueryExecutionInput.php new file mode 100644 index 000000000..e0a91bc8d --- /dev/null +++ b/src/Service/Athena/src/Input/GetQueryExecutionInput.php @@ -0,0 +1,86 @@ +queryExecutionId = $input['QueryExecutionId'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getQueryExecutionId(): ?string + { + return $this->queryExecutionId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetQueryExecution', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setQueryExecutionId(?string $value): self + { + $this->queryExecutionId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->queryExecutionId) { + throw new InvalidArgument(sprintf('Missing parameter "QueryExecutionId" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['QueryExecutionId'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/GetQueryResultsInput.php b/src/Service/Athena/src/Input/GetQueryResultsInput.php new file mode 100644 index 000000000..2db31fcfb --- /dev/null +++ b/src/Service/Athena/src/Input/GetQueryResultsInput.php @@ -0,0 +1,136 @@ +queryExecutionId = $input['QueryExecutionId'] ?? null; + $this->nextToken = $input['NextToken'] ?? null; + $this->maxResults = $input['MaxResults'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getMaxResults(): ?int + { + return $this->maxResults; + } + + public function getNextToken(): ?string + { + return $this->nextToken; + } + + public function getQueryExecutionId(): ?string + { + return $this->queryExecutionId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetQueryResults', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setMaxResults(?int $value): self + { + $this->maxResults = $value; + + return $this; + } + + public function setNextToken(?string $value): self + { + $this->nextToken = $value; + + return $this; + } + + public function setQueryExecutionId(?string $value): self + { + $this->queryExecutionId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->queryExecutionId) { + throw new InvalidArgument(sprintf('Missing parameter "QueryExecutionId" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['QueryExecutionId'] = $v; + if (null !== $v = $this->nextToken) { + $payload['NextToken'] = $v; + } + if (null !== $v = $this->maxResults) { + $payload['MaxResults'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/GetSessionRequest.php b/src/Service/Athena/src/Input/GetSessionRequest.php new file mode 100644 index 000000000..c8d86d9fe --- /dev/null +++ b/src/Service/Athena/src/Input/GetSessionRequest.php @@ -0,0 +1,86 @@ +sessionId = $input['SessionId'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getSessionId(): ?string + { + return $this->sessionId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetSession', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setSessionId(?string $value): self + { + $this->sessionId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->sessionId) { + throw new InvalidArgument(sprintf('Missing parameter "SessionId" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['SessionId'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/GetSessionStatusRequest.php b/src/Service/Athena/src/Input/GetSessionStatusRequest.php new file mode 100644 index 000000000..8f782c3a7 --- /dev/null +++ b/src/Service/Athena/src/Input/GetSessionStatusRequest.php @@ -0,0 +1,86 @@ +sessionId = $input['SessionId'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getSessionId(): ?string + { + return $this->sessionId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetSessionStatus', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setSessionId(?string $value): self + { + $this->sessionId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->sessionId) { + throw new InvalidArgument(sprintf('Missing parameter "SessionId" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['SessionId'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/GetTableMetadataInput.php b/src/Service/Athena/src/Input/GetTableMetadataInput.php new file mode 100644 index 000000000..98f673e2a --- /dev/null +++ b/src/Service/Athena/src/Input/GetTableMetadataInput.php @@ -0,0 +1,140 @@ +catalogName = $input['CatalogName'] ?? null; + $this->databaseName = $input['DatabaseName'] ?? null; + $this->tableName = $input['TableName'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCatalogName(): ?string + { + return $this->catalogName; + } + + public function getDatabaseName(): ?string + { + return $this->databaseName; + } + + public function getTableName(): ?string + { + return $this->tableName; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetTableMetadata', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setCatalogName(?string $value): self + { + $this->catalogName = $value; + + return $this; + } + + public function setDatabaseName(?string $value): self + { + $this->databaseName = $value; + + return $this; + } + + public function setTableName(?string $value): self + { + $this->tableName = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->catalogName) { + throw new InvalidArgument(sprintf('Missing parameter "CatalogName" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['CatalogName'] = $v; + if (null === $v = $this->databaseName) { + throw new InvalidArgument(sprintf('Missing parameter "DatabaseName" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['DatabaseName'] = $v; + if (null === $v = $this->tableName) { + throw new InvalidArgument(sprintf('Missing parameter "TableName" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['TableName'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/GetWorkGroupInput.php b/src/Service/Athena/src/Input/GetWorkGroupInput.php new file mode 100644 index 000000000..15adb9107 --- /dev/null +++ b/src/Service/Athena/src/Input/GetWorkGroupInput.php @@ -0,0 +1,86 @@ +workGroup = $input['WorkGroup'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getWorkGroup(): ?string + { + return $this->workGroup; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.GetWorkGroup', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setWorkGroup(?string $value): self + { + $this->workGroup = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->workGroup) { + throw new InvalidArgument(sprintf('Missing parameter "WorkGroup" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['WorkGroup'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/ListDatabasesInput.php b/src/Service/Athena/src/Input/ListDatabasesInput.php new file mode 100644 index 000000000..12fcd21c1 --- /dev/null +++ b/src/Service/Athena/src/Input/ListDatabasesInput.php @@ -0,0 +1,136 @@ +catalogName = $input['CatalogName'] ?? null; + $this->nextToken = $input['NextToken'] ?? null; + $this->maxResults = $input['MaxResults'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCatalogName(): ?string + { + return $this->catalogName; + } + + public function getMaxResults(): ?int + { + return $this->maxResults; + } + + public function getNextToken(): ?string + { + return $this->nextToken; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.ListDatabases', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setCatalogName(?string $value): self + { + $this->catalogName = $value; + + return $this; + } + + public function setMaxResults(?int $value): self + { + $this->maxResults = $value; + + return $this; + } + + public function setNextToken(?string $value): self + { + $this->nextToken = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->catalogName) { + throw new InvalidArgument(sprintf('Missing parameter "CatalogName" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['CatalogName'] = $v; + if (null !== $v = $this->nextToken) { + $payload['NextToken'] = $v; + } + if (null !== $v = $this->maxResults) { + $payload['MaxResults'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/ListNamedQueriesInput.php b/src/Service/Athena/src/Input/ListNamedQueriesInput.php new file mode 100644 index 000000000..81dffb670 --- /dev/null +++ b/src/Service/Athena/src/Input/ListNamedQueriesInput.php @@ -0,0 +1,133 @@ +nextToken = $input['NextToken'] ?? null; + $this->maxResults = $input['MaxResults'] ?? null; + $this->workGroup = $input['WorkGroup'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getMaxResults(): ?int + { + return $this->maxResults; + } + + public function getNextToken(): ?string + { + return $this->nextToken; + } + + public function getWorkGroup(): ?string + { + return $this->workGroup; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.ListNamedQueries', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setMaxResults(?int $value): self + { + $this->maxResults = $value; + + return $this; + } + + public function setNextToken(?string $value): self + { + $this->nextToken = $value; + + return $this; + } + + public function setWorkGroup(?string $value): self + { + $this->workGroup = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null !== $v = $this->nextToken) { + $payload['NextToken'] = $v; + } + if (null !== $v = $this->maxResults) { + $payload['MaxResults'] = $v; + } + if (null !== $v = $this->workGroup) { + $payload['WorkGroup'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/ListQueryExecutionsInput.php b/src/Service/Athena/src/Input/ListQueryExecutionsInput.php new file mode 100644 index 000000000..2bcf59884 --- /dev/null +++ b/src/Service/Athena/src/Input/ListQueryExecutionsInput.php @@ -0,0 +1,133 @@ +nextToken = $input['NextToken'] ?? null; + $this->maxResults = $input['MaxResults'] ?? null; + $this->workGroup = $input['WorkGroup'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getMaxResults(): ?int + { + return $this->maxResults; + } + + public function getNextToken(): ?string + { + return $this->nextToken; + } + + public function getWorkGroup(): ?string + { + return $this->workGroup; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.ListQueryExecutions', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setMaxResults(?int $value): self + { + $this->maxResults = $value; + + return $this; + } + + public function setNextToken(?string $value): self + { + $this->nextToken = $value; + + return $this; + } + + public function setWorkGroup(?string $value): self + { + $this->workGroup = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null !== $v = $this->nextToken) { + $payload['NextToken'] = $v; + } + if (null !== $v = $this->maxResults) { + $payload['MaxResults'] = $v; + } + if (null !== $v = $this->workGroup) { + $payload['WorkGroup'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/ListTableMetadataInput.php b/src/Service/Athena/src/Input/ListTableMetadataInput.php new file mode 100644 index 000000000..64d52eac0 --- /dev/null +++ b/src/Service/Athena/src/Input/ListTableMetadataInput.php @@ -0,0 +1,186 @@ +catalogName = $input['CatalogName'] ?? null; + $this->databaseName = $input['DatabaseName'] ?? null; + $this->expression = $input['Expression'] ?? null; + $this->nextToken = $input['NextToken'] ?? null; + $this->maxResults = $input['MaxResults'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCatalogName(): ?string + { + return $this->catalogName; + } + + public function getDatabaseName(): ?string + { + return $this->databaseName; + } + + public function getExpression(): ?string + { + return $this->expression; + } + + public function getMaxResults(): ?int + { + return $this->maxResults; + } + + public function getNextToken(): ?string + { + return $this->nextToken; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.ListTableMetadata', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setCatalogName(?string $value): self + { + $this->catalogName = $value; + + return $this; + } + + public function setDatabaseName(?string $value): self + { + $this->databaseName = $value; + + return $this; + } + + public function setExpression(?string $value): self + { + $this->expression = $value; + + return $this; + } + + public function setMaxResults(?int $value): self + { + $this->maxResults = $value; + + return $this; + } + + public function setNextToken(?string $value): self + { + $this->nextToken = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->catalogName) { + throw new InvalidArgument(sprintf('Missing parameter "CatalogName" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['CatalogName'] = $v; + if (null === $v = $this->databaseName) { + throw new InvalidArgument(sprintf('Missing parameter "DatabaseName" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['DatabaseName'] = $v; + if (null !== $v = $this->expression) { + $payload['Expression'] = $v; + } + if (null !== $v = $this->nextToken) { + $payload['NextToken'] = $v; + } + if (null !== $v = $this->maxResults) { + $payload['MaxResults'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/StartCalculationExecutionRequest.php b/src/Service/Athena/src/Input/StartCalculationExecutionRequest.php new file mode 100644 index 000000000..691bdae01 --- /dev/null +++ b/src/Service/Athena/src/Input/StartCalculationExecutionRequest.php @@ -0,0 +1,195 @@ +sessionId = $input['SessionId'] ?? null; + $this->description = $input['Description'] ?? null; + $this->calculationConfiguration = isset($input['CalculationConfiguration']) ? CalculationConfiguration::create($input['CalculationConfiguration']) : null; + $this->codeBlock = $input['CodeBlock'] ?? null; + $this->clientRequestToken = $input['ClientRequestToken'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @deprecated + */ + public function getCalculationConfiguration(): ?CalculationConfiguration + { + @trigger_error(sprintf('The property "CalculationConfiguration" of "%s" is deprecated by AWS.', __CLASS__), \E_USER_DEPRECATED); + + return $this->calculationConfiguration; + } + + public function getClientRequestToken(): ?string + { + return $this->clientRequestToken; + } + + public function getCodeBlock(): ?string + { + return $this->codeBlock; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function getSessionId(): ?string + { + return $this->sessionId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.StartCalculationExecution', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + /** + * @deprecated + */ + public function setCalculationConfiguration(?CalculationConfiguration $value): self + { + @trigger_error(sprintf('The property "CalculationConfiguration" of "%s" is deprecated by AWS.', __CLASS__), \E_USER_DEPRECATED); + $this->calculationConfiguration = $value; + + return $this; + } + + public function setClientRequestToken(?string $value): self + { + $this->clientRequestToken = $value; + + return $this; + } + + public function setCodeBlock(?string $value): self + { + $this->codeBlock = $value; + + return $this; + } + + public function setDescription(?string $value): self + { + $this->description = $value; + + return $this; + } + + public function setSessionId(?string $value): self + { + $this->sessionId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->sessionId) { + throw new InvalidArgument(sprintf('Missing parameter "SessionId" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['SessionId'] = $v; + if (null !== $v = $this->description) { + $payload['Description'] = $v; + } + if (null !== $v = $this->calculationConfiguration) { + @trigger_error(sprintf('The property "CalculationConfiguration" of "%s" is deprecated by AWS.', __CLASS__), \E_USER_DEPRECATED); + $payload['CalculationConfiguration'] = $v->requestBody(); + } + if (null !== $v = $this->codeBlock) { + $payload['CodeBlock'] = $v; + } + if (null !== $v = $this->clientRequestToken) { + $payload['ClientRequestToken'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/StartQueryExecutionInput.php b/src/Service/Athena/src/Input/StartQueryExecutionInput.php new file mode 100644 index 000000000..5c94ae7d2 --- /dev/null +++ b/src/Service/Athena/src/Input/StartQueryExecutionInput.php @@ -0,0 +1,251 @@ +queryString = $input['QueryString'] ?? null; + $this->clientRequestToken = $input['ClientRequestToken'] ?? null; + $this->queryExecutionContext = isset($input['QueryExecutionContext']) ? QueryExecutionContext::create($input['QueryExecutionContext']) : null; + $this->resultConfiguration = isset($input['ResultConfiguration']) ? ResultConfiguration::create($input['ResultConfiguration']) : null; + $this->workGroup = $input['WorkGroup'] ?? null; + $this->executionParameters = $input['ExecutionParameters'] ?? null; + $this->resultReuseConfiguration = isset($input['ResultReuseConfiguration']) ? ResultReuseConfiguration::create($input['ResultReuseConfiguration']) : null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getClientRequestToken(): ?string + { + return $this->clientRequestToken; + } + + /** + * @return string[] + */ + public function getExecutionParameters(): array + { + return $this->executionParameters ?? []; + } + + public function getQueryExecutionContext(): ?QueryExecutionContext + { + return $this->queryExecutionContext; + } + + public function getQueryString(): ?string + { + return $this->queryString; + } + + public function getResultConfiguration(): ?ResultConfiguration + { + return $this->resultConfiguration; + } + + public function getResultReuseConfiguration(): ?ResultReuseConfiguration + { + return $this->resultReuseConfiguration; + } + + public function getWorkGroup(): ?string + { + return $this->workGroup; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.StartQueryExecution', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setClientRequestToken(?string $value): self + { + $this->clientRequestToken = $value; + + return $this; + } + + /** + * @param string[] $value + */ + public function setExecutionParameters(array $value): self + { + $this->executionParameters = $value; + + return $this; + } + + public function setQueryExecutionContext(?QueryExecutionContext $value): self + { + $this->queryExecutionContext = $value; + + return $this; + } + + public function setQueryString(?string $value): self + { + $this->queryString = $value; + + return $this; + } + + public function setResultConfiguration(?ResultConfiguration $value): self + { + $this->resultConfiguration = $value; + + return $this; + } + + public function setResultReuseConfiguration(?ResultReuseConfiguration $value): self + { + $this->resultReuseConfiguration = $value; + + return $this; + } + + public function setWorkGroup(?string $value): self + { + $this->workGroup = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->queryString) { + throw new InvalidArgument(sprintf('Missing parameter "QueryString" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['QueryString'] = $v; + if (null === $v = $this->clientRequestToken) { + $v = uuid_create(\UUID_TYPE_RANDOM); + } + $payload['ClientRequestToken'] = $v; + if (null !== $v = $this->queryExecutionContext) { + $payload['QueryExecutionContext'] = $v->requestBody(); + } + if (null !== $v = $this->resultConfiguration) { + $payload['ResultConfiguration'] = $v->requestBody(); + } + if (null !== $v = $this->workGroup) { + $payload['WorkGroup'] = $v; + } + if (null !== $v = $this->executionParameters) { + $index = -1; + $payload['ExecutionParameters'] = []; + foreach ($v as $listValue) { + ++$index; + $payload['ExecutionParameters'][$index] = $listValue; + } + } + if (null !== $v = $this->resultReuseConfiguration) { + $payload['ResultReuseConfiguration'] = $v->requestBody(); + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/StartSessionRequest.php b/src/Service/Athena/src/Input/StartSessionRequest.php new file mode 100644 index 000000000..8005b1669 --- /dev/null +++ b/src/Service/Athena/src/Input/StartSessionRequest.php @@ -0,0 +1,215 @@ +description = $input['Description'] ?? null; + $this->workGroup = $input['WorkGroup'] ?? null; + $this->engineConfiguration = isset($input['EngineConfiguration']) ? EngineConfiguration::create($input['EngineConfiguration']) : null; + $this->notebookVersion = $input['NotebookVersion'] ?? null; + $this->sessionIdleTimeoutInMinutes = $input['SessionIdleTimeoutInMinutes'] ?? null; + $this->clientRequestToken = $input['ClientRequestToken'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getClientRequestToken(): ?string + { + return $this->clientRequestToken; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function getEngineConfiguration(): ?EngineConfiguration + { + return $this->engineConfiguration; + } + + public function getNotebookVersion(): ?string + { + return $this->notebookVersion; + } + + public function getSessionIdleTimeoutInMinutes(): ?int + { + return $this->sessionIdleTimeoutInMinutes; + } + + public function getWorkGroup(): ?string + { + return $this->workGroup; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.StartSession', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setClientRequestToken(?string $value): self + { + $this->clientRequestToken = $value; + + return $this; + } + + public function setDescription(?string $value): self + { + $this->description = $value; + + return $this; + } + + public function setEngineConfiguration(?EngineConfiguration $value): self + { + $this->engineConfiguration = $value; + + return $this; + } + + public function setNotebookVersion(?string $value): self + { + $this->notebookVersion = $value; + + return $this; + } + + public function setSessionIdleTimeoutInMinutes(?int $value): self + { + $this->sessionIdleTimeoutInMinutes = $value; + + return $this; + } + + public function setWorkGroup(?string $value): self + { + $this->workGroup = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null !== $v = $this->description) { + $payload['Description'] = $v; + } + if (null === $v = $this->workGroup) { + throw new InvalidArgument(sprintf('Missing parameter "WorkGroup" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['WorkGroup'] = $v; + if (null === $v = $this->engineConfiguration) { + throw new InvalidArgument(sprintf('Missing parameter "EngineConfiguration" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['EngineConfiguration'] = $v->requestBody(); + if (null !== $v = $this->notebookVersion) { + $payload['NotebookVersion'] = $v; + } + if (null !== $v = $this->sessionIdleTimeoutInMinutes) { + $payload['SessionIdleTimeoutInMinutes'] = $v; + } + if (null !== $v = $this->clientRequestToken) { + $payload['ClientRequestToken'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/StopCalculationExecutionRequest.php b/src/Service/Athena/src/Input/StopCalculationExecutionRequest.php new file mode 100644 index 000000000..f81c8c252 --- /dev/null +++ b/src/Service/Athena/src/Input/StopCalculationExecutionRequest.php @@ -0,0 +1,86 @@ +calculationExecutionId = $input['CalculationExecutionId'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCalculationExecutionId(): ?string + { + return $this->calculationExecutionId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.StopCalculationExecution', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setCalculationExecutionId(?string $value): self + { + $this->calculationExecutionId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->calculationExecutionId) { + throw new InvalidArgument(sprintf('Missing parameter "CalculationExecutionId" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['CalculationExecutionId'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/StopQueryExecutionInput.php b/src/Service/Athena/src/Input/StopQueryExecutionInput.php new file mode 100644 index 000000000..d5357696d --- /dev/null +++ b/src/Service/Athena/src/Input/StopQueryExecutionInput.php @@ -0,0 +1,85 @@ +queryExecutionId = $input['QueryExecutionId'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getQueryExecutionId(): ?string + { + return $this->queryExecutionId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.StopQueryExecution', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setQueryExecutionId(?string $value): self + { + $this->queryExecutionId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->queryExecutionId) { + $v = uuid_create(\UUID_TYPE_RANDOM); + } + $payload['QueryExecutionId'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Input/TerminateSessionRequest.php b/src/Service/Athena/src/Input/TerminateSessionRequest.php new file mode 100644 index 000000000..23ff8669e --- /dev/null +++ b/src/Service/Athena/src/Input/TerminateSessionRequest.php @@ -0,0 +1,86 @@ +sessionId = $input['SessionId'] ?? null; + parent::__construct($input); + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getSessionId(): ?string + { + return $this->sessionId; + } + + /** + * @internal + */ + public function request(): Request + { + // Prepare headers + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.1', + 'X-Amz-Target' => 'AmazonAthena.TerminateSession', + ]; + + // Prepare query + $query = []; + + // Prepare URI + $uriString = '/'; + + // Prepare Body + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); + + // Return the Request + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); + } + + public function setSessionId(?string $value): self + { + $this->sessionId = $value; + + return $this; + } + + private function requestBody(): array + { + $payload = []; + if (null === $v = $this->sessionId) { + throw new InvalidArgument(sprintf('Missing parameter "SessionId" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['SessionId'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/Result/GetCalculationExecutionResponse.php b/src/Service/Athena/src/Result/GetCalculationExecutionResponse.php new file mode 100644 index 000000000..c7e2370c9 --- /dev/null +++ b/src/Service/Athena/src/Result/GetCalculationExecutionResponse.php @@ -0,0 +1,138 @@ +initialize(); + + return $this->calculationExecutionId; + } + + public function getDescription(): ?string + { + $this->initialize(); + + return $this->description; + } + + public function getResult(): ?CalculationResult + { + $this->initialize(); + + return $this->result; + } + + public function getSessionId(): ?string + { + $this->initialize(); + + return $this->sessionId; + } + + public function getStatistics(): ?CalculationStatistics + { + $this->initialize(); + + return $this->statistics; + } + + public function getStatus(): ?CalculationStatus + { + $this->initialize(); + + return $this->status; + } + + public function getWorkingDirectory(): ?string + { + $this->initialize(); + + return $this->workingDirectory; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->calculationExecutionId = isset($data['CalculationExecutionId']) ? (string) $data['CalculationExecutionId'] : null; + $this->sessionId = isset($data['SessionId']) ? (string) $data['SessionId'] : null; + $this->description = isset($data['Description']) ? (string) $data['Description'] : null; + $this->workingDirectory = isset($data['WorkingDirectory']) ? (string) $data['WorkingDirectory'] : null; + $this->status = empty($data['Status']) ? null : $this->populateResultCalculationStatus($data['Status']); + $this->statistics = empty($data['Statistics']) ? null : $this->populateResultCalculationStatistics($data['Statistics']); + $this->result = empty($data['Result']) ? null : $this->populateResultCalculationResult($data['Result']); + } + + private function populateResultCalculationResult(array $json): CalculationResult + { + return new CalculationResult([ + 'StdOutS3Uri' => isset($json['StdOutS3Uri']) ? (string) $json['StdOutS3Uri'] : null, + 'StdErrorS3Uri' => isset($json['StdErrorS3Uri']) ? (string) $json['StdErrorS3Uri'] : null, + 'ResultS3Uri' => isset($json['ResultS3Uri']) ? (string) $json['ResultS3Uri'] : null, + 'ResultType' => isset($json['ResultType']) ? (string) $json['ResultType'] : null, + ]); + } + + private function populateResultCalculationStatistics(array $json): CalculationStatistics + { + return new CalculationStatistics([ + 'DpuExecutionInMillis' => isset($json['DpuExecutionInMillis']) ? (string) $json['DpuExecutionInMillis'] : null, + 'Progress' => isset($json['Progress']) ? (string) $json['Progress'] : null, + ]); + } + + private function populateResultCalculationStatus(array $json): CalculationStatus + { + return new CalculationStatus([ + 'SubmissionDateTime' => (isset($json['SubmissionDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['SubmissionDateTime'])))) ? $d : null, + 'CompletionDateTime' => (isset($json['CompletionDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['CompletionDateTime'])))) ? $d : null, + 'State' => isset($json['State']) ? (string) $json['State'] : null, + 'StateChangeReason' => isset($json['StateChangeReason']) ? (string) $json['StateChangeReason'] : null, + ]); + } +} diff --git a/src/Service/Athena/src/Result/GetCalculationExecutionStatusResponse.php b/src/Service/Athena/src/Result/GetCalculationExecutionStatusResponse.php new file mode 100644 index 000000000..aa69d4aa6 --- /dev/null +++ b/src/Service/Athena/src/Result/GetCalculationExecutionStatusResponse.php @@ -0,0 +1,61 @@ +initialize(); + + return $this->statistics; + } + + public function getStatus(): ?CalculationStatus + { + $this->initialize(); + + return $this->status; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->status = empty($data['Status']) ? null : $this->populateResultCalculationStatus($data['Status']); + $this->statistics = empty($data['Statistics']) ? null : $this->populateResultCalculationStatistics($data['Statistics']); + } + + private function populateResultCalculationStatistics(array $json): CalculationStatistics + { + return new CalculationStatistics([ + 'DpuExecutionInMillis' => isset($json['DpuExecutionInMillis']) ? (string) $json['DpuExecutionInMillis'] : null, + 'Progress' => isset($json['Progress']) ? (string) $json['Progress'] : null, + ]); + } + + private function populateResultCalculationStatus(array $json): CalculationStatus + { + return new CalculationStatus([ + 'SubmissionDateTime' => (isset($json['SubmissionDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['SubmissionDateTime'])))) ? $d : null, + 'CompletionDateTime' => (isset($json['CompletionDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['CompletionDateTime'])))) ? $d : null, + 'State' => isset($json['State']) ? (string) $json['State'] : null, + 'StateChangeReason' => isset($json['StateChangeReason']) ? (string) $json['StateChangeReason'] : null, + ]); + } +} diff --git a/src/Service/Athena/src/Result/GetDataCatalogOutput.php b/src/Service/Athena/src/Result/GetDataCatalogOutput.php new file mode 100644 index 000000000..771dc34c1 --- /dev/null +++ b/src/Service/Athena/src/Result/GetDataCatalogOutput.php @@ -0,0 +1,52 @@ +initialize(); + + return $this->dataCatalog; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->dataCatalog = empty($data['DataCatalog']) ? null : $this->populateResultDataCatalog($data['DataCatalog']); + } + + private function populateResultDataCatalog(array $json): DataCatalog + { + return new DataCatalog([ + 'Name' => (string) $json['Name'], + 'Description' => isset($json['Description']) ? (string) $json['Description'] : null, + 'Type' => (string) $json['Type'], + 'Parameters' => !isset($json['Parameters']) ? null : $this->populateResultParametersMap($json['Parameters']), + ]); + } + + /** + * @return array + */ + private function populateResultParametersMap(array $json): array + { + $items = []; + foreach ($json as $name => $value) { + $items[(string) $name] = (string) $value; + } + + return $items; + } +} diff --git a/src/Service/Athena/src/Result/GetDatabaseOutput.php b/src/Service/Athena/src/Result/GetDatabaseOutput.php new file mode 100644 index 000000000..5b9287a16 --- /dev/null +++ b/src/Service/Athena/src/Result/GetDatabaseOutput.php @@ -0,0 +1,51 @@ +initialize(); + + return $this->database; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->database = empty($data['Database']) ? null : $this->populateResultDatabase($data['Database']); + } + + private function populateResultDatabase(array $json): Database + { + return new Database([ + 'Name' => (string) $json['Name'], + 'Description' => isset($json['Description']) ? (string) $json['Description'] : null, + 'Parameters' => !isset($json['Parameters']) ? null : $this->populateResultParametersMap($json['Parameters']), + ]); + } + + /** + * @return array + */ + private function populateResultParametersMap(array $json): array + { + $items = []; + foreach ($json as $name => $value) { + $items[(string) $name] = (string) $value; + } + + return $items; + } +} diff --git a/src/Service/Athena/src/Result/GetNamedQueryOutput.php b/src/Service/Athena/src/Result/GetNamedQueryOutput.php new file mode 100644 index 000000000..f8bf3e764 --- /dev/null +++ b/src/Service/Athena/src/Result/GetNamedQueryOutput.php @@ -0,0 +1,41 @@ +initialize(); + + return $this->namedQuery; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->namedQuery = empty($data['NamedQuery']) ? null : $this->populateResultNamedQuery($data['NamedQuery']); + } + + private function populateResultNamedQuery(array $json): NamedQuery + { + return new NamedQuery([ + 'Name' => (string) $json['Name'], + 'Description' => isset($json['Description']) ? (string) $json['Description'] : null, + 'Database' => (string) $json['Database'], + 'QueryString' => (string) $json['QueryString'], + 'NamedQueryId' => isset($json['NamedQueryId']) ? (string) $json['NamedQueryId'] : null, + 'WorkGroup' => isset($json['WorkGroup']) ? (string) $json['WorkGroup'] : null, + ]); + } +} diff --git a/src/Service/Athena/src/Result/GetQueryExecutionOutput.php b/src/Service/Athena/src/Result/GetQueryExecutionOutput.php new file mode 100644 index 000000000..12c9b8122 --- /dev/null +++ b/src/Service/Athena/src/Result/GetQueryExecutionOutput.php @@ -0,0 +1,172 @@ +initialize(); + + return $this->queryExecution; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->queryExecution = empty($data['QueryExecution']) ? null : $this->populateResultQueryExecution($data['QueryExecution']); + } + + private function populateResultAclConfiguration(array $json): AclConfiguration + { + return new AclConfiguration([ + 'S3AclOption' => (string) $json['S3AclOption'], + ]); + } + + private function populateResultAthenaError(array $json): AthenaError + { + return new AthenaError([ + 'ErrorCategory' => isset($json['ErrorCategory']) ? (int) $json['ErrorCategory'] : null, + 'ErrorType' => isset($json['ErrorType']) ? (int) $json['ErrorType'] : null, + 'Retryable' => isset($json['Retryable']) ? filter_var($json['Retryable'], \FILTER_VALIDATE_BOOLEAN) : null, + 'ErrorMessage' => isset($json['ErrorMessage']) ? (string) $json['ErrorMessage'] : null, + ]); + } + + private function populateResultEncryptionConfiguration(array $json): EncryptionConfiguration + { + return new EncryptionConfiguration([ + 'EncryptionOption' => (string) $json['EncryptionOption'], + 'KmsKey' => isset($json['KmsKey']) ? (string) $json['KmsKey'] : null, + ]); + } + + private function populateResultEngineVersion(array $json): EngineVersion + { + return new EngineVersion([ + 'SelectedEngineVersion' => isset($json['SelectedEngineVersion']) ? (string) $json['SelectedEngineVersion'] : null, + 'EffectiveEngineVersion' => isset($json['EffectiveEngineVersion']) ? (string) $json['EffectiveEngineVersion'] : null, + ]); + } + + /** + * @return string[] + */ + private function populateResultExecutionParameters(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } + + private function populateResultQueryExecution(array $json): QueryExecution + { + return new QueryExecution([ + 'QueryExecutionId' => isset($json['QueryExecutionId']) ? (string) $json['QueryExecutionId'] : null, + 'Query' => isset($json['Query']) ? (string) $json['Query'] : null, + 'StatementType' => isset($json['StatementType']) ? (string) $json['StatementType'] : null, + 'ResultConfiguration' => empty($json['ResultConfiguration']) ? null : $this->populateResultResultConfiguration($json['ResultConfiguration']), + 'ResultReuseConfiguration' => empty($json['ResultReuseConfiguration']) ? null : $this->populateResultResultReuseConfiguration($json['ResultReuseConfiguration']), + 'QueryExecutionContext' => empty($json['QueryExecutionContext']) ? null : $this->populateResultQueryExecutionContext($json['QueryExecutionContext']), + 'Status' => empty($json['Status']) ? null : $this->populateResultQueryExecutionStatus($json['Status']), + 'Statistics' => empty($json['Statistics']) ? null : $this->populateResultQueryExecutionStatistics($json['Statistics']), + 'WorkGroup' => isset($json['WorkGroup']) ? (string) $json['WorkGroup'] : null, + 'EngineVersion' => empty($json['EngineVersion']) ? null : $this->populateResultEngineVersion($json['EngineVersion']), + 'ExecutionParameters' => !isset($json['ExecutionParameters']) ? null : $this->populateResultExecutionParameters($json['ExecutionParameters']), + 'SubstatementType' => isset($json['SubstatementType']) ? (string) $json['SubstatementType'] : null, + ]); + } + + private function populateResultQueryExecutionContext(array $json): QueryExecutionContext + { + return new QueryExecutionContext([ + 'Database' => isset($json['Database']) ? (string) $json['Database'] : null, + 'Catalog' => isset($json['Catalog']) ? (string) $json['Catalog'] : null, + ]); + } + + private function populateResultQueryExecutionStatistics(array $json): QueryExecutionStatistics + { + return new QueryExecutionStatistics([ + 'EngineExecutionTimeInMillis' => isset($json['EngineExecutionTimeInMillis']) ? (string) $json['EngineExecutionTimeInMillis'] : null, + 'DataScannedInBytes' => isset($json['DataScannedInBytes']) ? (string) $json['DataScannedInBytes'] : null, + 'DataManifestLocation' => isset($json['DataManifestLocation']) ? (string) $json['DataManifestLocation'] : null, + 'TotalExecutionTimeInMillis' => isset($json['TotalExecutionTimeInMillis']) ? (string) $json['TotalExecutionTimeInMillis'] : null, + 'QueryQueueTimeInMillis' => isset($json['QueryQueueTimeInMillis']) ? (string) $json['QueryQueueTimeInMillis'] : null, + 'QueryPlanningTimeInMillis' => isset($json['QueryPlanningTimeInMillis']) ? (string) $json['QueryPlanningTimeInMillis'] : null, + 'ServiceProcessingTimeInMillis' => isset($json['ServiceProcessingTimeInMillis']) ? (string) $json['ServiceProcessingTimeInMillis'] : null, + 'ResultReuseInformation' => empty($json['ResultReuseInformation']) ? null : $this->populateResultResultReuseInformation($json['ResultReuseInformation']), + ]); + } + + private function populateResultQueryExecutionStatus(array $json): QueryExecutionStatus + { + return new QueryExecutionStatus([ + 'State' => isset($json['State']) ? (string) $json['State'] : null, + 'StateChangeReason' => isset($json['StateChangeReason']) ? (string) $json['StateChangeReason'] : null, + 'SubmissionDateTime' => (isset($json['SubmissionDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['SubmissionDateTime'])))) ? $d : null, + 'CompletionDateTime' => (isset($json['CompletionDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['CompletionDateTime'])))) ? $d : null, + 'AthenaError' => empty($json['AthenaError']) ? null : $this->populateResultAthenaError($json['AthenaError']), + ]); + } + + private function populateResultResultConfiguration(array $json): ResultConfiguration + { + return new ResultConfiguration([ + 'OutputLocation' => isset($json['OutputLocation']) ? (string) $json['OutputLocation'] : null, + 'EncryptionConfiguration' => empty($json['EncryptionConfiguration']) ? null : $this->populateResultEncryptionConfiguration($json['EncryptionConfiguration']), + 'ExpectedBucketOwner' => isset($json['ExpectedBucketOwner']) ? (string) $json['ExpectedBucketOwner'] : null, + 'AclConfiguration' => empty($json['AclConfiguration']) ? null : $this->populateResultAclConfiguration($json['AclConfiguration']), + ]); + } + + private function populateResultResultReuseByAgeConfiguration(array $json): ResultReuseByAgeConfiguration + { + return new ResultReuseByAgeConfiguration([ + 'Enabled' => filter_var($json['Enabled'], \FILTER_VALIDATE_BOOLEAN), + 'MaxAgeInMinutes' => isset($json['MaxAgeInMinutes']) ? (int) $json['MaxAgeInMinutes'] : null, + ]); + } + + private function populateResultResultReuseConfiguration(array $json): ResultReuseConfiguration + { + return new ResultReuseConfiguration([ + 'ResultReuseByAgeConfiguration' => empty($json['ResultReuseByAgeConfiguration']) ? null : $this->populateResultResultReuseByAgeConfiguration($json['ResultReuseByAgeConfiguration']), + ]); + } + + private function populateResultResultReuseInformation(array $json): ResultReuseInformation + { + return new ResultReuseInformation([ + 'ReusedPreviousResult' => filter_var($json['ReusedPreviousResult'], \FILTER_VALIDATE_BOOLEAN), + ]); + } +} diff --git a/src/Service/Athena/src/Result/GetQueryResultsOutput.php b/src/Service/Athena/src/Result/GetQueryResultsOutput.php new file mode 100644 index 000000000..2f293187d --- /dev/null +++ b/src/Service/Athena/src/Result/GetQueryResultsOutput.php @@ -0,0 +1,188 @@ + + */ +class GetQueryResultsOutput extends Result implements \IteratorAggregate +{ + /** + * The number of rows inserted with a `CREATE TABLE AS SELECT` statement. + */ + private $updateCount; + + /** + * The results of the query execution. + */ + private $resultSet; + + /** + * A token generated by the Athena service that specifies where to continue pagination if a previous request was + * truncated. To obtain the next set of pages, pass in the `NextToken` from the response object of the previous page + * call. + */ + private $nextToken; + + /** + * Iterates over ResultSet.Rows. + * + * @return \Traversable + */ + public function getIterator(): \Traversable + { + $client = $this->awsClient; + if (!$client instanceof AthenaClient) { + throw new InvalidArgument('missing client injected in paginated result'); + } + if (!$this->input instanceof GetQueryResultsInput) { + throw new InvalidArgument('missing last request injected in paginated result'); + } + $input = clone $this->input; + $page = $this; + while (true) { + $page->initialize(); + if ($page->nextToken) { + $input->setNextToken($page->nextToken); + + $this->registerPrefetch($nextPage = $client->getQueryResults($input)); + } else { + $nextPage = null; + } + + yield from $page->getResultSet()->getRows(); + + if (null === $nextPage) { + break; + } + + $this->unregisterPrefetch($nextPage); + $page = $nextPage; + } + } + + public function getNextToken(): ?string + { + $this->initialize(); + + return $this->nextToken; + } + + public function getResultSet(): ?ResultSet + { + $this->initialize(); + + return $this->resultSet; + } + + public function getUpdateCount(): ?string + { + $this->initialize(); + + return $this->updateCount; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->updateCount = isset($data['UpdateCount']) ? (string) $data['UpdateCount'] : null; + $this->resultSet = empty($data['ResultSet']) ? null : $this->populateResultResultSet($data['ResultSet']); + $this->nextToken = isset($data['NextToken']) ? (string) $data['NextToken'] : null; + } + + private function populateResultColumnInfo(array $json): ColumnInfo + { + return new ColumnInfo([ + 'CatalogName' => isset($json['CatalogName']) ? (string) $json['CatalogName'] : null, + 'SchemaName' => isset($json['SchemaName']) ? (string) $json['SchemaName'] : null, + 'TableName' => isset($json['TableName']) ? (string) $json['TableName'] : null, + 'Name' => (string) $json['Name'], + 'Label' => isset($json['Label']) ? (string) $json['Label'] : null, + 'Type' => (string) $json['Type'], + 'Precision' => isset($json['Precision']) ? (int) $json['Precision'] : null, + 'Scale' => isset($json['Scale']) ? (int) $json['Scale'] : null, + 'Nullable' => isset($json['Nullable']) ? (string) $json['Nullable'] : null, + 'CaseSensitive' => isset($json['CaseSensitive']) ? filter_var($json['CaseSensitive'], \FILTER_VALIDATE_BOOLEAN) : null, + ]); + } + + /** + * @return ColumnInfo[] + */ + private function populateResultColumnInfoList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultColumnInfo($item); + } + + return $items; + } + + private function populateResultDatum(array $json): Datum + { + return new Datum([ + 'VarCharValue' => isset($json['VarCharValue']) ? (string) $json['VarCharValue'] : null, + ]); + } + + /** + * @return Datum[] + */ + private function populateResultDatumList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultDatum($item); + } + + return $items; + } + + private function populateResultResultSet(array $json): ResultSet + { + return new ResultSet([ + 'Rows' => !isset($json['Rows']) ? null : $this->populateResultRowList($json['Rows']), + 'ResultSetMetadata' => empty($json['ResultSetMetadata']) ? null : $this->populateResultResultSetMetadata($json['ResultSetMetadata']), + ]); + } + + private function populateResultResultSetMetadata(array $json): ResultSetMetadata + { + return new ResultSetMetadata([ + 'ColumnInfo' => !isset($json['ColumnInfo']) ? null : $this->populateResultColumnInfoList($json['ColumnInfo']), + ]); + } + + private function populateResultRow(array $json): Row + { + return new Row([ + 'Data' => !isset($json['Data']) ? null : $this->populateResultDatumList($json['Data']), + ]); + } + + /** + * @return Row[] + */ + private function populateResultRowList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultRow($item); + } + + return $items; + } +} diff --git a/src/Service/Athena/src/Result/GetSessionResponse.php b/src/Service/Athena/src/Result/GetSessionResponse.php new file mode 100644 index 000000000..856fc90b9 --- /dev/null +++ b/src/Service/Athena/src/Result/GetSessionResponse.php @@ -0,0 +1,198 @@ +initialize(); + + return $this->description; + } + + public function getEngineConfiguration(): ?EngineConfiguration + { + $this->initialize(); + + return $this->engineConfiguration; + } + + public function getEngineVersion(): ?string + { + $this->initialize(); + + return $this->engineVersion; + } + + public function getNotebookVersion(): ?string + { + $this->initialize(); + + return $this->notebookVersion; + } + + public function getSessionConfiguration(): ?SessionConfiguration + { + $this->initialize(); + + return $this->sessionConfiguration; + } + + public function getSessionId(): ?string + { + $this->initialize(); + + return $this->sessionId; + } + + public function getStatistics(): ?SessionStatistics + { + $this->initialize(); + + return $this->statistics; + } + + public function getStatus(): ?SessionStatus + { + $this->initialize(); + + return $this->status; + } + + public function getWorkGroup(): ?string + { + $this->initialize(); + + return $this->workGroup; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->sessionId = isset($data['SessionId']) ? (string) $data['SessionId'] : null; + $this->description = isset($data['Description']) ? (string) $data['Description'] : null; + $this->workGroup = isset($data['WorkGroup']) ? (string) $data['WorkGroup'] : null; + $this->engineVersion = isset($data['EngineVersion']) ? (string) $data['EngineVersion'] : null; + $this->engineConfiguration = empty($data['EngineConfiguration']) ? null : $this->populateResultEngineConfiguration($data['EngineConfiguration']); + $this->notebookVersion = isset($data['NotebookVersion']) ? (string) $data['NotebookVersion'] : null; + $this->sessionConfiguration = empty($data['SessionConfiguration']) ? null : $this->populateResultSessionConfiguration($data['SessionConfiguration']); + $this->status = empty($data['Status']) ? null : $this->populateResultSessionStatus($data['Status']); + $this->statistics = empty($data['Statistics']) ? null : $this->populateResultSessionStatistics($data['Statistics']); + } + + private function populateResultEncryptionConfiguration(array $json): EncryptionConfiguration + { + return new EncryptionConfiguration([ + 'EncryptionOption' => (string) $json['EncryptionOption'], + 'KmsKey' => isset($json['KmsKey']) ? (string) $json['KmsKey'] : null, + ]); + } + + private function populateResultEngineConfiguration(array $json): EngineConfiguration + { + return new EngineConfiguration([ + 'CoordinatorDpuSize' => isset($json['CoordinatorDpuSize']) ? (int) $json['CoordinatorDpuSize'] : null, + 'MaxConcurrentDpus' => (int) $json['MaxConcurrentDpus'], + 'DefaultExecutorDpuSize' => isset($json['DefaultExecutorDpuSize']) ? (int) $json['DefaultExecutorDpuSize'] : null, + 'AdditionalConfigs' => !isset($json['AdditionalConfigs']) ? null : $this->populateResultParametersMap($json['AdditionalConfigs']), + ]); + } + + /** + * @return array + */ + private function populateResultParametersMap(array $json): array + { + $items = []; + foreach ($json as $name => $value) { + $items[(string) $name] = (string) $value; + } + + return $items; + } + + private function populateResultSessionConfiguration(array $json): SessionConfiguration + { + return new SessionConfiguration([ + 'ExecutionRole' => isset($json['ExecutionRole']) ? (string) $json['ExecutionRole'] : null, + 'WorkingDirectory' => isset($json['WorkingDirectory']) ? (string) $json['WorkingDirectory'] : null, + 'IdleTimeoutSeconds' => isset($json['IdleTimeoutSeconds']) ? (string) $json['IdleTimeoutSeconds'] : null, + 'EncryptionConfiguration' => empty($json['EncryptionConfiguration']) ? null : $this->populateResultEncryptionConfiguration($json['EncryptionConfiguration']), + ]); + } + + private function populateResultSessionStatistics(array $json): SessionStatistics + { + return new SessionStatistics([ + 'DpuExecutionInMillis' => isset($json['DpuExecutionInMillis']) ? (string) $json['DpuExecutionInMillis'] : null, + ]); + } + + private function populateResultSessionStatus(array $json): SessionStatus + { + return new SessionStatus([ + 'StartDateTime' => (isset($json['StartDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['StartDateTime'])))) ? $d : null, + 'LastModifiedDateTime' => (isset($json['LastModifiedDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['LastModifiedDateTime'])))) ? $d : null, + 'EndDateTime' => (isset($json['EndDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['EndDateTime'])))) ? $d : null, + 'IdleSinceDateTime' => (isset($json['IdleSinceDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['IdleSinceDateTime'])))) ? $d : null, + 'State' => isset($json['State']) ? (string) $json['State'] : null, + 'StateChangeReason' => isset($json['StateChangeReason']) ? (string) $json['StateChangeReason'] : null, + ]); + } +} diff --git a/src/Service/Athena/src/Result/GetSessionStatusResponse.php b/src/Service/Athena/src/Result/GetSessionStatusResponse.php new file mode 100644 index 000000000..b127b8c4c --- /dev/null +++ b/src/Service/Athena/src/Result/GetSessionStatusResponse.php @@ -0,0 +1,54 @@ +initialize(); + + return $this->sessionId; + } + + public function getStatus(): ?SessionStatus + { + $this->initialize(); + + return $this->status; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->sessionId = isset($data['SessionId']) ? (string) $data['SessionId'] : null; + $this->status = empty($data['Status']) ? null : $this->populateResultSessionStatus($data['Status']); + } + + private function populateResultSessionStatus(array $json): SessionStatus + { + return new SessionStatus([ + 'StartDateTime' => (isset($json['StartDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['StartDateTime'])))) ? $d : null, + 'LastModifiedDateTime' => (isset($json['LastModifiedDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['LastModifiedDateTime'])))) ? $d : null, + 'EndDateTime' => (isset($json['EndDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['EndDateTime'])))) ? $d : null, + 'IdleSinceDateTime' => (isset($json['IdleSinceDateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['IdleSinceDateTime'])))) ? $d : null, + 'State' => isset($json['State']) ? (string) $json['State'] : null, + 'StateChangeReason' => isset($json['StateChangeReason']) ? (string) $json['StateChangeReason'] : null, + ]); + } +} diff --git a/src/Service/Athena/src/Result/GetTableMetadataOutput.php b/src/Service/Athena/src/Result/GetTableMetadataOutput.php new file mode 100644 index 000000000..74ca4f7cb --- /dev/null +++ b/src/Service/Athena/src/Result/GetTableMetadataOutput.php @@ -0,0 +1,78 @@ +initialize(); + + return $this->tableMetadata; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->tableMetadata = empty($data['TableMetadata']) ? null : $this->populateResultTableMetadata($data['TableMetadata']); + } + + private function populateResultColumn(array $json): Column + { + return new Column([ + 'Name' => (string) $json['Name'], + 'Type' => isset($json['Type']) ? (string) $json['Type'] : null, + 'Comment' => isset($json['Comment']) ? (string) $json['Comment'] : null, + ]); + } + + /** + * @return Column[] + */ + private function populateResultColumnList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultColumn($item); + } + + return $items; + } + + /** + * @return array + */ + private function populateResultParametersMap(array $json): array + { + $items = []; + foreach ($json as $name => $value) { + $items[(string) $name] = (string) $value; + } + + return $items; + } + + private function populateResultTableMetadata(array $json): TableMetadata + { + return new TableMetadata([ + 'Name' => (string) $json['Name'], + 'CreateTime' => (isset($json['CreateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['CreateTime'])))) ? $d : null, + 'LastAccessTime' => (isset($json['LastAccessTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['LastAccessTime'])))) ? $d : null, + 'TableType' => isset($json['TableType']) ? (string) $json['TableType'] : null, + 'Columns' => !isset($json['Columns']) ? null : $this->populateResultColumnList($json['Columns']), + 'PartitionKeys' => !isset($json['PartitionKeys']) ? null : $this->populateResultColumnList($json['PartitionKeys']), + 'Parameters' => !isset($json['Parameters']) ? null : $this->populateResultParametersMap($json['Parameters']), + ]); + } +} diff --git a/src/Service/Athena/src/Result/GetWorkGroupOutput.php b/src/Service/Athena/src/Result/GetWorkGroupOutput.php new file mode 100644 index 000000000..e46894996 --- /dev/null +++ b/src/Service/Athena/src/Result/GetWorkGroupOutput.php @@ -0,0 +1,102 @@ +initialize(); + + return $this->workGroup; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->workGroup = empty($data['WorkGroup']) ? null : $this->populateResultWorkGroup($data['WorkGroup']); + } + + private function populateResultAclConfiguration(array $json): AclConfiguration + { + return new AclConfiguration([ + 'S3AclOption' => (string) $json['S3AclOption'], + ]); + } + + private function populateResultCustomerContentEncryptionConfiguration(array $json): CustomerContentEncryptionConfiguration + { + return new CustomerContentEncryptionConfiguration([ + 'KmsKey' => (string) $json['KmsKey'], + ]); + } + + private function populateResultEncryptionConfiguration(array $json): EncryptionConfiguration + { + return new EncryptionConfiguration([ + 'EncryptionOption' => (string) $json['EncryptionOption'], + 'KmsKey' => isset($json['KmsKey']) ? (string) $json['KmsKey'] : null, + ]); + } + + private function populateResultEngineVersion(array $json): EngineVersion + { + return new EngineVersion([ + 'SelectedEngineVersion' => isset($json['SelectedEngineVersion']) ? (string) $json['SelectedEngineVersion'] : null, + 'EffectiveEngineVersion' => isset($json['EffectiveEngineVersion']) ? (string) $json['EffectiveEngineVersion'] : null, + ]); + } + + private function populateResultResultConfiguration(array $json): ResultConfiguration + { + return new ResultConfiguration([ + 'OutputLocation' => isset($json['OutputLocation']) ? (string) $json['OutputLocation'] : null, + 'EncryptionConfiguration' => empty($json['EncryptionConfiguration']) ? null : $this->populateResultEncryptionConfiguration($json['EncryptionConfiguration']), + 'ExpectedBucketOwner' => isset($json['ExpectedBucketOwner']) ? (string) $json['ExpectedBucketOwner'] : null, + 'AclConfiguration' => empty($json['AclConfiguration']) ? null : $this->populateResultAclConfiguration($json['AclConfiguration']), + ]); + } + + private function populateResultWorkGroup(array $json): WorkGroup + { + return new WorkGroup([ + 'Name' => (string) $json['Name'], + 'State' => isset($json['State']) ? (string) $json['State'] : null, + 'Configuration' => empty($json['Configuration']) ? null : $this->populateResultWorkGroupConfiguration($json['Configuration']), + 'Description' => isset($json['Description']) ? (string) $json['Description'] : null, + 'CreationTime' => (isset($json['CreationTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['CreationTime'])))) ? $d : null, + ]); + } + + private function populateResultWorkGroupConfiguration(array $json): WorkGroupConfiguration + { + return new WorkGroupConfiguration([ + 'ResultConfiguration' => empty($json['ResultConfiguration']) ? null : $this->populateResultResultConfiguration($json['ResultConfiguration']), + 'EnforceWorkGroupConfiguration' => isset($json['EnforceWorkGroupConfiguration']) ? filter_var($json['EnforceWorkGroupConfiguration'], \FILTER_VALIDATE_BOOLEAN) : null, + 'PublishCloudWatchMetricsEnabled' => isset($json['PublishCloudWatchMetricsEnabled']) ? filter_var($json['PublishCloudWatchMetricsEnabled'], \FILTER_VALIDATE_BOOLEAN) : null, + 'BytesScannedCutoffPerQuery' => isset($json['BytesScannedCutoffPerQuery']) ? (string) $json['BytesScannedCutoffPerQuery'] : null, + 'RequesterPaysEnabled' => isset($json['RequesterPaysEnabled']) ? filter_var($json['RequesterPaysEnabled'], \FILTER_VALIDATE_BOOLEAN) : null, + 'EngineVersion' => empty($json['EngineVersion']) ? null : $this->populateResultEngineVersion($json['EngineVersion']), + 'AdditionalConfiguration' => isset($json['AdditionalConfiguration']) ? (string) $json['AdditionalConfiguration'] : null, + 'ExecutionRole' => isset($json['ExecutionRole']) ? (string) $json['ExecutionRole'] : null, + 'CustomerContentEncryptionConfiguration' => empty($json['CustomerContentEncryptionConfiguration']) ? null : $this->populateResultCustomerContentEncryptionConfiguration($json['CustomerContentEncryptionConfiguration']), + 'EnableMinimumEncryptionConfiguration' => isset($json['EnableMinimumEncryptionConfiguration']) ? filter_var($json['EnableMinimumEncryptionConfiguration'], \FILTER_VALIDATE_BOOLEAN) : null, + ]); + } +} diff --git a/src/Service/Athena/src/Result/ListDatabasesOutput.php b/src/Service/Athena/src/Result/ListDatabasesOutput.php new file mode 100644 index 000000000..0140e017f --- /dev/null +++ b/src/Service/Athena/src/Result/ListDatabasesOutput.php @@ -0,0 +1,131 @@ + + */ +class ListDatabasesOutput extends Result implements \IteratorAggregate +{ + /** + * A list of databases from a data catalog. + */ + private $databaseList; + + /** + * A token generated by the Athena service that specifies where to continue pagination if a previous request was + * truncated. To obtain the next set of pages, pass in the NextToken from the response object of the previous page call. + */ + private $nextToken; + + /** + * @param bool $currentPageOnly When true, iterates over items of the current page. Otherwise also fetch items in the next pages. + * + * @return iterable + */ + public function getDatabaseList(bool $currentPageOnly = false): iterable + { + if ($currentPageOnly) { + $this->initialize(); + yield from $this->databaseList; + + return; + } + + $client = $this->awsClient; + if (!$client instanceof AthenaClient) { + throw new InvalidArgument('missing client injected in paginated result'); + } + if (!$this->input instanceof ListDatabasesInput) { + throw new InvalidArgument('missing last request injected in paginated result'); + } + $input = clone $this->input; + $page = $this; + while (true) { + $page->initialize(); + if ($page->nextToken) { + $input->setNextToken($page->nextToken); + + $this->registerPrefetch($nextPage = $client->listDatabases($input)); + } else { + $nextPage = null; + } + + yield from $page->databaseList; + + if (null === $nextPage) { + break; + } + + $this->unregisterPrefetch($nextPage); + $page = $nextPage; + } + } + + /** + * Iterates over DatabaseList. + * + * @return \Traversable + */ + public function getIterator(): \Traversable + { + yield from $this->getDatabaseList(); + } + + public function getNextToken(): ?string + { + $this->initialize(); + + return $this->nextToken; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->databaseList = empty($data['DatabaseList']) ? [] : $this->populateResultDatabaseList($data['DatabaseList']); + $this->nextToken = isset($data['NextToken']) ? (string) $data['NextToken'] : null; + } + + private function populateResultDatabase(array $json): Database + { + return new Database([ + 'Name' => (string) $json['Name'], + 'Description' => isset($json['Description']) ? (string) $json['Description'] : null, + 'Parameters' => !isset($json['Parameters']) ? null : $this->populateResultParametersMap($json['Parameters']), + ]); + } + + /** + * @return Database[] + */ + private function populateResultDatabaseList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultDatabase($item); + } + + return $items; + } + + /** + * @return array + */ + private function populateResultParametersMap(array $json): array + { + $items = []; + foreach ($json as $name => $value) { + $items[(string) $name] = (string) $value; + } + + return $items; + } +} diff --git a/src/Service/Athena/src/Result/ListNamedQueriesOutput.php b/src/Service/Athena/src/Result/ListNamedQueriesOutput.php new file mode 100644 index 000000000..9d023c9d0 --- /dev/null +++ b/src/Service/Athena/src/Result/ListNamedQueriesOutput.php @@ -0,0 +1,112 @@ + + */ +class ListNamedQueriesOutput extends Result implements \IteratorAggregate +{ + /** + * The list of unique query IDs. + */ + private $namedQueryIds; + + /** + * A token generated by the Athena service that specifies where to continue pagination if a previous request was + * truncated. To obtain the next set of pages, pass in the `NextToken` from the response object of the previous page + * call. + */ + private $nextToken; + + /** + * Iterates over NamedQueryIds. + * + * @return \Traversable + */ + public function getIterator(): \Traversable + { + yield from $this->getNamedQueryIds(); + } + + /** + * @param bool $currentPageOnly When true, iterates over items of the current page. Otherwise also fetch items in the next pages. + * + * @return iterable + */ + public function getNamedQueryIds(bool $currentPageOnly = false): iterable + { + if ($currentPageOnly) { + $this->initialize(); + yield from $this->namedQueryIds; + + return; + } + + $client = $this->awsClient; + if (!$client instanceof AthenaClient) { + throw new InvalidArgument('missing client injected in paginated result'); + } + if (!$this->input instanceof ListNamedQueriesInput) { + throw new InvalidArgument('missing last request injected in paginated result'); + } + $input = clone $this->input; + $page = $this; + while (true) { + $page->initialize(); + if ($page->nextToken) { + $input->setNextToken($page->nextToken); + + $this->registerPrefetch($nextPage = $client->listNamedQueries($input)); + } else { + $nextPage = null; + } + + yield from $page->namedQueryIds; + + if (null === $nextPage) { + break; + } + + $this->unregisterPrefetch($nextPage); + $page = $nextPage; + } + } + + public function getNextToken(): ?string + { + $this->initialize(); + + return $this->nextToken; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->namedQueryIds = empty($data['NamedQueryIds']) ? [] : $this->populateResultNamedQueryIdList($data['NamedQueryIds']); + $this->nextToken = isset($data['NextToken']) ? (string) $data['NextToken'] : null; + } + + /** + * @return string[] + */ + private function populateResultNamedQueryIdList(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } +} diff --git a/src/Service/Athena/src/Result/ListQueryExecutionsOutput.php b/src/Service/Athena/src/Result/ListQueryExecutionsOutput.php new file mode 100644 index 000000000..db453999b --- /dev/null +++ b/src/Service/Athena/src/Result/ListQueryExecutionsOutput.php @@ -0,0 +1,110 @@ + + */ +class ListQueryExecutionsOutput extends Result implements \IteratorAggregate +{ + /** + * The unique IDs of each query execution as an array of strings. + */ + private $queryExecutionIds; + + /** + * A token to be used by the next request if this request is truncated. + */ + private $nextToken; + + /** + * Iterates over QueryExecutionIds. + * + * @return \Traversable + */ + public function getIterator(): \Traversable + { + yield from $this->getQueryExecutionIds(); + } + + public function getNextToken(): ?string + { + $this->initialize(); + + return $this->nextToken; + } + + /** + * @param bool $currentPageOnly When true, iterates over items of the current page. Otherwise also fetch items in the next pages. + * + * @return iterable + */ + public function getQueryExecutionIds(bool $currentPageOnly = false): iterable + { + if ($currentPageOnly) { + $this->initialize(); + yield from $this->queryExecutionIds; + + return; + } + + $client = $this->awsClient; + if (!$client instanceof AthenaClient) { + throw new InvalidArgument('missing client injected in paginated result'); + } + if (!$this->input instanceof ListQueryExecutionsInput) { + throw new InvalidArgument('missing last request injected in paginated result'); + } + $input = clone $this->input; + $page = $this; + while (true) { + $page->initialize(); + if ($page->nextToken) { + $input->setNextToken($page->nextToken); + + $this->registerPrefetch($nextPage = $client->listQueryExecutions($input)); + } else { + $nextPage = null; + } + + yield from $page->queryExecutionIds; + + if (null === $nextPage) { + break; + } + + $this->unregisterPrefetch($nextPage); + $page = $nextPage; + } + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->queryExecutionIds = empty($data['QueryExecutionIds']) ? [] : $this->populateResultQueryExecutionIdList($data['QueryExecutionIds']); + $this->nextToken = isset($data['NextToken']) ? (string) $data['NextToken'] : null; + } + + /** + * @return string[] + */ + private function populateResultQueryExecutionIdList(array $json): array + { + $items = []; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } + } + + return $items; + } +} diff --git a/src/Service/Athena/src/Result/ListTableMetadataOutput.php b/src/Service/Athena/src/Result/ListTableMetadataOutput.php new file mode 100644 index 000000000..f3a2e69b6 --- /dev/null +++ b/src/Service/Athena/src/Result/ListTableMetadataOutput.php @@ -0,0 +1,158 @@ + + */ +class ListTableMetadataOutput extends Result implements \IteratorAggregate +{ + /** + * A list of table metadata. + */ + private $tableMetadataList; + + /** + * A token generated by the Athena service that specifies where to continue pagination if a previous request was + * truncated. To obtain the next set of pages, pass in the NextToken from the response object of the previous page call. + */ + private $nextToken; + + /** + * Iterates over TableMetadataList. + * + * @return \Traversable + */ + public function getIterator(): \Traversable + { + yield from $this->getTableMetadataList(); + } + + public function getNextToken(): ?string + { + $this->initialize(); + + return $this->nextToken; + } + + /** + * @param bool $currentPageOnly When true, iterates over items of the current page. Otherwise also fetch items in the next pages. + * + * @return iterable + */ + public function getTableMetadataList(bool $currentPageOnly = false): iterable + { + if ($currentPageOnly) { + $this->initialize(); + yield from $this->tableMetadataList; + + return; + } + + $client = $this->awsClient; + if (!$client instanceof AthenaClient) { + throw new InvalidArgument('missing client injected in paginated result'); + } + if (!$this->input instanceof ListTableMetadataInput) { + throw new InvalidArgument('missing last request injected in paginated result'); + } + $input = clone $this->input; + $page = $this; + while (true) { + $page->initialize(); + if ($page->nextToken) { + $input->setNextToken($page->nextToken); + + $this->registerPrefetch($nextPage = $client->listTableMetadata($input)); + } else { + $nextPage = null; + } + + yield from $page->tableMetadataList; + + if (null === $nextPage) { + break; + } + + $this->unregisterPrefetch($nextPage); + $page = $nextPage; + } + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->tableMetadataList = empty($data['TableMetadataList']) ? [] : $this->populateResultTableMetadataList($data['TableMetadataList']); + $this->nextToken = isset($data['NextToken']) ? (string) $data['NextToken'] : null; + } + + private function populateResultColumn(array $json): Column + { + return new Column([ + 'Name' => (string) $json['Name'], + 'Type' => isset($json['Type']) ? (string) $json['Type'] : null, + 'Comment' => isset($json['Comment']) ? (string) $json['Comment'] : null, + ]); + } + + /** + * @return Column[] + */ + private function populateResultColumnList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultColumn($item); + } + + return $items; + } + + /** + * @return array + */ + private function populateResultParametersMap(array $json): array + { + $items = []; + foreach ($json as $name => $value) { + $items[(string) $name] = (string) $value; + } + + return $items; + } + + private function populateResultTableMetadata(array $json): TableMetadata + { + return new TableMetadata([ + 'Name' => (string) $json['Name'], + 'CreateTime' => (isset($json['CreateTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['CreateTime'])))) ? $d : null, + 'LastAccessTime' => (isset($json['LastAccessTime']) && ($d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $json['LastAccessTime'])))) ? $d : null, + 'TableType' => isset($json['TableType']) ? (string) $json['TableType'] : null, + 'Columns' => !isset($json['Columns']) ? null : $this->populateResultColumnList($json['Columns']), + 'PartitionKeys' => !isset($json['PartitionKeys']) ? null : $this->populateResultColumnList($json['PartitionKeys']), + 'Parameters' => !isset($json['Parameters']) ? null : $this->populateResultParametersMap($json['Parameters']), + ]); + } + + /** + * @return TableMetadata[] + */ + private function populateResultTableMetadataList(array $json): array + { + $items = []; + foreach ($json as $item) { + $items[] = $this->populateResultTableMetadata($item); + } + + return $items; + } +} diff --git a/src/Service/Athena/src/Result/StartCalculationExecutionResponse.php b/src/Service/Athena/src/Result/StartCalculationExecutionResponse.php new file mode 100644 index 000000000..09cacd268 --- /dev/null +++ b/src/Service/Athena/src/Result/StartCalculationExecutionResponse.php @@ -0,0 +1,45 @@ +initialize(); + + return $this->calculationExecutionId; + } + + /** + * @return CalculationExecutionState::*|null + */ + public function getState(): ?string + { + $this->initialize(); + + return $this->state; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->calculationExecutionId = isset($data['CalculationExecutionId']) ? (string) $data['CalculationExecutionId'] : null; + $this->state = isset($data['State']) ? (string) $data['State'] : null; + } +} diff --git a/src/Service/Athena/src/Result/StartQueryExecutionOutput.php b/src/Service/Athena/src/Result/StartQueryExecutionOutput.php new file mode 100644 index 000000000..0d459c979 --- /dev/null +++ b/src/Service/Athena/src/Result/StartQueryExecutionOutput.php @@ -0,0 +1,28 @@ +initialize(); + + return $this->queryExecutionId; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->queryExecutionId = isset($data['QueryExecutionId']) ? (string) $data['QueryExecutionId'] : null; + } +} diff --git a/src/Service/Athena/src/Result/StartSessionResponse.php b/src/Service/Athena/src/Result/StartSessionResponse.php new file mode 100644 index 000000000..103115125 --- /dev/null +++ b/src/Service/Athena/src/Result/StartSessionResponse.php @@ -0,0 +1,45 @@ +initialize(); + + return $this->sessionId; + } + + /** + * @return SessionState::*|null + */ + public function getState(): ?string + { + $this->initialize(); + + return $this->state; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->sessionId = isset($data['SessionId']) ? (string) $data['SessionId'] : null; + $this->state = isset($data['State']) ? (string) $data['State'] : null; + } +} diff --git a/src/Service/Athena/src/Result/StopCalculationExecutionResponse.php b/src/Service/Athena/src/Result/StopCalculationExecutionResponse.php new file mode 100644 index 000000000..40bd4007a --- /dev/null +++ b/src/Service/Athena/src/Result/StopCalculationExecutionResponse.php @@ -0,0 +1,32 @@ +initialize(); + + return $this->state; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->state = isset($data['State']) ? (string) $data['State'] : null; + } +} diff --git a/src/Service/Athena/src/Result/StopQueryExecutionOutput.php b/src/Service/Athena/src/Result/StopQueryExecutionOutput.php new file mode 100644 index 000000000..e1519dcd4 --- /dev/null +++ b/src/Service/Athena/src/Result/StopQueryExecutionOutput.php @@ -0,0 +1,9 @@ +initialize(); + + return $this->state; + } + + protected function populateResult(Response $response): void + { + $data = $response->toArray(); + + $this->state = isset($data['State']) ? (string) $data['State'] : null; + } +} diff --git a/src/Service/Athena/src/ValueObject/AclConfiguration.php b/src/Service/Athena/src/ValueObject/AclConfiguration.php new file mode 100644 index 000000000..df1d59386 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/AclConfiguration.php @@ -0,0 +1,68 @@ +s3AclOption = $input['S3AclOption'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return S3AclOption::* + */ + public function getS3AclOption(): string + { + return $this->s3AclOption; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null === $v = $this->s3AclOption) { + throw new InvalidArgument(sprintf('Missing parameter "S3AclOption" for "%s". The value cannot be null.', __CLASS__)); + } + if (!S3AclOption::exists($v)) { + throw new InvalidArgument(sprintf('Invalid parameter "S3AclOption" for "%s". The value "%s" is not a valid "S3AclOption".', __CLASS__, $v)); + } + $payload['S3AclOption'] = $v; + + return $payload; + } +} diff --git a/src/Service/Athena/src/ValueObject/AthenaError.php b/src/Service/Athena/src/ValueObject/AthenaError.php new file mode 100644 index 000000000..f80f312f3 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/AthenaError.php @@ -0,0 +1,74 @@ +errorCategory = $input['ErrorCategory'] ?? null; + $this->errorType = $input['ErrorType'] ?? null; + $this->retryable = $input['Retryable'] ?? null; + $this->errorMessage = $input['ErrorMessage'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getErrorCategory(): ?int + { + return $this->errorCategory; + } + + public function getErrorMessage(): ?string + { + return $this->errorMessage; + } + + public function getErrorType(): ?int + { + return $this->errorType; + } + + public function getRetryable(): ?bool + { + return $this->retryable; + } +} diff --git a/src/Service/Athena/src/ValueObject/CalculationConfiguration.php b/src/Service/Athena/src/ValueObject/CalculationConfiguration.php new file mode 100644 index 000000000..91e700483 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/CalculationConfiguration.php @@ -0,0 +1,47 @@ +codeBlock = $input['CodeBlock'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCodeBlock(): ?string + { + return $this->codeBlock; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->codeBlock) { + $payload['CodeBlock'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/ValueObject/CalculationResult.php b/src/Service/Athena/src/ValueObject/CalculationResult.php new file mode 100644 index 000000000..a193e3500 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/CalculationResult.php @@ -0,0 +1,70 @@ +stdOutS3Uri = $input['StdOutS3Uri'] ?? null; + $this->stdErrorS3Uri = $input['StdErrorS3Uri'] ?? null; + $this->resultS3Uri = $input['ResultS3Uri'] ?? null; + $this->resultType = $input['ResultType'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getResultS3Uri(): ?string + { + return $this->resultS3Uri; + } + + public function getResultType(): ?string + { + return $this->resultType; + } + + public function getStdErrorS3Uri(): ?string + { + return $this->stdErrorS3Uri; + } + + public function getStdOutS3Uri(): ?string + { + return $this->stdOutS3Uri; + } +} diff --git a/src/Service/Athena/src/ValueObject/CalculationStatistics.php b/src/Service/Athena/src/ValueObject/CalculationStatistics.php new file mode 100644 index 000000000..9369b253c --- /dev/null +++ b/src/Service/Athena/src/ValueObject/CalculationStatistics.php @@ -0,0 +1,47 @@ +dpuExecutionInMillis = $input['DpuExecutionInMillis'] ?? null; + $this->progress = $input['Progress'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getDpuExecutionInMillis(): ?string + { + return $this->dpuExecutionInMillis; + } + + public function getProgress(): ?string + { + return $this->progress; + } +} diff --git a/src/Service/Athena/src/ValueObject/CalculationStatus.php b/src/Service/Athena/src/ValueObject/CalculationStatus.php new file mode 100644 index 000000000..0fb96a50f --- /dev/null +++ b/src/Service/Athena/src/ValueObject/CalculationStatus.php @@ -0,0 +1,76 @@ +submissionDateTime = $input['SubmissionDateTime'] ?? null; + $this->completionDateTime = $input['CompletionDateTime'] ?? null; + $this->state = $input['State'] ?? null; + $this->stateChangeReason = $input['StateChangeReason'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCompletionDateTime(): ?\DateTimeImmutable + { + return $this->completionDateTime; + } + + /** + * @return CalculationExecutionState::*|null + */ + public function getState(): ?string + { + return $this->state; + } + + public function getStateChangeReason(): ?string + { + return $this->stateChangeReason; + } + + public function getSubmissionDateTime(): ?\DateTimeImmutable + { + return $this->submissionDateTime; + } +} diff --git a/src/Service/Athena/src/ValueObject/Column.php b/src/Service/Athena/src/ValueObject/Column.php new file mode 100644 index 000000000..0f6c94bae --- /dev/null +++ b/src/Service/Athena/src/ValueObject/Column.php @@ -0,0 +1,58 @@ +name = $input['Name'] ?? null; + $this->type = $input['Type'] ?? null; + $this->comment = $input['Comment'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getComment(): ?string + { + return $this->comment; + } + + public function getName(): string + { + return $this->name; + } + + public function getType(): ?string + { + return $this->type; + } +} diff --git a/src/Service/Athena/src/ValueObject/ColumnInfo.php b/src/Service/Athena/src/ValueObject/ColumnInfo.php new file mode 100644 index 000000000..6746b3279 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/ColumnInfo.php @@ -0,0 +1,148 @@ +catalogName = $input['CatalogName'] ?? null; + $this->schemaName = $input['SchemaName'] ?? null; + $this->tableName = $input['TableName'] ?? null; + $this->name = $input['Name'] ?? null; + $this->label = $input['Label'] ?? null; + $this->type = $input['Type'] ?? null; + $this->precision = $input['Precision'] ?? null; + $this->scale = $input['Scale'] ?? null; + $this->nullable = $input['Nullable'] ?? null; + $this->caseSensitive = $input['CaseSensitive'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCaseSensitive(): ?bool + { + return $this->caseSensitive; + } + + public function getCatalogName(): ?string + { + return $this->catalogName; + } + + public function getLabel(): ?string + { + return $this->label; + } + + public function getName(): string + { + return $this->name; + } + + /** + * @return ColumnNullable::*|null + */ + public function getNullable(): ?string + { + return $this->nullable; + } + + public function getPrecision(): ?int + { + return $this->precision; + } + + public function getScale(): ?int + { + return $this->scale; + } + + public function getSchemaName(): ?string + { + return $this->schemaName; + } + + public function getTableName(): ?string + { + return $this->tableName; + } + + public function getType(): string + { + return $this->type; + } +} diff --git a/src/Service/Athena/src/ValueObject/CustomerContentEncryptionConfiguration.php b/src/Service/Athena/src/ValueObject/CustomerContentEncryptionConfiguration.php new file mode 100644 index 000000000..e23d1709b --- /dev/null +++ b/src/Service/Athena/src/ValueObject/CustomerContentEncryptionConfiguration.php @@ -0,0 +1,34 @@ +kmsKey = $input['KmsKey'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getKmsKey(): string + { + return $this->kmsKey; + } +} diff --git a/src/Service/Athena/src/ValueObject/DataCatalog.php b/src/Service/Athena/src/ValueObject/DataCatalog.php new file mode 100644 index 000000000..c534f0181 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/DataCatalog.php @@ -0,0 +1,82 @@ +, + * } $input + */ + public function __construct(array $input) + { + $this->name = $input['Name'] ?? null; + $this->description = $input['Description'] ?? null; + $this->type = $input['Type'] ?? null; + $this->parameters = $input['Parameters'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function getName(): string + { + return $this->name; + } + + /** + * @return array + */ + public function getParameters(): array + { + return $this->parameters ?? []; + } + + /** + * @return DataCatalogType::* + */ + public function getType(): string + { + return $this->type; + } +} diff --git a/src/Service/Athena/src/ValueObject/Database.php b/src/Service/Athena/src/ValueObject/Database.php new file mode 100644 index 000000000..835783e90 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/Database.php @@ -0,0 +1,61 @@ +, + * } $input + */ + public function __construct(array $input) + { + $this->name = $input['Name'] ?? null; + $this->description = $input['Description'] ?? null; + $this->parameters = $input['Parameters'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function getName(): string + { + return $this->name; + } + + /** + * @return array + */ + public function getParameters(): array + { + return $this->parameters ?? []; + } +} diff --git a/src/Service/Athena/src/ValueObject/Datum.php b/src/Service/Athena/src/ValueObject/Datum.php new file mode 100644 index 000000000..966948c1d --- /dev/null +++ b/src/Service/Athena/src/ValueObject/Datum.php @@ -0,0 +1,34 @@ +varCharValue = $input['VarCharValue'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getVarCharValue(): ?string + { + return $this->varCharValue; + } +} diff --git a/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php b/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php new file mode 100644 index 000000000..8961c7261 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php @@ -0,0 +1,79 @@ +encryptionOption = $input['EncryptionOption'] ?? null; + $this->kmsKey = $input['KmsKey'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return EncryptionOption::* + */ + public function getEncryptionOption(): string + { + return $this->encryptionOption; + } + + public function getKmsKey(): ?string + { + return $this->kmsKey; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null === $v = $this->encryptionOption) { + throw new InvalidArgument(sprintf('Missing parameter "EncryptionOption" for "%s". The value cannot be null.', __CLASS__)); + } + if (!EncryptionOption::exists($v)) { + throw new InvalidArgument(sprintf('Invalid parameter "EncryptionOption" for "%s". The value "%s" is not a valid "EncryptionOption".', __CLASS__, $v)); + } + $payload['EncryptionOption'] = $v; + if (null !== $v = $this->kmsKey) { + $payload['KmsKey'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/ValueObject/EngineConfiguration.php b/src/Service/Athena/src/ValueObject/EngineConfiguration.php new file mode 100644 index 000000000..5c160bfce --- /dev/null +++ b/src/Service/Athena/src/ValueObject/EngineConfiguration.php @@ -0,0 +1,110 @@ +, + * } $input + */ + public function __construct(array $input) + { + $this->coordinatorDpuSize = $input['CoordinatorDpuSize'] ?? null; + $this->maxConcurrentDpus = $input['MaxConcurrentDpus'] ?? null; + $this->defaultExecutorDpuSize = $input['DefaultExecutorDpuSize'] ?? null; + $this->additionalConfigs = $input['AdditionalConfigs'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return array + */ + public function getAdditionalConfigs(): array + { + return $this->additionalConfigs ?? []; + } + + public function getCoordinatorDpuSize(): ?int + { + return $this->coordinatorDpuSize; + } + + public function getDefaultExecutorDpuSize(): ?int + { + return $this->defaultExecutorDpuSize; + } + + public function getMaxConcurrentDpus(): int + { + return $this->maxConcurrentDpus; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->coordinatorDpuSize) { + $payload['CoordinatorDpuSize'] = $v; + } + if (null === $v = $this->maxConcurrentDpus) { + throw new InvalidArgument(sprintf('Missing parameter "MaxConcurrentDpus" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['MaxConcurrentDpus'] = $v; + if (null !== $v = $this->defaultExecutorDpuSize) { + $payload['DefaultExecutorDpuSize'] = $v; + } + if (null !== $v = $this->additionalConfigs) { + if (empty($v)) { + $payload['AdditionalConfigs'] = new \stdClass(); + } else { + $payload['AdditionalConfigs'] = []; + foreach ($v as $name => $mv) { + $payload['AdditionalConfigs'][$name] = $mv; + } + } + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/ValueObject/EngineVersion.php b/src/Service/Athena/src/ValueObject/EngineVersion.php new file mode 100644 index 000000000..8bff5e851 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/EngineVersion.php @@ -0,0 +1,50 @@ +selectedEngineVersion = $input['SelectedEngineVersion'] ?? null; + $this->effectiveEngineVersion = $input['EffectiveEngineVersion'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getEffectiveEngineVersion(): ?string + { + return $this->effectiveEngineVersion; + } + + public function getSelectedEngineVersion(): ?string + { + return $this->selectedEngineVersion; + } +} diff --git a/src/Service/Athena/src/ValueObject/NamedQuery.php b/src/Service/Athena/src/ValueObject/NamedQuery.php new file mode 100644 index 000000000..7d53826a4 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/NamedQuery.php @@ -0,0 +1,94 @@ +name = $input['Name'] ?? null; + $this->description = $input['Description'] ?? null; + $this->database = $input['Database'] ?? null; + $this->queryString = $input['QueryString'] ?? null; + $this->namedQueryId = $input['NamedQueryId'] ?? null; + $this->workGroup = $input['WorkGroup'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getDatabase(): string + { + return $this->database; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function getName(): string + { + return $this->name; + } + + public function getNamedQueryId(): ?string + { + return $this->namedQueryId; + } + + public function getQueryString(): string + { + return $this->queryString; + } + + public function getWorkGroup(): ?string + { + return $this->workGroup; + } +} diff --git a/src/Service/Athena/src/ValueObject/QueryExecution.php b/src/Service/Athena/src/ValueObject/QueryExecution.php new file mode 100644 index 000000000..684e6a451 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/QueryExecution.php @@ -0,0 +1,181 @@ +queryExecutionId = $input['QueryExecutionId'] ?? null; + $this->query = $input['Query'] ?? null; + $this->statementType = $input['StatementType'] ?? null; + $this->resultConfiguration = isset($input['ResultConfiguration']) ? ResultConfiguration::create($input['ResultConfiguration']) : null; + $this->resultReuseConfiguration = isset($input['ResultReuseConfiguration']) ? ResultReuseConfiguration::create($input['ResultReuseConfiguration']) : null; + $this->queryExecutionContext = isset($input['QueryExecutionContext']) ? QueryExecutionContext::create($input['QueryExecutionContext']) : null; + $this->status = isset($input['Status']) ? QueryExecutionStatus::create($input['Status']) : null; + $this->statistics = isset($input['Statistics']) ? QueryExecutionStatistics::create($input['Statistics']) : null; + $this->workGroup = $input['WorkGroup'] ?? null; + $this->engineVersion = isset($input['EngineVersion']) ? EngineVersion::create($input['EngineVersion']) : null; + $this->executionParameters = $input['ExecutionParameters'] ?? null; + $this->substatementType = $input['SubstatementType'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getEngineVersion(): ?EngineVersion + { + return $this->engineVersion; + } + + /** + * @return string[] + */ + public function getExecutionParameters(): array + { + return $this->executionParameters ?? []; + } + + public function getQuery(): ?string + { + return $this->query; + } + + public function getQueryExecutionContext(): ?QueryExecutionContext + { + return $this->queryExecutionContext; + } + + public function getQueryExecutionId(): ?string + { + return $this->queryExecutionId; + } + + public function getResultConfiguration(): ?ResultConfiguration + { + return $this->resultConfiguration; + } + + public function getResultReuseConfiguration(): ?ResultReuseConfiguration + { + return $this->resultReuseConfiguration; + } + + /** + * @return StatementType::*|null + */ + public function getStatementType(): ?string + { + return $this->statementType; + } + + public function getStatistics(): ?QueryExecutionStatistics + { + return $this->statistics; + } + + public function getStatus(): ?QueryExecutionStatus + { + return $this->status; + } + + public function getSubstatementType(): ?string + { + return $this->substatementType; + } + + public function getWorkGroup(): ?string + { + return $this->workGroup; + } +} diff --git a/src/Service/Athena/src/ValueObject/QueryExecutionContext.php b/src/Service/Athena/src/ValueObject/QueryExecutionContext.php new file mode 100644 index 000000000..59fe3b9a3 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/QueryExecutionContext.php @@ -0,0 +1,62 @@ +database = $input['Database'] ?? null; + $this->catalog = $input['Catalog'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getCatalog(): ?string + { + return $this->catalog; + } + + public function getDatabase(): ?string + { + return $this->database; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->database) { + $payload['Database'] = $v; + } + if (null !== $v = $this->catalog) { + $payload['Catalog'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/ValueObject/QueryExecutionStatistics.php b/src/Service/Athena/src/ValueObject/QueryExecutionStatistics.php new file mode 100644 index 000000000..4606d7b20 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/QueryExecutionStatistics.php @@ -0,0 +1,129 @@ +engineExecutionTimeInMillis = $input['EngineExecutionTimeInMillis'] ?? null; + $this->dataScannedInBytes = $input['DataScannedInBytes'] ?? null; + $this->dataManifestLocation = $input['DataManifestLocation'] ?? null; + $this->totalExecutionTimeInMillis = $input['TotalExecutionTimeInMillis'] ?? null; + $this->queryQueueTimeInMillis = $input['QueryQueueTimeInMillis'] ?? null; + $this->queryPlanningTimeInMillis = $input['QueryPlanningTimeInMillis'] ?? null; + $this->serviceProcessingTimeInMillis = $input['ServiceProcessingTimeInMillis'] ?? null; + $this->resultReuseInformation = isset($input['ResultReuseInformation']) ? ResultReuseInformation::create($input['ResultReuseInformation']) : null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getDataManifestLocation(): ?string + { + return $this->dataManifestLocation; + } + + public function getDataScannedInBytes(): ?string + { + return $this->dataScannedInBytes; + } + + public function getEngineExecutionTimeInMillis(): ?string + { + return $this->engineExecutionTimeInMillis; + } + + public function getQueryPlanningTimeInMillis(): ?string + { + return $this->queryPlanningTimeInMillis; + } + + public function getQueryQueueTimeInMillis(): ?string + { + return $this->queryQueueTimeInMillis; + } + + public function getResultReuseInformation(): ?ResultReuseInformation + { + return $this->resultReuseInformation; + } + + public function getServiceProcessingTimeInMillis(): ?string + { + return $this->serviceProcessingTimeInMillis; + } + + public function getTotalExecutionTimeInMillis(): ?string + { + return $this->totalExecutionTimeInMillis; + } +} diff --git a/src/Service/Athena/src/ValueObject/QueryExecutionStatus.php b/src/Service/Athena/src/ValueObject/QueryExecutionStatus.php new file mode 100644 index 000000000..9350543cf --- /dev/null +++ b/src/Service/Athena/src/ValueObject/QueryExecutionStatus.php @@ -0,0 +1,90 @@ +state = $input['State'] ?? null; + $this->stateChangeReason = $input['StateChangeReason'] ?? null; + $this->submissionDateTime = $input['SubmissionDateTime'] ?? null; + $this->completionDateTime = $input['CompletionDateTime'] ?? null; + $this->athenaError = isset($input['AthenaError']) ? AthenaError::create($input['AthenaError']) : null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getAthenaError(): ?AthenaError + { + return $this->athenaError; + } + + public function getCompletionDateTime(): ?\DateTimeImmutable + { + return $this->completionDateTime; + } + + /** + * @return QueryExecutionState::*|null + */ + public function getState(): ?string + { + return $this->state; + } + + public function getStateChangeReason(): ?string + { + return $this->stateChangeReason; + } + + public function getSubmissionDateTime(): ?\DateTimeImmutable + { + return $this->submissionDateTime; + } +} diff --git a/src/Service/Athena/src/ValueObject/ResultConfiguration.php b/src/Service/Athena/src/ValueObject/ResultConfiguration.php new file mode 100644 index 000000000..6f350f1bd --- /dev/null +++ b/src/Service/Athena/src/ValueObject/ResultConfiguration.php @@ -0,0 +1,117 @@ +outputLocation = $input['OutputLocation'] ?? null; + $this->encryptionConfiguration = isset($input['EncryptionConfiguration']) ? EncryptionConfiguration::create($input['EncryptionConfiguration']) : null; + $this->expectedBucketOwner = $input['ExpectedBucketOwner'] ?? null; + $this->aclConfiguration = isset($input['AclConfiguration']) ? AclConfiguration::create($input['AclConfiguration']) : null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getAclConfiguration(): ?AclConfiguration + { + return $this->aclConfiguration; + } + + public function getEncryptionConfiguration(): ?EncryptionConfiguration + { + return $this->encryptionConfiguration; + } + + public function getExpectedBucketOwner(): ?string + { + return $this->expectedBucketOwner; + } + + public function getOutputLocation(): ?string + { + return $this->outputLocation; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->outputLocation) { + $payload['OutputLocation'] = $v; + } + if (null !== $v = $this->encryptionConfiguration) { + $payload['EncryptionConfiguration'] = $v->requestBody(); + } + if (null !== $v = $this->expectedBucketOwner) { + $payload['ExpectedBucketOwner'] = $v; + } + if (null !== $v = $this->aclConfiguration) { + $payload['AclConfiguration'] = $v->requestBody(); + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php b/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php new file mode 100644 index 000000000..bb627ec3a --- /dev/null +++ b/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php @@ -0,0 +1,66 @@ +enabled = $input['Enabled'] ?? null; + $this->maxAgeInMinutes = $input['MaxAgeInMinutes'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getEnabled(): bool + { + return $this->enabled; + } + + public function getMaxAgeInMinutes(): ?int + { + return $this->maxAgeInMinutes; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null === $v = $this->enabled) { + throw new InvalidArgument(sprintf('Missing parameter "Enabled" for "%s". The value cannot be null.', __CLASS__)); + } + $payload['Enabled'] = (bool) $v; + if (null !== $v = $this->maxAgeInMinutes) { + $payload['MaxAgeInMinutes'] = $v; + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/ValueObject/ResultReuseConfiguration.php b/src/Service/Athena/src/ValueObject/ResultReuseConfiguration.php new file mode 100644 index 000000000..d71b6a171 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/ResultReuseConfiguration.php @@ -0,0 +1,47 @@ +resultReuseByAgeConfiguration = isset($input['ResultReuseByAgeConfiguration']) ? ResultReuseByAgeConfiguration::create($input['ResultReuseByAgeConfiguration']) : null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getResultReuseByAgeConfiguration(): ?ResultReuseByAgeConfiguration + { + return $this->resultReuseByAgeConfiguration; + } + + /** + * @internal + */ + public function requestBody(): array + { + $payload = []; + if (null !== $v = $this->resultReuseByAgeConfiguration) { + $payload['ResultReuseByAgeConfiguration'] = $v->requestBody(); + } + + return $payload; + } +} diff --git a/src/Service/Athena/src/ValueObject/ResultReuseInformation.php b/src/Service/Athena/src/ValueObject/ResultReuseInformation.php new file mode 100644 index 000000000..9ff6b06d7 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/ResultReuseInformation.php @@ -0,0 +1,34 @@ +reusedPreviousResult = $input['ReusedPreviousResult'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getReusedPreviousResult(): bool + { + return $this->reusedPreviousResult; + } +} diff --git a/src/Service/Athena/src/ValueObject/ResultSet.php b/src/Service/Athena/src/ValueObject/ResultSet.php new file mode 100644 index 000000000..39c261972 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/ResultSet.php @@ -0,0 +1,49 @@ +rows = isset($input['Rows']) ? array_map([Row::class, 'create'], $input['Rows']) : null; + $this->resultSetMetadata = isset($input['ResultSetMetadata']) ? ResultSetMetadata::create($input['ResultSetMetadata']) : null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getResultSetMetadata(): ?ResultSetMetadata + { + return $this->resultSetMetadata; + } + + /** + * @return Row[] + */ + public function getRows(): array + { + return $this->rows ?? []; + } +} diff --git a/src/Service/Athena/src/ValueObject/ResultSetMetadata.php b/src/Service/Athena/src/ValueObject/ResultSetMetadata.php new file mode 100644 index 000000000..2fadbbdce --- /dev/null +++ b/src/Service/Athena/src/ValueObject/ResultSetMetadata.php @@ -0,0 +1,37 @@ +columnInfo = isset($input['ColumnInfo']) ? array_map([ColumnInfo::class, 'create'], $input['ColumnInfo']) : null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return ColumnInfo[] + */ + public function getColumnInfo(): array + { + return $this->columnInfo ?? []; + } +} diff --git a/src/Service/Athena/src/ValueObject/Row.php b/src/Service/Athena/src/ValueObject/Row.php new file mode 100644 index 000000000..e3a784188 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/Row.php @@ -0,0 +1,37 @@ +data = isset($input['Data']) ? array_map([Datum::class, 'create'], $input['Data']) : null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return Datum[] + */ + public function getData(): array + { + return $this->data ?? []; + } +} diff --git a/src/Service/Athena/src/ValueObject/SessionConfiguration.php b/src/Service/Athena/src/ValueObject/SessionConfiguration.php new file mode 100644 index 000000000..b9fe51df4 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/SessionConfiguration.php @@ -0,0 +1,67 @@ +executionRole = $input['ExecutionRole'] ?? null; + $this->workingDirectory = $input['WorkingDirectory'] ?? null; + $this->idleTimeoutSeconds = $input['IdleTimeoutSeconds'] ?? null; + $this->encryptionConfiguration = isset($input['EncryptionConfiguration']) ? EncryptionConfiguration::create($input['EncryptionConfiguration']) : null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getEncryptionConfiguration(): ?EncryptionConfiguration + { + return $this->encryptionConfiguration; + } + + public function getExecutionRole(): ?string + { + return $this->executionRole; + } + + public function getIdleTimeoutSeconds(): ?string + { + return $this->idleTimeoutSeconds; + } + + public function getWorkingDirectory(): ?string + { + return $this->workingDirectory; + } +} diff --git a/src/Service/Athena/src/ValueObject/SessionStatistics.php b/src/Service/Athena/src/ValueObject/SessionStatistics.php new file mode 100644 index 000000000..f948d3df1 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/SessionStatistics.php @@ -0,0 +1,34 @@ +dpuExecutionInMillis = $input['DpuExecutionInMillis'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getDpuExecutionInMillis(): ?string + { + return $this->dpuExecutionInMillis; + } +} diff --git a/src/Service/Athena/src/ValueObject/SessionStatus.php b/src/Service/Athena/src/ValueObject/SessionStatus.php new file mode 100644 index 000000000..a7bba1a68 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/SessionStatus.php @@ -0,0 +1,99 @@ +startDateTime = $input['StartDateTime'] ?? null; + $this->lastModifiedDateTime = $input['LastModifiedDateTime'] ?? null; + $this->endDateTime = $input['EndDateTime'] ?? null; + $this->idleSinceDateTime = $input['IdleSinceDateTime'] ?? null; + $this->state = $input['State'] ?? null; + $this->stateChangeReason = $input['StateChangeReason'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getEndDateTime(): ?\DateTimeImmutable + { + return $this->endDateTime; + } + + public function getIdleSinceDateTime(): ?\DateTimeImmutable + { + return $this->idleSinceDateTime; + } + + public function getLastModifiedDateTime(): ?\DateTimeImmutable + { + return $this->lastModifiedDateTime; + } + + public function getStartDateTime(): ?\DateTimeImmutable + { + return $this->startDateTime; + } + + /** + * @return SessionState::*|null + */ + public function getState(): ?string + { + return $this->state; + } + + public function getStateChangeReason(): ?string + { + return $this->stateChangeReason; + } +} diff --git a/src/Service/Athena/src/ValueObject/TableMetadata.php b/src/Service/Athena/src/ValueObject/TableMetadata.php new file mode 100644 index 000000000..7e74c7f09 --- /dev/null +++ b/src/Service/Athena/src/ValueObject/TableMetadata.php @@ -0,0 +1,115 @@ +, + * } $input + */ + public function __construct(array $input) + { + $this->name = $input['Name'] ?? null; + $this->createTime = $input['CreateTime'] ?? null; + $this->lastAccessTime = $input['LastAccessTime'] ?? null; + $this->tableType = $input['TableType'] ?? null; + $this->columns = isset($input['Columns']) ? array_map([Column::class, 'create'], $input['Columns']) : null; + $this->partitionKeys = isset($input['PartitionKeys']) ? array_map([Column::class, 'create'], $input['PartitionKeys']) : null; + $this->parameters = $input['Parameters'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + /** + * @return Column[] + */ + public function getColumns(): array + { + return $this->columns ?? []; + } + + public function getCreateTime(): ?\DateTimeImmutable + { + return $this->createTime; + } + + public function getLastAccessTime(): ?\DateTimeImmutable + { + return $this->lastAccessTime; + } + + public function getName(): string + { + return $this->name; + } + + /** + * @return array + */ + public function getParameters(): array + { + return $this->parameters ?? []; + } + + /** + * @return Column[] + */ + public function getPartitionKeys(): array + { + return $this->partitionKeys ?? []; + } + + public function getTableType(): ?string + { + return $this->tableType; + } +} diff --git a/src/Service/Athena/src/ValueObject/WorkGroup.php b/src/Service/Athena/src/ValueObject/WorkGroup.php new file mode 100644 index 000000000..339c3f70f --- /dev/null +++ b/src/Service/Athena/src/ValueObject/WorkGroup.php @@ -0,0 +1,92 @@ +name = $input['Name'] ?? null; + $this->state = $input['State'] ?? null; + $this->configuration = isset($input['Configuration']) ? WorkGroupConfiguration::create($input['Configuration']) : null; + $this->description = $input['Description'] ?? null; + $this->creationTime = $input['CreationTime'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getConfiguration(): ?WorkGroupConfiguration + { + return $this->configuration; + } + + public function getCreationTime(): ?\DateTimeImmutable + { + return $this->creationTime; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function getName(): string + { + return $this->name; + } + + /** + * @return WorkGroupState::*|null + */ + public function getState(): ?string + { + return $this->state; + } +} diff --git a/src/Service/Athena/src/ValueObject/WorkGroupConfiguration.php b/src/Service/Athena/src/ValueObject/WorkGroupConfiguration.php new file mode 100644 index 000000000..f973c540b --- /dev/null +++ b/src/Service/Athena/src/ValueObject/WorkGroupConfiguration.php @@ -0,0 +1,165 @@ +resultConfiguration = isset($input['ResultConfiguration']) ? ResultConfiguration::create($input['ResultConfiguration']) : null; + $this->enforceWorkGroupConfiguration = $input['EnforceWorkGroupConfiguration'] ?? null; + $this->publishCloudWatchMetricsEnabled = $input['PublishCloudWatchMetricsEnabled'] ?? null; + $this->bytesScannedCutoffPerQuery = $input['BytesScannedCutoffPerQuery'] ?? null; + $this->requesterPaysEnabled = $input['RequesterPaysEnabled'] ?? null; + $this->engineVersion = isset($input['EngineVersion']) ? EngineVersion::create($input['EngineVersion']) : null; + $this->additionalConfiguration = $input['AdditionalConfiguration'] ?? null; + $this->executionRole = $input['ExecutionRole'] ?? null; + $this->customerContentEncryptionConfiguration = isset($input['CustomerContentEncryptionConfiguration']) ? CustomerContentEncryptionConfiguration::create($input['CustomerContentEncryptionConfiguration']) : null; + $this->enableMinimumEncryptionConfiguration = $input['EnableMinimumEncryptionConfiguration'] ?? null; + } + + public static function create($input): self + { + return $input instanceof self ? $input : new self($input); + } + + public function getAdditionalConfiguration(): ?string + { + return $this->additionalConfiguration; + } + + public function getBytesScannedCutoffPerQuery(): ?string + { + return $this->bytesScannedCutoffPerQuery; + } + + public function getCustomerContentEncryptionConfiguration(): ?CustomerContentEncryptionConfiguration + { + return $this->customerContentEncryptionConfiguration; + } + + public function getEnableMinimumEncryptionConfiguration(): ?bool + { + return $this->enableMinimumEncryptionConfiguration; + } + + public function getEnforceWorkGroupConfiguration(): ?bool + { + return $this->enforceWorkGroupConfiguration; + } + + public function getEngineVersion(): ?EngineVersion + { + return $this->engineVersion; + } + + public function getExecutionRole(): ?string + { + return $this->executionRole; + } + + public function getPublishCloudWatchMetricsEnabled(): ?bool + { + return $this->publishCloudWatchMetricsEnabled; + } + + public function getRequesterPaysEnabled(): ?bool + { + return $this->requesterPaysEnabled; + } + + public function getResultConfiguration(): ?ResultConfiguration + { + return $this->resultConfiguration; + } +} diff --git a/src/Service/Athena/tests/.gitignore b/src/Service/Athena/tests/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/src/Service/Athena/tests/Integration/AthenaClientTest.php b/src/Service/Athena/tests/Integration/AthenaClientTest.php new file mode 100644 index 000000000..7c37cd330 --- /dev/null +++ b/src/Service/Athena/tests/Integration/AthenaClientTest.php @@ -0,0 +1,419 @@ +getClient(); + + $input = new GetCalculationExecutionRequest([ + 'CalculationExecutionId' => 'change me', + ]); + $result = $client->getCalculationExecution($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getCalculationExecutionId()); + self::assertSame('changeIt', $result->getSessionId()); + self::assertSame('changeIt', $result->getDescription()); + self::assertSame('changeIt', $result->getWorkingDirectory()); + // self::assertTODO(expected, $result->getStatus()); + // self::assertTODO(expected, $result->getStatistics()); + // self::assertTODO(expected, $result->getResult()); + } + + public function testGetCalculationExecutionStatus(): void + { + $client = $this->getClient(); + + $input = new GetCalculationExecutionStatusRequest([ + 'CalculationExecutionId' => 'change me', + ]); + $result = $client->getCalculationExecutionStatus($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getStatus()); + // self::assertTODO(expected, $result->getStatistics()); + } + + public function testGetDataCatalog(): void + { + $client = $this->getClient(); + + $input = new GetDataCatalogInput([ + 'Name' => 'change me', + ]); + $result = $client->getDataCatalog($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getDataCatalog()); + } + + public function testGetDatabase(): void + { + $client = $this->getClient(); + + $input = new GetDatabaseInput([ + 'CatalogName' => 'change me', + 'DatabaseName' => 'change me', + ]); + $result = $client->getDatabase($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getDatabase()); + } + + public function testGetNamedQuery(): void + { + $client = $this->getClient(); + + $input = new GetNamedQueryInput([ + 'NamedQueryId' => 'change me', + ]); + $result = $client->getNamedQuery($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getNamedQuery()); + } + + public function testGetQueryExecution(): void + { + $client = $this->getClient(); + + $input = new GetQueryExecutionInput([ + 'QueryExecutionId' => 'change me', + ]); + $result = $client->getQueryExecution($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getQueryExecution()); + } + + public function testGetQueryResults(): void + { + $client = $this->getClient(); + + $input = new GetQueryResultsInput([ + 'QueryExecutionId' => 'change me', + 'NextToken' => 'change me', + 'MaxResults' => 1337, + ]); + $result = $client->getQueryResults($input); + + $result->resolve(); + + self::assertSame(1337, $result->getUpdateCount()); + self::assertInstanceOf(ResultSet::class, $result->getResultSet()); + self::assertSame('changeIt', $result->getNextToken()); + } + + public function testGetSession(): void + { + $client = $this->getClient(); + + $input = new GetSessionRequest([ + 'SessionId' => 'change me', + ]); + $result = $client->getSession($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getSessionId()); + self::assertSame('changeIt', $result->getDescription()); + self::assertSame('changeIt', $result->getWorkGroup()); + self::assertSame('changeIt', $result->getEngineVersion()); + // self::assertTODO(expected, $result->getEngineConfiguration()); + self::assertSame('changeIt', $result->getNotebookVersion()); + // self::assertTODO(expected, $result->getSessionConfiguration()); + // self::assertTODO(expected, $result->getStatus()); + // self::assertTODO(expected, $result->getStatistics()); + } + + public function testGetSessionStatus(): void + { + $client = $this->getClient(); + + $input = new GetSessionStatusRequest([ + 'SessionId' => 'change me', + ]); + $result = $client->getSessionStatus($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getSessionId()); + // self::assertTODO(expected, $result->getStatus()); + } + + public function testGetTableMetadata(): void + { + $client = $this->getClient(); + + $input = new GetTableMetadataInput([ + 'CatalogName' => 'change me', + 'DatabaseName' => 'change me', + 'TableName' => 'change me', + ]); + $result = $client->getTableMetadata($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getTableMetadata()); + } + + public function testGetWorkGroup(): void + { + $client = $this->getClient(); + + $input = new GetWorkGroupInput([ + 'WorkGroup' => 'change me', + ]); + $result = $client->getWorkGroup($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getWorkGroup()); + } + + public function testListDatabases(): void + { + $client = $this->getClient(); + + $input = new ListDatabasesInput([ + 'CatalogName' => 'change me', + 'NextToken' => 'change me', + 'MaxResults' => 1337, + ]); + $result = $client->listDatabases($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getDatabaseList()); + self::assertSame('changeIt', $result->getNextToken()); + } + + public function testListNamedQueries(): void + { + $client = $this->getClient(); + + $input = new ListNamedQueriesInput([ + 'NextToken' => 'change me', + 'MaxResults' => 1337, + 'WorkGroup' => 'change me', + ]); + $result = $client->listNamedQueries($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getNamedQueryIds()); + self::assertSame('changeIt', $result->getNextToken()); + } + + public function testListQueryExecutions(): void + { + $client = $this->getClient(); + + $input = new ListQueryExecutionsInput([ + 'NextToken' => 'change me', + 'MaxResults' => 1337, + 'WorkGroup' => 'change me', + ]); + $result = $client->listQueryExecutions($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getQueryExecutionIds()); + self::assertSame('changeIt', $result->getNextToken()); + } + + public function testListTableMetadata(): void + { + $client = $this->getClient(); + + $input = new ListTableMetadataInput([ + 'CatalogName' => 'change me', + 'DatabaseName' => 'change me', + 'Expression' => 'change me', + 'NextToken' => 'change me', + 'MaxResults' => 1337, + ]); + $result = $client->listTableMetadata($input); + + $result->resolve(); + + // self::assertTODO(expected, $result->getTableMetadataList()); + self::assertSame('changeIt', $result->getNextToken()); + } + + public function testStartCalculationExecution(): void + { + $client = $this->getClient(); + + $input = new StartCalculationExecutionRequest([ + 'SessionId' => 'change me', + 'Description' => 'change me', + 'CalculationConfiguration' => new CalculationConfiguration([ + 'CodeBlock' => 'change me', + ]), + 'CodeBlock' => 'change me', + 'ClientRequestToken' => 'change me', + ]); + $result = $client->startCalculationExecution($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getCalculationExecutionId()); + self::assertSame('changeIt', $result->getState()); + } + + public function testStartQueryExecution(): void + { + $client = $this->getClient(); + + $input = new StartQueryExecutionInput([ + 'QueryString' => 'select * from my-table limit 3', + 'ClientRequestToken' => 'Unique-caSe-sensitive-0011', + 'QueryExecutionContext' => new QueryExecutionContext([ + 'Database' => 'my_dbname', + 'Catalog' => 'my_catalog_name', + ]), + 'ResultConfiguration' => new ResultConfiguration([ + 'OutputLocation' => 's3://my_bucket/', + 'EncryptionConfiguration' => new EncryptionConfiguration([ + 'EncryptionOption' => 'SSE_S3', + ]), + 'ExpectedBucketOwner' => 's3_bucket_owner', + 'AclConfiguration' => new AclConfiguration([ + 'S3AclOption' => 'BUCKET_OWNER_FULL_CONTROL', + ]), + ]), + 'WorkGroup' => 'my_worgroup_name', + 'ExecutionParameters' => [], + 'ResultReuseConfiguration' => new ResultReuseConfiguration([ + 'ResultReuseByAgeConfiguration' => new ResultReuseByAgeConfiguration([ + 'Enabled' => false, + 'MaxAgeInMinutes' => 1337, + ]), + ]), + ]); + $result = $client->startQueryExecution($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getQueryExecutionId()); + } + + public function testStartSession(): void + { + $client = $this->getClient(); + + $input = new StartSessionRequest([ + 'Description' => 'my test description', + 'WorkGroup' => 'my_workgroup_name', + 'EngineConfiguration' => new EngineConfiguration([ + 'CoordinatorDpuSize' => 1337, + 'MaxConcurrentDpus' => 1337, + 'DefaultExecutorDpuSize' => 1337, + 'AdditionalConfigs' => ['change me' => 'change me'], + ]), + 'NotebookVersion' => 'change me', + 'SessionIdleTimeoutInMinutes' => 1337, + 'ClientRequestToken' => 'change me', + ]); + $result = $client->startSession($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getSessionId()); + self::assertSame('changeIt', $result->getState()); + } + + public function testStopCalculationExecution(): void + { + $client = $this->getClient(); + + $input = new StopCalculationExecutionRequest([ + 'CalculationExecutionId' => 'change me', + ]); + $result = $client->stopCalculationExecution($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getState()); + } + + public function testStopQueryExecution(): void + { + $client = $this->getClient(); + + $input = new StopQueryExecutionInput([ + 'QueryExecutionId' => 'change me', + ]); + $result = $client->stopQueryExecution($input); + + $result->resolve(); + } + + public function testTerminateSession(): void + { + $client = $this->getClient(); + + $input = new TerminateSessionRequest([ + 'SessionId' => 'change me', + ]); + $result = $client->terminateSession($input); + + $result->resolve(); + + self::assertSame('changeIt', $result->getState()); + } + + private function getClient(): AthenaClient + { + self::markTestSkipped('No yet Docker image for Athena '); + + return new AthenaClient([ + 'endpoint' => 'http://localhost', + ], new NullProvider()); + } +} diff --git a/src/Service/Athena/tests/Unit/AthenaClientTest.php b/src/Service/Athena/tests/Unit/AthenaClientTest.php new file mode 100644 index 000000000..e509f8ead --- /dev/null +++ b/src/Service/Athena/tests/Unit/AthenaClientTest.php @@ -0,0 +1,343 @@ + 'iad-6855-254589-ef4r4z5', + ]); + $result = $client->getCalculationExecution($input); + + self::assertInstanceOf(GetCalculationExecutionResponse::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetCalculationExecutionStatus(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetCalculationExecutionStatusRequest([ + 'CalculationExecutionId' => 'iad-6855-254589-ef4r4z5', + ]); + $result = $client->getCalculationExecutionStatus($input); + + self::assertInstanceOf(GetCalculationExecutionStatusResponse::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetDataCatalog(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetDataCatalogInput([ + 'Name' => 'iadCatalog', + ]); + $result = $client->getDataCatalog($input); + + self::assertInstanceOf(GetDataCatalogOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetDatabase(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetDatabaseInput([ + 'CatalogName' => 'iadCatalog', + 'DatabaseName' => 'iadDatabase', + ]); + $result = $client->getDatabase($input); + + self::assertInstanceOf(GetDatabaseOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetNamedQuery(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetNamedQueryInput([ + 'NamedQueryId' => 'iad-query-12536', + ]); + $result = $client->getNamedQuery($input); + + self::assertInstanceOf(GetNamedQueryOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetQueryExecution(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetQueryExecutionInput([ + 'QueryExecutionId' => 'iad-145r55t-11446', + ]); + $result = $client->getQueryExecution($input); + + self::assertInstanceOf(GetQueryExecutionOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetQueryResults(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetQueryResultsInput([ + 'QueryExecutionId' => 'iad-145r55t-11446', + + ]); + $result = $client->getQueryResults($input); + + self::assertInstanceOf(GetQueryResultsOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetSession(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetSessionRequest([ + 'SessionId' => 'session-iad-2563', + ]); + $result = $client->getSession($input); + + self::assertInstanceOf(GetSessionResponse::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetSessionStatus(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetSessionStatusRequest([ + 'SessionId' => 'session-iad-2563', + ]); + $result = $client->getSessionStatus($input); + + self::assertInstanceOf(GetSessionStatusResponse::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetTableMetadata(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetTableMetadataInput([ + 'CatalogName' => 'iadCatalog', + 'DatabaseName' => 'iadDatabase', + 'TableName' => 'product_catalog', + ]); + $result = $client->getTableMetadata($input); + + self::assertInstanceOf(GetTableMetadataOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testGetWorkGroup(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new GetWorkGroupInput([ + 'WorkGroup' => 'iadinternational', + ]); + $result = $client->getWorkGroup($input); + + self::assertInstanceOf(GetWorkGroupOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testListDatabases(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new ListDatabasesInput([ + 'CatalogName' => 'iadCatalog', + + ]); + $result = $client->listDatabases($input); + + self::assertInstanceOf(ListDatabasesOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testListNamedQueries(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new ListNamedQueriesInput([ + + ]); + $result = $client->listNamedQueries($input); + + self::assertInstanceOf(ListNamedQueriesOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testListQueryExecutions(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new ListQueryExecutionsInput([ + + ]); + $result = $client->listQueryExecutions($input); + + self::assertInstanceOf(ListQueryExecutionsOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testListTableMetadata(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new ListTableMetadataInput([ + 'CatalogName' => 'iadCatalog', + 'DatabaseName' => 'iadDatabase', + + ]); + $result = $client->listTableMetadata($input); + + self::assertInstanceOf(ListTableMetadataOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testStartCalculationExecution(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new StartCalculationExecutionRequest([ + 'SessionId' => 'session-iad-2563', + + ]); + $result = $client->startCalculationExecution($input); + + self::assertInstanceOf(StartCalculationExecutionResponse::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testStartQueryExecution(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new StartQueryExecutionInput([ + 'QueryString' => 'SELECT * FROM iadDatabase.catalog LIMT 10', + + ]); + $result = $client->startQueryExecution($input); + + self::assertInstanceOf(StartQueryExecutionOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testStartSession(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new StartSessionRequest([ + + 'WorkGroup' => 'iadinternational', + 'EngineConfiguration' => new EngineConfiguration([ + + 'MaxConcurrentDpus' => 1337, + + ]), + + ]); + $result = $client->startSession($input); + + self::assertInstanceOf(StartSessionResponse::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testStopCalculationExecution(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new StopCalculationExecutionRequest([ + 'CalculationExecutionId' => 'iad-e222-4619-ac1f', + ]); + $result = $client->stopCalculationExecution($input); + + self::assertInstanceOf(StopCalculationExecutionResponse::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testStopQueryExecution(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new StopQueryExecutionInput([ + 'QueryExecutionId' => 'irq-iad-25', + ]); + $result = $client->stopQueryExecution($input); + + self::assertInstanceOf(StopQueryExecutionOutput::class, $result); + self::assertFalse($result->info()['resolved']); + } + + public function testTerminateSession(): void + { + $client = new AthenaClient([], new NullProvider(), new MockHttpClient()); + + $input = new TerminateSessionRequest([ + 'SessionId' => 'session-iad-2563', + ]); + $result = $client->terminateSession($input); + + self::assertInstanceOf(TerminateSessionResponse::class, $result); + self::assertFalse($result->info()['resolved']); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetCalculationExecutionRequestTest.php b/src/Service/Athena/tests/Unit/Input/GetCalculationExecutionRequestTest.php new file mode 100644 index 000000000..a3053cab9 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetCalculationExecutionRequestTest.php @@ -0,0 +1,29 @@ + '145226', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetCalculationExecution.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.GetCalculationExecution + + { + "CalculationExecutionId": "145226" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetCalculationExecutionStatusRequestTest.php b/src/Service/Athena/tests/Unit/Input/GetCalculationExecutionStatusRequestTest.php new file mode 100644 index 000000000..50147078a --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetCalculationExecutionStatusRequestTest.php @@ -0,0 +1,29 @@ + '125-5rte41', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetCalculationExecutionStatus.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.GetCalculationExecutionStatus + + { + "CalculationExecutionId": "125-5rte41" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetDataCatalogInputTest.php b/src/Service/Athena/tests/Unit/Input/GetDataCatalogInputTest.php new file mode 100644 index 000000000..6338fe196 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetDataCatalogInputTest.php @@ -0,0 +1,27 @@ + 'myDataCatalog', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetDataCatalog.html + $expected = ' +POST / HTTP/1.0 +Content-Type: application/x-amz-json-1.1 +x-amz-target: AmazonAthena.GetDataCatalog + +{ "Name": "myDataCatalog" } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetDatabaseInputTest.php b/src/Service/Athena/tests/Unit/Input/GetDatabaseInputTest.php new file mode 100644 index 000000000..7562c4df2 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetDatabaseInputTest.php @@ -0,0 +1,31 @@ + 'my_catalog_name', + 'DatabaseName' => 'my_database_name', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetDatabase.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.GetDatabase + + { + "CatalogName": "my_catalog_name", + "DatabaseName": "my_database_name" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetNamedQueryInputTest.php b/src/Service/Athena/tests/Unit/Input/GetNamedQueryInputTest.php new file mode 100644 index 000000000..4d5d08780 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetNamedQueryInputTest.php @@ -0,0 +1,29 @@ + 'test_query', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetNamedQuery.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.GetNamedQuery + + { + "NamedQueryId": "test_query" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetQueryExecutionInputTest.php b/src/Service/Athena/tests/Unit/Input/GetQueryExecutionInputTest.php new file mode 100644 index 000000000..c0a795ee4 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetQueryExecutionInputTest.php @@ -0,0 +1,29 @@ + 'my_query_id25-96', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetQueryExecution.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.GetQueryExecution + + { + "QueryExecutionId": "my_query_id25-96" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetQueryResultsInputTest.php b/src/Service/Athena/tests/Unit/Input/GetQueryResultsInputTest.php new file mode 100644 index 000000000..93286eee2 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetQueryResultsInputTest.php @@ -0,0 +1,33 @@ + 'iad-145r55t-11446', + 'NextToken' => 'iad-next-2563', + 'MaxResults' => 1337, + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetQueryResults.html + $expected = ' +POST / HTTP/1.0 +Content-Type: application/x-amz-json-1.1 +x-amz-target: AmazonAthena.GetQueryResults + +{ + "QueryExecutionId": "iad-145r55t-11446", + "NextToken": "iad-next-2563", + "MaxResults": 1337 +} + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetSessionRequestTest.php b/src/Service/Athena/tests/Unit/Input/GetSessionRequestTest.php new file mode 100644 index 000000000..fb3c59b91 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetSessionRequestTest.php @@ -0,0 +1,29 @@ + 'iad-aws-Athena23669', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetSession.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.GetSession + + { + "SessionId": "iad-aws-Athena23669" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetSessionStatusRequestTest.php b/src/Service/Athena/tests/Unit/Input/GetSessionStatusRequestTest.php new file mode 100644 index 000000000..34a421970 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetSessionStatusRequestTest.php @@ -0,0 +1,29 @@ + 'my_session_1236', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetSessionStatus.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.GetSessionStatus + + { + "SessionId": "my_session_1236" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetTableMetadataInputTest.php b/src/Service/Athena/tests/Unit/Input/GetTableMetadataInputTest.php new file mode 100644 index 000000000..42875f74e --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetTableMetadataInputTest.php @@ -0,0 +1,33 @@ + 'myCatalogIad', + 'DatabaseName' => 'myDatabaseIad', + 'TableName' => 'myTableIad', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetTableMetadata.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.GetTableMetadata + + { + "CatalogName": "myCatalogIad", + "DatabaseName": "myDatabaseIad", + "TableName": "myTableIad" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/GetWorkGroupInputTest.php b/src/Service/Athena/tests/Unit/Input/GetWorkGroupInputTest.php new file mode 100644 index 000000000..7507bbf55 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/GetWorkGroupInputTest.php @@ -0,0 +1,29 @@ + 'iadinternational', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetWorkGroup.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.GetWorkGroup + + { + "WorkGroup": "iadinternational" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/ListDatabasesInputTest.php b/src/Service/Athena/tests/Unit/Input/ListDatabasesInputTest.php new file mode 100644 index 000000000..270104586 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/ListDatabasesInputTest.php @@ -0,0 +1,33 @@ + 'IadCatalog', + 'NextToken' => 'iad-002', + 'MaxResults' => 1337, + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_ListDatabases.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.ListDatabases + + { + "CatalogName": "IadCatalog", + "NextToken": "iad-002", + "MaxResults": 1337 +} + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/ListNamedQueriesInputTest.php b/src/Service/Athena/tests/Unit/Input/ListNamedQueriesInputTest.php new file mode 100644 index 000000000..2ecddef16 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/ListNamedQueriesInputTest.php @@ -0,0 +1,33 @@ + 'iad-9633', + 'MaxResults' => 1337, + 'WorkGroup' => 'iadinternatiaonal', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_ListNamedQueries.html + $expected = ' +POST / HTTP/1.0 +Content-Type: application/x-amz-json-1.1 +x-amz-target: AmazonAthena.ListNamedQueries + +{ + "NextToken": "iad-9633", + "MaxResults": 1337, + "WorkGroup": "iadinternatiaonal" +} + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/ListQueryExecutionsInputTest.php b/src/Service/Athena/tests/Unit/Input/ListQueryExecutionsInputTest.php new file mode 100644 index 000000000..e7ee97c31 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/ListQueryExecutionsInputTest.php @@ -0,0 +1,33 @@ + 'iad-9633', + 'MaxResults' => 1337, + 'WorkGroup' => 'iadinternatiaonal', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_ListQueryExecutions.html + $expected = ' +POST / HTTP/1.0 +Content-Type: application/x-amz-json-1.1 +x-amz-target: AmazonAthena.ListQueryExecutions + +{ + "NextToken": "iad-9633", + "MaxResults": 1337, + "WorkGroup": "iadinternatiaonal" +} + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/ListTableMetadataInputTest.php b/src/Service/Athena/tests/Unit/Input/ListTableMetadataInputTest.php new file mode 100644 index 000000000..0a869bdf5 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/ListTableMetadataInputTest.php @@ -0,0 +1,37 @@ + 'iadCatalog', + 'DatabaseName' => 'iadDb', + 'Expression' => 'iad international', + 'NextToken' => 'iad-4582', + 'MaxResults' => 1337, + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_ListTableMetadata.html + $expected = ' +POST / HTTP/1.0 +Content-Type: application/x-amz-json-1.1 +x-amz-target: AmazonAthena.ListTableMetadata + +{ +"CatalogName": "iadCatalog", +"DatabaseName": "iadDb", +"Expression": "iad international", +"NextToken": "iad-4582", +"MaxResults": 1337 +} + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/StartCalculationExecutionRequestTest.php b/src/Service/Athena/tests/Unit/Input/StartCalculationExecutionRequestTest.php new file mode 100644 index 000000000..47aead689 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/StartCalculationExecutionRequestTest.php @@ -0,0 +1,47 @@ + 'iad-session-25463', + 'Description' => 'iad international', + 'CalculationConfiguration' => new CalculationConfiguration([ + 'CodeBlock' => 'IAD', + ]), + 'CodeBlock' => 'IAD', + 'ClientRequestToken' => 'i@d-2023', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_StartCalculationExecution.html + $expected = ' +POST / HTTP/1.0 +Content-Type: application/x-amz-json-1.1 +x-amz-target: AmazonAthena.StartCalculationExecution + +{ + "SessionId": "iad-session-25463", + "Description": "iad international", + "CalculationConfiguration": { + "CodeBlock": "IAD" + }, + "CodeBlock": "IAD", + "ClientRequestToken": "i@d-2023" +} + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/StartQueryExecutionInputTest.php b/src/Service/Athena/tests/Unit/Input/StartQueryExecutionInputTest.php new file mode 100644 index 000000000..79a3ecd66 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/StartQueryExecutionInputTest.php @@ -0,0 +1,91 @@ + 'select * from my_table limit 3', + 'ClientRequestToken' => 'Unique-caSe-sensitive-0011', + 'QueryExecutionContext' => new QueryExecutionContext([ + 'Database' => 'my_dbname', + 'Catalog' => 'my_catalog_name', + ]), + 'ResultConfiguration' => new ResultConfiguration([ + 'OutputLocation' => 's3://my_bucket/', + 'EncryptionConfiguration' => new EncryptionConfiguration([ + 'EncryptionOption' => 'SSE_S3', + 'KmsKey' => 'mykey4452263', + ]), + 'ExpectedBucketOwner' => 's3_bucket_owner', + 'AclConfiguration' => new AclConfiguration([ + 'S3AclOption' => 'BUCKET_OWNER_FULL_CONTROL', + ]), + ]), + 'WorkGroup' => 'iadinternational', + 'ExecutionParameters' => [], + 'ResultReuseConfiguration' => new ResultReuseConfiguration([ + 'ResultReuseByAgeConfiguration' => new ResultReuseByAgeConfiguration([ + 'Enabled' => false, + 'MaxAgeInMinutes' => 1337, + ]), + ]), + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_StartQueryExecution.html + $expected = ' +POST / HTTP/1.0 +Content-Type: application/x-amz-json-1.1 +x-amz-target: AmazonAthena.StartQueryExecution + +{ + "QueryString": "select * from my_table limit 3", + "ClientRequestToken": "Unique-caSe-sensitive-0011", + "QueryExecutionContext": + { + "Database": "my_dbname", + "Catalog": "my_catalog_name" + }, + "ResultConfiguration": + { + "OutputLocation": "s3://my_bucket/", + "EncryptionConfiguration": + { + "EncryptionOption": "SSE_S3", + "KmsKey": "mykey4452263" + }, + "ExpectedBucketOwner": "s3_bucket_owner", + "AclConfiguration": + { + "S3AclOption": "BUCKET_OWNER_FULL_CONTROL" + } + }, + "WorkGroup": "iadinternational", + "ExecutionParameters": [], + "ResultReuseConfiguration": + { + "ResultReuseByAgeConfiguration": + { + "Enabled": false, + "MaxAgeInMinutes": 1337 + } + } +} +'; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/StartSessionRequestTest.php b/src/Service/Athena/tests/Unit/Input/StartSessionRequestTest.php new file mode 100644 index 000000000..7a4a47c63 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/StartSessionRequestTest.php @@ -0,0 +1,52 @@ + 'iad international asyncAws', + 'WorkGroup' => 'iadinternational', + 'EngineConfiguration' => new EngineConfiguration([ + 'CoordinatorDpuSize' => 1337, + 'MaxConcurrentDpus' => 1337, + 'DefaultExecutorDpuSize' => 1337, + 'AdditionalConfigs' => ['contrib' => 'iad'], + ]), + 'NotebookVersion' => 'v12', + 'SessionIdleTimeoutInMinutes' => 1337, + 'ClientRequestToken' => 'i@d-1452266', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_StartSession.html + $expected = ' +POST / HTTP/1.0 +Content-Type: application/x-amz-json-1.1 +x-amz-target: AmazonAthena.StartSession + +{ + "Description": "iad international asyncAws", + "WorkGroup": "iadinternational", + "EngineConfiguration": { + "CoordinatorDpuSize": 1337, + "DefaultExecutorDpuSize": 1337, + "MaxConcurrentDpus": 1337, + "AdditionalConfigs": { + "contrib" : "iad" + } + }, + "NotebookVersion": "v12", + "SessionIdleTimeoutInMinutes": 1337, + "ClientRequestToken": "i@d-1452266" +} + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/StopCalculationExecutionRequestTest.php b/src/Service/Athena/tests/Unit/Input/StopCalculationExecutionRequestTest.php new file mode 100644 index 000000000..9f351ae92 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/StopCalculationExecutionRequestTest.php @@ -0,0 +1,29 @@ + 'id14562', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_StopCalculationExecution.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.StopCalculationExecution + + { + "CalculationExecutionId": "id14562" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/StopQueryExecutionInputTest.php b/src/Service/Athena/tests/Unit/Input/StopQueryExecutionInputTest.php new file mode 100644 index 000000000..f86f0fb2f --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/StopQueryExecutionInputTest.php @@ -0,0 +1,29 @@ + 'my-query-id-24563', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_StopQueryExecution.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.StopQueryExecution + + { + "QueryExecutionId": "my-query-id-24563" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Input/TerminateSessionRequestTest.php b/src/Service/Athena/tests/Unit/Input/TerminateSessionRequestTest.php new file mode 100644 index 000000000..296668382 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Input/TerminateSessionRequestTest.php @@ -0,0 +1,29 @@ + 'my-iad-session', + ]); + + // see https://docs.aws.amazon.com/athena/latest/APIReference/API_TerminateSession.html + $expected = ' + POST / HTTP/1.0 + Content-Type: application/x-amz-json-1.1 + x-amz-target: AmazonAthena.TerminateSession + + { + "SessionId": "my-iad-session" + } + '; + + self::assertRequestEqualsHttpRequest($expected, $input->request()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetCalculationExecutionResponseTest.php b/src/Service/Athena/tests/Unit/Result/GetCalculationExecutionResponseTest.php new file mode 100644 index 000000000..76a62d2dc --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetCalculationExecutionResponseTest.php @@ -0,0 +1,56 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertSame($CalculationExecutionId, $result->getCalculationExecutionId()); + self::assertSame('session-iad-1526', $result->getSessionId()); + self::assertSame('iad international async_aws', $result->getDescription()); + self::assertSame('iad-directory', $result->getWorkingDirectory()); + self::assertSame('RUNNING', $result->getStatus()->getState()); + self::assertInstanceOf(CalculationStatistics::class, $result->getStatistics()); + self::assertSame('1337', $result->getStatistics()->getDpuExecutionInMillis()); + self::assertInstanceOf(CalculationResult::class, $result->getResult()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetCalculationExecutionStatusResponseTest.php b/src/Service/Athena/tests/Unit/Result/GetCalculationExecutionStatusResponseTest.php new file mode 100644 index 000000000..6df63ee8f --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetCalculationExecutionStatusResponseTest.php @@ -0,0 +1,40 @@ +request('POST', 'http://localhost'), $client, new NullLogger()) + ); + + self::assertInstanceOf(CalculationStatus::class, $result->getStatus()); + self::assertSame('CREATED', $result->getStatus()->getState()); + self::assertIsString($result->getStatistics()->getDpuExecutionInMillis()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetDataCatalogOutputTest.php b/src/Service/Athena/tests/Unit/Result/GetDataCatalogOutputTest.php new file mode 100644 index 000000000..dacd81246 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetDataCatalogOutputTest.php @@ -0,0 +1,35 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertInstanceOf(DataCatalog::class, $result->getDataCatalog()); + self::assertSame('GLUE', $result->getDataCatalog()->getType()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetDatabaseOutputTest.php b/src/Service/Athena/tests/Unit/Result/GetDatabaseOutputTest.php new file mode 100644 index 000000000..ec5d1acd6 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetDatabaseOutputTest.php @@ -0,0 +1,34 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertInstanceOf(Database::class, $result->getDatabase()); + self::assertSame('Iad2023', $result->getDatabase()->getName()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetNamedQueryOutputTest.php b/src/Service/Athena/tests/Unit/Result/GetNamedQueryOutputTest.php new file mode 100644 index 000000000..36131cd0d --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetNamedQueryOutputTest.php @@ -0,0 +1,36 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertInstanceOf(NamedQuery::class, $result->getNamedQuery()); + self::assertSame('my-uid-78555-2563', $result->getNamedQuery()->getNamedQueryId()); + self::assertSame('IadQuery', $result->getNamedQuery()->getName()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetQueryExecutionOutputTest.php b/src/Service/Athena/tests/Unit/Result/GetQueryExecutionOutputTest.php new file mode 100644 index 000000000..c37f955c1 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetQueryExecutionOutputTest.php @@ -0,0 +1,85 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertInstanceOf(QueryExecution::class, $result->getQueryExecution()); + self::assertSame('INSERTION', $result->getQueryExecution()->getSubstatementType()); + self::assertSame('DML', $result->getQueryExecution()->getStatementType()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetQueryResultsOutputTest.php b/src/Service/Athena/tests/Unit/Result/GetQueryResultsOutputTest.php new file mode 100644 index 000000000..6ac249283 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetQueryResultsOutputTest.php @@ -0,0 +1,92 @@ +request('POST', 'http://localhost'), $client, new NullLogger()), new AthenaClient(), new GetQueryResultsInput([])); + + self::assertSame('1337', $result->getUpdateCount()); + self::assertInstanceOf(ResultSet::class, $result->getResultSet()); + self::assertCount(2, $result->getResultSet()->getRows()); + self::assertInstanceOf(Row::class, $result->getResultSet()->getRows()[0]); + self::assertInstanceOf(Datum::class, $result->getResultSet()->getRows()[0]->getData()[0]); + self::assertInstanceOf(ResultSetMetadata::class, $result->getResultSet()->getResultSetMetadata()); + self::assertCount(2, $result->getResultSet()->getResultSetMetadata()->getColumnInfo()); + self::assertSame('iad-token-236', $result->getNextToken()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetSessionResponseTest.php b/src/Service/Athena/tests/Unit/Result/GetSessionResponseTest.php new file mode 100644 index 000000000..222c15cb5 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetSessionResponseTest.php @@ -0,0 +1,70 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertSame('session-iad-2036', $result->getSessionId()); + self::assertSame('iad international async_aws', $result->getDescription()); + self::assertSame('iadinternational', $result->getWorkGroup()); + self::assertSame('PySpark engine version 3', $result->getEngineVersion()); + self::assertInstanceOf(EngineConfiguration::class, $result->getEngineConfiguration()); + self::assertSame('v12', $result->getNotebookVersion()); + self::assertInstanceOf(SessionConfiguration::class, $result->getSessionConfiguration()); + self::assertInstanceOf(SessionStatus::class, $result->getStatus()); + self::assertInstanceOf(SessionStatistics::class, $result->getStatistics()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetSessionStatusResponseTest.php b/src/Service/Athena/tests/Unit/Result/GetSessionStatusResponseTest.php new file mode 100644 index 000000000..57c216c81 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetSessionStatusResponseTest.php @@ -0,0 +1,37 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertSame('session-iad-1256', $result->getSessionId()); + self::assertInstanceOf(SessionStatus::class, $result->getStatus()); + self::assertSame('RUNNING', $result->getStatus()->getState()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetTableMetadataOutputTest.php b/src/Service/Athena/tests/Unit/Result/GetTableMetadataOutputTest.php new file mode 100644 index 000000000..993c07297 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetTableMetadataOutputTest.php @@ -0,0 +1,51 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertInstanceOf(TableMetadata::class, $result->getTableMetadata()); + self::assertIsArray($result->getTableMetadata()->getPartitionKeys()); + self::assertSame('EXTERNAL_TABLE', $result->getTableMetadata()->getTableType()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/GetWorkGroupOutputTest.php b/src/Service/Athena/tests/Unit/Result/GetWorkGroupOutputTest.php new file mode 100644 index 000000000..dacf84996 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/GetWorkGroupOutputTest.php @@ -0,0 +1,61 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertInstanceOf(WorkGroup::class, $result->getWorkGroup()); + self::assertSame('ENABLED', $result->getWorkGroup()->getState()); + self::assertSame('iadWorkgroup', $result->getWorkGroup()->getName()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/ListDatabasesOutputTest.php b/src/Service/Athena/tests/Unit/Result/ListDatabasesOutputTest.php new file mode 100644 index 000000000..7fc87966e --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/ListDatabasesOutputTest.php @@ -0,0 +1,48 @@ +request('POST', 'http://localhost'), $client, new NullLogger() + ), + new AthenaClient(), + new ListDatabasesInput([ + 'CatalogName' => 'iadCatalog', + ]) + ); + + self::assertIsIterable($result->getDatabaseList()); + self::assertCount(1, $result->getDatabaseList()); + self::assertSame('iad-tok1n253', $result->getNextToken()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/ListNamedQueriesOutputTest.php b/src/Service/Athena/tests/Unit/Result/ListNamedQueriesOutputTest.php new file mode 100644 index 000000000..b150ba3cf --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/ListNamedQueriesOutputTest.php @@ -0,0 +1,33 @@ +request('POST', 'http://localhost'), $client, new NullLogger()), new AthenaClient(), new ListNamedQueriesInput([])); + + self::assertIsIterable($result->getNamedQueryIds()); + self::assertCount(2, $result->getNamedQueryIds()); + self::assertSame('iad-tok1n253', $result->getNextToken()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/ListQueryExecutionsOutputTest.php b/src/Service/Athena/tests/Unit/Result/ListQueryExecutionsOutputTest.php new file mode 100644 index 000000000..e50e1ceea --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/ListQueryExecutionsOutputTest.php @@ -0,0 +1,31 @@ +request('POST', 'http://localhost'), $client, new NullLogger()), new AthenaClient(), new ListQueryExecutionsInput([])); + + self::assertCount(1, $result->getQueryExecutionIds()); + self::assertSame('iad-tok1n255', $result->getNextToken()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/ListTableMetadataOutputTest.php b/src/Service/Athena/tests/Unit/Result/ListTableMetadataOutputTest.php new file mode 100644 index 000000000..a03020c5b --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/ListTableMetadataOutputTest.php @@ -0,0 +1,69 @@ +request( + 'POST', + 'http://localhost'), + $client, + new NullLogger()), + new AthenaClient(), + new ListTableMetadataInput([ + 'CatalogName' => 'iadCatalog', + 'DatabaseName' => 'iadDatbase', + ]) + ); + + self::assertIsIterable($result->getTableMetadataList()); + self::assertCount(1, $result->getTableMetadataList()); + self::assertArrayHasKey('TableType', $result->getTableMetadataList()); + self::assertSame('iad-tok1n256', $result->getNextToken()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/StartCalculationExecutionResponseTest.php b/src/Service/Athena/tests/Unit/Result/StartCalculationExecutionResponseTest.php new file mode 100644 index 000000000..3c29f7253 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/StartCalculationExecutionResponseTest.php @@ -0,0 +1,28 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertSame('uid-40555-5df4556', $result->getCalculationExecutionId()); + self::assertSame('QUEUED', $result->getState()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/StartQueryExecutionOutputTest.php b/src/Service/Athena/tests/Unit/Result/StartQueryExecutionOutputTest.php new file mode 100644 index 000000000..21eb48805 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/StartQueryExecutionOutputTest.php @@ -0,0 +1,26 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertSame('query-1428', $result->getQueryExecutionId()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/StartSessionResponseTest.php b/src/Service/Athena/tests/Unit/Result/StartSessionResponseTest.php new file mode 100644 index 000000000..23bf84a52 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/StartSessionResponseTest.php @@ -0,0 +1,28 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertSame('iad-session-12540', $result->getSessionId()); + self::assertSame('IDLE', $result->getState()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/StopCalculationExecutionResponseTest.php b/src/Service/Athena/tests/Unit/Result/StopCalculationExecutionResponseTest.php new file mode 100644 index 000000000..63db53a7d --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/StopCalculationExecutionResponseTest.php @@ -0,0 +1,26 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertSame('CANCELING', $result->getState()); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/StopQueryExecutionOutputTest.php b/src/Service/Athena/tests/Unit/Result/StopQueryExecutionOutputTest.php new file mode 100644 index 000000000..712c81585 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/StopQueryExecutionOutputTest.php @@ -0,0 +1,24 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertFalse($result->info()['resolved']); + } +} diff --git a/src/Service/Athena/tests/Unit/Result/TerminateSessionResponseTest.php b/src/Service/Athena/tests/Unit/Result/TerminateSessionResponseTest.php new file mode 100644 index 000000000..485852d44 --- /dev/null +++ b/src/Service/Athena/tests/Unit/Result/TerminateSessionResponseTest.php @@ -0,0 +1,27 @@ +request('POST', 'http://localhost'), $client, new NullLogger())); + + self::assertSame('TERMINATING', $result->getState()); + self::assertTrue($result->info()['resolved']); + } +}