Skip to content

Commit eb6ded6

Browse files
authored
PreSign request (#341)
* Draft PreSign request * Add documentation * Implement Presign in Signers * Regenerate Inputs * Refactor signer * Fix compare aligment * Add RequestContext * Add SDK tests * Typehint with DatetimeInterface * Remove presign override in s3 * Use memory first for RewindableFallback * Add comment on internal use of RewindableStream * Close stream and fix typehint * Fix treshold size
1 parent ef71054 commit eb6ded6

12 files changed

+36
-24
lines changed

src/DynamoDbClient.php

+14-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\DynamoDb;
44

55
use AsyncAws\Core\AbstractApi;
6+
use AsyncAws\Core\RequestContext;
67
use AsyncAws\DynamoDb\Input\CreateTableInput;
78
use AsyncAws\DynamoDb\Input\DeleteItemInput;
89
use AsyncAws\DynamoDb\Input\DeleteTableInput;
@@ -51,7 +52,7 @@ class DynamoDbClient extends AbstractApi
5152
*/
5253
public function createTable($input): CreateTableOutput
5354
{
54-
$response = $this->getResponse(CreateTableInput::create($input)->request());
55+
$response = $this->getResponse(CreateTableInput::create($input)->request(), new RequestContext(['operation' => 'CreateTable']));
5556

5657
return new CreateTableOutput($response);
5758
}
@@ -77,7 +78,7 @@ public function createTable($input): CreateTableOutput
7778
*/
7879
public function deleteItem($input): DeleteItemOutput
7980
{
80-
$response = $this->getResponse(DeleteItemInput::create($input)->request());
81+
$response = $this->getResponse(DeleteItemInput::create($input)->request(), new RequestContext(['operation' => 'DeleteItem']));
8182

8283
return new DeleteItemOutput($response);
8384
}
@@ -97,7 +98,7 @@ public function deleteItem($input): DeleteItemOutput
9798
*/
9899
public function deleteTable($input): DeleteTableOutput
99100
{
100-
$response = $this->getResponse(DeleteTableInput::create($input)->request());
101+
$response = $this->getResponse(DeleteTableInput::create($input)->request(), new RequestContext(['operation' => 'DeleteTable']));
101102

102103
return new DeleteTableOutput($response);
103104
}
@@ -114,7 +115,7 @@ public function deleteTable($input): DeleteTableOutput
114115
*/
115116
public function describeTable($input): DescribeTableOutput
116117
{
117-
$response = $this->getResponse(DescribeTableInput::create($input)->request());
118+
$response = $this->getResponse(DescribeTableInput::create($input)->request(), new RequestContext(['operation' => 'DescribeTable']));
118119

119120
return new DescribeTableOutput($response);
120121
}
@@ -137,7 +138,7 @@ public function describeTable($input): DescribeTableOutput
137138
*/
138139
public function getItem($input): GetItemOutput
139140
{
140-
$response = $this->getResponse(GetItemInput::create($input)->request());
141+
$response = $this->getResponse(GetItemInput::create($input)->request(), new RequestContext(['operation' => 'GetItem']));
141142

142143
return new GetItemOutput($response);
143144
}
@@ -156,7 +157,7 @@ public function getItem($input): GetItemOutput
156157
public function listTables($input = []): ListTablesOutput
157158
{
158159
$input = ListTablesInput::create($input);
159-
$response = $this->getResponse($input->request());
160+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListTables']));
160161

161162
return new ListTablesOutput($response, $this, $input);
162163
}
@@ -185,7 +186,7 @@ public function listTables($input = []): ListTablesOutput
185186
*/
186187
public function putItem($input): PutItemOutput
187188
{
188-
$response = $this->getResponse(PutItemInput::create($input)->request());
189+
$response = $this->getResponse(PutItemInput::create($input)->request(), new RequestContext(['operation' => 'PutItem']));
189190

190191
return new PutItemOutput($response);
191192
}
@@ -219,7 +220,7 @@ public function putItem($input): PutItemOutput
219220
public function query($input): QueryOutput
220221
{
221222
$input = QueryInput::create($input);
222-
$response = $this->getResponse($input->request());
223+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'Query']));
223224

