Configuration for the Table.GetItem operation
Esempio n. 1
0
        internal Document GetItemHelper(Key key, GetItemOperationConfig config, bool isAsync)
        {
            var currentConfig = config ?? new GetItemOperationConfig();
            var request       = new GetItemRequest
            {
                TableName      = TableName,
                Key            = key,
                ConsistentRead = currentConfig.ConsistentRead
            };

            ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)request).AddBeforeRequestHandler(isAsync ?
                                                                                                new RequestEventHandler(UserAgentRequestEventHandlerAsync) :
                                                                                                new RequestEventHandler(UserAgentRequestEventHandlerSync)
                                                                                                );
            if (currentConfig.AttributesToGet != null)
            {
                request.AttributesToGet = currentConfig.AttributesToGet;
            }

            var result       = DDBClient.GetItem(request);
            var attributeMap = result.Item;

            if (attributeMap == null || attributeMap.Count == 0)
            {
                return(null);
            }
            return(Document.FromAttributeMap(attributeMap));
        }
Esempio n. 2
0
        internal async Task <Document> GetItemHelperAsync(Key key, GetItemOperationConfig config, CancellationToken cancellationToken)
        {
            var currentConfig = config ?? new GetItemOperationConfig();
            var request       = new GetItemRequest
            {
                TableName      = TableName,
                Key            = key,
                ConsistentRead = currentConfig.ConsistentRead
            };

            this.AddRequestHandler(request, isAsync: true);

            if (currentConfig.AttributesToGet != null)
            {
                request.AttributesToGet = currentConfig.AttributesToGet;
            }

            var result = await DDBClient.GetItemAsync(request, cancellationToken).ConfigureAwait(false);

            var attributeMap = result.Item;

            if (attributeMap == null || attributeMap.Count == 0)
            {
                return(null);
            }
            return(this.FromAttributeMap(attributeMap));
        }
Esempio n. 3
0
        internal Document GetItemHelper(Key key, GetItemOperationConfig config)
        {
            var currentConfig = config ?? new GetItemOperationConfig();
            var request       = new GetItemRequest
            {
                TableName      = TableName,
                Key            = key,
                ConsistentRead = currentConfig.ConsistentRead
            };

            this.AddRequestHandler(request, isAsync: false);

            if (currentConfig.AttributesToGet != null)
            {
                request.AttributesToGet = currentConfig.AttributesToGet;
            }

            var result       = DDBClient.GetItem(request);
            var attributeMap = result.Item;

            if (attributeMap == null || attributeMap.Count == 0)
            {
                return(null);
            }
            return(this.FromAttributeMap(attributeMap));
        }
Esempio n. 4
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </summary>
 /// <param name="key">Ley 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 GetItemAsync(IDictionary <string, DynamoDBEntry> key, GetItemOperationConfig config,
                          AmazonDynamoDBCallback <Document> callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions ?? new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync <Document>(
         () => { return(GetItemHelper(MakeKey(key), config, true)); },
         asyncOptions,
         callback);
 }
Esempio n. 5
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </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 GetItemAsync(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config,
                          AmazonDynamoDBCallback <Document> callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions ?? new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync <Document>(
         () => { return(GetItemHelper(MakeKey(hashKey, rangeKey), config, true)); },
         asyncOptions,
         callback);
 }
Esempio n. 6
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </summary>
 /// <param name="key">Ley 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 EndGetItem
 ///         operation.</returns>
 public IAsyncResult BeginGetItem(IDictionary <string, DynamoDBEntry> key, GetItemOperationConfig config, AsyncCallback callback, object state)
 {
     return(DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(key), config, true), callback, state));
 }
Esempio n. 7
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </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 EndGetItem
 ///         operation.</returns>
 public IAsyncResult BeginGetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config, AsyncCallback callback, object state)
 {
     return(DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(hashKey, rangeKey), config, true), callback, state));
 }
