1package commitmentplans 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/tracing" 25 "net/http" 26) 27 28// SkusClient is the these APIs allow end users to operate on Azure Machine Learning Commitment Plans resources and 29// their child Commitment Association resources. They support CRUD operations for commitment plans, get and list 30// operations for commitment associations, moving commitment associations between commitment plans, and retrieving 31// commitment plan usage history. 32type SkusClient struct { 33 BaseClient 34} 35 36// NewSkusClient creates an instance of the SkusClient client. 37func NewSkusClient(subscriptionID string) SkusClient { 38 return NewSkusClientWithBaseURI(DefaultBaseURI, subscriptionID) 39} 40 41// NewSkusClientWithBaseURI creates an instance of the SkusClient client using a custom endpoint. Use this when 42// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 43func NewSkusClientWithBaseURI(baseURI string, subscriptionID string) SkusClient { 44 return SkusClient{NewWithBaseURI(baseURI, subscriptionID)} 45} 46 47// List lists the available commitment plan SKUs. 48func (client SkusClient) List(ctx context.Context) (result SkuListResult, err error) { 49 if tracing.IsEnabled() { 50 ctx = tracing.StartSpan(ctx, fqdn+"/SkusClient.List") 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 req, err := client.ListPreparer(ctx) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "commitmentplans.SkusClient", "List", nil, "Failure preparing request") 62 return 63 } 64 65 resp, err := client.ListSender(req) 66 if err != nil { 67 result.Response = autorest.Response{Response: resp} 68 err = autorest.NewErrorWithError(err, "commitmentplans.SkusClient", "List", resp, "Failure sending request") 69 return 70 } 71 72 result, err = client.ListResponder(resp) 73 if err != nil { 74 err = autorest.NewErrorWithError(err, "commitmentplans.SkusClient", "List", resp, "Failure responding to request") 75 } 76 77 return 78} 79 80// ListPreparer prepares the List request. 81func (client SkusClient) ListPreparer(ctx context.Context) (*http.Request, error) { 82 pathParameters := map[string]interface{}{ 83 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 84 } 85 86 const APIVersion = "2016-05-01-preview" 87 queryParameters := map[string]interface{}{ 88 "api-version": APIVersion, 89 } 90 91 preparer := autorest.CreatePreparer( 92 autorest.AsGet(), 93 autorest.WithBaseURL(client.BaseURI), 94 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MachineLearning/skus", pathParameters), 95 autorest.WithQueryParameters(queryParameters)) 96 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 97} 98 99// ListSender sends the List request. The method will close the 100// http.Response Body if it receives an error. 101func (client SkusClient) ListSender(req *http.Request) (*http.Response, error) { 102 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 103} 104 105// ListResponder handles the response to the List request. The method always 106// closes the http.Response Body. 107func (client SkusClient) ListResponder(resp *http.Response) (result SkuListResult, err error) { 108 err = autorest.Respond( 109 resp, 110 client.ByInspecting(), 111 azure.WithErrorUnlessStatusCode(http.StatusOK), 112 autorest.ByUnmarshallingJSON(&result), 113 autorest.ByClosing()) 114 result.Response = autorest.Response{Response: resp} 115 return 116} 117