GithubHelp home page GithubHelp logo

async-aws / aws Goto Github PK

View Code? Open in Web Editor NEW
423.0 12.0 125.0 9.99 MB

AWS SDK with readable code and async responses

Home Page: https://async-aws.com

License: MIT License

PHP 99.65% Makefile 0.15% JavaScript 0.07% SCSS 0.07% Twig 0.06%
aws async hacktoberfest

aws's Introduction

aws's People

Contributors

amenophis avatar async-aws-bot avatar bendavies avatar dukecz avatar ferror avatar grahamcampbell avatar gromnan avatar guillaumesmo avatar hmazter avatar ionbazan avatar jderusse avatar jean85 avatar jmariller avatar karamokobad avatar martinssipenko avatar maxon755 avatar michealmouner avatar misantron avatar mu1f407 avatar nealio82 avatar ngourle avatar nickaguilarh avatar nicolas-grekas avatar nyholm avatar pableu avatar rmikalkenas avatar smoench avatar stof avatar sunkan avatar tyx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws's Issues

Assert file is valid when dumping code

Notging prevent dumping an invalid file which leads to uncompilable-file.

This could be avoided by linting the code (php -l) after dumping it, and reverting the file in case of issue.

Implement all "incomplete tests"

There are test stubs that needs some love. Basically:

  1. Add some Input data and verify the HTTP request
  2. Add some HTTP response data and very Result
  • CloudFormation
  • S3
  • Ses
  • Sns
  • Sts
  • Sqs
  • Lambda

Screenshot 2020-02-23 at 18 55 50

Dont throw exception twice

If an exception is thrown on ->resolve(), it can be caught. But then on __destruct(), we will call resolve again and a new message is thrown.

Future idea: Automatic releases

We could do automatic minor releases every Wednesday if all of this conditions are true:

  • The only changes made are from the github action bot
  • The BC check is green
  • The CI check is green
  • If it is a AWS autogenerated service, (sqs, s3, etc)

Questions:

  • How to write with change logs?
  • Should it be minor releases?

Handle Enum

The api2-json file provides hints on enum. (ie. the Runtime Type in in Lambda)

We should:

  • provide const for the values
  • take those value in "validators"
class ListLayerVersionsRequest
{
    /**
     * A runtime identifier. For example, `go1.x`.
     *
     * @var string|null
     */
    private $CompatibleRuntime;

    public function validate(): void
    {
        foreach ($this->CompatibleRuntime as $value) {
            if (!isset(Runtime::AVAILABLE_RUNTIMES[$value])) {
                throw new InvalidArgument(sprintf('The CompatibleRuntime "%s" in "%s" is not a Valide "Runtime". Available values are "%"', $value, __CLASS__, array_keys(Runtime::AVAILABLE_RUNTIMES)));
            }
        }
    }
}

// Class is named "Runtime" because of the name of the shape
class Runtime 
{
    public const NODEJS = 'nodejs';
    public const NODEJS_4_3 = 'nodejs4.3';
    public const NODEJS_6_10 = 'nodejs6.10';
    public const NODEJS_4_3_EDGE = 'nodejs4.3-edge';
    // ..

    // = "AVAILABLE_" + className.upper()
    public const AVAILABLE_RUNTIME = [
        self::NODEJS = true,
        self::NODEJS_4_3 = true,
        self::NODEJS_6_10 = true,
        self::NODEJS_4_3_EDGE = true,
        // ..
    ];
}

Start using changelogs

Should we do it the symfony way? Ie both changelog in root and individual packages?

Alternatively we can just put changlog on the packages.

Use official SDK to build Objects

The official SDK contains JSON file describing every method/request/response

ie. https://github.com/aws/aws-sdk-php/blob/efdbdde0968355917470a255c0d2e509c49f7476/src/data/sqs/2012-11-05/api-2.json#L214-L229

To provide a library compatible with official Documentation, I suggest to use those files to generates our DTO/Objects.

