3
// Copyright (c) Microsoft and contributors. All rights reserved.
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
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.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
17
// Code generated by Microsoft (R) AutoRest Code Generator 0.12.0.0
18
// Changes may cause incorrect behavior and will be lost if the code is
22
"github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest"
27
// ProvidersClient is the client for the Providers methods of the Resources
29
type ProvidersClient struct {
33
// NewProvidersClient creates an instance of the ProvidersClient client.
34
func NewProvidersClient(subscriptionID string) ProvidersClient {
35
return NewProvidersClientWithBaseURI(DefaultBaseURI, subscriptionID)
38
// NewProvidersClientWithBaseURI creates an instance of the ProvidersClient
40
func NewProvidersClientWithBaseURI(baseURI string, subscriptionID string) ProvidersClient {
41
return ProvidersClient{NewWithBaseURI(baseURI, subscriptionID)}
44
// Get gets a resource provider.
46
// resourceProviderNamespace is namespace of the resource provider.
47
func (client ProvidersClient) Get(resourceProviderNamespace string) (result Provider, ae error) {
48
req, err := client.GetPreparer(resourceProviderNamespace)
50
return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Get", "Failure preparing request")
53
resp, err := client.GetSender(req)
55
result.Response = autorest.Response{Response: resp}
56
return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Get", "Failure sending request")
59
result, err = client.GetResponder(resp)
61
ae = autorest.NewErrorWithError(err, "resources/ProvidersClient", "Get", "Failure responding to request")
67
// GetPreparer prepares the Get request.
68
func (client ProvidersClient) GetPreparer(resourceProviderNamespace string) (*http.Request, error) {
69
pathParameters := map[string]interface{}{
70
"resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace),
71
"subscriptionId": url.QueryEscape(client.SubscriptionID),
74
queryParameters := map[string]interface{}{
75
"api-version": APIVersion,
78
return autorest.Prepare(&http.Request{},
81
autorest.WithBaseURL(client.BaseURI),
82
autorest.WithPath("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"),
83
autorest.WithPathParameters(pathParameters),
84
autorest.WithQueryParameters(queryParameters))
87
// GetSender sends the Get request. The method will close the
88
// http.Response Body if it receives an error.
89
func (client ProvidersClient) GetSender(req *http.Request) (*http.Response, error) {
90
return client.Send(req, http.StatusOK)
93
// GetResponder handles the response to the Get request. The method always
94
// closes the http.Response Body.
95
func (client ProvidersClient) GetResponder(resp *http.Response) (result Provider, err error) {
96
err = autorest.Respond(
98
client.ByInspecting(),
99
autorest.WithErrorUnlessStatusCode(http.StatusOK),
100
autorest.ByUnmarshallingJSON(&result),
101
autorest.ByClosing())
102
result.Response = autorest.Response{Response: resp}
106
// List gets a list of resource providers.
108
// top is query parameters. If null is passed returns all deployments.
109
func (client ProvidersClient) List(top *int) (result ProviderListResult, ae error) {
110
req, err := client.ListPreparer(top)
112
return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure preparing request")
115
resp, err := client.ListSender(req)
117
result.Response = autorest.Response{Response: resp}
118
return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure sending request")
121
result, err = client.ListResponder(resp)
123
ae = autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure responding to request")
129
// ListPreparer prepares the List request.
130
func (client ProvidersClient) ListPreparer(top *int) (*http.Request, error) {
131
pathParameters := map[string]interface{}{
132
"subscriptionId": url.QueryEscape(client.SubscriptionID),
135
queryParameters := map[string]interface{}{
136
"api-version": APIVersion,
139
queryParameters["$top"] = top
142
return autorest.Prepare(&http.Request{},
145
autorest.WithBaseURL(client.BaseURI),
146
autorest.WithPath("/subscriptions/{subscriptionId}/providers"),
147
autorest.WithPathParameters(pathParameters),
148
autorest.WithQueryParameters(queryParameters))
151
// ListSender sends the List request. The method will close the
152
// http.Response Body if it receives an error.
153
func (client ProvidersClient) ListSender(req *http.Request) (*http.Response, error) {
154
return client.Send(req, http.StatusOK)
157
// ListResponder handles the response to the List request. The method always
158
// closes the http.Response Body.
159
func (client ProvidersClient) ListResponder(resp *http.Response) (result ProviderListResult, err error) {
160
err = autorest.Respond(
162
client.ByInspecting(),
163
autorest.WithErrorUnlessStatusCode(http.StatusOK),
164
autorest.ByUnmarshallingJSON(&result),
165
autorest.ByClosing())
166
result.Response = autorest.Response{Response: resp}
170
// ListNextResults retrieves the next set of results, if any.
171
func (client ProvidersClient) ListNextResults(lastResults ProviderListResult) (result ProviderListResult, ae error) {
172
req, err := lastResults.ProviderListResultPreparer()
174
return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure preparing next results request request")
180
resp, err := client.ListSender(req)
182
result.Response = autorest.Response{Response: resp}
183
return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure sending next results request request")
186
result, err = client.ListResponder(resp)
188
ae = autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure responding to next results request request")
194
// Register registers provider to be used with a subscription.
196
// resourceProviderNamespace is namespace of the resource provider.
197
func (client ProvidersClient) Register(resourceProviderNamespace string) (result Provider, ae error) {
198
req, err := client.RegisterPreparer(resourceProviderNamespace)
200
return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Register", "Failure preparing request")
203
resp, err := client.RegisterSender(req)
205
result.Response = autorest.Response{Response: resp}
206
return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Register", "Failure sending request")
209
result, err = client.RegisterResponder(resp)
211
ae = autorest.NewErrorWithError(err, "resources/ProvidersClient", "Register", "Failure responding to request")
217
// RegisterPreparer prepares the Register request.
218
func (client ProvidersClient) RegisterPreparer(resourceProviderNamespace string) (*http.Request, error) {
219
pathParameters := map[string]interface{}{
220
"resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace),
221
"subscriptionId": url.QueryEscape(client.SubscriptionID),
224
queryParameters := map[string]interface{}{
225
"api-version": APIVersion,
228
return autorest.Prepare(&http.Request{},
231
autorest.WithBaseURL(client.BaseURI),
232
autorest.WithPath("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"),
233
autorest.WithPathParameters(pathParameters),
234
autorest.WithQueryParameters(queryParameters))
237
// RegisterSender sends the Register request. The method will close the
238
// http.Response Body if it receives an error.
239
func (client ProvidersClient) RegisterSender(req *http.Request) (*http.Response, error) {
240
return client.Send(req, http.StatusOK)
243
// RegisterResponder handles the response to the Register request. The method always
244
// closes the http.Response Body.
245
func (client ProvidersClient) RegisterResponder(resp *http.Response) (result Provider, err error) {
246
err = autorest.Respond(
248
client.ByInspecting(),
249
autorest.WithErrorUnlessStatusCode(http.StatusOK),
250
autorest.ByUnmarshallingJSON(&result),
251
autorest.ByClosing())
252
result.Response = autorest.Response{Response: resp}
256
// Unregister unregisters provider from a subscription.
258
// resourceProviderNamespace is namespace of the resource provider.
259
func (client ProvidersClient) Unregister(resourceProviderNamespace string) (result Provider, ae error) {
260
req, err := client.UnregisterPreparer(resourceProviderNamespace)
262
return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Unregister", "Failure preparing request")
265
resp, err := client.UnregisterSender(req)
267
result.Response = autorest.Response{Response: resp}
268
return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Unregister", "Failure sending request")
271
result, err = client.UnregisterResponder(resp)
273
ae = autorest.NewErrorWithError(err, "resources/ProvidersClient", "Unregister", "Failure responding to request")
279
// UnregisterPreparer prepares the Unregister request.
280
func (client ProvidersClient) UnregisterPreparer(resourceProviderNamespace string) (*http.Request, error) {
281
pathParameters := map[string]interface{}{
282
"resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace),
283
"subscriptionId": url.QueryEscape(client.SubscriptionID),
286
queryParameters := map[string]interface{}{
287
"api-version": APIVersion,
290
return autorest.Prepare(&http.Request{},
293
autorest.WithBaseURL(client.BaseURI),
294
autorest.WithPath("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"),
295
autorest.WithPathParameters(pathParameters),
296
autorest.WithQueryParameters(queryParameters))
299
// UnregisterSender sends the Unregister request. The method will close the
300
// http.Response Body if it receives an error.
301
func (client ProvidersClient) UnregisterSender(req *http.Request) (*http.Response, error) {
302
return client.Send(req, http.StatusOK)
305
// UnregisterResponder handles the response to the Unregister request. The method always
306
// closes the http.Response Body.
307
func (client ProvidersClient) UnregisterResponder(resp *http.Response) (result Provider, err error) {
308
err = autorest.Respond(
310
client.ByInspecting(),
311
autorest.WithErrorUnlessStatusCode(http.StatusOK),
312
autorest.ByUnmarshallingJSON(&result),
313
autorest.ByClosing())
314
result.Response = autorest.Response{Response: resp}