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