| @@ -3,8 +3,10 @@ | ||
| 3 | 3 | namespace Dudlewebs\WPMCS\s3\Aws; |
| 4 | 4 | |
| 5 | 5 | use Dudlewebs\WPMCS\s3\Aws\Endpoint\PartitionEndpointProvider; |
| 6 | 6 | use Dudlewebs\WPMCS\s3\Aws\Endpoint\PartitionInterface; |
| 7 | +use Dudlewebs\WPMCS\s3\Aws\EndpointV2\EndpointProviderV2; | |
| 8 | +use Dudlewebs\WPMCS\s3\Aws\EndpointV2\EndpointDefinitionProvider; | |
| 7 | 9 | class MultiRegionClient implements AwsClientInterface |
| 8 | 10 | { |
| 9 | 11 | use AwsClientTrait; |
| 10 | 12 | /** @var AwsClientInterface[] A pool of clients keyed by region. */ |
| @@ -26,8 +28,10 @@ | ||
| 26 | 28 | public static function getArguments() |
| 27 | 29 | { |
| 28 | 30 | $args = \array_intersect_key(ClientResolver::getDefaultArguments(), ['service' => \true, 'region' => \true]); |
| 29 | 31 | $args['region']['required'] = \false; |
| 32 | + unset($args['region']['fn']); | |
| 33 | + unset($args['region']['default']); | |
| 30 | 34 | return $args + ['client_factory' => ['type' => 'config', 'valid' => ['callable'], 'doc' => 'A callable that takes an array of client' . ' configuration arguments and returns a regionalized' . ' client.', 'required' => \true, 'internal' => \true, 'default' => function (array $args) { |
| 31 | 35 | $namespace = manifest($args['service'])['namespace']; |
| 32 | 36 | $klass = "Dudlewebs\\WPMCS\\s3\\Aws\\{$namespace}\\{$namespace}Client"; |
| 33 | 37 | $region = isset($args['region']) ? $args['region'] : null; |
| @@ -46,10 +50,11 @@ | ||
| 46 | 50 | } |
| 47 | 51 | if (!$value instanceof PartitionInterface) { |
| 48 | 52 | throw new \InvalidArgumentException('No valid partition' . ' was provided. Provide a concrete partition or' . ' the name of a partition (e.g., "aws," "aws-cn,"' . ' or "aws-us-gov").'); |
| 49 | 53 | } |
| 50 | - $args['partition'] = $value; | |
| 51 | - $args['endpoint_provider'] = $value; | |
| 54 | + $ruleset = EndpointDefinitionProvider::getEndpointRuleset($args['service'], isset($args['version']) ? $args['version'] : 'latest'); | |
| 55 | + $partitions = EndpointDefinitionProvider::getPartitions(); | |
| 56 | + $args['endpoint_provider'] = new EndpointProviderV2($ruleset, $partitions); | |
| 52 | 57 | }]]; |
| 53 | 58 | } |
| 54 | 59 | /** |
| 55 | 60 | * The multi-region client constructor accepts the following options: |