vendor/aws/aws-sdk-php/src/AwsClient.php line 244

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