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