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)); }
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)); }
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)); }
/// <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); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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); }
/// <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); }
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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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)); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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); }
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); }
/// <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); }