Container for the parameters to the DeleteItem operation.

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.

In addition to deleting an item, you can also return the item's attribute values in the same operation, using the ReturnValues parameter.

Unless you specify conditions, the DeleteItem is an idempotent operation; running it multiple times on the same item or attribute does not result in an error response.

Conditional deletes are useful for only deleting items if specific conditions are met. If those conditions are met, Amazon DynamoDB performs the delete. Otherwise, the item is not deleted.

Inheritance: Amazon.Runtime.AmazonWebServiceRequest
 // Delete TestID Table
 public static void DeleteData1(int Id)
 {
     var Req = new Amazon.DynamoDBv2.Model.DeleteItemRequest
     {
         TableName = "TestID",
         Key = new Dictionary<string, Amazon.DynamoDBv2.Model.AttributeValue>() { { "Id", new Amazon.DynamoDBv2.Model.AttributeValue { N = Id.ToString() } } }
     };
     var Rsp = client.DeleteItem(Req);
 }
        public static void DeleteData(string UID, string tableName)
        {
            var Req = new Amazon.DynamoDBv2.Model.DeleteItemRequest
            {
                TableName = tableName,
                Key = new Dictionary<string, Amazon.DynamoDBv2.Model.AttributeValue>() {{"UID",new Amazon.DynamoDBv2.Model.AttributeValue{S=UID}} }
            };

            var Rsp = client.DeleteItem(Req);
        }
Exemple #3
0
        public async Task DeleteUserByUserName(string username)
        {
            var Req = new Amazon.DynamoDBv2.Model.DeleteItemRequest
            {
                TableName = this.tableName,
                Key       = new Dictionary <string, Amazon.DynamoDBv2.Model.AttributeValue>()
                {
                    { "username", new Amazon.DynamoDBv2.Model.AttributeValue {
                          S = username.ToString()
                      } }
                }
            };
            var response = await DynamoDbClientService.getDynamoDBClient(environment).DeleteItemAsync(Req);

            var attributeList = response.Attributes;
        }
        public int DeleteItem(string primaryKeyName, string primaryKeyValue, string table)
        {
            int response = (int)DBEnum.DBResponseCodes.DEFAULT_VALUE;

            DeleteItemRequest request = new DeleteItemRequest(); // generate new deleterequest
            request.TableName = table;  // set to table name
            request.Key = new Dictionary<string, AttributeValue>() { { primaryKeyName , new AttributeValue { S = primaryKeyValue } } };
            try
            {
                this.client.DeleteItem(request);
                response = (int)DBEnum.DBResponseCodes.SUCCESS;
            }
            catch
            {
                response = (int)DBEnum.DBResponseCodes.DYNAMODB_EXCEPTION;
            }

            return response;
        }
