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 0.17.0.0 18// Changes may cause incorrect behavior and will be lost if the code is 19// regenerated. 20 21import ( 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 Storage Management Client. 29type AccountsClient struct { 30 ManagementClient 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 39// client. 40func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { 41 return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// CheckNameAvailability checks that account name is valid and is not in use. 45// 46// accountName is the name of the storage account within the specified 47// resource group. Storage account names must be between 3 and 24 characters 48// in length and use numbers and lower-case letters only. 49func (client AccountsClient) CheckNameAvailability(accountName AccountCheckNameAvailabilityParameters) (result CheckNameAvailabilityResult, err error) { 50 if err := validation.Validate([]validation.Validation{ 51 {TargetValue: accountName, 52 Constraints: []validation.Constraint{{Target: "accountName.Name", Name: validation.Null, Rule: true, Chain: nil}, 53 {Target: "accountName.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 54 return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "CheckNameAvailability") 55 } 56 57 req, err := client.CheckNameAvailabilityPreparer(accountName) 58 if err != nil { 59 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", nil, "Failure preparing request") 60 } 61 62 resp, err := client.CheckNameAvailabilitySender(req) 63 if err != nil { 64 result.Response = autorest.Response{Response: resp} 65 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", resp, "Failure sending request") 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(accountName AccountCheckNameAvailabilityParameters) (*http.Request, error) { 78 pathParameters := map[string]interface{}{ 79 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 80 } 81 82 queryParameters := map[string]interface{}{ 83 "api-version": client.APIVersion, 84 } 85 86 preparer := autorest.CreatePreparer( 87 autorest.AsJSON(), 88 autorest.AsPost(), 89 autorest.WithBaseURL(client.BaseURI), 90 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability", pathParameters), 91 autorest.WithJSON(accountName), 92 autorest.WithQueryParameters(queryParameters)) 93 return preparer.Prepare(&http.Request{}) 94} 95 96// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the 97// http.Response Body if it receives an error. 98func (client AccountsClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { 99 return autorest.SendWithSender(client, req) 100} 101 102// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always 103// closes the http.Response Body. 104func (client AccountsClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { 105 err = autorest.Respond( 106 resp, 107 client.ByInspecting(), 108 azure.WithErrorUnlessStatusCode(http.StatusOK), 109 autorest.ByUnmarshallingJSON(&result), 110 autorest.ByClosing()) 111 result.Response = autorest.Response{Response: resp} 112 return 113} 114 115// Create asynchronously creates a new storage account with the specified 116// parameters. If an account is already created and subsequent create request 117// is issued with different properties, the account properties will be 118// updated. If an account is already created and subsequent create or update 119// request is issued with exact same set of properties, the request will 120// succeed. This method may poll for completion. Polling can be canceled by 121// passing the cancel channel argument. The channel will be used to cancel 122// polling and any outstanding HTTP requests. 123// 124// resourceGroupName is the name of the resource group within the user's 125// subscription. accountName is the name of the storage account within the 126// specified resource group. Storage account names must be between 3 and 24 127// characters in length and use numbers and lower-case letters only. 128// parameters is the parameters to provide for the created account. 129func (client AccountsClient) Create(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { 130 if err := validation.Validate([]validation.Validation{ 131 {TargetValue: accountName, 132 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 133 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 134 {TargetValue: parameters, 135 Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: true, 136 Chain: []validation.Constraint{{Target: "parameters.Sku.Tier", Name: validation.ReadOnly, Rule: true, Chain: nil}}}, 137 {Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}, 138 {Target: "parameters.Properties", Name: validation.Null, Rule: false, 139 Chain: []validation.Constraint{{Target: "parameters.Properties.CustomDomain", Name: validation.Null, Rule: false, 140 Chain: []validation.Constraint{{Target: "parameters.Properties.CustomDomain.Name", Name: validation.Null, Rule: true, Chain: nil}}}, 141 {Target: "parameters.Properties.Encryption", Name: validation.Null, Rule: false, 142 Chain: []validation.Constraint{{Target: "parameters.Properties.Encryption.Services", Name: validation.Null, Rule: false, 143 Chain: []validation.Constraint{{Target: "parameters.Properties.Encryption.Services.Blob", Name: validation.Null, Rule: false, 144 Chain: []validation.Constraint{{Target: "parameters.Properties.Encryption.Services.Blob.LastEnabledTime", Name: validation.ReadOnly, Rule: true, Chain: nil}}}, 145 }}, 146 {Target: "parameters.Properties.Encryption.KeySource", Name: validation.Null, Rule: true, Chain: nil}, 147 }}, 148 }}}}}); err != nil { 149 return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "Create") 150 } 151 152 req, err := client.CreatePreparer(resourceGroupName, accountName, parameters, cancel) 153 if err != nil { 154 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", nil, "Failure preparing request") 155 } 156 157 resp, err := client.CreateSender(req) 158 if err != nil { 159 result.Response = resp 160 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", resp, "Failure sending request") 161 } 162 163 result, err = client.CreateResponder(resp) 164 if err != nil { 165 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", resp, "Failure responding to request") 166 } 167 168 return 169} 170 171// CreatePreparer prepares the Create request. 172func (client AccountsClient) CreatePreparer(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (*http.Request, error) { 173 pathParameters := map[string]interface{}{ 174 "accountName": autorest.Encode("path", accountName), 175 "resourceGroupName": autorest.Encode("path", resourceGroupName), 176 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 177 } 178 179 queryParameters := map[string]interface{}{ 180 "api-version": client.APIVersion, 181 } 182 183 preparer := autorest.CreatePreparer( 184 autorest.AsJSON(), 185 autorest.AsPut(), 186 autorest.WithBaseURL(client.BaseURI), 187 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 188 autorest.WithJSON(parameters), 189 autorest.WithQueryParameters(queryParameters)) 190 return preparer.Prepare(&http.Request{Cancel: cancel}) 191} 192 193// CreateSender sends the Create request. The method will close the 194// http.Response Body if it receives an error. 195func (client AccountsClient) CreateSender(req *http.Request) (*http.Response, error) { 196 return autorest.SendWithSender(client, 197 req, 198 azure.DoPollForAsynchronous(client.PollingDelay)) 199} 200 201// CreateResponder handles the response to the Create request. The method always 202// closes the http.Response Body. 203func (client AccountsClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { 204 err = autorest.Respond( 205 resp, 206 client.ByInspecting(), 207 azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), 208 autorest.ByClosing()) 209 result.Response = resp 210 return 211} 212 213// Delete deletes a storage account in Microsoft Azure. 214// 215// resourceGroupName is the name of the resource group within the user's 216// subscription. accountName is the name of the storage account within the 217// specified resource group. Storage account names must be between 3 and 24 218// characters in length and use numbers and lower-case letters only. 219func (client AccountsClient) Delete(resourceGroupName string, accountName string) (result autorest.Response, err error) { 220 if err := validation.Validate([]validation.Validation{ 221 {TargetValue: accountName, 222 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 223 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { 224 return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "Delete") 225 } 226 227 req, err := client.DeletePreparer(resourceGroupName, accountName) 228 if err != nil { 229 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", nil, "Failure preparing request") 230 } 231 232 resp, err := client.DeleteSender(req) 233 if err != nil { 234 result.Response = resp 235 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", resp, "Failure sending request") 236 } 237 238 result, err = client.DeleteResponder(resp) 239 if err != nil { 240 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", resp, "Failure responding to request") 241 } 242 243 return 244} 245 246// DeletePreparer prepares the Delete request. 247func (client AccountsClient) DeletePreparer(resourceGroupName string, accountName string) (*http.Request, error) { 248 pathParameters := map[string]interface{}{ 249 "accountName": autorest.Encode("path", accountName), 250 "resourceGroupName": autorest.Encode("path", resourceGroupName), 251 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 252 } 253 254 queryParameters := map[string]interface{}{ 255 "api-version": client.APIVersion, 256 } 257 258 preparer := autorest.CreatePreparer( 259 autorest.AsDelete(), 260 autorest.WithBaseURL(client.BaseURI), 261 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 262 autorest.WithQueryParameters(queryParameters)) 263 return preparer.Prepare(&http.Request{}) 264} 265 266// DeleteSender sends the Delete request. The method will close the 267// http.Response Body if it receives an error. 268func (client AccountsClient) DeleteSender(req *http.Request) (*http.Response, error) { 269 return autorest.SendWithSender(client, req) 270} 271 272// DeleteResponder handles the response to the Delete request. The method always 273// closes the http.Response Body. 274func (client AccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 275 err = autorest.Respond( 276 resp, 277 client.ByInspecting(), 278 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 279 autorest.ByClosing()) 280 result.Response = resp 281 return 282} 283 284// GetProperties returns the properties for the specified storage account 285// including but not limited to name, account type, location, and account 286// status. The ListKeys operation should be used to retrieve storage keys. 287// 288// resourceGroupName is the name of the resource group within the user's 289// subscription. accountName is the name of the storage account within the 290// specified resource group. Storage account names must be between 3 and 24 291// characters in length and use numbers and lower-case letters only. 292func (client AccountsClient) GetProperties(resourceGroupName string, accountName string) (result Account, err error) { 293 if err := validation.Validate([]validation.Validation{ 294 {TargetValue: accountName, 295 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 296 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { 297 return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "GetProperties") 298 } 299 300 req, err := client.GetPropertiesPreparer(resourceGroupName, accountName) 301 if err != nil { 302 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", nil, "Failure preparing request") 303 } 304 305 resp, err := client.GetPropertiesSender(req) 306 if err != nil { 307 result.Response = autorest.Response{Response: resp} 308 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", resp, "Failure sending request") 309 } 310 311 result, err = client.GetPropertiesResponder(resp) 312 if err != nil { 313 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", resp, "Failure responding to request") 314 } 315 316 return 317} 318 319// GetPropertiesPreparer prepares the GetProperties request. 320func (client AccountsClient) GetPropertiesPreparer(resourceGroupName string, accountName string) (*http.Request, error) { 321 pathParameters := map[string]interface{}{ 322 "accountName": autorest.Encode("path", accountName), 323 "resourceGroupName": autorest.Encode("path", resourceGroupName), 324 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 325 } 326 327 queryParameters := map[string]interface{}{ 328 "api-version": client.APIVersion, 329 } 330 331 preparer := autorest.CreatePreparer( 332 autorest.AsGet(), 333 autorest.WithBaseURL(client.BaseURI), 334 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 335 autorest.WithQueryParameters(queryParameters)) 336 return preparer.Prepare(&http.Request{}) 337} 338 339// GetPropertiesSender sends the GetProperties request. The method will close the 340// http.Response Body if it receives an error. 341func (client AccountsClient) GetPropertiesSender(req *http.Request) (*http.Response, error) { 342 return autorest.SendWithSender(client, req) 343} 344 345// GetPropertiesResponder handles the response to the GetProperties request. The method always 346// closes the http.Response Body. 347func (client AccountsClient) GetPropertiesResponder(resp *http.Response) (result Account, err error) { 348 err = autorest.Respond( 349 resp, 350 client.ByInspecting(), 351 azure.WithErrorUnlessStatusCode(http.StatusOK), 352 autorest.ByUnmarshallingJSON(&result), 353 autorest.ByClosing()) 354 result.Response = autorest.Response{Response: resp} 355 return 356} 357 358// List lists all the storage accounts available under the subscription. Note 359// that storage keys are not returned; use the ListKeys operation for this. 360func (client AccountsClient) List() (result AccountListResult, err error) { 361 req, err := client.ListPreparer() 362 if err != nil { 363 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "List", nil, "Failure preparing request") 364 } 365 366 resp, err := client.ListSender(req) 367 if err != nil { 368 result.Response = autorest.Response{Response: resp} 369 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "List", resp, "Failure sending request") 370 } 371 372 result, err = client.ListResponder(resp) 373 if err != nil { 374 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", resp, "Failure responding to request") 375 } 376 377 return 378} 379 380// ListPreparer prepares the List request. 381func (client AccountsClient) ListPreparer() (*http.Request, error) { 382 pathParameters := map[string]interface{}{ 383 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 384 } 385 386 queryParameters := map[string]interface{}{ 387 "api-version": client.APIVersion, 388 } 389 390 preparer := autorest.CreatePreparer( 391 autorest.AsGet(), 392 autorest.WithBaseURL(client.BaseURI), 393 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts", pathParameters), 394 autorest.WithQueryParameters(queryParameters)) 395 return preparer.Prepare(&http.Request{}) 396} 397 398// ListSender sends the List request. The method will close the 399// http.Response Body if it receives an error. 400func (client AccountsClient) ListSender(req *http.Request) (*http.Response, error) { 401 return autorest.SendWithSender(client, req) 402} 403 404// ListResponder handles the response to the List request. The method always 405// closes the http.Response Body. 406func (client AccountsClient) ListResponder(resp *http.Response) (result AccountListResult, err error) { 407 err = autorest.Respond( 408 resp, 409 client.ByInspecting(), 410 azure.WithErrorUnlessStatusCode(http.StatusOK), 411 autorest.ByUnmarshallingJSON(&result), 412 autorest.ByClosing()) 413 result.Response = autorest.Response{Response: resp} 414 return 415} 416 417// ListByResourceGroup lists all the storage accounts available under the 418// given resource group. Note that storage keys are not returned; use the 419// ListKeys operation for this. 420// 421// resourceGroupName is the name of the resource group within the user's 422// subscription. 423func (client AccountsClient) ListByResourceGroup(resourceGroupName string) (result AccountListResult, err error) { 424 req, err := client.ListByResourceGroupPreparer(resourceGroupName) 425 if err != nil { 426 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") 427 } 428 429 resp, err := client.ListByResourceGroupSender(req) 430 if err != nil { 431 result.Response = autorest.Response{Response: resp} 432 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") 433 } 434 435 result, err = client.ListByResourceGroupResponder(resp) 436 if err != nil { 437 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request") 438 } 439 440 return 441} 442 443// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 444func (client AccountsClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { 445 pathParameters := map[string]interface{}{ 446 "resourceGroupName": autorest.Encode("path", resourceGroupName), 447 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 448 } 449 450 queryParameters := map[string]interface{}{ 451 "api-version": client.APIVersion, 452 } 453 454 preparer := autorest.CreatePreparer( 455 autorest.AsGet(), 456 autorest.WithBaseURL(client.BaseURI), 457 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", pathParameters), 458 autorest.WithQueryParameters(queryParameters)) 459 return preparer.Prepare(&http.Request{}) 460} 461 462// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 463// http.Response Body if it receives an error. 464func (client AccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 465 return autorest.SendWithSender(client, req) 466} 467 468// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 469// closes the http.Response Body. 470func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) { 471 err = autorest.Respond( 472 resp, 473 client.ByInspecting(), 474 azure.WithErrorUnlessStatusCode(http.StatusOK), 475 autorest.ByUnmarshallingJSON(&result), 476 autorest.ByClosing()) 477 result.Response = autorest.Response{Response: resp} 478 return 479} 480 481// ListKeys lists the access keys for the specified storage account. 482// 483// resourceGroupName is the name of the resource group. accountName is the 484// name of the storage account. 485func (client AccountsClient) ListKeys(resourceGroupName string, accountName string) (result AccountListKeysResult, err error) { 486 if err := validation.Validate([]validation.Validation{ 487 {TargetValue: accountName, 488 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 489 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { 490 return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "ListKeys") 491 } 492 493 req, err := client.ListKeysPreparer(resourceGroupName, accountName) 494 if err != nil { 495 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", nil, "Failure preparing request") 496 } 497 498 resp, err := client.ListKeysSender(req) 499 if err != nil { 500 result.Response = autorest.Response{Response: resp} 501 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", resp, "Failure sending request") 502 } 503 504 result, err = client.ListKeysResponder(resp) 505 if err != nil { 506 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", resp, "Failure responding to request") 507 } 508 509 return 510} 511 512// ListKeysPreparer prepares the ListKeys request. 513func (client AccountsClient) ListKeysPreparer(resourceGroupName string, accountName string) (*http.Request, error) { 514 pathParameters := map[string]interface{}{ 515 "accountName": autorest.Encode("path", accountName), 516 "resourceGroupName": autorest.Encode("path", resourceGroupName), 517 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 518 } 519 520 queryParameters := map[string]interface{}{ 521 "api-version": client.APIVersion, 522 } 523 524 preparer := autorest.CreatePreparer( 525 autorest.AsPost(), 526 autorest.WithBaseURL(client.BaseURI), 527 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", pathParameters), 528 autorest.WithQueryParameters(queryParameters)) 529 return preparer.Prepare(&http.Request{}) 530} 531 532// ListKeysSender sends the ListKeys request. The method will close the 533// http.Response Body if it receives an error. 534func (client AccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) { 535 return autorest.SendWithSender(client, req) 536} 537 538// ListKeysResponder handles the response to the ListKeys request. The method always 539// closes the http.Response Body. 540func (client AccountsClient) ListKeysResponder(resp *http.Response) (result AccountListKeysResult, err error) { 541 err = autorest.Respond( 542 resp, 543 client.ByInspecting(), 544 azure.WithErrorUnlessStatusCode(http.StatusOK), 545 autorest.ByUnmarshallingJSON(&result), 546 autorest.ByClosing()) 547 result.Response = autorest.Response{Response: resp} 548 return 549} 550 551// RegenerateKey regenerates the access keys for the specified storage account. 552// 553// resourceGroupName is the name of the resource group within the user's 554// subscription. accountName is the name of the storage account within the 555// specified resource group. Storage account names must be between 3 and 24 556// characters in length and use numbers and lower-case letters only. 557// regenerateKey is specifies name of the key which should be regenerated. 558// key1 or key2 for the default keys 559func (client AccountsClient) RegenerateKey(resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (result AccountListKeysResult, err error) { 560 if err := validation.Validate([]validation.Validation{ 561 {TargetValue: accountName, 562 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 563 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 564 {TargetValue: regenerateKey, 565 Constraints: []validation.Constraint{{Target: "regenerateKey.KeyName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 566 return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "RegenerateKey") 567 } 568 569 req, err := client.RegenerateKeyPreparer(resourceGroupName, accountName, regenerateKey) 570 if err != nil { 571 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", nil, "Failure preparing request") 572 } 573 574 resp, err := client.RegenerateKeySender(req) 575 if err != nil { 576 result.Response = autorest.Response{Response: resp} 577 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", resp, "Failure sending request") 578 } 579 580 result, err = client.RegenerateKeyResponder(resp) 581 if err != nil { 582 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", resp, "Failure responding to request") 583 } 584 585 return 586} 587 588// RegenerateKeyPreparer prepares the RegenerateKey request. 589func (client AccountsClient) RegenerateKeyPreparer(resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (*http.Request, error) { 590 pathParameters := map[string]interface{}{ 591 "accountName": autorest.Encode("path", accountName), 592 "resourceGroupName": autorest.Encode("path", resourceGroupName), 593 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 594 } 595 596 queryParameters := map[string]interface{}{ 597 "api-version": client.APIVersion, 598 } 599 600 preparer := autorest.CreatePreparer( 601 autorest.AsJSON(), 602 autorest.AsPost(), 603 autorest.WithBaseURL(client.BaseURI), 604 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", pathParameters), 605 autorest.WithJSON(regenerateKey), 606 autorest.WithQueryParameters(queryParameters)) 607 return preparer.Prepare(&http.Request{}) 608} 609 610// RegenerateKeySender sends the RegenerateKey request. The method will close the 611// http.Response Body if it receives an error. 612func (client AccountsClient) RegenerateKeySender(req *http.Request) (*http.Response, error) { 613 return autorest.SendWithSender(client, req) 614} 615 616// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always 617// closes the http.Response Body. 618func (client AccountsClient) RegenerateKeyResponder(resp *http.Response) (result AccountListKeysResult, err error) { 619 err = autorest.Respond( 620 resp, 621 client.ByInspecting(), 622 azure.WithErrorUnlessStatusCode(http.StatusOK), 623 autorest.ByUnmarshallingJSON(&result), 624 autorest.ByClosing()) 625 result.Response = autorest.Response{Response: resp} 626 return 627} 628 629// Update the update operation can be used to update the account type, 630// encryption, or tags for a storage account. It can also be used to map the 631// account to a custom domain. Only one custom domain is supported per 632// storage account and. replacement/change of custom domain is not supported. 633// In order to replace an old custom domain, the old value must be 634// cleared/unregistered before a new value may be set. Update of multiple 635// properties is supported. This call does not change the storage keys for 636// the account. If you want to change storage account keys, use the 637// regenerate keys operation. The location and name of the storage account 638// cannot be changed after creation. 639// 640// resourceGroupName is the name of the resource group within the user's 641// subscription. accountName is the name of the storage account within the 642// specified resource group. Storage account names must be between 3 and 24 643// characters in length and use numbers and lower-case letters only. 644// parameters is the parameters to provide for the updated account. 645func (client AccountsClient) Update(resourceGroupName string, accountName string, parameters AccountUpdateParameters) (result Account, err error) { 646 if err := validation.Validate([]validation.Validation{ 647 {TargetValue: accountName, 648 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 649 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { 650 return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "Update") 651 } 652 653 req, err := client.UpdatePreparer(resourceGroupName, accountName, parameters) 654 if err != nil { 655 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", nil, "Failure preparing request") 656 } 657 658 resp, err := client.UpdateSender(req) 659 if err != nil { 660 result.Response = autorest.Response{Response: resp} 661 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", resp, "Failure sending request") 662 } 663 664 result, err = client.UpdateResponder(resp) 665 if err != nil { 666 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", resp, "Failure responding to request") 667 } 668 669 return 670} 671 672// UpdatePreparer prepares the Update request. 673func (client AccountsClient) UpdatePreparer(resourceGroupName string, accountName string, parameters AccountUpdateParameters) (*http.Request, error) { 674 pathParameters := map[string]interface{}{ 675 "accountName": autorest.Encode("path", accountName), 676 "resourceGroupName": autorest.Encode("path", resourceGroupName), 677 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 678 } 679 680 queryParameters := map[string]interface{}{ 681 "api-version": client.APIVersion, 682 } 683 684 preparer := autorest.CreatePreparer( 685 autorest.AsJSON(), 686 autorest.AsPatch(), 687 autorest.WithBaseURL(client.BaseURI), 688 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 689 autorest.WithJSON(parameters), 690 autorest.WithQueryParameters(queryParameters)) 691 return preparer.Prepare(&http.Request{}) 692} 693 694// UpdateSender sends the Update request. The method will close the 695// http.Response Body if it receives an error. 696func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, error) { 697 return autorest.SendWithSender(client, req) 698} 699 700// UpdateResponder handles the response to the Update request. The method always 701// closes the http.Response Body. 702func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) { 703 err = autorest.Respond( 704 resp, 705 client.ByInspecting(), 706 azure.WithErrorUnlessStatusCode(http.StatusOK), 707 autorest.ByUnmarshallingJSON(&result), 708 autorest.ByClosing()) 709 result.Response = autorest.Response{Response: resp} 710 return 711} 712