Skip to content

Commit

Permalink
Create Translate client (async-aws#1250)
Browse files Browse the repository at this point in the history
* Create Translate client

* Adding tests

* Update psalm baseline

* Updated AwsPackagesProvider.php

* Fixed bugs
  • Loading branch information
Nyholm authored May 28, 2022
1 parent 86f8c8b commit b045443
Show file tree
Hide file tree
Showing 44 changed files with 1,364 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ See full documentation on [https://async-aws.com](https://async-aws.com).
| [async-aws/step-functions](https://github.com/async-aws/step-functions) | [![Latest Stable Version](https://poser.pugx.org/async-aws/step-functions/v/stable)](https://packagist.org/packages/async-aws/step-functions) [![Total Downloads](https://poser.pugx.org/async-aws/step-functions/downloads)](https://packagist.org/packages/async-aws/step-functions) | [![](https://github.com/async-aws/step-functions/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/step-functions/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/step-functions.svg)](https://github.com/async-aws/step-functions/releases)
| [async-aws/timestream-query](https://github.com/async-aws/timestream-query) | [![Latest Stable Version](https://poser.pugx.org/async-aws/timestream-query/v/stable)](https://packagist.org/packages/async-aws/timestream-query) [![Total Downloads](https://poser.pugx.org/async-aws/timestream-query/downloads)](https://packagist.org/packages/async-aws/timestream-query) | [![](https://github.com/async-aws/timestream-query/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/timestream-query/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/timestream-query.svg)](https://github.com/async-aws/timestream-query/releases)
| [async-aws/timestream-write](https://github.com/async-aws/timestream-write) | [![Latest Stable Version](https://poser.pugx.org/async-aws/timestream-write/v/stable)](https://packagist.org/packages/async-aws/timestream-write) [![Total Downloads](https://poser.pugx.org/async-aws/timestream-write/downloads)](https://packagist.org/packages/async-aws/timestream-write) | [![](https://github.com/async-aws/timestream-write/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/timestream-write/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/timestream-write.svg)](https://github.com/async-aws/timestream-write/releases)
| [async-aws/translate](https://github.com/async-aws/translate) | [![Latest Stable Version](https://poser.pugx.org/async-aws/translate/v/stable)](https://packagist.org/packages/async-aws/translate) [![Total Downloads](https://poser.pugx.org/async-aws/translate/downloads)](https://packagist.org/packages/async-aws/translate) | [![](https://github.com/async-aws/translate/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/translate/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/translate.svg)](https://github.com/async-aws/translate/releases)
| [async-aws/x-ray](https://github.com/async-aws/x-ray) | [![Latest Stable Version](https://poser.pugx.org/async-aws/x-ray/v/stable)](https://packagist.org/packages/async-aws/x-ray) [![Total Downloads](https://poser.pugx.org/async-aws/x-ray/downloads)](https://packagist.org/packages/async-aws/x-ray) | [![](https://github.com/async-aws/x-ray/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/x-ray/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/x-ray.svg)](https://github.com/async-aws/x-ray/releases)
| **Integrations** | | | |
| [async-aws/async-aws-bundle](https://github.com/async-aws/symfony-bundle) | [![Latest Stable Version](https://poser.pugx.org/async-aws/async-aws-bundle/v/stable)](https://packagist.org/packages/async-aws/async-aws-bundle) [![Total Downloads](https://poser.pugx.org/async-aws/async-aws-bundle/downloads)](https://packagist.org/packages/async-aws/async-aws-bundle) | [![](https://github.com/async-aws/symfony-bundle/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/symfony-bundle/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/symfony-bundle.svg)](https://github.com/async-aws/symfony-bundle/releases)
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"AsyncAws\\StepFunctions\\": "src/Service/StepFunctions/src",
"AsyncAws\\TimestreamQuery\\": "src/Service/TimestreamQuery/src",
"AsyncAws\\TimestreamWrite\\": "src/Service/TimestreamWrite/src",
"AsyncAws\\Translate\\": "src/Service/Translate/src",
"AsyncAws\\XRay\\": "src/Service/XRay/src",
"AsyncAws\\DynamoDbSession\\": "src/Integration/Aws/DynamoDbSession/src",
"AsyncAws\\Flysystem\\S3\\": "src/Integration/Flysystem/S3/src",
Expand Down Expand Up @@ -124,6 +125,7 @@
"AsyncAws\\StepFunctions\\Tests\\": "src/Service/StepFunctions/tests",
"AsyncAws\\TimestreamQuery\\Tests\\": "src/Service/TimestreamQuery/tests",
"AsyncAws\\TimestreamWrite\\Tests\\": "src/Service/TimestreamWrite/tests",
"AsyncAws\\Translate\\Tests\\": "src/Service/Translate/tests",
"AsyncAws\\XRay\\Tests\\": "src/Service/XRay/tests",
"AsyncAws\\DynamoDbSession\\Tests\\": "src/Integration/Aws/DynamoDbSession/tests",
"AsyncAws\\Flysystem\\S3\\Tests\\": "src/Integration/Flysystem/S3/tests",
Expand Down
3 changes: 3 additions & 0 deletions couscous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ menu:
timestream-write:
text: Timestream Write
url: /clients/timestream-write.html
translate:
text: Translate
url: /clients/translate.html
x-ray:
text: X-Ray
url: /clients/x-ray.html
Expand Down
1 change: 1 addition & 0 deletions docs/clients/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,5 @@ for more information.
| [StepFunctions](./step-functions.md) | [async-aws/step-functions](https://packagist.org/packages/async-aws/step-functions)
| [TimestreamQuery](./timestream-query.md) | [async-aws/timestream-query](https://packagist.org/packages/async-aws/timestream-query)
| [TimestreamWrite](./timestream-write.md) | [async-aws/timestream-write](https://packagist.org/packages/async-aws/timestream-write)
| [Translate](./translate.md) | [async-aws/translate](https://packagist.org/packages/async-aws/translate)
| [XRay](./x-ray.md) | [async-aws/x-ray](https://packagist.org/packages/async-aws/x-ray)
14 changes: 14 additions & 0 deletions docs/clients/translate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
layout: client
category: clients
name: Translate
package: async-aws/translate
---

## Usage

### Write records

```php

```
10 changes: 10 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,16 @@
"WriteRecords"
]
},
"Translate": {
"source": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/translate/2017-07-01/api-2.json",
"documentation": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/translate/2017-07-01/docs-2.json",
"pagination": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/translate/2017-07-01/paginators-1.json",
"namespace": "AsyncAws\\Translate",
"api-reference": "https://docs.aws.amazon.com/translate/latest/dg",
"methods": [
"TranslateText"
]
},
"XRay": {
"source": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/xray/2016-04-12/api-2.json",
"documentation": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/xray/2016-04-12/docs-2.json",
Expand Down
6 changes: 4 additions & 2 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<file src="src/Core/src/AwsClientFactory.php">
<NullableReturnStatement occurrences="32">
<NullableReturnStatement occurrences="33">
<code>$this-&gt;serviceCache[__METHOD__]</code>
<code>$this-&gt;serviceCache[__METHOD__]</code>
<code>$this-&gt;serviceCache[__METHOD__]</code>
<code>$this-&gt;serviceCache[__METHOD__]</code>
Expand Down Expand Up @@ -35,7 +36,8 @@
<code>$this-&gt;serviceCache[__METHOD__]</code>
<code>$this-&gt;serviceCache[__METHOD__]</code>
</NullableReturnStatement>
<PossiblyUndefinedArrayOffset occurrences="32">
<PossiblyUndefinedArrayOffset occurrences="33">
<code>$this-&gt;serviceCache[__METHOD__]</code>
<code>$this-&gt;serviceCache[__METHOD__]</code>
<code>$this-&gt;serviceCache[__METHOD__]</code>
<code>$this-&gt;serviceCache[__METHOD__]</code>
Expand Down
14 changes: 14 additions & 0 deletions src/Core/src/AwsClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use AsyncAws\StepFunctions\StepFunctionsClient;
use AsyncAws\TimestreamQuery\TimestreamQueryClient;
use AsyncAws\TimestreamWrite\TimestreamWriteClient;
use AsyncAws\Translate\TranslateClient;
use AsyncAws\XRay\XRayClient;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
Expand Down Expand Up @@ -481,6 +482,19 @@ public function timestreamWrite(): TimestreamWriteClient
return $this->serviceCache[__METHOD__];
}

public function translate(): TranslateClient
{
if (!class_exists(TranslateClient::class)) {
throw MissingDependency::create('async-aws/translate', 'Translate');
}

if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new TranslateClient($this->configuration, $this->credentialProvider, $this->httpClient, $this->logger);
}

return $this->serviceCache[__METHOD__];
}

public function xRay(): XRayClient
{
if (!class_exists(XRayClient::class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ public static function getAllServices(): array
'class' => \AsyncAws\TimestreamWrite\TimestreamWriteClient::class,
'package' => 'async-aws/timestream-write',
],
'translate' => [
'class' => \AsyncAws\Translate\TranslateClient::class,
'package' => 'async-aws/translate',
],
'x_ray' => [
'class' => \AsyncAws\XRay\XRayClient::class,
'package' => 'async-aws/x-ray',
Expand Down
2 changes: 1 addition & 1 deletion src/Service/.template/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
max-parallel: 10
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']

steps:
- name: Set up PHP
Expand Down
5 changes: 5 additions & 0 deletions src/Service/Translate/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.github export-ignore
/tests export-ignore
/.gitignore export-ignore
/Makefile export-ignore
/phpunit.xml.dist export-ignore
3 changes: 3 additions & 0 deletions src/Service/Translate/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [nyholm, jderusse]
2 changes: 2 additions & 0 deletions src/Service/Translate/.github/workflows/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.yml]
indent_size = 2
76 changes: 76 additions & 0 deletions src/Service/Translate/.github/workflows/branch_alias.yml
Original file line number Diff line number Diff line change
@@ -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 }}:[email protected]/async-aws/aws aws
- name: Update branch alias
run: |
cd aws/src/Service/Translate
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 "[email protected]"
git config --local user.name "AsyncAws Bot"
echo "::group::git push"
git add .
git commit -m "Update branch alias"
git push
echo "::endgroup::"
27 changes: 27 additions & 0 deletions src/Service/Translate/.github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
git config --local user.name "AsyncAws Bot"
git commit -am "Allow unstable dependencies"
- name: Roave BC Check
uses: docker://nyholm/roave-bc-check-ga
38 changes: 38 additions & 0 deletions src/Service/Translate/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions src/Service/Translate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor/
*.cache
composer.lock
7 changes: 7 additions & 0 deletions src/Service/Translate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Change Log

## NOT RELEASED

## 0.1.0

First version
21 changes: 21 additions & 0 deletions src/Service/Translate/LICENSE
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 12 additions & 0 deletions src/Service/Translate/Makefile
Original file line number Diff line number Diff line change
@@ -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"
20 changes: 20 additions & 0 deletions src/Service/Translate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# AsyncAws Translate Client

![](https://github.com/async-aws/translate/workflows/Tests/badge.svg?branch=master)
![](https://github.com/async-aws/translate/workflows/BC%20Check/badge.svg?branch=master)

An API client for Translate.

## Install

```cli
composer require async-aws/translate
```

## Documentation

See https://async-aws.com/clients/translate.html for documentation.

## Contribute

Contributions are welcome and appreciated. Please read https://async-aws.com/contribute/
33 changes: 33 additions & 0 deletions src/Service/Translate/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "async-aws/translate",
"description": "Translate client, part of the AWS SDK provided by AsyncAws.",
"license": "MIT",
"type": "library",
"keywords": [
"aws",
"amazon",
"sdk",
"async-aws",
"translate"
],
"require": {
"php": "^7.2.5 || ^8.0",
"ext-json": "*",
"async-aws/core": "^1.9"
},
"autoload": {
"psr-4": {
"AsyncAws\\Translate\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"AsyncAws\\Translate\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.1-dev"
}
}
}
Loading

0 comments on commit b045443

Please sign in to comment.