PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / AwsClient.php
transferito / vendor / aws / aws-sdk-php / src Last commit date
ACMPCA 10 months ago ARCZonalShift 10 months ago AccessAnalyzer 10 months ago Account 10 months ago Acm 10 months ago AlexaForBusiness 10 months ago Amplify 10 months ago AmplifyBackend 10 months ago AmplifyUIBuilder 10 months ago Api 10 months ago ApiGateway 10 months ago ApiGatewayManagementApi 10 months ago ApiGatewayV2 10 months ago AppConfig 10 months ago AppConfigData 10 months ago AppFabric 10 months ago AppIntegrationsService 10 months ago AppMesh 10 months ago AppRegistry 10 months ago AppRunner 10 months ago AppSync 10 months ago Appflow 10 months ago ApplicationAutoScaling 10 months ago ApplicationCostProfiler 10 months ago ApplicationDiscoveryService 10 months ago ApplicationInsights 10 months ago Appstream 10 months ago Arn 10 months ago Athena 10 months ago AuditManager 10 months ago AugmentedAIRuntime 10 months ago AutoScaling 10 months ago AutoScalingPlans 10 months ago B2bi 10 months ago BCMDataExports 10 months ago Backup 10 months ago BackupGateway 10 months ago BackupStorage 10 months ago Batch 10 months ago Bedrock 10 months ago BedrockAgent 10 months ago BedrockAgentRuntime 10 months ago BedrockRuntime 10 months ago BillingConductor 10 months ago Braket 10 months ago Budgets 10 months ago Chime 10 months ago ChimeSDKIdentity 10 months ago ChimeSDKMediaPipelines 10 months ago ChimeSDKMeetings 10 months ago ChimeSDKMessaging 10 months ago ChimeSDKVoice 10 months ago CleanRooms 10 months ago CleanRoomsML 10 months ago ClientSideMonitoring 10 months ago Cloud9 10 months ago CloudControlApi 10 months ago CloudDirectory 10 months ago CloudFormation 10 months ago CloudFront 10 months ago CloudFrontKeyValueStore 10 months ago CloudHSMV2 10 months ago CloudHsm 10 months ago CloudSearch 10 months ago CloudSearchDomain 10 months ago CloudTrail 10 months ago CloudTrailData 10 months ago CloudWatch 10 months ago CloudWatchEvents 10 months ago CloudWatchEvidently 10 months ago CloudWatchLogs 10 months ago CloudWatchRUM 10 months ago CodeArtifact 10 months ago CodeBuild 10 months ago CodeCatalyst 10 months ago CodeCommit 10 months ago CodeDeploy 10 months ago CodeGuruProfiler 10 months ago CodeGuruReviewer 10 months ago CodeGuruSecurity 10 months ago CodePipeline 10 months ago CodeStar 10 months ago CodeStarNotifications 10 months ago CodeStarconnections 10 months ago CognitoIdentity 10 months ago CognitoIdentityProvider 10 months ago CognitoSync 10 months ago Comprehend 10 months ago ComprehendMedical 10 months ago ComputeOptimizer 10 months ago ConfigService 10 months ago Configuration 10 months ago Connect 10 months ago ConnectCampaignService 10 months ago ConnectCases 10 months ago ConnectContactLens 10 months ago ConnectParticipant 10 months ago ConnectWisdomService 10 months ago ControlTower 10 months ago CostExplorer 10 months ago CostOptimizationHub 10 months ago CostandUsageReportService 10 months ago Credentials 10 months ago Crypto 10 months ago CustomerProfiles 10 months ago DAX 10 months ago DLM 10 months ago DataExchange 10 months ago DataPipeline 10 months ago DataSync 10 months ago DataZone 10 months ago DatabaseMigrationService 10 months ago DefaultsMode 10 months ago Detective 10 months ago DevOpsGuru 10 months ago DeviceFarm 10 months ago DirectConnect 10 months ago DirectoryService 10 months ago DocDB 10 months ago DocDBElastic 10 months ago DynamoDb 10 months ago DynamoDbStreams 10 months ago EBS 10 months ago EC2InstanceConnect 10 months ago ECRPublic 10 months ago EKS 10 months ago EKSAuth 10 months ago EMRContainers 10 months ago EMRServerless 10 months ago Ec2 10 months ago Ecr 10 months ago Ecs 10 months ago Efs 10 months ago ElastiCache 10 months ago ElasticBeanstalk 10 months ago ElasticInference 10 months ago ElasticLoadBalancing 10 months ago ElasticLoadBalancingV2 10 months ago ElasticTranscoder 10 months ago ElasticsearchService 10 months ago Emr 10 months ago Endpoint 10 months ago EndpointDiscovery 10 months ago EndpointV2 10 months ago EntityResolution 10 months ago EventBridge 10 months ago Exception 10 months ago FIS 10 months ago FMS 10 months ago FSx 10 months ago FinSpaceData 10 months ago Firehose 10 months ago ForecastQueryService 10 months ago ForecastService 10 months ago FraudDetector 10 months ago FreeTier 10 months ago GameLift 10 months ago Glacier 10 months ago GlobalAccelerator 10 months ago Glue 10 months ago GlueDataBrew 10 months ago Greengrass 10 months ago GreengrassV2 10 months ago GroundStation 10 months ago GuardDuty 10 months ago Handler 10 months ago Health 10 months ago HealthLake 10 months ago Honeycode 10 months ago IVS 10 months ago IVSRealTime 10 months ago Iam 10 months ago Identity 10 months ago IdentityStore 10 months ago ImportExport 10 months ago Inspector 10 months ago Inspector2 10 months ago InspectorScan 10 months ago InternetMonitor 10 months ago IoT1ClickDevicesService 10 months ago IoT1ClickProjects 10 months ago IoTAnalytics 10 months ago IoTDeviceAdvisor 10 months ago IoTEvents 10 months ago IoTEventsData 10 months ago IoTFleetHub 10 months ago IoTFleetWise 10 months ago IoTJobsDataPlane 10 months ago IoTRoboRunner 10 months ago IoTSecureTunneling 10 months ago IoTSiteWise 10 months ago IoTThingsGraph 10 months ago IoTTwinMaker 10 months ago IoTWireless 10 months ago Iot 10 months ago IotDataPlane 10 months ago Kafka 10 months ago KafkaConnect 10 months ago KendraRanking 10 months ago Keyspaces 10 months ago Kinesis 10 months ago KinesisAnalytics 10 months ago KinesisAnalyticsV2 10 months ago KinesisVideo 10 months ago KinesisVideoArchivedMedia 10 months ago KinesisVideoMedia 10 months ago KinesisVideoSignalingChannels 10 months ago KinesisVideoWebRTCStorage 10 months ago Kms 10 months ago LakeFormation 10 months ago Lambda 10 months ago LaunchWizard 10 months ago LexModelBuildingService 10 months ago LexModelsV2 10 months ago LexRuntimeService 10 months ago LexRuntimeV2 10 months ago LicenseManager 10 months ago LicenseManagerLinuxSubscriptions 10 months ago LicenseManagerUserSubscriptions 10 months ago Lightsail 10 months ago LocationService 10 months ago LookoutEquipment 10 months ago LookoutMetrics 10 months ago LookoutforVision 10 months ago MQ 10 months ago MTurk 10 months ago MWAA 10 months ago MachineLearning 10 months ago Macie2 10 months ago MainframeModernization 10 months ago ManagedBlockchain 10 months ago ManagedBlockchainQuery 10 months ago ManagedGrafana 10 months ago MarketplaceAgreement 10 months ago MarketplaceCatalog 10 months ago MarketplaceCommerceAnalytics 10 months ago MarketplaceDeployment 10 months ago MarketplaceEntitlementService 10 months ago MarketplaceMetering 10 months ago MediaConnect 10 months ago MediaConvert 10 months ago MediaLive 10 months ago MediaPackage 10 months ago MediaPackageV2 10 months ago MediaPackageVod 10 months ago MediaStore 10 months ago MediaStoreData 10 months ago MediaTailor 10 months ago MedicalImaging 10 months ago MemoryDB 10 months ago MigrationHub 10 months ago MigrationHubConfig 10 months ago MigrationHubOrchestrator 10 months ago MigrationHubRefactorSpaces 10 months ago MigrationHubStrategyRecommendations 10 months ago Mobile 10 months ago Multipart 10 months ago Neptune 10 months ago Neptunedata 10 months ago NetworkFirewall 10 months ago NetworkManager 10 months ago NimbleStudio 10 months ago OAM 10 months ago OSIS 10 months ago Omics 10 months ago OpenSearchServerless 10 months ago OpenSearchService 10 months ago OpsWorks 10 months ago OpsWorksCM 10 months ago Organizations 10 months ago Outposts 10 months ago PI 10 months ago Panorama 10 months ago PaymentCryptography 10 months ago PaymentCryptographyData 10 months ago PcaConnectorAd 10 months ago Personalize 10 months ago PersonalizeEvents 10 months ago PersonalizeRuntime 10 months ago Pinpoint 10 months ago PinpointEmail 10 months ago PinpointSMSVoice 10 months ago PinpointSMSVoiceV2 10 months ago Pipes 10 months ago Polly 10 months ago Pricing 10 months ago PrivateNetworks 10 months ago PrometheusService 10 months ago Proton 10 months ago QBusiness 10 months ago QConnect 10 months ago QLDB 10 months ago QLDBSession 10 months ago QuickSight 10 months ago RAM 10 months ago RDSDataService 10 months ago Rds 10 months ago RecycleBin 10 months ago Redshift 10 months ago RedshiftDataAPIService 10 months ago RedshiftServerless 10 months ago Rekognition 10 months ago Repostspace 10 months ago ResilienceHub 10 months ago ResourceExplorer2 10 months ago ResourceGroups 10 months ago ResourceGroupsTaggingAPI 10 months ago Retry 10 months ago RoboMaker 10 months ago RolesAnywhere 10 months ago Route53 10 months ago Route53Domains 10 months ago Route53RecoveryCluster 10 months ago Route53RecoveryControlConfig 10 months ago Route53RecoveryReadiness 10 months ago Route53Resolver 10 months ago S3 10 months ago S3Control 10 months ago S3Outposts 10 months ago SSMContacts 10 months ago SSMIncidents 10 months ago SSO 10 months ago SSOAdmin 10 months ago SSOOIDC 10 months ago SageMaker 10 months ago SageMakerFeatureStoreRuntime 10 months ago SageMakerGeospatial 10 months ago SageMakerMetrics 10 months ago SageMakerRuntime 10 months ago SagemakerEdgeManager 10 months ago SavingsPlans 10 months ago Scheduler 10 months ago Schemas 10 months ago Script 10 months ago SecretsManager 10 months ago SecurityHub 10 months ago SecurityLake 10 months ago ServerlessApplicationRepository 10 months ago ServiceCatalog 10 months ago ServiceDiscovery 10 months ago ServiceQuotas 10 months ago Ses 10 months ago SesV2 10 months ago Sfn 10 months ago Shield 10 months ago Signature 10 months ago SimSpaceWeaver 10 months ago Sms 10 months ago SnowBall 10 months ago SnowDeviceManagement 10 months ago Sns 10 months ago Sqs 10 months ago Ssm 10 months ago SsmSap 10 months ago StorageGateway 10 months ago Sts 10 months ago Support 10 months ago SupportApp 10 months ago Swf 10 months ago Synthetics 10 months ago Textract 10 months ago TimestreamQuery 10 months ago TimestreamWrite 10 months ago Tnb 10 months ago Token 10 months ago TranscribeService 10 months ago Transfer 10 months ago Translate 10 months ago TrustedAdvisor 10 months ago VPCLattice 10 months ago VerifiedPermissions 10 months ago VoiceID 10 months ago WAFV2 10 months ago Waf 10 months ago WafRegional 10 months ago WellArchitected 10 months ago WorkDocs 10 months ago WorkLink 10 months ago WorkMail 10 months ago WorkMailMessageFlow 10 months ago WorkSpaces 10 months ago WorkSpacesThinClient 10 months ago WorkSpacesWeb 10 months ago XRay 10 months ago data 10 months ago drs 10 months ago finspace 10 months ago imagebuilder 10 months ago ivschat 10 months ago kendra 10 months ago mgn 10 months ago signer 10 months ago AbstractConfigurationProvider.php 10 months ago AwsClient.php 10 months ago AwsClientInterface.php 10 months ago AwsClientTrait.php 10 months ago CacheInterface.php 10 months ago ClientResolver.php 10 months ago Command.php 10 months ago CommandInterface.php 10 months ago CommandPool.php 10 months ago ConfigurationProviderInterface.php 10 months ago DoctrineCacheAdapter.php 10 months ago EndpointParameterMiddleware.php 10 months ago HandlerList.php 10 months ago HasDataTrait.php 10 months ago HasMonitoringEventsTrait.php 10 months ago HashInterface.php 10 months ago HashingStream.php 10 months ago History.php 10 months ago IdempotencyTokenMiddleware.php 10 months ago InputValidationMiddleware.php 10 months ago JsonCompiler.php 10 months ago LruArrayCache.php 10 months ago Middleware.php 10 months ago MockHandler.php 10 months ago MonitoringEventsInterface.php 10 months ago MultiRegionClient.php 10 months ago PhpHash.php 10 months ago PresignUrlMiddleware.php 10 months ago Psr16CacheAdapter.php 10 months ago PsrCacheAdapter.php 10 months ago QueryCompatibleInputMiddleware.php 10 months ago RequestCompressionMiddleware.php 10 months ago ResponseContainerInterface.php 10 months ago Result.php 10 months ago ResultInterface.php 10 months ago ResultPaginator.php 10 months ago RetryMiddleware.php 10 months ago RetryMiddlewareV2.php 10 months ago Sdk.php 10 months ago StreamRequestPayloadMiddleware.php 10 months ago TraceMiddleware.php 10 months ago Waiter.php 10 months ago WrappedHttpHandler.php 10 months ago functions.php 10 months ago
AwsClient.php
680 lines
1 <?php
2 namespace Aws;
3
4 use Aws\Api\ApiProvider;
5 use Aws\Api\DocModel;
6 use Aws\Api\Service;
7 use Aws\EndpointDiscovery\EndpointDiscoveryMiddleware;
8 use Aws\EndpointV2\EndpointProviderV2;
9 use Aws\EndpointV2\EndpointV2Middleware;
10 use Aws\Exception\AwsException;
11 use Aws\Signature\SignatureProvider;
12 use GuzzleHttp\Psr7\Uri;
13
14 /**
15 * Default AWS client implementation
16 */
17 class AwsClient implements AwsClientInterface
18 {
19 use AwsClientTrait;
20
21 /** @var array */
22 private $aliases;
23
24 /** @var array */
25 private $config;
26
27 /** @var string */
28 private $region;
29
30 /** @var string */
31 private $endpoint;
32
33 /** @var Service */
34 private $api;
35
36 /** @var callable */
37 private $signatureProvider;
38
39 /** @var callable */
40 private $credentialProvider;
41
42 /** @var callable */
43 private $tokenProvider;
44
45 /** @var HandlerList */
46 private $handlerList;
47
48 /** @var array*/
49 private $defaultRequestOptions;
50
51 /** @var array*/
52 private $clientContextParams = [];
53
54 /** @var array*/
55 protected $clientBuiltIns = [];
56
57 /** @var EndpointProviderV2 | callable */
58 protected $endpointProvider;
59
60 /** @var callable */
61 protected $serializer;
62
63 /**
64 * Get an array of client constructor arguments used by the client.
65 *
66 * @return array
67 */
68 public static function getArguments()
69 {
70 return ClientResolver::getDefaultArguments();
71 }
72
73 /**
74 * The client constructor accepts the following options:
75 *
76 * - api_provider: (callable) An optional PHP callable that accepts a
77 * type, service, and version argument, and returns an array of
78 * corresponding configuration data. The type value can be one of api,
79 * waiter, or paginator.
80 * - credentials:
81 * (Aws\Credentials\CredentialsInterface|array|bool|callable) Specifies
82 * the credentials used to sign requests. Provide an
83 * Aws\Credentials\CredentialsInterface object, an associative array of
84 * "key", "secret", and an optional "token" key, `false` to use null
85 * credentials, or a callable credentials provider used to create
86 * credentials or return null. See Aws\Credentials\CredentialProvider for
87 * a list of built-in credentials providers. If no credentials are
88 * provided, the SDK will attempt to load them from the environment.
89 * - token:
90 * (Aws\Token\TokenInterface|array|bool|callable) Specifies
91 * the token used to authorize requests. Provide an
92 * Aws\Token\TokenInterface object, an associative array of
93 * "token" and an optional "expires" key, `false` to use no
94 * token, or a callable token provider used to create a
95 * token or return null. See Aws\Token\TokenProvider for
96 * a list of built-in token providers. If no token is
97 * provided, the SDK will attempt to load one from the environment.
98 * - csm:
99 * (Aws\ClientSideMonitoring\ConfigurationInterface|array|callable) Specifies
100 * the credentials used to sign requests. Provide an
101 * Aws\ClientSideMonitoring\ConfigurationInterface object, a callable
102 * configuration provider used to create client-side monitoring configuration,
103 * `false` to disable csm, or an associative array with the following keys:
104 * enabled: (bool) Set to true to enable client-side monitoring, defaults
105 * to false; host: (string) the host location to send monitoring events to,
106 * defaults to 127.0.0.1; port: (int) The port used for the host connection,
107 * defaults to 31000; client_id: (string) An identifier for this project
108 * - debug: (bool|array) Set to true to display debug information when
109 * sending requests. Alternatively, you can provide an associative array
110 * with the following keys: logfn: (callable) Function that is invoked
111 * with log messages; stream_size: (int) When the size of a stream is
112 * greater than this number, the stream data will not be logged (set to
113 * "0" to not log any stream data); scrub_auth: (bool) Set to false to
114 * disable the scrubbing of auth data from the logged messages; http:
115 * (bool) Set to false to disable the "debug" feature of lower level HTTP
116 * adapters (e.g., verbose curl output).
117 * - stats: (bool|array) Set to true to gather transfer statistics on
118 * requests sent. Alternatively, you can provide an associative array with
119 * the following keys: retries: (bool) Set to false to disable reporting
120 * on retries attempted; http: (bool) Set to true to enable collecting
121 * statistics from lower level HTTP adapters (e.g., values returned in
122 * GuzzleHttp\TransferStats). HTTP handlers must support an
123 * `http_stats_receiver` option for this to have an effect; timer: (bool)
124 * Set to true to enable a command timer that reports the total wall clock
125 * time spent on an operation in seconds.
126 * - disable_host_prefix_injection: (bool) Set to true to disable host prefix
127 * injection logic for services that use it. This disables the entire
128 * prefix injection, including the portions supplied by user-defined
129 * parameters. Setting this flag will have no effect on services that do
130 * not use host prefix injection.
131 * - endpoint: (string) The full URI of the webservice. This is only
132 * required when connecting to a custom endpoint (e.g., a local version
133 * of S3).
134 * - endpoint_discovery: (Aws\EndpointDiscovery\ConfigurationInterface,
135 * Aws\CacheInterface, array, callable) Settings for endpoint discovery.
136 * Provide an instance of Aws\EndpointDiscovery\ConfigurationInterface,
137 * an instance Aws\CacheInterface, a callable that provides a promise for
138 * a Configuration object, or an associative array with the following
139 * keys: enabled: (bool) Set to true to enable endpoint discovery, false
140 * to explicitly disable it, defaults to false; cache_limit: (int) The
141 * maximum number of keys in the endpoints cache, defaults to 1000.
142 * - endpoint_provider: (callable) An optional PHP callable that
143 * accepts a hash of options including a "service" and "region" key and
144 * returns NULL or a hash of endpoint data, of which the "endpoint" key
145 * is required. See Aws\Endpoint\EndpointProvider for a list of built-in
146 * providers.
147 * - handler: (callable) A handler that accepts a command object,
148 * request object and returns a promise that is fulfilled with an
149 * Aws\ResultInterface object or rejected with an
150 * Aws\Exception\AwsException. A handler does not accept a next handler
151 * as it is terminal and expected to fulfill a command. If no handler is
152 * provided, a default Guzzle handler will be utilized.
153 * - http: (array, default=array(0)) Set to an array of SDK request
154 * options to apply to each request (e.g., proxy, verify, etc.).
155 * - http_handler: (callable) An HTTP handler is a function that
156 * accepts a PSR-7 request object and returns a promise that is fulfilled
157 * with a PSR-7 response object or rejected with an array of exception
158 * data. NOTE: This option supersedes any provided "handler" option.
159 * - idempotency_auto_fill: (bool|callable) Set to false to disable SDK to
160 * populate parameters that enabled 'idempotencyToken' trait with a random
161 * UUID v4 value on your behalf. Using default value 'true' still allows
162 * parameter value to be overwritten when provided. Note: auto-fill only
163 * works when cryptographically secure random bytes generator functions
164 * (random_bytes, openssl_random_pseudo_bytes or mcrypt_create_iv) can be
165 * found. You may also provide a callable source of random bytes.
166 * - profile: (string) Allows you to specify which profile to use when
167 * credentials are created from the AWS credentials file in your HOME
168 * directory. This setting overrides the AWS_PROFILE environment
169 * variable. Note: Specifying "profile" will cause the "credentials" key
170 * to be ignored.
171 * - region: (string, required) Region to connect to. See
172 * http://docs.aws.amazon.com/general/latest/gr/rande.html for a list of
173 * available regions.
174 * - retries: (int, Aws\Retry\ConfigurationInterface, Aws\CacheInterface,
175 * array, callable) Configures the retry mode and maximum number of
176 * allowed retries for a client (pass 0 to disable retries). Provide an
177 * integer for 'legacy' mode with the specified number of retries.
178 * Otherwise provide an instance of Aws\Retry\ConfigurationInterface, an
179 * instance of Aws\CacheInterface, a callable function, or an array with
180 * the following keys: mode: (string) Set to 'legacy', 'standard' (uses
181 * retry quota management), or 'adapative' (an experimental mode that adds
182 * client-side rate limiting to standard mode); max_attempts (int) The
183 * maximum number of attempts for a given request.
184 * - scheme: (string, default=string(5) "https") URI scheme to use when
185 * connecting connect. The SDK will utilize "https" endpoints (i.e.,
186 * utilize SSL/TLS connections) by default. You can attempt to connect to
187 * a service over an unencrypted "http" endpoint by setting ``scheme`` to
188 * "http".
189 * - signature_provider: (callable) A callable that accepts a signature
190 * version name (e.g., "v4"), a service name, and region, and
191 * returns a SignatureInterface object or null. This provider is used to
192 * create signers utilized by the client. See
193 * Aws\Signature\SignatureProvider for a list of built-in providers
194 * - signature_version: (string) A string representing a custom
195 * signature version to use with a service (e.g., v4). Note that
196 * per/operation signature version MAY override this requested signature
197 * version.
198 * - use_aws_shared_config_files: (bool, default=bool(true)) Set to false to
199 * disable checking for shared config file in '~/.aws/config' and
200 * '~/.aws/credentials'. This will override the AWS_CONFIG_FILE
201 * environment variable.
202 * - validate: (bool, default=bool(true)) Set to false to disable
203 * client-side parameter validation.
204 * - version: (string, required) The version of the webservice to
205 * utilize (e.g., 2006-03-01).
206 *
207 * @param array $args Client configuration arguments.
208 *
209 * @throws \InvalidArgumentException if any required options are missing or
210 * the service is not supported.
211 */
212 public function __construct(array $args)
213 {
214 list($service, $exceptionClass) = $this->parseClass();
215 if (!isset($args['service'])) {
216 $args['service'] = manifest($service)['endpoint'];
217 }
218 if (!isset($args['exception_class'])) {
219 $args['exception_class'] = $exceptionClass;
220 }
221 $this->handlerList = new HandlerList();
222 $resolver = new ClientResolver(static::getArguments());
223 $config = $resolver->resolve($args, $this->handlerList);
224 $this->api = $config['api'];
225 $this->signatureProvider = $config['signature_provider'];
226 $this->endpoint = new Uri($config['endpoint']);
227 $this->credentialProvider = $config['credentials'];
228 $this->tokenProvider = $config['token'];
229 $this->region = isset($config['region']) ? $config['region'] : null;
230 $this->config = $config['config'];
231 $this->setClientBuiltIns($args);
232 $this->clientContextParams = $this->setClientContextParams($args);
233 $this->defaultRequestOptions = $config['http'];
234 $this->endpointProvider = $config['endpoint_provider'];
235 $this->serializer = $config['serializer'];
236 $this->addSignatureMiddleware();
237 $this->addInvocationId();
238 $this->addEndpointParameterMiddleware($args);
239 $this->addEndpointDiscoveryMiddleware($config, $args);
240 $this->addRequestCompressionMiddleware($config);
241 $this->loadAliases();
242 $this->addStreamRequestPayload();
243 $this->addRecursionDetection();
244 if ($this->isUseEndpointV2()) {
245 $this->addEndpointV2Middleware();
246 }
247
248 if (!is_null($this->api->getMetadata('awsQueryCompatible'))) {
249 $this->addQueryCompatibleInputMiddleware($this->api);
250 }
251
252 if (isset($args['with_resolved'])) {
253 $args['with_resolved']($config);
254 }
255 }
256
257 public function getHandlerList()
258 {
259 return $this->handlerList;
260 }
261
262 public function getConfig($option = null)
263 {
264 return $option === null
265 ? $this->config
266 : (isset($this->config[$option])
267 ? $this->config[$option]
268 : null);
269 }
270
271 public function getCredentials()
272 {
273 $fn = $this->credentialProvider;
274 return $fn();
275 }
276
277
278 public function getEndpoint()
279 {
280 return $this->endpoint;
281 }
282
283 public function getRegion()
284 {
285 return $this->region;
286 }
287
288 public function getApi()
289 {
290 return $this->api;
291 }
292
293 public function getCommand($name, array $args = [])
294 {
295 // Fail fast if the command cannot be found in the description.
296 if (!isset($this->getApi()['operations'][$name])) {
297 $name = ucfirst($name);
298 if (!isset($this->getApi()['operations'][$name])) {
299 throw new \InvalidArgumentException("Operation not found: $name");
300 }
301 }
302
303 if (!isset($args['@http'])) {
304 $args['@http'] = $this->defaultRequestOptions;
305 } else {
306 $args['@http'] += $this->defaultRequestOptions;
307 }
308
309 return new Command($name, $args, clone $this->getHandlerList());
310 }
311
312 public function getEndpointProvider()
313 {
314 return $this->endpointProvider;
315 }
316
317 /**
318 * Provides the set of service context parameter
319 * key-value pairs used for endpoint resolution.
320 *
321 * @return array
322 */
323 public function getClientContextParams()
324 {
325 return $this->clientContextParams;
326 }
327
328 /**
329 * Provides the set of built-in keys and values
330 * used for endpoint resolution
331 *
332 * @return array
333 */
334 public function getClientBuiltIns()
335 {
336 return $this->clientBuiltIns;
337 }
338
339 public function __sleep()
340 {
341 throw new \RuntimeException('Instances of ' . static::class
342 . ' cannot be serialized');
343 }
344
345 /**
346 * Get the signature_provider function of the client.
347 *
348 * @return callable
349 */
350 final public function getSignatureProvider()
351 {
352 return $this->signatureProvider;
353 }
354
355 /**
356 * Parse the class name and setup the custom exception class of the client
357 * and return the "service" name of the client and "exception_class".
358 *
359 * @return array
360 */
361 private function parseClass()
362 {
363 $klass = get_class($this);
364
365 if ($klass === __CLASS__) {
366 return ['', AwsException::class];
367 }
368
369 $service = substr($klass, strrpos($klass, '\\') + 1, -6);
370
371 return [
372 strtolower($service),
373 "Aws\\{$service}\\Exception\\{$service}Exception"
374 ];
375 }
376
377 private function addEndpointParameterMiddleware($args)
378 {
379 if (empty($args['disable_host_prefix_injection'])) {
380 $list = $this->getHandlerList();
381 $list->appendBuild(
382 EndpointParameterMiddleware::wrap(
383 $this->api
384 ),
385 'endpoint_parameter'
386 );
387 }
388 }
389
390 private function addEndpointDiscoveryMiddleware($config, $args)
391 {
392 $list = $this->getHandlerList();
393
394 if (!isset($args['endpoint'])) {
395 $list->appendBuild(
396 EndpointDiscoveryMiddleware::wrap(
397 $this,
398 $args,
399 $config['endpoint_discovery']
400 ),
401 'EndpointDiscoveryMiddleware'
402 );
403 }
404 }
405
406 private function addSignatureMiddleware()
407 {
408 $api = $this->getApi();
409 $provider = $this->signatureProvider;
410 $version = $this->config['signature_version'];
411 $name = $this->config['signing_name'];
412 $region = $this->config['signing_region'];
413
414 $resolver = static function (
415 CommandInterface $c
416 ) use ($api, $provider, $name, $region, $version) {
417 if (!empty($c['@context']['signing_region'])) {
418 $region = $c['@context']['signing_region'];
419 }
420 if (!empty($c['@context']['signing_service'])) {
421 $name = $c['@context']['signing_service'];
422 }
423
424 $authType = $api->getOperation($c->getName())['authtype'];
425 switch ($authType){
426 case 'none':
427 $version = 'anonymous';
428 break;
429 case 'v4-unsigned-body':
430 $version = 'v4-unsigned-body';
431 break;
432 case 'bearer':
433 $version = 'bearer';
434 break;
435 }
436 if (isset($c['@context']['signature_version'])) {
437 if ($c['@context']['signature_version'] == 'v4a') {
438 $version = 'v4a';
439 }
440 }
441 if (!empty($endpointAuthSchemes = $c->getAuthSchemes())) {
442 $version = $endpointAuthSchemes['version'];
443 $name = isset($endpointAuthSchemes['name']) ?
444 $endpointAuthSchemes['name'] : $name;
445 $region = isset($endpointAuthSchemes['region']) ?
446 $endpointAuthSchemes['region'] : $region;
447 }
448 return SignatureProvider::resolve($provider, $version, $name, $region);
449 };
450 $this->handlerList->appendSign(
451 Middleware::signer($this->credentialProvider,
452 $resolver,
453 $this->tokenProvider,
454 $this->getConfig()
455 ),
456 'signer'
457 );
458 }
459
460 private function addRequestCompressionMiddleware($config)
461 {
462 if (empty($config['disable_request_compression'])) {
463 $list = $this->getHandlerList();
464 $list->appendBuild(
465 RequestCompressionMiddleware::wrap($config),
466 'request-compression'
467 );
468 }
469 }
470
471 private function addQueryCompatibleInputMiddleware(Service $api)
472 {
473 $list = $this->getHandlerList();
474 $list->appendValidate(
475 QueryCompatibleInputMiddleware::wrap($api),
476 'query-compatible-input'
477 );
478 }
479
480 private function addInvocationId()
481 {
482 // Add invocation id to each request
483 $this->handlerList->prependSign(Middleware::invocationId(), 'invocation-id');
484 }
485
486 private function loadAliases($file = null)
487 {
488 if (!isset($this->aliases)) {
489 if (is_null($file)) {
490 $file = __DIR__ . '/data/aliases.json';
491 }
492 $aliases = \Aws\load_compiled_json($file);
493 $serviceId = $this->api->getServiceId();
494 $version = $this->getApi()->getApiVersion();
495 if (!empty($aliases['operations'][$serviceId][$version])) {
496 $this->aliases = array_flip($aliases['operations'][$serviceId][$version]);
497 }
498 }
499 }
500
501 private function addStreamRequestPayload()
502 {
503 $streamRequestPayloadMiddleware = StreamRequestPayloadMiddleware::wrap(
504 $this->api
505 );
506
507 $this->handlerList->prependSign(
508 $streamRequestPayloadMiddleware,
509 'StreamRequestPayloadMiddleware'
510 );
511 }
512
513 private function addRecursionDetection()
514 {
515 // Add recursion detection header to requests
516 // originating in supported Lambda runtimes
517 $this->handlerList->appendBuild(
518 Middleware::recursionDetection(), 'recursion-detection'
519 );
520 }
521
522 private function addEndpointV2Middleware()
523 {
524 $list = $this->getHandlerList();
525 $endpointArgs = $this->getEndpointProviderArgs();
526
527 $list->prependBuild(
528 EndpointV2Middleware::wrap(
529 $this->endpointProvider,
530 $this->getApi(),
531 $endpointArgs
532 ),
533 'endpoint-resolution'
534 );
535 }
536
537 /**
538 * Retrieves client context param definition from service model,
539 * creates mapping of client context param names with client-provided
540 * values.
541 *
542 * @return array
543 */
544 private function setClientContextParams($args)
545 {
546 $api = $this->getApi();
547 $resolvedParams = [];
548 if (!empty($paramDefinitions = $api->getClientContextParams())) {
549 foreach($paramDefinitions as $paramName => $paramValue) {
550 if (isset($args[$paramName])) {
551 $result[$paramName] = $args[$paramName];
552 }
553 }
554 }
555 return $resolvedParams;
556 }
557
558 /**
559 * Retrieves and sets default values used for endpoint resolution.
560 */
561 private function setClientBuiltIns($args)
562 {
563 $builtIns = [];
564 $config = $this->getConfig();
565 $service = $args['service'];
566
567 $builtIns['SDK::Endpoint'] = isset($args['endpoint']) ? $args['endpoint'] : null;
568 $builtIns['AWS::Region'] = $this->getRegion();
569 $builtIns['AWS::UseFIPS'] = $config['use_fips_endpoint']->isUseFipsEndpoint();
570 $builtIns['AWS::UseDualStack'] = $config['use_dual_stack_endpoint']->isUseDualstackEndpoint();
571 if ($service === 's3' || $service === 's3control'){
572 $builtIns['AWS::S3::UseArnRegion'] = $config['use_arn_region']->isUseArnRegion();
573 }
574 if ($service === 's3') {
575 $builtIns['AWS::S3::UseArnRegion'] = $config['use_arn_region']->isUseArnRegion();
576 $builtIns['AWS::S3::Accelerate'] = $config['use_accelerate_endpoint'];
577 $builtIns['AWS::S3::ForcePathStyle'] = $config['use_path_style_endpoint'];
578 $builtIns['AWS::S3::DisableMultiRegionAccessPoints'] = $config['disable_multiregion_access_points'];
579 }
580 $this->clientBuiltIns += $builtIns;
581 }
582
583 /**
584 * Retrieves arguments to be used in endpoint resolution.
585 *
586 * @return array
587 */
588 public function getEndpointProviderArgs()
589 {
590 return $this->normalizeEndpointProviderArgs();
591 }
592
593 /**
594 * Combines built-in and client context parameter values in
595 * order of specificity. Client context parameter values supersede
596 * built-in values.
597 *
598 * @return array
599 */
600 private function normalizeEndpointProviderArgs()
601 {
602 $normalizedBuiltIns = [];
603
604 foreach($this->clientBuiltIns as $name => $value) {
605 $normalizedName = explode('::', $name);
606 $normalizedName = $normalizedName[count($normalizedName) - 1];
607 $normalizedBuiltIns[$normalizedName] = $value;
608 }
609
610 return array_merge($normalizedBuiltIns, $this->getClientContextParams());
611 }
612
613 protected function isUseEndpointV2()
614 {
615 return $this->endpointProvider instanceof EndpointProviderV2;
616 }
617
618 public static function emitDeprecationWarning() {
619 $phpVersion = PHP_VERSION_ID;
620 if ($phpVersion < 70205) {
621 $phpVersionString = phpversion();
622 @trigger_error(
623 "This installation of the SDK is using PHP version"
624 . " {$phpVersionString}, which will be deprecated on August"
625 . " 15th, 2023. Please upgrade your PHP version to a minimum of"
626 . " 7.2.5 before then to continue receiving updates to the AWS"
627 . " SDK for PHP. To disable this warning, set"
628 . " suppress_php_deprecation_warning to true on the client constructor"
629 . " or set the environment variable AWS_SUPPRESS_PHP_DEPRECATION_WARNING"
630 . " to true.",
631 E_USER_DEPRECATED
632 );
633 }
634 }
635
636
637 /**
638 * Returns a service model and doc model with any necessary changes
639 * applied.
640 *
641 * @param array $api Array of service data being documented.
642 * @param array $docs Array of doc model data.
643 *
644 * @return array Tuple containing a [Service, DocModel]
645 *
646 * @internal This should only used to document the service API.
647 * @codeCoverageIgnore
648 */
649 public static function applyDocFilters(array $api, array $docs)
650 {
651 $aliases = \Aws\load_compiled_json(__DIR__ . '/data/aliases.json');
652 $serviceId = $api['metadata']['serviceId'];
653 $version = $api['metadata']['apiVersion'];
654
655 // Replace names for any operations with SDK aliases
656 if (!empty($aliases['operations'][$serviceId][$version])) {
657 foreach ($aliases['operations'][$serviceId][$version] as $op => $alias) {
658 $api['operations'][$alias] = $api['operations'][$op];
659 $docs['operations'][$alias] = $docs['operations'][$op];
660 unset($api['operations'][$op], $docs['operations'][$op]);
661 }
662 }
663 ksort($api['operations']);
664
665 return [
666 new Service($api, ApiProvider::defaultProvider()),
667 new DocModel($docs)
668 ];
669 }
670
671 /**
672 * @deprecated
673 * @return static
674 */
675 public static function factory(array $config = [])
676 {
677 return new static($config);
678 }
679 }
680