1 package storagetables
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type TableClient struct {
20 BaseClient
21 }
22
23
24 func NewTableClient(URL string) TableClient {
25 return TableClient{New(URL)}
26 }
27
28
29
30
31
32
33
34
35
36 func (client TableClient) Create(ctx context.Context, tableProperties TableProperties, requestID string, formatParameter OdataMetadataFormat, responsePreference ResponseFormat) (result TableResponse, err error) {
37 if tracing.IsEnabled() {
38 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.Create")
39 defer func() {
40 sc := -1
41 if result.Response.Response != nil {
42 sc = result.Response.Response.StatusCode
43 }
44 tracing.EndSpan(ctx, sc, err)
45 }()
46 }
47 req, err := client.CreatePreparer(ctx, tableProperties, requestID, formatParameter, responsePreference)
48 if err != nil {
49 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Create", nil, "Failure preparing request")
50 return
51 }
52
53 resp, err := client.CreateSender(req)
54 if err != nil {
55 result.Response = autorest.Response{Response: resp}
56 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Create", resp, "Failure sending request")
57 return
58 }
59
60 result, err = client.CreateResponder(resp)
61 if err != nil {
62 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Create", resp, "Failure responding to request")
63 return
64 }
65
66 return
67 }
68
69
70 func (client TableClient) CreatePreparer(ctx context.Context, tableProperties TableProperties, requestID string, formatParameter OdataMetadataFormat, responsePreference ResponseFormat) (*http.Request, error) {
71 urlParameters := map[string]interface{}{
72 "url": client.URL,
73 }
74
75 queryParameters := map[string]interface{}{}
76 if len(string(formatParameter)) > 0 {
77 queryParameters["$format"] = autorest.Encode("query", formatParameter)
78 }
79
80 preparer := autorest.CreatePreparer(
81 autorest.AsContentType("application/json;odata=nometadata; charset=utf-8"),
82 autorest.AsPost(),
83 autorest.WithCustomBaseURL("{url}", urlParameters),
84 autorest.WithPath("/Tables"),
85 autorest.WithJSON(tableProperties),
86 autorest.WithQueryParameters(queryParameters),
87 autorest.WithHeader("x-ms-version", "2019-02-02"),
88 autorest.WithHeader("DataServiceVersion", "3.0"))
89 if len(requestID) > 0 {
90 preparer = autorest.DecoratePreparer(preparer,
91 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
92 }
93 if len(string(responsePreference)) > 0 {
94 preparer = autorest.DecoratePreparer(preparer,
95 autorest.WithHeader("Prefer", autorest.String(responsePreference)))
96 }
97 return preparer.Prepare((&http.Request{}).WithContext(ctx))
98 }
99
100
101
102 func (client TableClient) CreateSender(req *http.Request) (*http.Response, error) {
103 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
104 }
105
106
107
108 func (client TableClient) CreateResponder(resp *http.Response) (result TableResponse, err error) {
109 err = autorest.Respond(
110 resp,
111 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent),
112 autorest.ByUnmarshallingJSON(&result),
113 autorest.ByClosing())
114 result.Response = autorest.Response{Response: resp}
115 return
116 }
117
118
119
120
121
122
123 func (client TableClient) Delete(ctx context.Context, table string, requestID string) (result autorest.Response, err error) {
124 if tracing.IsEnabled() {
125 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.Delete")
126 defer func() {
127 sc := -1
128 if result.Response != nil {
129 sc = result.Response.StatusCode
130 }
131 tracing.EndSpan(ctx, sc, err)
132 }()
133 }
134 req, err := client.DeletePreparer(ctx, table, requestID)
135 if err != nil {
136 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Delete", nil, "Failure preparing request")
137 return
138 }
139
140 resp, err := client.DeleteSender(req)
141 if err != nil {
142 result.Response = resp
143 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Delete", resp, "Failure sending request")
144 return
145 }
146
147 result, err = client.DeleteResponder(resp)
148 if err != nil {
149 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Delete", resp, "Failure responding to request")
150 return
151 }
152
153 return
154 }
155
156
157 func (client TableClient) DeletePreparer(ctx context.Context, table string, requestID string) (*http.Request, error) {
158 urlParameters := map[string]interface{}{
159 "url": client.URL,
160 }
161
162 pathParameters := map[string]interface{}{
163 "table": autorest.Encode("path", table),
164 }
165
166 preparer := autorest.CreatePreparer(
167 autorest.AsDelete(),
168 autorest.WithCustomBaseURL("{url}", urlParameters),
169 autorest.WithPathParameters("/Tables('{table}')", pathParameters),
170 autorest.WithHeader("x-ms-version", "2019-02-02"))
171 if len(requestID) > 0 {
172 preparer = autorest.DecoratePreparer(preparer,
173 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
174 }
175 return preparer.Prepare((&http.Request{}).WithContext(ctx))
176 }
177
178
179
180 func (client TableClient) DeleteSender(req *http.Request) (*http.Response, error) {
181 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
182 }
183
184
185
186 func (client TableClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
187 err = autorest.Respond(
188 resp,
189 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
190 autorest.ByClosing())
191 result.Response = resp
192 return
193 }
194
195
196
197
198
199
200
201
202
203
204
205
206 func (client TableClient) DeleteEntity(ctx context.Context, table string, partitionKey string, rowKey string, ifMatch string, timeout *int32, requestID string, formatParameter OdataMetadataFormat) (result autorest.Response, err error) {
207 if tracing.IsEnabled() {
208 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.DeleteEntity")
209 defer func() {
210 sc := -1
211 if result.Response != nil {
212 sc = result.Response.StatusCode
213 }
214 tracing.EndSpan(ctx, sc, err)
215 }()
216 }
217 if err := validation.Validate([]validation.Validation{
218 {TargetValue: timeout,
219 Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
220 Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
221 return result, validation.NewError("storagetables.TableClient", "DeleteEntity", err.Error())
222 }
223
224 req, err := client.DeleteEntityPreparer(ctx, table, partitionKey, rowKey, ifMatch, timeout, requestID, formatParameter)
225 if err != nil {
226 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "DeleteEntity", nil, "Failure preparing request")
227 return
228 }
229
230 resp, err := client.DeleteEntitySender(req)
231 if err != nil {
232 result.Response = resp
233 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "DeleteEntity", resp, "Failure sending request")
234 return
235 }
236
237 result, err = client.DeleteEntityResponder(resp)
238 if err != nil {
239 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "DeleteEntity", resp, "Failure responding to request")
240 return
241 }
242
243 return
244 }
245
246
247 func (client TableClient) DeleteEntityPreparer(ctx context.Context, table string, partitionKey string, rowKey string, ifMatch string, timeout *int32, requestID string, formatParameter OdataMetadataFormat) (*http.Request, error) {
248 urlParameters := map[string]interface{}{
249 "url": client.URL,
250 }
251
252 pathParameters := map[string]interface{}{
253 "partitionKey": autorest.Encode("path", partitionKey),
254 "rowKey": autorest.Encode("path", rowKey),
255 "table": autorest.Encode("path", table),
256 }
257
258 queryParameters := map[string]interface{}{}
259 if timeout != nil {
260 queryParameters["timeout"] = autorest.Encode("query", *timeout)
261 }
262 if len(string(formatParameter)) > 0 {
263 queryParameters["$format"] = autorest.Encode("query", formatParameter)
264 }
265
266 preparer := autorest.CreatePreparer(
267 autorest.AsDelete(),
268 autorest.WithCustomBaseURL("{url}", urlParameters),
269 autorest.WithPathParameters("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')", pathParameters),
270 autorest.WithQueryParameters(queryParameters),
271 autorest.WithHeader("x-ms-version", "2019-02-02"),
272 autorest.WithHeader("DataServiceVersion", "3.0"),
273 autorest.WithHeader("If-Match", autorest.String(ifMatch)))
274 if len(requestID) > 0 {
275 preparer = autorest.DecoratePreparer(preparer,
276 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
277 }
278 return preparer.Prepare((&http.Request{}).WithContext(ctx))
279 }
280
281
282
283 func (client TableClient) DeleteEntitySender(req *http.Request) (*http.Response, error) {
284 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
285 }
286
287
288
289 func (client TableClient) DeleteEntityResponder(resp *http.Response) (result autorest.Response, err error) {
290 err = autorest.Respond(
291 resp,
292 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
293 autorest.ByClosing())
294 result.Response = resp
295 return
296 }
297
298
299
300
301
302
303
304
305 func (client TableClient) GetAccessPolicy(ctx context.Context, table string, timeout *int32, requestID string) (result ListSignedIdentifier, err error) {
306 if tracing.IsEnabled() {
307 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.GetAccessPolicy")
308 defer func() {
309 sc := -1
310 if result.Response.Response != nil {
311 sc = result.Response.Response.StatusCode
312 }
313 tracing.EndSpan(ctx, sc, err)
314 }()
315 }
316 if err := validation.Validate([]validation.Validation{
317 {TargetValue: timeout,
318 Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
319 Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
320 return result, validation.NewError("storagetables.TableClient", "GetAccessPolicy", err.Error())
321 }
322
323 req, err := client.GetAccessPolicyPreparer(ctx, table, timeout, requestID)
324 if err != nil {
325 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "GetAccessPolicy", nil, "Failure preparing request")
326 return
327 }
328
329 resp, err := client.GetAccessPolicySender(req)
330 if err != nil {
331 result.Response = autorest.Response{Response: resp}
332 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "GetAccessPolicy", resp, "Failure sending request")
333 return
334 }
335
336 result, err = client.GetAccessPolicyResponder(resp)
337 if err != nil {
338 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "GetAccessPolicy", resp, "Failure responding to request")
339 return
340 }
341
342 return
343 }
344
345
346 func (client TableClient) GetAccessPolicyPreparer(ctx context.Context, table string, timeout *int32, requestID string) (*http.Request, error) {
347 urlParameters := map[string]interface{}{
348 "url": client.URL,
349 }
350
351 pathParameters := map[string]interface{}{
352 "table": autorest.Encode("path", table),
353 }
354
355 queryParameters := map[string]interface{}{
356 "comp": autorest.Encode("query", "acl"),
357 }
358 if timeout != nil {
359 queryParameters["timeout"] = autorest.Encode("query", *timeout)
360 }
361
362 preparer := autorest.CreatePreparer(
363 autorest.AsGet(),
364 autorest.WithCustomBaseURL("{url}", urlParameters),
365 autorest.WithPathParameters("/{table}", pathParameters),
366 autorest.WithQueryParameters(queryParameters),
367 autorest.WithHeader("x-ms-version", "2019-02-02"))
368 if len(requestID) > 0 {
369 preparer = autorest.DecoratePreparer(preparer,
370 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
371 }
372 return preparer.Prepare((&http.Request{}).WithContext(ctx))
373 }
374
375
376
377 func (client TableClient) GetAccessPolicySender(req *http.Request) (*http.Response, error) {
378 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
379 }
380
381
382
383 func (client TableClient) GetAccessPolicyResponder(resp *http.Response) (result ListSignedIdentifier, err error) {
384 err = autorest.Respond(
385 resp,
386 azure.WithErrorUnlessStatusCode(http.StatusOK),
387 autorest.ByUnmarshallingJSON(&result.Value),
388 autorest.ByClosing())
389 result.Response = autorest.Response{Response: resp}
390 return
391 }
392
393
394
395
396
397
398
399
400
401
402
403 func (client TableClient) InsertEntity(ctx context.Context, table string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, responsePreference ResponseFormat) (result SetSetObject, err error) {
404 if tracing.IsEnabled() {
405 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.InsertEntity")
406 defer func() {
407 sc := -1
408 if result.Response.Response != nil {
409 sc = result.Response.Response.StatusCode
410 }
411 tracing.EndSpan(ctx, sc, err)
412 }()
413 }
414 if err := validation.Validate([]validation.Validation{
415 {TargetValue: timeout,
416 Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
417 Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
418 return result, validation.NewError("storagetables.TableClient", "InsertEntity", err.Error())
419 }
420
421 req, err := client.InsertEntityPreparer(ctx, table, timeout, requestID, formatParameter, tableEntityProperties, responsePreference)
422 if err != nil {
423 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "InsertEntity", nil, "Failure preparing request")
424 return
425 }
426
427 resp, err := client.InsertEntitySender(req)
428 if err != nil {
429 result.Response = autorest.Response{Response: resp}
430 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "InsertEntity", resp, "Failure sending request")
431 return
432 }
433
434 result, err = client.InsertEntityResponder(resp)
435 if err != nil {
436 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "InsertEntity", resp, "Failure responding to request")
437 return
438 }
439
440 return
441 }
442
443
444 func (client TableClient) InsertEntityPreparer(ctx context.Context, table string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, responsePreference ResponseFormat) (*http.Request, error) {
445 urlParameters := map[string]interface{}{
446 "url": client.URL,
447 }
448
449 pathParameters := map[string]interface{}{
450 "table": autorest.Encode("path", table),
451 }
452
453 queryParameters := map[string]interface{}{}
454 if timeout != nil {
455 queryParameters["timeout"] = autorest.Encode("query", *timeout)
456 }
457 if len(string(formatParameter)) > 0 {
458 queryParameters["$format"] = autorest.Encode("query", formatParameter)
459 }
460
461 preparer := autorest.CreatePreparer(
462 autorest.AsContentType("application/json;odata=nometadata; charset=utf-8"),
463 autorest.AsPost(),
464 autorest.WithCustomBaseURL("{url}", urlParameters),
465 autorest.WithPathParameters("/{table}", pathParameters),
466 autorest.WithQueryParameters(queryParameters),
467 autorest.WithHeader("x-ms-version", "2019-02-02"),
468 autorest.WithHeader("DataServiceVersion", "3.0"))
469 if tableEntityProperties != nil && len(tableEntityProperties) > 0 {
470 preparer = autorest.DecoratePreparer(preparer,
471 autorest.WithJSON(tableEntityProperties))
472 }
473 if len(requestID) > 0 {
474 preparer = autorest.DecoratePreparer(preparer,
475 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
476 }
477 if len(string(responsePreference)) > 0 {
478 preparer = autorest.DecoratePreparer(preparer,
479 autorest.WithHeader("Prefer", autorest.String(responsePreference)))
480 }
481 return preparer.Prepare((&http.Request{}).WithContext(ctx))
482 }
483
484
485
486 func (client TableClient) InsertEntitySender(req *http.Request) (*http.Response, error) {
487 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
488 }
489
490
491
492 func (client TableClient) InsertEntityResponder(resp *http.Response) (result SetSetObject, err error) {
493 err = autorest.Respond(
494 resp,
495 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent),
496 autorest.ByUnmarshallingJSON(&result.Value),
497 autorest.ByClosing())
498 result.Response = autorest.Response{Response: resp}
499 return
500 }
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516 func (client TableClient) MergeEntity(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, ifMatch string) (result autorest.Response, err error) {
517 if tracing.IsEnabled() {
518 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.MergeEntity")
519 defer func() {
520 sc := -1
521 if result.Response != nil {
522 sc = result.Response.StatusCode
523 }
524 tracing.EndSpan(ctx, sc, err)
525 }()
526 }
527 if err := validation.Validate([]validation.Validation{
528 {TargetValue: timeout,
529 Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
530 Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
531 return result, validation.NewError("storagetables.TableClient", "MergeEntity", err.Error())
532 }
533
534 req, err := client.MergeEntityPreparer(ctx, table, partitionKey, rowKey, timeout, requestID, formatParameter, tableEntityProperties, ifMatch)
535 if err != nil {
536 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "MergeEntity", nil, "Failure preparing request")
537 return
538 }
539
540 resp, err := client.MergeEntitySender(req)
541 if err != nil {
542 result.Response = resp
543 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "MergeEntity", resp, "Failure sending request")
544 return
545 }
546
547 result, err = client.MergeEntityResponder(resp)
548 if err != nil {
549 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "MergeEntity", resp, "Failure responding to request")
550 return
551 }
552
553 return
554 }
555
556
557 func (client TableClient) MergeEntityPreparer(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, ifMatch string) (*http.Request, error) {
558 urlParameters := map[string]interface{}{
559 "url": client.URL,
560 }
561
562 pathParameters := map[string]interface{}{
563 "partitionKey": autorest.Encode("path", partitionKey),
564 "rowKey": autorest.Encode("path", rowKey),
565 "table": autorest.Encode("path", table),
566 }
567
568 queryParameters := map[string]interface{}{}
569 if timeout != nil {
570 queryParameters["timeout"] = autorest.Encode("query", *timeout)
571 }
572 if len(string(formatParameter)) > 0 {
573 queryParameters["$format"] = autorest.Encode("query", formatParameter)
574 }
575
576 preparer := autorest.CreatePreparer(
577 autorest.AsContentType("application/json; charset=utf-8"),
578 autorest.AsPatch(),
579 autorest.WithCustomBaseURL("{url}", urlParameters),
580 autorest.WithPathParameters("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')", pathParameters),
581 autorest.WithQueryParameters(queryParameters),
582 autorest.WithHeader("x-ms-version", "2019-02-02"),
583 autorest.WithHeader("DataServiceVersion", "3.0"))
584 if tableEntityProperties != nil && len(tableEntityProperties) > 0 {
585 preparer = autorest.DecoratePreparer(preparer,
586 autorest.WithJSON(tableEntityProperties))
587 }
588 if len(requestID) > 0 {
589 preparer = autorest.DecoratePreparer(preparer,
590 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
591 }
592 if len(ifMatch) > 0 {
593 preparer = autorest.DecoratePreparer(preparer,
594 autorest.WithHeader("If-Match", autorest.String(ifMatch)))
595 }
596 return preparer.Prepare((&http.Request{}).WithContext(ctx))
597 }
598
599
600
601 func (client TableClient) MergeEntitySender(req *http.Request) (*http.Response, error) {
602 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
603 }
604
605
606
607 func (client TableClient) MergeEntityResponder(resp *http.Response) (result autorest.Response, err error) {
608 err = autorest.Respond(
609 resp,
610 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
611 autorest.ByClosing())
612 result.Response = resp
613 return
614 }
615
616
617
618
619
620
621
622
623
624
625
626 func (client TableClient) Query(ctx context.Context, requestID string, formatParameter OdataMetadataFormat, top *int32, selectParameter string, filter string, nextTableName string) (result TableQueryResponse, err error) {
627 if tracing.IsEnabled() {
628 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.Query")
629 defer func() {
630 sc := -1
631 if result.Response.Response != nil {
632 sc = result.Response.Response.StatusCode
633 }
634 tracing.EndSpan(ctx, sc, err)
635 }()
636 }
637 if err := validation.Validate([]validation.Validation{
638 {TargetValue: top,
639 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
640 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
641 return result, validation.NewError("storagetables.TableClient", "Query", err.Error())
642 }
643
644 req, err := client.QueryPreparer(ctx, requestID, formatParameter, top, selectParameter, filter, nextTableName)
645 if err != nil {
646 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Query", nil, "Failure preparing request")
647 return
648 }
649
650 resp, err := client.QuerySender(req)
651 if err != nil {
652 result.Response = autorest.Response{Response: resp}
653 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Query", resp, "Failure sending request")
654 return
655 }
656
657 result, err = client.QueryResponder(resp)
658 if err != nil {
659 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Query", resp, "Failure responding to request")
660 return
661 }
662
663 return
664 }
665
666
667 func (client TableClient) QueryPreparer(ctx context.Context, requestID string, formatParameter OdataMetadataFormat, top *int32, selectParameter string, filter string, nextTableName string) (*http.Request, error) {
668 urlParameters := map[string]interface{}{
669 "url": client.URL,
670 }
671
672 queryParameters := map[string]interface{}{}
673 if len(string(formatParameter)) > 0 {
674 queryParameters["$format"] = autorest.Encode("query", formatParameter)
675 }
676 if top != nil {
677 queryParameters["$top"] = autorest.Encode("query", *top)
678 }
679 if len(selectParameter) > 0 {
680 queryParameters["$select"] = autorest.Encode("query", selectParameter)
681 }
682 if len(filter) > 0 {
683 queryParameters["$filter"] = autorest.Encode("query", filter)
684 }
685 if len(nextTableName) > 0 {
686 queryParameters["NextTableName"] = autorest.Encode("query", nextTableName)
687 }
688
689 preparer := autorest.CreatePreparer(
690 autorest.AsGet(),
691 autorest.WithCustomBaseURL("{url}", urlParameters),
692 autorest.WithPath("/Tables"),
693 autorest.WithQueryParameters(queryParameters),
694 autorest.WithHeader("x-ms-version", "2019-02-02"),
695 autorest.WithHeader("DataServiceVersion", "3.0"))
696 if len(requestID) > 0 {
697 preparer = autorest.DecoratePreparer(preparer,
698 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
699 }
700 return preparer.Prepare((&http.Request{}).WithContext(ctx))
701 }
702
703
704
705 func (client TableClient) QuerySender(req *http.Request) (*http.Response, error) {
706 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
707 }
708
709
710
711 func (client TableClient) QueryResponder(resp *http.Response) (result TableQueryResponse, err error) {
712 err = autorest.Respond(
713 resp,
714 azure.WithErrorUnlessStatusCode(http.StatusOK),
715 autorest.ByUnmarshallingJSON(&result),
716 autorest.ByClosing())
717 result.Response = autorest.Response{Response: resp}
718 return
719 }
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734 func (client TableClient) QueryEntities(ctx context.Context, table string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, top *int32, selectParameter string, filter string, nextPartitionKey string, nextRowKey string) (result TableEntityQueryResponse, err error) {
735 if tracing.IsEnabled() {
736 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.QueryEntities")
737 defer func() {
738 sc := -1
739 if result.Response.Response != nil {
740 sc = result.Response.Response.StatusCode
741 }
742 tracing.EndSpan(ctx, sc, err)
743 }()
744 }
745 if err := validation.Validate([]validation.Validation{
746 {TargetValue: timeout,
747 Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
748 Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}},
749 {TargetValue: top,
750 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
751 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
752 return result, validation.NewError("storagetables.TableClient", "QueryEntities", err.Error())
753 }
754
755 req, err := client.QueryEntitiesPreparer(ctx, table, timeout, requestID, formatParameter, top, selectParameter, filter, nextPartitionKey, nextRowKey)
756 if err != nil {
757 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntities", nil, "Failure preparing request")
758 return
759 }
760
761 resp, err := client.QueryEntitiesSender(req)
762 if err != nil {
763 result.Response = autorest.Response{Response: resp}
764 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntities", resp, "Failure sending request")
765 return
766 }
767
768 result, err = client.QueryEntitiesResponder(resp)
769 if err != nil {
770 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntities", resp, "Failure responding to request")
771 return
772 }
773
774 return
775 }
776
777
778 func (client TableClient) QueryEntitiesPreparer(ctx context.Context, table string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, top *int32, selectParameter string, filter string, nextPartitionKey string, nextRowKey string) (*http.Request, error) {
779 urlParameters := map[string]interface{}{
780 "url": client.URL,
781 }
782
783 pathParameters := map[string]interface{}{
784 "table": autorest.Encode("path", table),
785 }
786
787 queryParameters := map[string]interface{}{}
788 if timeout != nil {
789 queryParameters["timeout"] = autorest.Encode("query", *timeout)
790 }
791 if len(string(formatParameter)) > 0 {
792 queryParameters["$format"] = autorest.Encode("query", formatParameter)
793 }
794 if top != nil {
795 queryParameters["$top"] = autorest.Encode("query", *top)
796 }
797 if len(selectParameter) > 0 {
798 queryParameters["$select"] = autorest.Encode("query", selectParameter)
799 }
800 if len(filter) > 0 {
801 queryParameters["$filter"] = autorest.Encode("query", filter)
802 }
803 if len(nextPartitionKey) > 0 {
804 queryParameters["NextPartitionKey"] = autorest.Encode("query", nextPartitionKey)
805 }
806 if len(nextRowKey) > 0 {
807 queryParameters["NextRowKey"] = autorest.Encode("query", nextRowKey)
808 }
809
810 preparer := autorest.CreatePreparer(
811 autorest.AsGet(),
812 autorest.WithCustomBaseURL("{url}", urlParameters),
813 autorest.WithPathParameters("/{table}()", pathParameters),
814 autorest.WithQueryParameters(queryParameters),
815 autorest.WithHeader("x-ms-version", "2019-02-02"),
816 autorest.WithHeader("DataServiceVersion", "3.0"))
817 if len(requestID) > 0 {
818 preparer = autorest.DecoratePreparer(preparer,
819 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
820 }
821 return preparer.Prepare((&http.Request{}).WithContext(ctx))
822 }
823
824
825
826 func (client TableClient) QueryEntitiesSender(req *http.Request) (*http.Response, error) {
827 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
828 }
829
830
831
832 func (client TableClient) QueryEntitiesResponder(resp *http.Response) (result TableEntityQueryResponse, err error) {
833 err = autorest.Respond(
834 resp,
835 azure.WithErrorUnlessStatusCode(http.StatusOK),
836 autorest.ByUnmarshallingJSON(&result),
837 autorest.ByClosing())
838 result.Response = autorest.Response{Response: resp}
839 return
840 }
841
842
843
844
845
846
847
848
849
850
851
852
853
854 func (client TableClient) QueryEntitiesWithPartitionAndRowKey(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, selectParameter string, filter string) (result TableEntityQueryResponse, err error) {
855 if tracing.IsEnabled() {
856 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.QueryEntitiesWithPartitionAndRowKey")
857 defer func() {
858 sc := -1
859 if result.Response.Response != nil {
860 sc = result.Response.Response.StatusCode
861 }
862 tracing.EndSpan(ctx, sc, err)
863 }()
864 }
865 if err := validation.Validate([]validation.Validation{
866 {TargetValue: timeout,
867 Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
868 Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
869 return result, validation.NewError("storagetables.TableClient", "QueryEntitiesWithPartitionAndRowKey", err.Error())
870 }
871
872 req, err := client.QueryEntitiesWithPartitionAndRowKeyPreparer(ctx, table, partitionKey, rowKey, timeout, requestID, formatParameter, selectParameter, filter)
873 if err != nil {
874 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntitiesWithPartitionAndRowKey", nil, "Failure preparing request")
875 return
876 }
877
878 resp, err := client.QueryEntitiesWithPartitionAndRowKeySender(req)
879 if err != nil {
880 result.Response = autorest.Response{Response: resp}
881 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntitiesWithPartitionAndRowKey", resp, "Failure sending request")
882 return
883 }
884
885 result, err = client.QueryEntitiesWithPartitionAndRowKeyResponder(resp)
886 if err != nil {
887 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntitiesWithPartitionAndRowKey", resp, "Failure responding to request")
888 return
889 }
890
891 return
892 }
893
894
895 func (client TableClient) QueryEntitiesWithPartitionAndRowKeyPreparer(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, selectParameter string, filter string) (*http.Request, error) {
896 urlParameters := map[string]interface{}{
897 "url": client.URL,
898 }
899
900 pathParameters := map[string]interface{}{
901 "partitionKey": autorest.Encode("path", partitionKey),
902 "rowKey": autorest.Encode("path", rowKey),
903 "table": autorest.Encode("path", table),
904 }
905
906 queryParameters := map[string]interface{}{}
907 if timeout != nil {
908 queryParameters["timeout"] = autorest.Encode("query", *timeout)
909 }
910 if len(string(formatParameter)) > 0 {
911 queryParameters["$format"] = autorest.Encode("query", formatParameter)
912 }
913 if len(selectParameter) > 0 {
914 queryParameters["$select"] = autorest.Encode("query", selectParameter)
915 }
916 if len(filter) > 0 {
917 queryParameters["$filter"] = autorest.Encode("query", filter)
918 }
919
920 preparer := autorest.CreatePreparer(
921 autorest.AsGet(),
922 autorest.WithCustomBaseURL("{url}", urlParameters),
923 autorest.WithPathParameters("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')", pathParameters),
924 autorest.WithQueryParameters(queryParameters),
925 autorest.WithHeader("x-ms-version", "2019-02-02"),
926 autorest.WithHeader("DataServiceVersion", "3.0"))
927 if len(requestID) > 0 {
928 preparer = autorest.DecoratePreparer(preparer,
929 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
930 }
931 return preparer.Prepare((&http.Request{}).WithContext(ctx))
932 }
933
934
935
936 func (client TableClient) QueryEntitiesWithPartitionAndRowKeySender(req *http.Request) (*http.Response, error) {
937 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
938 }
939
940
941
942 func (client TableClient) QueryEntitiesWithPartitionAndRowKeyResponder(resp *http.Response) (result TableEntityQueryResponse, err error) {
943 err = autorest.Respond(
944 resp,
945 azure.WithErrorUnlessStatusCode(http.StatusOK),
946 autorest.ByUnmarshallingJSON(&result),
947 autorest.ByClosing())
948 result.Response = autorest.Response{Response: resp}
949 return
950 }
951
952
953
954
955
956
957
958
959 func (client TableClient) SetAccessPolicy(ctx context.Context, table string, tableACL []SignedIdentifier, timeout *int32, requestID string) (result autorest.Response, err error) {
960 if tracing.IsEnabled() {
961 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.SetAccessPolicy")
962 defer func() {
963 sc := -1
964 if result.Response != nil {
965 sc = result.Response.StatusCode
966 }
967 tracing.EndSpan(ctx, sc, err)
968 }()
969 }
970 if err := validation.Validate([]validation.Validation{
971 {TargetValue: timeout,
972 Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
973 Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
974 return result, validation.NewError("storagetables.TableClient", "SetAccessPolicy", err.Error())
975 }
976
977 req, err := client.SetAccessPolicyPreparer(ctx, table, tableACL, timeout, requestID)
978 if err != nil {
979 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "SetAccessPolicy", nil, "Failure preparing request")
980 return
981 }
982
983 resp, err := client.SetAccessPolicySender(req)
984 if err != nil {
985 result.Response = resp
986 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "SetAccessPolicy", resp, "Failure sending request")
987 return
988 }
989
990 result, err = client.SetAccessPolicyResponder(resp)
991 if err != nil {
992 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "SetAccessPolicy", resp, "Failure responding to request")
993 return
994 }
995
996 return
997 }
998
999
1000 func (client TableClient) SetAccessPolicyPreparer(ctx context.Context, table string, tableACL []SignedIdentifier, timeout *int32, requestID string) (*http.Request, error) {
1001 urlParameters := map[string]interface{}{
1002 "url": client.URL,
1003 }
1004
1005 pathParameters := map[string]interface{}{
1006 "table": autorest.Encode("path", table),
1007 }
1008
1009 queryParameters := map[string]interface{}{
1010 "comp": autorest.Encode("query", "acl"),
1011 }
1012 if timeout != nil {
1013 queryParameters["timeout"] = autorest.Encode("query", *timeout)
1014 }
1015
1016 preparer := autorest.CreatePreparer(
1017 autorest.AsContentType("application/xml; charset=utf-8"),
1018 autorest.AsPut(),
1019 autorest.WithCustomBaseURL("{url}", urlParameters),
1020 autorest.WithPathParameters("/{table}", pathParameters),
1021 autorest.WithQueryParameters(queryParameters),
1022 autorest.WithHeader("x-ms-version", "2019-02-02"))
1023 if tableACL != nil && len(tableACL) > 0 {
1024 preparer = autorest.DecoratePreparer(preparer,
1025 autorest.WithJSON(tableACL))
1026 }
1027 if len(requestID) > 0 {
1028 preparer = autorest.DecoratePreparer(preparer,
1029 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
1030 }
1031 return preparer.Prepare((&http.Request{}).WithContext(ctx))
1032 }
1033
1034
1035
1036 func (client TableClient) SetAccessPolicySender(req *http.Request) (*http.Response, error) {
1037 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1038 }
1039
1040
1041
1042 func (client TableClient) SetAccessPolicyResponder(resp *http.Response) (result autorest.Response, err error) {
1043 err = autorest.Respond(
1044 resp,
1045 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
1046 autorest.ByClosing())
1047 result.Response = resp
1048 return
1049 }
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065 func (client TableClient) UpdateEntity(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, ifMatch string) (result autorest.Response, err error) {
1066 if tracing.IsEnabled() {
1067 ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.UpdateEntity")
1068 defer func() {
1069 sc := -1
1070 if result.Response != nil {
1071 sc = result.Response.StatusCode
1072 }
1073 tracing.EndSpan(ctx, sc, err)
1074 }()
1075 }
1076 if err := validation.Validate([]validation.Validation{
1077 {TargetValue: timeout,
1078 Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
1079 Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
1080 return result, validation.NewError("storagetables.TableClient", "UpdateEntity", err.Error())
1081 }
1082
1083 req, err := client.UpdateEntityPreparer(ctx, table, partitionKey, rowKey, timeout, requestID, formatParameter, tableEntityProperties, ifMatch)
1084 if err != nil {
1085 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "UpdateEntity", nil, "Failure preparing request")
1086 return
1087 }
1088
1089 resp, err := client.UpdateEntitySender(req)
1090 if err != nil {
1091 result.Response = resp
1092 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "UpdateEntity", resp, "Failure sending request")
1093 return
1094 }
1095
1096 result, err = client.UpdateEntityResponder(resp)
1097 if err != nil {
1098 err = autorest.NewErrorWithError(err, "storagetables.TableClient", "UpdateEntity", resp, "Failure responding to request")
1099 return
1100 }
1101
1102 return
1103 }
1104
1105
1106 func (client TableClient) UpdateEntityPreparer(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, ifMatch string) (*http.Request, error) {
1107 urlParameters := map[string]interface{}{
1108 "url": client.URL,
1109 }
1110
1111 pathParameters := map[string]interface{}{
1112 "partitionKey": autorest.Encode("path", partitionKey),
1113 "rowKey": autorest.Encode("path", rowKey),
1114 "table": autorest.Encode("path", table),
1115 }
1116
1117 queryParameters := map[string]interface{}{}
1118 if timeout != nil {
1119 queryParameters["timeout"] = autorest.Encode("query", *timeout)
1120 }
1121 if len(string(formatParameter)) > 0 {
1122 queryParameters["$format"] = autorest.Encode("query", formatParameter)
1123 }
1124
1125 preparer := autorest.CreatePreparer(
1126 autorest.AsContentType("application/json; charset=utf-8"),
1127 autorest.AsPut(),
1128 autorest.WithCustomBaseURL("{url}", urlParameters),
1129 autorest.WithPathParameters("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')", pathParameters),
1130 autorest.WithQueryParameters(queryParameters),
1131 autorest.WithHeader("x-ms-version", "2019-02-02"),
1132 autorest.WithHeader("DataServiceVersion", "3.0"))
1133 if tableEntityProperties != nil && len(tableEntityProperties) > 0 {
1134 preparer = autorest.DecoratePreparer(preparer,
1135 autorest.WithJSON(tableEntityProperties))
1136 }
1137 if len(requestID) > 0 {
1138 preparer = autorest.DecoratePreparer(preparer,
1139 autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
1140 }
1141 if len(ifMatch) > 0 {
1142 preparer = autorest.DecoratePreparer(preparer,
1143 autorest.WithHeader("If-Match", autorest.String(ifMatch)))
1144 }
1145 return preparer.Prepare((&http.Request{}).WithContext(ctx))
1146 }
1147
1148
1149
1150 func (client TableClient) UpdateEntitySender(req *http.Request) (*http.Response, error) {
1151 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1152 }
1153
1154
1155
1156 func (client TableClient) UpdateEntityResponder(resp *http.Response) (result autorest.Response, err error) {
1157 err = autorest.Respond(
1158 resp,
1159 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
1160 autorest.ByClosing())
1161 result.Response = resp
1162 return
1163 }
1164
View as plain text