1package storage 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/autorest/validation" 25 "net/http" 26) 27 28// AccountsClient is the the Azure Storage Management API. 29type AccountsClient struct { 30 BaseClient 31} 32 33// NewAccountsClient creates an instance of the AccountsClient client. 34func NewAccountsClient(subscriptionID string) AccountsClient { 35 return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewAccountsClientWithBaseURI creates an instance of the AccountsClient client. 39func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { 40 return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)} 41} 42 43// CheckNameAvailability checks that the storage account name is valid and is not already in use. 44// Parameters: 45// accountName - the name of the storage account within the specified resource group. Storage account names 46// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 47func (client AccountsClient) CheckNameAvailability(ctx context.Context, accountName AccountCheckNameAvailabilityParameters) (result CheckNameAvailabilityResult, err error) { 48 if err := validation.Validate([]validation.Validation{ 49 {TargetValue: accountName, 50 Constraints: []validation.Constraint{{Target: "accountName.Name", Name: validation.Null, Rule: true, Chain: nil}, 51 {Target: "accountName.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 52 return result, validation.NewError("storage.AccountsClient", "CheckNameAvailability", err.Error()) 53 } 54 55 req, err := client.CheckNameAvailabilityPreparer(ctx, accountName) 56 if err != nil { 57 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", nil, "Failure preparing request") 58 return 59 } 60 61 resp, err := client.CheckNameAvailabilitySender(req) 62 if err != nil { 63 result.Response = autorest.Response{Response: resp} 64 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", resp, "Failure sending request") 65 return 66 } 67 68 result, err = client.CheckNameAvailabilityResponder(resp) 69 if err != nil { 70 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", resp, "Failure responding to request") 71 } 72 73 return 74} 75 76// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. 77func (client AccountsClient) CheckNameAvailabilityPreparer(ctx context.Context, accountName AccountCheckNameAvailabilityParameters) (*http.Request, error) { 78 pathParameters := map[string]interface{}{ 79 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 80 } 81 82 const APIVersion = "2017-06-01" 83 queryParameters := map[string]interface{}{ 84 "api-version": APIVersion, 85 } 86 87 preparer := autorest.CreatePreparer( 88 autorest.AsContentType("application/json; charset=utf-8"), 89 autorest.AsPost(), 90 autorest.WithBaseURL(client.BaseURI), 91 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability", pathParameters), 92 autorest.WithJSON(accountName), 93 autorest.WithQueryParameters(queryParameters)) 94 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 95} 96 97// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the 98// http.Response Body if it receives an error. 99func (client AccountsClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { 100 return autorest.SendWithSender(client, req, 101 azure.DoRetryWithRegistration(client.Client)) 102} 103 104// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always 105// closes the http.Response Body. 106func (client AccountsClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { 107 err = autorest.Respond( 108 resp, 109 client.ByInspecting(), 110 azure.WithErrorUnlessStatusCode(http.StatusOK), 111 autorest.ByUnmarshallingJSON(&result), 112 autorest.ByClosing()) 113 result.Response = autorest.Response{Response: resp} 114 return 115} 116 117// Create asynchronously creates a new storage account with the specified parameters. If an account is already created 118// and a subsequent create request is issued with different properties, the account properties will be updated. If an 119// account is already created and a subsequent create or update request is issued with the exact same set of 120// properties, the request will succeed. 121// Parameters: 122// resourceGroupName - the name of the resource group within the user's subscription. The name is case 123// insensitive. 124// accountName - the name of the storage account within the specified resource group. Storage account names 125// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 126// parameters - the parameters to provide for the created account. 127func (client AccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters) (result AccountsCreateFuture, err error) { 128 if err := validation.Validate([]validation.Validation{ 129 {TargetValue: resourceGroupName, 130 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 131 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 132 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 133 {TargetValue: accountName, 134 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 135 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 136 {TargetValue: parameters, 137 Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: true, Chain: nil}, 138 {Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}, 139 {Target: "parameters.Identity", Name: validation.Null, Rule: false, 140 Chain: []validation.Constraint{{Target: "parameters.Identity.Type", Name: validation.Null, Rule: true, Chain: nil}}}, 141 {Target: "parameters.AccountPropertiesCreateParameters", Name: validation.Null, Rule: false, 142 Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.CustomDomain", Name: validation.Null, Rule: false, 143 Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.CustomDomain.Name", Name: validation.Null, Rule: true, Chain: nil}}}, 144 }}}}}); err != nil { 145 return result, validation.NewError("storage.AccountsClient", "Create", err.Error()) 146 } 147 148 req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, parameters) 149 if err != nil { 150 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", nil, "Failure preparing request") 151 return 152 } 153 154 result, err = client.CreateSender(req) 155 if err != nil { 156 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", result.Response(), "Failure sending request") 157 return 158 } 159 160 return 161} 162 163// CreatePreparer prepares the Create request. 164func (client AccountsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters) (*http.Request, error) { 165 pathParameters := map[string]interface{}{ 166 "accountName": autorest.Encode("path", accountName), 167 "resourceGroupName": autorest.Encode("path", resourceGroupName), 168 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 169 } 170 171 const APIVersion = "2017-06-01" 172 queryParameters := map[string]interface{}{ 173 "api-version": APIVersion, 174 } 175 176 preparer := autorest.CreatePreparer( 177 autorest.AsContentType("application/json; charset=utf-8"), 178 autorest.AsPut(), 179 autorest.WithBaseURL(client.BaseURI), 180 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 181 autorest.WithJSON(parameters), 182 autorest.WithQueryParameters(queryParameters)) 183 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 184} 185 186// CreateSender sends the Create request. The method will close the 187// http.Response Body if it receives an error. 188func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCreateFuture, err error) { 189 var resp *http.Response 190 resp, err = autorest.SendWithSender(client, req, 191 azure.DoRetryWithRegistration(client.Client)) 192 if err != nil { 193 return 194 } 195 err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) 196 if err != nil { 197 return 198 } 199 future.Future, err = azure.NewFutureFromResponse(resp) 200 return 201} 202 203// CreateResponder handles the response to the Create request. The method always 204// closes the http.Response Body. 205func (client AccountsClient) CreateResponder(resp *http.Response) (result Account, err error) { 206 err = autorest.Respond( 207 resp, 208 client.ByInspecting(), 209 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 210 autorest.ByUnmarshallingJSON(&result), 211 autorest.ByClosing()) 212 result.Response = autorest.Response{Response: resp} 213 return 214} 215 216// Delete deletes a storage account in Microsoft Azure. 217// Parameters: 218// resourceGroupName - the name of the resource group within the user's subscription. The name is case 219// insensitive. 220// accountName - the name of the storage account within the specified resource group. Storage account names 221// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 222func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result autorest.Response, err error) { 223 if err := validation.Validate([]validation.Validation{ 224 {TargetValue: resourceGroupName, 225 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 226 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 227 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 228 {TargetValue: accountName, 229 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 230 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { 231 return result, validation.NewError("storage.AccountsClient", "Delete", err.Error()) 232 } 233 234 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) 235 if err != nil { 236 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", nil, "Failure preparing request") 237 return 238 } 239 240 resp, err := client.DeleteSender(req) 241 if err != nil { 242 result.Response = resp 243 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", resp, "Failure sending request") 244 return 245 } 246 247 result, err = client.DeleteResponder(resp) 248 if err != nil { 249 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", resp, "Failure responding to request") 250 } 251 252 return 253} 254 255// DeletePreparer prepares the Delete request. 256func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 257 pathParameters := map[string]interface{}{ 258 "accountName": autorest.Encode("path", accountName), 259 "resourceGroupName": autorest.Encode("path", resourceGroupName), 260 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 261 } 262 263 const APIVersion = "2017-06-01" 264 queryParameters := map[string]interface{}{ 265 "api-version": APIVersion, 266 } 267 268 preparer := autorest.CreatePreparer( 269 autorest.AsDelete(), 270 autorest.WithBaseURL(client.BaseURI), 271 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 272 autorest.WithQueryParameters(queryParameters)) 273 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 274} 275 276// DeleteSender sends the Delete request. The method will close the 277// http.Response Body if it receives an error. 278func (client AccountsClient) DeleteSender(req *http.Request) (*http.Response, error) { 279 return autorest.SendWithSender(client, req, 280 azure.DoRetryWithRegistration(client.Client)) 281} 282 283// DeleteResponder handles the response to the Delete request. The method always 284// closes the http.Response Body. 285func (client AccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 286 err = autorest.Respond( 287 resp, 288 client.ByInspecting(), 289 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 290 autorest.ByClosing()) 291 result.Response = resp 292 return 293} 294 295// GetProperties returns the properties for the specified storage account including but not limited to name, SKU name, 296// location, and account status. The ListKeys operation should be used to retrieve storage keys. 297// Parameters: 298// resourceGroupName - the name of the resource group within the user's subscription. The name is case 299// insensitive. 300// accountName - the name of the storage account within the specified resource group. Storage account names 301// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 302func (client AccountsClient) GetProperties(ctx context.Context, resourceGroupName string, accountName string) (result Account, err error) { 303 if err := validation.Validate([]validation.Validation{ 304 {TargetValue: resourceGroupName, 305 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 306 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 307 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 308 {TargetValue: accountName, 309 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 310 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { 311 return result, validation.NewError("storage.AccountsClient", "GetProperties", err.Error()) 312 } 313 314 req, err := client.GetPropertiesPreparer(ctx, resourceGroupName, accountName) 315 if err != nil { 316 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", nil, "Failure preparing request") 317 return 318 } 319 320 resp, err := client.GetPropertiesSender(req) 321 if err != nil { 322 result.Response = autorest.Response{Response: resp} 323 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", resp, "Failure sending request") 324 return 325 } 326 327 result, err = client.GetPropertiesResponder(resp) 328 if err != nil { 329 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", resp, "Failure responding to request") 330 } 331 332 return 333} 334 335// GetPropertiesPreparer prepares the GetProperties request. 336func (client AccountsClient) GetPropertiesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 337 pathParameters := map[string]interface{}{ 338 "accountName": autorest.Encode("path", accountName), 339 "resourceGroupName": autorest.Encode("path", resourceGroupName), 340 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 341 } 342 343 const APIVersion = "2017-06-01" 344 queryParameters := map[string]interface{}{ 345 "api-version": APIVersion, 346 } 347 348 preparer := autorest.CreatePreparer( 349 autorest.AsGet(), 350 autorest.WithBaseURL(client.BaseURI), 351 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 352 autorest.WithQueryParameters(queryParameters)) 353 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 354} 355 356// GetPropertiesSender sends the GetProperties request. The method will close the 357// http.Response Body if it receives an error. 358func (client AccountsClient) GetPropertiesSender(req *http.Request) (*http.Response, error) { 359 return autorest.SendWithSender(client, req, 360 azure.DoRetryWithRegistration(client.Client)) 361} 362 363// GetPropertiesResponder handles the response to the GetProperties request. The method always 364// closes the http.Response Body. 365func (client AccountsClient) GetPropertiesResponder(resp *http.Response) (result Account, err error) { 366 err = autorest.Respond( 367 resp, 368 client.ByInspecting(), 369 azure.WithErrorUnlessStatusCode(http.StatusOK), 370 autorest.ByUnmarshallingJSON(&result), 371 autorest.ByClosing()) 372 result.Response = autorest.Response{Response: resp} 373 return 374} 375 376// List lists all the storage accounts available under the subscription. Note that storage keys are not returned; use 377// the ListKeys operation for this. 378func (client AccountsClient) List(ctx context.Context) (result AccountListResult, err error) { 379 req, err := client.ListPreparer(ctx) 380 if err != nil { 381 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", nil, "Failure preparing request") 382 return 383 } 384 385 resp, err := client.ListSender(req) 386 if err != nil { 387 result.Response = autorest.Response{Response: resp} 388 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", resp, "Failure sending request") 389 return 390 } 391 392 result, err = client.ListResponder(resp) 393 if err != nil { 394 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", resp, "Failure responding to request") 395 } 396 397 return 398} 399 400// ListPreparer prepares the List request. 401func (client AccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) { 402 pathParameters := map[string]interface{}{ 403 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 404 } 405 406 const APIVersion = "2017-06-01" 407 queryParameters := map[string]interface{}{ 408 "api-version": APIVersion, 409 } 410 411 preparer := autorest.CreatePreparer( 412 autorest.AsGet(), 413 autorest.WithBaseURL(client.BaseURI), 414 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts", pathParameters), 415 autorest.WithQueryParameters(queryParameters)) 416 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 417} 418 419// ListSender sends the List request. The method will close the 420// http.Response Body if it receives an error. 421func (client AccountsClient) ListSender(req *http.Request) (*http.Response, error) { 422 return autorest.SendWithSender(client, req, 423 azure.DoRetryWithRegistration(client.Client)) 424} 425 426// ListResponder handles the response to the List request. The method always 427// closes the http.Response Body. 428func (client AccountsClient) ListResponder(resp *http.Response) (result AccountListResult, err error) { 429 err = autorest.Respond( 430 resp, 431 client.ByInspecting(), 432 azure.WithErrorUnlessStatusCode(http.StatusOK), 433 autorest.ByUnmarshallingJSON(&result), 434 autorest.ByClosing()) 435 result.Response = autorest.Response{Response: resp} 436 return 437} 438 439// ListAccountSAS list SAS credentials of a storage account. 440// Parameters: 441// resourceGroupName - the name of the resource group within the user's subscription. The name is case 442// insensitive. 443// accountName - the name of the storage account within the specified resource group. Storage account names 444// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 445// parameters - the parameters to provide to list SAS credentials for the storage account. 446func (client AccountsClient) ListAccountSAS(ctx context.Context, resourceGroupName string, accountName string, parameters AccountSasParameters) (result ListAccountSasResponse, err error) { 447 if err := validation.Validate([]validation.Validation{ 448 {TargetValue: resourceGroupName, 449 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 450 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 451 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 452 {TargetValue: accountName, 453 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 454 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 455 {TargetValue: parameters, 456 Constraints: []validation.Constraint{{Target: "parameters.SharedAccessExpiryTime", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 457 return result, validation.NewError("storage.AccountsClient", "ListAccountSAS", err.Error()) 458 } 459 460 req, err := client.ListAccountSASPreparer(ctx, resourceGroupName, accountName, parameters) 461 if err != nil { 462 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListAccountSAS", nil, "Failure preparing request") 463 return 464 } 465 466 resp, err := client.ListAccountSASSender(req) 467 if err != nil { 468 result.Response = autorest.Response{Response: resp} 469 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListAccountSAS", resp, "Failure sending request") 470 return 471 } 472 473 result, err = client.ListAccountSASResponder(resp) 474 if err != nil { 475 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListAccountSAS", resp, "Failure responding to request") 476 } 477 478 return 479} 480 481// ListAccountSASPreparer prepares the ListAccountSAS request. 482func (client AccountsClient) ListAccountSASPreparer(ctx context.Context, resourceGroupName string, accountName string, parameters AccountSasParameters) (*http.Request, error) { 483 pathParameters := map[string]interface{}{ 484 "accountName": autorest.Encode("path", accountName), 485 "resourceGroupName": autorest.Encode("path", resourceGroupName), 486 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 487 } 488 489 const APIVersion = "2017-06-01" 490 queryParameters := map[string]interface{}{ 491 "api-version": APIVersion, 492 } 493 494 preparer := autorest.CreatePreparer( 495 autorest.AsContentType("application/json; charset=utf-8"), 496 autorest.AsPost(), 497 autorest.WithBaseURL(client.BaseURI), 498 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", pathParameters), 499 autorest.WithJSON(parameters), 500 autorest.WithQueryParameters(queryParameters)) 501 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 502} 503 504// ListAccountSASSender sends the ListAccountSAS request. The method will close the 505// http.Response Body if it receives an error. 506func (client AccountsClient) ListAccountSASSender(req *http.Request) (*http.Response, error) { 507 return autorest.SendWithSender(client, req, 508 azure.DoRetryWithRegistration(client.Client)) 509} 510 511// ListAccountSASResponder handles the response to the ListAccountSAS request. The method always 512// closes the http.Response Body. 513func (client AccountsClient) ListAccountSASResponder(resp *http.Response) (result ListAccountSasResponse, err error) { 514 err = autorest.Respond( 515 resp, 516 client.ByInspecting(), 517 azure.WithErrorUnlessStatusCode(http.StatusOK), 518 autorest.ByUnmarshallingJSON(&result), 519 autorest.ByClosing()) 520 result.Response = autorest.Response{Response: resp} 521 return 522} 523 524// ListByResourceGroup lists all the storage accounts available under the given resource group. Note that storage keys 525// are not returned; use the ListKeys operation for this. 526// Parameters: 527// resourceGroupName - the name of the resource group within the user's subscription. The name is case 528// insensitive. 529func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AccountListResult, err error) { 530 if err := validation.Validate([]validation.Validation{ 531 {TargetValue: resourceGroupName, 532 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 533 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 534 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 535 return result, validation.NewError("storage.AccountsClient", "ListByResourceGroup", err.Error()) 536 } 537 538 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 539 if err != nil { 540 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") 541 return 542 } 543 544 resp, err := client.ListByResourceGroupSender(req) 545 if err != nil { 546 result.Response = autorest.Response{Response: resp} 547 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") 548 return 549 } 550 551 result, err = client.ListByResourceGroupResponder(resp) 552 if err != nil { 553 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request") 554 } 555 556 return 557} 558 559// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 560func (client AccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 561 pathParameters := map[string]interface{}{ 562 "resourceGroupName": autorest.Encode("path", resourceGroupName), 563 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 564 } 565 566 const APIVersion = "2017-06-01" 567 queryParameters := map[string]interface{}{ 568 "api-version": APIVersion, 569 } 570 571 preparer := autorest.CreatePreparer( 572 autorest.AsGet(), 573 autorest.WithBaseURL(client.BaseURI), 574 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", pathParameters), 575 autorest.WithQueryParameters(queryParameters)) 576 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 577} 578 579// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 580// http.Response Body if it receives an error. 581func (client AccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 582 return autorest.SendWithSender(client, req, 583 azure.DoRetryWithRegistration(client.Client)) 584} 585 586// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 587// closes the http.Response Body. 588func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) { 589 err = autorest.Respond( 590 resp, 591 client.ByInspecting(), 592 azure.WithErrorUnlessStatusCode(http.StatusOK), 593 autorest.ByUnmarshallingJSON(&result), 594 autorest.ByClosing()) 595 result.Response = autorest.Response{Response: resp} 596 return 597} 598 599// ListKeys lists the access keys for the specified storage account. 600// Parameters: 601// resourceGroupName - the name of the resource group within the user's subscription. The name is case 602// insensitive. 603// accountName - the name of the storage account within the specified resource group. Storage account names 604// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 605func (client AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result AccountListKeysResult, err error) { 606 if err := validation.Validate([]validation.Validation{ 607 {TargetValue: resourceGroupName, 608 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 609 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 610 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 611 {TargetValue: accountName, 612 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 613 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { 614 return result, validation.NewError("storage.AccountsClient", "ListKeys", err.Error()) 615 } 616 617 req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName) 618 if err != nil { 619 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", nil, "Failure preparing request") 620 return 621 } 622 623 resp, err := client.ListKeysSender(req) 624 if err != nil { 625 result.Response = autorest.Response{Response: resp} 626 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", resp, "Failure sending request") 627 return 628 } 629 630 result, err = client.ListKeysResponder(resp) 631 if err != nil { 632 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", resp, "Failure responding to request") 633 } 634 635 return 636} 637 638// ListKeysPreparer prepares the ListKeys request. 639func (client AccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 640 pathParameters := map[string]interface{}{ 641 "accountName": autorest.Encode("path", accountName), 642 "resourceGroupName": autorest.Encode("path", resourceGroupName), 643 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 644 } 645 646 const APIVersion = "2017-06-01" 647 queryParameters := map[string]interface{}{ 648 "api-version": APIVersion, 649 } 650 651 preparer := autorest.CreatePreparer( 652 autorest.AsPost(), 653 autorest.WithBaseURL(client.BaseURI), 654 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", pathParameters), 655 autorest.WithQueryParameters(queryParameters)) 656 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 657} 658 659// ListKeysSender sends the ListKeys request. The method will close the 660// http.Response Body if it receives an error. 661func (client AccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) { 662 return autorest.SendWithSender(client, req, 663 azure.DoRetryWithRegistration(client.Client)) 664} 665 666// ListKeysResponder handles the response to the ListKeys request. The method always 667// closes the http.Response Body. 668func (client AccountsClient) ListKeysResponder(resp *http.Response) (result AccountListKeysResult, err error) { 669 err = autorest.Respond( 670 resp, 671 client.ByInspecting(), 672 azure.WithErrorUnlessStatusCode(http.StatusOK), 673 autorest.ByUnmarshallingJSON(&result), 674 autorest.ByClosing()) 675 result.Response = autorest.Response{Response: resp} 676 return 677} 678 679// ListServiceSAS list service SAS credentials of a specific resource. 680// Parameters: 681// resourceGroupName - the name of the resource group within the user's subscription. The name is case 682// insensitive. 683// accountName - the name of the storage account within the specified resource group. Storage account names 684// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 685// parameters - the parameters to provide to list service SAS credentials. 686func (client AccountsClient) ListServiceSAS(ctx context.Context, resourceGroupName string, accountName string, parameters ServiceSasParameters) (result ListServiceSasResponse, err error) { 687 if err := validation.Validate([]validation.Validation{ 688 {TargetValue: resourceGroupName, 689 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 690 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 691 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 692 {TargetValue: accountName, 693 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 694 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 695 {TargetValue: parameters, 696 Constraints: []validation.Constraint{{Target: "parameters.CanonicalizedResource", Name: validation.Null, Rule: true, Chain: nil}, 697 {Target: "parameters.Identifier", Name: validation.Null, Rule: false, 698 Chain: []validation.Constraint{{Target: "parameters.Identifier", Name: validation.MaxLength, Rule: 64, Chain: nil}}}}}}); err != nil { 699 return result, validation.NewError("storage.AccountsClient", "ListServiceSAS", err.Error()) 700 } 701 702 req, err := client.ListServiceSASPreparer(ctx, resourceGroupName, accountName, parameters) 703 if err != nil { 704 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListServiceSAS", nil, "Failure preparing request") 705 return 706 } 707 708 resp, err := client.ListServiceSASSender(req) 709 if err != nil { 710 result.Response = autorest.Response{Response: resp} 711 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListServiceSAS", resp, "Failure sending request") 712 return 713 } 714 715 result, err = client.ListServiceSASResponder(resp) 716 if err != nil { 717 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListServiceSAS", resp, "Failure responding to request") 718 } 719 720 return 721} 722 723// ListServiceSASPreparer prepares the ListServiceSAS request. 724func (client AccountsClient) ListServiceSASPreparer(ctx context.Context, resourceGroupName string, accountName string, parameters ServiceSasParameters) (*http.Request, error) { 725 pathParameters := map[string]interface{}{ 726 "accountName": autorest.Encode("path", accountName), 727 "resourceGroupName": autorest.Encode("path", resourceGroupName), 728 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 729 } 730 731 const APIVersion = "2017-06-01" 732 queryParameters := map[string]interface{}{ 733 "api-version": APIVersion, 734 } 735 736 preparer := autorest.CreatePreparer( 737 autorest.AsContentType("application/json; charset=utf-8"), 738 autorest.AsPost(), 739 autorest.WithBaseURL(client.BaseURI), 740 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", pathParameters), 741 autorest.WithJSON(parameters), 742 autorest.WithQueryParameters(queryParameters)) 743 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 744} 745 746// ListServiceSASSender sends the ListServiceSAS request. The method will close the 747// http.Response Body if it receives an error. 748func (client AccountsClient) ListServiceSASSender(req *http.Request) (*http.Response, error) { 749 return autorest.SendWithSender(client, req, 750 azure.DoRetryWithRegistration(client.Client)) 751} 752 753// ListServiceSASResponder handles the response to the ListServiceSAS request. The method always 754// closes the http.Response Body. 755func (client AccountsClient) ListServiceSASResponder(resp *http.Response) (result ListServiceSasResponse, err error) { 756 err = autorest.Respond( 757 resp, 758 client.ByInspecting(), 759 azure.WithErrorUnlessStatusCode(http.StatusOK), 760 autorest.ByUnmarshallingJSON(&result), 761 autorest.ByClosing()) 762 result.Response = autorest.Response{Response: resp} 763 return 764} 765 766// RegenerateKey regenerates one of the access keys for the specified storage account. 767// Parameters: 768// resourceGroupName - the name of the resource group within the user's subscription. The name is case 769// insensitive. 770// accountName - the name of the storage account within the specified resource group. Storage account names 771// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 772// regenerateKey - specifies name of the key which should be regenerated -- key1 or key2. 773func (client AccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (result AccountListKeysResult, err error) { 774 if err := validation.Validate([]validation.Validation{ 775 {TargetValue: resourceGroupName, 776 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 777 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 778 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 779 {TargetValue: accountName, 780 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 781 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 782 {TargetValue: regenerateKey, 783 Constraints: []validation.Constraint{{Target: "regenerateKey.KeyName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 784 return result, validation.NewError("storage.AccountsClient", "RegenerateKey", err.Error()) 785 } 786 787 req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, accountName, regenerateKey) 788 if err != nil { 789 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", nil, "Failure preparing request") 790 return 791 } 792 793 resp, err := client.RegenerateKeySender(req) 794 if err != nil { 795 result.Response = autorest.Response{Response: resp} 796 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", resp, "Failure sending request") 797 return 798 } 799 800 result, err = client.RegenerateKeyResponder(resp) 801 if err != nil { 802 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", resp, "Failure responding to request") 803 } 804 805 return 806} 807 808// RegenerateKeyPreparer prepares the RegenerateKey request. 809func (client AccountsClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (*http.Request, error) { 810 pathParameters := map[string]interface{}{ 811 "accountName": autorest.Encode("path", accountName), 812 "resourceGroupName": autorest.Encode("path", resourceGroupName), 813 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 814 } 815 816 const APIVersion = "2017-06-01" 817 queryParameters := map[string]interface{}{ 818 "api-version": APIVersion, 819 } 820 821 preparer := autorest.CreatePreparer( 822 autorest.AsContentType("application/json; charset=utf-8"), 823 autorest.AsPost(), 824 autorest.WithBaseURL(client.BaseURI), 825 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", pathParameters), 826 autorest.WithJSON(regenerateKey), 827 autorest.WithQueryParameters(queryParameters)) 828 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 829} 830 831// RegenerateKeySender sends the RegenerateKey request. The method will close the 832// http.Response Body if it receives an error. 833func (client AccountsClient) RegenerateKeySender(req *http.Request) (*http.Response, error) { 834 return autorest.SendWithSender(client, req, 835 azure.DoRetryWithRegistration(client.Client)) 836} 837 838// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always 839// closes the http.Response Body. 840func (client AccountsClient) RegenerateKeyResponder(resp *http.Response) (result AccountListKeysResult, err error) { 841 err = autorest.Respond( 842 resp, 843 client.ByInspecting(), 844 azure.WithErrorUnlessStatusCode(http.StatusOK), 845 autorest.ByUnmarshallingJSON(&result), 846 autorest.ByClosing()) 847 result.Response = autorest.Response{Response: resp} 848 return 849} 850 851// Update the update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. 852// It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; 853// the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value 854// must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This 855// call does not change the storage keys for the account. If you want to change the storage account keys, use the 856// regenerate keys operation. The location and name of the storage account cannot be changed after creation. 857// Parameters: 858// resourceGroupName - the name of the resource group within the user's subscription. The name is case 859// insensitive. 860// accountName - the name of the storage account within the specified resource group. Storage account names 861// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 862// parameters - the parameters to provide for the updated account. 863func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters) (result Account, err error) { 864 if err := validation.Validate([]validation.Validation{ 865 {TargetValue: resourceGroupName, 866 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 867 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 868 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 869 {TargetValue: accountName, 870 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 871 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { 872 return result, validation.NewError("storage.AccountsClient", "Update", err.Error()) 873 } 874 875 req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, parameters) 876 if err != nil { 877 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", nil, "Failure preparing request") 878 return 879 } 880 881 resp, err := client.UpdateSender(req) 882 if err != nil { 883 result.Response = autorest.Response{Response: resp} 884 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", resp, "Failure sending request") 885 return 886 } 887 888 result, err = client.UpdateResponder(resp) 889 if err != nil { 890 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", resp, "Failure responding to request") 891 } 892 893 return 894} 895 896// UpdatePreparer prepares the Update request. 897func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters) (*http.Request, error) { 898 pathParameters := map[string]interface{}{ 899 "accountName": autorest.Encode("path", accountName), 900 "resourceGroupName": autorest.Encode("path", resourceGroupName), 901 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 902 } 903 904 const APIVersion = "2017-06-01" 905 queryParameters := map[string]interface{}{ 906 "api-version": APIVersion, 907 } 908 909 preparer := autorest.CreatePreparer( 910 autorest.AsContentType("application/json; charset=utf-8"), 911 autorest.AsPatch(), 912 autorest.WithBaseURL(client.BaseURI), 913 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 914 autorest.WithJSON(parameters), 915 autorest.WithQueryParameters(queryParameters)) 916 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 917} 918 919// UpdateSender sends the Update request. The method will close the 920// http.Response Body if it receives an error. 921func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, error) { 922 return autorest.SendWithSender(client, req, 923 azure.DoRetryWithRegistration(client.Client)) 924} 925 926// UpdateResponder handles the response to the Update request. The method always 927// closes the http.Response Body. 928func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) { 929 err = autorest.Respond( 930 resp, 931 client.ByInspecting(), 932 azure.WithErrorUnlessStatusCode(http.StatusOK), 933 autorest.ByUnmarshallingJSON(&result), 934 autorest.ByClosing()) 935 result.Response = autorest.Response{Response: resp} 936 return 937} 938