3232use AsyncAws \DynamoDb \Input \CreateTableInput ;
3333use AsyncAws \DynamoDb \Input \DeleteItemInput ;
3434use AsyncAws \DynamoDb \Input \DeleteTableInput ;
35+ use AsyncAws \DynamoDb \Input \DescribeEndpointsRequest ;
3536use AsyncAws \DynamoDb \Input \DescribeTableInput ;
3637use AsyncAws \DynamoDb \Input \ExecuteStatementInput ;
3738use AsyncAws \DynamoDb \Input \GetItemInput ;
4849use AsyncAws \DynamoDb \Result \CreateTableOutput ;
4950use AsyncAws \DynamoDb \Result \DeleteItemOutput ;
5051use AsyncAws \DynamoDb \Result \DeleteTableOutput ;
52+ use AsyncAws \DynamoDb \Result \DescribeEndpointsResponse ;
5153use AsyncAws \DynamoDb \Result \DescribeTableOutput ;
5254use AsyncAws \DynamoDb \Result \ExecuteStatementOutput ;
5355use AsyncAws \DynamoDb \Result \GetItemOutput ;
@@ -107,7 +109,7 @@ public function batchGetItem($input): BatchGetItemOutput
107109 'ResourceNotFoundException ' => ResourceNotFoundException::class,
108110 'RequestLimitExceeded ' => RequestLimitExceededException::class,
109111 'InternalServerError ' => InternalServerErrorException::class,
110- ]]));
112+ ], ' usesEndpointDiscovery ' => true ]));
111113
112114 return new BatchGetItemOutput ($ response , $ this , $ input );
113115 }
@@ -145,7 +147,7 @@ public function batchWriteItem($input): BatchWriteItemOutput
145147 'ItemCollectionSizeLimitExceededException ' => ItemCollectionSizeLimitExceededException::class,
146148 'RequestLimitExceeded ' => RequestLimitExceededException::class,
147149 'InternalServerError ' => InternalServerErrorException::class,
148- ]]));
150+ ], ' usesEndpointDiscovery ' => true ]));
149151
150152 return new BatchWriteItemOutput ($ response );
151153 }
@@ -184,7 +186,7 @@ public function createTable($input): CreateTableOutput
184186 'ResourceInUseException ' => ResourceInUseException::class,
185187 'LimitExceededException ' => LimitExceededException::class,
186188 'InternalServerError ' => InternalServerErrorException::class,
187- ]]));
189+ ], ' usesEndpointDiscovery ' => true ]));
188190
189191 return new CreateTableOutput ($ response );
190192 }
@@ -229,7 +231,7 @@ public function deleteItem($input): DeleteItemOutput
229231 'TransactionConflictException ' => TransactionConflictException::class,
230232 'RequestLimitExceeded ' => RequestLimitExceededException::class,
231233 'InternalServerError ' => InternalServerErrorException::class,
232- ]]));
234+ ], ' usesEndpointDiscovery ' => true ]));
233235
234236 return new DeleteItemOutput ($ response );
235237 }
@@ -262,11 +264,29 @@ public function deleteTable($input): DeleteTableOutput
262264 'ResourceNotFoundException ' => ResourceNotFoundException::class,
263265 'LimitExceededException ' => LimitExceededException::class,
264266 'InternalServerError ' => InternalServerErrorException::class,
265- ]]));
267+ ], ' usesEndpointDiscovery ' => true ]));
266268
267269 return new DeleteTableOutput ($ response );
268270 }
269271
272+ /**
273+ * Returns the regional endpoint information.
274+ *
275+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeEndpoints.html
276+ * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-dynamodb-2012-08-10.html#describeendpoints
277+ *
278+ * @param array{
279+ * @region?: string,
280+ * }|DescribeEndpointsRequest $input
281+ */
282+ public function describeEndpoints ($ input = []): DescribeEndpointsResponse
283+ {
284+ $ input = DescribeEndpointsRequest::create ($ input );
285+ $ response = $ this ->getResponse ($ input ->request (), new RequestContext (['operation ' => 'DescribeEndpoints ' , 'region ' => $ input ->getRegion ()]));
286+
287+ return new DescribeEndpointsResponse ($ response );
288+ }
289+
270290 /**
271291 * Returns information about the table, including the current status of the table, when it was created, the primary key
272292 * schema, and any indexes on the table.
@@ -288,7 +308,7 @@ public function describeTable($input): DescribeTableOutput
288308 $ response = $ this ->getResponse ($ input ->request (), new RequestContext (['operation ' => 'DescribeTable ' , 'region ' => $ input ->getRegion (), 'exceptionMapping ' => [
289309 'ResourceNotFoundException ' => ResourceNotFoundException::class,
290310 'InternalServerError ' => InternalServerErrorException::class,
291- ]]));
311+ ], ' usesEndpointDiscovery ' => true ]));
292312
293313 return new DescribeTableOutput ($ response );
294314 }
@@ -366,7 +386,7 @@ public function getItem($input): GetItemOutput
366386 'ResourceNotFoundException ' => ResourceNotFoundException::class,
367387 'RequestLimitExceeded ' => RequestLimitExceededException::class,
368388 'InternalServerError ' => InternalServerErrorException::class,
369- ]]));
389+ ], ' usesEndpointDiscovery ' => true ]));
370390
371391 return new GetItemOutput ($ response );
372392 }
@@ -391,7 +411,7 @@ public function listTables($input = []): ListTablesOutput
391411 $ input = ListTablesInput::create ($ input );
392412 $ response = $ this ->getResponse ($ input ->request (), new RequestContext (['operation ' => 'ListTables ' , 'region ' => $ input ->getRegion (), 'exceptionMapping ' => [
393413 'InternalServerError ' => InternalServerErrorException::class,
394- ]]));
414+ ], ' usesEndpointDiscovery ' => true ]));
395415
396416 return new ListTablesOutput ($ response , $ this , $ input );
397417 }
@@ -439,7 +459,7 @@ public function putItem($input): PutItemOutput
439459 'TransactionConflictException ' => TransactionConflictException::class,
440460 'RequestLimitExceeded ' => RequestLimitExceededException::class,
441461 'InternalServerError ' => InternalServerErrorException::class,
442- ]]));
462+ ], ' usesEndpointDiscovery ' => true ]));
443463
444464 return new PutItemOutput ($ response );
445465 }
@@ -486,7 +506,7 @@ public function query($input): QueryOutput
486506 'ResourceNotFoundException ' => ResourceNotFoundException::class,
487507 'RequestLimitExceeded ' => RequestLimitExceededException::class,
488508 'InternalServerError ' => InternalServerErrorException::class,
489- ]]));
509+ ], ' usesEndpointDiscovery ' => true ]));
490510
491511 return new QueryOutput ($ response , $ this , $ input );
492512 }
@@ -531,7 +551,7 @@ public function scan($input): ScanOutput
531551 'ResourceNotFoundException ' => ResourceNotFoundException::class,
532552 'RequestLimitExceeded ' => RequestLimitExceededException::class,
533553 'InternalServerError ' => InternalServerErrorException::class,
534- ]]));
554+ ], ' usesEndpointDiscovery ' => true ]));
535555
536556 return new ScanOutput ($ response , $ this , $ input );
537557 }
@@ -610,7 +630,7 @@ public function transactWriteItems($input): TransactWriteItemsOutput
610630 'ProvisionedThroughputExceededException ' => ProvisionedThroughputExceededException::class,
611631 'RequestLimitExceeded ' => RequestLimitExceededException::class,
612632 'InternalServerError ' => InternalServerErrorException::class,
613- ]]));
633+ ], ' usesEndpointDiscovery ' => true ]));
614634
615635 return new TransactWriteItemsOutput ($ response );
616636 }
@@ -659,7 +679,7 @@ public function updateItem($input): UpdateItemOutput
659679 'TransactionConflictException ' => TransactionConflictException::class,
660680 'RequestLimitExceeded ' => RequestLimitExceededException::class,
661681 'InternalServerError ' => InternalServerErrorException::class,
662- ]]));
682+ ], ' usesEndpointDiscovery ' => true ]));
663683
664684 return new UpdateItemOutput ($ response );
665685 }
@@ -697,7 +717,7 @@ public function updateTable($input): UpdateTableOutput
697717 'ResourceNotFoundException ' => ResourceNotFoundException::class,
698718 'LimitExceededException ' => LimitExceededException::class,
699719 'InternalServerError ' => InternalServerErrorException::class,
700- ]]));
720+ ], ' usesEndpointDiscovery ' => true ]));
701721
702722 return new UpdateTableOutput ($ response );
703723 }
@@ -730,11 +750,16 @@ public function updateTimeToLive($input): UpdateTimeToLiveOutput
730750 'ResourceNotFoundException ' => ResourceNotFoundException::class,
731751 'LimitExceededException ' => LimitExceededException::class,
732752 'InternalServerError ' => InternalServerErrorException::class,
733- ]]));
753+ ], ' usesEndpointDiscovery ' => true ]));
734754
735755 return new UpdateTimeToLiveOutput ($ response );
736756 }
737757
758+ protected function discoverEndpoints (?string $ region ): array
759+ {
760+ return $ this ->describeEndpoints ($ region ? ['@region ' => $ region ] : [])->getEndpoints ();
761+ }
762+
738763 protected function getAwsErrorFactory (): AwsErrorFactoryInterface
739764 {
740765 return new JsonRpcAwsErrorFactory ();
0 commit comments