32
32
use AsyncAws \DynamoDb \Input \CreateTableInput ;
33
33
use AsyncAws \DynamoDb \Input \DeleteItemInput ;
34
34
use AsyncAws \DynamoDb \Input \DeleteTableInput ;
35
+ use AsyncAws \DynamoDb \Input \DescribeEndpointsRequest ;
35
36
use AsyncAws \DynamoDb \Input \DescribeTableInput ;
36
37
use AsyncAws \DynamoDb \Input \ExecuteStatementInput ;
37
38
use AsyncAws \DynamoDb \Input \GetItemInput ;
48
49
use AsyncAws \DynamoDb \Result \CreateTableOutput ;
49
50
use AsyncAws \DynamoDb \Result \DeleteItemOutput ;
50
51
use AsyncAws \DynamoDb \Result \DeleteTableOutput ;
52
+ use AsyncAws \DynamoDb \Result \DescribeEndpointsResponse ;
51
53
use AsyncAws \DynamoDb \Result \DescribeTableOutput ;
52
54
use AsyncAws \DynamoDb \Result \ExecuteStatementOutput ;
53
55
use AsyncAws \DynamoDb \Result \GetItemOutput ;
@@ -107,7 +109,7 @@ public function batchGetItem($input): BatchGetItemOutput
107
109
'ResourceNotFoundException ' => ResourceNotFoundException::class,
108
110
'RequestLimitExceeded ' => RequestLimitExceededException::class,
109
111
'InternalServerError ' => InternalServerErrorException::class,
110
- ]]));
112
+ ], ' usesEndpointDiscovery ' => true ]));
111
113
112
114
return new BatchGetItemOutput ($ response , $ this , $ input );
113
115
}
@@ -145,7 +147,7 @@ public function batchWriteItem($input): BatchWriteItemOutput
145
147
'ItemCollectionSizeLimitExceededException ' => ItemCollectionSizeLimitExceededException::class,
146
148
'RequestLimitExceeded ' => RequestLimitExceededException::class,
147
149
'InternalServerError ' => InternalServerErrorException::class,
148
- ]]));
150
+ ], ' usesEndpointDiscovery ' => true ]));
149
151
150
152
return new BatchWriteItemOutput ($ response );
151
153
}
@@ -184,7 +186,7 @@ public function createTable($input): CreateTableOutput
184
186
'ResourceInUseException ' => ResourceInUseException::class,
185
187
'LimitExceededException ' => LimitExceededException::class,
186
188
'InternalServerError ' => InternalServerErrorException::class,
187
- ]]));
189
+ ], ' usesEndpointDiscovery ' => true ]));
188
190
189
191
return new CreateTableOutput ($ response );
190
192
}
@@ -229,7 +231,7 @@ public function deleteItem($input): DeleteItemOutput
229
231
'TransactionConflictException ' => TransactionConflictException::class,
230
232
'RequestLimitExceeded ' => RequestLimitExceededException::class,
231
233
'InternalServerError ' => InternalServerErrorException::class,
232
- ]]));
234
+ ], ' usesEndpointDiscovery ' => true ]));
233
235
234
236
return new DeleteItemOutput ($ response );
235
237
}
@@ -262,11 +264,29 @@ public function deleteTable($input): DeleteTableOutput
262
264
'ResourceNotFoundException ' => ResourceNotFoundException::class,
263
265
'LimitExceededException ' => LimitExceededException::class,
264
266
'InternalServerError ' => InternalServerErrorException::class,
265
- ]]));
267
+ ], ' usesEndpointDiscovery ' => true ]));
266
268
267
269
return new DeleteTableOutput ($ response );
268
270
}
269
271
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
+
270
290
/**
271
291
* Returns information about the table, including the current status of the table, when it was created, the primary key
272
292
* schema, and any indexes on the table.
@@ -288,7 +308,7 @@ public function describeTable($input): DescribeTableOutput
288
308
$ response = $ this ->getResponse ($ input ->request (), new RequestContext (['operation ' => 'DescribeTable ' , 'region ' => $ input ->getRegion (), 'exceptionMapping ' => [
289
309
'ResourceNotFoundException ' => ResourceNotFoundException::class,
290
310
'InternalServerError ' => InternalServerErrorException::class,
291
- ]]));
311
+ ], ' usesEndpointDiscovery ' => true ]));
292
312
293
313
return new DescribeTableOutput ($ response );
294
314
}
@@ -366,7 +386,7 @@ public function getItem($input): GetItemOutput
366
386
'ResourceNotFoundException ' => ResourceNotFoundException::class,
367
387
'RequestLimitExceeded ' => RequestLimitExceededException::class,
368
388
'InternalServerError ' => InternalServerErrorException::class,
369
- ]]));
389
+ ], ' usesEndpointDiscovery ' => true ]));
370
390
371
391
return new GetItemOutput ($ response );
372
392
}
@@ -391,7 +411,7 @@ public function listTables($input = []): ListTablesOutput
391
411
$ input = ListTablesInput::create ($ input );
392
412
$ response = $ this ->getResponse ($ input ->request (), new RequestContext (['operation ' => 'ListTables ' , 'region ' => $ input ->getRegion (), 'exceptionMapping ' => [
393
413
'InternalServerError ' => InternalServerErrorException::class,
394
- ]]));
414
+ ], ' usesEndpointDiscovery ' => true ]));
395
415
396
416
return new ListTablesOutput ($ response , $ this , $ input );
397
417
}
@@ -439,7 +459,7 @@ public function putItem($input): PutItemOutput
439
459
'TransactionConflictException ' => TransactionConflictException::class,
440
460
'RequestLimitExceeded ' => RequestLimitExceededException::class,
441
461
'InternalServerError ' => InternalServerErrorException::class,
442
- ]]));
462
+ ], ' usesEndpointDiscovery ' => true ]));
443
463
444
464
return new PutItemOutput ($ response );
445
465
}
@@ -486,7 +506,7 @@ public function query($input): QueryOutput
486
506
'ResourceNotFoundException ' => ResourceNotFoundException::class,
487
507
'RequestLimitExceeded ' => RequestLimitExceededException::class,
488
508
'InternalServerError ' => InternalServerErrorException::class,
489
- ]]));
509
+ ], ' usesEndpointDiscovery ' => true ]));
490
510
491
511
return new QueryOutput ($ response , $ this , $ input );
492
512
}
@@ -531,7 +551,7 @@ public function scan($input): ScanOutput
531
551
'ResourceNotFoundException ' => ResourceNotFoundException::class,
532
552
'RequestLimitExceeded ' => RequestLimitExceededException::class,
533
553
'InternalServerError ' => InternalServerErrorException::class,
534
- ]]));
554
+ ], ' usesEndpointDiscovery ' => true ]));
535
555
536
556
return new ScanOutput ($ response , $ this , $ input );
537
557
}
@@ -610,7 +630,7 @@ public function transactWriteItems($input): TransactWriteItemsOutput
610
630
'ProvisionedThroughputExceededException ' => ProvisionedThroughputExceededException::class,
611
631
'RequestLimitExceeded ' => RequestLimitExceededException::class,
612
632
'InternalServerError ' => InternalServerErrorException::class,
613
- ]]));
633
+ ], ' usesEndpointDiscovery ' => true ]));
614
634
615
635
return new TransactWriteItemsOutput ($ response );
616
636
}
@@ -659,7 +679,7 @@ public function updateItem($input): UpdateItemOutput
659
679
'TransactionConflictException ' => TransactionConflictException::class,
660
680
'RequestLimitExceeded ' => RequestLimitExceededException::class,
661
681
'InternalServerError ' => InternalServerErrorException::class,
662
- ]]));
682
+ ], ' usesEndpointDiscovery ' => true ]));
663
683
664
684
return new UpdateItemOutput ($ response );
665
685
}
@@ -697,7 +717,7 @@ public function updateTable($input): UpdateTableOutput
697
717
'ResourceNotFoundException ' => ResourceNotFoundException::class,
698
718
'LimitExceededException ' => LimitExceededException::class,
699
719
'InternalServerError ' => InternalServerErrorException::class,
700
- ]]));
720
+ ], ' usesEndpointDiscovery ' => true ]));
701
721
702
722
return new UpdateTableOutput ($ response );
703
723
}
@@ -730,11 +750,16 @@ public function updateTimeToLive($input): UpdateTimeToLiveOutput
730
750
'ResourceNotFoundException ' => ResourceNotFoundException::class,
731
751
'LimitExceededException ' => LimitExceededException::class,
732
752
'InternalServerError ' => InternalServerErrorException::class,
733
- ]]));
753
+ ], ' usesEndpointDiscovery ' => true ]));
734
754
735
755
return new UpdateTimeToLiveOutput ($ response );
736
756
}
737
757
758
+ protected function discoverEndpoints (?string $ region ): array
759
+ {
760
+ return $ this ->describeEndpoints ($ region ? ['@region ' => $ region ] : [])->getEndpoints ();
761
+ }
762
+
738
763
protected function getAwsErrorFactory (): AwsErrorFactoryInterface
739
764
{
740
765
return new JsonRpcAwsErrorFactory ();
0 commit comments