import { Command as $Command } from "@smithy/smithy-client"; import type { MetadataBearer as __MetadataBearer } from "@smithy/types"; import type { DynamoDBClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../DynamoDBClient"; import type { UpdateItemInput, UpdateItemOutput } from "../models/models_0"; /** * @public */ export type { __MetadataBearer }; export { $Command }; /** * @public * * The input for {@link UpdateItemCommand}. */ export interface UpdateItemCommandInput extends UpdateItemInput { } /** * @public * * The output of {@link UpdateItemCommand}. */ export interface UpdateItemCommandOutput extends UpdateItemOutput, __MetadataBearer { } declare const UpdateItemCommand_base: { new (input: UpdateItemCommandInput): import("@smithy/smithy-client").CommandImpl; new (input: UpdateItemCommandInput): import("@smithy/smithy-client").CommandImpl; getEndpointParameterInstructions(): import("@smithy/middleware-endpoint").EndpointParameterInstructions; }; /** *

Edits an existing item's attributes, or adds a new item to the table if it does not * already exist. You can put, delete, or add attribute values. You can also perform a * conditional update on an existing item (insert a new attribute name-value pair if it * doesn't exist, or replace an existing name-value pair if it has certain expected * attribute values).

*

You can also return the item's attribute values in the same UpdateItem * operation using the ReturnValues parameter.

* @example * Use a bare-bones client and the command you need to make an API call. * ```javascript * import { DynamoDBClient, UpdateItemCommand } from "@aws-sdk/client-dynamodb"; // ES Modules import * // const { DynamoDBClient, UpdateItemCommand } = require("@aws-sdk/client-dynamodb"); // CommonJS import * // import type { DynamoDBClientConfig } from "@aws-sdk/client-dynamodb"; * const config = {}; // type is DynamoDBClientConfig * const client = new DynamoDBClient(config); * const input = { // UpdateItemInput * TableName: "STRING_VALUE", // required * Key: { // Key // required * "": { // 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 * "": {// 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: { * "": "", * }, * L: [ // ListAttributeValue * "", * ], * NULL: true || false, * BOOL: true || false, * }, * }, * L: [ * "", * ], * NULL: true || false, * BOOL: true || false, * }, * }, * AttributeUpdates: { // AttributeUpdates * "": { // AttributeValueUpdate * Value: "", * Action: "ADD" || "PUT" || "DELETE", * }, * }, * Expected: { // ExpectedAttributeMap * "": { // ExpectedAttributeValue * Value: "", * Exists: true || false, * ComparisonOperator: "EQ" || "NE" || "IN" || "LE" || "LT" || "GE" || "GT" || "BETWEEN" || "NOT_NULL" || "NULL" || "CONTAINS" || "NOT_CONTAINS" || "BEGINS_WITH", * AttributeValueList: [ // AttributeValueList * "", * ], * }, * }, * ConditionalOperator: "AND" || "OR", * ReturnValues: "NONE" || "ALL_OLD" || "UPDATED_OLD" || "ALL_NEW" || "UPDATED_NEW", * ReturnConsumedCapacity: "INDEXES" || "TOTAL" || "NONE", * ReturnItemCollectionMetrics: "SIZE" || "NONE", * UpdateExpression: "STRING_VALUE", * ConditionExpression: "STRING_VALUE", * ExpressionAttributeNames: { // ExpressionAttributeNameMap * "": "STRING_VALUE", * }, * ExpressionAttributeValues: { // ExpressionAttributeValueMap * "": "", * }, * ReturnValuesOnConditionCheckFailure: "ALL_OLD" || "NONE", * }; * const command = new UpdateItemCommand(input); * const response = await client.send(command); * // { // UpdateItemOutput * // Attributes: { // AttributeMap * // "": { // 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 * // "": {// Union: only one key present * // S: "STRING_VALUE", * // N: "STRING_VALUE", * // B: new Uint8Array(), * // SS: [ * // "STRING_VALUE", * // ], * // NS: [ * // "STRING_VALUE", * // ], * // BS: [ * // new Uint8Array(), * // ], * // M: { * // "": "", * // }, * // L: [ // ListAttributeValue * // "", * // ], * // NULL: true || false, * // BOOL: true || false, * // }, * // }, * // L: [ * // "", * // ], * // 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 * // "": { * // ReadCapacityUnits: Number("double"), * // WriteCapacityUnits: Number("double"), * // CapacityUnits: Number("double"), * // }, * // }, * // GlobalSecondaryIndexes: { * // "": { * // ReadCapacityUnits: Number("double"), * // WriteCapacityUnits: Number("double"), * // CapacityUnits: Number("double"), * // }, * // }, * // }, * // ItemCollectionMetrics: { // ItemCollectionMetrics * // ItemCollectionKey: { // ItemCollectionKeyAttributeMap * // "": "", * // }, * // SizeEstimateRangeGB: [ // ItemCollectionSizeEstimateRange * // Number("double"), * // ], * // }, * // }; * * ``` * * @param UpdateItemCommandInput - {@link UpdateItemCommandInput} * @returns {@link UpdateItemCommandOutput} * @see {@link UpdateItemCommandInput} for command's `input` shape. * @see {@link UpdateItemCommandOutput} for command's `response` shape. * @see {@link DynamoDBClientResolvedConfig | config} for DynamoDBClient's `config` shape. * * @throws {@link ConditionalCheckFailedException} (client fault) *

