/
zz_generated_fileshares_client.go
502 lines (478 loc) · 25.4 KB
/
zz_generated_fileshares_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
//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"
)
// FileSharesClient contains the methods for the FileShares group.
// Don't use this type directly, use NewFileSharesClient() instead.
type FileSharesClient struct {
host string
subscriptionID string
pl runtime.Pipeline
}
// NewFileSharesClient creates a new instance of FileSharesClient 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 NewFileSharesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *FileSharesClient {
if options == nil {
options = &arm.ClientOptions{}
}
ep := options.Endpoint
if len(ep) == 0 {
ep = arm.AzurePublicCloud
}
client := &FileSharesClient{
subscriptionID: subscriptionID,
host: string(ep),
pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options),
}
return client
}
// Create - Creates a new share under the specified account as described by request body. The share resource includes metadata
// and properties for that share. It does not include a list of the files contained by
// the share.
// 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.
// shareName - The name of the file share within the specified storage account. File share names must be between 3 and 63
// characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-)
// character must be immediately preceded and followed by a letter or number.
// fileShare - Properties of the file share to create.
// options - FileSharesClientCreateOptions contains the optional parameters for the FileSharesClient.Create method.
func (client *FileSharesClient) Create(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesClientCreateOptions) (FileSharesClientCreateResponse, error) {
req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, shareName, fileShare, options)
if err != nil {
return FileSharesClientCreateResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return FileSharesClientCreateResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) {
return FileSharesClientCreateResponse{}, runtime.NewResponseError(resp)
}
return client.createHandleResponse(resp)
}
// createCreateRequest creates the Create request.
func (client *FileSharesClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesClientCreateOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"
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 shareName == "" {
return nil, errors.New("parameter shareName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName))
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()
if options != nil && options.Expand != nil {
reqQP.Set("$expand", *options.Expand)
}
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, fileShare)
}
// createHandleResponse handles the Create response.
func (client *FileSharesClient) createHandleResponse(resp *http.Response) (FileSharesClientCreateResponse, error) {
result := FileSharesClientCreateResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.FileShare); err != nil {
return FileSharesClientCreateResponse{}, err
}
return result, nil
}
// Delete - Deletes specified share under its 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.
// shareName - The name of the file share within the specified storage account. File share names must be between 3 and 63
// characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-)
// character must be immediately preceded and followed by a letter or number.
// options - FileSharesClientDeleteOptions contains the optional parameters for the FileSharesClient.Delete method.
func (client *FileSharesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesClientDeleteOptions) (FileSharesClientDeleteResponse, error) {
req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, shareName, options)
if err != nil {
return FileSharesClientDeleteResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return FileSharesClientDeleteResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) {
return FileSharesClientDeleteResponse{}, runtime.NewResponseError(resp)
}
return FileSharesClientDeleteResponse{RawResponse: resp}, nil
}
// deleteCreateRequest creates the Delete request.
func (client *FileSharesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesClientDeleteOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"
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 shareName == "" {
return nil, errors.New("parameter shareName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName))
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")
if options != nil && options.Include != nil {
reqQP.Set("$include", *options.Include)
}
req.Raw().URL.RawQuery = reqQP.Encode()
if options != nil && options.XMSSnapshot != nil {
req.Raw().Header.Set("x-ms-snapshot", *options.XMSSnapshot)
}
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// Get - Gets properties of a specified share.
// 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.
// shareName - The name of the file share within the specified storage account. File share names must be between 3 and 63
// characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-)
// character must be immediately preceded and followed by a letter or number.
// options - FileSharesClientGetOptions contains the optional parameters for the FileSharesClient.Get method.
func (client *FileSharesClient) Get(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesClientGetOptions) (FileSharesClientGetResponse, error) {
req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, shareName, options)
if err != nil {
return FileSharesClientGetResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return FileSharesClientGetResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return FileSharesClientGetResponse{}, runtime.NewResponseError(resp)
}
return client.getHandleResponse(resp)
}
// getCreateRequest creates the Get request.
func (client *FileSharesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesClientGetOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"
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 shareName == "" {
return nil, errors.New("parameter shareName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName))
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", *options.Expand)
}
req.Raw().URL.RawQuery = reqQP.Encode()
if options != nil && options.XMSSnapshot != nil {
req.Raw().Header.Set("x-ms-snapshot", *options.XMSSnapshot)
}
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// getHandleResponse handles the Get response.
func (client *FileSharesClient) getHandleResponse(resp *http.Response) (FileSharesClientGetResponse, error) {
result := FileSharesClientGetResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.FileShare); err != nil {
return FileSharesClientGetResponse{}, err
}
return result, nil
}
// Lease - The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can
// be 15 to 60 seconds, or can be infinite.
// 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.
// shareName - The name of the file share within the specified storage account. File share names must be between 3 and 63
// characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-)
// character must be immediately preceded and followed by a letter or number.
// options - FileSharesClientLeaseOptions contains the optional parameters for the FileSharesClient.Lease method.
func (client *FileSharesClient) Lease(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesClientLeaseOptions) (FileSharesClientLeaseResponse, error) {
req, err := client.leaseCreateRequest(ctx, resourceGroupName, accountName, shareName, options)
if err != nil {
return FileSharesClientLeaseResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return FileSharesClientLeaseResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return FileSharesClientLeaseResponse{}, runtime.NewResponseError(resp)
}
return client.leaseHandleResponse(resp)
}
// leaseCreateRequest creates the Lease request.
func (client *FileSharesClient) leaseCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesClientLeaseOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"
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 shareName == "" {
return nil, errors.New("parameter shareName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName))
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()
if options != nil && options.XMSSnapshot != nil {
req.Raw().Header.Set("x-ms-snapshot", *options.XMSSnapshot)
}
req.Raw().Header.Set("Accept", "application/json")
if options != nil && options.Parameters != nil {
return req, runtime.MarshalAsJSON(req, *options.Parameters)
}
return req, nil
}
// leaseHandleResponse handles the Lease response.
func (client *FileSharesClient) leaseHandleResponse(resp *http.Response) (FileSharesClientLeaseResponse, error) {
result := FileSharesClientLeaseResponse{RawResponse: resp}
if val := resp.Header.Get("ETag"); val != "" {
result.ETag = &val
}
if err := runtime.UnmarshalAsJSON(resp, &result.LeaseShareResponse); err != nil {
return FileSharesClientLeaseResponse{}, err
}
return result, nil
}
// List - Lists all shares.
// 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 - FileSharesClientListOptions contains the optional parameters for the FileSharesClient.List method.
func (client *FileSharesClient) List(resourceGroupName string, accountName string, options *FileSharesClientListOptions) *FileSharesClientListPager {
return &FileSharesClientListPager{
client: client,
requester: func(ctx context.Context) (*policy.Request, error) {
return client.listCreateRequest(ctx, resourceGroupName, accountName, options)
},
advancer: func(ctx context.Context, resp FileSharesClientListResponse) (*policy.Request, error) {
return runtime.NewRequest(ctx, http.MethodGet, *resp.FileShareItems.NextLink)
},
}
}
// listCreateRequest creates the List request.
func (client *FileSharesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *FileSharesClientListOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"
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.Maxpagesize != nil {
reqQP.Set("$maxpagesize", *options.Maxpagesize)
}
if options != nil && options.Filter != nil {
reqQP.Set("$filter", *options.Filter)
}
if options != nil && options.Expand != nil {
reqQP.Set("$expand", *options.Expand)
}
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// listHandleResponse handles the List response.
func (client *FileSharesClient) listHandleResponse(resp *http.Response) (FileSharesClientListResponse, error) {
result := FileSharesClientListResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.FileShareItems); err != nil {
return FileSharesClientListResponse{}, err
}
return result, nil
}
// Restore - Restore a file share within a valid retention days if share soft delete is enabled
// 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.
// shareName - The name of the file share within the specified storage account. File share names must be between 3 and 63
// characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-)
// character must be immediately preceded and followed by a letter or number.
// options - FileSharesClientRestoreOptions contains the optional parameters for the FileSharesClient.Restore method.
func (client *FileSharesClient) Restore(ctx context.Context, resourceGroupName string, accountName string, shareName string, deletedShare DeletedShare, options *FileSharesClientRestoreOptions) (FileSharesClientRestoreResponse, error) {
req, err := client.restoreCreateRequest(ctx, resourceGroupName, accountName, shareName, deletedShare, options)
if err != nil {
return FileSharesClientRestoreResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return FileSharesClientRestoreResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return FileSharesClientRestoreResponse{}, runtime.NewResponseError(resp)
}
return FileSharesClientRestoreResponse{RawResponse: resp}, nil
}
// restoreCreateRequest creates the Restore request.
func (client *FileSharesClient) restoreCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, deletedShare DeletedShare, options *FileSharesClientRestoreOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"
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 shareName == "" {
return nil, errors.New("parameter shareName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName))
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, deletedShare)
}
// Update - Updates share properties as specified in request body. Properties not mentioned in the request will not be changed.
// Update fails if the specified share does not already exist.
// 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.
// shareName - The name of the file share within the specified storage account. File share names must be between 3 and 63
// characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-)
// character must be immediately preceded and followed by a letter or number.
// fileShare - Properties to update for the file share.
// options - FileSharesClientUpdateOptions contains the optional parameters for the FileSharesClient.Update method.
func (client *FileSharesClient) Update(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesClientUpdateOptions) (FileSharesClientUpdateResponse, error) {
req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, shareName, fileShare, options)
if err != nil {
return FileSharesClientUpdateResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return FileSharesClientUpdateResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return FileSharesClientUpdateResponse{}, runtime.NewResponseError(resp)
}
return client.updateHandleResponse(resp)
}
// updateCreateRequest creates the Update request.
func (client *FileSharesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesClientUpdateOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"
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 shareName == "" {
return nil, errors.New("parameter shareName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName))
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, fileShare)
}
// updateHandleResponse handles the Update response.
func (client *FileSharesClient) updateHandleResponse(resp *http.Response) (FileSharesClientUpdateResponse, error) {
result := FileSharesClientUpdateResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.FileShare); err != nil {
return FileSharesClientUpdateResponse{}, err
}
return result, nil
}