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/tracing" 25 "net/http" 26) 27 28// AccountsClient is the the Storage Management Client. 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 using a custom endpoint. Use this 39// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 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// Parameters: 46// accountName - the name of the storage account within the specified resource group. Storage account names 47// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 48func (client AccountsClient) CheckNameAvailability(ctx context.Context, accountName AccountCheckNameAvailabilityParameters) (result CheckNameAvailabilityResult, err error) { 49 if tracing.IsEnabled() { 50 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.CheckNameAvailability") 51 defer func() { 52 sc := -1 53 if result.Response.Response != nil { 54 sc = result.Response.Response.StatusCode 55 } 56 tracing.EndSpan(ctx, sc, err) 57 }() 58 } 59 req, err := client.CheckNameAvailabilityPreparer(ctx, accountName) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", nil, "Failure preparing request") 62 return 63 } 64 65 resp, err := client.CheckNameAvailabilitySender(req) 66 if err != nil { 67 result.Response = autorest.Response{Response: resp} 68 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", resp, "Failure sending request") 69 return 70 } 71 72 result, err = client.CheckNameAvailabilityResponder(resp) 73 if err != nil { 74 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", resp, "Failure responding to request") 75 } 76 77 return 78} 79 80// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. 81func (client AccountsClient) CheckNameAvailabilityPreparer(ctx context.Context, accountName AccountCheckNameAvailabilityParameters) (*http.Request, error) { 82 pathParameters := map[string]interface{}{ 83 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 84 } 85 86 const APIVersion = "2015-05-01-preview" 87 queryParameters := map[string]interface{}{ 88 "api-version": APIVersion, 89 } 90 91 preparer := autorest.CreatePreparer( 92 autorest.AsContentType("application/json; charset=utf-8"), 93 autorest.AsPost(), 94 autorest.WithBaseURL(client.BaseURI), 95 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability", pathParameters), 96 autorest.WithJSON(accountName), 97 autorest.WithQueryParameters(queryParameters)) 98 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 99} 100 101// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the 102// http.Response Body if it receives an error. 103func (client AccountsClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { 104 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 105} 106 107// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always 108// closes the http.Response Body. 109func (client AccountsClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { 110 err = autorest.Respond( 111 resp, 112 client.ByInspecting(), 113 azure.WithErrorUnlessStatusCode(http.StatusOK), 114 autorest.ByUnmarshallingJSON(&result), 115 autorest.ByClosing()) 116 result.Response = autorest.Response{Response: resp} 117 return 118} 119 120// Create asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be 121// updated with this API and should instead use the Update Storage Account API. If an account is already created and 122// subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. 123// Parameters: 124// resourceGroupName - the name of the resource group within the user's subscription. 125// accountName - the name of the storage account within the specified resource group. Storage account names 126// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 127// parameters - the parameters to provide for the created account. 128func (client AccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters) (result AccountsCreateFuture, err error) { 129 if tracing.IsEnabled() { 130 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Create") 131 defer func() { 132 sc := -1 133 if result.Response() != nil { 134 sc = result.Response().StatusCode 135 } 136 tracing.EndSpan(ctx, sc, err) 137 }() 138 } 139 req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, parameters) 140 if err != nil { 141 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", nil, "Failure preparing request") 142 return 143 } 144 145 result, err = client.CreateSender(req) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", result.Response(), "Failure sending request") 148 return 149 } 150 151 return 152} 153 154// CreatePreparer prepares the Create request. 155func (client AccountsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters) (*http.Request, error) { 156 pathParameters := map[string]interface{}{ 157 "accountName": autorest.Encode("path", accountName), 158 "resourceGroupName": autorest.Encode("path", resourceGroupName), 159 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 160 } 161 162 const APIVersion = "2015-05-01-preview" 163 queryParameters := map[string]interface{}{ 164 "api-version": APIVersion, 165 } 166 167 preparer := autorest.CreatePreparer( 168 autorest.AsContentType("application/json; charset=utf-8"), 169 autorest.AsPut(), 170 autorest.WithBaseURL(client.BaseURI), 171 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 172 autorest.WithJSON(parameters), 173 autorest.WithQueryParameters(queryParameters)) 174 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 175} 176 177// CreateSender sends the Create request. The method will close the 178// http.Response Body if it receives an error. 179func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCreateFuture, err error) { 180 var resp *http.Response 181 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 182 if err != nil { 183 return 184 } 185 future.Future, err = azure.NewFutureFromResponse(resp) 186 return 187} 188 189// CreateResponder handles the response to the Create request. The method always 190// closes the http.Response Body. 191func (client AccountsClient) CreateResponder(resp *http.Response) (result Account, err error) { 192 err = autorest.Respond( 193 resp, 194 client.ByInspecting(), 195 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 196 autorest.ByUnmarshallingJSON(&result), 197 autorest.ByClosing()) 198 result.Response = autorest.Response{Response: resp} 199 return 200} 201 202// Delete deletes a storage account in Microsoft Azure. 203// Parameters: 204// resourceGroupName - the name of the resource group within the user's subscription. 205// accountName - the name of the storage account within the specified resource group. Storage account names 206// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 207func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result autorest.Response, err error) { 208 if tracing.IsEnabled() { 209 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Delete") 210 defer func() { 211 sc := -1 212 if result.Response != nil { 213 sc = result.Response.StatusCode 214 } 215 tracing.EndSpan(ctx, sc, err) 216 }() 217 } 218 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) 219 if err != nil { 220 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", nil, "Failure preparing request") 221 return 222 } 223 224 resp, err := client.DeleteSender(req) 225 if err != nil { 226 result.Response = resp 227 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", resp, "Failure sending request") 228 return 229 } 230 231 result, err = client.DeleteResponder(resp) 232 if err != nil { 233 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", resp, "Failure responding to request") 234 } 235 236 return 237} 238 239// DeletePreparer prepares the Delete request. 240func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 241 pathParameters := map[string]interface{}{ 242 "accountName": autorest.Encode("path", accountName), 243 "resourceGroupName": autorest.Encode("path", resourceGroupName), 244 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 245 } 246 247 const APIVersion = "2015-05-01-preview" 248 queryParameters := map[string]interface{}{ 249 "api-version": APIVersion, 250 } 251 252 preparer := autorest.CreatePreparer( 253 autorest.AsDelete(), 254 autorest.WithBaseURL(client.BaseURI), 255 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 256 autorest.WithQueryParameters(queryParameters)) 257 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 258} 259 260// DeleteSender sends the Delete request. The method will close the 261// http.Response Body if it receives an error. 262func (client AccountsClient) DeleteSender(req *http.Request) (*http.Response, error) { 263 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 264} 265 266// DeleteResponder handles the response to the Delete request. The method always 267// closes the http.Response Body. 268func (client AccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 269 err = autorest.Respond( 270 resp, 271 client.ByInspecting(), 272 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 273 autorest.ByClosing()) 274 result.Response = resp 275 return 276} 277 278// GetProperties returns the properties for the specified storage account including but not limited to name, account 279// type, location, and account status. The ListKeys operation should be used to retrieve storage keys. 280// Parameters: 281// resourceGroupName - the name of the resource group within the user's subscription. 282// accountName - the name of the storage account within the specified resource group. Storage account names 283// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 284func (client AccountsClient) GetProperties(ctx context.Context, resourceGroupName string, accountName string) (result Account, err error) { 285 if tracing.IsEnabled() { 286 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.GetProperties") 287 defer func() { 288 sc := -1 289 if result.Response.Response != nil { 290 sc = result.Response.Response.StatusCode 291 } 292 tracing.EndSpan(ctx, sc, err) 293 }() 294 } 295 req, err := client.GetPropertiesPreparer(ctx, resourceGroupName, accountName) 296 if err != nil { 297 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", nil, "Failure preparing request") 298 return 299 } 300 301 resp, err := client.GetPropertiesSender(req) 302 if err != nil { 303 result.Response = autorest.Response{Response: resp} 304 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", resp, "Failure sending request") 305 return 306 } 307 308 result, err = client.GetPropertiesResponder(resp) 309 if err != nil { 310 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", resp, "Failure responding to request") 311 } 312 313 return 314} 315 316// GetPropertiesPreparer prepares the GetProperties request. 317func (client AccountsClient) GetPropertiesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 318 pathParameters := map[string]interface{}{ 319 "accountName": autorest.Encode("path", accountName), 320 "resourceGroupName": autorest.Encode("path", resourceGroupName), 321 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 322 } 323 324 const APIVersion = "2015-05-01-preview" 325 queryParameters := map[string]interface{}{ 326 "api-version": APIVersion, 327 } 328 329 preparer := autorest.CreatePreparer( 330 autorest.AsGet(), 331 autorest.WithBaseURL(client.BaseURI), 332 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 333 autorest.WithQueryParameters(queryParameters)) 334 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 335} 336 337// GetPropertiesSender sends the GetProperties request. The method will close the 338// http.Response Body if it receives an error. 339func (client AccountsClient) GetPropertiesSender(req *http.Request) (*http.Response, error) { 340 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 341} 342 343// GetPropertiesResponder handles the response to the GetProperties request. The method always 344// closes the http.Response Body. 345func (client AccountsClient) GetPropertiesResponder(resp *http.Response) (result Account, err error) { 346 err = autorest.Respond( 347 resp, 348 client.ByInspecting(), 349 azure.WithErrorUnlessStatusCode(http.StatusOK), 350 autorest.ByUnmarshallingJSON(&result), 351 autorest.ByClosing()) 352 result.Response = autorest.Response{Response: resp} 353 return 354} 355 356// List lists all the storage accounts available under the subscription. Note that storage keys are not returned; use 357// the ListKeys operation for this. 358func (client AccountsClient) List(ctx context.Context) (result AccountListResultPage, err error) { 359 if tracing.IsEnabled() { 360 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List") 361 defer func() { 362 sc := -1 363 if result.alr.Response.Response != nil { 364 sc = result.alr.Response.Response.StatusCode 365 } 366 tracing.EndSpan(ctx, sc, err) 367 }() 368 } 369 result.fn = client.listNextResults 370 req, err := client.ListPreparer(ctx) 371 if err != nil { 372 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", nil, "Failure preparing request") 373 return 374 } 375 376 resp, err := client.ListSender(req) 377 if err != nil { 378 result.alr.Response = autorest.Response{Response: resp} 379 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", resp, "Failure sending request") 380 return 381 } 382 383 result.alr, err = client.ListResponder(resp) 384 if err != nil { 385 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", resp, "Failure responding to request") 386 } 387 388 return 389} 390 391// ListPreparer prepares the List request. 392func (client AccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) { 393 pathParameters := map[string]interface{}{ 394 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 395 } 396 397 const APIVersion = "2015-05-01-preview" 398 queryParameters := map[string]interface{}{ 399 "api-version": APIVersion, 400 } 401 402 preparer := autorest.CreatePreparer( 403 autorest.AsGet(), 404 autorest.WithBaseURL(client.BaseURI), 405 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts", pathParameters), 406 autorest.WithQueryParameters(queryParameters)) 407 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 408} 409 410// ListSender sends the List request. The method will close the 411// http.Response Body if it receives an error. 412func (client AccountsClient) ListSender(req *http.Request) (*http.Response, error) { 413 return client.Send(req, 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// listNextResults retrieves the next set of results, if any. 430func (client AccountsClient) listNextResults(ctx context.Context, lastResults AccountListResult) (result AccountListResult, err error) { 431 req, err := lastResults.accountListResultPreparer(ctx) 432 if err != nil { 433 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "listNextResults", nil, "Failure preparing next results request") 434 } 435 if req == nil { 436 return 437 } 438 resp, err := client.ListSender(req) 439 if err != nil { 440 result.Response = autorest.Response{Response: resp} 441 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "listNextResults", resp, "Failure sending next results request") 442 } 443 result, err = client.ListResponder(resp) 444 if err != nil { 445 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "listNextResults", resp, "Failure responding to next results request") 446 } 447 return 448} 449 450// ListComplete enumerates all values, automatically crossing page boundaries as required. 451func (client AccountsClient) ListComplete(ctx context.Context) (result AccountListResultIterator, err error) { 452 if tracing.IsEnabled() { 453 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List") 454 defer func() { 455 sc := -1 456 if result.Response().Response.Response != nil { 457 sc = result.page.Response().Response.Response.StatusCode 458 } 459 tracing.EndSpan(ctx, sc, err) 460 }() 461 } 462 result.page, err = client.List(ctx) 463 return 464} 465 466// ListByResourceGroup lists all the storage accounts available under the given resource group. Note that storage keys 467// are not returned; use the ListKeys operation for this. 468// Parameters: 469// resourceGroupName - the name of the resource group within the user's subscription. 470func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AccountListResultPage, err error) { 471 if tracing.IsEnabled() { 472 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup") 473 defer func() { 474 sc := -1 475 if result.alr.Response.Response != nil { 476 sc = result.alr.Response.Response.StatusCode 477 } 478 tracing.EndSpan(ctx, sc, err) 479 }() 480 } 481 result.fn = client.listByResourceGroupNextResults 482 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 483 if err != nil { 484 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") 485 return 486 } 487 488 resp, err := client.ListByResourceGroupSender(req) 489 if err != nil { 490 result.alr.Response = autorest.Response{Response: resp} 491 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") 492 return 493 } 494 495 result.alr, err = client.ListByResourceGroupResponder(resp) 496 if err != nil { 497 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request") 498 } 499 500 return 501} 502 503// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 504func (client AccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 505 pathParameters := map[string]interface{}{ 506 "resourceGroupName": autorest.Encode("path", resourceGroupName), 507 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 508 } 509 510 const APIVersion = "2015-05-01-preview" 511 queryParameters := map[string]interface{}{ 512 "api-version": APIVersion, 513 } 514 515 preparer := autorest.CreatePreparer( 516 autorest.AsGet(), 517 autorest.WithBaseURL(client.BaseURI), 518 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", pathParameters), 519 autorest.WithQueryParameters(queryParameters)) 520 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 521} 522 523// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 524// http.Response Body if it receives an error. 525func (client AccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 526 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 527} 528 529// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 530// closes the http.Response Body. 531func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) { 532 err = autorest.Respond( 533 resp, 534 client.ByInspecting(), 535 azure.WithErrorUnlessStatusCode(http.StatusOK), 536 autorest.ByUnmarshallingJSON(&result), 537 autorest.ByClosing()) 538 result.Response = autorest.Response{Response: resp} 539 return 540} 541 542// listByResourceGroupNextResults retrieves the next set of results, if any. 543func (client AccountsClient) listByResourceGroupNextResults(ctx context.Context, lastResults AccountListResult) (result AccountListResult, err error) { 544 req, err := lastResults.accountListResultPreparer(ctx) 545 if err != nil { 546 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 547 } 548 if req == nil { 549 return 550 } 551 resp, err := client.ListByResourceGroupSender(req) 552 if err != nil { 553 result.Response = autorest.Response{Response: resp} 554 return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 555 } 556 result, err = client.ListByResourceGroupResponder(resp) 557 if err != nil { 558 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 559 } 560 return 561} 562 563// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 564func (client AccountsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AccountListResultIterator, err error) { 565 if tracing.IsEnabled() { 566 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup") 567 defer func() { 568 sc := -1 569 if result.Response().Response.Response != nil { 570 sc = result.page.Response().Response.Response.StatusCode 571 } 572 tracing.EndSpan(ctx, sc, err) 573 }() 574 } 575 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) 576 return 577} 578 579// ListKeys lists the access keys for the specified storage account. 580// Parameters: 581// resourceGroupName - the name of the resource group. 582// accountName - the name of the storage account. 583func (client AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result AccountKeys, err error) { 584 if tracing.IsEnabled() { 585 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListKeys") 586 defer func() { 587 sc := -1 588 if result.Response.Response != nil { 589 sc = result.Response.Response.StatusCode 590 } 591 tracing.EndSpan(ctx, sc, err) 592 }() 593 } 594 req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName) 595 if err != nil { 596 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", nil, "Failure preparing request") 597 return 598 } 599 600 resp, err := client.ListKeysSender(req) 601 if err != nil { 602 result.Response = autorest.Response{Response: resp} 603 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", resp, "Failure sending request") 604 return 605 } 606 607 result, err = client.ListKeysResponder(resp) 608 if err != nil { 609 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", resp, "Failure responding to request") 610 } 611 612 return 613} 614 615// ListKeysPreparer prepares the ListKeys request. 616func (client AccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 617 pathParameters := map[string]interface{}{ 618 "accountName": autorest.Encode("path", accountName), 619 "resourceGroupName": autorest.Encode("path", resourceGroupName), 620 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 621 } 622 623 const APIVersion = "2015-05-01-preview" 624 queryParameters := map[string]interface{}{ 625 "api-version": APIVersion, 626 } 627 628 preparer := autorest.CreatePreparer( 629 autorest.AsPost(), 630 autorest.WithBaseURL(client.BaseURI), 631 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", pathParameters), 632 autorest.WithQueryParameters(queryParameters)) 633 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 634} 635 636// ListKeysSender sends the ListKeys request. The method will close the 637// http.Response Body if it receives an error. 638func (client AccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) { 639 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 640} 641 642// ListKeysResponder handles the response to the ListKeys request. The method always 643// closes the http.Response Body. 644func (client AccountsClient) ListKeysResponder(resp *http.Response) (result AccountKeys, err error) { 645 err = autorest.Respond( 646 resp, 647 client.ByInspecting(), 648 azure.WithErrorUnlessStatusCode(http.StatusOK), 649 autorest.ByUnmarshallingJSON(&result), 650 autorest.ByClosing()) 651 result.Response = autorest.Response{Response: resp} 652 return 653} 654 655// RegenerateKey regenerates the access keys for the specified storage account. 656// Parameters: 657// resourceGroupName - the name of the resource group within the user's subscription. 658// accountName - the name of the storage account within the specified resource group. Storage account names 659// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 660// regenerateKey - specifies name of the key which should be regenerated. 661func (client AccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (result AccountKeys, err error) { 662 if tracing.IsEnabled() { 663 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.RegenerateKey") 664 defer func() { 665 sc := -1 666 if result.Response.Response != nil { 667 sc = result.Response.Response.StatusCode 668 } 669 tracing.EndSpan(ctx, sc, err) 670 }() 671 } 672 req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, accountName, regenerateKey) 673 if err != nil { 674 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", nil, "Failure preparing request") 675 return 676 } 677 678 resp, err := client.RegenerateKeySender(req) 679 if err != nil { 680 result.Response = autorest.Response{Response: resp} 681 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", resp, "Failure sending request") 682 return 683 } 684 685 result, err = client.RegenerateKeyResponder(resp) 686 if err != nil { 687 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", resp, "Failure responding to request") 688 } 689 690 return 691} 692 693// RegenerateKeyPreparer prepares the RegenerateKey request. 694func (client AccountsClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (*http.Request, error) { 695 pathParameters := map[string]interface{}{ 696 "accountName": autorest.Encode("path", accountName), 697 "resourceGroupName": autorest.Encode("path", resourceGroupName), 698 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 699 } 700 701 const APIVersion = "2015-05-01-preview" 702 queryParameters := map[string]interface{}{ 703 "api-version": APIVersion, 704 } 705 706 preparer := autorest.CreatePreparer( 707 autorest.AsContentType("application/json; charset=utf-8"), 708 autorest.AsPost(), 709 autorest.WithBaseURL(client.BaseURI), 710 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", pathParameters), 711 autorest.WithJSON(regenerateKey), 712 autorest.WithQueryParameters(queryParameters)) 713 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 714} 715 716// RegenerateKeySender sends the RegenerateKey request. The method will close the 717// http.Response Body if it receives an error. 718func (client AccountsClient) RegenerateKeySender(req *http.Request) (*http.Response, error) { 719 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 720} 721 722// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always 723// closes the http.Response Body. 724func (client AccountsClient) RegenerateKeyResponder(resp *http.Response) (result AccountKeys, err error) { 725 err = autorest.Respond( 726 resp, 727 client.ByInspecting(), 728 azure.WithErrorUnlessStatusCode(http.StatusOK), 729 autorest.ByUnmarshallingJSON(&result), 730 autorest.ByClosing()) 731 result.Response = autorest.Response{Response: resp} 732 return 733} 734 735// Update updates the account type or tags for a storage account. It can also be used to add a custom domain (note that 736// custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. 737// This API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these 738// properties, call the API multiple times with one change per call. This call does not change the storage keys for the 739// account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the 740// storage account cannot be changed after creation. 741// Parameters: 742// resourceGroupName - the name of the resource group within the user's subscription. 743// accountName - the name of the storage account within the specified resource group. Storage account names 744// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 745// parameters - the parameters to update on the account. Note that only one property can be changed at a time 746// using this API. 747func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters) (result Account, err error) { 748 if tracing.IsEnabled() { 749 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update") 750 defer func() { 751 sc := -1 752 if result.Response.Response != nil { 753 sc = result.Response.Response.StatusCode 754 } 755 tracing.EndSpan(ctx, sc, err) 756 }() 757 } 758 req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, parameters) 759 if err != nil { 760 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", nil, "Failure preparing request") 761 return 762 } 763 764 resp, err := client.UpdateSender(req) 765 if err != nil { 766 result.Response = autorest.Response{Response: resp} 767 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", resp, "Failure sending request") 768 return 769 } 770 771 result, err = client.UpdateResponder(resp) 772 if err != nil { 773 err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", resp, "Failure responding to request") 774 } 775 776 return 777} 778 779// UpdatePreparer prepares the Update request. 780func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters) (*http.Request, error) { 781 pathParameters := map[string]interface{}{ 782 "accountName": autorest.Encode("path", accountName), 783 "resourceGroupName": autorest.Encode("path", resourceGroupName), 784 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 785 } 786 787 const APIVersion = "2015-05-01-preview" 788 queryParameters := map[string]interface{}{ 789 "api-version": APIVersion, 790 } 791 792 preparer := autorest.CreatePreparer( 793 autorest.AsContentType("application/json; charset=utf-8"), 794 autorest.AsPatch(), 795 autorest.WithBaseURL(client.BaseURI), 796 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), 797 autorest.WithJSON(parameters), 798 autorest.WithQueryParameters(queryParameters)) 799 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 800} 801 802// UpdateSender sends the Update request. The method will close the 803// http.Response Body if it receives an error. 804func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, error) { 805 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 806} 807 808// UpdateResponder handles the response to the Update request. The method always 809// closes the http.Response Body. 810func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) { 811 err = autorest.Respond( 812 resp, 813 client.ByInspecting(), 814 azure.WithErrorUnlessStatusCode(http.StatusOK), 815 autorest.ByUnmarshallingJSON(&result), 816 autorest.ByClosing()) 817 result.Response = autorest.Response{Response: resp} 818 return 819} 820