Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 2... Línea 2...
2
namespace Aws;
2
namespace Aws;
Línea 3... Línea 3...
3
 
3
 
4
use Aws\Api\ApiProvider;
4
use Aws\Api\ApiProvider;
5
use Aws\Api\Service;
5
use Aws\Api\Service;
-
 
6
use Aws\Api\Validator;
-
 
7
use Aws\Auth\AuthResolver;
-
 
8
use Aws\Auth\AuthSchemeResolver;
6
use Aws\Api\Validator;
9
use Aws\Auth\AuthSchemeResolverInterface;
7
use Aws\ClientSideMonitoring\ApiCallAttemptMonitoringMiddleware;
10
use Aws\ClientSideMonitoring\ApiCallAttemptMonitoringMiddleware;
8
use Aws\ClientSideMonitoring\ApiCallMonitoringMiddleware;
11
use Aws\ClientSideMonitoring\ApiCallMonitoringMiddleware;
9
use Aws\ClientSideMonitoring\Configuration;
12
use Aws\ClientSideMonitoring\Configuration;
10
use Aws\Configuration\ConfigurationResolver;
13
use Aws\Configuration\ConfigurationResolver;
Línea 42... Línea 45...
42
class ClientResolver
45
class ClientResolver
43
{
46
{
44
    /** @var array */
47
    /** @var array */
45
    private $argDefinitions;
48
    private $argDefinitions;
Línea -... Línea 49...
-
 
49
 
-
 
50
    /**
-
 
51
     * When using this option as default please make sure that, your config
-
 
52
     * has at least one data type defined in `valid` otherwise it will be
-
 
53
     * defaulted to `string`. Also, the default value will be the falsy value
-
 
54
     * based on the resolved data type. For example, the default for `string`
-
 
55
     * will be `''` and for bool will be `false`.
-
 
56
     *
-
 
57
     * @var string
-
 
58
     */
-
 
59
    const DEFAULT_FROM_ENV_INI = [
-
 
60
        __CLASS__,
-
 
61
        '_resolve_from_env_ini'
-
 
62
    ];
46
 
63
 
47
    /** @var array Map of types to a corresponding function */
64
    /** @var array Map of types to a corresponding function */
48
    private static $typeMap = [
65
    private static $typeMap = [
49
        'resource' => 'is_resource',
66
        'resource' => 'is_resource',
50
        'callable' => 'is_callable',
67
        'callable' => 'is_callable',
Línea 81... Línea 98...
81
            'type'      => 'value',
98
            'type'      => 'value',
82
            'valid'     => ['bool'],
99
            'valid'     => ['bool'],
83
            '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.',
100
            '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.',
84
            'default'   => false,
101
            'default'   => false,
85
        ],
102
        ],
-
 
103
        'ignore_configured_endpoint_urls' => [
-
 
104
            'type'      => 'value',
-
 
105
            'valid'     => ['bool'],
-
 
106
            'doc'       => 'Set to true to disable endpoint urls configured using `AWS_ENDPOINT_URL` and `endpoint_url` shared config option.',
-
 
107
            'fn'        => [__CLASS__, '_apply_ignore_configured_endpoint_urls'],
-
 
108
            'default'   => self::DEFAULT_FROM_ENV_INI,
-
 
109
        ],
86
        'endpoint' => [
110
        'endpoint' => [
87
            'type'  => 'value',
111
            'type'  => 'value',
88
            'valid' => ['string'],
112
            'valid' => ['string'],
89
            'doc'   => 'The full URI of the webservice. This is only required when connecting to a custom endpoint (e.g., a local version of S3).',
113
            'doc'   => 'The full URI of the webservice. This is only required when connecting to a custom endpoint (e.g., a local version of S3).',
90
            'fn'    => [__CLASS__, '_apply_endpoint'],
114
            'fn'    => [__CLASS__, '_apply_endpoint'],
-
 
115
            'default'   => [__CLASS__, '_default_endpoint']
91
        ],
116
        ],
92
        'region' => [
117
        'region' => [
93
            'type'     => 'value',
118
            'type'     => 'value',
94
            'valid'    => ['string'],
119
            'valid'    => ['string'],
95
            'required' => [__CLASS__, '_missing_region'],
-
 
96
            'doc'      => 'Region to connect to. See http://docs.aws.amazon.com/general/latest/gr/rande.html for a list of available regions.',
120
            'doc'      => 'Region to connect to. See http://docs.aws.amazon.com/general/latest/gr/rande.html for a list of available regions.',
-
 
121
            'fn'       => [__CLASS__, '_apply_region'],
-
 
122
            'default'  => self::DEFAULT_FROM_ENV_INI
97
        ],
123
        ],
98
        'version' => [
124
        'version' => [
99
            'type'     => 'value',
125
            'type'     => 'value',
100
            'valid'    => ['string'],
126
            'valid'    => ['string'],
101
            'doc'      => 'The version of the webservice to utilize (e.g., 2006-03-01).',
127
            'doc'      => 'The version of the webservice to utilize (e.g., 2006-03-01).',
Línea 142... Línea 168...
142
            'doc'      => 'An optional PHP callable that accepts a hash of options including a "service" and "region" key and returns NULL or a hash of endpoint data, of which the "endpoint" key is required. See Aws\\Endpoint\\EndpointProvider for a list of built-in providers.',
168
            'doc'      => 'An optional PHP callable that accepts a hash of options including a "service" and "region" key and returns NULL or a hash of endpoint data, of which the "endpoint" key is required. See Aws\\Endpoint\\EndpointProvider for a list of built-in providers.',
143
            'default'  => [__CLASS__, '_default_endpoint_provider'],
169
            'default'  => [__CLASS__, '_default_endpoint_provider'],
144
        ],
170
        ],
145
        'serializer' => [
171
        'serializer' => [
146
            'default'   => [__CLASS__, '_default_serializer'],
172
            'default'   => [__CLASS__, '_default_serializer'],
-
 
173
            'fn'        => [__CLASS__, '_apply_serializer'],
147
            'internal'  => true,
174
            'internal'  => true,
148
            'type'      => 'value',
175
            'type'      => 'value',
149
            'valid'     => ['callable'],
176
            'valid'     => ['callable'],
150
        ],
177
        ],
151
        'signature_version' => [
178
        'signature_version' => [
Línea 184... Línea 211...
184
            'valid'   => [TokenInterface::class, CacheInterface::class, 'array', 'bool', 'callable'],
211
            'valid'   => [TokenInterface::class, CacheInterface::class, 'array', 'bool', 'callable'],
185
            'doc'     => 'Specifies the token used to authorize requests. Provide an Aws\Token\TokenInterface object, an associative array of "token", and an optional "expiration" key, `false` to use a null token, or a callable token provider used to fetch a token or return null. See Aws\\Token\\TokenProvider for a list of built-in credentials providers. If no token is provided, the SDK will attempt to load one from the environment.',
212
            'doc'     => 'Specifies the token used to authorize requests. Provide an Aws\Token\TokenInterface object, an associative array of "token", and an optional "expiration" key, `false` to use a null token, or a callable token provider used to fetch a token or return null. See Aws\\Token\\TokenProvider for a list of built-in credentials providers. If no token is provided, the SDK will attempt to load one from the environment.',
186
            'fn'      => [__CLASS__, '_apply_token'],
213
            'fn'      => [__CLASS__, '_apply_token'],
187
            'default' => [__CLASS__, '_default_token_provider'],
214
            'default' => [__CLASS__, '_default_token_provider'],
188
        ],
215
        ],
-
 
216
        'auth_scheme_resolver' => [
-
 
217
            'type'    => 'value',
-
 
218
            'valid'   => [AuthSchemeResolverInterface::class],
-
 
219
            'doc'     => 'An instance of Aws\Auth\AuthSchemeResolverInterface which selects a modeled auth scheme and returns a signature version',
-
 
220
            'default' => [__CLASS__, '_default_auth_scheme_resolver'],
-
 
221
        ],
189
        'endpoint_discovery' => [
222
        'endpoint_discovery' => [
190
            'type'     => 'value',
223
            'type'     => 'value',
191
            'valid'    => [ConfigurationInterface::class, CacheInterface::class, 'array', 'callable'],
224
            'valid'    => [ConfigurationInterface::class, CacheInterface::class, 'array', 'callable'],
192
            'doc'      => 'Specifies settings for endpoint discovery. Provide an instance of Aws\EndpointDiscovery\ConfigurationInterface, an instance Aws\CacheInterface, a callable that provides a promise for a Configuration object, or an associative array with the following keys: enabled: (bool) Set to true to enable endpoint discovery, false to explicitly disable it. Defaults to false; cache_limit: (int) The maximum number of keys in the endpoints cache. Defaults to 1000.',
225
            'doc'      => 'Specifies settings for endpoint discovery. Provide an instance of Aws\EndpointDiscovery\ConfigurationInterface, an instance Aws\CacheInterface, a callable that provides a promise for a Configuration object, or an associative array with the following keys: enabled: (bool) Set to true to enable endpoint discovery, false to explicitly disable it. Defaults to false; cache_limit: (int) The maximum number of keys in the endpoints cache. Defaults to 1000.',
193
            'fn'       => [__CLASS__, '_apply_endpoint_discovery'],
226
            'fn'       => [__CLASS__, '_apply_endpoint_discovery'],
Línea 223... Línea 256...
223
        'disable_request_compression' => [
256
        'disable_request_compression' => [
224
            'type'      => 'value',
257
            'type'      => 'value',
225
            'valid'     => ['bool', 'callable'],
258
            'valid'     => ['bool', 'callable'],
226
            'doc'       => 'Set to true to disable request compression for supported operations',
259
            'doc'       => 'Set to true to disable request compression for supported operations',
227
            'fn'        => [__CLASS__, '_apply_disable_request_compression'],
260
            'fn'        => [__CLASS__, '_apply_disable_request_compression'],
228
            'default'   => [__CLASS__, '_default_disable_request_compression'],
261
            'default'   => self::DEFAULT_FROM_ENV_INI,
229
        ],
262
        ],
230
        'request_min_compression_size_bytes' => [
263
        'request_min_compression_size_bytes' => [
231
            'type'      => 'value',
264
            'type'      => 'value',
232
            'valid'     => ['int', 'callable'],
265
            'valid'     => ['int', 'callable'],
233
            '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`',
266
            '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`',
Línea 258... Línea 291...
258
            'valid'    => ['callable'],
291
            'valid'    => ['callable'],
259
            'doc'      => 'A handler that accepts a command object, request object and returns a promise that is fulfilled with an Aws\ResultInterface object or rejected with an Aws\Exception\AwsException. A handler does not accept a next handler as it is terminal and expected to fulfill a command. If no handler is provided, a default Guzzle handler will be utilized.',
292
            'doc'      => 'A handler that accepts a command object, request object and returns a promise that is fulfilled with an Aws\ResultInterface object or rejected with an Aws\Exception\AwsException. A handler does not accept a next handler as it is terminal and expected to fulfill a command. If no handler is provided, a default Guzzle handler will be utilized.',
260
            'fn'       => [__CLASS__, '_apply_handler'],
293
            'fn'       => [__CLASS__, '_apply_handler'],
261
            'default'  => [__CLASS__, '_default_handler']
294
            'default'  => [__CLASS__, '_default_handler']
262
        ],
295
        ],
-
 
296
        'app_id' => [
-
 
297
            'type' => 'value',
-
 
298
            'valid' => ['string'],
-
 
299
            'doc' => 'app_id(AppId) is an optional application specific identifier that can be set. 
-
 
300
             When set it will be appended to the User-Agent header of every request in the form of App/{AppId}. 
-
 
301
             This value is also sourced from environment variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.',
-
 
302
            'fn' => [__CLASS__, '_apply_app_id'],
-
 
303
            'default' => [__CLASS__, '_default_app_id']
-
 
304
        ],
263
        'ua_append' => [
305
        'ua_append' => [
264
            'type'     => 'value',
306
            'type'     => 'value',
265
            'valid'    => ['string', 'array'],
307
            'valid'    => ['string', 'array'],
266
            'doc'      => 'Provide a string or array of strings to send in the User-Agent header.',
308
            'doc'      => 'Provide a string or array of strings to send in the User-Agent header.',
267
            'fn'       => [__CLASS__, '_apply_user_agent'],
309
            'fn'       => [__CLASS__, '_apply_user_agent'],
Línea 281... Línea 323...
281
            'default'   => true,
323
            'default'   => true,
282
        ],
324
        ],
283
        'suppress_php_deprecation_warning' => [
325
        'suppress_php_deprecation_warning' => [
284
            'type'      => 'value',
326
            'type'      => 'value',
285
            'valid'     => ['bool'],
327
            'valid'     => ['bool'],
286
            'doc'       => 'Set to false to disable the deprecation warning of PHP versions 7.2.4 and below',
328
            'doc' => 'Set to true to suppress PHP runtime deprecation warnings. The current deprecation campaign is PHP versions 8.0.x and below, taking effect on 1/13/2025.',
287
            'default'   => false,
329
            'default' => false,
288
            'fn'        => [__CLASS__, '_apply_suppress_php_deprecation_warning']
330
            'fn' => [__CLASS__, '_apply_suppress_php_deprecation_warning']
289
        ],
331
        ],
-
 
332
        'account_id_endpoint_mode' => [
-
 
333
            'type'      => 'value',
-
 
334
            'valid'     => ['string'],
-
 
335
            '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.',
-
 
336
            'default'  => [__CLASS__, '_default_account_id_endpoint_mode'],
-
 
337
            'fn'       => [__CLASS__, '_apply_account_id_endpoint_mode']
-
 
338
        ],
-
 
339
        'sigv4a_signing_region_set' => [
-
 
340
            'type' => 'value',
-
 
341
            'valid' => ['string', 'array'],
-
 
342
            'doc' => 'A comma-delimited list of supported regions sent in sigv4a requests.',
-
 
343
            'fn' => [__CLASS__, '_apply_sigv4a_signing_region_set'],
-
 
344
            'default' => self::DEFAULT_FROM_ENV_INI
-
 
345
        ]
290
    ];
346
    ];
Línea 291... Línea 347...
291
 
347
 
292
    /**
348
    /**
293
     * Gets an array of default client arguments, each argument containing a
349
     * Gets an array of default client arguments, each argument containing a
Línea 353... Línea 409...
353
                        && (
409
                        && (
354
                            is_array($a['default'])
410
                            is_array($a['default'])
355
                            || $a['default'] instanceof \Closure
411
                            || $a['default'] instanceof \Closure
356
                        )
412
                        )
357
                    ) {
413
                    ) {
-
 
414
                        if ($a['default'] === self::DEFAULT_FROM_ENV_INI) {
-
 
415
                            $args[$key] = $a['default'](
-
 
416
                                $key,
-
 
417
                                $a['valid'][0] ?? 'string',
-
 
418
                                $args
-
 
419
                            );
-
 
420
                        } else {
358
                        $args[$key] = $a['default']($args);
421
                            $args[$key] = $a['default']($args);
-
 
422
                        }
359
                    } else {
423
                    } else {
360
                        $args[$key] = $a['default'];
424
                        $args[$key] = $a['default'];
361
                    }
425
                    }
362
                } elseif (empty($a['required'])) {
426
                } elseif (empty($a['required'])) {
363
                    continue;
427
                    continue;
Línea 538... Línea 602...
538
    public static function _apply_disable_request_compression($value, array &$args) {
602
    public static function _apply_disable_request_compression($value, array &$args) {
539
        if (is_callable($value)) {
603
        if (is_callable($value)) {
540
            $value = $value();
604
            $value = $value();
541
        }
605
        }
542
        if (!is_bool($value)) {
606
        if (!is_bool($value)) {
543
           throw new IAE(
607
            throw new IAE(
544
              "Invalid configuration value provided for 'disable_request_compression'."
608
                "Invalid configuration value provided for 'disable_request_compression'."
545
              . " value must be a bool."
609
                . " value must be a bool."
546
           );
610
            );
547
        }
611
        }
548
        $args['config']['disable_request_compression'] = $value;
612
        $args['config']['disable_request_compression'] = $value;
549
    }
613
    }
Línea 550... Línea -...
550
 
-
 
551
    public static function _default_disable_request_compression(array &$args) {
-
 
552
        return ConfigurationResolver::resolve(
-
 
553
            'disable_request_compression',
-
 
554
            false,
-
 
555
            'bool',
-
 
556
            $args
-
 
557
        );
-
 
558
    }
-
 
559
 
614
 
560
    public static function _apply_min_compression_size($value, array &$args) {
615
    public static function _apply_min_compression_size($value, array &$args) {
561
        if (is_callable($value)) {
616
        if (is_callable($value)) {
562
            $value = $value();
617
            $value = $value();
563
        }
618
        }
564
        if (!is_int($value)
619
        if (!is_int($value)
565
            || (is_int($value)
620
            || (is_int($value)
566
            && ($value < 0 || $value > 10485760))
621
                && ($value < 0 || $value > 10485760))
567
        ) {
622
        ) {
568
            throw new IAE(" Invalid configuration value provided for 'min_compression_size_bytes'."
623
            throw new IAE(" Invalid configuration value provided for 'min_compression_size_bytes'."
569
            . " value must be an integer between 0 and 10485760, inclusive.");
624
                . " value must be an integer between 0 and 10485760, inclusive.");
570
        }
625
        }
571
        $args['config']['request_min_compression_size_bytes'] = $value;
626
        $args['config']['request_min_compression_size_bytes'] = $value;
Línea 572... Línea 627...
572
    }
627
    }
Línea 594... Línea 649...
594
        ) {
649
        ) {
595
            $args['credentials'] = CredentialProvider::fromCredentials(
650
            $args['credentials'] = CredentialProvider::fromCredentials(
596
                new Credentials(
651
                new Credentials(
597
                    $value['key'],
652
                    $value['key'],
598
                    $value['secret'],
653
                    $value['secret'],
599
                    isset($value['token']) ? $value['token'] : null,
654
                    $value['token'] ?? null,
600
                    isset($value['expires']) ? $value['expires'] : null
655
                    $value['expires'] ?? null,
-
 
656
                    $value['accountId'] ?? null
601
                )
657
                )
602
            );
658
            );
603
        } elseif ($value === false) {
659
        } elseif ($value === false) {
604
            $args['credentials'] = CredentialProvider::fromCredentials(
660
            $args['credentials'] = CredentialProvider::fromCredentials(
605
                new Credentials('', '')
661
                new Credentials('', '')
606
            );
662
            );
607
            $args['config']['signature_version'] = 'anonymous';
663
            $args['config']['signature_version'] = 'anonymous';
-
 
664
            $args['config']['configured_signature_version'] = true;
608
        } elseif ($value instanceof CacheInterface) {
665
        } elseif ($value instanceof CacheInterface) {
609
            $args['credentials'] = CredentialProvider::defaultProvider($args);
666
            $args['credentials'] = CredentialProvider::defaultProvider($args);
610
        } else {
667
        } else {
611
            throw new IAE('Credentials must be an instance of '
668
            throw new IAE('Credentials must be an instance of '
612
                . "'" . CredentialsInterface::class . ', an associative '
669
                . "'" . CredentialsInterface::class . ', an associative '
Línea 632... Línea 689...
632
            && isset($value['token'])
689
            && isset($value['token'])
633
        ) {
690
        ) {
634
            $args['token'] = TokenProvider::fromToken(
691
            $args['token'] = TokenProvider::fromToken(
635
                new Token(
692
                new Token(
636
                    $value['token'],
693
                    $value['token'],
637
                    isset($value['expires']) ? $value['expires'] : null
694
                    $value['expires'] ?? null
638
                )
695
                )
639
            );
696
            );
640
        } elseif ($value instanceof CacheInterface) {
697
        } elseif ($value instanceof CacheInterface) {
641
            $args['token'] = TokenProvider::defaultProvider($args);
698
            $args['token'] = TokenProvider::defaultProvider($args);
642
        } else {
699
        } else {
Línea 716... Línea 773...
716
                $options = self::getEndpointProviderOptions($args);
773
                $options = self::getEndpointProviderOptions($args);
717
                $value = PartitionEndpointProvider::defaultProvider($options)
774
                $value = PartitionEndpointProvider::defaultProvider($options)
718
                    ->getPartition($args['region'], $args['service']);
775
                    ->getPartition($args['region'], $args['service']);
719
            }
776
            }
Línea 720... Línea 777...
720
 
777
 
721
            $endpointPrefix = isset($args['api']['metadata']['endpointPrefix'])
-
 
722
                ? $args['api']['metadata']['endpointPrefix']
-
 
Línea 723... Línea 778...
723
                : $args['service'];
778
            $endpointPrefix = $args['api']['metadata']['endpointPrefix'] ?? $args['service'];
724
 
779
 
725
            // Check region is a valid host label when it is being used to
780
            // Check region is a valid host label when it is being used to
726
            // generate an endpoint
781
            // generate an endpoint
Línea 830... Línea 885...
830
 
885
 
831
    public static function _default_use_dual_stack_endpoint(array &$args) {
886
    public static function _default_use_dual_stack_endpoint(array &$args) {
832
        return UseDualStackConfigProvider::defaultProvider($args);
887
        return UseDualStackConfigProvider::defaultProvider($args);
Línea -... Línea 888...
-
 
888
    }
-
 
889
 
-
 
890
    public static function _apply_serializer($value, array &$args, HandlerList $list)
-
 
891
    {
-
 
892
        $list->prependBuild(Middleware::requestBuilder($value), 'builder');
833
    }
893
    }
834
 
894
 
835
    public static function _apply_debug($value, array &$args, HandlerList $list)
895
    public static function _apply_debug($value, array &$args, HandlerList $list)
836
    {
896
    {
837
        if ($value !== false) {
897
        if ($value !== false) {
Línea 906... Línea 966...
906
            $args['exception_class'],
966
            $args['exception_class'],
907
            $args['stats']['http']
967
            $args['stats']['http']
908
        );
968
        );
909
    }
969
    }
Línea 910... Línea 970...
910
 
970
 
911
    public static function _apply_user_agent($inputUserAgent, array &$args, HandlerList $list)
971
    public static function _apply_app_id($value, array &$args)
912
    {
972
    {
913
        //Add SDK version
973
        // AppId should not be longer than 50 chars
914
        $userAgent = ['aws-sdk-php/' . Sdk::VERSION];
-
 
915
 
974
        static $MAX_APP_ID_LENGTH = 50;
916
        //If on HHVM add the HHVM version
975
        if (strlen($value) > $MAX_APP_ID_LENGTH) {
-
 
976
            trigger_error("The provided or configured value for `AppId`, "
917
        if (defined('HHVM_VERSION')) {
977
                ."which is an user agent parameter, exceeds the maximum length of "
918
            $userAgent []= 'HHVM/' . HHVM_VERSION;
978
            ."$MAX_APP_ID_LENGTH characters.", E_USER_WARNING);
Línea 919... Línea -...
919
        }
-
 
920
 
-
 
921
        //Add OS version
-
 
922
        $disabledFunctions = explode(',', ini_get('disable_functions'));
-
 
923
        if (function_exists('php_uname')
-
 
924
            && !in_array('php_uname', $disabledFunctions, true)
-
 
925
        ) {
-
 
926
            $osName = "OS/" . php_uname('s') . '#' . php_uname('r');
979
        }
927
            if (!empty($osName)) {
-
 
928
                $userAgent []= $osName;
-
 
929
            }
-
 
930
        }
-
 
931
 
-
 
932
        //Add the language version
-
 
933
        $userAgent []= 'lang/php#' . phpversion();
-
 
934
 
-
 
935
        //Add exec environment if present
-
 
936
        if ($executionEnvironment = getenv('AWS_EXECUTION_ENV')) {
980
 
Línea 937... Línea 981...
937
            $userAgent []= $executionEnvironment;
981
        $args['app_id'] = $value;
-
 
982
    }
938
        }
983
 
939
 
-
 
940
        //Add endpoint discovery if set
984
    public static function _default_app_id(array $args)
941
        if (isset($args['endpoint_discovery'])) {
985
    {
942
            if (($args['endpoint_discovery'] instanceof \Aws\EndpointDiscovery\Configuration
986
        return ConfigurationResolver::resolve(
943
                && $args['endpoint_discovery']->isEnabled())
-
 
944
            ) {
-
 
945
                $userAgent []= 'cfg/endpoint-discovery';
-
 
946
            } elseif (is_array($args['endpoint_discovery'])
987
            'sdk_ua_app_id',
947
                && isset($args['endpoint_discovery']['enabled'])
-
 
948
                && $args['endpoint_discovery']['enabled']
988
            '',
949
            ) {
989
            'string',
Línea 950... Línea 990...
950
                $userAgent []= 'cfg/endpoint-discovery';
990
            $args
951
            }
991
        );
952
        }
-
 
953
 
-
 
954
        //Add retry mode if set
992
    }
955
        if (isset($args['retries'])) {
993
 
956
            if ($args['retries'] instanceof \Aws\Retry\Configuration) {
994
    public static function _apply_user_agent(
-
 
995
        $inputUserAgent,
957
                $userAgent []= 'cfg/retry-mode#' . $args["retries"]->getMode();
996
        array &$args,
958
            } elseif (is_array($args['retries'])
997
        HandlerList $list
959
                && isset($args["retries"]["mode"])
-
 
960
            ) {
998
    ): void
961
                $userAgent []= 'cfg/retry-mode#' . $args["retries"]["mode"];
999
    {
962
            }
1000
        // Add endpoint discovery if set
963
        }
1001
        $userAgent = [];
964
        //Add the input to the end
1002
        // Add the input to the end
965
        if ($inputUserAgent){
1003
        if ($inputUserAgent){
966
            if (!is_array($inputUserAgent)) {
1004
            if (!is_array($inputUserAgent)) {
967
                $inputUserAgent = [$inputUserAgent];
1005
                $inputUserAgent = [$inputUserAgent];
Línea 968... Línea 1006...
968
            }
1006
            }
Línea 969... Línea -...
969
            $inputUserAgent = array_map('strval', $inputUserAgent);
-
 
970
            $userAgent = array_merge($userAgent, $inputUserAgent);
1007
            $inputUserAgent = array_map('strval', $inputUserAgent);
971
        }
-
 
972
 
1008
            $userAgent = array_merge($userAgent, $inputUserAgent);
973
        $args['ua_append'] = $userAgent;
-
 
974
 
-
 
975
        $list->appendBuild(static function (callable $handler) use ($userAgent) {
-
 
976
            return function (
1009
        }
977
                CommandInterface $command,
1010
 
978
                RequestInterface $request
1011
        $args['ua_append'] = $userAgent;
979
            ) use ($handler, $userAgent) {
1012
 
980
                return $handler(
1013
        $list->appendBuild(
981
                    $command,
-
 
982
                    $request->withHeader(
-
 
983
                        'X-Amz-User-Agent',
-
 
984
                        implode(' ', array_merge(
-
 
985
                            $userAgent,
-
 
986
                            $request->getHeader('X-Amz-User-Agent')
-
 
987
                        ))
-
 
988
                    )->withHeader(
1014
            Middleware::mapRequest(function (RequestInterface $request) use ($userAgent) {
989
                        'User-Agent',
1015
                return $request->withHeader(
990
                        implode(' ', array_merge(
1016
                    'X-Amz-User-Agent',
991
                            $userAgent,
1017
                    implode(' ', array_merge(
992
                            $request->getHeader('User-Agent')
1018
                        $userAgent,
Línea 993... Línea 1019...
993
                        ))
1019
                        $request->getHeader('X-Amz-User-Agent')
994
                    )
1020
                    ))
-
 
1021
                );
-
 
1022
            })
-
 
1023
        );
-
 
1024
    }
-
 
1025
 
-
 
1026
    public static function _apply_endpoint($value, array &$args, HandlerList $list)
995
                );
1027
    {
996
            };
1028
        if (empty($value)) {
Línea 997... Línea 1029...
997
        });
1029
            unset($args['endpoint']);
998
    }
1030
            return;
Línea 1024... Línea 1056...
1024
                'idempotency_auto_fill'
1056
                'idempotency_auto_fill'
1025
            );
1057
            );
1026
        }
1058
        }
1027
    }
1059
    }
Línea 1028... Línea 1060...
1028
 
1060
 
-
 
1061
    public static function _default_account_id_endpoint_mode($args)
1029
    public static function _apply_suppress_php_deprecation_warning($suppressWarning, array &$args) {
1062
    {
1030
        if ($suppressWarning) {
1063
        return ConfigurationResolver::resolve(
1031
            $args['suppress_php_deprecation_warning'] = true;
1064
            'account_id_endpoint_mode',
1032
        } elseif (!empty($_ENV["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"])) {
1065
            'preferred',
-
 
1066
            'string',
-
 
1067
            $args
-
 
1068
        );
-
 
1069
    }
1033
            $args['suppress_php_deprecation_warning'] =
1070
 
-
 
1071
    public static function _apply_account_id_endpoint_mode($value, array &$args)
1034
                $_ENV["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"];
1072
    {
1035
        } elseif (!empty($_SERVER["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"])) {
1073
        static $accountIdEndpointModes = ['disabled', 'required', 'preferred'];
1036
            $args['suppress_php_deprecation_warning'] =
1074
        if (!in_array($value, $accountIdEndpointModes)) {
1037
                $_SERVER["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"];
1075
            throw new IAE(
1038
        } elseif (!empty(getenv("AWS_SUPPRESS_PHP_DEPRECATION_WARNING"))) {
1076
                "The value provided for the config account_id_endpoint_mode is invalid."
1039
            $args['suppress_php_deprecation_warning']
1077
                ."Valid values are: " . implode(", ", $accountIdEndpointModes)
1040
                = getenv("AWS_SUPPRESS_PHP_DEPRECATION_WARNING");
1078
            );
-
 
1079
        }
-
 
1080
 
1041
        }
1081
        $args['account_id_endpoint_mode'] = $value;
Línea 1042... Línea 1082...
1042
    }
1082
    }
1043
 
1083
 
1044
    public static function _default_endpoint_provider(array $args)
1084
    public static function _default_endpoint_provider(array $args)
1045
    {
1085
    {
1046
        $service =  isset($args['api']) ? $args['api'] : null;
1086
        $service = $args['api'] ?? null;
Línea 1047... Línea 1087...
1047
        $serviceName = isset($service) ? $service->getServiceName() : null;
1087
        $serviceName = isset($service) ? $service->getServiceName() : null;
1048
        $apiVersion = isset($service) ? $service->getApiVersion() : null;
1088
        $apiVersion = isset($service) ? $service->getApiVersion() : null;
Línea 1075... Línea 1115...
1075
    public static function _default_signature_provider()
1115
    public static function _default_signature_provider()
1076
    {
1116
    {
1077
        return SignatureProvider::defaultProvider();
1117
        return SignatureProvider::defaultProvider();
1078
    }
1118
    }
Línea -... Línea 1119...
-
 
1119
 
-
 
1120
    public static function _default_auth_scheme_resolver(array $args)
-
 
1121
    {
-
 
1122
        return new AuthSchemeResolver($args['credentials'], $args['token']);
-
 
1123
    }
1079
 
1124
 
1080
    public static function _default_signature_version(array &$args)
1125
    public static function _default_signature_version(array &$args)
1081
    {
1126
    {
1082
        if (isset($args['config']['signature_version'])) {
1127
        if (isset($args['config']['signature_version'])) {
1083
            return $args['config']['signature_version'];
1128
            return $args['config']['signature_version'];
Línea 1130... Línea 1175...
1130
            : call_user_func(PartitionEndpointProvider::defaultProvider(), [
1175
            : call_user_func(PartitionEndpointProvider::defaultProvider(), [
1131
                'service' => $args['service'],
1176
                'service' => $args['service'],
1132
                'region' => $args['region'],
1177
                'region' => $args['region'],
1133
            ]);
1178
            ]);
Línea 1134... Línea 1179...
1134
 
1179
 
-
 
1180
        return $args['__partition_result']['signingRegion'] ?? $args['region'];
-
 
1181
    }
-
 
1182
 
-
 
1183
    public static function _apply_ignore_configured_endpoint_urls($value, array &$args)
-
 
1184
    {
-
 
1185
        $args['config']['ignore_configured_endpoint_urls'] = $value;
-
 
1186
    }
-
 
1187
 
-
 
1188
    public static function _apply_suppress_php_deprecation_warning($value, &$args)
-
 
1189
    {
-
 
1190
        if ($value)  {
-
 
1191
            $args['suppress_php_deprecation_warning'] = true;
1135
        return isset($args['__partition_result']['signingRegion'])
1192
        } elseif (!empty(getenv("AWS_SUPPRESS_PHP_DEPRECATION_WARNING"))) {
-
 
1193
            $args['suppress_php_deprecation_warning']
-
 
1194
                = \Aws\boolean_value(getenv("AWS_SUPPRESS_PHP_DEPRECATION_WARNING"));
-
 
1195
        } elseif (!empty($_SERVER["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"])) {
-
 
1196
            $args['suppress_php_deprecation_warning'] =
-
 
1197
                \Aws\boolean_value($_SERVER["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"]);
-
 
1198
        } elseif (!empty($_ENV["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"])) {
-
 
1199
            $args['suppress_php_deprecation_warning'] =
-
 
1200
                \Aws\boolean_value($_ENV["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"]);
-
 
1201
        }
-
 
1202
 
-
 
1203
        if ($args['suppress_php_deprecation_warning'] === false
-
 
1204
            && PHP_VERSION_ID < 80100
-
 
1205
        ) {
-
 
1206
            self::emitDeprecationWarning();
-
 
1207
        }
-
 
1208
    }
-
 
1209
 
-
 
1210
    public static function _default_endpoint(array &$args)
-
 
1211
    {
-
 
1212
        if ($args['config']['ignore_configured_endpoint_urls']
-
 
1213
            || !self::isValidService($args['service'])
-
 
1214
        ) {
-
 
1215
            return '';
-
 
1216
        }
-
 
1217
 
-
 
1218
        $serviceIdentifier = \Aws\manifest($args['service'])['serviceIdentifier'];
-
 
1219
        $value =  ConfigurationResolver::resolve(
-
 
1220
            'endpoint_url_' . $serviceIdentifier,
-
 
1221
            '',
-
 
1222
            'string',
-
 
1223
            $args + [
-
 
1224
                'ini_resolver_options' => [
-
 
1225
                    'section' => 'services',
-
 
1226
                    'subsection' => $serviceIdentifier,
-
 
1227
                    'key' => 'endpoint_url'
-
 
1228
                ]
-
 
1229
            ]
-
 
1230
        );
-
 
1231
 
-
 
1232
        if (empty($value)) {
-
 
1233
            $value = ConfigurationResolver::resolve(
-
 
1234
                'endpoint_url',
1136
            ? $args['__partition_result']['signingRegion']
1235
                '',
-
 
1236
                'string',
-
 
1237
                $args
-
 
1238
            );
-
 
1239
        }
-
 
1240
 
-
 
1241
        if (!empty($value)) {
-
 
1242
            $args['config']['configured_endpoint_url'] = true;
-
 
1243
        }
-
 
1244
 
-
 
1245
        return $value;
-
 
1246
    }
-
 
1247
 
-
 
1248
    public static function _apply_sigv4a_signing_region_set($value, array &$args)
-
 
1249
    {
-
 
1250
        if (empty($value)) {
-
 
1251
            $args['sigv4a_signing_region_set'] = null;
-
 
1252
        } elseif (is_array($value)) {
-
 
1253
            $args['sigv4a_signing_region_set'] = implode(', ', $value);
-
 
1254
        } else {
-
 
1255
            $args['sigv4a_signing_region_set'] = $value;
-
 
1256
        }
-
 
1257
    }
-
 
1258
 
-
 
1259
    public static function _apply_region($value, array &$args)
-
 
1260
    {
-
 
1261
        if (empty($value)) {
-
 
1262
            self::_missing_region($args);
-
 
1263
        }
1137
            : $args['region'];
1264
        $args['region'] = $value;
Línea 1138... Línea 1265...
1138
    }
1265
    }
1139
 
1266
 
1140
    public static function _missing_region(array $args)
1267
    public static function _missing_region(array $args)
-
 
1268
    {
-
 
1269
        $service = $args['service'] ?? '';
-
 
1270
 
-
 
1271
        $msg = <<<EOT
-
 
1272
Missing required client configuration options:
Línea 1141... Línea -...
1141
    {
-
 
1142
        $service = isset($args['service']) ? $args['service'] : '';
1273
 
1143
 
1274
region: (string)
1144
        return <<<EOT
1275
 
1145
A "region" configuration value is required for the "{$service}" service
1276
A "region" configuration value is required for the "{$service}" service
-
 
1277
(e.g., "us-west-2"). A list of available public regions and endpoints can be
-
 
1278
found at http://docs.aws.amazon.com/general/latest/gr/rande.html.
-
 
1279
EOT;
-
 
1280
        throw new IAE($msg);
-
 
1281
    }
-
 
1282
 
-
 
1283
    /**
-
 
1284
     * Resolves a value from env or config.
-
 
1285
     *
-
 
1286
     * @param $key
-
 
1287
     * @param $expectedType
-
 
1288
     * @param $args
-
 
1289
     *
-
 
1290
     * @return mixed|string
-
 
1291
     */
-
 
1292
    private static function _resolve_from_env_ini(
-
 
1293
        string $key,
-
 
1294
        string $expectedType,
-
 
1295
        array $args
-
 
1296
    ) {
-
 
1297
        static $typeDefaultMap = [
-
 
1298
            'int' => 0,
-
 
1299
            'bool' => false,
-
 
1300
            'boolean' => false,
-
 
1301
            'string' => '',
-
 
1302
        ];
-
 
1303
 
-
 
1304
        return ConfigurationResolver::resolve(
-
 
1305
            $key,
-
 
1306
            $typeDefaultMap[$expectedType] ?? '',
1146
(e.g., "us-west-2"). A list of available public regions and endpoints can be
1307
            $expectedType,
Línea 1147... Línea 1308...
1147
found at http://docs.aws.amazon.com/general/latest/gr/rande.html.
1308
            $args
1148
EOT;
1309
        );
1149
    }
1310
    }
Línea 1158... Línea 1319...
1158
    {
1319
    {
1159
        $options = [];
1320
        $options = [];
1160
        $optionKeys = [
1321
        $optionKeys = [
1161
            'sts_regional_endpoints',
1322
            'sts_regional_endpoints',
1162
            's3_us_east_1_regional_endpoint',
1323
            's3_us_east_1_regional_endpoint',
1163
            ];
1324
        ];
1164
        $configKeys = [
1325
        $configKeys = [
1165
            'use_dual_stack_endpoint',
1326
            'use_dual_stack_endpoint',
1166
            'use_fips_endpoint',
1327
            'use_fips_endpoint',
1167
        ];
1328
        ];
1168
        foreach ($optionKeys as $key) {
1329
        foreach ($optionKeys as $key) {
Línea 1190... Línea 1351...
1190
    }
1351
    }
Línea 1191... Línea 1352...
1191
 
1352
 
1192
    private function _apply_client_context_params(array $args)
1353
    private function _apply_client_context_params(array $args)
1193
    {
1354
    {
1194
        if (isset($args['api'])
1355
        if (isset($args['api'])
1195
           && !empty($args['api']->getClientContextParams()))
1356
            && !empty($args['api']->getClientContextParams()))
1196
        {
1357
        {
1197
            $clientContextParams = $args['api']->getClientContextParams();
1358
            $clientContextParams = $args['api']->getClientContextParams();
1198
            foreach($clientContextParams as $paramName => $paramDefinition) {
1359
            foreach($clientContextParams as $paramName => $paramDefinition) {
1199
                $definition = [
1360
                $definition = [
1200
                    'type' => 'value',
1361
                    'type' => 'value',
1201
                    'valid' => [$paramDefinition['type']],
-
 
1202
                    'doc' => isset($paramDefinition['documentation']) ?
1362
                    'valid' => [$paramDefinition['type']],
1203
                        $paramDefinition['documentation'] : null
1363
                    'doc' => $paramDefinition['documentation'] ?? null
1204
                ];
1364
                ];
Línea 1205... Línea 1365...
1205
                $this->argDefinitions[$paramName] = $definition;
1365
                $this->argDefinitions[$paramName] = $definition;
1206
 
1366
 
Línea 1212... Línea 1372...
1212
                }
1372
                }
1213
            }
1373
            }
1214
        }
1374
        }
1215
    }
1375
    }
Línea 1216... Línea 1376...
1216
 
1376
 
-
 
1377
    private static function isValidService($service)
1217
    private static function isValidService($service) {
1378
    {
1218
        if (is_null($service)) {
1379
        if (is_null($service)) {
1219
            return false;
1380
            return false;
1220
        }
1381
        }
1221
        $services = \Aws\manifest();
1382
        $services = \Aws\manifest();
1222
        return isset($services[$service]);
1383
        return isset($services[$service]);
Línea 1223... Línea 1384...
1223
    }
1384
    }
-
 
1385
 
1224
 
1386
    private static function isValidApiVersion($service, $apiVersion)
1225
    private static function isValidApiVersion($service, $apiVersion) {
1387
    {
1226
        if (is_null($apiVersion)) {
1388
        if (is_null($apiVersion)) {
1227
            return false;
1389
            return false;
1228
        }
1390
        }
-
 
1391
        return is_dir(
-
 
1392
            __DIR__ . "/data/{$service}/$apiVersion"
-
 
1393
        );
-
 
1394
    }
-
 
1395
 
-
 
1396
    private static function emitDeprecationWarning()
-
 
1397
    {
-
 
1398
        $phpVersionString = phpversion();
-
 
1399
        trigger_error(
-
 
1400
            "This installation of the SDK is using PHP version"
-
 
1401
            .  " {$phpVersionString}, which will be deprecated on January"
-
 
1402
            .  " 13th, 2025.\nPlease upgrade your PHP version to a minimum of"
-
 
1403
            .  " 8.1.x to continue receiving updates for the AWS"
-
 
1404
            .  " SDK for PHP.\nTo disable this warning, set"
-
 
1405
            .  " suppress_php_deprecation_warning to true on the client constructor"
-
 
1406
            .  " or set the environment variable AWS_SUPPRESS_PHP_DEPRECATION_WARNING"
-
 
1407
            .  " to true.\nMore information can be found at: "
1229
        return is_dir(
1408
            .   "https://aws.amazon.com/blogs/developer/announcing-the-end-of-support-for-php-runtimes-8-0-x-and-below-in-the-aws-sdk-for-php/\n",
1230
          __DIR__ . "/data/{$service}/$apiVersion"
1409
            E_USER_DEPRECATED
1231
        );
1410
        );