/
zz_generated_accounts_client.go
989 lines (938 loc) · 51.4 KB
/
zz_generated_accounts_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
//go:build go1.16
// +build go1.16
// 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.
package armstorage
import (
"context"
"errors"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"net/http"
"net/url"
"strings"
)
// AccountsClient contains the methods for the StorageAccounts group.
// Don't use this type directly, use NewAccountsClient() instead.
type AccountsClient struct {
host string
subscriptionID string
pl runtime.Pipeline
}
// NewAccountsClient creates a new instance of AccountsClient with the specified values.
// subscriptionID - The ID of the target subscription.
// credential - used to authorize requests. Usually a credential from azidentity.
// options - pass nil to accept the default values.
func NewAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AccountsClient {
if options == nil {
options = &arm.ClientOptions{}
}
ep := options.Endpoint
if len(ep) == 0 {
ep = arm.AzurePublicCloud
}
client := &AccountsClient{
subscriptionID: subscriptionID,
host: string(ep),
pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options),
}
return client
}
// BeginAbortHierarchicalNamespaceMigration - Abort live Migration of storage account to enable Hns
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// options - AccountsClientBeginAbortHierarchicalNamespaceMigrationOptions contains the optional parameters for the AccountsClient.BeginAbortHierarchicalNamespaceMigration
// method.
func (client *AccountsClient) BeginAbortHierarchicalNamespaceMigration(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginAbortHierarchicalNamespaceMigrationOptions) (AccountsClientAbortHierarchicalNamespaceMigrationPollerResponse, error) {
resp, err := client.abortHierarchicalNamespaceMigration(ctx, resourceGroupName, accountName, options)
if err != nil {
return AccountsClientAbortHierarchicalNamespaceMigrationPollerResponse{}, err
}
result := AccountsClientAbortHierarchicalNamespaceMigrationPollerResponse{
RawResponse: resp,
}
pt, err := armruntime.NewPoller("AccountsClient.AbortHierarchicalNamespaceMigration", "location", resp, client.pl)
if err != nil {
return AccountsClientAbortHierarchicalNamespaceMigrationPollerResponse{}, err
}
result.Poller = &AccountsClientAbortHierarchicalNamespaceMigrationPoller{
pt: pt,
}
return result, nil
}
// AbortHierarchicalNamespaceMigration - Abort live Migration of storage account to enable Hns
// If the operation fails it returns an *azcore.ResponseError type.
func (client *AccountsClient) abortHierarchicalNamespaceMigration(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginAbortHierarchicalNamespaceMigrationOptions) (*http.Response, error) {
req, err := client.abortHierarchicalNamespaceMigrationCreateRequest(ctx, resourceGroupName, accountName, options)
if err != nil {
return nil, err
}
resp, err := client.pl.Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// abortHierarchicalNamespaceMigrationCreateRequest creates the AbortHierarchicalNamespaceMigration request.
func (client *AccountsClient) abortHierarchicalNamespaceMigrationCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginAbortHierarchicalNamespaceMigrationOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// CheckNameAvailability - Checks that the storage account name is valid and is not already in use.
// If the operation fails it returns an *azcore.ResponseError type.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// options - AccountsClientCheckNameAvailabilityOptions contains the optional parameters for the AccountsClient.CheckNameAvailability
// method.
func (client *AccountsClient) CheckNameAvailability(ctx context.Context, accountName AccountCheckNameAvailabilityParameters, options *AccountsClientCheckNameAvailabilityOptions) (AccountsClientCheckNameAvailabilityResponse, error) {
req, err := client.checkNameAvailabilityCreateRequest(ctx, accountName, options)
if err != nil {
return AccountsClientCheckNameAvailabilityResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return AccountsClientCheckNameAvailabilityResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return AccountsClientCheckNameAvailabilityResponse{}, runtime.NewResponseError(resp)
}
return client.checkNameAvailabilityHandleResponse(resp)
}
// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request.
func (client *AccountsClient) checkNameAvailabilityCreateRequest(ctx context.Context, accountName AccountCheckNameAvailabilityParameters, options *AccountsClientCheckNameAvailabilityOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, runtime.MarshalAsJSON(req, accountName)
}
// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response.
func (client *AccountsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (AccountsClientCheckNameAvailabilityResponse, error) {
result := AccountsClientCheckNameAvailabilityResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResult); err != nil {
return AccountsClientCheckNameAvailabilityResponse{}, err
}
return result, nil
}
// BeginCreate - Asynchronously creates a new storage account with the specified parameters. If an account is already created
// and a subsequent create request is issued with different properties, the account properties
// will be updated. If an account is already created and a subsequent create or update request is issued with the exact same
// set of properties, the request will succeed.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// parameters - The parameters to provide for the created account.
// options - AccountsClientBeginCreateOptions contains the optional parameters for the AccountsClient.BeginCreate method.
func (client *AccountsClient) BeginCreate(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters, options *AccountsClientBeginCreateOptions) (AccountsClientCreatePollerResponse, error) {
resp, err := client.create(ctx, resourceGroupName, accountName, parameters, options)
if err != nil {
return AccountsClientCreatePollerResponse{}, err
}
result := AccountsClientCreatePollerResponse{
RawResponse: resp,
}
pt, err := armruntime.NewPoller("AccountsClient.Create", "", resp, client.pl)
if err != nil {
return AccountsClientCreatePollerResponse{}, err
}
result.Poller = &AccountsClientCreatePoller{
pt: pt,
}
return result, nil
}
// Create - Asynchronously creates a new storage account with the specified parameters. If an account is already created and
// a subsequent create request is issued with different properties, the account properties
// will be updated. If an account is already created and a subsequent create or update request is issued with the exact same
// set of properties, the request will succeed.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *AccountsClient) create(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters, options *AccountsClientBeginCreateOptions) (*http.Response, error) {
req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, parameters, options)
if err != nil {
return nil, err
}
resp, err := client.pl.Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// createCreateRequest creates the Create request.
func (client *AccountsClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters, options *AccountsClientBeginCreateOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, runtime.MarshalAsJSON(req, parameters)
}
// Delete - Deletes a storage account in Microsoft Azure.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// options - AccountsClientDeleteOptions contains the optional parameters for the AccountsClient.Delete method.
func (client *AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientDeleteOptions) (AccountsClientDeleteResponse, error) {
req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options)
if err != nil {
return AccountsClientDeleteResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return AccountsClientDeleteResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) {
return AccountsClientDeleteResponse{}, runtime.NewResponseError(resp)
}
return AccountsClientDeleteResponse{RawResponse: resp}, nil
}
// deleteCreateRequest creates the Delete request.
func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientDeleteOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
return req, nil
}
// BeginFailover - Failover request can be triggered for a storage account in case of availability issues. The failover occurs
// from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The
// secondary cluster will become primary after failover.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// options - AccountsClientBeginFailoverOptions contains the optional parameters for the AccountsClient.BeginFailover method.
func (client *AccountsClient) BeginFailover(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginFailoverOptions) (AccountsClientFailoverPollerResponse, error) {
resp, err := client.failover(ctx, resourceGroupName, accountName, options)
if err != nil {
return AccountsClientFailoverPollerResponse{}, err
}
result := AccountsClientFailoverPollerResponse{
RawResponse: resp,
}
pt, err := armruntime.NewPoller("AccountsClient.Failover", "location", resp, client.pl)
if err != nil {
return AccountsClientFailoverPollerResponse{}, err
}
result.Poller = &AccountsClientFailoverPoller{
pt: pt,
}
return result, nil
}
// Failover - Failover request can be triggered for a storage account in case of availability issues. The failover occurs
// from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The
// secondary cluster will become primary after failover.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *AccountsClient) failover(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginFailoverOptions) (*http.Response, error) {
req, err := client.failoverCreateRequest(ctx, resourceGroupName, accountName, options)
if err != nil {
return nil, err
}
resp, err := client.pl.Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// failoverCreateRequest creates the Failover request.
func (client *AccountsClient) failoverCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginFailoverOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
return req, nil
}
// GetProperties - Returns the properties for the specified storage account including but not limited to name, SKU name, location,
// and account status. The ListKeys operation should be used to retrieve storage keys.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// options - AccountsClientGetPropertiesOptions contains the optional parameters for the AccountsClient.GetProperties method.
func (client *AccountsClient) GetProperties(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientGetPropertiesOptions) (AccountsClientGetPropertiesResponse, error) {
req, err := client.getPropertiesCreateRequest(ctx, resourceGroupName, accountName, options)
if err != nil {
return AccountsClientGetPropertiesResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return AccountsClientGetPropertiesResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return AccountsClientGetPropertiesResponse{}, runtime.NewResponseError(resp)
}
return client.getPropertiesHandleResponse(resp)
}
// getPropertiesCreateRequest creates the GetProperties request.
func (client *AccountsClient) getPropertiesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientGetPropertiesOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
if options != nil && options.Expand != nil {
reqQP.Set("$expand", string(*options.Expand))
}
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// getPropertiesHandleResponse handles the GetProperties response.
func (client *AccountsClient) getPropertiesHandleResponse(resp *http.Response) (AccountsClientGetPropertiesResponse, error) {
result := AccountsClientGetPropertiesResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.Account); err != nil {
return AccountsClientGetPropertiesResponse{}, err
}
return result, nil
}
// BeginHierarchicalNamespaceMigration - Live Migration of storage account to enable Hns
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// requestType - Required. Hierarchical namespace migration type can either be a hierarchical namespace validation request
// 'HnsOnValidationRequest' or a hydration request 'HnsOnHydrationRequest'. The validation
// request will validate the migration whereas the hydration request will migrate the account.
// options - AccountsClientBeginHierarchicalNamespaceMigrationOptions contains the optional parameters for the AccountsClient.BeginHierarchicalNamespaceMigration
// method.
func (client *AccountsClient) BeginHierarchicalNamespaceMigration(ctx context.Context, resourceGroupName string, accountName string, requestType string, options *AccountsClientBeginHierarchicalNamespaceMigrationOptions) (AccountsClientHierarchicalNamespaceMigrationPollerResponse, error) {
resp, err := client.hierarchicalNamespaceMigration(ctx, resourceGroupName, accountName, requestType, options)
if err != nil {
return AccountsClientHierarchicalNamespaceMigrationPollerResponse{}, err
}
result := AccountsClientHierarchicalNamespaceMigrationPollerResponse{
RawResponse: resp,
}
pt, err := armruntime.NewPoller("AccountsClient.HierarchicalNamespaceMigration", "location", resp, client.pl)
if err != nil {
return AccountsClientHierarchicalNamespaceMigrationPollerResponse{}, err
}
result.Poller = &AccountsClientHierarchicalNamespaceMigrationPoller{
pt: pt,
}
return result, nil
}
// HierarchicalNamespaceMigration - Live Migration of storage account to enable Hns
// If the operation fails it returns an *azcore.ResponseError type.
func (client *AccountsClient) hierarchicalNamespaceMigration(ctx context.Context, resourceGroupName string, accountName string, requestType string, options *AccountsClientBeginHierarchicalNamespaceMigrationOptions) (*http.Response, error) {
req, err := client.hierarchicalNamespaceMigrationCreateRequest(ctx, resourceGroupName, accountName, requestType, options)
if err != nil {
return nil, err
}
resp, err := client.pl.Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// hierarchicalNamespaceMigrationCreateRequest creates the HierarchicalNamespaceMigration request.
func (client *AccountsClient) hierarchicalNamespaceMigrationCreateRequest(ctx context.Context, resourceGroupName string, accountName string, requestType string, options *AccountsClientBeginHierarchicalNamespaceMigrationOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
reqQP.Set("requestType", requestType)
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// List - Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the
// ListKeys operation for this.
// If the operation fails it returns an *azcore.ResponseError type.
// options - AccountsClientListOptions contains the optional parameters for the AccountsClient.List method.
func (client *AccountsClient) List(options *AccountsClientListOptions) *AccountsClientListPager {
return &AccountsClientListPager{
client: client,
requester: func(ctx context.Context) (*policy.Request, error) {
return client.listCreateRequest(ctx, options)
},
advancer: func(ctx context.Context, resp AccountsClientListResponse) (*policy.Request, error) {
return runtime.NewRequest(ctx, http.MethodGet, *resp.AccountListResult.NextLink)
},
}
}
// listCreateRequest creates the List request.
func (client *AccountsClient) listCreateRequest(ctx context.Context, options *AccountsClientListOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// listHandleResponse handles the List response.
func (client *AccountsClient) listHandleResponse(resp *http.Response) (AccountsClientListResponse, error) {
result := AccountsClientListResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.AccountListResult); err != nil {
return AccountsClientListResponse{}, err
}
return result, nil
}
// ListAccountSAS - List SAS credentials of a storage account.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// parameters - The parameters to provide to list SAS credentials for the storage account.
// options - AccountsClientListAccountSASOptions contains the optional parameters for the AccountsClient.ListAccountSAS method.
func (client *AccountsClient) ListAccountSAS(ctx context.Context, resourceGroupName string, accountName string, parameters AccountSasParameters, options *AccountsClientListAccountSASOptions) (AccountsClientListAccountSASResponse, error) {
req, err := client.listAccountSASCreateRequest(ctx, resourceGroupName, accountName, parameters, options)
if err != nil {
return AccountsClientListAccountSASResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return AccountsClientListAccountSASResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return AccountsClientListAccountSASResponse{}, runtime.NewResponseError(resp)
}
return client.listAccountSASHandleResponse(resp)
}
// listAccountSASCreateRequest creates the ListAccountSAS request.
func (client *AccountsClient) listAccountSASCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters AccountSasParameters, options *AccountsClientListAccountSASOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, runtime.MarshalAsJSON(req, parameters)
}
// listAccountSASHandleResponse handles the ListAccountSAS response.
func (client *AccountsClient) listAccountSASHandleResponse(resp *http.Response) (AccountsClientListAccountSASResponse, error) {
result := AccountsClientListAccountSASResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.ListAccountSasResponse); err != nil {
return AccountsClientListAccountSASResponse{}, err
}
return result, nil
}
// ListByResourceGroup - Lists all the storage accounts available under the given resource group. Note that storage keys are
// not returned; use the ListKeys operation for this.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// options - AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.ListByResourceGroup
// method.
func (client *AccountsClient) ListByResourceGroup(resourceGroupName string, options *AccountsClientListByResourceGroupOptions) *AccountsClientListByResourceGroupPager {
return &AccountsClientListByResourceGroupPager{
client: client,
requester: func(ctx context.Context) (*policy.Request, error) {
return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options)
},
advancer: func(ctx context.Context, resp AccountsClientListByResourceGroupResponse) (*policy.Request, error) {
return runtime.NewRequest(ctx, http.MethodGet, *resp.AccountListResult.NextLink)
},
}
}
// listByResourceGroupCreateRequest creates the ListByResourceGroup request.
func (client *AccountsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AccountsClientListByResourceGroupOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// listByResourceGroupHandleResponse handles the ListByResourceGroup response.
func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Response) (AccountsClientListByResourceGroupResponse, error) {
result := AccountsClientListByResourceGroupResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.AccountListResult); err != nil {
return AccountsClientListByResourceGroupResponse{}, err
}
return result, nil
}
// ListKeys - Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// options - AccountsClientListKeysOptions contains the optional parameters for the AccountsClient.ListKeys method.
func (client *AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientListKeysOptions) (AccountsClientListKeysResponse, error) {
req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options)
if err != nil {
return AccountsClientListKeysResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return AccountsClientListKeysResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return AccountsClientListKeysResponse{}, runtime.NewResponseError(resp)
}
return client.listKeysHandleResponse(resp)
}
// listKeysCreateRequest creates the ListKeys request.
func (client *AccountsClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientListKeysOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
if options != nil && options.Expand != nil {
reqQP.Set("$expand", "kerb")
}
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// listKeysHandleResponse handles the ListKeys response.
func (client *AccountsClient) listKeysHandleResponse(resp *http.Response) (AccountsClientListKeysResponse, error) {
result := AccountsClientListKeysResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.AccountListKeysResult); err != nil {
return AccountsClientListKeysResponse{}, err
}
return result, nil
}
// ListServiceSAS - List service SAS credentials of a specific resource.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// parameters - The parameters to provide to list service SAS credentials.
// options - AccountsClientListServiceSASOptions contains the optional parameters for the AccountsClient.ListServiceSAS method.
func (client *AccountsClient) ListServiceSAS(ctx context.Context, resourceGroupName string, accountName string, parameters ServiceSasParameters, options *AccountsClientListServiceSASOptions) (AccountsClientListServiceSASResponse, error) {
req, err := client.listServiceSASCreateRequest(ctx, resourceGroupName, accountName, parameters, options)
if err != nil {
return AccountsClientListServiceSASResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return AccountsClientListServiceSASResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return AccountsClientListServiceSASResponse{}, runtime.NewResponseError(resp)
}
return client.listServiceSASHandleResponse(resp)
}
// listServiceSASCreateRequest creates the ListServiceSAS request.
func (client *AccountsClient) listServiceSASCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters ServiceSasParameters, options *AccountsClientListServiceSASOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, runtime.MarshalAsJSON(req, parameters)
}
// listServiceSASHandleResponse handles the ListServiceSAS response.
func (client *AccountsClient) listServiceSASHandleResponse(resp *http.Response) (AccountsClientListServiceSASResponse, error) {
result := AccountsClientListServiceSASResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.ListServiceSasResponse); err != nil {
return AccountsClientListServiceSASResponse{}, err
}
return result, nil
}
// RegenerateKey - Regenerates one of the access keys or Kerberos keys for the specified storage account.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// regenerateKey - Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2.
// options - AccountsClientRegenerateKeyOptions contains the optional parameters for the AccountsClient.RegenerateKey method.
func (client *AccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters, options *AccountsClientRegenerateKeyOptions) (AccountsClientRegenerateKeyResponse, error) {
req, err := client.regenerateKeyCreateRequest(ctx, resourceGroupName, accountName, regenerateKey, options)
if err != nil {
return AccountsClientRegenerateKeyResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return AccountsClientRegenerateKeyResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return AccountsClientRegenerateKeyResponse{}, runtime.NewResponseError(resp)
}
return client.regenerateKeyHandleResponse(resp)
}
// regenerateKeyCreateRequest creates the RegenerateKey request.
func (client *AccountsClient) regenerateKeyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters, options *AccountsClientRegenerateKeyOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, runtime.MarshalAsJSON(req, regenerateKey)
}
// regenerateKeyHandleResponse handles the RegenerateKey response.
func (client *AccountsClient) regenerateKeyHandleResponse(resp *http.Response) (AccountsClientRegenerateKeyResponse, error) {
result := AccountsClientRegenerateKeyResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.AccountListKeysResult); err != nil {
return AccountsClientRegenerateKeyResponse{}, err
}
return result, nil
}
// BeginRestoreBlobRanges - Restore blobs in the specified blob ranges
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// parameters - The parameters to provide for restore blob ranges.
// options - AccountsClientBeginRestoreBlobRangesOptions contains the optional parameters for the AccountsClient.BeginRestoreBlobRanges
// method.
func (client *AccountsClient) BeginRestoreBlobRanges(ctx context.Context, resourceGroupName string, accountName string, parameters BlobRestoreParameters, options *AccountsClientBeginRestoreBlobRangesOptions) (AccountsClientRestoreBlobRangesPollerResponse, error) {
resp, err := client.restoreBlobRanges(ctx, resourceGroupName, accountName, parameters, options)
if err != nil {
return AccountsClientRestoreBlobRangesPollerResponse{}, err
}
result := AccountsClientRestoreBlobRangesPollerResponse{
RawResponse: resp,
}
pt, err := armruntime.NewPoller("AccountsClient.RestoreBlobRanges", "location", resp, client.pl)
if err != nil {
return AccountsClientRestoreBlobRangesPollerResponse{}, err
}
result.Poller = &AccountsClientRestoreBlobRangesPoller{
pt: pt,
}
return result, nil
}
// RestoreBlobRanges - Restore blobs in the specified blob ranges
// If the operation fails it returns an *azcore.ResponseError type.
func (client *AccountsClient) restoreBlobRanges(ctx context.Context, resourceGroupName string, accountName string, parameters BlobRestoreParameters, options *AccountsClientBeginRestoreBlobRangesOptions) (*http.Response, error) {
req, err := client.restoreBlobRangesCreateRequest(ctx, resourceGroupName, accountName, parameters, options)
if err != nil {
return nil, err
}
resp, err := client.pl.Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// restoreBlobRangesCreateRequest creates the RestoreBlobRanges request.
func (client *AccountsClient) restoreBlobRangesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters BlobRestoreParameters, options *AccountsClientBeginRestoreBlobRangesOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, runtime.MarshalAsJSON(req, parameters)
}
// RevokeUserDelegationKeys - Revoke user delegation keys.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// options - AccountsClientRevokeUserDelegationKeysOptions contains the optional parameters for the AccountsClient.RevokeUserDelegationKeys
// method.
func (client *AccountsClient) RevokeUserDelegationKeys(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientRevokeUserDelegationKeysOptions) (AccountsClientRevokeUserDelegationKeysResponse, error) {
req, err := client.revokeUserDelegationKeysCreateRequest(ctx, resourceGroupName, accountName, options)
if err != nil {
return AccountsClientRevokeUserDelegationKeysResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return AccountsClientRevokeUserDelegationKeysResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return AccountsClientRevokeUserDelegationKeysResponse{}, runtime.NewResponseError(resp)
}
return AccountsClientRevokeUserDelegationKeysResponse{RawResponse: resp}, nil
}
// revokeUserDelegationKeysCreateRequest creates the RevokeUserDelegationKeys request.
func (client *AccountsClient) revokeUserDelegationKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientRevokeUserDelegationKeysOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
return req, nil
}
// Update - The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It
// can also be used to map the account to a custom domain. Only one custom domain is
// supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom
// domain, the old value must be cleared/unregistered before a new value can be
// set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you
// want to change the storage account keys, use the regenerate keys operation. The
// location and name of the storage account cannot be changed after creation.
// If the operation fails it returns an *azcore.ResponseError type.
// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive.
// accountName - The name of the storage account within the specified resource group. Storage account names must be between
// 3 and 24 characters in length and use numbers and lower-case letters only.
// parameters - The parameters to provide for the updated account.
// options - AccountsClientUpdateOptions contains the optional parameters for the AccountsClient.Update method.
func (client *AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters, options *AccountsClientUpdateOptions) (AccountsClientUpdateResponse, error) {
req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, parameters, options)
if err != nil {
return AccountsClientUpdateResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return AccountsClientUpdateResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return AccountsClientUpdateResponse{}, runtime.NewResponseError(resp)
}
return client.updateHandleResponse(resp)
}
// updateCreateRequest creates the Update request.
func (client *AccountsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters, options *AccountsClientUpdateOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if accountName == "" {
return nil, errors.New("parameter accountName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, runtime.MarshalAsJSON(req, parameters)
}
// updateHandleResponse handles the Update response.
func (client *AccountsClient) updateHandleResponse(resp *http.Response) (AccountsClientUpdateResponse, error) {
result := AccountsClientUpdateResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.Account); err != nil {
return AccountsClientUpdateResponse{}, err
}
return result, nil
}