-
Notifications
You must be signed in to change notification settings - Fork 850
/
zz_path_client.go
1584 lines (1544 loc) · 69.3 KB
/
zz_path_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//go:build go1.18
// +build go1.18
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// DO NOT EDIT.
package generated
import (
"context"
"encoding/base64"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"io"
"net/http"
"strconv"
"time"
)
// PathClient contains the methods for the Path group.
// Don't use this type directly, use a constructor function instead.
type PathClient struct {
internal *azcore.Client
endpoint string
xmsLeaseDuration int32
}
// AppendData - Append data to the file.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2021-06-08
// - body - Initial data
// - options - PathClientAppendDataOptions contains the optional parameters for the PathClient.AppendData method.
// - PathHTTPHeaders - PathHTTPHeaders contains a group of parameters for the PathClient.Create method.
// - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the PathClient.Create method.
// - CPKInfo - CPKInfo contains a group of parameters for the PathClient.Create method.
func (client *PathClient) AppendData(ctx context.Context, body io.ReadSeekCloser, options *PathClientAppendDataOptions, pathHTTPHeaders *PathHTTPHeaders, leaseAccessConditions *LeaseAccessConditions, cpkInfo *CPKInfo) (PathClientAppendDataResponse, error) {
req, err := client.appendDataCreateRequest(ctx, body, options, pathHTTPHeaders, leaseAccessConditions, cpkInfo)
if err != nil {
return PathClientAppendDataResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return PathClientAppendDataResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusAccepted) {
return PathClientAppendDataResponse{}, runtime.NewResponseError(resp)
}
return client.appendDataHandleResponse(resp)
}
// appendDataCreateRequest creates the AppendData request.
func (client *PathClient) appendDataCreateRequest(ctx context.Context, body io.ReadSeekCloser, options *PathClientAppendDataOptions, pathHTTPHeaders *PathHTTPHeaders, leaseAccessConditions *LeaseAccessConditions, cpkInfo *CPKInfo) (*policy.Request, error) {
req, err := runtime.NewRequest(ctx, http.MethodPatch, client.endpoint)
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("action", "append")
if options != nil && options.Position != nil {
reqQP.Set("position", strconv.FormatInt(*options.Position, 10))
}
if options != nil && options.Timeout != nil {
reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
}
if options != nil && options.Flush != nil {
reqQP.Set("flush", strconv.FormatBool(*options.Flush))
}
req.Raw().URL.RawQuery = reqQP.Encode()
if options != nil && options.ContentLength != nil {
req.Raw().Header["Content-Length"] = []string{strconv.FormatInt(*options.ContentLength, 10)}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.TransactionalContentHash != nil {
req.Raw().Header["Content-MD5"] = []string{base64.StdEncoding.EncodeToString(pathHTTPHeaders.TransactionalContentHash)}
}
if options != nil && options.TransactionalContentCRC64 != nil {
req.Raw().Header["x-ms-content-crc64"] = []string{base64.StdEncoding.EncodeToString(options.TransactionalContentCRC64)}
}
if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil {
req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID}
}
if options != nil && options.LeaseAction != nil {
req.Raw().Header["x-ms-lease-action"] = []string{string(*options.LeaseAction)}
}
if options != nil && options.LeaseDuration != nil {
req.Raw().Header["x-ms-lease-duration"] = []string{strconv.FormatInt(*options.LeaseDuration, 10)}
}
if options != nil && options.ProposedLeaseID != nil {
req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID}
}
if options != nil && options.RequestID != nil {
req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
}
req.Raw().Header["x-ms-version"] = []string{"2021-06-08"}
if cpkInfo != nil && cpkInfo.EncryptionKey != nil {
req.Raw().Header["x-ms-encryption-key"] = []string{*cpkInfo.EncryptionKey}
}
if cpkInfo != nil && cpkInfo.EncryptionKeySHA256 != nil {
req.Raw().Header["x-ms-encryption-key-sha256"] = []string{*cpkInfo.EncryptionKeySHA256}
}
if cpkInfo != nil && cpkInfo.EncryptionAlgorithm != nil {
req.Raw().Header["x-ms-encryption-algorithm"] = []string{string(*cpkInfo.EncryptionAlgorithm)}
}
req.Raw().Header["Accept"] = []string{"application/json"}
if err := req.SetBody(body, "application/json"); err != nil {
return nil, err
}
return req, nil
}
// appendDataHandleResponse handles the AppendData response.
func (client *PathClient) appendDataHandleResponse(resp *http.Response) (PathClientAppendDataResponse, error) {
result := PathClientAppendDataResponse{}
if val := resp.Header.Get("Date"); val != "" {
date, err := time.Parse(time.RFC1123, val)
if err != nil {
return PathClientAppendDataResponse{}, err
}
result.Date = &date
}
if val := resp.Header.Get("x-ms-request-id"); val != "" {
result.RequestID = &val
}
if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
result.ClientRequestID = &val
}
if val := resp.Header.Get("x-ms-version"); val != "" {
result.Version = &val
}
if val := resp.Header.Get("ETag"); val != "" {
result.ETag = (*azcore.ETag)(&val)
}
if val := resp.Header.Get("Content-MD5"); val != "" {
contentMD5, err := base64.StdEncoding.DecodeString(val)
if err != nil {
return PathClientAppendDataResponse{}, err
}
result.ContentMD5 = contentMD5
}
if val := resp.Header.Get("x-ms-content-crc64"); val != "" {
contentCRC64, err := base64.StdEncoding.DecodeString(val)
if err != nil {
return PathClientAppendDataResponse{}, err
}
result.ContentCRC64 = contentCRC64
}
if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" {
isServerEncrypted, err := strconv.ParseBool(val)
if err != nil {
return PathClientAppendDataResponse{}, err
}
result.IsServerEncrypted = &isServerEncrypted
}
if val := resp.Header.Get("x-ms-encryption-key-sha256"); val != "" {
result.EncryptionKeySHA256 = &val
}
if val := resp.Header.Get("x-ms-lease-renewed"); val != "" {
leaseRenewed, err := strconv.ParseBool(val)
if err != nil {
return PathClientAppendDataResponse{}, err
}
result.LeaseRenewed = &leaseRenewed
}
return result, nil
}
// Create - Create or rename a file or directory. By default, the destination is overwritten and if the destination already
// exists and has a lease the lease is broken. This operation supports conditional HTTP
// requests. For more information, see Specifying Conditional Headers for Blob Service Operations
// [https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations].
// To fail if the destination already exists, use a conditional request with
// If-None-Match: "*".
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2021-06-08
// - options - PathClientCreateOptions contains the optional parameters for the PathClient.Create method.
// - PathHTTPHeaders - PathHTTPHeaders contains a group of parameters for the PathClient.Create method.
// - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the PathClient.Create method.
// - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the FileSystemClient.SetProperties
// method.
// - SourceModifiedAccessConditions - SourceModifiedAccessConditions contains a group of parameters for the PathClient.Create
// method.
// - CPKInfo - CPKInfo contains a group of parameters for the PathClient.Create method.
func (client *PathClient) Create(ctx context.Context, options *PathClientCreateOptions, pathHTTPHeaders *PathHTTPHeaders, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, sourceModifiedAccessConditions *SourceModifiedAccessConditions, cpkInfo *CPKInfo) (PathClientCreateResponse, error) {
req, err := client.createCreateRequest(ctx, options, pathHTTPHeaders, leaseAccessConditions, modifiedAccessConditions, sourceModifiedAccessConditions, cpkInfo)
if err != nil {
return PathClientCreateResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return PathClientCreateResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusCreated) {
return PathClientCreateResponse{}, runtime.NewResponseError(resp)
}
return client.createHandleResponse(resp)
}
// createCreateRequest creates the Create request.
func (client *PathClient) createCreateRequest(ctx context.Context, options *PathClientCreateOptions, pathHTTPHeaders *PathHTTPHeaders, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, sourceModifiedAccessConditions *SourceModifiedAccessConditions, cpkInfo *CPKInfo) (*policy.Request, error) {
req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint)
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
if options != nil && options.Timeout != nil {
reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
}
if options != nil && options.Resource != nil {
reqQP.Set("resource", string(*options.Resource))
}
if options != nil && options.Continuation != nil {
reqQP.Set("continuation", *options.Continuation)
}
if options != nil && options.Mode != nil {
reqQP.Set("mode", string(*options.Mode))
}
req.Raw().URL.RawQuery = reqQP.Encode()
if options != nil && options.RequestID != nil {
req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
}
req.Raw().Header["x-ms-version"] = []string{"2021-06-08"}
if pathHTTPHeaders != nil && pathHTTPHeaders.CacheControl != nil {
req.Raw().Header["x-ms-cache-control"] = []string{*pathHTTPHeaders.CacheControl}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.ContentEncoding != nil {
req.Raw().Header["x-ms-content-encoding"] = []string{*pathHTTPHeaders.ContentEncoding}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.ContentLanguage != nil {
req.Raw().Header["x-ms-content-language"] = []string{*pathHTTPHeaders.ContentLanguage}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.ContentDisposition != nil {
req.Raw().Header["x-ms-content-disposition"] = []string{*pathHTTPHeaders.ContentDisposition}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.ContentType != nil {
req.Raw().Header["x-ms-content-type"] = []string{*pathHTTPHeaders.ContentType}
}
if options != nil && options.RenameSource != nil {
req.Raw().Header["x-ms-rename-source"] = []string{*options.RenameSource}
}
if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil {
req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID}
}
if options != nil && options.SourceLeaseID != nil {
req.Raw().Header["x-ms-source-lease-id"] = []string{*options.SourceLeaseID}
}
if options != nil && options.Properties != nil {
req.Raw().Header["x-ms-properties"] = []string{*options.Properties}
}
if options != nil && options.Permissions != nil {
req.Raw().Header["x-ms-permissions"] = []string{*options.Permissions}
}
if options != nil && options.Umask != nil {
req.Raw().Header["x-ms-umask"] = []string{*options.Umask}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfMatch != nil {
req.Raw().Header["If-Match"] = []string{string(*modifiedAccessConditions.IfMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfNoneMatch != nil {
req.Raw().Header["If-None-Match"] = []string{string(*modifiedAccessConditions.IfNoneMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfModifiedSince != nil {
req.Raw().Header["If-Modified-Since"] = []string{modifiedAccessConditions.IfModifiedSince.Format(time.RFC1123)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfUnmodifiedSince != nil {
req.Raw().Header["If-Unmodified-Since"] = []string{modifiedAccessConditions.IfUnmodifiedSince.Format(time.RFC1123)}
}
if sourceModifiedAccessConditions != nil && sourceModifiedAccessConditions.SourceIfMatch != nil {
req.Raw().Header["x-ms-source-if-match"] = []string{string(*sourceModifiedAccessConditions.SourceIfMatch)}
}
if sourceModifiedAccessConditions != nil && sourceModifiedAccessConditions.SourceIfNoneMatch != nil {
req.Raw().Header["x-ms-source-if-none-match"] = []string{string(*sourceModifiedAccessConditions.SourceIfNoneMatch)}
}
if sourceModifiedAccessConditions != nil && sourceModifiedAccessConditions.SourceIfModifiedSince != nil {
req.Raw().Header["x-ms-source-if-modified-since"] = []string{sourceModifiedAccessConditions.SourceIfModifiedSince.Format(time.RFC1123)}
}
if sourceModifiedAccessConditions != nil && sourceModifiedAccessConditions.SourceIfUnmodifiedSince != nil {
req.Raw().Header["x-ms-source-if-unmodified-since"] = []string{sourceModifiedAccessConditions.SourceIfUnmodifiedSince.Format(time.RFC1123)}
}
if cpkInfo != nil && cpkInfo.EncryptionKey != nil {
req.Raw().Header["x-ms-encryption-key"] = []string{*cpkInfo.EncryptionKey}
}
if cpkInfo != nil && cpkInfo.EncryptionKeySHA256 != nil {
req.Raw().Header["x-ms-encryption-key-sha256"] = []string{*cpkInfo.EncryptionKeySHA256}
}
if cpkInfo != nil && cpkInfo.EncryptionAlgorithm != nil {
req.Raw().Header["x-ms-encryption-algorithm"] = []string{string(*cpkInfo.EncryptionAlgorithm)}
}
if options != nil && options.Owner != nil {
req.Raw().Header["x-ms-owner"] = []string{*options.Owner}
}
if options != nil && options.Group != nil {
req.Raw().Header["x-ms-group"] = []string{*options.Group}
}
if options != nil && options.ACL != nil {
req.Raw().Header["x-ms-acl"] = []string{*options.ACL}
}
if options != nil && options.ProposedLeaseID != nil {
req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID}
}
if options != nil && options.LeaseDuration != nil {
req.Raw().Header["x-ms-lease-duration"] = []string{strconv.FormatInt(*options.LeaseDuration, 10)}
}
if options != nil && options.ExpiryOptions != nil {
req.Raw().Header["x-ms-expiry-option"] = []string{string(*options.ExpiryOptions)}
}
if options != nil && options.ExpiresOn != nil {
req.Raw().Header["x-ms-expiry-time"] = []string{*options.ExpiresOn}
}
if options != nil && options.EncryptionContext != nil {
req.Raw().Header["x-ms-encryption-context"] = []string{*options.EncryptionContext}
}
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// createHandleResponse handles the Create response.
func (client *PathClient) createHandleResponse(resp *http.Response) (PathClientCreateResponse, error) {
result := PathClientCreateResponse{}
if val := resp.Header.Get("Date"); val != "" {
date, err := time.Parse(time.RFC1123, val)
if err != nil {
return PathClientCreateResponse{}, err
}
result.Date = &date
}
if val := resp.Header.Get("ETag"); val != "" {
result.ETag = (*azcore.ETag)(&val)
}
if val := resp.Header.Get("Last-Modified"); val != "" {
lastModified, err := time.Parse(time.RFC1123, val)
if err != nil {
return PathClientCreateResponse{}, err
}
result.LastModified = &lastModified
}
if val := resp.Header.Get("x-ms-request-id"); val != "" {
result.RequestID = &val
}
if val := resp.Header.Get("x-ms-version"); val != "" {
result.Version = &val
}
if val := resp.Header.Get("x-ms-continuation"); val != "" {
result.Continuation = &val
}
if val := resp.Header.Get("Content-Length"); val != "" {
contentLength, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return PathClientCreateResponse{}, err
}
result.ContentLength = &contentLength
}
if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" {
isServerEncrypted, err := strconv.ParseBool(val)
if err != nil {
return PathClientCreateResponse{}, err
}
result.IsServerEncrypted = &isServerEncrypted
}
if val := resp.Header.Get("x-ms-encryption-key-sha256"); val != "" {
result.EncryptionKeySHA256 = &val
}
return result, nil
}
// Delete - Delete the file or directory. This operation supports conditional HTTP requests. For more information, see Specifying
// Conditional Headers for Blob Service Operations
// [https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations].
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2021-06-08
// - options - PathClientDeleteOptions contains the optional parameters for the PathClient.Delete method.
// - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the PathClient.Create method.
// - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the FileSystemClient.SetProperties
// method.
func (client *PathClient) Delete(ctx context.Context, options *PathClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (PathClientDeleteResponse, error) {
req, err := client.deleteCreateRequest(ctx, options, leaseAccessConditions, modifiedAccessConditions)
if err != nil {
return PathClientDeleteResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return PathClientDeleteResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return PathClientDeleteResponse{}, runtime.NewResponseError(resp)
}
return client.deleteHandleResponse(resp)
}
// deleteCreateRequest creates the Delete request.
func (client *PathClient) deleteCreateRequest(ctx context.Context, options *PathClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (*policy.Request, error) {
req, err := runtime.NewRequest(ctx, http.MethodDelete, client.endpoint)
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
if options != nil && options.Timeout != nil {
reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
}
if options != nil && options.Recursive != nil {
reqQP.Set("recursive", strconv.FormatBool(*options.Recursive))
}
if options != nil && options.Continuation != nil {
reqQP.Set("continuation", *options.Continuation)
}
req.Raw().URL.RawQuery = reqQP.Encode()
if options != nil && options.RequestID != nil {
req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
}
req.Raw().Header["x-ms-version"] = []string{"2021-06-08"}
if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil {
req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfMatch != nil {
req.Raw().Header["If-Match"] = []string{string(*modifiedAccessConditions.IfMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfNoneMatch != nil {
req.Raw().Header["If-None-Match"] = []string{string(*modifiedAccessConditions.IfNoneMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfModifiedSince != nil {
req.Raw().Header["If-Modified-Since"] = []string{modifiedAccessConditions.IfModifiedSince.Format(time.RFC1123)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfUnmodifiedSince != nil {
req.Raw().Header["If-Unmodified-Since"] = []string{modifiedAccessConditions.IfUnmodifiedSince.Format(time.RFC1123)}
}
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// deleteHandleResponse handles the Delete response.
func (client *PathClient) deleteHandleResponse(resp *http.Response) (PathClientDeleteResponse, error) {
result := PathClientDeleteResponse{}
if val := resp.Header.Get("Date"); val != "" {
date, err := time.Parse(time.RFC1123, val)
if err != nil {
return PathClientDeleteResponse{}, err
}
result.Date = &date
}
if val := resp.Header.Get("x-ms-request-id"); val != "" {
result.RequestID = &val
}
if val := resp.Header.Get("x-ms-version"); val != "" {
result.Version = &val
}
if val := resp.Header.Get("x-ms-continuation"); val != "" {
result.Continuation = &val
}
if val := resp.Header.Get("x-ms-deletion-id"); val != "" {
result.DeletionID = &val
}
return result, nil
}
// FlushData - Set the owner, group, permissions, or access control list for a path.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2021-06-08
// - options - PathClientFlushDataOptions contains the optional parameters for the PathClient.FlushData method.
// - PathHTTPHeaders - PathHTTPHeaders contains a group of parameters for the PathClient.Create method.
// - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the PathClient.Create method.
// - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the FileSystemClient.SetProperties
// method.
// - CPKInfo - CPKInfo contains a group of parameters for the PathClient.Create method.
func (client *PathClient) FlushData(ctx context.Context, options *PathClientFlushDataOptions, pathHTTPHeaders *PathHTTPHeaders, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, cpkInfo *CPKInfo) (PathClientFlushDataResponse, error) {
req, err := client.flushDataCreateRequest(ctx, options, pathHTTPHeaders, leaseAccessConditions, modifiedAccessConditions, cpkInfo)
if err != nil {
return PathClientFlushDataResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return PathClientFlushDataResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return PathClientFlushDataResponse{}, runtime.NewResponseError(resp)
}
return client.flushDataHandleResponse(resp)
}
// flushDataCreateRequest creates the FlushData request.
func (client *PathClient) flushDataCreateRequest(ctx context.Context, options *PathClientFlushDataOptions, pathHTTPHeaders *PathHTTPHeaders, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, cpkInfo *CPKInfo) (*policy.Request, error) {
req, err := runtime.NewRequest(ctx, http.MethodPatch, client.endpoint)
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("action", "flush")
if options != nil && options.Timeout != nil {
reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
}
if options != nil && options.Position != nil {
reqQP.Set("position", strconv.FormatInt(*options.Position, 10))
}
if options != nil && options.RetainUncommittedData != nil {
reqQP.Set("retainUncommittedData", strconv.FormatBool(*options.RetainUncommittedData))
}
if options != nil && options.Close != nil {
reqQP.Set("close", strconv.FormatBool(*options.Close))
}
req.Raw().URL.RawQuery = reqQP.Encode()
if options != nil && options.ContentLength != nil {
req.Raw().Header["Content-Length"] = []string{strconv.FormatInt(*options.ContentLength, 10)}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.ContentMD5 != nil {
req.Raw().Header["x-ms-content-md5"] = []string{base64.StdEncoding.EncodeToString(pathHTTPHeaders.ContentMD5)}
}
if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil {
req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID}
}
if options != nil && options.LeaseAction != nil {
req.Raw().Header["x-ms-lease-action"] = []string{string(*options.LeaseAction)}
}
if options != nil && options.LeaseDuration != nil {
req.Raw().Header["x-ms-lease-duration"] = []string{strconv.FormatInt(*options.LeaseDuration, 10)}
}
if options != nil && options.ProposedLeaseID != nil {
req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.CacheControl != nil {
req.Raw().Header["x-ms-cache-control"] = []string{*pathHTTPHeaders.CacheControl}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.ContentType != nil {
req.Raw().Header["x-ms-content-type"] = []string{*pathHTTPHeaders.ContentType}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.ContentDisposition != nil {
req.Raw().Header["x-ms-content-disposition"] = []string{*pathHTTPHeaders.ContentDisposition}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.ContentEncoding != nil {
req.Raw().Header["x-ms-content-encoding"] = []string{*pathHTTPHeaders.ContentEncoding}
}
if pathHTTPHeaders != nil && pathHTTPHeaders.ContentLanguage != nil {
req.Raw().Header["x-ms-content-language"] = []string{*pathHTTPHeaders.ContentLanguage}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfMatch != nil {
req.Raw().Header["If-Match"] = []string{string(*modifiedAccessConditions.IfMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfNoneMatch != nil {
req.Raw().Header["If-None-Match"] = []string{string(*modifiedAccessConditions.IfNoneMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfModifiedSince != nil {
req.Raw().Header["If-Modified-Since"] = []string{modifiedAccessConditions.IfModifiedSince.Format(time.RFC1123)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfUnmodifiedSince != nil {
req.Raw().Header["If-Unmodified-Since"] = []string{modifiedAccessConditions.IfUnmodifiedSince.Format(time.RFC1123)}
}
if options != nil && options.RequestID != nil {
req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
}
req.Raw().Header["x-ms-version"] = []string{"2021-06-08"}
if cpkInfo != nil && cpkInfo.EncryptionKey != nil {
req.Raw().Header["x-ms-encryption-key"] = []string{*cpkInfo.EncryptionKey}
}
if cpkInfo != nil && cpkInfo.EncryptionKeySHA256 != nil {
req.Raw().Header["x-ms-encryption-key-sha256"] = []string{*cpkInfo.EncryptionKeySHA256}
}
if cpkInfo != nil && cpkInfo.EncryptionAlgorithm != nil {
req.Raw().Header["x-ms-encryption-algorithm"] = []string{string(*cpkInfo.EncryptionAlgorithm)}
}
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// flushDataHandleResponse handles the FlushData response.
func (client *PathClient) flushDataHandleResponse(resp *http.Response) (PathClientFlushDataResponse, error) {
result := PathClientFlushDataResponse{}
if val := resp.Header.Get("Date"); val != "" {
date, err := time.Parse(time.RFC1123, val)
if err != nil {
return PathClientFlushDataResponse{}, err
}
result.Date = &date
}
if val := resp.Header.Get("ETag"); val != "" {
result.ETag = (*azcore.ETag)(&val)
}
if val := resp.Header.Get("Last-Modified"); val != "" {
lastModified, err := time.Parse(time.RFC1123, val)
if err != nil {
return PathClientFlushDataResponse{}, err
}
result.LastModified = &lastModified
}
if val := resp.Header.Get("Content-Length"); val != "" {
contentLength, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return PathClientFlushDataResponse{}, err
}
result.ContentLength = &contentLength
}
if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
result.ClientRequestID = &val
}
if val := resp.Header.Get("x-ms-request-id"); val != "" {
result.RequestID = &val
}
if val := resp.Header.Get("x-ms-version"); val != "" {
result.Version = &val
}
if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" {
isServerEncrypted, err := strconv.ParseBool(val)
if err != nil {
return PathClientFlushDataResponse{}, err
}
result.IsServerEncrypted = &isServerEncrypted
}
if val := resp.Header.Get("x-ms-encryption-key-sha256"); val != "" {
result.EncryptionKeySHA256 = &val
}
if val := resp.Header.Get("x-ms-lease-renewed"); val != "" {
leaseRenewed, err := strconv.ParseBool(val)
if err != nil {
return PathClientFlushDataResponse{}, err
}
result.LeaseRenewed = &leaseRenewed
}
return result, nil
}
// GetProperties - Get Properties returns all system and user defined properties for a path. Get Status returns all system
// defined properties for a path. Get Access Control List returns the access control list for a
// path. This operation supports conditional HTTP requests. For more information, see Specifying Conditional Headers for Blob
// Service Operations
// [https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations].
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2021-06-08
// - options - PathClientGetPropertiesOptions contains the optional parameters for the PathClient.GetProperties method.
// - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the PathClient.Create method.
// - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the FileSystemClient.SetProperties
// method.
func (client *PathClient) GetProperties(ctx context.Context, options *PathClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (PathClientGetPropertiesResponse, error) {
req, err := client.getPropertiesCreateRequest(ctx, options, leaseAccessConditions, modifiedAccessConditions)
if err != nil {
return PathClientGetPropertiesResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return PathClientGetPropertiesResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return PathClientGetPropertiesResponse{}, runtime.NewResponseError(resp)
}
return client.getPropertiesHandleResponse(resp)
}
// getPropertiesCreateRequest creates the GetProperties request.
func (client *PathClient) getPropertiesCreateRequest(ctx context.Context, options *PathClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (*policy.Request, error) {
req, err := runtime.NewRequest(ctx, http.MethodHead, client.endpoint)
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
if options != nil && options.Timeout != nil {
reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
}
if options != nil && options.Action != nil {
reqQP.Set("action", string(*options.Action))
}
if options != nil && options.Upn != nil {
reqQP.Set("upn", strconv.FormatBool(*options.Upn))
}
req.Raw().URL.RawQuery = reqQP.Encode()
if options != nil && options.RequestID != nil {
req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
}
req.Raw().Header["x-ms-version"] = []string{"2021-06-08"}
if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil {
req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfMatch != nil {
req.Raw().Header["If-Match"] = []string{string(*modifiedAccessConditions.IfMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfNoneMatch != nil {
req.Raw().Header["If-None-Match"] = []string{string(*modifiedAccessConditions.IfNoneMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfModifiedSince != nil {
req.Raw().Header["If-Modified-Since"] = []string{modifiedAccessConditions.IfModifiedSince.Format(time.RFC1123)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfUnmodifiedSince != nil {
req.Raw().Header["If-Unmodified-Since"] = []string{modifiedAccessConditions.IfUnmodifiedSince.Format(time.RFC1123)}
}
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// getPropertiesHandleResponse handles the GetProperties response.
func (client *PathClient) getPropertiesHandleResponse(resp *http.Response) (PathClientGetPropertiesResponse, error) {
result := PathClientGetPropertiesResponse{}
if val := resp.Header.Get("Accept-Ranges"); val != "" {
result.AcceptRanges = &val
}
if val := resp.Header.Get("Cache-Control"); val != "" {
result.CacheControl = &val
}
if val := resp.Header.Get("Content-Disposition"); val != "" {
result.ContentDisposition = &val
}
if val := resp.Header.Get("Content-Encoding"); val != "" {
result.ContentEncoding = &val
}
if val := resp.Header.Get("Content-Language"); val != "" {
result.ContentLanguage = &val
}
if val := resp.Header.Get("Content-Length"); val != "" {
contentLength, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return PathClientGetPropertiesResponse{}, err
}
result.ContentLength = &contentLength
}
if val := resp.Header.Get("Content-Range"); val != "" {
result.ContentRange = &val
}
if val := resp.Header.Get("Content-Type"); val != "" {
result.ContentType = &val
}
if val := resp.Header.Get("Content-MD5"); val != "" {
result.ContentMD5 = &val
}
if val := resp.Header.Get("Date"); val != "" {
date, err := time.Parse(time.RFC1123, val)
if err != nil {
return PathClientGetPropertiesResponse{}, err
}
result.Date = &date
}
if val := resp.Header.Get("ETag"); val != "" {
result.ETag = (*azcore.ETag)(&val)
}
if val := resp.Header.Get("Last-Modified"); val != "" {
lastModified, err := time.Parse(time.RFC1123, val)
if err != nil {
return PathClientGetPropertiesResponse{}, err
}
result.LastModified = &lastModified
}
if val := resp.Header.Get("x-ms-request-id"); val != "" {
result.RequestID = &val
}
if val := resp.Header.Get("x-ms-version"); val != "" {
result.Version = &val
}
if val := resp.Header.Get("x-ms-resource-type"); val != "" {
result.ResourceType = &val
}
if val := resp.Header.Get("x-ms-properties"); val != "" {
result.Properties = &val
}
if val := resp.Header.Get("x-ms-owner"); val != "" {
result.Owner = &val
}
if val := resp.Header.Get("x-ms-group"); val != "" {
result.Group = &val
}
if val := resp.Header.Get("x-ms-permissions"); val != "" {
result.Permissions = &val
}
if val := resp.Header.Get("x-ms-acl"); val != "" {
result.ACL = &val
}
if val := resp.Header.Get("x-ms-lease-duration"); val != "" {
result.LeaseDuration = &val
}
if val := resp.Header.Get("x-ms-lease-state"); val != "" {
result.LeaseState = &val
}
if val := resp.Header.Get("x-ms-lease-status"); val != "" {
result.LeaseStatus = &val
}
return result, nil
}
// Lease - Create and manage a lease to restrict write and delete access to the path. This operation supports conditional
// HTTP requests. For more information, see Specifying Conditional Headers for Blob Service
// Operations [https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations].
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2021-06-08
// - xmsLeaseAction - There are five lease actions: "acquire", "break", "change", "renew", and "release". Use "acquire" and
// specify the "x-ms-proposed-lease-id" and "x-ms-lease-duration" to acquire a new lease. Use "break"
// to break an existing lease. When a lease is broken, the lease break period is allowed to elapse, during which time no lease
// operation except break and release can be performed on the file. When a
// lease is successfully broken, the response indicates the interval in seconds until a new lease can be acquired. Use "change"
// and specify the current lease ID in "x-ms-lease-id" and the new lease ID in
// "x-ms-proposed-lease-id" to change the lease ID of an active lease. Use "renew" and specify the "x-ms-lease-id" to renew
// an existing lease. Use "release" and specify the "x-ms-lease-id" to release a
// lease.
// - options - PathClientLeaseOptions contains the optional parameters for the PathClient.Lease method.
// - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the PathClient.Create method.
// - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the FileSystemClient.SetProperties
// method.
func (client *PathClient) Lease(ctx context.Context, xmsLeaseAction PathLeaseAction, options *PathClientLeaseOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (PathClientLeaseResponse, error) {
req, err := client.leaseCreateRequest(ctx, xmsLeaseAction, options, leaseAccessConditions, modifiedAccessConditions)
if err != nil {
return PathClientLeaseResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return PathClientLeaseResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) {
return PathClientLeaseResponse{}, runtime.NewResponseError(resp)
}
return client.leaseHandleResponse(resp)
}
// leaseCreateRequest creates the Lease request.
func (client *PathClient) leaseCreateRequest(ctx context.Context, xmsLeaseAction PathLeaseAction, options *PathClientLeaseOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (*policy.Request, error) {
req, err := runtime.NewRequest(ctx, http.MethodPost, client.endpoint)
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
if options != nil && options.Timeout != nil {
reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
}
req.Raw().URL.RawQuery = reqQP.Encode()
if options != nil && options.RequestID != nil {
req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
}
req.Raw().Header["x-ms-version"] = []string{"2021-06-08"}
req.Raw().Header["x-ms-lease-action"] = []string{string(xmsLeaseAction)}
req.Raw().Header["x-ms-lease-duration"] = []string{strconv.FormatInt(int64(client.xmsLeaseDuration), 10)}
if options != nil && options.XMSLeaseBreakPeriod != nil {
req.Raw().Header["x-ms-lease-break-period"] = []string{strconv.FormatInt(int64(*options.XMSLeaseBreakPeriod), 10)}
}
if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil {
req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID}
}
if options != nil && options.ProposedLeaseID != nil {
req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfMatch != nil {
req.Raw().Header["If-Match"] = []string{string(*modifiedAccessConditions.IfMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfNoneMatch != nil {
req.Raw().Header["If-None-Match"] = []string{string(*modifiedAccessConditions.IfNoneMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfModifiedSince != nil {
req.Raw().Header["If-Modified-Since"] = []string{modifiedAccessConditions.IfModifiedSince.Format(time.RFC1123)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfUnmodifiedSince != nil {
req.Raw().Header["If-Unmodified-Since"] = []string{modifiedAccessConditions.IfUnmodifiedSince.Format(time.RFC1123)}
}
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// leaseHandleResponse handles the Lease response.
func (client *PathClient) leaseHandleResponse(resp *http.Response) (PathClientLeaseResponse, error) {
result := PathClientLeaseResponse{}
if val := resp.Header.Get("Date"); val != "" {
date, err := time.Parse(time.RFC1123, val)
if err != nil {
return PathClientLeaseResponse{}, err
}
result.Date = &date
}
if val := resp.Header.Get("ETag"); val != "" {
result.ETag = (*azcore.ETag)(&val)
}
if val := resp.Header.Get("Last-Modified"); val != "" {
lastModified, err := time.Parse(time.RFC1123, val)
if err != nil {
return PathClientLeaseResponse{}, err
}
result.LastModified = &lastModified
}
if val := resp.Header.Get("x-ms-request-id"); val != "" {
result.RequestID = &val
}
if val := resp.Header.Get("x-ms-version"); val != "" {
result.Version = &val
}
if val := resp.Header.Get("x-ms-lease-id"); val != "" {
result.LeaseID = &val
}
if val := resp.Header.Get("x-ms-lease-time"); val != "" {
result.LeaseTime = &val
}
return result, nil
}
// Read - Read the contents of a file. For read operations, range requests are supported. This operation supports conditional
// HTTP requests. For more information, see Specifying Conditional Headers for Blob
// Service Operations [https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations].
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2021-06-08
// - options - PathClientReadOptions contains the optional parameters for the PathClient.Read method.
// - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the PathClient.Create method.
// - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the FileSystemClient.SetProperties
// method.
// - CPKInfo - CPKInfo contains a group of parameters for the PathClient.Create method.
func (client *PathClient) Read(ctx context.Context, options *PathClientReadOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, cpkInfo *CPKInfo) (PathClientReadResponse, error) {
req, err := client.readCreateRequest(ctx, options, leaseAccessConditions, modifiedAccessConditions, cpkInfo)
if err != nil {
return PathClientReadResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return PathClientReadResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusPartialContent) {
return PathClientReadResponse{}, runtime.NewResponseError(resp)
}
return client.readHandleResponse(resp)
}
// readCreateRequest creates the Read request.
func (client *PathClient) readCreateRequest(ctx context.Context, options *PathClientReadOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, cpkInfo *CPKInfo) (*policy.Request, error) {
req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint)
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
if options != nil && options.Timeout != nil {
reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
}
req.Raw().URL.RawQuery = reqQP.Encode()
runtime.SkipBodyDownload(req)
if options != nil && options.RequestID != nil {
req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
}
req.Raw().Header["x-ms-version"] = []string{"2021-06-08"}
if options != nil && options.Range != nil {
req.Raw().Header["Range"] = []string{*options.Range}
}
if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil {
req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID}
}
if options != nil && options.XMSRangeGetContentMD5 != nil {
req.Raw().Header["x-ms-range-get-content-md5"] = []string{strconv.FormatBool(*options.XMSRangeGetContentMD5)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfMatch != nil {
req.Raw().Header["If-Match"] = []string{string(*modifiedAccessConditions.IfMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfNoneMatch != nil {
req.Raw().Header["If-None-Match"] = []string{string(*modifiedAccessConditions.IfNoneMatch)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfModifiedSince != nil {
req.Raw().Header["If-Modified-Since"] = []string{modifiedAccessConditions.IfModifiedSince.Format(time.RFC1123)}
}
if modifiedAccessConditions != nil && modifiedAccessConditions.IfUnmodifiedSince != nil {
req.Raw().Header["If-Unmodified-Since"] = []string{modifiedAccessConditions.IfUnmodifiedSince.Format(time.RFC1123)}
}
if cpkInfo != nil && cpkInfo.EncryptionKey != nil {
req.Raw().Header["x-ms-encryption-key"] = []string{*cpkInfo.EncryptionKey}
}
if cpkInfo != nil && cpkInfo.EncryptionKeySHA256 != nil {
req.Raw().Header["x-ms-encryption-key-sha256"] = []string{*cpkInfo.EncryptionKeySHA256}
}
if cpkInfo != nil && cpkInfo.EncryptionAlgorithm != nil {
req.Raw().Header["x-ms-encryption-algorithm"] = []string{string(*cpkInfo.EncryptionAlgorithm)}
}
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// readHandleResponse handles the Read response.
func (client *PathClient) readHandleResponse(resp *http.Response) (PathClientReadResponse, error) {
result := PathClientReadResponse{Body: resp.Body}
if val := resp.Header.Get("Accept-Ranges"); val != "" {
result.AcceptRanges = &val
}
if val := resp.Header.Get("Cache-Control"); val != "" {
result.CacheControl = &val
}
if val := resp.Header.Get("Content-Disposition"); val != "" {
result.ContentDisposition = &val
}
if val := resp.Header.Get("Content-Encoding"); val != "" {
result.ContentEncoding = &val
}
if val := resp.Header.Get("Content-Language"); val != "" {
result.ContentLanguage = &val
}
if val := resp.Header.Get("Content-Length"); val != "" {
contentLength, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return PathClientReadResponse{}, err
}
result.ContentLength = &contentLength
}
if val := resp.Header.Get("Content-Range"); val != "" {
result.ContentRange = &val
}
if val := resp.Header.Get("Content-Type"); val != "" {
result.ContentType = &val
}
if val := resp.Header.Get("Content-MD5"); val != "" {
result.ContentMD5 = &val
}
if val := resp.Header.Get("Date"); val != "" {
date, err := time.Parse(time.RFC1123, val)