Skip to content

Commit

Permalink
Merge pull request #422 from nextcloud/dependabot/composer/aws/aws-sd…
Browse files Browse the repository at this point in the history
…k-php-3.133.27
  • Loading branch information
dependabot-preview[bot] committed Mar 6, 2020
2 parents 97fb70b + d51e03a commit a70e51b
Show file tree
Hide file tree
Showing 256 changed files with 4,886 additions and 41 deletions.
157 changes: 157 additions & 0 deletions aws/aws-sdk-php/src/AbstractConfigurationProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?php
namespace Aws;

use GuzzleHttp\Promise;

/**
* A configuration provider is a function that returns a promise that is
* fulfilled with a configuration object. This class provides base functionality
* usable by specific configuration provider implementations
*/
abstract class AbstractConfigurationProvider
{
const ENV_PROFILE = 'AWS_PROFILE';
const ENV_CONFIG_FILE = 'AWS_CONFIG_FILE';

public static $cacheKey;

protected static $interfaceClass;
protected static $exceptionClass;

/**
* Wraps a config provider and saves provided configuration in an
* instance of Aws\CacheInterface. Forwards calls when no config found
* in cache and updates cache with the results.
*
* @param callable $provider Configuration provider function to wrap
* @param CacheInterface $cache Cache to store configuration
* @param string|null $cacheKey (optional) Cache key to use
*
* @return callable
*/
public static function cache(
callable $provider,
CacheInterface $cache,
$cacheKey = null
) {
$cacheKey = $cacheKey ?: static::$cacheKey;

return function () use ($provider, $cache, $cacheKey) {
$found = $cache->get($cacheKey);
if ($found instanceof static::$interfaceClass) {
return Promise\promise_for($found);
}

return $provider()
->then(function ($config) use (
$cache,
$cacheKey
) {
$cache->set($cacheKey, $config);
return $config;
});
};
}

/**
* Creates an aggregate configuration provider that invokes the provided
* variadic providers one after the other until a provider returns
* configuration.
*
* @return callable
*/
public static function chain()
{
$links = func_get_args();
if (empty($links)) {
throw new \InvalidArgumentException('No providers in chain');
}

return function () use ($links) {
/** @var callable $parent */
$parent = array_shift($links);
$promise = $parent();
while ($next = array_shift($links)) {
$promise = $promise->otherwise($next);
}
return $promise;
};
}

/**
* Gets the environment's HOME directory if available.
*
* @return null|string
*/
protected static function getHomeDir()
{
// On Linux/Unix-like systems, use the HOME environment variable
if ($homeDir = getenv('HOME')) {
return $homeDir;
}

// Get the HOMEDRIVE and HOMEPATH values for Windows hosts
$homeDrive = getenv('HOMEDRIVE');
$homePath = getenv('HOMEPATH');

return ($homeDrive && $homePath) ? $homeDrive . $homePath : null;
}

/**
* Gets default config file location from environment, falling back to aws
* default location
*
* @return string
*/
protected static function getDefaultConfigFilename()
{
if ($filename = getenv(self::ENV_CONFIG_FILE)) {
return $filename;
}
return self::getHomeDir() . '/.aws/config';
}

/**
* Wraps a config provider and caches previously provided configuration.
*
* @param callable $provider Config provider function to wrap.
*
* @return callable
*/
public static function memoize(callable $provider)
{
return function () use ($provider) {
static $result;
static $isConstant;

// Constant config will be returned constantly.
if ($isConstant) {
return $result;
}

// Create the initial promise that will be used as the cached value
if (null === $result) {
$result = $provider();
}

// Return config and set flag that provider is already set
return $result
->then(function ($config) use (&$isConstant) {
$isConstant = true;
return $config;
});
};
}

/**
* Reject promise with standardized exception.
*
* @param $msg
* @return Promise\RejectedPromise
*/
protected static function reject($msg)
{
$exceptionClass = static::$exceptionClass;
return new Promise\RejectedPromise(new $exceptionClass($msg));
}
}
45 changes: 45 additions & 0 deletions aws/aws-sdk-php/src/AccessAnalyzer/AccessAnalyzerClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
namespace Aws\AccessAnalyzer;

use Aws\AwsClient;

