MDL-80639 libs: upgrade AWS SDK for PHP to 3.318.0

Signed-off-by: Daniel Ziegenberg <[email protected]>
This commit is contained in:
Daniel Ziegenberg
2024-08-07 20:03:38 +02:00
parent 8a6e8563fd
commit be2c9f57dd
1212 changed files with 9103 additions and 2120 deletions
+227 -49
View File
@@ -4,6 +4,9 @@ namespace Aws;
use Aws\Api\ApiProvider;
use Aws\Api\Service;
use Aws\Api\Validator;
use Aws\Auth\AuthResolver;
use Aws\Auth\AuthSchemeResolver;
use Aws\Auth\AuthSchemeResolverInterface;
use Aws\ClientSideMonitoring\ApiCallAttemptMonitoringMiddleware;
use Aws\ClientSideMonitoring\ApiCallMonitoringMiddleware;
use Aws\ClientSideMonitoring\Configuration;
@@ -83,17 +86,26 @@ 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',
@@ -144,6 +156,7 @@ class ClientResolver
],
'serializer' => [
'default' => [__CLASS__, '_default_serializer'],
'fn' => [__CLASS__, '_apply_serializer'],
'internal' => true,
'type' => 'value',
'valid' => ['callable'],
@@ -186,6 +199,12 @@ class ClientResolver
'fn' => [__CLASS__, '_apply_token'],
'default' => [__CLASS__, '_default_token_provider'],
],
'auth_scheme_resolver' => [
'type' => 'value',
'valid' => [AuthSchemeResolverInterface::class],
'doc' => 'An instance of Aws\Auth\AuthSchemeResolverInterface which selects a modeled auth scheme and returns a signature version',
'default' => [__CLASS__, '_default_auth_scheme_resolver'],
],
'endpoint_discovery' => [
'type' => 'value',
'valid' => [ConfigurationInterface::class, CacheInterface::class, 'array', 'callable'],
@@ -260,6 +279,15 @@ class ClientResolver
'fn' => [__CLASS__, '_apply_handler'],
'default' => [__CLASS__, '_default_handler']
],
'app_id' => [
'type' => 'value',
'valid' => ['string'],
'doc' => 'app_id(AppId) is an optional application specific identifier that can be set.
When set it will be appended to the User-Agent header of every request in the form of App/{AppId}.
This value is also sourced from environment variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.',
'fn' => [__CLASS__, '_apply_app_id'],
'default' => [__CLASS__, '_default_app_id']
],
'ua_append' => [
'type' => 'value',
'valid' => ['string', 'array'],
@@ -280,13 +308,20 @@ class ClientResolver
'doc' => 'Set to false to disable checking for shared aws config files usually located in \'~/.aws/config\' and \'~/.aws/credentials\'. This will be ignored if you set the \'profile\' setting.',
'default' => true,
],
'suppress_php_deprecation_warning' => [
'account_id_endpoint_mode' => [
'type' => 'value',
'valid' => ['bool'],
'doc' => 'Set to false to disable the deprecation warning of PHP versions 7.2.4 and below',
'default' => false,
'fn' => [__CLASS__, '_apply_suppress_php_deprecation_warning']
'valid' => ['string'],
'doc' => 'Decides whether account_id must a be a required resolved credentials property. If this configuration is set to disabled, then account_id is not required. If set to preferred a warning will be logged when account_id is not resolved, and when set to required an exception will be thrown if account_id is not resolved.',
'default' => [__CLASS__, '_default_account_id_endpoint_mode'],
'fn' => [__CLASS__, '_apply_account_id_endpoint_mode']
],
'sigv4a_signing_region_set' => [
'type' => 'value',
'valid' => ['array', 'string'],
'doc' => 'A comma-delimited list of supported regions sent in sigv4a requests.',
'fn' => [__CLASS__, '_apply_sigv4a_signing_region_set'],
'default' => [__CLASS__, '_default_sigv4a_signing_region_set']
]
];
/**
@@ -540,10 +575,10 @@ class ClientResolver
$value = $value();
}
if (!is_bool($value)) {
throw new IAE(
"Invalid configuration value provided for 'disable_request_compression'."
. " value must be a bool."
);
throw new IAE(
"Invalid configuration value provided for 'disable_request_compression'."
. " value must be a bool."
);
}
$args['config']['disable_request_compression'] = $value;
}
@@ -563,10 +598,10 @@ class ClientResolver
}
if (!is_int($value)
|| (is_int($value)
&& ($value < 0 || $value > 10485760))
&& ($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.");
. " value must be an integer between 0 and 10485760, inclusive.");
}
$args['config']['request_min_compression_size_bytes'] = $value;
}
@@ -596,8 +631,9 @@ class ClientResolver
new Credentials(
$value['key'],
$value['secret'],
isset($value['token']) ? $value['token'] : null,
isset($value['expires']) ? $value['expires'] : null
$value['token'] ?? null,
$value['expires'] ?? null,
$value['accountId'] ?? null
)
);
} elseif ($value === false) {
@@ -605,6 +641,7 @@ class ClientResolver
new Credentials('', '')
);
$args['config']['signature_version'] = 'anonymous';
$args['config']['configured_signature_version'] = true;
} elseif ($value instanceof CacheInterface) {
$args['credentials'] = CredentialProvider::defaultProvider($args);
} else {
@@ -634,7 +671,7 @@ class ClientResolver
$args['token'] = TokenProvider::fromToken(
new Token(
$value['token'],
isset($value['expires']) ? $value['expires'] : null
$value['expires'] ?? null
)
);
} elseif ($value instanceof CacheInterface) {
@@ -718,9 +755,7 @@ class ClientResolver
->getPartition($args['region'], $args['service']);
}
$endpointPrefix = isset($args['api']['metadata']['endpointPrefix'])
? $args['api']['metadata']['endpointPrefix']
: $args['service'];
$endpointPrefix = $args['api']['metadata']['endpointPrefix'] ?? $args['service'];
// Check region is a valid host label when it is being used to
// generate an endpoint
@@ -832,6 +867,11 @@ class ClientResolver
return UseDualStackConfigProvider::defaultProvider($args);
}
public static function _apply_serializer($value, array &$args, HandlerList $list)
{
$list->prependBuild(Middleware::requestBuilder($value), 'builder');
}
public static function _apply_debug($value, array &$args, HandlerList $list)
{
if ($value !== false) {
@@ -908,17 +948,43 @@ class ClientResolver
);
}
public static function _apply_app_id($value, array &$args)
{
// AppId should not be longer than 50 chars
static $MAX_APP_ID_LENGTH = 50;
if (strlen($value) > $MAX_APP_ID_LENGTH) {
trigger_error("The provided or configured value for `AppId`, "
."which is an user agent parameter, exceeds the maximum length of "
."$MAX_APP_ID_LENGTH characters.", E_USER_WARNING);
}
$args['app_id'] = $value;
}
public static function _default_app_id(array $args)
{
return ConfigurationResolver::resolve(
'sdk_ua_app_id',
'',
'string',
$args
);
}
public static function _apply_user_agent($inputUserAgent, array &$args, HandlerList $list)
{
//Add SDK version
// Add SDK version
$userAgent = ['aws-sdk-php/' . Sdk::VERSION];
//If on HHVM add the HHVM version
// User Agent Metadata
$userAgent[] = 'ua/2.0';
// If on HHVM add the HHVM version
if (defined('HHVM_VERSION')) {
$userAgent []= 'HHVM/' . HHVM_VERSION;
}
//Add OS version
// Add OS version
$disabledFunctions = explode(',', ini_get('disable_functions'));
if (function_exists('php_uname')
&& !in_array('php_uname', $disabledFunctions, true)
@@ -929,15 +995,15 @@ class ClientResolver
}
}
//Add the language version
// Add the language version
$userAgent []= 'lang/php#' . phpversion();
//Add exec environment if present
// Add exec environment if present
if ($executionEnvironment = getenv('AWS_EXECUTION_ENV')) {
$userAgent []= $executionEnvironment;
}
//Add endpoint discovery if set
// Add endpoint discovery if set
if (isset($args['endpoint_discovery'])) {
if (($args['endpoint_discovery'] instanceof \Aws\EndpointDiscovery\Configuration
&& $args['endpoint_discovery']->isEnabled())
@@ -951,7 +1017,7 @@ class ClientResolver
}
}
//Add retry mode if set
// Add retry mode if set
if (isset($args['retries'])) {
if ($args['retries'] instanceof \Aws\Retry\Configuration) {
$userAgent []= 'cfg/retry-mode#' . $args["retries"]->getMode();
@@ -961,7 +1027,13 @@ class ClientResolver
$userAgent []= 'cfg/retry-mode#' . $args["retries"]["mode"];
}
}
//Add the input to the end
// AppID Metadata
if (!empty($args['app_id'])) {
$userAgent[] = 'app/' . $args['app_id'];
}
// Add the input to the end
if ($inputUserAgent){
if (!is_array($inputUserAgent)) {
$inputUserAgent = [$inputUserAgent];
@@ -999,6 +1071,11 @@ class ClientResolver
public static function _apply_endpoint($value, array &$args, HandlerList $list)
{
if (empty($value)) {
unset($args['endpoint']);
return;
}
$args['endpoint'] = $value;
}
@@ -1026,24 +1103,32 @@ class ClientResolver
}
}
public static function _apply_suppress_php_deprecation_warning($suppressWarning, array &$args) {
if ($suppressWarning) {
$args['suppress_php_deprecation_warning'] = true;
} elseif (!empty($_ENV["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"])) {
$args['suppress_php_deprecation_warning'] =
$_ENV["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"];
} elseif (!empty($_SERVER["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"])) {
$args['suppress_php_deprecation_warning'] =
$_SERVER["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"];
} elseif (!empty(getenv("AWS_SUPPRESS_PHP_DEPRECATION_WARNING"))) {
$args['suppress_php_deprecation_warning']
= getenv("AWS_SUPPRESS_PHP_DEPRECATION_WARNING");
public static function _default_account_id_endpoint_mode($args)
{
return ConfigurationResolver::resolve(
'account_id_endpoint_mode',
'preferred',
'string',
$args
);
}
public static function _apply_account_id_endpoint_mode($value, array &$args)
{
static $accountIdEndpointModes = ['disabled', 'required', 'preferred'];
if (!in_array($value, $accountIdEndpointModes)) {
throw new IAE(
"The value provided for the config account_id_endpoint_mode is invalid."
."Valid values are: " . implode(", ", $accountIdEndpointModes)
);
}
$args['account_id_endpoint_mode'] = $value;
}
public static function _default_endpoint_provider(array $args)
{
$service = isset($args['api']) ? $args['api'] : null;
$service = $args['api'] ?? null;
$serviceName = isset($service) ? $service->getServiceName() : null;
$apiVersion = isset($service) ? $service->getApiVersion() : null;
@@ -1077,6 +1162,11 @@ class ClientResolver
return SignatureProvider::defaultProvider();
}
public static function _default_auth_scheme_resolver(array $args)
{
return new AuthSchemeResolver($args['credentials'], $args['token']);
}
public static function _default_signature_version(array &$args)
{
if (isset($args['config']['signature_version'])) {
@@ -1132,20 +1222,109 @@ class ClientResolver
'region' => $args['region'],
]);
return isset($args['__partition_result']['signingRegion'])
? $args['__partition_result']['signingRegion']
: $args['region'];
return $args['__partition_result']['signingRegion'] ?? $args['region'];
}
public static function _apply_ignore_configured_endpoint_urls($value, array &$args)
{
$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
);
}
if (!empty($value)) {
$args['config']['configured_endpoint_url'] = true;
}
return $value;
}
public static function _apply_sigv4a_signing_region_set($value, array &$args)
{
if (empty($value)) {
$args['sigv4a_signing_region_set'] = null;
} elseif (is_array($value)) {
$args['sigv4a_signing_region_set'] = implode(', ', $value);
} else {
$args['sigv4a_signing_region_set'] = $value;
}
}
public static function _default_sigv4a_signing_region_set(array &$args)
{
return ConfigurationResolver::resolve(
'sigv4a_signing_region_set',
'',
'string'
);
}
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'] : '';
$service = $args['service'] ?? '';
$msg = <<<EOT
Missing required client configuration options:
region: (string)
return <<<EOT
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);
}
/**
@@ -1160,7 +1339,7 @@ EOT;
$optionKeys = [
'sts_regional_endpoints',
's3_us_east_1_regional_endpoint',
];
];
$configKeys = [
'use_dual_stack_endpoint',
'use_fips_endpoint',
@@ -1192,15 +1371,14 @@ 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) {
$definition = [
'type' => 'value',
'valid' => [$paramDefinition['type']],
'doc' => isset($paramDefinition['documentation']) ?
$paramDefinition['documentation'] : null
'doc' => $paramDefinition['documentation'] ?? null
];
$this->argDefinitions[$paramName] = $definition;
@@ -1227,7 +1405,7 @@ EOT;
return false;
}
return is_dir(
__DIR__ . "/data/{$service}/$apiVersion"
__DIR__ . "/data/{$service}/$apiVersion"
);
}
}