Esempio n. 8
0
 /// <summary>
 /// Gets a document from DynamoDB by key, using specified configs.
 /// </summary>
 /// <param name="key">Key of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Document from DynamoDB.</returns>
 public Document GetItem(IDictionary<string, DynamoDBEntry> key, GetItemOperationConfig config = null)
 {
     return GetItemHelper(MakeKey(key), config, false);
 }
Esempio n. 9
0
 /// <summary>
 /// Gets a document from DynamoDB by hash-and-range primary key,
 /// using 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>Document from DynamoDB.</returns>
 public Document GetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config = null)
 {
     return GetItemHelper(MakeKey(hashKey, rangeKey), config, false);
 }
Esempio n. 10
0
        internal Document GetItemHelper(Key key, GetItemOperationConfig config, bool isAsync)
        {
            var currentConfig = config ?? new GetItemOperationConfig();
            var request = new GetItemRequest
            {
                TableName = TableName,
                Key = key,
                ConsistentRead = currentConfig.ConsistentRead
            };
            request.BeforeRequestEvent += isAsync ?
                new RequestEventHandler(UserAgentRequestEventHandlerAsync) :
                new RequestEventHandler(UserAgentRequestEventHandlerSync);
            if (currentConfig.AttributesToGet != null)
                request.WithAttributesToGet(currentConfig.AttributesToGet);

            var result = DDBClient.GetItem(request);
            var attributeMap = result.GetItemResult.Item;
            if (attributeMap == null)
                return null;
            return Document.FromAttributeMap(attributeMap);
        }
Esempio n. 11
0
 /// <summary>
 /// Gets a document from DynamoDB by hash-and-range primary key,
 /// using 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>Document from DynamoDB.</returns>
 public Document GetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config)
 {
     return(GetItemHelper(MakeKey(hashKey, rangeKey), config));
 }
Esempio n. 12
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </summary>
 /// <param name="key">Ley 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> GetItemAsync(IDictionary <string, DynamoDBEntry> key, GetItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(GetItemHelperAsync(MakeKey(key), config, cancellationToken));
 }
Esempio n. 13
0
 /// <summary>
 /// Gets a document from DynamoDB by key, using specified configs.
 /// </summary>
 /// <param name="key">Key of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Document from DynamoDB.</returns>
 internal Document GetItem(IDictionary <string, DynamoDBEntry> key, GetItemOperationConfig config)
 {
     DynamoDBAsyncExecutor.IsMainThread("GetItemAsync");
     return(GetItemHelper(MakeKey(key), config, false));
 }
Esempio n. 14
0
 /// <summary>
 /// Gets a document from DynamoDB by hash-and-range primary key,
 /// using 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>Document from DynamoDB.</returns>
 internal Document GetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config)
 {
     DynamoDBAsyncExecutor.IsMainThread("GetItemAsync");
     return(GetItemHelper(MakeKey(hashKey, rangeKey), config, false));
 }
Esempio n. 15
0
 /// <summary>
 /// Gets a document from DynamoDB by hash primary key, using specified configs.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Document from DynamoDB.</returns>
 public Document GetItem(Primitive hashKey, GetItemOperationConfig config)
 {
     return(GetItemHelper(MakeKey(hashKey, null), config, false));
 }
Esempio n. 16
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </summary>
 /// <param name="key">Ley 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 EndGetItem
 ///         operation.</returns>
 public IAsyncResult BeginGetItem(IDictionary<string, DynamoDBEntry> key, GetItemOperationConfig config, AsyncCallback callback, object state)
 {
     return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(key), config, true), callback, state);
 }
Esempio n. 17
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </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 EndGetItem
 ///         operation.</returns>
 public IAsyncResult BeginGetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config, AsyncCallback callback, object state)
 {
     return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(hashKey, rangeKey), config, true), callback, state);
 }
Esempio n. 18
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem 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 GetItemAsync(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config,
     AmazonDynamoDBCallback<Document> callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions ?? new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync<Document>(
         () => { return GetItemHelper(MakeKey(hashKey, rangeKey), config, true); },
         asyncOptions,
         callback);
 }
