| 1 |
<?php |
| 2 |
namespace Aws; |
| 3 |
|
| 4 |
use Aws\Api\ApiProvider; |
| 5 |
use Aws\Api\DocModel; |
| 6 |
use Aws\Api\Service; |
| 7 |
use Aws\Auth\AuthSelectionMiddleware; |
| 8 |
use Aws\Auth\AuthSchemeResolverInterface; |
| 9 |
use Aws\EndpointDiscovery\EndpointDiscoveryMiddleware; |
| 10 |
use Aws\EndpointV2\EndpointProviderV2; |
| 11 |
use Aws\EndpointV2\EndpointV2Middleware; |
| 12 |
use Aws\Exception\AwsException; |
| 13 |
use Aws\Signature\SignatureProvider; |
| 14 |
use GuzzleHttp\Psr7\Uri; |
| 15 |
use Psr\Http\Message\RequestInterface; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
class AwsClient implements AwsClientInterface |
| 21 |
{ |
| 22 |
use AwsClientTrait; |
| 23 |
|
| 24 |
|
| 25 |
private $aliases; |
| 26 |
|
| 27 |
|
| 28 |
private $config; |
| 29 |
|
| 30 |
|
| 31 |
private $region; |
| 32 |
|
| 33 |
|
| 34 |
private $signingRegionSet; |
| 35 |
|
| 36 |
|
| 37 |
private $endpoint; |
| 38 |
|
| 39 |
|
| 40 |
private $api; |
| 41 |
|
| 42 |
|
| 43 |
private $signatureProvider; |
| 44 |
|
| 45 |
|
| 46 |
private $authSchemeResolver; |
| 47 |
|
| 48 |
|
| 49 |
private $credentialProvider; |
| 50 |
|
| 51 |
|
| 52 |
private $tokenProvider; |
| 53 |
|
| 54 |
|
| 55 |
private $handlerList; |
| 56 |
|
| 57 |
|
| 58 |
private $defaultRequestOptions; |
| 59 |
|
| 60 |
|
| 61 |
private $clientContextParams = []; |
| 62 |
|
| 63 |
|
| 64 |
protected $clientBuiltIns = []; |
| 65 |
|
| 66 |
|
| 67 |
protected $endpointProvider; |
| 68 |
|
| 69 |
|
| 70 |
protected $serializer; |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
public static function getArguments() |
| 78 |
{ |
| 79 |
return ClientResolver::getDefaultArguments(); |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
public function __construct(array $args) |
| 239 |
{ |
| 240 |
list($service, $exceptionClass) = $this->parseClass(); |
| 241 |
if (!isset($args['service'])) { |
| 242 |
$args['service'] = manifest($service)['endpoint']; |
| 243 |
} |
| 244 |
if (!isset($args['exception_class'])) { |
| 245 |
$args['exception_class'] = $exceptionClass; |
| 246 |
} |
| 247 |
$this->handlerList = new HandlerList(); |
| 248 |
$resolver = new ClientResolver(static::getArguments()); |
| 249 |
$config = $resolver->resolve($args, $this->handlerList); |
| 250 |
$this->api = $config['api']; |
| 251 |
$this->signatureProvider = $config['signature_provider']; |
| 252 |
$this->authSchemeResolver = $config['auth_scheme_resolver']; |
| 253 |
$this->endpoint = new Uri($config['endpoint']); |
| 254 |
$this->credentialProvider = $config['credentials']; |
| 255 |
$this->tokenProvider = $config['token']; |
| 256 |
$this->region = $config['region'] ?? null; |
| 257 |
$this->signingRegionSet = $config['sigv4a_signing_region_set'] ?? null; |
| 258 |
$this->config = $config['config']; |
| 259 |
$this->setClientBuiltIns($args, $config); |
| 260 |
$this->clientContextParams = $this->setClientContextParams($args); |
| 261 |
$this->defaultRequestOptions = $config['http']; |
| 262 |
$this->endpointProvider = $config['endpoint_provider']; |
| 263 |
$this->serializer = $config['serializer']; |
| 264 |
$this->addSignatureMiddleware($args); |
| 265 |
$this->addInvocationId(); |
| 266 |
$this->addEndpointParameterMiddleware($args); |
| 267 |
$this->addEndpointDiscoveryMiddleware($config, $args); |
| 268 |
$this->addRequestCompressionMiddleware($config); |
| 269 |
$this->loadAliases(); |
| 270 |
$this->addStreamRequestPayload(); |
| 271 |
$this->addRecursionDetection(); |
| 272 |
if ($this->isUseEndpointV2()) { |
| 273 |
$this->addEndpointV2Middleware(); |
| 274 |
} |
| 275 |
$this->addAuthSelectionMiddleware($config['config']); |
| 276 |
|
| 277 |
if (!is_null($this->api->getMetadata('awsQueryCompatible'))) { |
| 278 |
$this->addQueryCompatibleInputMiddleware($this->api); |
| 279 |
$this->addQueryModeHeader(); |
| 280 |
} |
| 281 |
|
| 282 |
if (isset($args['with_resolved'])) { |
| 283 |
$args['with_resolved']($config); |
| 284 |
} |
| 285 |
$this->addUserAgentMiddleware($config); |
| 286 |
$this->addEventStreamHttpFlagMiddleware(); |
| 287 |
} |
| 288 |
|
| 289 |
public function getHandlerList() |
| 290 |
{ |
| 291 |
return $this->handlerList; |
| 292 |
} |
| 293 |
|
| 294 |
public function getConfig($option = null) |
| 295 |
{ |
| 296 |
return $option === null |
| 297 |
? $this->config |
| 298 |
: $this->config[$option] ?? null; |
| 299 |
} |
| 300 |
|
| 301 |
public function getCredentials() |
| 302 |
{ |
| 303 |
$fn = $this->credentialProvider; |
| 304 |
return $fn(); |
| 305 |
} |
| 306 |
|
| 307 |
public function getToken() |
| 308 |
{ |
| 309 |
$fn = $this->tokenProvider; |
| 310 |
return $fn(); |
| 311 |
} |
| 312 |
|
| 313 |
|
| 314 |
public function getEndpoint() |
| 315 |
{ |
| 316 |
return $this->endpoint; |
| 317 |
} |
| 318 |
|
| 319 |
public function getRegion() |
| 320 |
{ |
| 321 |
return $this->region; |
| 322 |
} |
| 323 |
|
| 324 |
public function getApi() |
| 325 |
{ |
| 326 |
return $this->api; |
| 327 |
} |
| 328 |
|
| 329 |
public function getCommand($name, array $args = []) |
| 330 |
{ |
| 331 |
|
| 332 |
if (!isset($this->getApi()['operations'][$name])) { |
| 333 |
$name = ucfirst($name); |
| 334 |
if (!isset($this->getApi()['operations'][$name])) { |
| 335 |
throw new \InvalidArgumentException("Operation not found: $name"); |
| 336 |
} |
| 337 |
} |
| 338 |
|
| 339 |
if (!isset($args['@http'])) { |
| 340 |
$args['@http'] = $this->defaultRequestOptions; |
| 341 |
} else { |
| 342 |
$args['@http'] += $this->defaultRequestOptions; |
| 343 |
} |
| 344 |
|
| 345 |
return new Command($name, $args, clone $this->getHandlerList()); |
| 346 |
} |
| 347 |
|
| 348 |
public function getEndpointProvider() |
| 349 |
{ |
| 350 |
return $this->endpointProvider; |
| 351 |
} |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
public function getClientContextParams() |
| 360 |
{ |
| 361 |
return $this->clientContextParams; |
| 362 |
} |
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
public function getClientBuiltIns() |
| 371 |
{ |
| 372 |
return $this->clientBuiltIns; |
| 373 |
} |
| 374 |
|
| 375 |
public function __sleep() |
| 376 |
{ |
| 377 |
throw new \RuntimeException('Instances of ' . static::class |
| 378 |
. ' cannot be serialized'); |
| 379 |
} |
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
final public function getSignatureProvider() |
| 387 |
{ |
| 388 |
return $this->signatureProvider; |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
private function parseClass() |
| 398 |
{ |
| 399 |
$klass = get_class($this); |
| 400 |
|
| 401 |
if ($klass === __CLASS__) { |
| 402 |
return ['', AwsException::class]; |
| 403 |
} |
| 404 |
|
| 405 |
$service = substr($klass, strrpos($klass, '\\') + 1, -6); |
| 406 |
|
| 407 |
return [ |
| 408 |
strtolower($service), |
| 409 |
"Aws\\{$service}\\Exception\\{$service}Exception" |
| 410 |
]; |
| 411 |
} |
| 412 |
|
| 413 |
private function addEndpointParameterMiddleware($args) |
| 414 |
{ |
| 415 |
if (empty($args['disable_host_prefix_injection'])) { |
| 416 |
$list = $this->getHandlerList(); |
| 417 |
$list->appendBuild( |
| 418 |
EndpointParameterMiddleware::wrap( |
| 419 |
$this->api |
| 420 |
), |
| 421 |
'endpoint_parameter' |
| 422 |
); |
| 423 |
} |
| 424 |
} |
| 425 |
|
| 426 |
private function addEndpointDiscoveryMiddleware($config, $args) |
| 427 |
{ |
| 428 |
$list = $this->getHandlerList(); |
| 429 |
|
| 430 |
if (!isset($args['endpoint'])) { |
| 431 |
$list->appendBuild( |
| 432 |
EndpointDiscoveryMiddleware::wrap( |
| 433 |
$this, |
| 434 |
$args, |
| 435 |
$config['endpoint_discovery'] |
| 436 |
), |
| 437 |
'EndpointDiscoveryMiddleware' |
| 438 |
); |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
private function addSignatureMiddleware(array $args) |
| 443 |
{ |
| 444 |
$api = $this->getApi(); |
| 445 |
$provider = $this->signatureProvider; |
| 446 |
$signatureVersion = $this->config['signature_version']; |
| 447 |
$name = $this->config['signing_name']; |
| 448 |
$region = $this->config['signing_region']; |
| 449 |
$signingRegionSet = $this->signingRegionSet; |
| 450 |
|
| 451 |
if (isset($args['signature_version']) |
| 452 |
|| isset($this->config['configured_signature_version']) |
| 453 |
) { |
| 454 |
$configuredSignatureVersion = true; |
| 455 |
} else { |
| 456 |
$configuredSignatureVersion = false; |
| 457 |
} |
| 458 |
|
| 459 |
$resolver = static function ( |
| 460 |
CommandInterface $command |
| 461 |
) use ( |
| 462 |
$api, |
| 463 |
$provider, |
| 464 |
$name, |
| 465 |
$region, |
| 466 |
$signatureVersion, |
| 467 |
$configuredSignatureVersion, |
| 468 |
$signingRegionSet |
| 469 |
) { |
| 470 |
if (!$configuredSignatureVersion) { |
| 471 |
if (!empty($command['@context']['signing_region'])) { |
| 472 |
$region = $command['@context']['signing_region']; |
| 473 |
} |
| 474 |
if (!empty($command['@context']['signing_service'])) { |
| 475 |
$name = $command['@context']['signing_service']; |
| 476 |
} |
| 477 |
if (!empty($command['@context']['signature_version'])) { |
| 478 |
$signatureVersion = $command['@context']['signature_version']; |
| 479 |
} |
| 480 |
|
| 481 |
$authType = $api->getOperation($command->getName())['authtype']; |
| 482 |
switch ($authType){ |
| 483 |
case 'none': |
| 484 |
$signatureVersion = 'anonymous'; |
| 485 |
break; |
| 486 |
case 'v4-unsigned-body': |
| 487 |
$signatureVersion = 'v4-unsigned-body'; |
| 488 |
break; |
| 489 |
case 'bearer': |
| 490 |
$signatureVersion = 'bearer'; |
| 491 |
break; |
| 492 |
} |
| 493 |
} |
| 494 |
|
| 495 |
if ($signatureVersion === 'v4a') { |
| 496 |
$commandSigningRegionSet = !empty($command['@context']['signing_region_set']) |
| 497 |
? implode(', ', $command['@context']['signing_region_set']) |
| 498 |
: null; |
| 499 |
|
| 500 |
$region = $signingRegionSet |
| 501 |
?? $commandSigningRegionSet |
| 502 |
?? $region; |
| 503 |
} |
| 504 |
|
| 505 |
|
| 506 |
$command->getMetricsBuilder()->identifyMetricByValueAndAppend( |
| 507 |
'signature', |
| 508 |
$signatureVersion |
| 509 |
); |
| 510 |
|
| 511 |
return SignatureProvider::resolve($provider, $signatureVersion, $name, $region); |
| 512 |
}; |
| 513 |
$this->handlerList->appendSign( |
| 514 |
Middleware::signer($this->credentialProvider, |
| 515 |
$resolver, |
| 516 |
$this->tokenProvider, |
| 517 |
$this->getConfig() |
| 518 |
), |
| 519 |
'signer' |
| 520 |
); |
| 521 |
} |
| 522 |
|
| 523 |
private function addRequestCompressionMiddleware($config) |
| 524 |
{ |
| 525 |
if (empty($config['disable_request_compression'])) { |
| 526 |
$list = $this->getHandlerList(); |
| 527 |
$list->appendBuild( |
| 528 |
RequestCompressionMiddleware::wrap($config), |
| 529 |
'request-compression' |
| 530 |
); |
| 531 |
} |
| 532 |
} |
| 533 |
|
| 534 |
private function addQueryCompatibleInputMiddleware(Service $api) |
| 535 |
{ |
| 536 |
$list = $this->getHandlerList(); |
| 537 |
$list->appendValidate( |
| 538 |
QueryCompatibleInputMiddleware::wrap($api), |
| 539 |
'query-compatible-input' |
| 540 |
); |
| 541 |
} |
| 542 |
|
| 543 |
private function addQueryModeHeader(): void |
| 544 |
{ |
| 545 |
$list = $this->getHandlerList(); |
| 546 |
$list->appendBuild( |
| 547 |
Middleware::mapRequest(static function (RequestInterface $r) { |
| 548 |
return $r->withHeader( |
| 549 |
'x-amzn-query-mode', |
| 550 |
"true" |
| 551 |
); |
| 552 |
}), |
| 553 |
'x-amzn-query-mode-header' |
| 554 |
); |
| 555 |
} |
| 556 |
|
| 557 |
private function addInvocationId() |
| 558 |
{ |
| 559 |
|
| 560 |
$this->handlerList->prependSign(Middleware::invocationId(), 'invocation-id'); |
| 561 |
} |
| 562 |
|
| 563 |
private function loadAliases($file = null) |
| 564 |
{ |
| 565 |
if (!isset($this->aliases)) { |
| 566 |
if (is_null($file)) { |
| 567 |
$file = __DIR__ . '/data/aliases.json'; |
| 568 |
} |
| 569 |
$aliases = \Aws\load_compiled_json($file); |
| 570 |
$serviceId = $this->api->getServiceId(); |
| 571 |
$version = $this->getApi()->getApiVersion(); |
| 572 |
$serviceAliases = null; |
| 573 |
|
| 574 |
if (!is_null($serviceId) && isset($aliases['operations'][$serviceId])) { |
| 575 |
$serviceAliases = $aliases['operations'][$serviceId]; |
| 576 |
} |
| 577 |
|
| 578 |
if ($serviceAliases && isset($serviceAliases[$version])) { |
| 579 |
$this->aliases = array_flip($serviceAliases[$version]); |
| 580 |
} |
| 581 |
} |
| 582 |
} |
| 583 |
|
| 584 |
private function addStreamRequestPayload() |
| 585 |
{ |
| 586 |
$streamRequestPayloadMiddleware = StreamRequestPayloadMiddleware::wrap( |
| 587 |
$this->api |
| 588 |
); |
| 589 |
|
| 590 |
$this->handlerList->prependSign( |
| 591 |
$streamRequestPayloadMiddleware, |
| 592 |
'StreamRequestPayloadMiddleware' |
| 593 |
); |
| 594 |
} |
| 595 |
|
| 596 |
private function addRecursionDetection() |
| 597 |
{ |
| 598 |
|
| 599 |
|
| 600 |
$this->handlerList->appendBuild( |
| 601 |
Middleware::recursionDetection(), 'recursion-detection' |
| 602 |
); |
| 603 |
} |
| 604 |
|
| 605 |
private function addAuthSelectionMiddleware(array $args) |
| 606 |
{ |
| 607 |
$list = $this->getHandlerList(); |
| 608 |
|
| 609 |
$list->prependBuild( |
| 610 |
AuthSelectionMiddleware::wrap( |
| 611 |
$this->authSchemeResolver, |
| 612 |
$this->getApi(), |
| 613 |
$args['auth_scheme_preference'] ?? null |
| 614 |
), |
| 615 |
'auth-selection' |
| 616 |
); |
| 617 |
} |
| 618 |
|
| 619 |
private function addEndpointV2Middleware() |
| 620 |
{ |
| 621 |
$list = $this->getHandlerList(); |
| 622 |
$endpointArgs = $this->getEndpointProviderArgs(); |
| 623 |
|
| 624 |
$list->prependBuild( |
| 625 |
EndpointV2Middleware::wrap( |
| 626 |
$this->endpointProvider, |
| 627 |
$this->getApi(), |
| 628 |
$endpointArgs, |
| 629 |
$this->credentialProvider |
| 630 |
), |
| 631 |
'endpoint-resolution' |
| 632 |
); |
| 633 |
} |
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
private function addUserAgentMiddleware($args) |
| 646 |
{ |
| 647 |
$this->getHandlerList()->appendSign( |
| 648 |
UserAgentMiddleware::wrap($args), |
| 649 |
'user-agent' |
| 650 |
); |
| 651 |
} |
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
private function addEventStreamHttpFlagMiddleware(): void |
| 659 |
{ |
| 660 |
$api = $this->getApi(); |
| 661 |
$this->getHandlerList() |
| 662 |
-> appendInit( |
| 663 |
static function (callable $handler) use ($api) { |
| 664 |
return static function (CommandInterface $command, $request = null) use ($handler, $api) { |
| 665 |
$operation = $api->getOperation($command->getName()); |
| 666 |
$output = $operation->getOutput(); |
| 667 |
foreach ($output->getMembers() as $memberProps) { |
| 668 |
if (!empty($memberProps['eventstream'])) { |
| 669 |
$command['@http']['stream'] = true; |
| 670 |
break; |
| 671 |
} |
| 672 |
} |
| 673 |
|
| 674 |
return $handler($command, $request); |
| 675 |
}; |
| 676 |
}, |
| 677 |
'event-streaming-flag-middleware' |
| 678 |
); |
| 679 |
} |
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
private function setClientContextParams($args) |
| 689 |
{ |
| 690 |
$api = $this->getApi(); |
| 691 |
$resolvedParams = []; |
| 692 |
if (!empty($paramDefinitions = $api->getClientContextParams())) { |
| 693 |
foreach($paramDefinitions as $paramName => $paramValue) { |
| 694 |
if (isset($args[$paramName])) { |
| 695 |
$resolvedParams[$paramName] = $args[$paramName]; |
| 696 |
} |
| 697 |
} |
| 698 |
} |
| 699 |
return $resolvedParams; |
| 700 |
} |
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
private function setClientBuiltIns($args, $resolvedConfig) |
| 706 |
{ |
| 707 |
$builtIns = []; |
| 708 |
$config = $resolvedConfig['config']; |
| 709 |
$service = $args['service']; |
| 710 |
|
| 711 |
$builtIns['SDK::Endpoint'] = null; |
| 712 |
if (!empty($args['endpoint'])) { |
| 713 |
$builtIns['SDK::Endpoint'] = $args['endpoint']; |
| 714 |
} elseif (isset($config['configured_endpoint_url'])) { |
| 715 |
$builtIns['SDK::Endpoint'] = (string) $this->getEndpoint(); |
| 716 |
} |
| 717 |
$builtIns['AWS::Region'] = $this->getRegion(); |
| 718 |
$builtIns['AWS::UseFIPS'] = $config['use_fips_endpoint']->isUseFipsEndpoint(); |
| 719 |
$builtIns['AWS::UseDualStack'] = $config['use_dual_stack_endpoint']->isUseDualstackEndpoint(); |
| 720 |
if ($service === 's3' || $service === 's3control'){ |
| 721 |
$builtIns['AWS::S3::UseArnRegion'] = $config['use_arn_region']->isUseArnRegion(); |
| 722 |
} |
| 723 |
if ($service === 's3') { |
| 724 |
$builtIns['AWS::S3::UseArnRegion'] = $config['use_arn_region']->isUseArnRegion(); |
| 725 |
$builtIns['AWS::S3::Accelerate'] = $config['use_accelerate_endpoint']; |
| 726 |
$builtIns['AWS::S3::ForcePathStyle'] = $config['use_path_style_endpoint']; |
| 727 |
$builtIns['AWS::S3::DisableMultiRegionAccessPoints'] = $config['disable_multiregion_access_points']; |
| 728 |
} |
| 729 |
$builtIns['AWS::Auth::AccountIdEndpointMode'] = $resolvedConfig['account_id_endpoint_mode']; |
| 730 |
|
| 731 |
$this->clientBuiltIns += $builtIns; |
| 732 |
} |
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
public function getEndpointProviderArgs() |
| 740 |
{ |
| 741 |
return $this->normalizeEndpointProviderArgs(); |
| 742 |
} |
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
private function normalizeEndpointProviderArgs() |
| 752 |
{ |
| 753 |
$normalizedBuiltIns = []; |
| 754 |
|
| 755 |
foreach($this->clientBuiltIns as $name => $value) { |
| 756 |
$normalizedName = explode('::', $name); |
| 757 |
$normalizedName = $normalizedName[count($normalizedName) - 1]; |
| 758 |
$normalizedBuiltIns[$normalizedName] = $value; |
| 759 |
} |
| 760 |
|
| 761 |
return array_merge($normalizedBuiltIns, $this->getClientContextParams()); |
| 762 |
} |
| 763 |
|
| 764 |
protected function isUseEndpointV2() |
| 765 |
{ |
| 766 |
return $this->endpointProvider instanceof EndpointProviderV2; |
| 767 |
} |
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
public static function applyDocFilters(array $api, array $docs) |
| 783 |
{ |
| 784 |
$aliases = \Aws\load_compiled_json(__DIR__ . '/data/aliases.json'); |
| 785 |
$serviceId = $api['metadata']['serviceId'] ?? ''; |
| 786 |
$version = $api['metadata']['apiVersion']; |
| 787 |
|
| 788 |
|
| 789 |
if (!empty($aliases['operations'][$serviceId][$version])) { |
| 790 |
foreach ($aliases['operations'][$serviceId][$version] as $op => $alias) { |
| 791 |
$api['operations'][$alias] = $api['operations'][$op]; |
| 792 |
$docs['operations'][$alias] = $docs['operations'][$op]; |
| 793 |
unset($api['operations'][$op], $docs['operations'][$op]); |
| 794 |
} |
| 795 |
} |
| 796 |
ksort($api['operations']); |
| 797 |
|
| 798 |
return [ |
| 799 |
new Service($api, ApiProvider::defaultProvider()), |
| 800 |
new DocModel($docs) |
| 801 |
]; |
| 802 |
} |
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
public static function factory(array $config = []) |
| 809 |
{ |
| 810 |
return new static($config); |
| 811 |
} |
| 812 |
} |