Skip to content

Commit 782fe42

Browse files
Update generated code (#1502)
* update generated code * Apply suggestions from code review --------- Co-authored-by: Jérémy Derussé <[email protected]>
1 parent 810c236 commit 782fe42

File tree

7 files changed

+189
-0
lines changed

7 files changed

+189
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
### Added
1515

1616
- AWS enhancement: Documentation updates.
17+
- AWS api-change: This release adds ReturnValuesOnConditionCheckFailure parameter to PutItem, UpdateItem, DeleteItem, ExecuteStatement, BatchExecuteStatement and ExecuteTransaction APIs. When set to ALL_OLD, API returns a copy of the item as it was when a conditional write failed
1718

1819
## 1.4.0
1920

src/DynamoDbClient.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use AsyncAws\DynamoDb\Enum\ReturnConsumedCapacity;
1313
use AsyncAws\DynamoDb\Enum\ReturnItemCollectionMetrics;
1414
use AsyncAws\DynamoDb\Enum\ReturnValue;
15+
use AsyncAws\DynamoDb\Enum\ReturnValuesOnConditionCheckFailure;
1516
use AsyncAws\DynamoDb\Enum\Select;
1617
use AsyncAws\DynamoDb\Enum\TableClass;
1718
use AsyncAws\DynamoDb\Exception\ConditionalCheckFailedException;
@@ -323,6 +324,7 @@ public function createTable($input): CreateTableOutput
323324
* ConditionExpression?: string,
324325
* ExpressionAttributeNames?: array<string, string>,
325326
* ExpressionAttributeValues?: array<string, AttributeValue|array>,
327+
* ReturnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure::*,
326328
* '@region'?: string|null,
327329
* }|DeleteItemInput $input
328330
*
@@ -476,6 +478,7 @@ public function describeTable($input): DescribeTableOutput
476478
* NextToken?: string,
477479
* ReturnConsumedCapacity?: ReturnConsumedCapacity::*,
478480
* Limit?: int,
481+
* ReturnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure::*,
479482
* '@region'?: string|null,
480483
* }|ExecuteStatementInput $input
481484
*
@@ -608,6 +611,7 @@ public function listTables($input = []): ListTablesOutput
608611
* ConditionExpression?: string,
609612
* ExpressionAttributeNames?: array<string, string>,
610613
* ExpressionAttributeValues?: array<string, AttributeValue|array>,
614+
* ReturnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure::*,
611615
* '@region'?: string|null,
612616
* }|PutItemInput $input
613617
*
@@ -918,6 +922,7 @@ public function transactWriteItems($input): TransactWriteItemsOutput
918922
* ConditionExpression?: string,
919923
* ExpressionAttributeNames?: array<string, string>,
920924
* ExpressionAttributeValues?: array<string, AttributeValue|array>,
925+
* ReturnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure::*,
921926
* '@region'?: string|null,
922927
* }|UpdateItemInput $input
923928
*

src/Exception/ConditionalCheckFailedException.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,49 @@
33
namespace AsyncAws\DynamoDb\Exception;
44

55
use AsyncAws\Core\Exception\Http\ClientException;
6+
use AsyncAws\DynamoDb\ValueObject\AttributeValue;
67
use Symfony\Contracts\HttpClient\ResponseInterface;
78

89
/**
910
* A condition specified in the operation could not be evaluated.
1011
*/
1112
final class ConditionalCheckFailedException extends ClientException
1213
{
14+
/**
15+
* Item which caused the `ConditionalCheckFailedException`.
16+
*
17+
* @var array<string, AttributeValue>
18+
*/
19+
private $item;
20+
21+
/**
22+
* @return array<string, AttributeValue>
23+
*/
24+
public function getItem(): array
25+
{
26+
return $this->item;
27+
}
28+
1329
protected function populateResult(ResponseInterface $response): void
1430
{
1531
$data = $response->toArray(false);
1632

1733
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
1834
$this->message = $v;
1935
}
36+
$this->item = empty($data['Item']) ? [] : $this->populateResultAttributeMap($data['Item']);
37+
}
38+
39+
/**
40+
* @return array<string, AttributeValue>
41+
*/
42+
private function populateResultAttributeMap(array $json): array
43+
{
44+
$items = [];
45+
foreach ($json as $name => $value) {
46+
$items[(string) $name] = AttributeValue::create($value);
47+
}
48+
49+
return $items;
2050
}
2151
}

