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