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