src/Input/DeleteItemInput.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use AsyncAws\DynamoDb\Enum\ReturnConsumedCapacity;
1111
use AsyncAws\DynamoDb\Enum\ReturnItemCollectionMetrics;
1212
use AsyncAws\DynamoDb\Enum\ReturnValue;
13+
use AsyncAws\DynamoDb\Enum\ReturnValuesOnConditionCheckFailure;
1314
use AsyncAws\DynamoDb\ValueObject\AttributeValue;
1415
use AsyncAws\DynamoDb\ValueObject\ExpectedAttributeValue;
1516

@@ -173,6 +174,16 @@ final class DeleteItemInput extends Input
173174
*/
174175
private $expressionAttributeValues;
175176

177+
/**
178+
* An optional parameter that returns the item attributes for a `DeleteItem` operation that failed a condition check.
179+
*
180+
* There is no additional cost associated with requesting a return value aside from the small network and processing
181+
* overhead of receiving a larger response. No read capacity units are consumed.
182+
*
183+
* @var ReturnValuesOnConditionCheckFailure::*|null
184+
*/
185+
private $returnValuesOnConditionCheckFailure;
186+
176187
/**
177188
* @param array{
178189
* TableName?: string,
@@ -185,6 +196,7 @@ final class DeleteItemInput extends Input
185196
* ConditionExpression?: string,
186197
* ExpressionAttributeNames?: array<string, string>,
187198
* ExpressionAttributeValues?: array<string, AttributeValue|array>,
199+
* ReturnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure::*,
188200
* '@region'?: string|null,
189201
* } $input
190202
*/
@@ -218,6 +230,7 @@ public function __construct(array $input = [])
218230
$this->expressionAttributeValues[$key] = AttributeValue::create($item);
219231
}
220232
}
233+
$this->returnValuesOnConditionCheckFailure = $input['ReturnValuesOnConditionCheckFailure'] ?? null;
221234
parent::__construct($input);
222235
}
223236

@@ -233,6 +246,7 @@ public function __construct(array $input = [])
233246
* ConditionExpression?: string,
234247
* ExpressionAttributeNames?: array<string, string>,
235248
* ExpressionAttributeValues?: array<string, AttributeValue|array>,
249+
* ReturnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure::*,
236250
* '@region'?: string|null,
237251
* }|DeleteItemInput $input
238252
*/
@@ -310,6 +324,14 @@ public function getReturnValues(): ?string
310324
return $this->returnValues;
311325
}
312326

327+
/**
328+
* @return ReturnValuesOnConditionCheckFailure::*|null
329+
*/
330+
public function getReturnValuesOnConditionCheckFailure(): ?string
331+
{
332+
return $this->returnValuesOnConditionCheckFailure;
333+
}
334+
313335
public function getTableName(): ?string
314336
{
315337
return $this->tableName;
@@ -427,6 +449,16 @@ public function setReturnValues(?string $value): self
427449
return $this;
428450
}
429451

452+
/**
453+
* @param ReturnValuesOnConditionCheckFailure::*|null $value
454+
*/
455+
public function setReturnValuesOnConditionCheckFailure(?string $value): self
456+
{
457+
$this->returnValuesOnConditionCheckFailure = $value;
458+
459+
return $this;
460+
}
461+
430462
public function setTableName(?string $value): self
431463
{
432464
$this->tableName = $value;
@@ -510,6 +542,12 @@ private function requestBody(): array
510542
}
511543
}
512544
}
545+
if (null !== $v = $this->returnValuesOnConditionCheckFailure) {
546+
if (!ReturnValuesOnConditionCheckFailure::exists($v)) {
547+
throw new InvalidArgument(sprintf('Invalid parameter "ReturnValuesOnConditionCheckFailure" for "%s". The value "%s" is not a valid "ReturnValuesOnConditionCheckFailure".', __CLASS__, $v));
548+
}
549+
$payload['ReturnValuesOnConditionCheckFailure'] = $v;
550+
}
513551