Exemple #5
0
        public async Task DeleteCitybyCompositeKey(string state, string city)
        {
            var deleteItemRequest = new Amazon.DynamoDBv2.Model.DeleteItemRequest
            {
                TableName = this.tableName,
                Key       = new Dictionary <string, Amazon.DynamoDBv2.Model.AttributeValue>()
                {
                    { "state", new Amazon.DynamoDBv2.Model.AttributeValue {
                          S = state.ToString()
                      } },
                    { "city", new Amazon.DynamoDBv2.Model.AttributeValue {
                          S = city.ToString()
                      } }
                }
            };
            var response = await DynamoDbClientService.getDynamoDBClient(environment).DeleteItemAsync(deleteItemRequest);

            var attributeList = response.Attributes;
        }
        internal DeleteItemResponse DeleteItem(DeleteItemRequest request)
        {
            var marshaller = new DeleteItemRequestMarshaller();
            var unmarshaller = DeleteItemResponseUnmarshaller.Instance;

            return Invoke<DeleteItemRequest,DeleteItemResponse>(request, marshaller, unmarshaller);
        }
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.AmazonDynamoDB.DeleteItem"/>
 /// </summary>
 /// 
 /// <param name="deleteItemRequest">Container for the necessary parameters to execute the DeleteItem operation on AmazonDynamoDBv2.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// 
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
 ///         operation.</returns>
 public IAsyncResult BeginDeleteItem(DeleteItemRequest deleteItemRequest, AsyncCallback callback, object state)
 {
     return invokeDeleteItem(deleteItemRequest, callback, state, false);
 }
 /// <summary>
 /// <para>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.</para> <para>In addition to deleting an item, you can also return the item's attribute values in the
 /// same operation, using the <i>ReturnValues</i> parameter.</para> <para>Unless you specify conditions, the <i>DeleteItem</i> is an idempotent
 /// operation; running it multiple times on the same item or attribute does <i>not</i> result in an error response.</para> <para>Conditional
 /// deletes are useful for only deleting items if specific conditions are met. If those conditions are met, Amazon DynamoDB performs the delete.
 /// Otherwise, the item is not deleted. </para>
 /// </summary>
 /// 
 /// <param name="deleteItemRequest">Container for the necessary parameters to execute the DeleteItem service method on AmazonDynamoDBv2.</param>
 /// 
 /// <returns>The response from the DeleteItem service method, as returned by AmazonDynamoDBv2.</returns>
 /// 
 /// <exception cref="ItemCollectionSizeLimitExceededException"/>
 /// <exception cref="ResourceNotFoundException"/>
 /// <exception cref="ConditionalCheckFailedException"/>
 /// <exception cref="ProvisionedThroughputExceededException"/>
 /// <exception cref="InternalServerErrorException"/>
 public DeleteItemResponse DeleteItem(DeleteItemRequest deleteItemRequest)
 {
     IAsyncResult asyncResult = invokeDeleteItem(deleteItemRequest, null, null, true);
     return EndDeleteItem(asyncResult);
 }
 /// <summary>
 /// 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.
 /// 
 ///  
 /// <para>
 /// In addition to deleting an item, you can also return the item's attribute values in
 /// the same operation, using the <i>ReturnValues</i> parameter.
 /// </para>
 ///  
 /// <para>
 /// Unless you specify conditions, the <i>DeleteItem</i> is an idempotent operation; running
 /// it multiple times on the same item or attribute does <i>not</i> result in an error
 /// response.
 /// </para>
 ///  
 /// <para>
 /// 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. 
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table from which to delete the item.</param>
 /// <param name="key">A map of attribute names to <i>AttributeValue</i> objects, representing the primary key of the item to delete. For the primary key, you must provide all of the attributes. For example, with a hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide both the hash attribute and the range attribute.</param>
 /// <param name="returnValues">Use <i>ReturnValues</i> if you want to get the item attributes as they appeared before they were deleted. For <i>DeleteItem</i>, the valid values are: <ul> <li> <code>NONE</code> - If <i>ReturnValues</i> is not specified, or if its value is <code>NONE</code>, then nothing is returned. (This setting is the default for <i>ReturnValues</i>.) </li> <li> <code>ALL_OLD</code> - The content of the old item is returned. </li> </ul></param>
 /// 
 /// <returns>The response from the DeleteItem service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.ConditionalCheckFailedException">
 /// A condition specified in the operation could not be evaluated.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ItemCollectionSizeLimitExceededException">
 /// An item collection is too large. This exception is only returned for tables that have
 /// one or more local secondary indexes.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
 /// The request rate is too high, or the request is too large, for the available throughput
 /// to accommodate. The AWS SDKs automatically retry requests that receive this exception;
 /// therefore, your request will eventually succeed, unless the request is too large or
 /// your retry queue is too large to finish. Reduce the frequency of requests by using
 /// the strategies listed in <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
 /// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// 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>.
 /// </exception>
 public DeleteItemResponse DeleteItem(string tableName, Dictionary<string, AttributeValue> key, ReturnValue returnValues)
 {
     var request = new DeleteItemRequest();
     request.TableName = tableName;
     request.Key = key;
     request.ReturnValues = returnValues;
     return DeleteItem(request);
 }
 IAsyncResult invokeDeleteItem(DeleteItemRequest deleteItemRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new DeleteItemRequestMarshaller().Marshall(deleteItemRequest);
     var unmarshaller = DeleteItemResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
Exemple #11
0
        internal Document DeleteHelper(Key key, DeleteItemOperationConfig config, bool isAsync)
        {
            var currentConfig = config ?? new DeleteItemOperationConfig();

            var req = new DeleteItemRequest
            {
                TableName = TableName,
                Key = key
            };
            req.BeforeRequestEvent += isAsync ?
                new RequestEventHandler(UserAgentRequestEventHandlerAsync) :
                new RequestEventHandler(UserAgentRequestEventHandlerSync);
            if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes)
                req.ReturnValues = EnumMapper.Convert(currentConfig.ReturnValues);
            if (currentConfig.Expected != null && currentConfig.ExpectedState != null)
                throw new InvalidOperationException("Expected and ExpectedState cannot be set at the same time");
            if (currentConfig.Expected != null)
                req.Expected = currentConfig.Expected.ToExpectedAttributeMap();
            if (currentConfig.ExpectedState != null &&
                currentConfig.ExpectedState.ExpectedValues != null &&
                currentConfig.ExpectedState.ExpectedValues.Count > 0)
            {
                req.Expected = currentConfig.ExpectedState.ToExpectedAttributeMap();
                if (req.Expected.Count > 1)
                    req.ConditionalOperator = EnumMapper.Convert(currentConfig.ExpectedState.ConditionalOperator);
            }

            var attributes = DDBClient.DeleteItem(req).Attributes;

            Document ret = null;
            if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes)
            {
                ret = Document.FromAttributeMap(attributes);
            }
            return ret;
        }
        public void CRUDSamples()
        {
            EnsureTables();

            PutSample();

            {
                #region GetItem Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define item key
                //  Hash-key of the target item is string value "Mark Twain"
                //  Range-key of the target item is string value "The Adventures of Tom Sawyer"
                Dictionary<string, AttributeValue> key = new Dictionary<string, AttributeValue>
                {
                    { "Author", new AttributeValue { S = "Mark Twain" } },
                    { "Title", new AttributeValue { S = "The Adventures of Tom Sawyer" } }
                };

                // Create GetItem request
                GetItemRequest request = new GetItemRequest
                {
                    TableName = "SampleTable",
                    Key = key,
                };

                // Issue request
                var result = client.GetItem(request);

                // View response
                Console.WriteLine("Item:");
                Dictionary<string, AttributeValue> item = result.Item;
                foreach (var keyValuePair in item)
                {
                    Console.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
                        keyValuePair.Key,
                        keyValuePair.Value.S,
                        keyValuePair.Value.N,
                        string.Join(", ", keyValuePair.Value.SS ?? new List<string>()),
                        string.Join(", ", keyValuePair.Value.NS ?? new List<string>()));
                }

                #endregion
            }

            {
                #region UpdateItem Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define item key
                //  Hash-key of the target item is string value "Mark Twain"
                //  Range-key of the target item is string value "The Adventures of Tom Sawyer"
                Dictionary<string, AttributeValue> key = new Dictionary<string, AttributeValue>
                {
                    { "Author", new AttributeValue { S = "Mark Twain" } },
                    { "Title", new AttributeValue { S = "The Adventures of Tom Sawyer" } }
                };

                // Define attribute updates
                Dictionary<string, AttributeValueUpdate> updates = new Dictionary<string, AttributeValueUpdate>();
                // Update item's Setting attribute
                updates["Setting"] = new AttributeValueUpdate()
                {
                    Action = AttributeAction.PUT,
                    Value = new AttributeValue { S = "St. Petersburg, Missouri" }
                };
                // Remove item's Bibliography attribute
                updates["Bibliography"] = new AttributeValueUpdate()
                {
                    Action = AttributeAction.DELETE
                };   
                // Add a new string to the item's Genres SS attribute
                updates["Genres"] = new AttributeValueUpdate()
                {
                    Action = AttributeAction.ADD,
                    Value = new AttributeValue { SS = new List<string> { "Bildungsroman" } }
                };

                // Create UpdateItem request
                UpdateItemRequest request = new UpdateItemRequest
                {
                    TableName = "SampleTable",
                    Key = key,
                    AttributeUpdates = updates
                };

                // Issue request
                client.UpdateItem(request);

                #endregion
            }

            {
                #region DeleteItem Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define item key
                //  Hash-key of the target item is string value "Mark Twain"
                //  Range-key of the target item is string value "The Adventures of Tom Sawyer"
                Dictionary<string, AttributeValue> key = new Dictionary<string, AttributeValue>
                {
                    { "Author", new AttributeValue { S = "Mark Twain" } },
                    { "Title", new AttributeValue { S = "The Adventures of Tom Sawyer" } }
                };

                // Create DeleteItem request
                DeleteItemRequest request = new DeleteItemRequest
                {
                    TableName = "SampleTable",
                    Key = key
                };

                // Issue request
                client.DeleteItem(request);

                #endregion
            }
        }
 /// <summary>
 /// 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.
 /// 
 ///  
 /// <para>
 /// In addition to deleting an item, you can also return the item's attribute values in
 /// the same operation, using the <i>ReturnValues</i> parameter.
 /// </para>
 ///  
 /// <para>
 /// Unless you specify conditions, the <i>DeleteItem</i> is an idempotent operation; running
 /// it multiple times on the same item or attribute does <i>not</i> result in an error
 /// response.
 /// </para>
 ///  
 /// <para>
 /// 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. 
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table from which to delete the item.</param>
 /// <param name="key">A map of attribute names to <i>AttributeValue</i> objects, representing the primary key of the item to delete. For the primary key, you must provide all of the attributes. For example, with a hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide both the hash attribute and the range attribute.</param>
 /// <param name="returnValues">Use <i>ReturnValues</i> if you want to get the item attributes as they appeared before they were deleted. For <i>DeleteItem</i>, the valid values are: <ul> <li> <code>NONE</code> - If <i>ReturnValues</i> is not specified, or if its value is <code>NONE</code>, then nothing is returned. (This setting is the default for <i>ReturnValues</i>.) </li> <li> <code>ALL_OLD</code> - The content of the old item is returned. </li> </ul></param>
 /// 
 /// <returns>The response from the DeleteItem service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.ConditionalCheckFailedException">
 /// A condition specified in the operation could not be evaluated.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ItemCollectionSizeLimitExceededException">
 /// An item collection is too large. This exception is only returned for tables that have
 /// one or more local secondary indexes.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
 /// The request rate is too high, or the request is too large, for the available throughput
 /// to accommodate. The AWS SDKs automatically retry requests that receive this exception;
 /// therefore, your request will eventually succeed, unless the request is too large or
 /// your retry queue is too large to finish. Reduce the frequency of requests by using
 /// the strategies listed in <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
 /// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// 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>.
 /// </exception>
 public void DeleteItemAsync(string tableName, Dictionary<string, AttributeValue> key, ReturnValue returnValues, AmazonServiceCallback<DeleteItemRequest, DeleteItemResponse> callback, AsyncOptions options = null)
 {
     var request = new DeleteItemRequest();
     request.TableName = tableName;
     request.Key = key;
     request.ReturnValues = returnValues;
     DeleteItemAsync(request, callback, options);
 }
 /// <summary>
 /// 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.
 /// 
 ///  
 /// <para>
 /// In addition to deleting an item, you can also return the item's attribute values in
 /// the same operation, using the <i>ReturnValues</i> parameter.
 /// </para>
 ///  
 /// <para>
 /// Unless you specify conditions, the <i>DeleteItem</i> is an idempotent operation; running
 /// it multiple times on the same item or attribute does <i>not</i> result in an error
 /// response.
 /// </para>
 ///  
 /// <para>
 /// 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. 
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table from which to delete the item.</param>
 /// <param name="key">A map of attribute names to <i>AttributeValue</i> objects, representing the primary key of the item to delete. For the primary key, you must provide all of the attributes. For example, with a hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide both the hash attribute and the range attribute.</param>
 /// <param name="returnValues">Use <i>ReturnValues</i> if you want to get the item attributes as they appeared before they were deleted. For <i>DeleteItem</i>, the valid values are: <ul> <li> <code>NONE</code> - If <i>ReturnValues</i> is not specified, or if its value is <code>NONE</code>, then nothing is returned. (This setting is the default for <i>ReturnValues</i>.) </li> <li> <code>ALL_OLD</code> - The content of the old item is returned. </li> </ul></param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// 
 /// <returns>The response from the DeleteItem service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.ConditionalCheckFailedException">
 /// A condition specified in the operation could not be evaluated.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ItemCollectionSizeLimitExceededException">
 /// An item collection is too large. This exception is only returned for tables that have
 /// one or more local secondary indexes.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
 /// Your request rate is too high. The AWS 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="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
 /// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// 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>.
 /// </exception>
 public Task<DeleteItemResponse> DeleteItemAsync(string tableName, Dictionary<string, AttributeValue> key, ReturnValue returnValues, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new DeleteItemRequest();
     request.TableName = tableName;
     request.Key = key;
     request.ReturnValues = returnValues;
     return DeleteItemAsync(request, cancellationToken);
 }
		internal DeleteItemResponse DeleteItem(DeleteItemRequest request)
        {
            var task = DeleteItemAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
Exemple #16
0
 internal void ApplyExpression(DeleteItemRequest request, DynamoDBEntryConversion conversion)
 {
     request.ConditionExpression = this.ExpressionStatement;
     request.ExpressionAttributeNames = new Dictionary<string, string>(this.ExpressionAttributeNames);
     request.ExpressionAttributeValues = ConvertToAttributeValues(this.ExpressionAttributeValues, conversion);
 }
Exemple #17
0
        internal Document DeleteHelper(Key key, DeleteItemOperationConfig config, bool isAsync)
        {
            var currentConfig = config ?? new DeleteItemOperationConfig();

            var req = new DeleteItemRequest
            {
                TableName = TableName,
                Key = key
            };
            req.BeforeRequestEvent += isAsync ?
                new RequestEventHandler(UserAgentRequestEventHandlerAsync) :
                new RequestEventHandler(UserAgentRequestEventHandlerSync);
            if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes)
            {
                req.ReturnValues = EnumToStringMapper.Convert(currentConfig.ReturnValues);
            }
            if (currentConfig.Expected != null)
            {
                req.Expected = currentConfig.Expected.ToExpectedAttributeMap();
            }

            var attributes = DDBClient.DeleteItem(req).Attributes;

            Document ret = null;
            if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes)
            {
                ret = Document.FromAttributeMap(attributes);
            }
            return ret;
        }
        public void Delete_item_with_AWSSDK()
        {
            db.PutItem(new Todo { Id = 1, Content = "TODO 1", Order = 1 });

            var request = new DeleteItemRequest
            {
                TableName = "Todo",
                Key = new Dictionary<string, AttributeValue> {
                    { "Id", new AttributeValue { N = "1"} }
                },
            };

            awsDb.DeleteItem(request);

            Assert.That(db.GetItem<Todo>(1), Is.Null);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteItem operation.
        /// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB.DeleteItem"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteItem operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
		public async Task<DeleteItemResponse> DeleteItemAsync(DeleteItemRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteItemRequestMarshaller();
            var unmarshaller = DeleteItemResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, DeleteItemRequest, DeleteItemResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteItem operation.
        /// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteItem operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<DeleteItemResponse> DeleteItemAsync(DeleteItemRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteItemRequestMarshaller();
            var unmarshaller = DeleteItemResponseUnmarshaller.Instance;

            return InvokeAsync<DeleteItemRequest,DeleteItemResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
		internal DeleteItemResponse DeleteItem(DeleteItemRequest request)
        {
            var task = DeleteItemAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
Exemple #22
0
        internal Document DeleteHelper(Key key, DeleteItemOperationConfig config, bool isAsync)
        {
            var currentConfig = config ?? new DeleteItemOperationConfig();

            var req = new DeleteItemRequest
            {
                TableName = TableName,
                Key = key
            };
            ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)req).AddBeforeRequestHandler(isAsync ?
                new RequestEventHandler(UserAgentRequestEventHandlerAsync) :
                new RequestEventHandler(UserAgentRequestEventHandlerSync)
                );
            if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes)
                req.ReturnValues = EnumMapper.Convert(currentConfig.ReturnValues);

            ValidateConditional(currentConfig);

            if (currentConfig.Expected != null)
            {
                req.Expected = currentConfig.Expected.ToExpectedAttributeMap(Conversion);
            }
            else if (currentConfig.ExpectedState != null &&
                currentConfig.ExpectedState.ExpectedValues != null &&
                currentConfig.ExpectedState.ExpectedValues.Count > 0)
            {
                req.Expected = currentConfig.ExpectedState.ToExpectedAttributeMap(Conversion);
                if (req.Expected.Count > 1)
                    req.ConditionalOperator = EnumMapper.Convert(currentConfig.ExpectedState.ConditionalOperator);
            }
            else if (currentConfig.ConditionalExpression != null && currentConfig.ConditionalExpression.IsSet)
            {
                currentConfig.ConditionalExpression.ApplyExpression(req, this.Conversion);
            }

            var attributes = DDBClient.DeleteItem(req).Attributes;

            Document ret = null;
            if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes)
            {
                ret = Document.FromAttributeMap(attributes);
            }
            return ret;
        }
        /// <summary>
        /// <para>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.</para> <para>In addition to deleting an item, you can also return the item's attribute values in the
        /// same operation, using the <i>ReturnValues</i> parameter.</para> <para>Unless you specify conditions, the <i>DeleteItem</i> is an idempotent
        /// operation; running it multiple times on the same item or attribute does <i>not</i> result in an error response.</para> <para>Conditional
        /// deletes are useful for only deleting items if specific conditions are met. If those conditions are met, DynamoDB performs the delete.
        /// Otherwise, the item is not deleted. </para>
        /// </summary>
        /// 
        /// <param name="deleteItemRequest">Container for the necessary parameters to execute the DeleteItem service method on AmazonDynamoDBv2.</param>
        /// 
        /// <returns>The response from the DeleteItem service method, as returned by AmazonDynamoDBv2.</returns>
        /// 
        /// <exception cref="T:Amazon.DynamoDBv2.Model.ItemCollectionSizeLimitExceededException" />
        /// <exception cref="T:Amazon.DynamoDBv2.Model.ResourceNotFoundException" />
        /// <exception cref="T:Amazon.DynamoDBv2.Model.ConditionalCheckFailedException" />
        /// <exception cref="T:Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException" />
        /// <exception cref="T:Amazon.DynamoDBv2.Model.InternalServerErrorException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<DeleteItemResponse> DeleteItemAsync(DeleteItemRequest deleteItemRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteItemRequestMarshaller();
            var unmarshaller = DeleteItemResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, DeleteItemRequest, DeleteItemResponse>(deleteItemRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteItem operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteItem operation on AmazonDynamoDBClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
        ///         operation.</returns>
        public IAsyncResult BeginDeleteItem(DeleteItemRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new DeleteItemRequestMarshaller();
            var unmarshaller = DeleteItemResponseUnmarshaller.Instance;

            return BeginInvoke<DeleteItemRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteItem operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the DeleteItem operation on AmazonDynamoDBClient.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void DeleteItemAsync(DeleteItemRequest request, AmazonServiceCallback<DeleteItemRequest, DeleteItemResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new DeleteItemRequestMarshaller();
     var unmarshaller = DeleteItemResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<DeleteItemRequest,DeleteItemResponse> responseObject 
                     = new AmazonServiceResult<DeleteItemRequest,DeleteItemResponse>((DeleteItemRequest)req, (DeleteItemResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<DeleteItemRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }