Configuration for the Table.DeleteItem operation
Inheritance: IConditionalOperationConfig
Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 /// <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);
 }
Ejemplo n.º 3
0
 /// <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);
 }
Ejemplo n.º 4
0
 /// <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);
 }
Ejemplo n.º 5
0
 /// <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);
     }
 }
Ejemplo n.º 6
0
 /// <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);
     }
 }
Ejemplo n.º 7
0
 /// <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);
     }
 }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
 /// <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);
 }
Ejemplo n.º 12
0
 /// <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));
 }
Ejemplo n.º 13
0
 /// <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);
 }
Ejemplo n.º 14
0
 /// <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);
 }
Ejemplo n.º 15
0
 /// <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));
 }
Ejemplo n.º 16
0
 /// <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));
 }
Ejemplo n.º 17
0
 /// <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));
 }
Ejemplo n.º 18
0
 /// <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));
 }
Ejemplo n.º 19
0
 /// <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));
 }
Ejemplo n.º 20
0
 /// <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));
 }
Ejemplo n.º 21
0
 /// <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));
 }
Ejemplo n.º 22
0
 /// <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));
 }
Ejemplo n.º 23
0
 /// <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);
 }
Ejemplo n.º 24
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;
        }
Ejemplo n.º 25
0
 /// <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);
 }
Ejemplo n.º 26
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;
        }
Ejemplo n.º 27
0
 /// <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;
     }
 }
Ejemplo n.º 28
0
 /// <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));
 }
Ejemplo n.º 29
0
 /// <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));
 }
Ejemplo n.º 30
0
 /// <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);
 }
Ejemplo n.º 31
0
 /// <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);
 }
Ejemplo n.º 32
0
 /// <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);
 }
Ejemplo n.º 33
0
 /// <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);
 }
Ejemplo n.º 34
0
 /// <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);
 }
Ejemplo n.º 35
0
 /// <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));
 }
Ejemplo n.º 36
0
 /// <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);
 }
Ejemplo n.º 37
0
 /// <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));
 }
Ejemplo n.º 38
0
 /// <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;
     }
 }
Ejemplo n.º 39
0
 /// <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));
 }
Ejemplo n.º 40
0
 /// <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);
 }
Ejemplo n.º 41
0
 /// <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));
 }
Ejemplo n.º 42
0
 /// <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);
 }
Ejemplo n.º 43
0
 /// <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);
 }
Ejemplo n.º 44
0
 /// <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;
     }
 }
Ejemplo n.º 45
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;
        }
Ejemplo n.º 46
0
 /// <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);
 }