diff options
Diffstat (limited to 'vendor/aws/aws-sdk-php/src/ClientResolver.php')
-rw-r--r-- | vendor/aws/aws-sdk-php/src/ClientResolver.php | 242 |
1 files changed, 192 insertions, 50 deletions
diff --git a/vendor/aws/aws-sdk-php/src/ClientResolver.php b/vendor/aws/aws-sdk-php/src/ClientResolver.php index 7943bbc..69f4439 100644 --- a/vendor/aws/aws-sdk-php/src/ClientResolver.php +++ b/vendor/aws/aws-sdk-php/src/ClientResolver.php @@ -1,36 +1,38 @@ <?php namespace Aws; -use Aws\Api\Validator; use Aws\Api\ApiProvider; use Aws\Api\Service; +use Aws\Api\Validator; use Aws\ClientSideMonitoring\ApiCallAttemptMonitoringMiddleware; use Aws\ClientSideMonitoring\ApiCallMonitoringMiddleware; use Aws\ClientSideMonitoring\Configuration; +use Aws\Configuration\ConfigurationResolver; +use Aws\Credentials\CredentialProvider; use Aws\Credentials\Credentials; use Aws\Credentials\CredentialsInterface; +use Aws\DefaultsMode\ConfigurationInterface as ConfigModeInterface; +use Aws\DefaultsMode\ConfigurationProvider as ConfigModeProvider; +use Aws\Endpoint\EndpointProvider; use Aws\Endpoint\PartitionEndpointProvider; -use Aws\Endpoint\UseFipsEndpoint\Configuration as UseFipsEndpointConfiguration; -use Aws\Endpoint\UseFipsEndpoint\ConfigurationProvider as UseFipsConfigProvider; -use Aws\Endpoint\UseFipsEndpoint\ConfigurationInterface as UseFipsEndpointConfigurationInterface; use Aws\Endpoint\UseDualstackEndpoint\Configuration as UseDualStackEndpointConfiguration; -use Aws\Endpoint\UseDualstackEndpoint\ConfigurationProvider as UseDualStackConfigProvider; use Aws\Endpoint\UseDualstackEndpoint\ConfigurationInterface as UseDualStackEndpointConfigurationInterface; +use Aws\Endpoint\UseDualstackEndpoint\ConfigurationProvider as UseDualStackConfigProvider; +use Aws\Endpoint\UseFipsEndpoint\Configuration as UseFipsEndpointConfiguration; +use Aws\Endpoint\UseFipsEndpoint\ConfigurationInterface as UseFipsEndpointConfigurationInterface; +use Aws\Endpoint\UseFipsEndpoint\ConfigurationProvider as UseFipsConfigProvider; use Aws\EndpointDiscovery\ConfigurationInterface; use Aws\EndpointDiscovery\ConfigurationProvider; use Aws\EndpointV2\EndpointDefinitionProvider; +use Aws\Exception\AwsException; use Aws\Exception\InvalidRegionException; use Aws\Retry\ConfigurationInterface as RetryConfigInterface; use Aws\Retry\ConfigurationProvider as RetryConfigProvider; -use Aws\DefaultsMode\ConfigurationInterface as ConfigModeInterface; -use Aws\DefaultsMode\ConfigurationProvider as ConfigModeProvider; use Aws\Signature\SignatureProvider; -use Aws\Endpoint\EndpointProvider; use Aws\Token\Token; use Aws\Token\TokenInterface; use Aws\Token\TokenProvider; use GuzzleHttp\Promise\PromiseInterface; -use Aws\Credentials\CredentialProvider; use InvalidArgumentException as IAE; use Psr\Http\Message\RequestInterface; @@ -66,7 +68,7 @@ class ClientResolver 'type' => 'value', 'valid' => ['string'], 'doc' => 'Exception class to create when an error occurs.', - 'default' => 'Aws\Exception\AwsException', + 'default' => AwsException::class, 'internal' => true ], 'scheme' => [ @@ -81,23 +83,32 @@ class ClientResolver 'doc' => 'Set to true to disable host prefix injection logic for services that use it. This disables the entire prefix injection, including the portions supplied by user-defined parameters. Setting this flag will have no effect on services that do not use host prefix injection.', 'default' => false, ], + 'ignore_configured_endpoint_urls' => [ + 'type' => 'value', + 'valid' => ['bool'], + 'doc' => 'Set to true to disable endpoint urls configured using `AWS_ENDPOINT_URL` and `endpoint_url` shared config option.', + 'fn' => [__CLASS__, '_apply_ignore_configured_endpoint_urls'], + 'default' => [__CLASS__, '_default_ignore_configured_endpoint_urls'], + ], 'endpoint' => [ 'type' => 'value', 'valid' => ['string'], 'doc' => 'The full URI of the webservice. This is only required when connecting to a custom endpoint (e.g., a local version of S3).', 'fn' => [__CLASS__, '_apply_endpoint'], + 'default' => [__CLASS__, '_default_endpoint'] ], 'region' => [ 'type' => 'value', 'valid' => ['string'], - 'required' => [__CLASS__, '_missing_region'], 'doc' => 'Region to connect to. See http://docs.aws.amazon.com/general/latest/gr/rande.html for a list of available regions.', + 'fn' => [__CLASS__, '_apply_region'], + 'default' => [__CLASS__, '_default_region'] ], 'version' => [ 'type' => 'value', 'valid' => ['string'], - 'required' => [__CLASS__, '_missing_version'], 'doc' => 'The version of the webservice to utilize (e.g., 2006-03-01).', + 'default' => 'latest', ], 'signature_provider' => [ 'type' => 'value', @@ -218,6 +229,20 @@ class ClientResolver 'doc' => 'Set to true to display debug information when sending requests. Alternatively, you can provide an associative array with the following keys: logfn: (callable) Function that is invoked with log messages; stream_size: (int) When the size of a stream is greater than this number, the stream data will not be logged (set to "0" to not log any stream data); scrub_auth: (bool) Set to false to disable the scrubbing of auth data from the logged messages; http: (bool) Set to false to disable the "debug" feature of lower level HTTP adapters (e.g., verbose curl output).', 'fn' => [__CLASS__, '_apply_debug'], ], + 'disable_request_compression' => [ + 'type' => 'value', + 'valid' => ['bool', 'callable'], + 'doc' => 'Set to true to disable request compression for supported operations', + 'fn' => [__CLASS__, '_apply_disable_request_compression'], + 'default' => [__CLASS__, '_default_disable_request_compression'], + ], + 'request_min_compression_size_bytes' => [ + 'type' => 'value', + 'valid' => ['int', 'callable'], + 'doc' => 'Set to a value between between 0 and 10485760 bytes, inclusive. This value will be ignored if `disable_request_compression` is set to `true`', + 'fn' => [__CLASS__, '_apply_min_compression_size'], + 'default' => [__CLASS__, '_default_min_compression_size'], + ], 'csm' => [ 'type' => 'value', 'valid' => [\Aws\ClientSideMonitoring\ConfigurationInterface::class, 'callable', 'array', 'bool'], @@ -512,6 +537,51 @@ class ClientResolver } } + public static function _apply_disable_request_compression($value, array &$args) { + if (is_callable($value)) { + $value = $value(); + } + if (!is_bool($value)) { + throw new IAE( + "Invalid configuration value provided for 'disable_request_compression'." + . " value must be a bool." + ); + } + $args['config']['disable_request_compression'] = $value; + } + + public static function _default_disable_request_compression(array &$args) { + return ConfigurationResolver::resolve( + 'disable_request_compression', + false, + 'bool', + $args + ); + } + + public static function _apply_min_compression_size($value, array &$args) { + if (is_callable($value)) { + $value = $value(); + } + if (!is_int($value) + || (is_int($value) + && ($value < 0 || $value > 10485760)) + ) { + throw new IAE(" Invalid configuration value provided for 'min_compression_size_bytes'." + . " value must be an integer between 0 and 10485760, inclusive."); + } + $args['config']['request_min_compression_size_bytes'] = $value; + } + + public static function _default_min_compression_size(array &$args) { + return ConfigurationResolver::resolve( + 'request_min_compression_size_bytes', + 10240, + 'int', + $args + ); + } + public static function _apply_credentials($value, array &$args) { if (is_callable($value)) { @@ -541,7 +611,7 @@ class ClientResolver $args['credentials'] = CredentialProvider::defaultProvider($args); } else { throw new IAE('Credentials must be an instance of ' - . 'Aws\Credentials\CredentialsInterface, an associative ' + . "'" . CredentialsInterface::class . ', an associative ' . 'array that contains "key", "secret", and an optional "token" ' . 'key-value pairs, a credentials provider function, or false.'); } @@ -573,7 +643,7 @@ class ClientResolver $args['token'] = TokenProvider::defaultProvider($args); } else { throw new IAE('Token must be an instance of ' - . 'Aws\Token\TokenInterface, an associative ' + . TokenInterface::class . ', an associative ' . 'array that contains "token" and an optional "expires" ' . 'key-value pairs, a token provider function, or false.'); } @@ -683,12 +753,15 @@ class ClientResolver $args['endpoint'] = $result['endpoint']; - if ( - empty($args['config']['signature_version']) - && isset($result['signatureVersion']) - ) { - $args['config']['signature_version'] - = $result['signatureVersion']; + if (empty($args['config']['signature_version'])) { + if ( + isset($args['api']) + && $args['api']->getSignatureVersion() == 'bearer' + ) { + $args['config']['signature_version'] = 'bearer'; + } elseif (isset($result['signatureVersion'])) { + $args['config']['signature_version'] = $result['signatureVersion']; + } } if ( @@ -852,20 +925,44 @@ class ClientResolver if (function_exists('php_uname') && !in_array('php_uname', $disabledFunctions, true) ) { - $osName = "OS/" . php_uname('s') . '/' . php_uname('r'); + $osName = "OS/" . php_uname('s') . '#' . php_uname('r'); if (!empty($osName)) { $userAgent []= $osName; } } //Add the language version - $userAgent []= 'lang/php/' . phpversion(); + $userAgent []= 'lang/php#' . phpversion(); //Add exec environment if present if ($executionEnvironment = getenv('AWS_EXECUTION_ENV')) { $userAgent []= $executionEnvironment; } + //Add endpoint discovery if set + if (isset($args['endpoint_discovery'])) { + if (($args['endpoint_discovery'] instanceof \Aws\EndpointDiscovery\Configuration + && $args['endpoint_discovery']->isEnabled()) + ) { + $userAgent []= 'cfg/endpoint-discovery'; + } elseif (is_array($args['endpoint_discovery']) + && isset($args['endpoint_discovery']['enabled']) + && $args['endpoint_discovery']['enabled'] + ) { + $userAgent []= 'cfg/endpoint-discovery'; + } + } + + //Add retry mode if set + if (isset($args['retries'])) { + if ($args['retries'] instanceof \Aws\Retry\Configuration) { + $userAgent []= 'cfg/retry-mode#' . $args["retries"]->getMode(); + } elseif (is_array($args['retries']) + && isset($args["retries"]["mode"]) + ) { + $userAgent []= 'cfg/retry-mode#' . $args["retries"]["mode"]; + } + } //Add the input to the end if ($inputUserAgent){ if (!is_array($inputUserAgent)) { @@ -904,6 +1001,11 @@ class ClientResolver public static function _apply_endpoint($value, array &$args, HandlerList $list) { + if (empty($value)) { + unset($args['endpoint']); + return; + } + $args['endpoint'] = $value; } @@ -1027,42 +1129,82 @@ class ClientResolver : $args['region']; } - public static function _missing_version(array $args) + public static function _apply_ignore_configured_endpoint_urls($value, array &$args) { - $service = isset($args['service']) ? $args['service'] : ''; - $versions = ApiProvider::defaultProvider()->getVersions($service); - $versions = implode("\n", array_map(function ($v) { - return "* \"$v\""; - }, $versions)) ?: '* (none found)'; - - return <<<EOT -A "version" configuration value is required. Specifying a version constraint -ensures that your code will not be affected by a breaking change made to the -service. For example, when using Amazon S3, you can lock your API version to -"2006-03-01". - -Your build of the SDK has the following version(s) of "{$service}": {$versions} - -You may provide "latest" to the "version" configuration value to utilize the -most recent available API version that your client's API provider can find. -Note: Using 'latest' in a production application is not recommended. - -A list of available API versions can be found on each client's API documentation -page: http://docs.aws.amazon.com/aws-sdk-php/v3/api/index.html. If you are -unable to load a specific API version, then you may need to update your copy of -the SDK. -EOT; + $args['config']['ignore_configured_endpoint_urls'] = $value; + } + + public static function _default_ignore_configured_endpoint_urls(array &$args) + { + return ConfigurationResolver::resolve( + 'ignore_configured_endpoint_urls', + false, + 'bool', + $args + ); + } + + public static function _default_endpoint(array &$args) + { + if ($args['config']['ignore_configured_endpoint_urls'] + || !self::isValidService($args['service']) + ) { + return ''; + } + + $serviceIdentifier = \Aws\manifest($args['service'])['serviceIdentifier']; + $value = ConfigurationResolver::resolve( + 'endpoint_url_' . $serviceIdentifier, + '', + 'string', + $args + [ + 'ini_resolver_options' => [ + 'section' => 'services', + 'subsection' => $serviceIdentifier, + 'key' => 'endpoint_url' + ] + ] + ); + + if (empty($value)) { + $value = ConfigurationResolver::resolve( + 'endpoint_url', + '', + 'string', + $args + ); + } + + return $value; + } + + public static function _apply_region($value, array &$args) + { + if (empty($value)) { + self::_missing_region($args); + } + $args['region'] = $value; + } + + public static function _default_region(&$args) + { + return ConfigurationResolver::resolve('region', '', 'string'); } public static function _missing_region(array $args) { $service = isset($args['service']) ? $args['service'] : ''; - return <<<EOT + $msg = <<<EOT +Missing required client configuration options: + +region: (string) + A "region" configuration value is required for the "{$service}" service (e.g., "us-west-2"). A list of available public regions and endpoints can be found at http://docs.aws.amazon.com/general/latest/gr/rande.html. EOT; + throw new IAE($msg); } /** @@ -1077,7 +1219,7 @@ EOT; $optionKeys = [ 'sts_regional_endpoints', 's3_us_east_1_regional_endpoint', - ]; + ]; $configKeys = [ 'use_dual_stack_endpoint', 'use_fips_endpoint', @@ -1109,7 +1251,7 @@ EOT; private function _apply_client_context_params(array $args) { if (isset($args['api']) - && !empty($args['api']->getClientContextParams())) + && !empty($args['api']->getClientContextParams())) { $clientContextParams = $args['api']->getClientContextParams(); foreach($clientContextParams as $paramName => $paramDefinition) { @@ -1144,7 +1286,7 @@ EOT; return false; } return is_dir( - __DIR__ . "/data/{$service}/$apiVersion" + __DIR__ . "/data/{$service}/$apiVersion" ); } } |