Skip to content

Commit b8c337c

Browse files
committed
async_aws (Athena Client): create aws Athena Client with somes operations
1 parent 7a8cf5a commit b8c337c

File tree

160 files changed

+11075
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+11075
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ See full documentation on [https://async-aws.com](https://async-aws.com).
1212
| --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1313
| [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) |
1414
| [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) |
15+
| [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) |
1516
| [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) |
1617
| [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) |
1718
| [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) |

composer.json

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"autoload": {
5050
"psr-4": {
5151
"AsyncAws\\AppSync\\": "src/Service/AppSync/src",
52+
"AsyncAws\\Athena\\": "src/Service/Athena/src",
5253
"AsyncAws\\CloudFormation\\": "src/Service/CloudFormation/src",
5354
"AsyncAws\\CloudFront\\": "src/Service/CloudFront/src",
5455
"AsyncAws\\CloudWatchLogs\\": "src/Service/CloudWatchLogs/src",
@@ -100,6 +101,7 @@
100101
"autoload-dev": {
101102
"psr-4": {
102103
"AsyncAws\\AppSync\\Tests\\": "src/Service/AppSync/tests",
104+
"AsyncAws\\Athena\\Tests\\": "src/Service/Athena/tests",
103105
"AsyncAws\\CloudFormation\\Tests\\": "src/Service/CloudFormation/tests",
104106
"AsyncAws\\CloudFront\\Tests\\": "src/Service/CloudFront/tests",
105107
"AsyncAws\\CloudWatchLogs\\Tests\\": "src/Service/CloudWatchLogs/tests",

couscous.yml

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ menu:
3434
app-sync:
3535
text: AppSync
3636
url: /clients/app-sync.html
37+
athena:
38+
text: Athena
39+
url: /clients/athena.html
3740
cf:
3841
text: Cloud Formation
3942
url: /clients/cf.html

docs/clients/athena.md

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
layout: client
3+
category: clients
4+
name: Athena
5+
package: async-aws/athena
6+
---
7+
8+
## Usage
9+
10+
### List Databases
11+
12+
```php
13+
use AsyncAws\Athena\AthenaClient;
14+
use AsyncAws\Athena\Input\ListDatabasesInput;
15+
16+
$athena = new AthenaClient();
17+
18+
$result = $athena->listDatabases(new ListDatabasesInput([
19+
'CatalogName' => 'my_catalog'
20+
]));
21+
22+
foreach ($result->getDatabaseList() as $database) {
23+
echo 'Database name : ' . $database->getName();
24+
echo 'Database description : ' . $database->getDescription();
25+
echo 'Database parameter : '.PHP_EOL;
26+
print_r($database->getParameters());
27+
}
28+
29+
```
30+
more information [listDatabases](https://docs.aws.amazon.com/athena/latest/APIReference/API_ListDatabases.html)
31+
32+
### Query to Amazon Athena
33+
34+
```php
35+
use AsyncAws\Athena\AthenaClient;
36+
use AsyncAws\Athena\Input\StartQueryExecutionInput;
37+
use AsyncAws\Athena\Input\DescribeTableInput;
38+
use AsyncAws\Athena\ValueObject\QueryExecutionContext;
39+
use AsyncAws\Athena\ValueObject\ResultConfiguration;
40+
use AsyncAws\Athena\ValueObject\EncryptionConfiguration;
41+
use AsyncAws\Athena\ValueObject\AclConfiguration;
42+
use AsyncAws\Athena\ValueObject\ResultReuseByAgeConfiguration;
43+
use AsyncAws\Athena\Input\GetQueryExecutionInput;
44+
use AsyncAws\Athena\Input\GetQueryResultsInput;
45+
use AsyncAws\Athena\ValueObject\Row;
46+
use AsyncAws\Athena\ValueObject\Datum;
47+
use AsyncAws\Athena\Enum\QueryExecutionState;
48+
49+
$athena = new AthenaClient();
50+
51+
// Submits a sample query to Amazon Athena and returns the execution ID of the query.
52+
$startQueryResult = $athena->startQueryExecution(new StartQueryExecutionInput([
53+
'QueryString' => 'select * from product limit 30',
54+
'QueryExecutionContext' => new QueryExecutionContext([
55+
'Database' => 'production_db', // REQUIRED
56+
]),
57+
'ResultConfiguration' => new ResultConfiguration([
58+
'OutputLocation' => 's3://output_bucket_Location', // REQUIRED
59+
'EncryptionConfiguration' => new EncryptionConfiguration([
60+
'EncryptionOption' => 'SSE_S3', // REQUIRED SSE_S3|SSE_KMS|CSE_KMS
61+
])
62+
]),
63+
]));
64+
65+
66+
// Wait for an Amazon Athena query to complete, fail or to be cancelled.
67+
$isQueryStillRunning = true;
68+
while ($isQueryStillRunning) {
69+
$queryExecutionResult = $athena->getQueryExecution( new GetQueryExecutionInput([
70+
'QueryExecutionId' => $startQueryResult->getQueryExecutionId(), // REQUIRED
71+
]));
72+
$queryState=$queryExecutionResult->getQueryExecution()->getStatus()->getState();
73+
if($queryState === QueryExecutionState::FAILED) {
74+
throw new \Exception(
75+
'Athena query failed to run with error message: '.$queryExecutionResult->getQueryExecution()->getStatus()->getStateChangeReason()
76+
)
77+
} elseif ($queryState === QueryExecutionState::CANCELLED) {
78+
throw new \Exception('Athena query was cancelled.')
79+
} elseif ($queryState === QueryExecutionState::SUCCEEDED) {
80+
$isQueryStillRunning = false;
81+
}
82+
echo 'The current status is: : ' . $queryState;
83+
}
84+
85+
86+
// retrieves the results of a query
87+
$results = $athena->getQueryResults(new GetQueryResultsInput([
88+
'QueryExecutionId' => $startQueryResult->getQueryExecutionId(),
89+
'MaxResults' => 10000
90+
]));
91+
92+
/** @var Row $row */
93+
foreach ($results => $row) {
94+
if ($index === 0) {
95+
$columnLabels = array_column($row->getData(), 'VarCharValue'); // $row->getData() return [ 'VarCharValue' => value]
96+
}
97+
$columnValues[] = array_column($row->getData(), 'VarCharValue');
98+
}
99+
100+
// retrieves the results column structure details
101+
$columnsDetail = $result->getResultSet()->getResultSetMetadata()->getColumnInfo();
102+
103+
print_r($columnsDetail);
104+
```

docs/clients/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ for more information.
138138
| Api Client | Package name |
139139
| ------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
140140
| [AppSync](./app-sync.md) | [async-aws/app-sync](https://packagist.org/packages/async-aws/app-sync) |
141+
| [Athena](./athena.md) | [async-aws/athena](https://packagist.org/packages/async-aws/athena) |
141142
| [CloudFormation](./cf.md) | [async-aws/cloud-formation](https://packagist.org/packages/async-aws/cloud-formation) |
142143
| [CloudFront](./cloud-front.md) | [async-aws/cloud-front](https://packagist.org/packages/async-aws/cloud-front) |
143144
| [CloudWatch](./cloud-watch.md) | [async-aws/cloud-watch](https://packagist.org/packages/async-aws/cloud-watch) |

manifest.json

+42
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,48 @@
2222
"UpdateResolver"
2323
]
2424
},
25+
"Athena": {
26+
"source": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/api-2.json",
27+
"documentation": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/docs-2.json",
28+
"pagination": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/paginators-1.json",
29+
"endpoint-rule-set": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/endpoint-rule-set-1.json",
30+
"endpoint-tests": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/endpoint-tests-1.json",
31+
"example": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/examples-1.json",
32+
"smoke": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/athena/2017-05-18/smoke.json",
33+
"api-reference": "https://docs.aws.amazon.com/athena/latest/APIReference",
34+
"methods": [
35+
"GetCalculationExecution",
36+
"GetCalculationExecutionStatus",
37+
"GetDataCatalog",
38+
"GetDatabase",
39+
"GetNamedQuery",
40+
"GetQueryExecution",
41+
"GetQueryResults",
42+
"GetSession",
43+
"GetSessionStatus",
44+
"GetTableMetadata",
45+
"GetWorkGroup",
46+
"ListDatabases",
47+
"ListNamedQueries",
48+
"ListQueryExecutions",
49+
"ListTableMetadata",
50+
"StartCalculationExecution",
51+
"StartQueryExecution",
52+
"StartSession",
53+
"StopCalculationExecution",
54+
"StopQueryExecution",
55+
"TerminateSession"
56+
],
57+
"patches": {
58+
"pagination": [
59+
{
60+
"value": "ResultSet.Rows",
61+
"op": "add",
62+
"path": "/pagination/GetQueryResults/result_key"
63+
}
64+
]
65+
}
66+
},
2567
"CloudFormation": {
2668
"source": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/cloudformation/2010-05-15/api-2.json",
2769
"documentation": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/cloudformation/2010-05-15/docs-2.json",

phpstan.neon.dist

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ parameters:
3131
paths:
3232
- src/Core/src/Sts/ValueObject
3333
- src/Service/AppSync/src/ValueObject
34+
- src/Service/Athena/src/ValueObject
3435
- src/Service/CodeBuild/src/ValueObject
3536
- src/Service/CodeCommit/src/ValueObject
3637
- src/Service/CloudFormation/src/ValueObject

src/Core/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## NOT RELEASED
44

5+
## 1.19.0
6+
7+
### Added
8+
9+
- Support for Athena
10+
- AWS enhancement: Documentation updates.
11+
512
## 1.18.1
613

714
### Changed

src/Core/src/AwsClientFactory.php

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace AsyncAws\Core;
66

77
use AsyncAws\AppSync\AppSyncClient;
8+
use AsyncAws\Athena\AthenaClient;
89
use AsyncAws\CloudFormation\CloudFormationClient;
910
use AsyncAws\CloudFront\CloudFrontClient;
1011
use AsyncAws\CloudWatch\CloudWatchClient;
@@ -576,4 +577,17 @@ public function cognitoIdentityProvider(): CognitoIdentityProviderClient
576577

577578
return $this->serviceCache[__METHOD__];
578579
}
580+
581+
public function athena(): AthenaClient
582+
{
583+
if (!class_exists(AthenaClient::class)) {
584+
throw MissingDependency::create('async-aws/athena', 'Athena');
585+
}
586+
587+
if (!isset($this->serviceCache[__METHOD__])) {
588+
$this->serviceCache[__METHOD__] = new AthenaClient($this->configuration, $this->credentialProvider, $this->httpClient, $this->logger);
589+
}
590+
591+
return $this->serviceCache[__METHOD__];
592+
}
579593
}

src/Integration/Symfony/Bundle/src/DependencyInjection/AwsPackagesProvider.php

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public static function getAllServices(): array
1313
'class' => \AsyncAws\AppSync\AppSyncClient::class,
1414
'package' => 'async-aws/app-sync',
1515
],
16+
'athena' => [
17+
'class' => \AsyncAws\Athena\AthenaClient::class,
18+
'package' => 'async-aws/athena',
19+
],
1620
'cloud_formation' => [
1721
'class' => \AsyncAws\CloudFormation\CloudFormationClient::class,
1822
'package' => 'async-aws/cloud-formation',

src/Service/Athena/.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.github export-ignore
2+
/tests export-ignore
3+
/.gitignore export-ignore
4+
/Makefile export-ignore
5+
/phpunit.xml.dist export-ignore
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [nyholm, jderusse]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[*.yml]
2+
indent_size = 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Update branch alias
2+
3+
on:
4+
push:
5+
tags: ['*']
6+
7+
jobs:
8+
branch-alias:
9+
name: Update branch alias
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Set up PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: 8.1
17+
coverage: none
18+
19+
- name: Find branch alias
20+
id: find_alias
21+
run: |
22+
TAG=$(echo $GITHUB_REF | cut -d'/' -f 3)
23+
echo "Last tag was $TAG"
24+
ARR=(${TAG//./ })
25+
ARR[1]=$((${ARR[1]}+1))
26+
echo ::set-output name=alias::${ARR[0]}.${ARR[1]}
27+
28+
- name: Checkout main repo
29+
run: |
30+
git clone --branch master https://${{ secrets.BOT_GITHUB_TOKEN }}:[email protected]/async-aws/aws aws
31+
32+
- name: Update branch alias
33+
run: |
34+
cd aws/src/Service/Athena
35+
CURRENT_ALIAS=$(composer config extra.branch-alias.dev-master | cut -d'-' -f 1)
36+
37+
# If there is a current value on the branch alias
38+
if [ ! -z $CURRENT_ALIAS ]; then
39+
NEW_ALIAS=${{ steps.find_alias.outputs.alias }}
40+
CURRENT_ARR=(${CURRENT_ALIAS//./ })
41+
NEW_ARR=(${NEW_ALIAS//./ })
42+
43+
if [ ${CURRENT_ARR[0]} -gt ${NEW_ARR[0]} ]; then
44+
echo "The current value for major version is larger"
45+
exit 1;
46+
fi
47+
48+
if [ ${CURRENT_ARR[0]} -eq ${NEW_ARR[0]} ] && [ ${CURRENT_ARR[1]} -gt ${NEW_ARR[1]} ]; then
49+
echo "The current value for minor version is larger"
50+
exit 1;
51+
fi
52+
fi
53+
54+
composer config extra.branch-alias.dev-master ${{ steps.find_alias.outputs.alias }}-dev
55+
56+
- name: Commit & push the new files
57+
run: |
58+
echo "::group::git status"
59+
cd aws
60+
git status
61+
echo "::endgroup::"
62+
63+
git add -N .
64+
if [[ $(git diff --numstat | wc -l) -eq 0 ]]; then
65+
echo "No changes found. Exiting."
66+
exit 0;
67+
fi
68+
69+
git config --local user.email "[email protected]"
70+
git config --local user.name "AsyncAws Bot"
71+
72+
echo "::group::git push"
73+
git add .
74+
git commit -m "Update branch alias"
75+
git push
76+
echo "::endgroup::"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: BC Check
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
roave-bc-check:
10+
name: Roave BC Check
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- name: Modify composer.json
18+
run: |
19+
sed -i -re 's/"require": \{/"minimum-stability": "dev","prefer-stable": true,"require": \{/' composer.json
20+
cat composer.json
21+
22+
git config --local user.email "[email protected]"
23+
git config --local user.name "AsyncAws Bot"
24+
git commit -am "Allow unstable dependencies"
25+
26+
- name: Roave BC Check
27+
uses: docker://nyholm/roave-bc-check-ga

0 commit comments

Comments
 (0)