|
15 | 15 | use AsyncAws\TimestreamQuery\Exception\ThrottlingException; |
16 | 16 | use AsyncAws\TimestreamQuery\Exception\ValidationException; |
17 | 17 | use AsyncAws\TimestreamQuery\Input\CancelQueryRequest; |
| 18 | +use AsyncAws\TimestreamQuery\Input\DescribeEndpointsRequest; |
18 | 19 | use AsyncAws\TimestreamQuery\Input\PrepareQueryRequest; |
19 | 20 | use AsyncAws\TimestreamQuery\Input\QueryRequest; |
20 | 21 | use AsyncAws\TimestreamQuery\Result\CancelQueryResponse; |
| 22 | +use AsyncAws\TimestreamQuery\Result\DescribeEndpointsResponse; |
21 | 23 | use AsyncAws\TimestreamQuery\Result\PrepareQueryResponse; |
22 | 24 | use AsyncAws\TimestreamQuery\Result\QueryResponse; |
23 | 25 |
|
@@ -53,11 +55,38 @@ public function cancelQuery($input): CancelQueryResponse |
53 | 55 | 'ThrottlingException' => ThrottlingException::class, |
54 | 56 | 'ValidationException' => ValidationException::class, |
55 | 57 | 'InvalidEndpointException' => InvalidEndpointException::class, |
56 | | - ]])); |
| 58 | + ], 'requiresEndpointDiscovery' => true, 'usesEndpointDiscovery' => true])); |
57 | 59 |
|
58 | 60 | return new CancelQueryResponse($response); |
59 | 61 | } |
60 | 62 |
|
| 63 | + /** |
| 64 | + * DescribeEndpoints returns a list of available endpoints to make Timestream API calls against. This API is available |
| 65 | + * through both Write and Query. |
| 66 | + * |
| 67 | + * @see https://docs.aws.amazon.com/timestream/latest/developerguide/API_DescribeEndpoints.html |
| 68 | + * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-query.timestream-2018-11-01.html#describeendpoints |
| 69 | + * |
| 70 | + * @param array{ |
| 71 | + * @region?: string, |
| 72 | + * }|DescribeEndpointsRequest $input |
| 73 | + * |
| 74 | + * @throws InternalServerException |
| 75 | + * @throws ValidationException |
| 76 | + * @throws ThrottlingException |
| 77 | + */ |
| 78 | + public function describeEndpoints($input = []): DescribeEndpointsResponse |
| 79 | + { |
| 80 | + $input = DescribeEndpointsRequest::create($input); |
| 81 | + $response = $this->getResponse($input->request(), new RequestContext(['operation' => 'DescribeEndpoints', 'region' => $input->getRegion(), 'exceptionMapping' => [ |
| 82 | + 'InternalServerException' => InternalServerException::class, |
| 83 | + 'ValidationException' => ValidationException::class, |
| 84 | + 'ThrottlingException' => ThrottlingException::class, |
| 85 | + ]])); |
| 86 | + |
| 87 | + return new DescribeEndpointsResponse($response); |
| 88 | + } |
| 89 | + |
61 | 90 | /** |
62 | 91 | * A synchronous operation that allows you to submit a query with parameters to be stored by Timestream for later |
63 | 92 | * running. Timestream only supports using this operation with the `PrepareQueryRequest$ValidateOnly` set to `true`. |
@@ -86,7 +115,7 @@ public function prepareQuery($input): PrepareQueryResponse |
86 | 115 | 'ThrottlingException' => ThrottlingException::class, |
87 | 116 | 'ValidationException' => ValidationException::class, |
88 | 117 | 'InvalidEndpointException' => InvalidEndpointException::class, |
89 | | - ]])); |
| 118 | + ], 'requiresEndpointDiscovery' => true, 'usesEndpointDiscovery' => true])); |
90 | 119 |
|
91 | 120 | return new PrepareQueryResponse($response); |
92 | 121 | } |
@@ -127,11 +156,16 @@ public function query($input): QueryResponse |
127 | 156 | 'ThrottlingException' => ThrottlingException::class, |
128 | 157 | 'ValidationException' => ValidationException::class, |
129 | 158 | 'InvalidEndpointException' => InvalidEndpointException::class, |
130 | | - ]])); |
| 159 | + ], 'requiresEndpointDiscovery' => true, 'usesEndpointDiscovery' => true])); |
131 | 160 |
|
132 | 161 | return new QueryResponse($response, $this, $input); |
133 | 162 | } |
134 | 163 |
|
| 164 | + protected function discoverEndpoints(?string $region): array |
| 165 | + { |
| 166 | + return $this->describeEndpoints($region ? ['@region' => $region] : [])->getEndpoints(); |
| 167 | + } |
| 168 | + |
135 | 169 | protected function getAwsErrorFactory(): AwsErrorFactoryInterface |
136 | 170 | { |
137 | 171 | return new JsonRpcAwsErrorFactory(); |
|
0 commit comments