The content of simple-aws is:

  • low level logic to perform request, deal with response, authentication, pagination
  • a developper tool to generate the Request/Response Functions based on SDK JSON files (similar to https://github.com/thecodingmachine/safe)

Optionnaly it will also provides:

  • helper classes that provides a non-official but more friendly contract ($s3->putFile($path)) (ie like psr/cache vs psr/simple-cache)

What do you think?

Look for datatype "map"

We look for "structure" or "list" on many places, but we fail to look for "map".

We should always consider these 3 types of combined types.

[S3] How to create a directory

The following code:

require_once __DIR__.'/vendor/autoload.php';

$s3 = new \AsyncAws\S3\S3Client([
    'region' => 'eu-central-1',
]);
$bucket = 'async-aws-test';

$result = $s3->putObject([
    'Bucket' => $bucket,
    'Key' => 'foo/',
]);

$result->resolve();

Will give:

Uncaught AsyncAws\Core\Exception\Http\ClientException: HTTP/1.1 411 Length Required returned for "https://s3.eu-central-1.amazonaws.com/async-aws-test/foo/".

Configuration Fallback misbehaving

I have a Bref based lambda function processing files stored in an s3 bucket on object creation events. Files are accessed via Flysystem v2.

Composer require:

"bref/bref": "^0.5.16",
"async-aws/flysystem-s3": "^0.2.0",

When creating the S3Client I'm using these params:

$client = new S3Client([
    'accessKeyId' => $config['username'],
    'accessKeySecret' => $config['password'],
    'region' => $config['region'],
]);

When trying to list files I'm getting this error

Code: InvalidToken
Message: The provided token is malformed or otherwise invalid.

From what I see in async-aws/core Configuration.php falls back to all env vars if an option is not specified. The Lambda has env vars for

AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN

but I'm using a different user for accessing the s3 bucket when creating the client. I think when doing so the Configuration should not use the sessionToken from env vars.

Support for streamable input

It is just a minor thing. We should remove return type hint on parameters like PutObjectRequest::getBody().

We should also update the constructor doc block.

The correct signature is array|string|resource|\Traversable|\Closure

Handle "Metadata"

On the S3 HeadObjectOutput there is a parameter "Metadata" that is never set.

I think, that all parameters on the object is the metadata..

Should Result::$client be private?

The AsyncAws\Core\Result has some private properties and some protected. Should we be consistent with these?

Should we be defensive and do all private?

Or are we okey with using protected?

Restructure file hierarchy

├── CHANGELOG.md
├── composer.json
├── docs
│   ├── authentication.md
│   ├── ...
│   └── waiter.md
└── src
    ├── CodeGenerator
    ├── Core
    ├── Service
    │   ├── CloudFormation
    │   ├── Lambda
    │   ├── S3
    │   ├── Ses
    │   ├── Sns
    │   └── Sqs
    └── Integration
        ├── Flysystem
        |   └── S3
        └── Symfony
            ├── SqsTransport
            └── Bundle

Find a solution for steaming responses

Currently, the only way to stream a response is to:

$result = ...;
$info = $result->getInfo();
foreach($httpClient->stream($info['response']) as $chunk) {
  // ...
}

Do we want to provide a better way?

How to test PRs?

If someone submit a PR with a patch for a bug, how can that be tested before the PR is merged?

`sendMessage` method not found when mocking `SqsClient`

When trying to mock SqsClient from the official AWS SDK i get the following error:

Trying to configure method "sendMessage" which cannot be configured because it does not exist, has not been specified, is final, or is static

because the method does not belong class but is somehow added to it. Please keep this in mind when releasing the stable version and dont make the same structure as the official SDK.

[Automatic PR] What if PR is not merged

What if:

Day 0: Update in official SDK
Day 1: Bot creates a PR with updates
Day 2: We still dont merge that PR
Day 3: Update in official SDK
Day 4: ??

Will the PR be updated?
Will a new PR be created?

What if we merge the PR but not delete the branch?

Hide "promise/async" complexity

I like the way symfony/http-client handle async calls, by processing the call when needed and hiding the complexity to the user.

as a user, I'd love to use something like:

$bucket = '...';
$client = (new AwsClient())->s3();
$objects = $client->listObjects(['bucket' => $bucket]);  // async 

// do something else...

foreach ($objects as $object) { // listObjects resolved here
  $client->deleteObject(['bucket' => $bucket, 'key' => $objet->getKey()]); // async
}

// deletions resolved at destruct

For DX, and IDE autocompletion, I think that each method should return an Dedicated Object with Getter TypeHinted.

$bucket = '...';
$key = '...';

$client = (new AwsClient())->s3();

$object = $client->getObject(['bucket' => $bucket, 'key' => $key']); // async
$object->getContentLength(); // resolved here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.