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// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2016-05-01-preview/commitmentplans instead.
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// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2016-05-01-preview/commitmentplans instead.
37// NewSkusClient creates an instance of the SkusClient client.
38func NewSkusClient(subscriptionID string) SkusClient {
39	return NewSkusClientWithBaseURI(DefaultBaseURI, subscriptionID)
40}
41
42// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2016-05-01-preview/commitmentplans instead.
43// NewSkusClientWithBaseURI creates an instance of the SkusClient client.
44func NewSkusClientWithBaseURI(baseURI string, subscriptionID string) SkusClient {
45	return SkusClient{NewWithBaseURI(baseURI, subscriptionID)}
46}
47
48// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2016-05-01-preview/commitmentplans instead.
49// List lists the available commitment plan SKUs.
50func (client SkusClient) List(ctx context.Context) (result SkuListResult, err error) {
51	req, err := client.ListPreparer(ctx)
52	if err != nil {
53		err = autorest.NewErrorWithError(err, "commitmentplans.SkusClient", "List", nil, "Failure preparing request")
54		return
55	}
56
57	resp, err := client.ListSender(req)
58	if err != nil {
59		result.Response = autorest.Response{Response: resp}
60		err = autorest.NewErrorWithError(err, "commitmentplans.SkusClient", "List", resp, "Failure sending request")
61		return
62	}
63
64	result, err = client.ListResponder(resp)
65	if err != nil {
66		err = autorest.NewErrorWithError(err, "commitmentplans.SkusClient", "List", resp, "Failure responding to request")
67	}
68
69	return
70}
71
72// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2016-05-01-preview/commitmentplans instead.
73// ListPreparer prepares the List request.
74func (client SkusClient) ListPreparer(ctx context.Context) (*http.Request, error) {
75	pathParameters := map[string]interface{}{
76		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
77	}
78
79	const APIVersion = "2016-05-01-preview"
80	queryParameters := map[string]interface{}{
81		"api-version": APIVersion,
82	}
83
84	preparer := autorest.CreatePreparer(
85		autorest.AsGet(),
86		autorest.WithBaseURL(client.BaseURI),
87		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MachineLearning/skus", pathParameters),
88		autorest.WithQueryParameters(queryParameters))
89	return preparer.Prepare((&http.Request{}).WithContext(ctx))
90}
91
92// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2016-05-01-preview/commitmentplans instead.
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 autorest.SendWithSender(client, req,
97		azure.DoRetryWithRegistration(client.Client))
98}
99
100// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2016-05-01-preview/commitmentplans instead.
101// ListResponder handles the response to the List request. The method always
102// closes the http.Response Body.
103func (client SkusClient) ListResponder(resp *http.Response) (result SkuListResult, err error) {
104	err = autorest.Respond(
105		resp,
106		client.ByInspecting(),
107		azure.WithErrorUnlessStatusCode(http.StatusOK),
108		autorest.ByUnmarshallingJSON(&result),
109		autorest.ByClosing())
110	result.Response = autorest.Response{Response: resp}
111	return
112}
113