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