514552
return $payload;
515553
}

src/Input/ExecuteStatementInput.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use AsyncAws\Core\Request;
88
use AsyncAws\Core\Stream\StreamFactory;
99
use AsyncAws\DynamoDb\Enum\ReturnConsumedCapacity;
10+
use AsyncAws\DynamoDb\Enum\ReturnValuesOnConditionCheckFailure;
1011
use AsyncAws\DynamoDb\ValueObject\AttributeValue;
1112

1213
final class ExecuteStatementInput extends Input
@@ -59,6 +60,17 @@ final class ExecuteStatementInput extends Input
5960
*/
6061
private $limit;
6162

63+
/**
64+
* An optional parameter that returns the item attributes for an `ExecuteStatement` operation that failed a condition
65+
* check.
66+
*
67+
* There is no additional cost associated with requesting a return value aside from the small network and processing
68+
* overhead of receiving a larger response. No read capacity units are consumed.
69+
*
70+
* @var ReturnValuesOnConditionCheckFailure::*|null
71+
*/
72+
private $returnValuesOnConditionCheckFailure;
73+
6274
/**
6375
* @param array{
6476
* Statement?: string,
@@ -67,6 +79,7 @@ final class ExecuteStatementInput extends Input
6779
* NextToken?: string,
6880
* ReturnConsumedCapacity?: ReturnConsumedCapacity::*,
6981
* Limit?: int,
82+
* ReturnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure::*,
7083
* '@region'?: string|null,
7184
* } $input
7285
*/
@@ -78,6 +91,7 @@ public function __construct(array $input = [])
7891
$this->nextToken = $input['NextToken'] ?? null;
7992
$this->returnConsumedCapacity = $input['ReturnConsumedCapacity'] ?? null;
8093
$this->limit = $input['Limit'] ?? null;
94+
$this->returnValuesOnConditionCheckFailure = $input['ReturnValuesOnConditionCheckFailure'] ?? null;
8195
parent::__construct($input);
8296
}
8397

@@ -89,6 +103,7 @@ public function __construct(array $input = [])
89103
* NextToken?: string,
90104
* ReturnConsumedCapacity?: ReturnConsumedCapacity::*,
91105
* Limit?: int,
106+
* ReturnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure::*,
92107
* '@region'?: string|null,
93108
* }|ExecuteStatementInput $input
94109
*/
@@ -128,6 +143,14 @@ public function getReturnConsumedCapacity(): ?string
128143
return $this->returnConsumedCapacity;
129144
}
130145

146+
/**
147+
* @return ReturnValuesOnConditionCheckFailure::*|null
148+
*/
149+
public function getReturnValuesOnConditionCheckFailure(): ?string
150+
{
151+
return $this->returnValuesOnConditionCheckFailure;
152+
}
153+
131154
public function getStatement(): ?string
132155
{
133156
return $this->statement;
@@ -199,6 +222,16 @@ public function setReturnConsumedCapacity(?string $value): self
199222
return $this;
200223
}
201224

225+
/**
226+
* @param ReturnValuesOnConditionCheckFailure::*|null $value
227+
*/
228+
public function setReturnValuesOnConditionCheckFailure(?string $value): self
229+
{
230+
$this->returnValuesOnConditionCheckFailure = $value;
231+
232+
return $this;
233+
}
234+
202235
public function setStatement(?string $value): self
203236
{
204237
$this->statement = $value;
@@ -236,6 +269,12 @@ private function requestBody(): array
236269
if (null !== $v = $this->limit) {
237270
$payload['Limit'] = $v;
238271
}
272+
if (null !== $v = $this->returnValuesOnConditionCheckFailure) {
273+
if (!ReturnValuesOnConditionCheckFailure::exists($v)) {
274+
throw new InvalidArgument(sprintf('Invalid parameter "ReturnValuesOnConditionCheckFailure" for "%s". The value "%s" is not a valid "ReturnValuesOnConditionCheckFailure".', __CLASS__, $v));
275+
}
276+
$payload['ReturnValuesOnConditionCheckFailure'] = $v;
277+
}
239278

240279
return $payload;
241280
}

src/Input/PutItemInput.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use AsyncAws\DynamoDb\Enum\ReturnConsumedCapacity;
1111
use AsyncAws\DynamoDb\Enum\ReturnItemCollectionMetrics;
1212
use AsyncAws\DynamoDb\Enum\ReturnValue;
13+
use AsyncAws\DynamoDb\Enum\ReturnValuesOnConditionCheckFailure;
1314
use AsyncAws\DynamoDb\ValueObject\AttributeValue;
1415
use AsyncAws\DynamoDb\ValueObject\ExpectedAttributeValue;
1516

@@ -188,6 +189,16 @@ final class PutItemInput extends Input
188189
*/
189190
private $expressionAttributeValues;
190191

192+
/**
193+
* An optional parameter that returns the item attributes for a `PutItem` operation that failed a condition check.
194+
*
195+
* There is no additional cost associated with requesting a return value aside from the small network and processing
196+
* overhead of receiving a larger response. No read capacity units are consumed.
197+
*
198+
* @var ReturnValuesOnConditionCheckFailure::*|null
199+
*/
200+
private $returnValuesOnConditionCheckFailure;
201+
191202
/**
192203
* @param array{
193204
* TableName?: string,
@@ -200,6 +211,7 @@ final class PutItemInput extends Input
200211
* ConditionExpression?: string,
201212
* ExpressionAttributeNames?: array<string, string>,
202213
* ExpressionAttributeValues?: array<string, AttributeValue|array>,
214+
* ReturnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure::*,
203215
* '@region'?: string|null,
204216
* } $input
205217
*/
@@ -233,6 +245,7 @@ public function __construct(array $input = [])
233245
$this->expressionAttributeValues[$key] = AttributeValue::create($item);
234246
}
235247
}
248+
$this->returnValuesOnConditionCheckFailure = $input['ReturnValuesOnConditionCheckFailure'] ?? null;
236249
parent::__construct($input);
237250
}
238251

@@ -248,6 +261,7 @@ public function __construct(array $input = [])
248261
* ConditionExpression?: string,
249262
* ExpressionAttributeNames?: array<string, string>,
250263
* ExpressionAttributeValues?: array<string, AttributeValue|array>,
264+
* ReturnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure::*,
251265
* '@region'?: string|null,
252266
* }|PutItemInput $input
253267
*/
@@ -325,6 +339,14 @@ public function getReturnValues(): ?string
325339
return $this->returnValues;
326340
}
327341

342+
/**
343+
* @return ReturnValuesOnConditionCheckFailure::*|null
344+
*/
345+
public function getReturnValuesOnConditionCheckFailure(): ?string
346+
{
347+
return $this->returnValuesOnConditionCheckFailure;
348+
}
349+
328350
public function getTableName(): ?string
329351
{
330352
return $this->tableName;
@@ -442,6 +464,16 @@ public function setReturnValues(?string $value): self
442464
return $this;
443465
}
444466

467+
/**
468+
* @param ReturnValuesOnConditionCheckFailure::*|null $value
469+
*/
470+
public function setReturnValuesOnConditionCheckFailure(?string $value): self
471+
{
472+
$this->returnValuesOnConditionCheckFailure = $value;
473+
474+
return $this;
475+
}
476+
445477
public function setTableName(?string $value): self
446478
{
447479
$this->tableName = $value;
@@ -525,6 +557,12 @@ private function requestBody(): array
525557
}
526558
}
527559
}
560+
if (null !== $v = $this->returnValuesOnConditionCheckFailure) {
561+
if (!ReturnValuesOnConditionCheckFailure::exists($v)) {
562+
throw new InvalidArgument(sprintf('Invalid parameter "ReturnValuesOnConditionCheckFailure" for "%s". The value "%s" is not a valid "ReturnValuesOnConditionCheckFailure".', __CLASS__, $v));
563+
}
564+
$payload['ReturnValuesOnConditionCheckFailure'] = $v;
565+
}
528566

529567
return $payload;
530568
}

0 commit comments

Comments
 (0)