Esempio n. 19
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// Returns the Document from DynamoDB in callback
 /// </summary>
 /// <param name="key">Ley 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 GetItemAsync(IDictionary <string, DynamoDBEntry> key, GetItemOperationConfig config, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => GetItemHelper(MakeKey(key), config, true), "GetItemAsync", callback, state);
 }
Esempio n. 20
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// </summary>
 /// <param name="key">Ley 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 GetItemAsync(IDictionary<string, DynamoDBEntry> key, GetItemOperationConfig config,
     AmazonDynamoDBCallback<Document> callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions ?? new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync<Document>(
         () => { return GetItemHelper(MakeKey(key), config, true); },
         asyncOptions,
         callback);
 }
Esempio n. 21
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// Returns the Document from DynamoDB in callback
 /// </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 GetItemAsync(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config, AmazonDynamoCallback <Document> callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation <Document>(() => GetItemHelper(MakeKey(hashKey, rangeKey), config, true), "GetItemAsync", callback, state);
 }
Esempio n. 22
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </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> GetItemAsync(Primitive hashKey, GetItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(GetItemHelperAsync(MakeKey(hashKey, null), config, cancellationToken));
 }
Esempio n. 23
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </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> GetItemAsync(Primitive hashKey, GetItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken))
 {
     return AsyncRunner.Run(() => GetItemHelper(MakeKey(hashKey, null), config, true), cancellationToken);
 }
Esempio n. 24
0
 /// <summary>
 /// Gets a document from DynamoDB by key, using specified configs.
 /// </summary>
 /// <param name="key">Key of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Document from DynamoDB.</returns>
 public Document GetItem(IDictionary <string, DynamoDBEntry> key, GetItemOperationConfig config)
 {
     return(GetItemHelper(MakeKey(key), config));
 }
Esempio n. 25
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </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> GetItemAsync(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(AsyncRunner.Run(() => GetItemHelper(MakeKey(hashKey, rangeKey), config, true), cancellationToken));
 }
Esempio n. 26
0
 /// <summary>
 /// Gets a document from DynamoDB by hash primary key, using specified configs.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Document from DynamoDB.</returns>
 public Document GetItem(Primitive hashKey, GetItemOperationConfig config = null)
 {
     return(GetItem(hashKey, null, config));
 }
Esempio n. 27
0
 /// <summary>
 /// Gets a document from DynamoDB by hash primary key, using specified configs.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Document from DynamoDB.</returns>
 public Document GetItem(Primitive hashKey, GetItemOperationConfig config = null)
 {
     return GetItem(hashKey, null, config);
 }
Esempio n. 28
0
        internal Document GetItemHelper(Key key, GetItemOperationConfig config, bool isAsync)
        {
            var currentConfig = config ?? new GetItemOperationConfig();
            var request = new GetItemRequest
            {
                TableName = TableName,
                Key = key,
                ConsistentRead = currentConfig.ConsistentRead
            };

            ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)request).AddBeforeRequestHandler(isAsync ?
                new RequestEventHandler(UserAgentRequestEventHandlerAsync) :
                new RequestEventHandler(UserAgentRequestEventHandlerSync)
                );
            if (currentConfig.AttributesToGet != null)
                request.AttributesToGet = currentConfig.AttributesToGet;

            var result = DDBClient.GetItem(request);
            var attributeMap = result.Item;
            if (attributeMap == null || attributeMap.Count == 0)
                return null;
            return Document.FromAttributeMap(attributeMap);
        }
Esempio n. 29
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Table.GetItem"/>
 /// </summary>
 /// <param name="key">Ley 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> GetItemAsync(IDictionary<string, DynamoDBEntry> key, GetItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken))
 {
     return AsyncRunner.Run(() => GetItemHelper(MakeKey(key), config, true), cancellationToken);
 }