/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using Amazon.DynamoDBv2.Model;
using Amazon.Runtime;
using Amazon.Util;
using System.Linq;
using System.Threading;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Amazon.DynamoDBv2.DocumentModel
{
public partial class Table
{
#region PutItemAsync
///
/// Initiates the asynchronous execution of the PutItem operation.
///
///
/// Document to save.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndPutItem
/// operation.
public IAsyncResult BeginPutItem(Document doc, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => PutItemHelper(doc, null), callback, state);
}
///
/// Initiates the asynchronous execution of the PutItem operation.
///
///
/// Document to save.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndPutItem
/// operation.
public IAsyncResult BeginPutItem(Document doc, PutItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => PutItemHelper(doc, config), callback, state);
}
///
/// Finishes the asynchronous execution of the PutItem operation.
///
///
/// The IAsyncResult returned by the call to BeginPutItem.
/// Null or updated attributes, depending on config.
public Document EndPutItem(IAsyncResult asyncResult)
{
return DynamoDBAsyncExecutor.EndOperation(asyncResult);
}
#endregion
#region GetItemAsync
///
/// Initiates the asynchronous execution of the GetItem operation.
///
///
/// Hash key element of the document.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetItem
/// operation.
public IAsyncResult BeginGetItem(Primitive hashKey, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(hashKey, null), null), callback, state);
}
///
/// Initiates the asynchronous execution of the GetItem operation.
///
///
/// Hash key element of the document.
/// Range key element of the document.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetItem
/// operation.
public IAsyncResult BeginGetItem(Primitive hashKey, Primitive rangeKey, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(hashKey, rangeKey), null), callback, state);
}
///
/// Initiates the asynchronous execution of the GetItem operation.
///
///
/// Hash key element of the document.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetItem
/// operation.
public IAsyncResult BeginGetItem(Primitive hashKey, GetItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(hashKey, null), config), callback, state);
}
///
/// Initiates the asynchronous execution of the GetItem operation.
///
///
/// Hash key element of the document.
/// Range key element of the document.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetItem
/// operation.
public IAsyncResult BeginGetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(hashKey, rangeKey), config), callback, state);
}
///
/// Initiates the asynchronous execution of the GetItem operation.
///
///
/// Key of the document.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetItem
/// operation.
public IAsyncResult BeginGetItem(IDictionary key, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(key), null), callback, state);
}
///
/// Initiates the asynchronous execution of the GetItem operation.
///
///
/// Ley of the document.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetItem
/// operation.
public IAsyncResult BeginGetItem(IDictionary key, GetItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(key), config), callback, state);
}
///
/// Finishes the asynchronous execution of the GetItem operation.
///
///
/// The IAsyncResult returned by the call to BeginGetItem.
/// Document from DynamoDB.
public Document EndGetItem(IAsyncResult asyncResult)
{
return DynamoDBAsyncExecutor.EndOperation(asyncResult);
}
#endregion
#region UpdateItemAsync
///
/// Initiates the asynchronous execution of the UpdateItem operation.
///
///
/// Document to update.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndUpdateItem
/// operation.
public IAsyncResult BeginUpdateItem(Document doc, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => UpdateHelper(doc, MakeKey(doc), null), callback, state);
}
///
/// Initiates the asynchronous execution of the UpdateItem operation.
///
///
/// Attributes to update.
/// Hash key element of the document.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndUpdateItem
/// operation.
public IAsyncResult BeginUpdateItem(Document doc, Primitive hashKey, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => UpdateHelper(doc, MakeKey(hashKey, null), null), callback, state);
}
///
/// Initiates the asynchronous execution of the UpdateItem operation.
///
///
/// Attributes to update.
/// Hash key element of the document.
/// Range key element of the document.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndUpdateItem
/// operation.
public IAsyncResult BeginUpdateItem(Document doc, Primitive hashKey, Primitive rangeKey, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => UpdateHelper(doc, MakeKey(hashKey, rangeKey), null), callback, state);
}
///
/// Initiates the asynchronous execution of the UpdateItem operation.
///
///
/// Attributes to update.
/// Key of the document.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndUpdateItem
/// operation.
public IAsyncResult BeginUpdateItem(Document doc, IDictionary key, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => UpdateHelper(doc, MakeKey(key), null), callback, state);
}
///
/// Initiates the asynchronous execution of the UpdateItem operation.
///
///
/// Document to update.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndUpdateItem
/// operation.
public IAsyncResult BeginUpdateItem(Document doc, UpdateItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => UpdateHelper(doc, MakeKey(doc), config), callback, state);
}
///
/// Initiates the asynchronous execution of the UpdateItem operation.
///
///
/// Attributes to update.
/// Hash key element of the document.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndUpdateItem
/// operation.
public IAsyncResult BeginUpdateItem(Document doc, Primitive hashKey, UpdateItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => UpdateHelper(doc, MakeKey(hashKey, null), config), callback, state);
}
///
/// Initiates the asynchronous execution of the UpdateItem operation.
///
///
/// Attributes to update.
/// Hash key element of the document.
/// Range key element of the document.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndUpdateItem
/// operation.
public IAsyncResult BeginUpdateItem(Document doc, Primitive hashKey, Primitive rangeKey, UpdateItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => UpdateHelper(doc, MakeKey(hashKey, rangeKey), config), callback, state);
}
///
/// Initiates the asynchronous execution of the UpdateItem operation.
///
///
/// Attributes to update.
/// Key of the document.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndUpdateItem
/// operation.
public IAsyncResult BeginUpdateItem(Document doc, IDictionary key, UpdateItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => UpdateHelper(doc, MakeKey(key), config), callback, state);
}
///
/// Finishes the asynchronous execution of the GetItem operation.
///
///
/// The IAsyncResult returned by the call to BeginUpdateItem.
/// Null or updated attributes, depending on config.
public Document EndUpdateItem(IAsyncResult asyncResult)
{
return DynamoDBAsyncExecutor.EndOperation(asyncResult);
}
#endregion
#region DeleteItemAsync
///
/// Initiates the asynchronous execution of the DeleteItem operation.
///
///
/// Document to delete.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
/// operation.
public IAsyncResult BeginDeleteItem(Document document, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => { DeleteHelper(MakeKey(document), null); return null; }, callback, state);
}
///
/// Initiates the asynchronous execution of the DeleteItem operation.
///
///
/// Hash key element of the document.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
/// operation.
public IAsyncResult BeginDeleteItem(Primitive hashKey, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => { DeleteHelper(MakeKey(hashKey, null), null); return null; }, callback, state);
}
///
/// Initiates the asynchronous execution of the DeleteItem operation.
///
///
/// Hash key element of the document.
/// Range key element of the document.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
/// operation.
public IAsyncResult BeginDeleteItem(Primitive hashKey, Primitive rangeKey, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => { DeleteHelper(MakeKey(hashKey, rangeKey), null); return null; }, callback, state);
}
///
/// Initiates the asynchronous execution of the DeleteItem operation.
///
///
/// Key of the document.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
/// operation.
public IAsyncResult BeginDeleteItem(IDictionary key, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => { DeleteHelper(MakeKey(key), null); return null; }, callback, state);
}
///
/// Initiates the asynchronous execution of the DeleteItem operation.
///
///
/// Document to delete.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
/// operation.
public IAsyncResult BeginDeleteItem(Document document, DeleteItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(document), config), callback, state);
}
///
/// Initiates the asynchronous execution of the DeleteItem operation.
///
///
/// Hash key element of the document.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
/// operation.
public IAsyncResult BeginDeleteItem(Primitive hashKey, DeleteItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(hashKey, null), config), callback, state);
}
///
/// Initiates the asynchronous execution of the DeleteItem operation.
///
///
/// Hash key element of the document.
/// Range key element of the document.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
/// operation.
public IAsyncResult BeginDeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(hashKey, rangeKey), config), callback, state);
}
///
/// Initiates the asynchronous execution of the DeleteItem operation.
///
///
/// Key of the document.
/// Configuration to use.
/// An AsyncCallback delegate that is invoked when the operation completes.
/// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.
/// An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
/// operation.
public IAsyncResult BeginDeleteItem(IDictionary key, DeleteItemOperationConfig config, AsyncCallback callback, object state)
{
return DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(key), config), callback, state);
}
///
/// Finishes the asynchronous execution of the DeleteItem operation.
///
///
/// The IAsyncResult returned by the call to BeginDeleteItem.
/// Null or old attributes, depending on config.
public Document EndDeleteItem(IAsyncResult asyncResult)
{
return DynamoDBAsyncExecutor.EndOperation(asyncResult);
}
#endregion
}
}