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