1package storage 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// FileSharesClient is the the Azure Storage Management API. 19type FileSharesClient struct { 20 BaseClient 21} 22 23// NewFileSharesClient creates an instance of the FileSharesClient client. 24func NewFileSharesClient(subscriptionID string) FileSharesClient { 25 return NewFileSharesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewFileSharesClientWithBaseURI creates an instance of the FileSharesClient client using a custom endpoint. Use this 29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewFileSharesClientWithBaseURI(baseURI string, subscriptionID string) FileSharesClient { 31 return FileSharesClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// Create creates a new share under the specified account as described by request body. The share resource includes 35// metadata and properties for that share. It does not include a list of the files contained by the share. 36// Parameters: 37// resourceGroupName - the name of the resource group within the user's subscription. The name is case 38// insensitive. 39// accountName - the name of the storage account within the specified resource group. Storage account names 40// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 41// shareName - the name of the file share within the specified storage account. File share names must be 42// between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) 43// character must be immediately preceded and followed by a letter or number. 44// fileShare - properties of the file share to create. 45func (client FileSharesClient) Create(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare) (result FileShare, err error) { 46 if tracing.IsEnabled() { 47 ctx = tracing.StartSpan(ctx, fqdn+"/FileSharesClient.Create") 48 defer func() { 49 sc := -1 50 if result.Response.Response != nil { 51 sc = result.Response.Response.StatusCode 52 } 53 tracing.EndSpan(ctx, sc, err) 54 }() 55 } 56 if err := validation.Validate([]validation.Validation{ 57 {TargetValue: resourceGroupName, 58 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 59 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 60 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 61 {TargetValue: accountName, 62 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 63 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 64 {TargetValue: shareName, 65 Constraints: []validation.Constraint{{Target: "shareName", Name: validation.MaxLength, Rule: 63, Chain: nil}, 66 {Target: "shareName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 67 {TargetValue: fileShare, 68 Constraints: []validation.Constraint{{Target: "fileShare.FileShareProperties", Name: validation.Null, Rule: false, 69 Chain: []validation.Constraint{{Target: "fileShare.FileShareProperties.ShareQuota", Name: validation.Null, Rule: false, 70 Chain: []validation.Constraint{{Target: "fileShare.FileShareProperties.ShareQuota", Name: validation.InclusiveMaximum, Rule: int64(102400), Chain: nil}, 71 {Target: "fileShare.FileShareProperties.ShareQuota", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 72 }}, 73 }}}}, 74 {TargetValue: client.SubscriptionID, 75 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 76 return result, validation.NewError("storage.FileSharesClient", "Create", err.Error()) 77 } 78 79 req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, shareName, fileShare) 80 if err != nil { 81 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Create", nil, "Failure preparing request") 82 return 83 } 84 85 resp, err := client.CreateSender(req) 86 if err != nil { 87 result.Response = autorest.Response{Response: resp} 88 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Create", resp, "Failure sending request") 89 return 90 } 91 92 result, err = client.CreateResponder(resp) 93 if err != nil { 94 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Create", resp, "Failure responding to request") 95 return 96 } 97 98 return 99} 100 101// CreatePreparer prepares the Create request. 102func (client FileSharesClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare) (*http.Request, error) { 103 pathParameters := map[string]interface{}{ 104 "accountName": autorest.Encode("path", accountName), 105 "resourceGroupName": autorest.Encode("path", resourceGroupName), 106 "shareName": autorest.Encode("path", shareName), 107 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 108 } 109 110 const APIVersion = "2019-06-01" 111 queryParameters := map[string]interface{}{ 112 "api-version": APIVersion, 113 } 114 115 preparer := autorest.CreatePreparer( 116 autorest.AsContentType("application/json; charset=utf-8"), 117 autorest.AsPut(), 118 autorest.WithBaseURL(client.BaseURI), 119 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", pathParameters), 120 autorest.WithJSON(fileShare), 121 autorest.WithQueryParameters(queryParameters)) 122 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 123} 124 125// CreateSender sends the Create request. The method will close the 126// http.Response Body if it receives an error. 127func (client FileSharesClient) CreateSender(req *http.Request) (*http.Response, error) { 128 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 129} 130 131// CreateResponder handles the response to the Create request. The method always 132// closes the http.Response Body. 133func (client FileSharesClient) CreateResponder(resp *http.Response) (result FileShare, err error) { 134 err = autorest.Respond( 135 resp, 136 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 137 autorest.ByUnmarshallingJSON(&result), 138 autorest.ByClosing()) 139 result.Response = autorest.Response{Response: resp} 140 return 141} 142 143// Delete deletes specified share under its account. 144// Parameters: 145// resourceGroupName - the name of the resource group within the user's subscription. The name is case 146// insensitive. 147// accountName - the name of the storage account within the specified resource group. Storage account names 148// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 149// shareName - the name of the file share within the specified storage account. File share names must be 150// between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) 151// character must be immediately preceded and followed by a letter or number. 152func (client FileSharesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, shareName string) (result autorest.Response, err error) { 153 if tracing.IsEnabled() { 154 ctx = tracing.StartSpan(ctx, fqdn+"/FileSharesClient.Delete") 155 defer func() { 156 sc := -1 157 if result.Response != nil { 158 sc = result.Response.StatusCode 159 } 160 tracing.EndSpan(ctx, sc, err) 161 }() 162 } 163 if err := validation.Validate([]validation.Validation{ 164 {TargetValue: resourceGroupName, 165 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 166 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 167 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 168 {TargetValue: accountName, 169 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 170 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 171 {TargetValue: shareName, 172 Constraints: []validation.Constraint{{Target: "shareName", Name: validation.MaxLength, Rule: 63, Chain: nil}, 173 {Target: "shareName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 174 {TargetValue: client.SubscriptionID, 175 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 176 return result, validation.NewError("storage.FileSharesClient", "Delete", err.Error()) 177 } 178 179 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, shareName) 180 if err != nil { 181 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Delete", nil, "Failure preparing request") 182 return 183 } 184 185 resp, err := client.DeleteSender(req) 186 if err != nil { 187 result.Response = resp 188 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Delete", resp, "Failure sending request") 189 return 190 } 191 192 result, err = client.DeleteResponder(resp) 193 if err != nil { 194 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Delete", resp, "Failure responding to request") 195 return 196 } 197 198 return 199} 200 201// DeletePreparer prepares the Delete request. 202func (client FileSharesClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, shareName string) (*http.Request, error) { 203 pathParameters := map[string]interface{}{ 204 "accountName": autorest.Encode("path", accountName), 205 "resourceGroupName": autorest.Encode("path", resourceGroupName), 206 "shareName": autorest.Encode("path", shareName), 207 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 208 } 209 210 const APIVersion = "2019-06-01" 211 queryParameters := map[string]interface{}{ 212 "api-version": APIVersion, 213 } 214 215 preparer := autorest.CreatePreparer( 216 autorest.AsDelete(), 217 autorest.WithBaseURL(client.BaseURI), 218 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", pathParameters), 219 autorest.WithQueryParameters(queryParameters)) 220 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 221} 222 223// DeleteSender sends the Delete request. The method will close the 224// http.Response Body if it receives an error. 225func (client FileSharesClient) DeleteSender(req *http.Request) (*http.Response, error) { 226 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 227} 228 229// DeleteResponder handles the response to the Delete request. The method always 230// closes the http.Response Body. 231func (client FileSharesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 232 err = autorest.Respond( 233 resp, 234 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 235 autorest.ByClosing()) 236 result.Response = resp 237 return 238} 239 240// Get gets properties of a specified share. 241// Parameters: 242// resourceGroupName - the name of the resource group within the user's subscription. The name is case 243// insensitive. 244// accountName - the name of the storage account within the specified resource group. Storage account names 245// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 246// shareName - the name of the file share within the specified storage account. File share names must be 247// between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) 248// character must be immediately preceded and followed by a letter or number. 249// expand - optional, used to expand the properties within share's properties. 250func (client FileSharesClient) Get(ctx context.Context, resourceGroupName string, accountName string, shareName string, expand GetShareExpand) (result FileShare, err error) { 251 if tracing.IsEnabled() { 252 ctx = tracing.StartSpan(ctx, fqdn+"/FileSharesClient.Get") 253 defer func() { 254 sc := -1 255 if result.Response.Response != nil { 256 sc = result.Response.Response.StatusCode 257 } 258 tracing.EndSpan(ctx, sc, err) 259 }() 260 } 261 if err := validation.Validate([]validation.Validation{ 262 {TargetValue: resourceGroupName, 263 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 264 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 265 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 266 {TargetValue: accountName, 267 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 268 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 269 {TargetValue: shareName, 270 Constraints: []validation.Constraint{{Target: "shareName", Name: validation.MaxLength, Rule: 63, Chain: nil}, 271 {Target: "shareName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 272 {TargetValue: client.SubscriptionID, 273 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 274 return result, validation.NewError("storage.FileSharesClient", "Get", err.Error()) 275 } 276 277 req, err := client.GetPreparer(ctx, resourceGroupName, accountName, shareName, expand) 278 if err != nil { 279 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Get", nil, "Failure preparing request") 280 return 281 } 282 283 resp, err := client.GetSender(req) 284 if err != nil { 285 result.Response = autorest.Response{Response: resp} 286 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Get", resp, "Failure sending request") 287 return 288 } 289 290 result, err = client.GetResponder(resp) 291 if err != nil { 292 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Get", resp, "Failure responding to request") 293 return 294 } 295 296 return 297} 298 299// GetPreparer prepares the Get request. 300func (client FileSharesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, shareName string, expand GetShareExpand) (*http.Request, error) { 301 pathParameters := map[string]interface{}{ 302 "accountName": autorest.Encode("path", accountName), 303 "resourceGroupName": autorest.Encode("path", resourceGroupName), 304 "shareName": autorest.Encode("path", shareName), 305 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 306 } 307 308 const APIVersion = "2019-06-01" 309 queryParameters := map[string]interface{}{ 310 "api-version": APIVersion, 311 } 312 if len(string(expand)) > 0 { 313 queryParameters["$expand"] = autorest.Encode("query", expand) 314 } 315 316 preparer := autorest.CreatePreparer( 317 autorest.AsGet(), 318 autorest.WithBaseURL(client.BaseURI), 319 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", pathParameters), 320 autorest.WithQueryParameters(queryParameters)) 321 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 322} 323 324// GetSender sends the Get request. The method will close the 325// http.Response Body if it receives an error. 326func (client FileSharesClient) GetSender(req *http.Request) (*http.Response, error) { 327 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 328} 329 330// GetResponder handles the response to the Get request. The method always 331// closes the http.Response Body. 332func (client FileSharesClient) GetResponder(resp *http.Response) (result FileShare, err error) { 333 err = autorest.Respond( 334 resp, 335 azure.WithErrorUnlessStatusCode(http.StatusOK), 336 autorest.ByUnmarshallingJSON(&result), 337 autorest.ByClosing()) 338 result.Response = autorest.Response{Response: resp} 339 return 340} 341 342// List lists all shares. 343// Parameters: 344// resourceGroupName - the name of the resource group within the user's subscription. The name is case 345// insensitive. 346// accountName - the name of the storage account within the specified resource group. Storage account names 347// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 348// maxpagesize - optional. Specified maximum number of shares that can be included in the list. 349// filter - optional. When specified, only share names starting with the filter will be listed. 350// expand - optional, used to expand the properties within share's properties. 351func (client FileSharesClient) List(ctx context.Context, resourceGroupName string, accountName string, maxpagesize string, filter string, expand ListSharesExpand) (result FileShareItemsPage, err error) { 352 if tracing.IsEnabled() { 353 ctx = tracing.StartSpan(ctx, fqdn+"/FileSharesClient.List") 354 defer func() { 355 sc := -1 356 if result.fsi.Response.Response != nil { 357 sc = result.fsi.Response.Response.StatusCode 358 } 359 tracing.EndSpan(ctx, sc, err) 360 }() 361 } 362 if err := validation.Validate([]validation.Validation{ 363 {TargetValue: resourceGroupName, 364 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 365 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 366 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 367 {TargetValue: accountName, 368 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 369 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 370 {TargetValue: client.SubscriptionID, 371 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 372 return result, validation.NewError("storage.FileSharesClient", "List", err.Error()) 373 } 374 375 result.fn = client.listNextResults 376 req, err := client.ListPreparer(ctx, resourceGroupName, accountName, maxpagesize, filter, expand) 377 if err != nil { 378 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "List", nil, "Failure preparing request") 379 return 380 } 381 382 resp, err := client.ListSender(req) 383 if err != nil { 384 result.fsi.Response = autorest.Response{Response: resp} 385 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "List", resp, "Failure sending request") 386 return 387 } 388 389 result.fsi, err = client.ListResponder(resp) 390 if err != nil { 391 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "List", resp, "Failure responding to request") 392 return 393 } 394 if result.fsi.hasNextLink() && result.fsi.IsEmpty() { 395 err = result.NextWithContext(ctx) 396 return 397 } 398 399 return 400} 401 402// ListPreparer prepares the List request. 403func (client FileSharesClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, maxpagesize string, filter string, expand ListSharesExpand) (*http.Request, error) { 404 pathParameters := map[string]interface{}{ 405 "accountName": autorest.Encode("path", accountName), 406 "resourceGroupName": autorest.Encode("path", resourceGroupName), 407 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 408 } 409 410 const APIVersion = "2019-06-01" 411 queryParameters := map[string]interface{}{ 412 "api-version": APIVersion, 413 } 414 if len(maxpagesize) > 0 { 415 queryParameters["$maxpagesize"] = autorest.Encode("query", maxpagesize) 416 } 417 if len(filter) > 0 { 418 queryParameters["$filter"] = autorest.Encode("query", filter) 419 } 420 if len(string(expand)) > 0 { 421 queryParameters["$expand"] = autorest.Encode("query", expand) 422 } 423 424 preparer := autorest.CreatePreparer( 425 autorest.AsGet(), 426 autorest.WithBaseURL(client.BaseURI), 427 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", pathParameters), 428 autorest.WithQueryParameters(queryParameters)) 429 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 430} 431 432// ListSender sends the List request. The method will close the 433// http.Response Body if it receives an error. 434func (client FileSharesClient) ListSender(req *http.Request) (*http.Response, error) { 435 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 436} 437 438// ListResponder handles the response to the List request. The method always 439// closes the http.Response Body. 440func (client FileSharesClient) ListResponder(resp *http.Response) (result FileShareItems, err error) { 441 err = autorest.Respond( 442 resp, 443 azure.WithErrorUnlessStatusCode(http.StatusOK), 444 autorest.ByUnmarshallingJSON(&result), 445 autorest.ByClosing()) 446 result.Response = autorest.Response{Response: resp} 447 return 448} 449 450// listNextResults retrieves the next set of results, if any. 451func (client FileSharesClient) listNextResults(ctx context.Context, lastResults FileShareItems) (result FileShareItems, err error) { 452 req, err := lastResults.fileShareItemsPreparer(ctx) 453 if err != nil { 454 return result, autorest.NewErrorWithError(err, "storage.FileSharesClient", "listNextResults", nil, "Failure preparing next results request") 455 } 456 if req == nil { 457 return 458 } 459 resp, err := client.ListSender(req) 460 if err != nil { 461 result.Response = autorest.Response{Response: resp} 462 return result, autorest.NewErrorWithError(err, "storage.FileSharesClient", "listNextResults", resp, "Failure sending next results request") 463 } 464 result, err = client.ListResponder(resp) 465 if err != nil { 466 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "listNextResults", resp, "Failure responding to next results request") 467 } 468 return 469} 470 471// ListComplete enumerates all values, automatically crossing page boundaries as required. 472func (client FileSharesClient) ListComplete(ctx context.Context, resourceGroupName string, accountName string, maxpagesize string, filter string, expand ListSharesExpand) (result FileShareItemsIterator, err error) { 473 if tracing.IsEnabled() { 474 ctx = tracing.StartSpan(ctx, fqdn+"/FileSharesClient.List") 475 defer func() { 476 sc := -1 477 if result.Response().Response.Response != nil { 478 sc = result.page.Response().Response.Response.StatusCode 479 } 480 tracing.EndSpan(ctx, sc, err) 481 }() 482 } 483 result.page, err = client.List(ctx, resourceGroupName, accountName, maxpagesize, filter, expand) 484 return 485} 486 487// Restore restore a file share within a valid retention days if share soft delete is enabled 488// Parameters: 489// resourceGroupName - the name of the resource group within the user's subscription. The name is case 490// insensitive. 491// accountName - the name of the storage account within the specified resource group. Storage account names 492// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 493// shareName - the name of the file share within the specified storage account. File share names must be 494// between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) 495// character must be immediately preceded and followed by a letter or number. 496func (client FileSharesClient) Restore(ctx context.Context, resourceGroupName string, accountName string, shareName string, deletedShare DeletedShare) (result autorest.Response, err error) { 497 if tracing.IsEnabled() { 498 ctx = tracing.StartSpan(ctx, fqdn+"/FileSharesClient.Restore") 499 defer func() { 500 sc := -1 501 if result.Response != nil { 502 sc = result.Response.StatusCode 503 } 504 tracing.EndSpan(ctx, sc, err) 505 }() 506 } 507 if err := validation.Validate([]validation.Validation{ 508 {TargetValue: resourceGroupName, 509 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 510 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 511 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 512 {TargetValue: accountName, 513 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 514 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 515 {TargetValue: shareName, 516 Constraints: []validation.Constraint{{Target: "shareName", Name: validation.MaxLength, Rule: 63, Chain: nil}, 517 {Target: "shareName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 518 {TargetValue: deletedShare, 519 Constraints: []validation.Constraint{{Target: "deletedShare.DeletedShareName", Name: validation.Null, Rule: true, Chain: nil}, 520 {Target: "deletedShare.DeletedShareVersion", Name: validation.Null, Rule: true, Chain: nil}}}, 521 {TargetValue: client.SubscriptionID, 522 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 523 return result, validation.NewError("storage.FileSharesClient", "Restore", err.Error()) 524 } 525 526 req, err := client.RestorePreparer(ctx, resourceGroupName, accountName, shareName, deletedShare) 527 if err != nil { 528 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Restore", nil, "Failure preparing request") 529 return 530 } 531 532 resp, err := client.RestoreSender(req) 533 if err != nil { 534 result.Response = resp 535 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Restore", resp, "Failure sending request") 536 return 537 } 538 539 result, err = client.RestoreResponder(resp) 540 if err != nil { 541 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Restore", resp, "Failure responding to request") 542 return 543 } 544 545 return 546} 547 548// RestorePreparer prepares the Restore request. 549func (client FileSharesClient) RestorePreparer(ctx context.Context, resourceGroupName string, accountName string, shareName string, deletedShare DeletedShare) (*http.Request, error) { 550 pathParameters := map[string]interface{}{ 551 "accountName": autorest.Encode("path", accountName), 552 "resourceGroupName": autorest.Encode("path", resourceGroupName), 553 "shareName": autorest.Encode("path", shareName), 554 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 555 } 556 557 const APIVersion = "2019-06-01" 558 queryParameters := map[string]interface{}{ 559 "api-version": APIVersion, 560 } 561 562 preparer := autorest.CreatePreparer( 563 autorest.AsContentType("application/json; charset=utf-8"), 564 autorest.AsPost(), 565 autorest.WithBaseURL(client.BaseURI), 566 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", pathParameters), 567 autorest.WithJSON(deletedShare), 568 autorest.WithQueryParameters(queryParameters)) 569 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 570} 571 572// RestoreSender sends the Restore request. The method will close the 573// http.Response Body if it receives an error. 574func (client FileSharesClient) RestoreSender(req *http.Request) (*http.Response, error) { 575 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 576} 577 578// RestoreResponder handles the response to the Restore request. The method always 579// closes the http.Response Body. 580func (client FileSharesClient) RestoreResponder(resp *http.Response) (result autorest.Response, err error) { 581 err = autorest.Respond( 582 resp, 583 azure.WithErrorUnlessStatusCode(http.StatusOK), 584 autorest.ByClosing()) 585 result.Response = resp 586 return 587} 588 589// Update updates share properties as specified in request body. Properties not mentioned in the request will not be 590// changed. Update fails if the specified share does not already exist. 591// Parameters: 592// resourceGroupName - the name of the resource group within the user's subscription. The name is case 593// insensitive. 594// accountName - the name of the storage account within the specified resource group. Storage account names 595// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 596// shareName - the name of the file share within the specified storage account. File share names must be 597// between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) 598// character must be immediately preceded and followed by a letter or number. 599// fileShare - properties to update for the file share. 600func (client FileSharesClient) Update(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare) (result FileShare, err error) { 601 if tracing.IsEnabled() { 602 ctx = tracing.StartSpan(ctx, fqdn+"/FileSharesClient.Update") 603 defer func() { 604 sc := -1 605 if result.Response.Response != nil { 606 sc = result.Response.Response.StatusCode 607 } 608 tracing.EndSpan(ctx, sc, err) 609 }() 610 } 611 if err := validation.Validate([]validation.Validation{ 612 {TargetValue: resourceGroupName, 613 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 614 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 615 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 616 {TargetValue: accountName, 617 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 618 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 619 {TargetValue: shareName, 620 Constraints: []validation.Constraint{{Target: "shareName", Name: validation.MaxLength, Rule: 63, Chain: nil}, 621 {Target: "shareName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 622 {TargetValue: client.SubscriptionID, 623 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 624 return result, validation.NewError("storage.FileSharesClient", "Update", err.Error()) 625 } 626 627 req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, shareName, fileShare) 628 if err != nil { 629 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Update", nil, "Failure preparing request") 630 return 631 } 632 633 resp, err := client.UpdateSender(req) 634 if err != nil { 635 result.Response = autorest.Response{Response: resp} 636 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Update", resp, "Failure sending request") 637 return 638 } 639 640 result, err = client.UpdateResponder(resp) 641 if err != nil { 642 err = autorest.NewErrorWithError(err, "storage.FileSharesClient", "Update", resp, "Failure responding to request") 643 return 644 } 645 646 return 647} 648 649// UpdatePreparer prepares the Update request. 650func (client FileSharesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare) (*http.Request, error) { 651 pathParameters := map[string]interface{}{ 652 "accountName": autorest.Encode("path", accountName), 653 "resourceGroupName": autorest.Encode("path", resourceGroupName), 654 "shareName": autorest.Encode("path", shareName), 655 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 656 } 657 658 const APIVersion = "2019-06-01" 659 queryParameters := map[string]interface{}{ 660 "api-version": APIVersion, 661 } 662 663 preparer := autorest.CreatePreparer( 664 autorest.AsContentType("application/json; charset=utf-8"), 665 autorest.AsPatch(), 666 autorest.WithBaseURL(client.BaseURI), 667 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", pathParameters), 668 autorest.WithJSON(fileShare), 669 autorest.WithQueryParameters(queryParameters)) 670 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 671} 672 673// UpdateSender sends the Update request. The method will close the 674// http.Response Body if it receives an error. 675func (client FileSharesClient) UpdateSender(req *http.Request) (*http.Response, error) { 676 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 677} 678 679// UpdateResponder handles the response to the Update request. The method always 680// closes the http.Response Body. 681func (client FileSharesClient) UpdateResponder(resp *http.Response) (result FileShare, err error) { 682 err = autorest.Respond( 683 resp, 684 azure.WithErrorUnlessStatusCode(http.StatusOK), 685 autorest.ByUnmarshallingJSON(&result), 686 autorest.ByClosing()) 687 result.Response = autorest.Response{Response: resp} 688 return 689} 690