Skip to content

Commit 3daedce

Browse files
authored
Revert "enhancement: Endpointv2 Middleware (#2790)" (#2833)
1 parent dca4bc1 commit 3daedce

18 files changed

+294
-584
lines changed

src/Api/Serializer/JsonRpcSerializer.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use Aws\Api\Service;
55
use Aws\CommandInterface;
6+
use Aws\EndpointV2\EndpointProviderV2;
67
use Aws\EndpointV2\EndpointV2SerializerTrait;
7-
use Aws\EndpointV2\Ruleset\RulesetEndpoint;
88
use GuzzleHttp\Psr7\Request;
99
use Psr\Http\Message\RequestInterface;
1010

@@ -56,7 +56,8 @@ public function __construct(
5656
*/
5757
public function __invoke(
5858
CommandInterface $command,
59-
$endpoint = null
59+
$endpointProvider = null,
60+
$clientArgs = null
6061
)
6162
{
6263
$operationName = $command->getName();
@@ -67,8 +68,15 @@ public function __invoke(
6768
'Content-Type' => $this->contentType
6869
];
6970

70-
if ($endpoint instanceof RulesetEndpoint) {
71-
$this->setEndpointV2RequestOptions($endpoint, $headers);
71+
if ($endpointProvider instanceof EndpointProviderV2) {
72+
$this->setRequestOptions(
73+
$endpointProvider,
74+
$command,
75+
$operation,
76+
$commandArgs,
77+
$clientArgs,
78+
$headers
79+
);
7280
}
7381

7482
return new Request(

src/Api/Serializer/QuerySerializer.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Aws\CommandInterface;
66
use Aws\EndpointV2\EndpointProviderV2;
77
use Aws\EndpointV2\EndpointV2SerializerTrait;
8-
use Aws\EndpointV2\Ruleset\RulesetEndpoint;
98
use GuzzleHttp\Psr7\Request;
109
use Psr\Http\Message\RequestInterface;
1110

@@ -43,7 +42,8 @@ public function __construct(
4342
*/
4443
public function __invoke(
4544
CommandInterface $command,
46-
$endpoint = null
45+
$endpointProvider = null,
46+
$clientArgs = null
4747
)
4848
{
4949
$operation = $this->api->getOperation($command->getName());
@@ -67,8 +67,15 @@ public function __invoke(
6767
'Content-Type' => 'application/x-www-form-urlencoded'
6868
];
6969

70-
if ($endpoint instanceof RulesetEndpoint) {
71-
$this->setEndpointV2RequestOptions($endpoint, $headers);
70+
if ($endpointProvider instanceof EndpointProviderV2) {
71+
$this->setRequestOptions(
72+
$endpointProvider,
73+
$command,
74+
$operation,
75+
$commandArgs,
76+
$clientArgs,
77+
$headers
78+
);
7279
}
7380

7481
return new Request(

src/Api/Serializer/RestSerializer.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Aws\CommandInterface;
1111
use Aws\EndpointV2\EndpointProviderV2;
1212
use Aws\EndpointV2\EndpointV2SerializerTrait;
13-
use Aws\EndpointV2\Ruleset\RulesetEndpoint;
1413
use GuzzleHttp\Psr7;
1514
use GuzzleHttp\Psr7\Request;
1615
use GuzzleHttp\Psr7\Uri;
@@ -50,25 +49,33 @@ public function __construct(Service $api, $endpoint)
5049
*/
5150
public function __invoke(
5251
CommandInterface $command,
53-
$endpoint = null
52+
$endpointProvider = null,
53+
$clientArgs = null
5454
)
5555
{
5656
$operation = $this->api->getOperation($command->getName());
5757
$commandArgs = $command->toArray();
5858
$opts = $this->serialize($operation, $commandArgs);
59-
$headers = $opts['headers'] ?? [];
60-
61-
if ($endpoint instanceof RulesetEndpoint) {
62-
$this->setEndpointV2RequestOptions($endpoint, $headers);
59+
$headers = isset($opts['headers']) ? $opts['headers'] : [];
60+
61+
if ($endpointProvider instanceof EndpointProviderV2) {
62+
$this->setRequestOptions(
63+
$endpointProvider,
64+
$command,
65+
$operation,
66+
$commandArgs,
67+
$clientArgs,
68+
$headers
69+
);
70+
$this->endpoint = new Uri($this->endpoint);
6371
}
64-
6572
$uri = $this->buildEndpoint($operation, $commandArgs, $opts);
6673

6774
return new Request(
6875
$operation['http']['method'],
6976
$uri,
7077
$headers,
71-
$opts['body'] ?? null
78+
isset($opts['body']) ? $opts['body'] : null
7279
);
7380
}
7481

src/AwsClient.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Aws\Api\Service;
77
use Aws\EndpointDiscovery\EndpointDiscoveryMiddleware;
88
use Aws\EndpointV2\EndpointProviderV2;
9-
use Aws\EndpointV2\EndpointV2Middleware;
109
use Aws\Exception\AwsException;
1110
use Aws\Signature\SignatureProvider;
1211
use GuzzleHttp\Psr7\Uri;
@@ -241,9 +240,7 @@ public function __construct(array $args)
241240
$this->loadAliases();
242241
$this->addStreamRequestPayload();
243242
$this->addRecursionDetection();
244-
if ($this->isUseEndpointV2()) {
245-
$this->addEndpointV2Middleware();
246-
}
243+
$this->addRequestBuilder();
247244

248245
if (!is_null($this->api->getMetadata('awsQueryCompatible'))) {
249246
$this->addQueryCompatibleInputMiddleware($this->api);
@@ -515,18 +512,24 @@ private function addRecursionDetection()
515512
);
516513
}
517514

518-
private function addEndpointV2Middleware()
515+
/**
516+
* Adds the `builder` middleware such that a client's endpoint
517+
* provider and endpoint resolution arguments can be passed.
518+
*/
519+
private function addRequestBuilder()
519520
{
520-
$list = $this->getHandlerList();
521+
$handlerList = $this->getHandlerList();
522+
$serializer = $this->serializer;
523+
$endpointProvider = $this->endpointProvider;
521524
$endpointArgs = $this->getEndpointProviderArgs();
522525

523-
$list->prependBuild(
524-
EndpointV2Middleware::wrap(
525-
$this->endpointProvider,
526-
$this->getApi(),
526+
$handlerList->prependBuild(
527+
Middleware::requestBuilder(
528+
$serializer,
529+
$endpointProvider,
527530
$endpointArgs
528531
),
529-
'endpointV2_middleware'
532+
'builderV2'
530533
);
531534
}
532535

src/ClientResolver.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ class ClientResolver
153153
],
154154
'serializer' => [
155155
'default' => [__CLASS__, '_default_serializer'],
156-
'fn' => [__CLASS__, '_apply_serializer'],
157156
'internal' => true,
158157
'type' => 'value',
159158
'valid' => ['callable'],
@@ -835,11 +834,6 @@ public static function _default_use_dual_stack_endpoint(array &$args) {
835834
return UseDualStackConfigProvider::defaultProvider($args);
836835
}
837836

838-
public static function _apply_serializer($value, array &$args, HandlerList $list)
839-
{
840-
$list->prependBuild(Middleware::requestBuilder($value), 'builder');
841-
}
842-
843837
public static function _apply_debug($value, array &$args, HandlerList $list)
844838
{
845839
if ($value !== false) {

0 commit comments

Comments
 (0)