예제 #1
0
 public Task UpdateTableAsync(TableSchema tableSchema)
 {
     return CreateOrUpdateTableAsync(HttpMethod.Put, tableSchema);
 }
예제 #2
0
 public Task<bool> CreateTableAsync(TableSchema tableSchema)
 {
     return CreateOrUpdateTableAsync(HttpMethod.Post, tableSchema);
 }
예제 #3
0
        private async Task CreateOrUpdateTableAsync(HttpMethod httpMethod, TableSchema tableSchema)
        {
            if (tableSchema == null)
            {
                throw new ArgumentNullException("tableSchema");
            }

            IHttpAddress address = baseAddress.WithResource( "_schema");

            var tableSchemas = new { table = new List<TableSchema> { tableSchema } };
            string body = contentSerializer.Serialize(tableSchemas);
            IHttpRequest request = new HttpRequest(httpMethod, address.Build(), baseHeaders, body);

            IHttpResponse response = await httpFacade.RequestAsync(request);
            HttpUtils.ThrowOnBadStatus(response, contentSerializer);
        }
예제 #4
0
        private async Task<bool> CreateOrUpdateTableAsync(HttpMethod httpMethod, TableSchema tableSchema)
        {
            if (tableSchema == null)
            {
                throw new ArgumentNullException("tableSchema");
            }

            SuccessResponse result = await base.RequestWithPayloadAsync<RequestResourceWrapper<TableSchema>, SuccessResponse>(
                method: httpMethod,
                resource: "_schema",
                query: null,
                payload: new RequestResourceWrapper<TableSchema> { Records = new List<TableSchema>(new [] { tableSchema }) }
                );

            return result.Success ?? false;
        }