/**
* This client is used to interact with the **Access Analyzer** service.
* @method \Aws\Result createAnalyzer(array $args = [])
* @method \GuzzleHttp\Promise\Promise createAnalyzerAsync(array $args = [])
* @method \Aws\Result createArchiveRule(array $args = [])
* @method \GuzzleHttp\Promise\Promise createArchiveRuleAsync(array $args = [])
* @method \Aws\Result deleteAnalyzer(array $args = [])
* @method \GuzzleHttp\Promise\Promise deleteAnalyzerAsync(array $args = [])
* @method \Aws\Result deleteArchiveRule(array $args = [])
* @method \GuzzleHttp\Promise\Promise deleteArchiveRuleAsync(array $args = [])
* @method \Aws\Result getAnalyzedResource(array $args = [])
* @method \GuzzleHttp\Promise\Promise getAnalyzedResourceAsync(array $args = [])
* @method \Aws\Result getAnalyzer(array $args = [])
* @method \GuzzleHttp\Promise\Promise getAnalyzerAsync(array $args = [])
* @method \Aws\Result getArchiveRule(array $args = [])
* @method \GuzzleHttp\Promise\Promise getArchiveRuleAsync(array $args = [])
* @method \Aws\Result getFinding(array $args = [])
* @method \GuzzleHttp\Promise\Promise getFindingAsync(array $args = [])
* @method \Aws\Result listAnalyzedResources(array $args = [])
* @method \GuzzleHttp\Promise\Promise listAnalyzedResourcesAsync(array $args = [])
* @method \Aws\Result listAnalyzers(array $args = [])
* @method \GuzzleHttp\Promise\Promise listAnalyzersAsync(array $args = [])
* @method \Aws\Result listArchiveRules(array $args = [])
* @method \GuzzleHttp\Promise\Promise listArchiveRulesAsync(array $args = [])
* @method \Aws\Result listFindings(array $args = [])
* @method \GuzzleHttp\Promise\Promise listFindingsAsync(array $args = [])
* @method \Aws\Result listTagsForResource(array $args = [])
* @method \GuzzleHttp\Promise\Promise listTagsForResourceAsync(array $args = [])
* @method \Aws\Result startResourceScan(array $args = [])
* @method \GuzzleHttp\Promise\Promise startResourceScanAsync(array $args = [])
* @method \Aws\Result tagResource(array $args = [])
* @method \GuzzleHttp\Promise\Promise tagResourceAsync(array $args = [])
* @method \Aws\Result untagResource(array $args = [])
* @method \GuzzleHttp\Promise\Promise untagResourceAsync(array $args = [])
* @method \Aws\Result updateArchiveRule(array $args = [])
* @method \GuzzleHttp\Promise\Promise updateArchiveRuleAsync(array $args = [])
* @method \Aws\Result updateFindings(array $args = [])
* @method \GuzzleHttp\Promise\Promise updateFindingsAsync(array $args = [])
*/
class AccessAnalyzerClient extends AwsClient {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace Aws\AccessAnalyzer\Exception;

use Aws\Exception\AwsException;

/**
* Represents an error interacting with the **Access Analyzer** service.
*/
class AccessAnalyzerException extends AwsException {}
94 changes: 94 additions & 0 deletions aws/aws-sdk-php/src/Api/ErrorParser/AbstractErrorParser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
namespace Aws\Api\ErrorParser;

use Aws\Api\Parser\MetadataParserTrait;
use Aws\Api\Parser\PayloadParserTrait;
use Aws\Api\Service;
use Aws\Api\StructureShape;
use Aws\CommandInterface;
use Psr\Http\Message\ResponseInterface;

abstract class AbstractErrorParser
{
use MetadataParserTrait;
use PayloadParserTrait;

/**
* @var Service
*/
protected $api;

/**
* @param Service $api
*/
public function __construct(Service $api = null)
{
$this->api = $api;
}

abstract protected function payload(
ResponseInterface $response,
StructureShape $member
);

protected function extractPayload(
StructureShape $member,
ResponseInterface $response
) {
if ($member instanceof StructureShape) {
// Structure members parse top-level data into a specific key.
return $this->payload($response, $member);
} else {
// Streaming data is just the stream from the response body.
return $response->getBody();
}
}

protected function populateShape(
array &$data,
ResponseInterface $response,
CommandInterface $command = null
) {
$data['body'] = [];

if (!empty($command) && !empty($this->api)) {

// If modeled error code is indicated, check for known error shape
if (!empty($data['code'])) {

$errors = $this->api->getOperation($command->getName())->getErrors();
foreach ($errors as $key => $error) {

// If error code matches a known error shape, populate the body
if ($data['code'] == $error['name']
&& $error instanceof StructureShape
) {
$modeledError = $error;
$data['body'] = $this->extractPayload(
$modeledError,
$response
);

foreach ($error->getMembers() as $name => $member) {
switch ($member['location']) {
case 'header':
$this->extractHeader($name, $member, $response, $data['body']);
break;
case 'headers':
$this->extractHeaders($name, $member, $response, $data['body']);
break;
case 'statusCode':
$this->extractStatus($name, $response, $data['body']);
break;
}
}

break;
}
}
}
}

return $data;
}
}
Loading

0 comments on commit a70e51b

Please sign in to comment.