| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using System.Threading; |
| | 12 | | using System.Threading.Tasks; |
| | 13 | | using System.Xml.Linq; |
| | 14 | | using Azure.Core; |
| | 15 | | using Azure.Core.Pipeline; |
| | 16 | | using Azure.Data.Tables.Models; |
| | 17 | |
|
| | 18 | | namespace Azure.Data.Tables |
| | 19 | | { |
| | 20 | | internal partial class TableRestClient |
| | 21 | | { |
| | 22 | | private string url; |
| | 23 | | private string version; |
| | 24 | | private ClientDiagnostics _clientDiagnostics; |
| | 25 | | private HttpPipeline _pipeline; |
| | 26 | |
|
| | 27 | | /// <summary> Initializes a new instance of TableRestClient. </summary> |
| | 28 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 29 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 30 | | /// <param name="url"> The URL of the service account or table that is the targe of the desired operation. </par |
| | 31 | | /// <param name="version"> Specifies the version of the operation to use for this request. </param> |
| | 32 | | /// <exception cref="ArgumentNullException"> <paramref name="url"/> or <paramref name="version"/> is null. </exc |
| 496 | 33 | | public TableRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string url, string version = |
| | 34 | | { |
| 496 | 35 | | if (url == null) |
| | 36 | | { |
| 0 | 37 | | throw new ArgumentNullException(nameof(url)); |
| | 38 | | } |
| 496 | 39 | | if (version == null) |
| | 40 | | { |
| 0 | 41 | | throw new ArgumentNullException(nameof(version)); |
| | 42 | | } |
| | 43 | |
|
| 496 | 44 | | this.url = url; |
| 496 | 45 | | this.version = version; |
| 496 | 46 | | _clientDiagnostics = clientDiagnostics; |
| 496 | 47 | | _pipeline = pipeline; |
| 496 | 48 | | } |
| | 49 | |
|
| | 50 | | internal HttpMessage CreateQueryRequest(string requestId, string nextTableName, QueryOptions queryOptions) |
| | 51 | | { |
| 56 | 52 | | var message = _pipeline.CreateMessage(); |
| 56 | 53 | | var request = message.Request; |
| 56 | 54 | | request.Method = RequestMethod.Get; |
| 56 | 55 | | var uri = new RawRequestUriBuilder(); |
| 56 | 56 | | uri.AppendRaw(url, false); |
| 56 | 57 | | uri.AppendPath("/Tables", false); |
| 56 | 58 | | if (queryOptions?.Format != null) |
| | 59 | | { |
| 56 | 60 | | uri.AppendQuery("$format", queryOptions.Format.Value.ToString(), true); |
| | 61 | | } |
| 56 | 62 | | if (queryOptions?.Top != null) |
| | 63 | | { |
| 24 | 64 | | uri.AppendQuery("$top", queryOptions.Top.Value, true); |
| | 65 | | } |
| 56 | 66 | | if (queryOptions?.Select != null) |
| | 67 | | { |
| 0 | 68 | | uri.AppendQuery("$select", queryOptions.Select, true); |
| | 69 | | } |
| 56 | 70 | | if (queryOptions?.Filter != null) |
| | 71 | | { |
| 24 | 72 | | uri.AppendQuery("$filter", queryOptions.Filter, true); |
| | 73 | | } |
| 56 | 74 | | if (nextTableName != null) |
| | 75 | | { |
| 16 | 76 | | uri.AppendQuery("NextTableName", nextTableName, true); |
| | 77 | | } |
| 56 | 78 | | request.Uri = uri; |
| 56 | 79 | | request.Headers.Add("x-ms-version", version); |
| 56 | 80 | | if (requestId != null) |
| | 81 | | { |
| 0 | 82 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 83 | | } |
| 56 | 84 | | request.Headers.Add("DataServiceVersion", "3.0"); |
| 56 | 85 | | request.Headers.Add("Accept", "application/json"); |
| 56 | 86 | | return message; |
| | 87 | | } |
| | 88 | |
|
| | 89 | | /// <summary> Queries tables under the given account. </summary> |
| | 90 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 91 | | /// <param name="nextTableName"> A table query continuation token from a previous call. </param> |
| | 92 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 93 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 94 | | public async Task<ResponseWithHeaders<TableQueryResponse, TableQueryHeaders>> QueryAsync(string requestId = null |
| | 95 | | { |
| 28 | 96 | | using var message = CreateQueryRequest(requestId, nextTableName, queryOptions); |
| 28 | 97 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 28 | 98 | | var headers = new TableQueryHeaders(message.Response); |
| 28 | 99 | | switch (message.Response.Status) |
| | 100 | | { |
| | 101 | | case 200: |
| | 102 | | { |
| | 103 | | TableQueryResponse value = default; |
| 28 | 104 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 28 | 105 | | value = TableQueryResponse.DeserializeTableQueryResponse(document.RootElement); |
| 28 | 106 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 107 | | } |
| | 108 | | default: |
| 0 | 109 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 110 | | } |
| 28 | 111 | | } |
| | 112 | |
|
| | 113 | | /// <summary> Queries tables under the given account. </summary> |
| | 114 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 115 | | /// <param name="nextTableName"> A table query continuation token from a previous call. </param> |
| | 116 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 117 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 118 | | public ResponseWithHeaders<TableQueryResponse, TableQueryHeaders> Query(string requestId = null, string nextTabl |
| | 119 | | { |
| 28 | 120 | | using var message = CreateQueryRequest(requestId, nextTableName, queryOptions); |
| 28 | 121 | | _pipeline.Send(message, cancellationToken); |
| 28 | 122 | | var headers = new TableQueryHeaders(message.Response); |
| 28 | 123 | | switch (message.Response.Status) |
| | 124 | | { |
| | 125 | | case 200: |
| | 126 | | { |
| | 127 | | TableQueryResponse value = default; |
| 28 | 128 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 28 | 129 | | value = TableQueryResponse.DeserializeTableQueryResponse(document.RootElement); |
| 28 | 130 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 131 | | } |
| | 132 | | default: |
| 0 | 133 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 134 | | } |
| 28 | 135 | | } |
| | 136 | |
|
| | 137 | | internal HttpMessage CreateCreateRequest(TableProperties tableProperties, string requestId, ResponseFormat? resp |
| | 138 | | { |
| 656 | 139 | | var message = _pipeline.CreateMessage(); |
| 656 | 140 | | var request = message.Request; |
| 656 | 141 | | request.Method = RequestMethod.Post; |
| 656 | 142 | | var uri = new RawRequestUriBuilder(); |
| 656 | 143 | | uri.AppendRaw(url, false); |
| 656 | 144 | | uri.AppendPath("/Tables", false); |
| 656 | 145 | | if (queryOptions?.Format != null) |
| | 146 | | { |
| 656 | 147 | | uri.AppendQuery("$format", queryOptions.Format.Value.ToString(), true); |
| | 148 | | } |
| 656 | 149 | | request.Uri = uri; |
| 656 | 150 | | request.Headers.Add("x-ms-version", version); |
| 656 | 151 | | if (requestId != null) |
| | 152 | | { |
| 0 | 153 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 154 | | } |
| 656 | 155 | | request.Headers.Add("DataServiceVersion", "3.0"); |
| 656 | 156 | | if (responsePreference != null) |
| | 157 | | { |
| 0 | 158 | | request.Headers.Add("Prefer", responsePreference.Value.ToString()); |
| | 159 | | } |
| 656 | 160 | | request.Headers.Add("Accept", "application/json"); |
| 656 | 161 | | request.Headers.Add("Content-Type", "application/json;odata=nometadata"); |
| 656 | 162 | | var content = new Utf8JsonRequestContent(); |
| 656 | 163 | | content.JsonWriter.WriteObjectValue(tableProperties); |
| 656 | 164 | | request.Content = content; |
| 656 | 165 | | return message; |
| | 166 | | } |
| | 167 | |
|
| | 168 | | /// <summary> Creates a new table under the given account. </summary> |
| | 169 | | /// <param name="tableProperties"> The Table properties. </param> |
| | 170 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 171 | | /// <param name="responsePreference"> Specifies whether the response should include the inserted entity in the p |
| | 172 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 173 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 174 | | /// <exception cref="ArgumentNullException"> <paramref name="tableProperties"/> is null. </exception> |
| | 175 | | public async Task<ResponseWithHeaders<TableResponse, TableCreateHeaders>> CreateAsync(TableProperties tablePrope |
| | 176 | | { |
| 328 | 177 | | if (tableProperties == null) |
| | 178 | | { |
| 0 | 179 | | throw new ArgumentNullException(nameof(tableProperties)); |
| | 180 | | } |
| | 181 | |
|
| 328 | 182 | | using var message = CreateCreateRequest(tableProperties, requestId, responsePreference, queryOptions); |
| 328 | 183 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 328 | 184 | | var headers = new TableCreateHeaders(message.Response); |
| 328 | 185 | | switch (message.Response.Status) |
| | 186 | | { |
| | 187 | | case 201: |
| | 188 | | { |
| | 189 | | TableResponse value = default; |
| 320 | 190 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 320 | 191 | | value = TableResponse.DeserializeTableResponse(document.RootElement); |
| 320 | 192 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 193 | | } |
| | 194 | | case 204: |
| 0 | 195 | | return ResponseWithHeaders.FromValue<TableResponse, TableCreateHeaders>(null, headers, message.Respo |
| | 196 | | default: |
| 8 | 197 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 198 | | } |
| 320 | 199 | | } |
| | 200 | |
|
| | 201 | | /// <summary> Creates a new table under the given account. </summary> |
| | 202 | | /// <param name="tableProperties"> The Table properties. </param> |
| | 203 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 204 | | /// <param name="responsePreference"> Specifies whether the response should include the inserted entity in the p |
| | 205 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 206 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 207 | | /// <exception cref="ArgumentNullException"> <paramref name="tableProperties"/> is null. </exception> |
| | 208 | | public ResponseWithHeaders<TableResponse, TableCreateHeaders> Create(TableProperties tableProperties, string req |
| | 209 | | { |
| 328 | 210 | | if (tableProperties == null) |
| | 211 | | { |
| 0 | 212 | | throw new ArgumentNullException(nameof(tableProperties)); |
| | 213 | | } |
| | 214 | |
|
| 328 | 215 | | using var message = CreateCreateRequest(tableProperties, requestId, responsePreference, queryOptions); |
| 328 | 216 | | _pipeline.Send(message, cancellationToken); |
| 328 | 217 | | var headers = new TableCreateHeaders(message.Response); |
| 328 | 218 | | switch (message.Response.Status) |
| | 219 | | { |
| | 220 | | case 201: |
| | 221 | | { |
| | 222 | | TableResponse value = default; |
| 320 | 223 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 320 | 224 | | value = TableResponse.DeserializeTableResponse(document.RootElement); |
| 320 | 225 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 226 | | } |
| | 227 | | case 204: |
| 0 | 228 | | return ResponseWithHeaders.FromValue<TableResponse, TableCreateHeaders>(null, headers, message.Respo |
| | 229 | | default: |
| 8 | 230 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 231 | | } |
| 320 | 232 | | } |
| | 233 | |
|
| | 234 | | internal HttpMessage CreateDeleteRequest(string table, string requestId) |
| | 235 | | { |
| 640 | 236 | | var message = _pipeline.CreateMessage(); |
| 640 | 237 | | var request = message.Request; |
| 640 | 238 | | request.Method = RequestMethod.Delete; |
| 640 | 239 | | var uri = new RawRequestUriBuilder(); |
| 640 | 240 | | uri.AppendRaw(url, false); |
| 640 | 241 | | uri.AppendPath("/Tables('", false); |
| 640 | 242 | | uri.AppendPath(table, true); |
| 640 | 243 | | uri.AppendPath("')", false); |
| 640 | 244 | | request.Uri = uri; |
| 640 | 245 | | request.Headers.Add("x-ms-version", version); |
| 640 | 246 | | if (requestId != null) |
| | 247 | | { |
| 0 | 248 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 249 | | } |
| 640 | 250 | | request.Headers.Add("Accept", "application/json"); |
| 640 | 251 | | return message; |
| | 252 | | } |
| | 253 | |
|
| | 254 | | /// <summary> Operation permanently deletes the specified table. </summary> |
| | 255 | | /// <param name="table"> The name of the table. </param> |
| | 256 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 257 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 258 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/> is null. </exception> |
| | 259 | | public async Task<ResponseWithHeaders<TableDeleteHeaders>> DeleteAsync(string table, string requestId = null, Ca |
| | 260 | | { |
| 322 | 261 | | if (table == null) |
| | 262 | | { |
| 2 | 263 | | throw new ArgumentNullException(nameof(table)); |
| | 264 | | } |
| | 265 | |
|
| 320 | 266 | | using var message = CreateDeleteRequest(table, requestId); |
| 320 | 267 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 320 | 268 | | var headers = new TableDeleteHeaders(message.Response); |
| 320 | 269 | | switch (message.Response.Status) |
| | 270 | | { |
| | 271 | | case 204: |
| 320 | 272 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 273 | | default: |
| 0 | 274 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 275 | | } |
| 320 | 276 | | } |
| | 277 | |
|
| | 278 | | /// <summary> Operation permanently deletes the specified table. </summary> |
| | 279 | | /// <param name="table"> The name of the table. </param> |
| | 280 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 281 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 282 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/> is null. </exception> |
| | 283 | | public ResponseWithHeaders<TableDeleteHeaders> Delete(string table, string requestId = null, CancellationToken c |
| | 284 | | { |
| 322 | 285 | | if (table == null) |
| | 286 | | { |
| 2 | 287 | | throw new ArgumentNullException(nameof(table)); |
| | 288 | | } |
| | 289 | |
|
| 320 | 290 | | using var message = CreateDeleteRequest(table, requestId); |
| 320 | 291 | | _pipeline.Send(message, cancellationToken); |
| 320 | 292 | | var headers = new TableDeleteHeaders(message.Response); |
| 320 | 293 | | switch (message.Response.Status) |
| | 294 | | { |
| | 295 | | case 204: |
| 320 | 296 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 297 | | default: |
| 0 | 298 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 299 | | } |
| 320 | 300 | | } |
| | 301 | |
|
| | 302 | | internal HttpMessage CreateQueryEntitiesRequest(string table, int? timeout, string requestId, string nextPartiti |
| | 303 | | { |
| 732 | 304 | | var message = _pipeline.CreateMessage(); |
| 732 | 305 | | var request = message.Request; |
| 732 | 306 | | request.Method = RequestMethod.Get; |
| 732 | 307 | | var uri = new RawRequestUriBuilder(); |
| 732 | 308 | | uri.AppendRaw(url, false); |
| 732 | 309 | | uri.AppendPath("/", false); |
| 732 | 310 | | uri.AppendPath(table, true); |
| 732 | 311 | | uri.AppendPath("()", false); |
| 732 | 312 | | if (timeout != null) |
| | 313 | | { |
| 0 | 314 | | uri.AppendQuery("timeout", timeout.Value, true); |
| | 315 | | } |
| 732 | 316 | | if (queryOptions?.Format != null) |
| | 317 | | { |
| 732 | 318 | | uri.AppendQuery("$format", queryOptions.Format.Value.ToString(), true); |
| | 319 | | } |
| 732 | 320 | | if (queryOptions?.Top != null) |
| | 321 | | { |
| 96 | 322 | | uri.AppendQuery("$top", queryOptions.Top.Value, true); |
| | 323 | | } |
| 732 | 324 | | if (queryOptions?.Select != null) |
| | 325 | | { |
| 0 | 326 | | uri.AppendQuery("$select", queryOptions.Select, true); |
| | 327 | | } |
| 732 | 328 | | if (queryOptions?.Filter != null) |
| | 329 | | { |
| 636 | 330 | | uri.AppendQuery("$filter", queryOptions.Filter, true); |
| | 331 | | } |
| 732 | 332 | | if (nextPartitionKey != null) |
| | 333 | | { |
| 64 | 334 | | uri.AppendQuery("NextPartitionKey", nextPartitionKey, true); |
| | 335 | | } |
| 732 | 336 | | if (nextRowKey != null) |
| | 337 | | { |
| 64 | 338 | | uri.AppendQuery("NextRowKey", nextRowKey, true); |
| | 339 | | } |
| 732 | 340 | | request.Uri = uri; |
| 732 | 341 | | request.Headers.Add("x-ms-version", version); |
| 732 | 342 | | if (requestId != null) |
| | 343 | | { |
| 0 | 344 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 345 | | } |
| 732 | 346 | | request.Headers.Add("DataServiceVersion", "3.0"); |
| 732 | 347 | | request.Headers.Add("Accept", "application/json"); |
| 732 | 348 | | return message; |
| | 349 | | } |
| | 350 | |
|
| | 351 | | /// <summary> Queries entities in a table. </summary> |
| | 352 | | /// <param name="table"> The name of the table. </param> |
| | 353 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 354 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 355 | | /// <param name="nextPartitionKey"> An entity query continuation token from a previous call. </param> |
| | 356 | | /// <param name="nextRowKey"> An entity query continuation token from a previous call. </param> |
| | 357 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 358 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 359 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/> is null. </exception> |
| | 360 | | public async Task<ResponseWithHeaders<TableEntityQueryResponse, TableQueryEntitiesHeaders>> QueryEntitiesAsync(s |
| | 361 | | { |
| 366 | 362 | | if (table == null) |
| | 363 | | { |
| 0 | 364 | | throw new ArgumentNullException(nameof(table)); |
| | 365 | | } |
| | 366 | |
|
| 366 | 367 | | using var message = CreateQueryEntitiesRequest(table, timeout, requestId, nextPartitionKey, nextRowKey, quer |
| 366 | 368 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 366 | 369 | | var headers = new TableQueryEntitiesHeaders(message.Response); |
| 366 | 370 | | switch (message.Response.Status) |
| | 371 | | { |
| | 372 | | case 200: |
| | 373 | | { |
| | 374 | | TableEntityQueryResponse value = default; |
| 366 | 375 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 366 | 376 | | value = TableEntityQueryResponse.DeserializeTableEntityQueryResponse(document.RootElement); |
| 366 | 377 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 378 | | } |
| | 379 | | default: |
| 0 | 380 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 381 | | } |
| 366 | 382 | | } |
| | 383 | |
|
| | 384 | | /// <summary> Queries entities in a table. </summary> |
| | 385 | | /// <param name="table"> The name of the table. </param> |
| | 386 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 387 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 388 | | /// <param name="nextPartitionKey"> An entity query continuation token from a previous call. </param> |
| | 389 | | /// <param name="nextRowKey"> An entity query continuation token from a previous call. </param> |
| | 390 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 391 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 392 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/> is null. </exception> |
| | 393 | | public ResponseWithHeaders<TableEntityQueryResponse, TableQueryEntitiesHeaders> QueryEntities(string table, int? |
| | 394 | | { |
| 366 | 395 | | if (table == null) |
| | 396 | | { |
| 0 | 397 | | throw new ArgumentNullException(nameof(table)); |
| | 398 | | } |
| | 399 | |
|
| 366 | 400 | | using var message = CreateQueryEntitiesRequest(table, timeout, requestId, nextPartitionKey, nextRowKey, quer |
| 366 | 401 | | _pipeline.Send(message, cancellationToken); |
| 366 | 402 | | var headers = new TableQueryEntitiesHeaders(message.Response); |
| 366 | 403 | | switch (message.Response.Status) |
| | 404 | | { |
| | 405 | | case 200: |
| | 406 | | { |
| | 407 | | TableEntityQueryResponse value = default; |
| 366 | 408 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 366 | 409 | | value = TableEntityQueryResponse.DeserializeTableEntityQueryResponse(document.RootElement); |
| 366 | 410 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 411 | | } |
| | 412 | | default: |
| 0 | 413 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 414 | | } |
| 366 | 415 | | } |
| | 416 | |
|
| | 417 | | internal HttpMessage CreateQueryEntitiesWithPartitionAndRowKeyRequest(string table, string partitionKey, string |
| | 418 | | { |
| 8 | 419 | | var message = _pipeline.CreateMessage(); |
| 8 | 420 | | var request = message.Request; |
| 8 | 421 | | request.Method = RequestMethod.Get; |
| 8 | 422 | | var uri = new RawRequestUriBuilder(); |
| 8 | 423 | | uri.AppendRaw(url, false); |
| 8 | 424 | | uri.AppendPath("/", false); |
| 8 | 425 | | uri.AppendPath(table, true); |
| 8 | 426 | | uri.AppendPath("(PartitionKey='", false); |
| 8 | 427 | | uri.AppendPath(partitionKey, true); |
| 8 | 428 | | uri.AppendPath("',RowKey='", false); |
| 8 | 429 | | uri.AppendPath(rowKey, true); |
| 8 | 430 | | uri.AppendPath("')", false); |
| 8 | 431 | | if (timeout != null) |
| | 432 | | { |
| 0 | 433 | | uri.AppendQuery("timeout", timeout.Value, true); |
| | 434 | | } |
| 8 | 435 | | if (queryOptions?.Format != null) |
| | 436 | | { |
| 8 | 437 | | uri.AppendQuery("$format", queryOptions.Format.Value.ToString(), true); |
| | 438 | | } |
| 8 | 439 | | if (queryOptions?.Select != null) |
| | 440 | | { |
| 0 | 441 | | uri.AppendQuery("$select", queryOptions.Select, true); |
| | 442 | | } |
| 8 | 443 | | if (queryOptions?.Filter != null) |
| | 444 | | { |
| 0 | 445 | | uri.AppendQuery("$filter", queryOptions.Filter, true); |
| | 446 | | } |
| 8 | 447 | | request.Uri = uri; |
| 8 | 448 | | request.Headers.Add("x-ms-version", version); |
| 8 | 449 | | if (requestId != null) |
| | 450 | | { |
| 0 | 451 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 452 | | } |
| 8 | 453 | | request.Headers.Add("DataServiceVersion", "3.0"); |
| 8 | 454 | | request.Headers.Add("Accept", "application/json"); |
| 8 | 455 | | return message; |
| | 456 | | } |
| | 457 | |
|
| | 458 | | /// <summary> Queries entities in a table. </summary> |
| | 459 | | /// <param name="table"> The name of the table. </param> |
| | 460 | | /// <param name="partitionKey"> The partition key of the entity. </param> |
| | 461 | | /// <param name="rowKey"> The row key of the entity. </param> |
| | 462 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 463 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 464 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 465 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 466 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/>, <paramref name="partitionKey"/>, or <para |
| | 467 | | public async Task<ResponseWithHeaders<IReadOnlyDictionary<string, object>, TableQueryEntitiesWithPartitionAndRow |
| | 468 | | { |
| 4 | 469 | | if (table == null) |
| | 470 | | { |
| 0 | 471 | | throw new ArgumentNullException(nameof(table)); |
| | 472 | | } |
| 4 | 473 | | if (partitionKey == null) |
| | 474 | | { |
| 0 | 475 | | throw new ArgumentNullException(nameof(partitionKey)); |
| | 476 | | } |
| 4 | 477 | | if (rowKey == null) |
| | 478 | | { |
| 0 | 479 | | throw new ArgumentNullException(nameof(rowKey)); |
| | 480 | | } |
| | 481 | |
|
| 4 | 482 | | using var message = CreateQueryEntitiesWithPartitionAndRowKeyRequest(table, partitionKey, rowKey, timeout, r |
| 4 | 483 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 484 | | var headers = new TableQueryEntitiesWithPartitionAndRowKeyHeaders(message.Response); |
| 4 | 485 | | switch (message.Response.Status) |
| | 486 | | { |
| | 487 | | case 200: |
| | 488 | | { |
| | 489 | | IReadOnlyDictionary<string, object> value = default; |
| 4 | 490 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 491 | | Dictionary<string, object> dictionary = new Dictionary<string, object>(); |
| 164 | 492 | | foreach (var property in document.RootElement.EnumerateObject()) |
| | 493 | | { |
| 78 | 494 | | dictionary.Add(property.Name, property.Value.GetObject()); |
| | 495 | | } |
| 4 | 496 | | value = dictionary; |
| 4 | 497 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 498 | | } |
| | 499 | | default: |
| 0 | 500 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 501 | | } |
| 4 | 502 | | } |
| | 503 | |
|
| | 504 | | /// <summary> Queries entities in a table. </summary> |
| | 505 | | /// <param name="table"> The name of the table. </param> |
| | 506 | | /// <param name="partitionKey"> The partition key of the entity. </param> |
| | 507 | | /// <param name="rowKey"> The row key of the entity. </param> |
| | 508 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 509 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 510 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 511 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 512 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/>, <paramref name="partitionKey"/>, or <para |
| | 513 | | public ResponseWithHeaders<IReadOnlyDictionary<string, object>, TableQueryEntitiesWithPartitionAndRowKeyHeaders> |
| | 514 | | { |
| 4 | 515 | | if (table == null) |
| | 516 | | { |
| 0 | 517 | | throw new ArgumentNullException(nameof(table)); |
| | 518 | | } |
| 4 | 519 | | if (partitionKey == null) |
| | 520 | | { |
| 0 | 521 | | throw new ArgumentNullException(nameof(partitionKey)); |
| | 522 | | } |
| 4 | 523 | | if (rowKey == null) |
| | 524 | | { |
| 0 | 525 | | throw new ArgumentNullException(nameof(rowKey)); |
| | 526 | | } |
| | 527 | |
|
| 4 | 528 | | using var message = CreateQueryEntitiesWithPartitionAndRowKeyRequest(table, partitionKey, rowKey, timeout, r |
| 4 | 529 | | _pipeline.Send(message, cancellationToken); |
| 4 | 530 | | var headers = new TableQueryEntitiesWithPartitionAndRowKeyHeaders(message.Response); |
| 4 | 531 | | switch (message.Response.Status) |
| | 532 | | { |
| | 533 | | case 200: |
| | 534 | | { |
| | 535 | | IReadOnlyDictionary<string, object> value = default; |
| 4 | 536 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 537 | | Dictionary<string, object> dictionary = new Dictionary<string, object>(); |
| 164 | 538 | | foreach (var property in document.RootElement.EnumerateObject()) |
| | 539 | | { |
| 78 | 540 | | dictionary.Add(property.Name, property.Value.GetObject()); |
| | 541 | | } |
| 4 | 542 | | value = dictionary; |
| 4 | 543 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 544 | | } |
| | 545 | | default: |
| 0 | 546 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 547 | | } |
| 4 | 548 | | } |
| | 549 | |
|
| | 550 | | internal HttpMessage CreateUpdateEntityRequest(string table, string partitionKey, string rowKey, int? timeout, s |
| | 551 | | { |
| 172 | 552 | | var message = _pipeline.CreateMessage(); |
| 172 | 553 | | var request = message.Request; |
| 172 | 554 | | request.Method = RequestMethod.Put; |
| 172 | 555 | | var uri = new RawRequestUriBuilder(); |
| 172 | 556 | | uri.AppendRaw(url, false); |
| 172 | 557 | | uri.AppendPath("/", false); |
| 172 | 558 | | uri.AppendPath(table, true); |
| 172 | 559 | | uri.AppendPath("(PartitionKey='", false); |
| 172 | 560 | | uri.AppendPath(partitionKey, true); |
| 172 | 561 | | uri.AppendPath("',RowKey='", false); |
| 172 | 562 | | uri.AppendPath(rowKey, true); |
| 172 | 563 | | uri.AppendPath("')", false); |
| 172 | 564 | | if (timeout != null) |
| | 565 | | { |
| 0 | 566 | | uri.AppendQuery("timeout", timeout.Value, true); |
| | 567 | | } |
| 172 | 568 | | if (queryOptions?.Format != null) |
| | 569 | | { |
| 172 | 570 | | uri.AppendQuery("$format", queryOptions.Format.Value.ToString(), true); |
| | 571 | | } |
| 172 | 572 | | request.Uri = uri; |
| 172 | 573 | | request.Headers.Add("x-ms-version", version); |
| 172 | 574 | | if (requestId != null) |
| | 575 | | { |
| 0 | 576 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 577 | | } |
| 172 | 578 | | request.Headers.Add("DataServiceVersion", "3.0"); |
| 172 | 579 | | if (ifMatch != null) |
| | 580 | | { |
| 48 | 581 | | request.Headers.Add("If-Match", ifMatch); |
| | 582 | | } |
| 172 | 583 | | request.Headers.Add("Accept", "application/json"); |
| 172 | 584 | | request.Headers.Add("Content-Type", "application/json"); |
| 172 | 585 | | if (tableEntityProperties != null) |
| | 586 | | { |
| 172 | 587 | | var content = new Utf8JsonRequestContent(); |
| 172 | 588 | | content.JsonWriter.WriteStartObject(); |
| 2992 | 589 | | foreach (var item in tableEntityProperties) |
| | 590 | | { |
| 1324 | 591 | | content.JsonWriter.WritePropertyName(item.Key); |
| 1324 | 592 | | content.JsonWriter.WriteObjectValue(item.Value); |
| | 593 | | } |
| 172 | 594 | | content.JsonWriter.WriteEndObject(); |
| 172 | 595 | | request.Content = content; |
| | 596 | | } |
| 172 | 597 | | return message; |
| | 598 | | } |
| | 599 | |
|
| | 600 | | /// <summary> Update entity in a table. </summary> |
| | 601 | | /// <param name="table"> The name of the table. </param> |
| | 602 | | /// <param name="partitionKey"> The partition key of the entity. </param> |
| | 603 | | /// <param name="rowKey"> The row key of the entity. </param> |
| | 604 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 605 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 606 | | /// <param name="ifMatch"> Match condition for an entity to be updated. If specified and a matching entity is no |
| | 607 | | /// <param name="tableEntityProperties"> The properties for the table entity. </param> |
| | 608 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 609 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 610 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/>, <paramref name="partitionKey"/>, or <para |
| | 611 | | public async Task<ResponseWithHeaders<TableUpdateEntityHeaders>> UpdateEntityAsync(string table, string partitio |
| | 612 | | { |
| 86 | 613 | | if (table == null) |
| | 614 | | { |
| 0 | 615 | | throw new ArgumentNullException(nameof(table)); |
| | 616 | | } |
| 86 | 617 | | if (partitionKey == null) |
| | 618 | | { |
| 0 | 619 | | throw new ArgumentNullException(nameof(partitionKey)); |
| | 620 | | } |
| 86 | 621 | | if (rowKey == null) |
| | 622 | | { |
| 0 | 623 | | throw new ArgumentNullException(nameof(rowKey)); |
| | 624 | | } |
| | 625 | |
|
| 86 | 626 | | using var message = CreateUpdateEntityRequest(table, partitionKey, rowKey, timeout, requestId, ifMatch, tabl |
| 86 | 627 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 86 | 628 | | var headers = new TableUpdateEntityHeaders(message.Response); |
| 86 | 629 | | switch (message.Response.Status) |
| | 630 | | { |
| | 631 | | case 204: |
| 74 | 632 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 633 | | default: |
| 12 | 634 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 635 | | } |
| 74 | 636 | | } |
| | 637 | |
|
| | 638 | | /// <summary> Update entity in a table. </summary> |
| | 639 | | /// <param name="table"> The name of the table. </param> |
| | 640 | | /// <param name="partitionKey"> The partition key of the entity. </param> |
| | 641 | | /// <param name="rowKey"> The row key of the entity. </param> |
| | 642 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 643 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 644 | | /// <param name="ifMatch"> Match condition for an entity to be updated. If specified and a matching entity is no |
| | 645 | | /// <param name="tableEntityProperties"> The properties for the table entity. </param> |
| | 646 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 647 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 648 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/>, <paramref name="partitionKey"/>, or <para |
| | 649 | | public ResponseWithHeaders<TableUpdateEntityHeaders> UpdateEntity(string table, string partitionKey, string rowK |
| | 650 | | { |
| 86 | 651 | | if (table == null) |
| | 652 | | { |
| 0 | 653 | | throw new ArgumentNullException(nameof(table)); |
| | 654 | | } |
| 86 | 655 | | if (partitionKey == null) |
| | 656 | | { |
| 0 | 657 | | throw new ArgumentNullException(nameof(partitionKey)); |
| | 658 | | } |
| 86 | 659 | | if (rowKey == null) |
| | 660 | | { |
| 0 | 661 | | throw new ArgumentNullException(nameof(rowKey)); |
| | 662 | | } |
| | 663 | |
|
| 86 | 664 | | using var message = CreateUpdateEntityRequest(table, partitionKey, rowKey, timeout, requestId, ifMatch, tabl |
| 86 | 665 | | _pipeline.Send(message, cancellationToken); |
| 86 | 666 | | var headers = new TableUpdateEntityHeaders(message.Response); |
| 86 | 667 | | switch (message.Response.Status) |
| | 668 | | { |
| | 669 | | case 204: |
| 74 | 670 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 671 | | default: |
| 12 | 672 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 673 | | } |
| 74 | 674 | | } |
| | 675 | |
|
| | 676 | | internal HttpMessage CreateMergeEntityRequest(string table, string partitionKey, string rowKey, int? timeout, st |
| | 677 | | { |
| 32 | 678 | | var message = _pipeline.CreateMessage(); |
| 32 | 679 | | var request = message.Request; |
| 32 | 680 | | request.Method = RequestMethod.Patch; |
| 32 | 681 | | var uri = new RawRequestUriBuilder(); |
| 32 | 682 | | uri.AppendRaw(url, false); |
| 32 | 683 | | uri.AppendPath("/", false); |
| 32 | 684 | | uri.AppendPath(table, true); |
| 32 | 685 | | uri.AppendPath("(PartitionKey='", false); |
| 32 | 686 | | uri.AppendPath(partitionKey, true); |
| 32 | 687 | | uri.AppendPath("',RowKey='", false); |
| 32 | 688 | | uri.AppendPath(rowKey, true); |
| 32 | 689 | | uri.AppendPath("')", false); |
| 32 | 690 | | if (timeout != null) |
| | 691 | | { |
| 0 | 692 | | uri.AppendQuery("timeout", timeout.Value, true); |
| | 693 | | } |
| 32 | 694 | | if (queryOptions?.Format != null) |
| | 695 | | { |
| 32 | 696 | | uri.AppendQuery("$format", queryOptions.Format.Value.ToString(), true); |
| | 697 | | } |
| 32 | 698 | | request.Uri = uri; |
| 32 | 699 | | request.Headers.Add("x-ms-version", version); |
| 32 | 700 | | if (requestId != null) |
| | 701 | | { |
| 0 | 702 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 703 | | } |
| 32 | 704 | | request.Headers.Add("DataServiceVersion", "3.0"); |
| 32 | 705 | | if (ifMatch != null) |
| | 706 | | { |
| 24 | 707 | | request.Headers.Add("If-Match", ifMatch); |
| | 708 | | } |
| 32 | 709 | | request.Headers.Add("Content-Type", "application/json"); |
| 32 | 710 | | if (tableEntityProperties != null) |
| | 711 | | { |
| 32 | 712 | | var content = new Utf8JsonRequestContent(); |
| 32 | 713 | | content.JsonWriter.WriteStartObject(); |
| 568 | 714 | | foreach (var item in tableEntityProperties) |
| | 715 | | { |
| 252 | 716 | | content.JsonWriter.WritePropertyName(item.Key); |
| 252 | 717 | | content.JsonWriter.WriteObjectValue(item.Value); |
| | 718 | | } |
| 32 | 719 | | content.JsonWriter.WriteEndObject(); |
| 32 | 720 | | request.Content = content; |
| | 721 | | } |
| 32 | 722 | | return message; |
| | 723 | | } |
| | 724 | |
|
| | 725 | | /// <summary> Merge entity in a table. </summary> |
| | 726 | | /// <param name="table"> The name of the table. </param> |
| | 727 | | /// <param name="partitionKey"> The partition key of the entity. </param> |
| | 728 | | /// <param name="rowKey"> The row key of the entity. </param> |
| | 729 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 730 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 731 | | /// <param name="ifMatch"> Match condition for an entity to be updated. If specified and a matching entity is no |
| | 732 | | /// <param name="tableEntityProperties"> The properties for the table entity. </param> |
| | 733 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 734 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 735 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/>, <paramref name="partitionKey"/>, or <para |
| | 736 | | public async Task<ResponseWithHeaders<TableMergeEntityHeaders>> MergeEntityAsync(string table, string partitionK |
| | 737 | | { |
| 16 | 738 | | if (table == null) |
| | 739 | | { |
| 0 | 740 | | throw new ArgumentNullException(nameof(table)); |
| | 741 | | } |
| 16 | 742 | | if (partitionKey == null) |
| | 743 | | { |
| 0 | 744 | | throw new ArgumentNullException(nameof(partitionKey)); |
| | 745 | | } |
| 16 | 746 | | if (rowKey == null) |
| | 747 | | { |
| 0 | 748 | | throw new ArgumentNullException(nameof(rowKey)); |
| | 749 | | } |
| | 750 | |
|
| 16 | 751 | | using var message = CreateMergeEntityRequest(table, partitionKey, rowKey, timeout, requestId, ifMatch, table |
| 16 | 752 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 16 | 753 | | var headers = new TableMergeEntityHeaders(message.Response); |
| 16 | 754 | | switch (message.Response.Status) |
| | 755 | | { |
| | 756 | | case 204: |
| 12 | 757 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 758 | | default: |
| 4 | 759 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 760 | | } |
| 12 | 761 | | } |
| | 762 | |
|
| | 763 | | /// <summary> Merge entity in a table. </summary> |
| | 764 | | /// <param name="table"> The name of the table. </param> |
| | 765 | | /// <param name="partitionKey"> The partition key of the entity. </param> |
| | 766 | | /// <param name="rowKey"> The row key of the entity. </param> |
| | 767 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 768 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 769 | | /// <param name="ifMatch"> Match condition for an entity to be updated. If specified and a matching entity is no |
| | 770 | | /// <param name="tableEntityProperties"> The properties for the table entity. </param> |
| | 771 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 772 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 773 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/>, <paramref name="partitionKey"/>, or <para |
| | 774 | | public ResponseWithHeaders<TableMergeEntityHeaders> MergeEntity(string table, string partitionKey, string rowKey |
| | 775 | | { |
| 16 | 776 | | if (table == null) |
| | 777 | | { |
| 0 | 778 | | throw new ArgumentNullException(nameof(table)); |
| | 779 | | } |
| 16 | 780 | | if (partitionKey == null) |
| | 781 | | { |
| 0 | 782 | | throw new ArgumentNullException(nameof(partitionKey)); |
| | 783 | | } |
| 16 | 784 | | if (rowKey == null) |
| | 785 | | { |
| 0 | 786 | | throw new ArgumentNullException(nameof(rowKey)); |
| | 787 | | } |
| | 788 | |
|
| 16 | 789 | | using var message = CreateMergeEntityRequest(table, partitionKey, rowKey, timeout, requestId, ifMatch, table |
| 16 | 790 | | _pipeline.Send(message, cancellationToken); |
| 16 | 791 | | var headers = new TableMergeEntityHeaders(message.Response); |
| 16 | 792 | | switch (message.Response.Status) |
| | 793 | | { |
| | 794 | | case 204: |
| 12 | 795 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 796 | | default: |
| 4 | 797 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 798 | | } |
| 12 | 799 | | } |
| | 800 | |
|
| | 801 | | internal HttpMessage CreateDeleteEntityRequest(string table, string partitionKey, string rowKey, string ifMatch, |
| | 802 | | { |
| 48 | 803 | | var message = _pipeline.CreateMessage(); |
| 48 | 804 | | var request = message.Request; |
| 48 | 805 | | request.Method = RequestMethod.Delete; |
| 48 | 806 | | var uri = new RawRequestUriBuilder(); |
| 48 | 807 | | uri.AppendRaw(url, false); |
| 48 | 808 | | uri.AppendPath("/", false); |
| 48 | 809 | | uri.AppendPath(table, true); |
| 48 | 810 | | uri.AppendPath("(PartitionKey='", false); |
| 48 | 811 | | uri.AppendPath(partitionKey, true); |
| 48 | 812 | | uri.AppendPath("',RowKey='", false); |
| 48 | 813 | | uri.AppendPath(rowKey, true); |
| 48 | 814 | | uri.AppendPath("')", false); |
| 48 | 815 | | if (timeout != null) |
| | 816 | | { |
| 0 | 817 | | uri.AppendQuery("timeout", timeout.Value, true); |
| | 818 | | } |
| 48 | 819 | | if (queryOptions?.Format != null) |
| | 820 | | { |
| 48 | 821 | | uri.AppendQuery("$format", queryOptions.Format.Value.ToString(), true); |
| | 822 | | } |
| 48 | 823 | | request.Uri = uri; |
| 48 | 824 | | request.Headers.Add("x-ms-version", version); |
| 48 | 825 | | if (requestId != null) |
| | 826 | | { |
| 0 | 827 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 828 | | } |
| 48 | 829 | | request.Headers.Add("DataServiceVersion", "3.0"); |
| 48 | 830 | | request.Headers.Add("If-Match", ifMatch); |
| 48 | 831 | | return message; |
| | 832 | | } |
| | 833 | |
|
| | 834 | | /// <summary> Deletes the specified entity in a table. </summary> |
| | 835 | | /// <param name="table"> The name of the table. </param> |
| | 836 | | /// <param name="partitionKey"> The partition key of the entity. </param> |
| | 837 | | /// <param name="rowKey"> The row key of the entity. </param> |
| | 838 | | /// <param name="ifMatch"> Match condition for an entity to be deleted. If specified and a matching entity is no |
| | 839 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 840 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 841 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 842 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 843 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/>, <paramref name="partitionKey"/>, <paramre |
| | 844 | | public async Task<ResponseWithHeaders<TableDeleteEntityHeaders>> DeleteEntityAsync(string table, string partitio |
| | 845 | | { |
| 24 | 846 | | if (table == null) |
| | 847 | | { |
| 0 | 848 | | throw new ArgumentNullException(nameof(table)); |
| | 849 | | } |
| 24 | 850 | | if (partitionKey == null) |
| | 851 | | { |
| 0 | 852 | | throw new ArgumentNullException(nameof(partitionKey)); |
| | 853 | | } |
| 24 | 854 | | if (rowKey == null) |
| | 855 | | { |
| 0 | 856 | | throw new ArgumentNullException(nameof(rowKey)); |
| | 857 | | } |
| 24 | 858 | | if (ifMatch == null) |
| | 859 | | { |
| 0 | 860 | | throw new ArgumentNullException(nameof(ifMatch)); |
| | 861 | | } |
| | 862 | |
|
| 24 | 863 | | using var message = CreateDeleteEntityRequest(table, partitionKey, rowKey, ifMatch, timeout, requestId, quer |
| 24 | 864 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 24 | 865 | | var headers = new TableDeleteEntityHeaders(message.Response); |
| 24 | 866 | | switch (message.Response.Status) |
| | 867 | | { |
| | 868 | | case 204: |
| 16 | 869 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 870 | | default: |
| 8 | 871 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 872 | | } |
| 16 | 873 | | } |
| | 874 | |
|
| | 875 | | /// <summary> Deletes the specified entity in a table. </summary> |
| | 876 | | /// <param name="table"> The name of the table. </param> |
| | 877 | | /// <param name="partitionKey"> The partition key of the entity. </param> |
| | 878 | | /// <param name="rowKey"> The row key of the entity. </param> |
| | 879 | | /// <param name="ifMatch"> Match condition for an entity to be deleted. If specified and a matching entity is no |
| | 880 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 881 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 882 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 883 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 884 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/>, <paramref name="partitionKey"/>, <paramre |
| | 885 | | public ResponseWithHeaders<TableDeleteEntityHeaders> DeleteEntity(string table, string partitionKey, string rowK |
| | 886 | | { |
| 24 | 887 | | if (table == null) |
| | 888 | | { |
| 0 | 889 | | throw new ArgumentNullException(nameof(table)); |
| | 890 | | } |
| 24 | 891 | | if (partitionKey == null) |
| | 892 | | { |
| 0 | 893 | | throw new ArgumentNullException(nameof(partitionKey)); |
| | 894 | | } |
| 24 | 895 | | if (rowKey == null) |
| | 896 | | { |
| 0 | 897 | | throw new ArgumentNullException(nameof(rowKey)); |
| | 898 | | } |
| 24 | 899 | | if (ifMatch == null) |
| | 900 | | { |
| 0 | 901 | | throw new ArgumentNullException(nameof(ifMatch)); |
| | 902 | | } |
| | 903 | |
|
| 24 | 904 | | using var message = CreateDeleteEntityRequest(table, partitionKey, rowKey, ifMatch, timeout, requestId, quer |
| 24 | 905 | | _pipeline.Send(message, cancellationToken); |
| 24 | 906 | | var headers = new TableDeleteEntityHeaders(message.Response); |
| 24 | 907 | | switch (message.Response.Status) |
| | 908 | | { |
| | 909 | | case 204: |
| 16 | 910 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 911 | | default: |
| 8 | 912 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 913 | | } |
| 16 | 914 | | } |
| | 915 | |
|
| | 916 | | internal HttpMessage CreateInsertEntityRequest(string table, int? timeout, string requestId, ResponseFormat? res |
| | 917 | | { |
| 1704 | 918 | | var message = _pipeline.CreateMessage(); |
| 1704 | 919 | | var request = message.Request; |
| 1704 | 920 | | request.Method = RequestMethod.Post; |
| 1704 | 921 | | var uri = new RawRequestUriBuilder(); |
| 1704 | 922 | | uri.AppendRaw(url, false); |
| 1704 | 923 | | uri.AppendPath("/", false); |
| 1704 | 924 | | uri.AppendPath(table, true); |
| 1704 | 925 | | if (timeout != null) |
| | 926 | | { |
| 0 | 927 | | uri.AppendQuery("timeout", timeout.Value, true); |
| | 928 | | } |
| 1704 | 929 | | if (queryOptions?.Format != null) |
| | 930 | | { |
| 1704 | 931 | | uri.AppendQuery("$format", queryOptions.Format.Value.ToString(), true); |
| | 932 | | } |
| 1704 | 933 | | request.Uri = uri; |
| 1704 | 934 | | request.Headers.Add("x-ms-version", version); |
| 1704 | 935 | | if (requestId != null) |
| | 936 | | { |
| 0 | 937 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 938 | | } |
| 1704 | 939 | | request.Headers.Add("DataServiceVersion", "3.0"); |
| 1704 | 940 | | if (responsePreference != null) |
| | 941 | | { |
| 0 | 942 | | request.Headers.Add("Prefer", responsePreference.Value.ToString()); |
| | 943 | | } |
| 1704 | 944 | | request.Headers.Add("Accept", "application/json"); |
| 1704 | 945 | | request.Headers.Add("Content-Type", "application/json;odata=nometadata"); |
| 1704 | 946 | | if (tableEntityProperties != null) |
| | 947 | | { |
| 1704 | 948 | | var content = new Utf8JsonRequestContent(); |
| 1704 | 949 | | content.JsonWriter.WriteStartObject(); |
| 86256 | 950 | | foreach (var item in tableEntityProperties) |
| | 951 | | { |
| 41424 | 952 | | content.JsonWriter.WritePropertyName(item.Key); |
| 41424 | 953 | | content.JsonWriter.WriteObjectValue(item.Value); |
| | 954 | | } |
| 1704 | 955 | | content.JsonWriter.WriteEndObject(); |
| 1704 | 956 | | request.Content = content; |
| | 957 | | } |
| 1704 | 958 | | return message; |
| | 959 | | } |
| | 960 | |
|
| | 961 | | /// <summary> Insert entity in a table. </summary> |
| | 962 | | /// <param name="table"> The name of the table. </param> |
| | 963 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 964 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 965 | | /// <param name="responsePreference"> Specifies whether the response should include the inserted entity in the p |
| | 966 | | /// <param name="tableEntityProperties"> The properties for the table entity. </param> |
| | 967 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 968 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 969 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/> is null. </exception> |
| | 970 | | public async Task<ResponseWithHeaders<IReadOnlyDictionary<string, object>, TableInsertEntityHeaders>> InsertEnti |
| | 971 | | { |
| 852 | 972 | | if (table == null) |
| | 973 | | { |
| 0 | 974 | | throw new ArgumentNullException(nameof(table)); |
| | 975 | | } |
| | 976 | |
|
| 852 | 977 | | using var message = CreateInsertEntityRequest(table, timeout, requestId, responsePreference, tableEntityProp |
| 852 | 978 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 852 | 979 | | var headers = new TableInsertEntityHeaders(message.Response); |
| 852 | 980 | | switch (message.Response.Status) |
| | 981 | | { |
| | 982 | | case 201: |
| | 983 | | { |
| | 984 | | IReadOnlyDictionary<string, object> value = default; |
| 852 | 985 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 852 | 986 | | Dictionary<string, object> dictionary = new Dictionary<string, object>(); |
| 43452 | 987 | | foreach (var property in document.RootElement.EnumerateObject()) |
| | 988 | | { |
| 20874 | 989 | | dictionary.Add(property.Name, property.Value.GetObject()); |
| | 990 | | } |
| 852 | 991 | | value = dictionary; |
| 852 | 992 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 993 | | } |
| | 994 | | case 204: |
| 0 | 995 | | return ResponseWithHeaders.FromValue<IReadOnlyDictionary<string, object>, TableInsertEntityHeaders>( |
| | 996 | | default: |
| 0 | 997 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 998 | | } |
| 852 | 999 | | } |
| | 1000 | |
|
| | 1001 | | /// <summary> Insert entity in a table. </summary> |
| | 1002 | | /// <param name="table"> The name of the table. </param> |
| | 1003 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 1004 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 1005 | | /// <param name="responsePreference"> Specifies whether the response should include the inserted entity in the p |
| | 1006 | | /// <param name="tableEntityProperties"> The properties for the table entity. </param> |
| | 1007 | | /// <param name="queryOptions"> Parameter group. </param> |
| | 1008 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1009 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/> is null. </exception> |
| | 1010 | | public ResponseWithHeaders<IReadOnlyDictionary<string, object>, TableInsertEntityHeaders> InsertEntity(string ta |
| | 1011 | | { |
| 852 | 1012 | | if (table == null) |
| | 1013 | | { |
| 0 | 1014 | | throw new ArgumentNullException(nameof(table)); |
| | 1015 | | } |
| | 1016 | |
|
| 852 | 1017 | | using var message = CreateInsertEntityRequest(table, timeout, requestId, responsePreference, tableEntityProp |
| 852 | 1018 | | _pipeline.Send(message, cancellationToken); |
| 852 | 1019 | | var headers = new TableInsertEntityHeaders(message.Response); |
| 852 | 1020 | | switch (message.Response.Status) |
| | 1021 | | { |
| | 1022 | | case 201: |
| | 1023 | | { |
| | 1024 | | IReadOnlyDictionary<string, object> value = default; |
| 852 | 1025 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 852 | 1026 | | Dictionary<string, object> dictionary = new Dictionary<string, object>(); |
| 43452 | 1027 | | foreach (var property in document.RootElement.EnumerateObject()) |
| | 1028 | | { |
| 20874 | 1029 | | dictionary.Add(property.Name, property.Value.GetObject()); |
| | 1030 | | } |
| 852 | 1031 | | value = dictionary; |
| 852 | 1032 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 1033 | | } |
| | 1034 | | case 204: |
| 0 | 1035 | | return ResponseWithHeaders.FromValue<IReadOnlyDictionary<string, object>, TableInsertEntityHeaders>( |
| | 1036 | | default: |
| 0 | 1037 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1038 | | } |
| 852 | 1039 | | } |
| | 1040 | |
|
| | 1041 | | internal HttpMessage CreateGetAccessPolicyRequest(string table, int? timeout, string requestId) |
| | 1042 | | { |
| 4 | 1043 | | var message = _pipeline.CreateMessage(); |
| 4 | 1044 | | var request = message.Request; |
| 4 | 1045 | | request.Method = RequestMethod.Get; |
| 4 | 1046 | | var uri = new RawRequestUriBuilder(); |
| 4 | 1047 | | uri.AppendRaw(url, false); |
| 4 | 1048 | | uri.AppendPath("/", false); |
| 4 | 1049 | | uri.AppendPath(table, true); |
| 4 | 1050 | | if (timeout != null) |
| | 1051 | | { |
| 0 | 1052 | | uri.AppendQuery("timeout", timeout.Value, true); |
| | 1053 | | } |
| 4 | 1054 | | uri.AppendQuery("comp", "acl", true); |
| 4 | 1055 | | request.Uri = uri; |
| 4 | 1056 | | request.Headers.Add("x-ms-version", version); |
| 4 | 1057 | | if (requestId != null) |
| | 1058 | | { |
| 0 | 1059 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 1060 | | } |
| 4 | 1061 | | return message; |
| | 1062 | | } |
| | 1063 | |
|
| | 1064 | | /// <summary> Retrieves details about any stored access policies specified on the table that may be used with Sh |
| | 1065 | | /// <param name="table"> The name of the table. </param> |
| | 1066 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 1067 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 1068 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1069 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/> is null. </exception> |
| | 1070 | | public async Task<ResponseWithHeaders<IReadOnlyList<SignedIdentifier>, TableGetAccessPolicyHeaders>> GetAccessPo |
| | 1071 | | { |
| 2 | 1072 | | if (table == null) |
| | 1073 | | { |
| 0 | 1074 | | throw new ArgumentNullException(nameof(table)); |
| | 1075 | | } |
| | 1076 | |
|
| 2 | 1077 | | using var message = CreateGetAccessPolicyRequest(table, timeout, requestId); |
| 2 | 1078 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1079 | | var headers = new TableGetAccessPolicyHeaders(message.Response); |
| 2 | 1080 | | switch (message.Response.Status) |
| | 1081 | | { |
| | 1082 | | case 200: |
| | 1083 | | { |
| 2 | 1084 | | IReadOnlyList<SignedIdentifier> value = default; |
| 2 | 1085 | | var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace); |
| 2 | 1086 | | if (document.Element("SignedIdentifiers") is XElement signedIdentifiersElement) |
| | 1087 | | { |
| 2 | 1088 | | var array = new List<SignedIdentifier>(); |
| 8 | 1089 | | foreach (var e in signedIdentifiersElement.Elements("SignedIdentifier")) |
| | 1090 | | { |
| 2 | 1091 | | array.Add(SignedIdentifier.DeserializeSignedIdentifier(e)); |
| | 1092 | | } |
| 2 | 1093 | | value = array; |
| | 1094 | | } |
| 2 | 1095 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 1096 | | } |
| | 1097 | | default: |
| 0 | 1098 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1099 | | } |
| 2 | 1100 | | } |
| | 1101 | |
|
| | 1102 | | /// <summary> Retrieves details about any stored access policies specified on the table that may be used with Sh |
| | 1103 | | /// <param name="table"> The name of the table. </param> |
| | 1104 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 1105 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 1106 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1107 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/> is null. </exception> |
| | 1108 | | public ResponseWithHeaders<IReadOnlyList<SignedIdentifier>, TableGetAccessPolicyHeaders> GetAccessPolicy(string |
| | 1109 | | { |
| 2 | 1110 | | if (table == null) |
| | 1111 | | { |
| 0 | 1112 | | throw new ArgumentNullException(nameof(table)); |
| | 1113 | | } |
| | 1114 | |
|
| 2 | 1115 | | using var message = CreateGetAccessPolicyRequest(table, timeout, requestId); |
| 2 | 1116 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1117 | | var headers = new TableGetAccessPolicyHeaders(message.Response); |
| 2 | 1118 | | switch (message.Response.Status) |
| | 1119 | | { |
| | 1120 | | case 200: |
| | 1121 | | { |
| 2 | 1122 | | IReadOnlyList<SignedIdentifier> value = default; |
| 2 | 1123 | | var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace); |
| 2 | 1124 | | if (document.Element("SignedIdentifiers") is XElement signedIdentifiersElement) |
| | 1125 | | { |
| 2 | 1126 | | var array = new List<SignedIdentifier>(); |
| 8 | 1127 | | foreach (var e in signedIdentifiersElement.Elements("SignedIdentifier")) |
| | 1128 | | { |
| 2 | 1129 | | array.Add(SignedIdentifier.DeserializeSignedIdentifier(e)); |
| | 1130 | | } |
| 2 | 1131 | | value = array; |
| | 1132 | | } |
| 2 | 1133 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 1134 | | } |
| | 1135 | | default: |
| 0 | 1136 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1137 | | } |
| 2 | 1138 | | } |
| | 1139 | |
|
| | 1140 | | internal HttpMessage CreateSetAccessPolicyRequest(string table, int? timeout, string requestId, IEnumerable<Sign |
| | 1141 | | { |
| 4 | 1142 | | var message = _pipeline.CreateMessage(); |
| 4 | 1143 | | var request = message.Request; |
| 4 | 1144 | | request.Method = RequestMethod.Put; |
| 4 | 1145 | | var uri = new RawRequestUriBuilder(); |
| 4 | 1146 | | uri.AppendRaw(url, false); |
| 4 | 1147 | | uri.AppendPath("/", false); |
| 4 | 1148 | | uri.AppendPath(table, true); |
| 4 | 1149 | | if (timeout != null) |
| | 1150 | | { |
| 0 | 1151 | | uri.AppendQuery("timeout", timeout.Value, true); |
| | 1152 | | } |
| 4 | 1153 | | uri.AppendQuery("comp", "acl", true); |
| 4 | 1154 | | request.Uri = uri; |
| 4 | 1155 | | request.Headers.Add("x-ms-version", version); |
| 4 | 1156 | | if (requestId != null) |
| | 1157 | | { |
| 0 | 1158 | | request.Headers.Add("x-ms-client-request-id", requestId); |
| | 1159 | | } |
| 4 | 1160 | | request.Headers.Add("Accept", "application/xml"); |
| 4 | 1161 | | request.Headers.Add("Content-Type", "application/xml"); |
| 4 | 1162 | | if (tableAcl != null) |
| | 1163 | | { |
| 4 | 1164 | | var content = new XmlWriterContent(); |
| 4 | 1165 | | content.XmlWriter.WriteStartElement("SignedIdentifiers"); |
| 16 | 1166 | | foreach (var item in tableAcl) |
| | 1167 | | { |
| 4 | 1168 | | content.XmlWriter.WriteObjectValue(item, "SignedIdentifier"); |
| | 1169 | | } |
| 4 | 1170 | | content.XmlWriter.WriteEndElement(); |
| 4 | 1171 | | request.Content = content; |
| | 1172 | | } |
| 4 | 1173 | | return message; |
| | 1174 | | } |
| | 1175 | |
|
| | 1176 | | /// <summary> Sets stored access policies for the table that may be used with Shared Access Signatures. </summar |
| | 1177 | | /// <param name="table"> The name of the table. </param> |
| | 1178 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 1179 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 1180 | | /// <param name="tableAcl"> The acls for the table. </param> |
| | 1181 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1182 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/> is null. </exception> |
| | 1183 | | public async Task<ResponseWithHeaders<TableSetAccessPolicyHeaders>> SetAccessPolicyAsync(string table, int? time |
| | 1184 | | { |
| 2 | 1185 | | if (table == null) |
| | 1186 | | { |
| 0 | 1187 | | throw new ArgumentNullException(nameof(table)); |
| | 1188 | | } |
| | 1189 | |
|
| 2 | 1190 | | using var message = CreateSetAccessPolicyRequest(table, timeout, requestId, tableAcl); |
| 2 | 1191 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1192 | | var headers = new TableSetAccessPolicyHeaders(message.Response); |
| 2 | 1193 | | switch (message.Response.Status) |
| | 1194 | | { |
| | 1195 | | case 204: |
| 2 | 1196 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 1197 | | default: |
| 0 | 1198 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1199 | | } |
| 2 | 1200 | | } |
| | 1201 | |
|
| | 1202 | | /// <summary> Sets stored access policies for the table that may be used with Shared Access Signatures. </summar |
| | 1203 | | /// <param name="table"> The name of the table. </param> |
| | 1204 | | /// <param name="timeout"> The timeout parameter is expressed in seconds. </param> |
| | 1205 | | /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor |
| | 1206 | | /// <param name="tableAcl"> The acls for the table. </param> |
| | 1207 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1208 | | /// <exception cref="ArgumentNullException"> <paramref name="table"/> is null. </exception> |
| | 1209 | | public ResponseWithHeaders<TableSetAccessPolicyHeaders> SetAccessPolicy(string table, int? timeout = null, strin |
| | 1210 | | { |
| 2 | 1211 | | if (table == null) |
| | 1212 | | { |
| 0 | 1213 | | throw new ArgumentNullException(nameof(table)); |
| | 1214 | | } |
| | 1215 | |
|
| 2 | 1216 | | using var message = CreateSetAccessPolicyRequest(table, timeout, requestId, tableAcl); |
| 2 | 1217 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1218 | | var headers = new TableSetAccessPolicyHeaders(message.Response); |
| 2 | 1219 | | switch (message.Response.Status) |
| | 1220 | | { |
| | 1221 | | case 204: |
| 2 | 1222 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 1223 | | default: |
| 0 | 1224 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1225 | | } |
| 2 | 1226 | | } |
| | 1227 | | } |
| | 1228 | | } |