PluginProbe
Media Cloud Sync / 1.2.13
Media Cloud Sync v1.2.13
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / AwsClient.php

AwsClient.php in Media Cloud Sync 1.2.13, at includes/sdk/s3/Aws/AwsClient.php

593 lines 27.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws;
4
5 use Dudlewebs\WPMCS\s3\Aws\Api\ApiProvider;
6 use Dudlewebs\WPMCS\s3\Aws\Api\DocModel;
7 use Dudlewebs\WPMCS\s3\Aws\Api\Service;
8 use Dudlewebs\WPMCS\s3\Aws\Auth\AuthSelectionMiddleware;
9 use Dudlewebs\WPMCS\s3\Aws\Auth\AuthSchemeResolverInterface;
10 use Dudlewebs\WPMCS\s3\Aws\EndpointDiscovery\EndpointDiscoveryMiddleware;
11 use Dudlewebs\WPMCS\s3\Aws\EndpointV2\EndpointProviderV2;
12 use Dudlewebs\WPMCS\s3\Aws\EndpointV2\EndpointV2Middleware;
13 use Dudlewebs\WPMCS\s3\Aws\Exception\AwsException;
14 use Dudlewebs\WPMCS\s3\Aws\Signature\SignatureProvider;
15 use Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7\Uri;
16 /**
17 * Default AWS client implementation
18 */
19 class AwsClient implements AwsClientInterface
20 {
21 use AwsClientTrait;
22 /** @var array */
23 private $aliases;
24 /** @var array */
25 private $config;
26 /** @var string */
27 private $region;
28 /** @var string */
29 private $signingRegionSet;
30 /** @var string */
31 private $endpoint;
32 /** @var Service */
33 private $api;
34 /** @var callable */
35 private $signatureProvider;
36 /** @var AuthSchemeResolverInterface */
37 private $authSchemeResolver;
38 /** @var callable */
39 private $credentialProvider;
40 /** @var callable */
41 private $tokenProvider;
42 /** @var HandlerList */
43 private $handlerList;
44 /** @var array*/
45 private $defaultRequestOptions;
46 /** @var array*/
47 private $clientContextParams = [];
48 /** @var array*/
49 protected $clientBuiltIns = [];
50 /** @var EndpointProviderV2 | callable */
51 protected $endpointProvider;
52 /** @var callable */
53 protected $serializer;
54 /**
55 * Get an array of client constructor arguments used by the client.
56 *
57 * @return array
58 */
59 public static function getArguments()
60 {
61 return ClientResolver::getDefaultArguments();
62 }
63 /**
64 * The client constructor accepts the following options:
65 *
66 * - api_provider: (callable) An optional PHP callable that accepts a
67 * type, service, and version argument, and returns an array of
68 * corresponding configuration data. The type value can be one of api,
69 * waiter, or paginator.
70 * - credentials:
71 * (Aws\Credentials\CredentialsInterface|array|bool|callable) Specifies
72 * the credentials used to sign requests. Provide an
73 * Aws\Credentials\CredentialsInterface object, an associative array of
74 * "key", "secret", and an optional "token" key, `false` to use null
75 * credentials, or a callable credentials provider used to create
76 * credentials or return null. See Aws\Credentials\CredentialProvider for
77 * a list of built-in credentials providers. If no credentials are
78 * provided, the SDK will attempt to load them from the environment.
79 * - token:
80 * (Aws\Token\TokenInterface|array|bool|callable) Specifies
81 * the token used to authorize requests. Provide an
82 * Aws\Token\TokenInterface object, an associative array of
83 * "token" and an optional "expires" key, `false` to use no
84 * token, or a callable token provider used to create a
85 * token or return null. See Aws\Token\TokenProvider for
86 * a list of built-in token providers. If no token is
87 * provided, the SDK will attempt to load one from the environment.
88 * - csm:
89 * (Aws\ClientSideMonitoring\ConfigurationInterface|array|callable) Specifies
90 * the credentials used to sign requests. Provide an
91 * Aws\ClientSideMonitoring\ConfigurationInterface object, a callable
92 * configuration provider used to create client-side monitoring configuration,
93 * `false` to disable csm, or an associative array with the following keys:
94 * enabled: (bool) Set to true to enable client-side monitoring, defaults
95 * to false; host: (string) the host location to send monitoring events to,
96 * defaults to 127.0.0.1; port: (int) The port used for the host connection,
97 * defaults to 31000; client_id: (string) An identifier for this project
98 * - debug: (bool|array) Set to true to display debug information when
99 * sending requests. Alternatively, you can provide an associative array
100 * with the following keys: logfn: (callable) Function that is invoked
101 * with log messages; stream_size: (int) When the size of a stream is
102 * greater than this number, the stream data will not be logged (set to
103 * "0" to not log any stream data); scrub_auth: (bool) Set to false to
104 * disable the scrubbing of auth data from the logged messages; http:
105 * (bool) Set to false to disable the "debug" feature of lower level HTTP
106 * adapters (e.g., verbose curl output).
107 * - stats: (bool|array) Set to true to gather transfer statistics on
108 * requests sent. Alternatively, you can provide an associative array with
109 * the following keys: retries: (bool) Set to false to disable reporting
110 * on retries attempted; http: (bool) Set to true to enable collecting
111 * statistics from lower level HTTP adapters (e.g., values returned in
112 * GuzzleHttp\TransferStats). HTTP handlers must support an
113 * `http_stats_receiver` option for this to have an effect; timer: (bool)
114 * Set to true to enable a command timer that reports the total wall clock
115 * time spent on an operation in seconds.
116 * - disable_host_prefix_injection: (bool) Set to true to disable host prefix
117 * injection logic for services that use it. This disables the entire
118 * prefix injection, including the portions supplied by user-defined
119 * parameters. Setting this flag will have no effect on services that do
120 * not use host prefix injection.
121 * - endpoint: (string) The full URI of the webservice. This is only
122 * required when connecting to a custom endpoint (e.g., a local version
123 * of S3).
124 * - endpoint_discovery: (Aws\EndpointDiscovery\ConfigurationInterface,
125 * Aws\CacheInterface, array, callable) Settings for endpoint discovery.
126 * Provide an instance of Aws\EndpointDiscovery\ConfigurationInterface,
127 * an instance Aws\CacheInterface, a callable that provides a promise for
128 * a Configuration object, or an associative array with the following
129 * keys: enabled: (bool) Set to true to enable endpoint discovery, false
130 * to explicitly disable it, defaults to false; cache_limit: (int) The
131 * maximum number of keys in the endpoints cache, defaults to 1000.
132 * - endpoint_provider: (callable) An optional PHP callable that
133 * accepts a hash of options including a "service" and "region" key and
134 * returns NULL or a hash of endpoint data, of which the "endpoint" key
135 * is required. See Aws\Endpoint\EndpointProvider for a list of built-in
136 * providers.
137 * - handler: (callable) A handler that accepts a command object,
138 * request object and returns a promise that is fulfilled with an
139 * Aws\ResultInterface object or rejected with an
140 * Aws\Exception\AwsException. A handler does not accept a next handler
141 * as it is terminal and expected to fulfill a command. If no handler is
142 * provided, a default Guzzle handler will be utilized.
143 * - http: (array, default=array(0)) Set to an array of SDK request
144 * options to apply to each request (e.g., proxy, verify, etc.).
145 * - http_handler: (callable) An HTTP handler is a function that
146 * accepts a PSR-7 request object and returns a promise that is fulfilled
147 * with a PSR-7 response object or rejected with an array of exception
148 * data. NOTE: This option supersedes any provided "handler" option.
149 * - idempotency_auto_fill: (bool|callable) Set to false to disable SDK to
150 * populate parameters that enabled 'idempotencyToken' trait with a random
151 * UUID v4 value on your behalf. Using default value 'true' still allows
152 * parameter value to be overwritten when provided. Note: auto-fill only
153 * works when cryptographically secure random bytes generator functions
154 * (random_bytes, openssl_random_pseudo_bytes or mcrypt_create_iv) can be
155 * found. You may also provide a callable source of random bytes.
156 * - profile: (string) Allows you to specify which profile to use when
157 * credentials are created from the AWS credentials file in your HOME
158 * directory. This setting overrides the AWS_PROFILE environment
159 * variable. Note: Specifying "profile" will cause the "credentials" key
160 * to be ignored.
161 * - region: (string, required) Region to connect to. See
162 * http://docs.aws.amazon.com/general/latest/gr/rande.html for a list of
163 * available regions.
164 * - retries: (int, Aws\Retry\ConfigurationInterface, Aws\CacheInterface,
165 * array, callable) Configures the retry mode and maximum number of
166 * allowed retries for a client (pass 0 to disable retries). Provide an
167 * integer for 'legacy' mode with the specified number of retries.
168 * Otherwise provide an instance of Aws\Retry\ConfigurationInterface, an
169 * instance of Aws\CacheInterface, a callable function, or an array with
170 * the following keys: mode: (string) Set to 'legacy', 'standard' (uses
171 * retry quota management), or 'adapative' (an experimental mode that adds
172 * client-side rate limiting to standard mode); max_attempts (int) The
173 * maximum number of attempts for a given request.
174 * - scheme: (string, default=string(5) "https") URI scheme to use when
175 * connecting connect. The SDK will utilize "https" endpoints (i.e.,
176 * utilize SSL/TLS connections) by default. You can attempt to connect to
177 * a service over an unencrypted "http" endpoint by setting ``scheme`` to
178 * "http".
179 * - signature_provider: (callable) A callable that accepts a signature
180 * version name (e.g., "v4"), a service name, and region, and
181 * returns a SignatureInterface object or null. This provider is used to
182 * create signers utilized by the client. See
183 * Aws\Signature\SignatureProvider for a list of built-in providers
184 * - signature_version: (string) A string representing a custom
185 * signature version to use with a service (e.g., v4). Note that
186 * per/operation signature version MAY override this requested signature
187 * version.
188 * - use_aws_shared_config_files: (bool, default=bool(true)) Set to false to
189 * disable checking for shared config file in '~/.aws/config' and
190 * '~/.aws/credentials'. This will override the AWS_CONFIG_FILE
191 * environment variable.
192 * - validate: (bool, default=bool(true)) Set to false to disable
193 * client-side parameter validation.
194 * - version: (string, required) The version of the webservice to
195 * utilize (e.g., 2006-03-01).
196 * - account_id_endpoint_mode: (string, default(preferred)) this option
197 * decides whether credentials should resolve an accountId value,
198 * which is going to be used as part of the endpoint resolution.
199 * The valid values for this option are:
200 * - preferred: when this value is set then, a warning is logged when
201 * accountId is empty in the resolved identity.
202 * - required: when this value is set then, an exception is thrown when
203 * accountId is empty in the resolved identity.
204 * - disabled: when this value is set then, the validation for if accountId
205 * was resolved or not, is ignored.
206 * - ua_append: (string, array) To pass custom user agent parameters.
207 * - app_id: (string) an optional application specific identifier that can be set.
208 * When set it will be appended to the User-Agent header of every request
209 * in the form of App/{AppId}. This variable is sourced from environment
210 * variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.
211 * See https://docs.aws.amazon.com/sdkref/latest/guide/settings-reference.html for
212 * more information on environment variables and shared config settings.
213 *
214 * @param array $args Client configuration arguments.
215 *
216 * @throws \InvalidArgumentException if any required options are missing or
217 * the service is not supported.
218 */
219 public function __construct(array $args)
220 {
221 list($service, $exceptionClass) = $this->parseClass();
222 if (!isset($args['service'])) {
223 $args['service'] = manifest($service)['endpoint'];
224 }
225 if (!isset($args['exception_class'])) {
226 $args['exception_class'] = $exceptionClass;
227 }
228 $this->handlerList = new HandlerList();
229 $resolver = new ClientResolver(static::getArguments());
230 $config = $resolver->resolve($args, $this->handlerList);
231 $this->api = $config['api'];
232 $this->signatureProvider = $config['signature_provider'];
233 $this->authSchemeResolver = $config['auth_scheme_resolver'];
234 $this->endpoint = new Uri($config['endpoint']);
235 $this->credentialProvider = $config['credentials'];
236 $this->tokenProvider = $config['token'];
237 $this->region = $config['region'] ?? null;
238 $this->signingRegionSet = $config['sigv4a_signing_region_set'] ?? null;
239 $this->config = $config['config'];
240 $this->setClientBuiltIns($args, $config);
241 $this->clientContextParams = $this->setClientContextParams($args);
242 $this->defaultRequestOptions = $config['http'];
243 $this->endpointProvider = $config['endpoint_provider'];
244 $this->serializer = $config['serializer'];
245 $this->addSignatureMiddleware($args);
246 $this->addInvocationId();
247 $this->addEndpointParameterMiddleware($args);
248 $this->addEndpointDiscoveryMiddleware($config, $args);
249 $this->addRequestCompressionMiddleware($config);
250 $this->loadAliases();
251 $this->addStreamRequestPayload();
252 $this->addRecursionDetection();
253 if ($this->isUseEndpointV2()) {
254 $this->addEndpointV2Middleware();
255 }
256 $this->addAuthSelectionMiddleware();
257 if (!\is_null($this->api->getMetadata('awsQueryCompatible'))) {
258 $this->addQueryCompatibleInputMiddleware($this->api);
259 }
260 if (isset($args['with_resolved'])) {
261 $args['with_resolved']($config);
262 }
263 }
264 public function getHandlerList()
265 {
266 return $this->handlerList;
267 }
268 public function getConfig($option = null)
269 {
270 return $option === null ? $this->config : $this->config[$option] ?? null;
271 }
272 public function getCredentials()
273 {
274 $fn = $this->credentialProvider;
275 return $fn();
276 }
277 public function getEndpoint()
278 {
279 return $this->endpoint;
280 }
281 public function getRegion()
282 {
283 return $this->region;
284 }
285 public function getApi()
286 {
287 return $this->api;
288 }
289 public function getCommand($name, array $args = [])
290 {
291 // Fail fast if the command cannot be found in the description.
292 if (!isset($this->getApi()['operations'][$name])) {
293 $name = \ucfirst($name);
294 if (!isset($this->getApi()['operations'][$name])) {
295 throw new \InvalidArgumentException("Operation not found: {$name}");
296 }
297 }
298 if (!isset($args['@http'])) {
299 $args['@http'] = $this->defaultRequestOptions;
300 } else {
301 $args['@http'] += $this->defaultRequestOptions;
302 }
303 return new Command($name, $args, clone $this->getHandlerList());
304 }
305 public function getEndpointProvider()
306 {
307 return $this->endpointProvider;
308 }
309 /**
310 * Provides the set of service context parameter
311 * key-value pairs used for endpoint resolution.
312 *
313 * @return array
314 */
315 public function getClientContextParams()
316 {
317 return $this->clientContextParams;
318 }
319 /**
320 * Provides the set of built-in keys and values
321 * used for endpoint resolution
322 *
323 * @return array
324 */
325 public function getClientBuiltIns()
326 {
327 return $this->clientBuiltIns;
328 }
329 public function __sleep()
330 {
331 throw new \RuntimeException('Instances of ' . static::class . ' cannot be serialized');
332 }
333 /**
334 * Get the signature_provider function of the client.
335 *
336 * @return callable
337 */
338 public final function getSignatureProvider()
339 {
340 return $this->signatureProvider;
341 }
342 /**
343 * Parse the class name and setup the custom exception class of the client
344 * and return the "service" name of the client and "exception_class".
345 *
346 * @return array
347 */
348 private function parseClass()
349 {
350 $klass = \get_class($this);
351 if ($klass === __CLASS__) {
352 return ['', AwsException::class];
353 }
354 $service = \substr($klass, \strrpos($klass, '\\') + 1, -6);
355 return [\strtolower($service), "Dudlewebs\\WPMCS\\s3\\Aws\\{$service}\\Exception\\{$service}Exception"];
356 }
357 private function addEndpointParameterMiddleware($args)
358 {
359 if (empty($args['disable_host_prefix_injection'])) {
360 $list = $this->getHandlerList();
361 $list->appendBuild(EndpointParameterMiddleware::wrap($this->api), 'endpoint_parameter');
362 }
363 }
364 private function addEndpointDiscoveryMiddleware($config, $args)
365 {
366 $list = $this->getHandlerList();
367 if (!isset($args['endpoint'])) {
368 $list->appendBuild(EndpointDiscoveryMiddleware::wrap($this, $args, $config['endpoint_discovery']), 'EndpointDiscoveryMiddleware');
369 }
370 }
371 private function addSignatureMiddleware(array $args)
372 {
373 $api = $this->getApi();
374 $provider = $this->signatureProvider;
375 $signatureVersion = $this->config['signature_version'];
376 $name = $this->config['signing_name'];
377 $region = $this->config['signing_region'];
378 $signingRegionSet = $this->signingRegionSet;
379 if (isset($args['signature_version']) || isset($this->config['configured_signature_version'])) {
380 $configuredSignatureVersion = \true;
381 } else {
382 $configuredSignatureVersion = \false;
383 }
384 $resolver = static function (CommandInterface $c) use($api, $provider, $name, $region, $signatureVersion, $configuredSignatureVersion, $signingRegionSet) {
385 if (!$configuredSignatureVersion) {
386 if (!empty($c['@context']['signing_region'])) {
387 $region = $c['@context']['signing_region'];
388 }
389 if (!empty($c['@context']['signing_service'])) {
390 $name = $c['@context']['signing_service'];
391 }
392 if (!empty($c['@context']['signature_version'])) {
393 $signatureVersion = $c['@context']['signature_version'];
394 }
395 $authType = $api->getOperation($c->getName())['authtype'];
396 switch ($authType) {
397 case 'none':
398 $signatureVersion = 'anonymous';
399 break;
400 case 'v4-unsigned-body':
401 $signatureVersion = 'v4-unsigned-body';
402 break;
403 case 'bearer':
404 $signatureVersion = 'bearer';
405 break;
406 }
407 }
408 if ($signatureVersion === 'v4a') {
409 $commandSigningRegionSet = !empty($c['@context']['signing_region_set']) ? \implode(', ', $c['@context']['signing_region_set']) : null;
410 $region = $signingRegionSet ?? $commandSigningRegionSet ?? $region;
411 }
412 return SignatureProvider::resolve($provider, $signatureVersion, $name, $region);
413 };
414 $this->handlerList->appendSign(Middleware::signer($this->credentialProvider, $resolver, $this->tokenProvider, $this->getConfig()), 'signer');
415 }
416 private function addRequestCompressionMiddleware($config)
417 {
418 if (empty($config['disable_request_compression'])) {
419 $list = $this->getHandlerList();
420 $list->appendBuild(RequestCompressionMiddleware::wrap($config), 'request-compression');
421 }
422 }
423 private function addQueryCompatibleInputMiddleware(Service $api)
424 {
425 $list = $this->getHandlerList();
426 $list->appendValidate(QueryCompatibleInputMiddleware::wrap($api), 'query-compatible-input');
427 }
428 private function addInvocationId()
429 {
430 // Add invocation id to each request
431 $this->handlerList->prependSign(Middleware::invocationId(), 'invocation-id');
432 }
433 private function loadAliases($file = null)
434 {
435 if (!isset($this->aliases)) {
436 if (\is_null($file)) {
437 $file = __DIR__ . '/data/aliases.json';
438 }
439 $aliases = \Dudlewebs\WPMCS\s3\Aws\load_compiled_json($file);
440 $serviceId = $this->api->getServiceId();
441 $version = $this->getApi()->getApiVersion();
442 if (!empty($aliases['operations'][$serviceId][$version])) {
443 $this->aliases = \array_flip($aliases['operations'][$serviceId][$version]);
444 }
445 }
446 }
447 private function addStreamRequestPayload()
448 {
449 $streamRequestPayloadMiddleware = StreamRequestPayloadMiddleware::wrap($this->api);
450 $this->handlerList->prependSign($streamRequestPayloadMiddleware, 'StreamRequestPayloadMiddleware');
451 }
452 private function addRecursionDetection()
453 {
454 // Add recursion detection header to requests
455 // originating in supported Lambda runtimes
456 $this->handlerList->appendBuild(Middleware::recursionDetection(), 'recursion-detection');
457 }
458 private function addAuthSelectionMiddleware()
459 {
460 $list = $this->getHandlerList();
461 $list->prependBuild(AuthSelectionMiddleware::wrap($this->authSchemeResolver, $this->getApi()), 'auth-selection');
462 }
463 private function addEndpointV2Middleware()
464 {
465 $list = $this->getHandlerList();
466 $endpointArgs = $this->getEndpointProviderArgs();
467 $list->prependBuild(EndpointV2Middleware::wrap($this->endpointProvider, $this->getApi(), $endpointArgs, $this->credentialProvider), 'endpoint-resolution');
468 }
469 /**
470 * Retrieves client context param definition from service model,
471 * creates mapping of client context param names with client-provided
472 * values.
473 *
474 * @return array
475 */
476 private function setClientContextParams($args)
477 {
478 $api = $this->getApi();
479 $resolvedParams = [];
480 if (!empty($paramDefinitions = $api->getClientContextParams())) {
481 foreach ($paramDefinitions as $paramName => $paramValue) {
482 if (isset($args[$paramName])) {
483 $resolvedParams[$paramName] = $args[$paramName];
484 }
485 }
486 }
487 return $resolvedParams;
488 }
489 /**
490 * Retrieves and sets default values used for endpoint resolution.
491 */
492 private function setClientBuiltIns($args, $resolvedConfig)
493 {
494 $builtIns = [];
495 $config = $resolvedConfig['config'];
496 $service = $args['service'];
497 $builtIns['SDK::Endpoint'] = null;
498 if (!empty($args['endpoint'])) {
499 $builtIns['SDK::Endpoint'] = $args['endpoint'];
500 } elseif (isset($config['configured_endpoint_url'])) {
501 $builtIns['SDK::Endpoint'] = (string) $this->getEndpoint();
502 }
503 $builtIns['AWS::Region'] = $this->getRegion();
504 $builtIns['AWS::UseFIPS'] = $config['use_fips_endpoint']->isUseFipsEndpoint();
505 $builtIns['AWS::UseDualStack'] = $config['use_dual_stack_endpoint']->isUseDualstackEndpoint();
506 if ($service === 's3' || $service === 's3control') {
507 $builtIns['AWS::S3::UseArnRegion'] = $config['use_arn_region']->isUseArnRegion();
508 }
509 if ($service === 's3') {
510 $builtIns['AWS::S3::UseArnRegion'] = $config['use_arn_region']->isUseArnRegion();
511 $builtIns['AWS::S3::Accelerate'] = $config['use_accelerate_endpoint'];
512 $builtIns['AWS::S3::ForcePathStyle'] = $config['use_path_style_endpoint'];
513 $builtIns['AWS::S3::DisableMultiRegionAccessPoints'] = $config['disable_multiregion_access_points'];
514 }
515 $builtIns['AWS::Auth::AccountIdEndpointMode'] = $resolvedConfig['account_id_endpoint_mode'];
516 $this->clientBuiltIns += $builtIns;
517 }
518 /**
519 * Retrieves arguments to be used in endpoint resolution.
520 *
521 * @return array
522 */
523 public function getEndpointProviderArgs()
524 {
525 return $this->normalizeEndpointProviderArgs();
526 }
527 /**
528 * Combines built-in and client context parameter values in
529 * order of specificity. Client context parameter values supersede
530 * built-in values.
531 *
532 * @return array
533 */
534 private function normalizeEndpointProviderArgs()
535 {
536 $normalizedBuiltIns = [];
537 foreach ($this->clientBuiltIns as $name => $value) {
538 $normalizedName = \explode('::', $name);
539 $normalizedName = $normalizedName[\count($normalizedName) - 1];
540 $normalizedBuiltIns[$normalizedName] = $value;
541 }
542 return \array_merge($normalizedBuiltIns, $this->getClientContextParams());
543 }
544 protected function isUseEndpointV2()
545 {
546 return $this->endpointProvider instanceof EndpointProviderV2;
547 }
548 public static function emitDeprecationWarning()
549 {
550 $phpVersion = \PHP_VERSION_ID;
551 if ($phpVersion < 70205) {
552 $phpVersionString = \phpversion();
553 @\trigger_error("This installation of the SDK is using PHP version" . " {$phpVersionString}, which will be deprecated on August" . " 15th, 2023. Please upgrade your PHP version to a minimum of" . " 7.2.5 before then to continue receiving updates to the AWS" . " SDK for PHP. To disable this warning, set" . " suppress_php_deprecation_warning to true on the client constructor" . " or set the environment variable AWS_SUPPRESS_PHP_DEPRECATION_WARNING" . " to true.", \E_USER_DEPRECATED);
554 }
555 }
556 /**
557 * Returns a service model and doc model with any necessary changes
558 * applied.
559 *
560 * @param array $api Array of service data being documented.
561 * @param array $docs Array of doc model data.
562 *
563 * @return array Tuple containing a [Service, DocModel]
564 *
565 * @internal This should only used to document the service API.
566 * @codeCoverageIgnore
567 */
568 public static function applyDocFilters(array $api, array $docs)
569 {
570 $aliases = \Dudlewebs\WPMCS\s3\Aws\load_compiled_json(__DIR__ . '/data/aliases.json');
571 $serviceId = $api['metadata']['serviceId'] ?? '';
572 $version = $api['metadata']['apiVersion'];
573 // Replace names for any operations with SDK aliases
574 if (!empty($aliases['operations'][$serviceId][$version])) {
575 foreach ($aliases['operations'][$serviceId][$version] as $op => $alias) {
576 $api['operations'][$alias] = $api['operations'][$op];
577 $docs['operations'][$alias] = $docs['operations'][$op];
578 unset($api['operations'][$op], $docs['operations'][$op]);
579 }
580 }
581 \ksort($api['operations']);
582 return [new Service($api, ApiProvider::defaultProvider()), new DocModel($docs)];
583 }
584 /**
585 * @deprecated
586 * @return static
587 */
588 public static function factory(array $config = [])
589 {
590 return new static($config);
591 }
592 }
593