224225
return new QueryOutput($response, $this, $input);
225226
}
@@ -252,7 +253,7 @@ public function query($input): QueryOutput
252253
public function scan($input): ScanOutput
253254
{
254255
$input = ScanInput::create($input);
255-
$response = $this->getResponse($input->request());
256+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'Scan']));
256257

257258
return new ScanOutput($response, $this, $input);
258259
}
@@ -269,7 +270,7 @@ public function scan($input): ScanOutput
269270
public function tableExists($input): TableExistsWaiter
270271
{
271272
$input = DescribeTableInput::create($input);
272-
$response = $this->getResponse($input->request());
273+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'DescribeTable']));
273274

274275
return new TableExistsWaiter($response, $this, $input);
275276
}
@@ -286,7 +287,7 @@ public function tableExists($input): TableExistsWaiter
286287
public function tableNotExists($input): TableNotExistsWaiter
287288
{
288289
$input = DescribeTableInput::create($input);
289-
$response = $this->getResponse($input->request());
290+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'DescribeTable']));
290291

291292
return new TableNotExistsWaiter($response, $this, $input);
292293
}
@@ -316,7 +317,7 @@ public function tableNotExists($input): TableNotExistsWaiter
316317
*/
317318
public function updateItem($input): UpdateItemOutput
318319
{
319-
$response = $this->getResponse(UpdateItemInput::create($input)->request());
320+
$response = $this->getResponse(UpdateItemInput::create($input)->request(), new RequestContext(['operation' => 'UpdateItem']));
320321

321322
return new UpdateItemOutput($response);
322323
}
@@ -340,7 +341,7 @@ public function updateItem($input): UpdateItemOutput
340341
*/
341342
public function updateTable($input): UpdateTableOutput
342343
{
343-
$response = $this->getResponse(UpdateTableInput::create($input)->request());
344+
$response = $this->getResponse(UpdateTableInput::create($input)->request(), new RequestContext(['operation' => 'UpdateTable']));
344345

345346
return new UpdateTableOutput($response);
346347
}

src/Input/CreateTableInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\DynamoDb\Input;
44

55
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
67
use AsyncAws\Core\Request;
78
use AsyncAws\Core\Stream\StreamFactory;
89
use AsyncAws\DynamoDb\Enum\BillingMode;
@@ -15,7 +16,7 @@
1516
use AsyncAws\DynamoDb\ValueObject\StreamSpecification;
1617
use AsyncAws\DynamoDb\ValueObject\Tag;
1718

