private static RESTCommand <TableResult> RetrieveImpl(TableOperation operation, CloudTableClient client, string tableName, TableRequestOptions requestOptions) { RESTCommand <TableResult> retrieveCmd = new RESTCommand <TableResult>(client.Credentials, operation.GenerateRequestURI(client.StorageUri, tableName)); requestOptions.ApplyToStorageCommand(retrieveCmd); TableResult result = new TableResult(); if (operation.SelectColumns != null && operation.SelectColumns.Count > 0) { retrieveCmd.Builder = operation.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); } retrieveCmd.CommandLocationMode = operation.isPrimaryOnlyRetrieve ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; retrieveCmd.RetrieveResponseStream = true; retrieveCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; retrieveCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); retrieveCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex, cmd, ctx); retrieveCmd.PostProcessResponse = (cmd, resp, ctx) => Task.Run(async() => { if (resp.StatusCode == HttpStatusCode.NotFound) { return(result); } result = await TableOperationHttpResponseParsers.TableOperationPostProcess(result, operation, cmd, resp, ctx, requestOptions, client.AccountName); return(result); }); return(retrieveCmd); }
private static RESTCommand <TableResult> RetrieveImpl(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { requestOptions.AssertPolicyIfRequired(); RESTCommand <TableResult> retrieveCmd = new RESTCommand <TableResult>(client.Credentials, operation.GenerateRequestURI(client.StorageUri, table.Name)); requestOptions.ApplyToStorageCommand(retrieveCmd); TableResult result = new TableResult(); if (operation.SelectColumns != null && operation.SelectColumns.Count > 0) { // If encryption policy is set, then add the encryption metadata column to Select columns in order to be able to decrypt properties. if (requestOptions.EncryptionPolicy != null) { operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionKeyDetails); operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionPropertyDetails); } retrieveCmd.Builder = operation.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); } retrieveCmd.CommandLocationMode = operation.isPrimaryOnlyRetrieve ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; retrieveCmd.RetrieveResponseStream = true; retrieveCmd.SignRequest = client.AuthenticationHandler.SignRequest; retrieveCmd.ParseError = ODataErrorHelper.ReadFromStreamUsingODataLib; retrieveCmd.BuildRequestDelegate = (uri, builder, timeout, useVersionHeader, ctx) => TableOperationHttpWebRequestFactory.BuildRequestForTableOperation(uri, builder, client.BufferManager, timeout, operation, useVersionHeader, ctx, requestOptions).Item1; retrieveCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex); retrieveCmd.PostProcessResponse = (cmd, resp, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) { return(result); } result = TableOperationHttpResponseParsers.TableOperationPostProcess(result, operation, cmd.ResponseStream, resp, ctx, requestOptions, client.AccountName); return(result); }; retrieveCmd.PostProcessResponseAsync = async(cmd, resp, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) { return(result); } result = await TableOperationHttpResponseParsers.TableOperationPostProcessAsync(result, operation, cmd.ResponseStream, resp, ctx, requestOptions, client.AccountName); return(result); }; return(retrieveCmd); }
private static RESTCommand<TableResult> RetrieveImpl(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { requestOptions.AssertPolicyIfRequired(); RESTCommand<TableResult> retrieveCmd = new RESTCommand<TableResult>(client.Credentials, operation.GenerateRequestURI(client.StorageUri, table.Name)); requestOptions.ApplyToStorageCommand(retrieveCmd); TableResult result = new TableResult(); if (operation.SelectColumns != null && operation.SelectColumns.Count > 0) { // If encryption policy is set, then add the encryption metadata column to Select columns in order to be able to decrypt properties. if (requestOptions.EncryptionPolicy != null) { operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionKeyDetails); operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionPropertyDetails); } retrieveCmd.Builder = operation.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); } retrieveCmd.CommandLocationMode = operation.isPrimaryOnlyRetrieve ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; retrieveCmd.RetrieveResponseStream = true; retrieveCmd.SignRequest = client.AuthenticationHandler.SignRequest; retrieveCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; retrieveCmd.BuildRequestDelegate = (uri, builder, timeout, useVersionHeader, ctx) => TableOperationHttpWebRequestFactory.BuildRequestForTableOperation(uri, builder, client.BufferManager, timeout, operation, useVersionHeader, ctx, requestOptions, client.AccountName).Item1; retrieveCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex); retrieveCmd.PostProcessResponse = (cmd, resp, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) { return result; } result = TableOperationHttpResponseParsers.TableOperationPostProcess(result, operation, cmd, resp, ctx, requestOptions, client.AccountName); return result; }; return retrieveCmd; }
private static RESTCommand<TableResult> RetrieveImpl(TableOperation operation, CloudTableClient client, string tableName, TableRequestOptions requestOptions) { RESTCommand<TableResult> retrieveCmd = new RESTCommand<TableResult>(client.Credentials, operation.GenerateRequestURI(client.StorageUri, tableName)); requestOptions.ApplyToStorageCommand(retrieveCmd); TableResult result = new TableResult(); if (operation.SelectColumns != null && operation.SelectColumns.Count > 0) { retrieveCmd.Builder = operation.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); } retrieveCmd.CommandLocationMode = operation.isPrimaryOnlyRetrieve ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; retrieveCmd.RetrieveResponseStream = true; retrieveCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; retrieveCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); retrieveCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex, cmd, ctx); retrieveCmd.PostProcessResponse = (cmd, resp, ctx) => Task.Run(async () => { if (resp.StatusCode == HttpStatusCode.NotFound) { return result; } result = await TableOperationHttpResponseParsers.TableOperationPostProcess(result, operation, cmd, resp, ctx, requestOptions, client.AccountName); return result; }); return retrieveCmd; }