Skip to content

Commit

Permalink
Added x-ray client (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored Oct 22, 2021
0 parents commit a248d2b
Show file tree
Hide file tree
Showing 24 changed files with 792 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .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 .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 .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 .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.0
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/XRay
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::"
27 changes: 27 additions & 0 deletions .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 "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
38 changes: 38 additions & 0 deletions .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']

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 .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 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 LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2021 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 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 README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# AsyncAws X-Ray Client

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

An API client for XRay.

## Install

```cli
composer require async-aws/x-ray
```

## Documentation

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

## Contribute

Contributions are welcome and appreciated. Please read https://async-aws.com/contribute/
33 changes: 33 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "async-aws/x-ray",
"type": "library",
"description": "XRay client, part of the AWS SDK provided by AsyncAws.",
"keywords": [
"aws",
"amazon",
"sdk",
"async-aws",
"x-ray"
],
"license": "MIT",
"require": {
"php": "^7.2.5 || ^8.0",
"ext-json": "*",
"async-aws/core": "^1.9"
},
"extra": {
"branch-alias": {
"dev-master": "0.1-dev"
}
},
"autoload": {
"psr-4": {
"AsyncAws\\XRay\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"AsyncAws\\XRay\\Tests\\": "tests/"
}
}
}
23 changes: 23 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
>
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
</php>
<testsuites>
<testsuite name="Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
21 changes: 21 additions & 0 deletions src/Exception/InvalidRequestException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace AsyncAws\XRay\Exception;

use AsyncAws\Core\Exception\Http\ClientException;
use Symfony\Contracts\HttpClient\ResponseInterface;

/**
* The request is missing required parameters or has invalid parameters.
*/
final class InvalidRequestException extends ClientException
{
protected function populateResult(ResponseInterface $response): void
{
$data = $response->toArray(false);

if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
$this->message = $v;
}
}
}
21 changes: 21 additions & 0 deletions src/Exception/ThrottledException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace AsyncAws\XRay\Exception;

use AsyncAws\Core\Exception\Http\ClientException;
use Symfony\Contracts\HttpClient\ResponseInterface;

/**
* The request exceeds the maximum number of requests per second.
*/
final class ThrottledException extends ClientException
{
protected function populateResult(ResponseInterface $response): void
{
$data = $response->toArray(false);

if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
$this->message = $v;
}
}
}
Loading

0 comments on commit a248d2b

Please sign in to comment.