private static RESTCommand <TableResult> MergeImpl(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { RESTCommand <TableResult> rESTCommand = new RESTCommand <TableResult>(client.Credentials, RESTCommandGeneratorUtils.GenerateRequestURI(operation, client.StorageUri, table.Name)); RESTCommandGeneratorUtils.ApplyTableRequestOptionsToStorageCommand(requestOptions, rESTCommand); rESTCommand.HttpClient = client.HttpClient; TableResult result = new TableResult { Result = operation.Entity }; rESTCommand.ParseErrorAsync = StorageExtendedErrorInformationRestHelper.ReadExtendedErrorInfoFromStreamAsync; rESTCommand.BuildRequest = ((RESTCommand <TableResult> cmd, Uri uri, UriQueryBuilder builder, HttpContent httpContent, int?timeout, OperationContext ctx) => TableRequestMessageFactory.BuildStorageRequestMessageForTableOperation(uri, operation, SharedKeyCanonicalizer.Instance, client.Credentials, ctx, requestOptions)); rESTCommand.PreProcessResponse = ((RESTCommand <TableResult> cmd, HttpResponseMessage resp, Exception ex, OperationContext ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex)); return(rESTCommand); }
private static RESTCommand <TableResult> RetrieveImpl(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { RESTCommand <TableResult> rESTCommand = new RESTCommand <TableResult>(client.Credentials, RESTCommandGeneratorUtils.GenerateRequestURI(operation, client.StorageUri, table.Name)); RESTCommandGeneratorUtils.ApplyTableRequestOptionsToStorageCommand(requestOptions, rESTCommand); rESTCommand.HttpClient = client.HttpClient; TableResult result = new TableResult(); if (operation.SelectColumns != null && operation.SelectColumns.Count > 0) { rESTCommand.Builder = RESTCommandGeneratorUtils.GenerateQueryBuilder(operation, requestOptions.ProjectSystemProperties); } rESTCommand.ParseErrorAsync = StorageExtendedErrorInformationRestHelper.ReadExtendedErrorInfoFromStreamAsync; rESTCommand.BuildRequest = ((RESTCommand <TableResult> cmd, Uri uri, UriQueryBuilder builder, HttpContent httpContent, int?timeout, OperationContext ctx) => TableRequestMessageFactory.BuildStorageRequestMessageForTableOperation((builder != null) ? builder.AddToUri(uri) : uri, operation, SharedKeyCanonicalizer.Instance, client.Credentials, ctx, requestOptions)); rESTCommand.PreProcessResponse = ((RESTCommand <TableResult> cmd, HttpResponseMessage resp, Exception ex, OperationContext ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex)); rESTCommand.PostProcessResponseAsync = delegate(RESTCommand <TableResult> cmd, HttpResponseMessage resp, OperationContext ctx, CancellationToken token) { if (resp.StatusCode == HttpStatusCode.NotFound) { return(Task.FromResult(result)); } return(TableOperationHttpResponseParsers.TableOperationPostProcessAsync(result, operation, cmd, resp, ctx, requestOptions, client.Credentials.AccountName, token)); }; return(rESTCommand); }
internal static RESTCommand <ServiceStats> GenerateCMDForGetServiceStats(CloudTableClient client, TableRequestOptions requestOptions) { RESTCommand <ServiceStats> rESTCommand = new RESTCommand <ServiceStats>(client.Credentials, client.StorageUri); RESTCommandGeneratorUtils.ApplyTableRequestOptionsToStorageCommand(requestOptions, rESTCommand); rESTCommand.HttpClient = client.HttpClient; LocationMode?locationMode = requestOptions.LocationMode; if (locationMode.GetValueOrDefault() == LocationMode.PrimaryOnly && (locationMode.HasValue ? true : false)) { throw new InvalidOperationException("GetServiceStats cannot be run with a 'PrimaryOnly' location mode."); } rESTCommand.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; rESTCommand.BuildRequest = ((RESTCommand <ServiceStats> cmd, Uri uri, UriQueryBuilder uriBuilder, HttpContent httpContent, int?timeout, OperationContext ctx) => TableRequestMessageFactory.BuildStorageRequestMessageForGetServiceStats(uri, uriBuilder, timeout, SharedKeyCanonicalizer.Instance, client.Credentials, ctx, requestOptions)); rESTCommand.ParseErrorAsync = StorageExtendedErrorInformationRestHelper.ReadExtendedErrorInfoFromStreamAsync; rESTCommand.PreProcessResponse = ((RESTCommand <ServiceStats> cmd, HttpResponseMessage resp, Exception ex, OperationContext ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null, cmd, ex)); rESTCommand.PostProcessResponseAsync = ((RESTCommand <ServiceStats> cmd, HttpResponseMessage resp, OperationContext ctx, CancellationToken token) => TableOperationHttpResponseParsers.ReadServiceStatsAsync(cmd.ResponseStream)); return(rESTCommand); }
internal static RESTCommand <ServiceProperties> GetServicePropertiesImpl(CloudTableClient client, TableRequestOptions requestOptions) { RESTCommand <ServiceProperties> rESTCommand = new RESTCommand <ServiceProperties>(client.Credentials, client.StorageUri); RESTCommandGeneratorUtils.ApplyTableRequestOptionsToStorageCommand(requestOptions, rESTCommand); rESTCommand.HttpClient = client.HttpClient; rESTCommand.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; rESTCommand.BuildRequest = ((RESTCommand <ServiceProperties> cmd, Uri uri, UriQueryBuilder uriBuilder, HttpContent httpContent, int?timeout, OperationContext ctx) => TableRequestMessageFactory.BuildStorageRequestMessageForTableServiceProperties(uri, uriBuilder, timeout, HttpMethod.Get, null, SharedKeyCanonicalizer.Instance, client.Credentials, ctx, requestOptions)); rESTCommand.ParseErrorAsync = StorageExtendedErrorInformationRestHelper.ReadExtendedErrorInfoFromStreamAsync; rESTCommand.PreProcessResponse = ((RESTCommand <ServiceProperties> cmd, HttpResponseMessage resp, Exception ex, OperationContext ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null, cmd, ex)); rESTCommand.PostProcessResponseAsync = ((RESTCommand <ServiceProperties> cmd, HttpResponseMessage resp, OperationContext ctx, CancellationToken token) => TableOperationHttpResponseParsers.ReadServicePropertiesAsync(cmd.ResponseStream)); return(rESTCommand); }
internal static RESTCommand <TableBatchResult> GenerateCMDForTableBatchOperation(TableBatchOperation batch, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { RESTCommand <TableBatchResult> rESTCommand = new RESTCommand <TableBatchResult>(client.Credentials, client.StorageUri); RESTCommandGeneratorUtils.ApplyTableRequestOptionsToStorageCommand(requestOptions, rESTCommand); rESTCommand.HttpClient = client.HttpClient; TableBatchResult results = new TableBatchResult(); rESTCommand.CommandLocationMode = ((!batch.ContainsWrites) ? CommandLocationMode.PrimaryOrSecondary : CommandLocationMode.PrimaryOnly); rESTCommand.CommandLocationMode = CommandLocationMode.PrimaryOnly; rESTCommand.ParseErrorAsync = StorageExtendedErrorInformationRestHelper.ReadExtendedErrorInfoFromStreamAsync; rESTCommand.BuildRequest = ((RESTCommand <TableBatchResult> cmd, Uri uri, UriQueryBuilder builder, HttpContent httpContent, int?timeout, OperationContext ctx) => TableRequestMessageFactory.BuildStorageRequestMessageForTableBatchOperation(uri, batch, SharedKeyCanonicalizer.Instance, table.Name, client.Credentials, ctx, requestOptions)); rESTCommand.PreProcessResponse = ((RESTCommand <TableBatchResult> cmd, HttpResponseMessage resp, Exception ex, OperationContext ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp?.StatusCode ?? HttpStatusCode.Unused, results, cmd, ex)); rESTCommand.PostProcessResponseAsync = ((RESTCommand <TableBatchResult> cmd, HttpResponseMessage resp, OperationContext ctx, CancellationToken token) => TableOperationHttpResponseParsers.TableBatchOperationPostProcessAsync(results, batch, cmd, resp, ctx, requestOptions, client.Credentials.AccountName, token)); rESTCommand.RecoveryAction = delegate { results.Clear(); }; return(rESTCommand); }