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