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); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param> /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param> public void DeleteItemAsync(Document document, DeleteItemOperationConfig config, AmazonDynamoDBCallback callback, AsyncOptions asyncOptions = null) { asyncOptions = asyncOptions ?? new AsyncOptions(); DynamoDBAsyncExecutor.ExecuteAsync( () => { DeleteHelper(MakeKey(document), config, true); }, asyncOptions, callback); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param> /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param> public void DeleteItemAsync(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config, AmazonDynamoDBCallback callback, AsyncOptions asyncOptions = null) { asyncOptions = asyncOptions ?? new AsyncOptions(); DynamoDBAsyncExecutor.ExecuteAsync( () => { DeleteHelper(MakeKey(hashKey, rangeKey), config, true); }, asyncOptions, callback); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param> /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param> public void DeleteItemAsync(IDictionary <string, DynamoDBEntry> key, DeleteItemOperationConfig config, AmazonDynamoDBCallback callback, AsyncOptions asyncOptions = null) { asyncOptions = asyncOptions ?? new AsyncOptions(); DynamoDBAsyncExecutor.ExecuteAsync( () => { DeleteHelper(MakeKey(key), config, true); }, asyncOptions, callback); }
/// <summary> /// Delete a document in DynamoDB, identified by a key, using specified configs. /// </summary> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>True if deleted or false if the condition in the config was not met.</returns> public bool TryDeleteItem(IDictionary <string, DynamoDBEntry> key, DeleteItemOperationConfig config) { try { DeleteHelper(MakeKey(key), config); return(true); } catch (ConditionalCheckFailedException) { return(false); } }
/// <summary> /// Delete a document in DynamoDB, using specified configs. /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <returns>True if deleted or false if the condition in the config was not met.</returns> public bool TryDeleteItem(Document document, DeleteItemOperationConfig config) { try { DeleteItem(document, config); return(true); } catch (ConditionalCheckFailedException) { return(false); } }
/// <summary> /// Delete a document in DynamoDB, identified by hash-and-range primary key, /// using the specified configs. /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>True if deleted or false if the condition in the config was not met.</returns> public bool TryDeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config) { try { DeleteItem(hashKey, rangeKey, config); return(true); } catch (ConditionalCheckFailedException) { return(false); } }
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); }
internal async Task <Document> DeleteHelperAsync(Key key, DeleteItemOperationConfig config, CancellationToken cancellationToken) { var currentConfig = config ?? new DeleteItemOperationConfig(); var req = new DeleteItemRequest { TableName = TableName, Key = key }; this.AddRequestHandler(req, isAsync: true); if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes) { req.ReturnValues = EnumMapper.Convert(currentConfig.ReturnValues); } ValidateConditional(currentConfig); if (currentConfig.Expected != null) { req.Expected = this.ToExpectedAttributeMap(currentConfig.Expected); } else if (currentConfig.ExpectedState != null && currentConfig.ExpectedState.ExpectedValues != null && currentConfig.ExpectedState.ExpectedValues.Count > 0) { req.Expected = currentConfig.ExpectedState.ToExpectedAttributeMap(this); 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); } var attributes = (await DDBClient.DeleteItemAsync(req, cancellationToken).ConfigureAwait(false)).Attributes; Document ret = null; if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes) { ret = this.FromAttributeMap(attributes); } return(ret); }
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); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="cancellationToken">Token which can be used to cancel the task.</param> /// <returns>A Task that can be used to poll or wait for results, or both.</returns> public Task<Document> DeleteItemAsync(IDictionary<string, DynamoDBEntry> key, DeleteItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken)) { return AsyncRunner.Run(() => DeleteHelper(MakeKey(key), config, true), cancellationToken); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="cancellationToken">Token which can be used to cancel the task.</param> /// <returns>A Task that can be used to poll or wait for results, or both.</returns> public Task <Document> DeleteItemAsync(IDictionary <string, DynamoDBEntry> key, DeleteItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken)) { return(DeleteHelperAsync(MakeKey(key), config, cancellationToken)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">An AmazonDynamoCallback 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>void</returns> public void DeleteItemAsync(Document document, DeleteItemOperationConfig config, AmazonDynamoCallback <Document> callback, object state) { DynamoDBAsyncExecutor.AsyncOperation <Document>(() => DeleteHelper(MakeKey(document), config, true), "DeleteItemAsync", callback, state); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param> /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param> public void DeleteItemAsync(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config, AmazonDynamoDBCallback callback, AsyncOptions asyncOptions = null) { asyncOptions = asyncOptions ?? new AsyncOptions(); DynamoDBAsyncExecutor.ExecuteAsync( () => { DeleteHelper(MakeKey(hashKey, rangeKey), config, true); }, asyncOptions, callback); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <param name="cancellationToken">Token which can be used to cancel the task.</param> /// <returns>A Task that can be used to poll or wait for results, or both.</returns> public Task <Document> DeleteItemAsync(Document document, DeleteItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken)) { return(DeleteHelperAsync(MakeKey(document), config, cancellationToken)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</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(Document document, DeleteItemOperationConfig config, AsyncCallback callback, object state) { return(DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(document), config, true), callback, state)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</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(IDictionary <string, DynamoDBEntry> key, DeleteItemOperationConfig config, AsyncCallback callback, object state) { return(DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(key), config, true), callback, state)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="cancellationToken">Token which can be used to cancel the task.</param> /// <returns>A Task that can be used to poll or wait for results, or both.</returns> public Task <Document> DeleteItemAsync(Primitive hashKey, DeleteItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken)) { return(AsyncRunner.Run(() => DeleteHelper(MakeKey(hashKey, null), config, true), cancellationToken)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <param name="cancellationToken">Token which can be used to cancel the task.</param> /// <returns>A Task that can be used to poll or wait for results, or both.</returns> public Task <Document> DeleteItemAsync(Document document, DeleteItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken)) { return(AsyncRunner.Run(() => DeleteHelper(MakeKey(document), config, true), cancellationToken)); }
/// <summary> /// Delete a document in DynamoDB, identified by hash-and-range primary key, /// using the specified configs. /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> internal Document DeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config) { DynamoDBAsyncExecutor.IsMainThread("DeleteItemAsync"); return(DeleteHelper(MakeKey(hashKey, rangeKey), config, false)); }
/// <summary> /// Delete a document in DynamoDB, identified by a key, using specified configs. /// </summary> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> internal Document DeleteItem(IDictionary <string, DynamoDBEntry> key, DeleteItemOperationConfig config) { DynamoDBAsyncExecutor.IsMainThread("DeleteItemAsync"); return(DeleteHelper(MakeKey(key), config, false)); }
/// <summary> /// Delete a document in DynamoDB, using specified configs. /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> internal Document DeleteItem(Document document, DeleteItemOperationConfig config) { DynamoDBAsyncExecutor.IsMainThread("DeleteItemAsync"); return(DeleteHelper(MakeKey(document), config, false)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</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(Document document, DeleteItemOperationConfig config, AsyncCallback callback, object state) { return DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(document), config, true), callback, state); }
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; }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</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(IDictionary<string, DynamoDBEntry> key, DeleteItemOperationConfig config, AsyncCallback callback, object state) { return DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(key), config, true), callback, state); }
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; }
/// <summary> /// Delete a document in DynamoDB, identified by a key, using specified configs. /// </summary> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>True if deleted or false if the condition in the config was not met.</returns> public bool TryDeleteItem(IDictionary<string, DynamoDBEntry> key, DeleteItemOperationConfig config = null) { try { DeleteHelper(MakeKey(key), config, false); return true; } catch (ConditionalCheckFailedException) { return false; } }
/// <summary> /// Delete a document in DynamoDB, identified by hash-key, /// using the specified configs. /// </summary> /// <exception cref="T:Amazon.DynamoDBv2.Model.ConditionalCheckFailedException">If the condition set on the config fails.</exception> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> public Document DeleteItem(Primitive hashKey, DeleteItemOperationConfig config = null) { return(DeleteHelper(MakeKey(hashKey, null), config, false)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</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(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config, AsyncCallback callback, object state) { return(DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(hashKey, rangeKey), config, true), callback, state)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// /// </summary> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">An AmazonDynamoCallback 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>void</returns> public void DeleteItemAsync(IDictionary <string, DynamoDBEntry> key, DeleteItemOperationConfig config, AmazonDynamoCallback <Document> callback, object state) { DynamoDBAsyncExecutor.AsyncOperation <Document>(() => DeleteHelper(MakeKey(key), config, true), "DeleteItemAsync", callback, state); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param> /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param> public void DeleteItemAsync(Document document, DeleteItemOperationConfig config, AmazonDynamoDBCallback callback, AsyncOptions asyncOptions = null) { asyncOptions = asyncOptions ?? new AsyncOptions(); DynamoDBAsyncExecutor.ExecuteAsync( () => { DeleteHelper(MakeKey(document), config, true); }, asyncOptions, callback); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">An AmazonDynamoCallback 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>void</returns> public void DeleteItemAsync(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config, AmazonDynamoCallback <Document> callback, object state) { DynamoDBAsyncExecutor.AsyncOperation <Document>(() => DeleteHelper(MakeKey(hashKey, rangeKey), config, true), "DeleteItemAsync", callback, state); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// </summary> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param> /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param> public void DeleteItemAsync(IDictionary<string, DynamoDBEntry> key, DeleteItemOperationConfig config, AmazonDynamoDBCallback callback, AsyncOptions asyncOptions = null) { asyncOptions = asyncOptions ?? new AsyncOptions(); DynamoDBAsyncExecutor.ExecuteAsync( () => { DeleteHelper(MakeKey(key), config, true); }, asyncOptions, callback); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="cancellationToken">Token which can be used to cancel the task.</param> /// <returns>A Task that can be used to poll or wait for results, or both.</returns> public Task<Document> DeleteItemAsync(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken)) { return AsyncRunner.Run(() => DeleteHelper(MakeKey(hashKey, rangeKey), config, true), cancellationToken); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="cancellationToken">Token which can be used to cancel the task.</param> /// <returns>A Task that can be used to poll or wait for results, or both.</returns> public Task <Document> DeleteItemAsync(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken)) { return(DeleteHelperAsync(MakeKey(hashKey, rangeKey), config, cancellationToken)); }
/// <summary> /// Delete a document in DynamoDB, identified by hash-and-range primary key, /// using the specified configs. /// </summary> /// <exception cref="T:Amazon.DynamoDBv2.Model.ConditionalCheckFailedException">If the condition set on the config fails.</exception> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> public Document DeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config = null) { return DeleteHelper(MakeKey(hashKey, rangeKey), config, false); }
/// <summary> /// Delete a document in DynamoDB, using specified configs. /// </summary> /// <exception cref="T:Amazon.DynamoDBv2.Model.ConditionalCheckFailedException">If the condition set on the config fails.</exception> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> public Document DeleteItem(Document document, DeleteItemOperationConfig config) { return(DeleteHelper(MakeKey(document), config)); }
/// <summary> /// Delete a document in DynamoDB, identified by hash-and-range primary key, /// using the specified configs. /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>True if deleted or false if the condition in the config was not met.</returns> public bool TryDeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config = null) { try { DeleteItem(hashKey, rangeKey, config); return true; } catch (ConditionalCheckFailedException) { return false; } }
/// <summary> /// Delete a document in DynamoDB, identified by hash-and-range primary key, /// using the specified configs. /// </summary> /// <exception cref="T:Amazon.DynamoDBv2.Model.ConditionalCheckFailedException">If the condition set on the config fails.</exception> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> public Document DeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config) { return(DeleteHelper(MakeKey(hashKey, rangeKey), config)); }
/// <summary> /// Delete a document in DynamoDB, identified by a key, using specified configs. /// </summary> /// <exception cref="T:Amazon.DynamoDBv2.Model.ConditionalCheckFailedException">If the condition set on the config fails.</exception> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> public Document DeleteItem(IDictionary<string, DynamoDBEntry> key, DeleteItemOperationConfig config = null) { return DeleteHelper(MakeKey(key), config, false); }
/// <summary> /// Delete a document in DynamoDB, identified by a key, using specified configs. /// </summary> /// <exception cref="T:Amazon.DynamoDBv2.Model.ConditionalCheckFailedException">If the condition set on the config fails.</exception> /// <param name="key">Key of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> public Document DeleteItem(IDictionary <string, DynamoDBEntry> key, DeleteItemOperationConfig config) { return(DeleteHelper(MakeKey(key), config)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</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(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config, AsyncCallback callback, object state) { return DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(hashKey, rangeKey), config, true), callback, state); }
/// <summary> /// Delete a document in DynamoDB, using specified configs. /// </summary> /// <exception cref="T:Amazon.DynamoDBv2.Model.ConditionalCheckFailedException">If the condition set on the config fails.</exception> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> public Document DeleteItem(Document document, DeleteItemOperationConfig config = null) { return DeleteHelper(MakeKey(document), config, false); }
/// <summary> /// Delete a document in DynamoDB, using specified configs. /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <returns>True if deleted or false if the condition in the config was not met.</returns> public bool TryDeleteItem(Document document, DeleteItemOperationConfig config = null) { try { DeleteItem(document, config); return true; } catch (ConditionalCheckFailedException) { return false; } }
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> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <param name="cancellationToken">Token which can be used to cancel the task.</param> /// <returns>A Task that can be used to poll or wait for results, or both.</returns> public Task<Document> DeleteItemAsync(Document document, DeleteItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken)) { return AsyncRunner.Run(() => DeleteHelper(MakeKey(document), config, true), cancellationToken); }