forked from aws/aws-sdk-js-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeleteItemCommand.ts
305 lines (302 loc) · 11.2 KB
/
DeleteItemCommand.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
// smithy-typescript generated code
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
import { DynamoDBClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../DynamoDBClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { DeleteItemInput, DeleteItemOutput } from "../models/models_0";
import { DeleteItem } from "../schemas/com.amazonaws.dynamodb";
/**
* @public
*/
export type { __MetadataBearer };
export { $Command };
/**
* @public
*
* The input for {@link DeleteItemCommand}.
*/
export interface DeleteItemCommandInput extends DeleteItemInput {}
/**
* @public
*
* The output of {@link DeleteItemCommand}.
*/
export interface DeleteItemCommandOutput extends DeleteItemOutput, __MetadataBearer {}
/**
* <p>Deletes a single item in a table by primary key. You can perform a conditional delete
* operation that deletes the item if it exists, or if it has an expected attribute
* value.</p>
* <p>In addition to deleting an item, you can also return the item's attribute values in
* the same operation, using the <code>ReturnValues</code> parameter.</p>
* <p>Unless you specify conditions, the <code>DeleteItem</code> is an idempotent operation;
* running it multiple times on the same item or attribute does <i>not</i>
* result in an error response.</p>
* <p>Conditional deletes are useful for deleting items only if specific conditions are met.
* If those conditions are met, DynamoDB performs the delete. Otherwise, the item is not
* deleted.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { DynamoDBClient, DeleteItemCommand } from "@aws-sdk/client-dynamodb"; // ES Modules import
* // const { DynamoDBClient, DeleteItemCommand } = require("@aws-sdk/client-dynamodb"); // CommonJS import
* const client = new DynamoDBClient(config);
* const input = { // DeleteItemInput
* TableName: "STRING_VALUE", // required
* Key: { // Key // required
* "<keys>": { // AttributeValue Union: only one key present
* S: "STRING_VALUE",
* N: "STRING_VALUE",
* B: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
* SS: [ // StringSetAttributeValue
* "STRING_VALUE",
* ],
* NS: [ // NumberSetAttributeValue
* "STRING_VALUE",
* ],
* BS: [ // BinarySetAttributeValue
* new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
* ],
* M: { // MapAttributeValue
* "<keys>": {// Union: only one key present
* S: "STRING_VALUE",
* N: "STRING_VALUE",
* B: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
* SS: [
* "STRING_VALUE",
* ],
* NS: [
* "STRING_VALUE",
* ],
* BS: [
* new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
* ],
* M: {
* "<keys>": "<AttributeValue>",
* },
* L: [ // ListAttributeValue
* "<AttributeValue>",
* ],
* NULL: true || false,
* BOOL: true || false,
* },
* },
* L: [
* "<AttributeValue>",
* ],
* NULL: true || false,
* BOOL: true || false,
* },
* },
* Expected: { // ExpectedAttributeMap
* "<keys>": { // ExpectedAttributeValue
* Value: "<AttributeValue>",
* Exists: true || false,
* ComparisonOperator: "EQ" || "NE" || "IN" || "LE" || "LT" || "GE" || "GT" || "BETWEEN" || "NOT_NULL" || "NULL" || "CONTAINS" || "NOT_CONTAINS" || "BEGINS_WITH",
* AttributeValueList: [ // AttributeValueList
* "<AttributeValue>",
* ],
* },
* },
* ConditionalOperator: "AND" || "OR",
* ReturnValues: "NONE" || "ALL_OLD" || "UPDATED_OLD" || "ALL_NEW" || "UPDATED_NEW",
* ReturnConsumedCapacity: "INDEXES" || "TOTAL" || "NONE",
* ReturnItemCollectionMetrics: "SIZE" || "NONE",
* ConditionExpression: "STRING_VALUE",
* ExpressionAttributeNames: { // ExpressionAttributeNameMap
* "<keys>": "STRING_VALUE",
* },
* ExpressionAttributeValues: { // ExpressionAttributeValueMap
* "<keys>": "<AttributeValue>",
* },
* ReturnValuesOnConditionCheckFailure: "ALL_OLD" || "NONE",
* };
* const command = new DeleteItemCommand(input);
* const response = await client.send(command);
* // { // DeleteItemOutput
* // Attributes: { // AttributeMap
* // "<keys>": { // AttributeValue Union: only one key present
* // S: "STRING_VALUE",
* // N: "STRING_VALUE",
* // B: new Uint8Array(),
* // SS: [ // StringSetAttributeValue
* // "STRING_VALUE",
* // ],
* // NS: [ // NumberSetAttributeValue
* // "STRING_VALUE",
* // ],
* // BS: [ // BinarySetAttributeValue
* // new Uint8Array(),
* // ],
* // M: { // MapAttributeValue
* // "<keys>": {// Union: only one key present
* // S: "STRING_VALUE",
* // N: "STRING_VALUE",
* // B: new Uint8Array(),
* // SS: [
* // "STRING_VALUE",
* // ],
* // NS: [
* // "STRING_VALUE",
* // ],
* // BS: [
* // new Uint8Array(),
* // ],
* // M: {
* // "<keys>": "<AttributeValue>",
* // },
* // L: [ // ListAttributeValue
* // "<AttributeValue>",
* // ],
* // NULL: true || false,
* // BOOL: true || false,
* // },
* // },
* // L: [
* // "<AttributeValue>",
* // ],
* // NULL: true || false,
* // BOOL: true || false,
* // },
* // },
* // ConsumedCapacity: { // ConsumedCapacity
* // TableName: "STRING_VALUE",
* // CapacityUnits: Number("double"),
* // ReadCapacityUnits: Number("double"),
* // WriteCapacityUnits: Number("double"),
* // Table: { // Capacity
* // ReadCapacityUnits: Number("double"),
* // WriteCapacityUnits: Number("double"),
* // CapacityUnits: Number("double"),
* // },
* // LocalSecondaryIndexes: { // SecondaryIndexesCapacityMap
* // "<keys>": {
* // ReadCapacityUnits: Number("double"),
* // WriteCapacityUnits: Number("double"),
* // CapacityUnits: Number("double"),
* // },
* // },
* // GlobalSecondaryIndexes: {
* // "<keys>": {
* // ReadCapacityUnits: Number("double"),
* // WriteCapacityUnits: Number("double"),
* // CapacityUnits: Number("double"),
* // },
* // },
* // },
* // ItemCollectionMetrics: { // ItemCollectionMetrics
* // ItemCollectionKey: { // ItemCollectionKeyAttributeMap
* // "<keys>": "<AttributeValue>",
* // },
* // SizeEstimateRangeGB: [ // ItemCollectionSizeEstimateRange
* // Number("double"),
* // ],
* // },
* // };
*
* ```
*
* @param DeleteItemCommandInput - {@link DeleteItemCommandInput}
* @returns {@link DeleteItemCommandOutput}
* @see {@link DeleteItemCommandInput} for command's `input` shape.
* @see {@link DeleteItemCommandOutput} for command's `response` shape.
* @see {@link DynamoDBClientResolvedConfig | config} for DynamoDBClient's `config` shape.
*
* @throws {@link ConditionalCheckFailedException} (client fault)
* <p>A condition specified in the operation could not be evaluated.</p>
*
* @throws {@link InternalServerError} (server fault)
* <p>An error occurred on the server side.</p>
*
* @throws {@link InvalidEndpointException} (client fault)
*
* @throws {@link ItemCollectionSizeLimitExceededException} (client fault)
* <p>An item collection is too large. This exception is only returned for tables that
* have one or more local secondary indexes.</p>
*
* @throws {@link ProvisionedThroughputExceededException} (client fault)
* <p>Your request rate is too high. The Amazon Web Services SDKs for DynamoDB
* automatically retry requests that receive this exception. Your request is eventually
* successful, unless your retry queue is too large to finish. Reduce the frequency of
* requests and use exponential backoff. For more information, go to <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff">Error Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
*
* @throws {@link ReplicatedWriteConflictException} (client fault)
* <p>The request was rejected because one or more items in the request are being modified by a request in another Region. </p>
*
* @throws {@link RequestLimitExceeded} (client fault)
* <p>Throughput exceeds the current throughput quota for your account. Please contact
* <a href="https://aws.amazon.com/support">Amazon Web Services Support</a> to request a
* quota increase.</p>
*
* @throws {@link ResourceNotFoundException} (client fault)
* <p>The operation tried to access a nonexistent table or index. The resource might not
* be specified correctly, or its status might not be <code>ACTIVE</code>.</p>
*
* @throws {@link TransactionConflictException} (client fault)
* <p>Operation was rejected because there is an ongoing transaction for the
* item.</p>
*
* @throws {@link DynamoDBServiceException}
* <p>Base exception class for all service exceptions from DynamoDB service.</p>
*
* @public
* @example To delete an item
* ```javascript
* // This example deletes an item from the Music table.
* const input = {
* "Key": {
* "Artist": {
* "S": "No One You Know"
* },
* "SongTitle": {
* "S": "Scared of My Shadow"
* }
* },
* "TableName": "Music"
* };
* const command = new DeleteItemCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "ConsumedCapacity": {
* "CapacityUnits": 1,
* "TableName": "Music"
* }
* }
* *\/
* // example id: to-delete-an-item-1475884573758
* ```
*
*/
export class DeleteItemCommand extends $Command
.classBuilder<
DeleteItemCommandInput,
DeleteItemCommandOutput,
DynamoDBClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes
>()
.ep({
...commonParams,
ResourceArn: { type: "contextParams", name: "TableName" },
})
.m(function (this: any, Command: any, cs: any, config: DynamoDBClientResolvedConfig, o: any) {
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
})
.s("DynamoDB_20120810", "DeleteItem", {})
.n("DynamoDBClient", "DeleteItemCommand")
.f(void 0, void 0)
.sc(DeleteItem)
.build() {
/** @internal type navigation helper, not in runtime. */
protected declare static __types: {
api: {
input: DeleteItemInput;
output: DeleteItemOutput;
};
sdk: {
input: DeleteItemCommandInput;
output: DeleteItemCommandOutput;
};
};
}