18-
class CreateTableInput
19+
class CreateTableInput implements Input
1920
{
2021
/**
2122
* An array of attributes that describe the key schema for the table and indexes.

src/Input/DeleteItemInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\DynamoDb\Input;
44

55
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
67
use AsyncAws\Core\Request;
78
use AsyncAws\Core\Stream\StreamFactory;
89
use AsyncAws\DynamoDb\Enum\ConditionalOperator;
@@ -12,7 +13,7 @@
1213
use AsyncAws\DynamoDb\ValueObject\AttributeValue;
1314
use AsyncAws\DynamoDb\ValueObject\ExpectedAttributeValue;
1415

15-
class DeleteItemInput
16+
class DeleteItemInput implements Input
1617
{
1718
/**
1819
* The name of the table from which to delete the item.

src/Input/DeleteTableInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace AsyncAws\DynamoDb\Input;
44

55
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
67
use AsyncAws\Core\Request;
78
use AsyncAws\Core\Stream\StreamFactory;
89

9-
class DeleteTableInput
10+
class DeleteTableInput implements Input
1011
{
1112
/**
1213
* The name of the table to delete.

src/Input/DescribeTableInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace AsyncAws\DynamoDb\Input;
44

55
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
67
use AsyncAws\Core\Request;
78
use AsyncAws\Core\Stream\StreamFactory;
89

9-
class DescribeTableInput
10+
class DescribeTableInput implements Input
1011
{
1112
/**
1213
* The name of the table to describe.

src/Input/GetItemInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
namespace AsyncAws\DynamoDb\Input;
44

55
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
67
use AsyncAws\Core\Request;
78
use AsyncAws\Core\Stream\StreamFactory;
89
use AsyncAws\DynamoDb\Enum\ReturnConsumedCapacity;
910
use AsyncAws\DynamoDb\ValueObject\AttributeValue;
1011

11-
class GetItemInput
12+
class GetItemInput implements Input
1213
{
1314
/**
1415
* The name of the table containing the requested item.

src/Input/ListTablesInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace AsyncAws\DynamoDb\Input;
44

5+
use AsyncAws\Core\Input;
56
use AsyncAws\Core\Request;
67
use AsyncAws\Core\Stream\StreamFactory;
78

8-
class ListTablesInput
9+
class ListTablesInput implements Input
910
{
1011
/**
1112
* The first table name that this operation will evaluate. Use the value that was returned for `LastEvaluatedTableName`

src/Input/PutItemInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\DynamoDb\Input;
44

55
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
67
use AsyncAws\Core\Request;
78
use AsyncAws\Core\Stream\StreamFactory;
89
use AsyncAws\DynamoDb\Enum\ConditionalOperator;
@@ -12,7 +13,7 @@
1213
use AsyncAws\DynamoDb\ValueObject\AttributeValue;
1314
use AsyncAws\DynamoDb\ValueObject\ExpectedAttributeValue;
1415

15-
class PutItemInput
16+
class PutItemInput implements Input
1617
{
1718
/**
1819
* The name of the table to contain the item.

src/Input/QueryInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\DynamoDb\Input;
44

55
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
67
use AsyncAws\Core\Request;
78
use AsyncAws\Core\Stream\StreamFactory;
89
use AsyncAws\DynamoDb\Enum\ConditionalOperator;
@@ -11,7 +12,7 @@
1112
use AsyncAws\DynamoDb\ValueObject\AttributeValue;
1213
use AsyncAws\DynamoDb\ValueObject\Condition;
1314

14-
class QueryInput
15+
class QueryInput implements Input
1516
{
1617
/**
1718
* The name of the table containing the requested items.

src/Input/ScanInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\DynamoDb\Input;
44

55
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
67
use AsyncAws\Core\Request;
78
use AsyncAws\Core\Stream\StreamFactory;
89
use AsyncAws\DynamoDb\Enum\ConditionalOperator;
@@ -11,7 +12,7 @@
1112
use AsyncAws\DynamoDb\ValueObject\AttributeValue;
1213
use AsyncAws\DynamoDb\ValueObject\Condition;
1314

14-
class ScanInput
15+
class ScanInput implements Input
1516
{
1617
/**
1718
* The name of the table containing the requested items; or, if you provide `IndexName`, the name of the table to which

src/Input/UpdateItemInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\DynamoDb\Input;
44

55
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
67
use AsyncAws\Core\Request;
78
use AsyncAws\Core\Stream\StreamFactory;
89
use AsyncAws\DynamoDb\Enum\ConditionalOperator;
@@ -13,7 +14,7 @@
1314
use AsyncAws\DynamoDb\ValueObject\AttributeValueUpdate;
1415
use AsyncAws\DynamoDb\ValueObject\ExpectedAttributeValue;
1516

16-
class UpdateItemInput
17+
class UpdateItemInput implements Input
1718
{
1819
/**
1920
* The name of the table containing the item to update.

src/Input/UpdateTableInput.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\DynamoDb\Input;
44

55
use AsyncAws\Core\Exception\InvalidArgument;
6+
use AsyncAws\Core\Input;
67
use AsyncAws\Core\Request;
78
use AsyncAws\Core\Stream\StreamFactory;
89
use AsyncAws\DynamoDb\Enum\BillingMode;
@@ -13,7 +14,7 @@
1314
use AsyncAws\DynamoDb\ValueObject\SSESpecification;
1415
use AsyncAws\DynamoDb\ValueObject\StreamSpecification;
1516

16-
class UpdateTableInput
17+
class UpdateTableInput implements Input
1718
{
1819
/**
1920
* An array of attributes that describe the key schema for the table and indexes. If you are adding a new global

0 commit comments

Comments
 (0)