A condition specified in the operation failed to be evaluated.

* * @throws {@link InternalServerError} (server fault) *

An error occurred on the server side.

* * @throws {@link InvalidEndpointException} (client fault) * * @throws {@link ItemCollectionSizeLimitExceededException} (client fault) *

An item collection is too large. This exception is only returned for tables that * have one or more local secondary indexes.

* * @throws {@link ProvisionedThroughputExceededException} (client fault) *

The request was denied due to request throttling. For detailed information about * why the request was throttled and the ARN of the impacted resource, find the ThrottlingReason field in the returned exception. 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 Error Retries and Exponential Backoff in the Amazon DynamoDB Developer Guide.

* * @throws {@link ReplicatedWriteConflictException} (client fault) *

The request was rejected because one or more items in the request are being modified * by a request in another Region.

* * @throws {@link RequestLimitExceeded} (client fault) *

Throughput exceeds the current throughput quota for your account. For detailed * information about why the request was throttled and the ARN of the impacted resource, * find the ThrottlingReason field in the returned exception. Contact Amazon Web Services Support to request a quota * increase.

* * @throws {@link ResourceNotFoundException} (client fault) *

The operation tried to access a nonexistent table or index. The resource might not * be specified correctly, or its status might not be ACTIVE.

* * @throws {@link ThrottlingException} (client fault) *

The request was denied due to request throttling. For detailed information about why * the request was throttled and the ARN of the impacted resource, find the ThrottlingReason field in the returned exception.

* * @throws {@link TransactionConflictException} (client fault) *

Operation was rejected because there is an ongoing transaction for the * item.

* * @throws {@link DynamoDBServiceException} *

Base exception class for all service exceptions from DynamoDB service.

* * * @example To update an item in a table * ```javascript * // This example updates an item in the Music table. It adds a new attribute (Year) and modifies the AlbumTitle attribute. All of the attributes in the item, as they appear after the update, are returned in the response. * const input = { * ExpressionAttributeNames: { * #AT: "AlbumTitle", * #Y: "Year" * }, * ExpressionAttributeValues: { * :t: { * S: "Louder Than Ever" * }, * :y: { * N: "2015" * } * }, * Key: { * Artist: { * S: "Acme Band" * }, * SongTitle: { * S: "Happy Day" * } * }, * ReturnValues: "ALL_NEW", * TableName: "Music", * UpdateExpression: "SET #Y = :y, #AT = :t" * }; * const command = new UpdateItemCommand(input); * const response = await client.send(command); * /* response is * { * Attributes: { * AlbumTitle: { * S: "Louder Than Ever" * }, * Artist: { * S: "Acme Band" * }, * SongTitle: { * S: "Happy Day" * }, * Year: { * N: "2015" * } * } * } * *\/ * ``` * * @public */ export declare class UpdateItemCommand extends UpdateItemCommand_base { /** @internal type navigation helper, not in runtime. */ protected static __types: { api: { input: UpdateItemInput; output: UpdateItemOutput; }; sdk: { input: UpdateItemCommandInput; output: UpdateItemCommandOutput; }; }; }