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// SkusClient is the the Azure Storage Management API.
18type SkusClient struct {
19	BaseClient
20}
21
22// NewSkusClient creates an instance of the SkusClient client.
23func NewSkusClient(subscriptionID string) SkusClient {
24	return NewSkusClientWithBaseURI(DefaultBaseURI, subscriptionID)
25}
26
27// NewSkusClientWithBaseURI creates an instance of the SkusClient client using a custom endpoint.  Use this when
28// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
29func NewSkusClientWithBaseURI(baseURI string, subscriptionID string) SkusClient {
30	return SkusClient{NewWithBaseURI(baseURI, subscriptionID)}
31}
32
33// List lists the available SKUs supported by Microsoft.Storage for given subscription.
34func (client SkusClient) List(ctx context.Context) (result SkuListResult, err error) {
35	if tracing.IsEnabled() {
36		ctx = tracing.StartSpan(ctx, fqdn+"/SkusClient.List")
37		defer func() {
38			sc := -1
39			if result.Response.Response != nil {
40				sc = result.Response.Response.StatusCode
41			}
42			tracing.EndSpan(ctx, sc, err)
43		}()
44	}
45	req, err := client.ListPreparer(ctx)
46	if err != nil {
47		err = autorest.NewErrorWithError(err, "storage.SkusClient", "List", nil, "Failure preparing request")
48		return
49	}
50
51	resp, err := client.ListSender(req)
52	if err != nil {
53		result.Response = autorest.Response{Response: resp}
54		err = autorest.NewErrorWithError(err, "storage.SkusClient", "List", resp, "Failure sending request")
55		return
56	}
57
58	result, err = client.ListResponder(resp)
59	if err != nil {
60		err = autorest.NewErrorWithError(err, "storage.SkusClient", "List", resp, "Failure responding to request")
61		return
62	}
63
64	return
65}
66
67// ListPreparer prepares the List request.
68func (client SkusClient) ListPreparer(ctx context.Context) (*http.Request, error) {
69	pathParameters := map[string]interface{}{
70		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
71	}
72
73	const APIVersion = "2017-06-01"
74	queryParameters := map[string]interface{}{
75		"api-version": APIVersion,
76	}
77
78	preparer := autorest.CreatePreparer(
79		autorest.AsGet(),
80		autorest.WithBaseURL(client.BaseURI),
81		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus", pathParameters),
82		autorest.WithQueryParameters(queryParameters))
83	return preparer.Prepare((&http.Request{}).WithContext(ctx))
84}
85
86// ListSender sends the List request. The method will close the
87// http.Response Body if it receives an error.
88func (client SkusClient) ListSender(req *http.Request) (*http.Response, error) {
89	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
90}
91
92// ListResponder handles the response to the List request. The method always
93// closes the http.Response Body.
94func (client SkusClient) ListResponder(resp *http.Response) (result SkuListResult, err error) {
95	err = autorest.Respond(
96		resp,
97		azure.WithErrorUnlessStatusCode(http.StatusOK),
98		autorest.ByUnmarshallingJSON(&result),
99		autorest.ByClosing())
100	result.Response = autorest.Response{Response: resp}
101	return
102}
103