~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/Azure/azure-sdk-for-go/arm/resources/providers.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package resources
 
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 0.12.0.0
 
18
// Changes may cause incorrect behavior and will be lost if the code is
 
19
// regenerated.
 
20
 
 
21
import (
 
22
        "github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest"
 
23
        "net/http"
 
24
        "net/url"
 
25
)
 
26
 
 
27
// ProvidersClient is the client for the Providers methods of the Resources
 
28
// service.
 
29
type ProvidersClient struct {
 
30
        ManagementClient
 
31
}
 
32
 
 
33
// NewProvidersClient creates an instance of the ProvidersClient client.
 
34
func NewProvidersClient(subscriptionID string) ProvidersClient {
 
35
        return NewProvidersClientWithBaseURI(DefaultBaseURI, subscriptionID)
 
36
}
 
37
 
 
38
// NewProvidersClientWithBaseURI creates an instance of the ProvidersClient
 
39
// client.
 
40
func NewProvidersClientWithBaseURI(baseURI string, subscriptionID string) ProvidersClient {
 
41
        return ProvidersClient{NewWithBaseURI(baseURI, subscriptionID)}
 
42
}
 
43
 
 
44
// Get gets a resource provider.
 
45
//
 
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)
 
49
        if err != nil {
 
50
                return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Get", "Failure preparing request")
 
51
        }
 
52
 
 
53
        resp, err := client.GetSender(req)
 
54
        if err != nil {
 
55
                result.Response = autorest.Response{Response: resp}
 
56
                return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Get", "Failure sending request")
 
57
        }
 
58
 
 
59
        result, err = client.GetResponder(resp)
 
60
        if err != nil {
 
61
                ae = autorest.NewErrorWithError(err, "resources/ProvidersClient", "Get", "Failure responding to request")
 
62
        }
 
63
 
 
64
        return
 
65
}
 
66
 
 
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),
 
72
        }
 
73
 
 
74
        queryParameters := map[string]interface{}{
 
75
                "api-version": APIVersion,
 
76
        }
 
77
 
 
78
        return autorest.Prepare(&http.Request{},
 
79
                autorest.AsJSON(),
 
80
                autorest.AsGet(),
 
81
                autorest.WithBaseURL(client.BaseURI),
 
82
                autorest.WithPath("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"),
 
83
                autorest.WithPathParameters(pathParameters),
 
84
                autorest.WithQueryParameters(queryParameters))
 
85
}
 
86
 
 
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)
 
91
}
 
92
 
 
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(
 
97
                resp,
 
98
                client.ByInspecting(),
 
99
                autorest.WithErrorUnlessStatusCode(http.StatusOK),
 
100
                autorest.ByUnmarshallingJSON(&result),
 
101
                autorest.ByClosing())
 
102
        result.Response = autorest.Response{Response: resp}
 
103
        return
 
104
}
 
105
 
 
106
// List gets a list of resource providers.
 
107
//
 
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)
 
111
        if err != nil {
 
112
                return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure preparing request")
 
113
        }
 
114
 
 
115
        resp, err := client.ListSender(req)
 
116
        if err != nil {
 
117
                result.Response = autorest.Response{Response: resp}
 
118
                return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure sending request")
 
119
        }
 
120
 
 
121
        result, err = client.ListResponder(resp)
 
122
        if err != nil {
 
123
                ae = autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure responding to request")
 
124
        }
 
125
 
 
126
        return
 
127
}
 
128
 
 
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),
 
133
        }
 
134
 
 
135
        queryParameters := map[string]interface{}{
 
136
                "api-version": APIVersion,
 
137
        }
 
138
        if top != nil {
 
139
                queryParameters["$top"] = top
 
140
        }
 
141
 
 
142
        return autorest.Prepare(&http.Request{},
 
143
                autorest.AsJSON(),
 
144
                autorest.AsGet(),
 
145
                autorest.WithBaseURL(client.BaseURI),
 
146
                autorest.WithPath("/subscriptions/{subscriptionId}/providers"),
 
147
                autorest.WithPathParameters(pathParameters),
 
148
                autorest.WithQueryParameters(queryParameters))
 
149
}
 
150
 
 
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)
 
155
}
 
156
 
 
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(
 
161
                resp,
 
162
                client.ByInspecting(),
 
163
                autorest.WithErrorUnlessStatusCode(http.StatusOK),
 
164
                autorest.ByUnmarshallingJSON(&result),
 
165
                autorest.ByClosing())
 
166
        result.Response = autorest.Response{Response: resp}
 
167
        return
 
168
}
 
169
 
 
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()
 
173
        if err != nil {
 
174
                return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure preparing next results request request")
 
175
        }
 
176
        if req == nil {
 
177
                return
 
178
        }
 
179
 
 
180
        resp, err := client.ListSender(req)
 
181
        if err != nil {
 
182
                result.Response = autorest.Response{Response: resp}
 
183
                return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure sending next results request request")
 
184
        }
 
185
 
 
186
        result, err = client.ListResponder(resp)
 
187
        if err != nil {
 
188
                ae = autorest.NewErrorWithError(err, "resources/ProvidersClient", "List", "Failure responding to next results request request")
 
189
        }
 
190
 
 
191
        return
 
192
}
 
193
 
 
194
// Register registers provider to be used with a subscription.
 
195
//
 
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)
 
199
        if err != nil {
 
200
                return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Register", "Failure preparing request")
 
201
        }
 
202
 
 
203
        resp, err := client.RegisterSender(req)
 
204
        if err != nil {
 
205
                result.Response = autorest.Response{Response: resp}
 
206
                return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Register", "Failure sending request")
 
207
        }
 
208
 
 
209
        result, err = client.RegisterResponder(resp)
 
210
        if err != nil {
 
211
                ae = autorest.NewErrorWithError(err, "resources/ProvidersClient", "Register", "Failure responding to request")
 
212
        }
 
213
 
 
214
        return
 
215
}
 
216
 
 
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),
 
222
        }
 
223
 
 
224
        queryParameters := map[string]interface{}{
 
225
                "api-version": APIVersion,
 
226
        }
 
227
 
 
228
        return autorest.Prepare(&http.Request{},
 
229
                autorest.AsJSON(),
 
230
                autorest.AsPost(),
 
231
                autorest.WithBaseURL(client.BaseURI),
 
232
                autorest.WithPath("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"),
 
233
                autorest.WithPathParameters(pathParameters),
 
234
                autorest.WithQueryParameters(queryParameters))
 
235
}
 
236
 
 
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)
 
241
}
 
242
 
 
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(
 
247
                resp,
 
248
                client.ByInspecting(),
 
249
                autorest.WithErrorUnlessStatusCode(http.StatusOK),
 
250
                autorest.ByUnmarshallingJSON(&result),
 
251
                autorest.ByClosing())
 
252
        result.Response = autorest.Response{Response: resp}
 
253
        return
 
254
}
 
255
 
 
256
// Unregister unregisters provider from a subscription.
 
257
//
 
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)
 
261
        if err != nil {
 
262
                return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Unregister", "Failure preparing request")
 
263
        }
 
264
 
 
265
        resp, err := client.UnregisterSender(req)
 
266
        if err != nil {
 
267
                result.Response = autorest.Response{Response: resp}
 
268
                return result, autorest.NewErrorWithError(err, "resources/ProvidersClient", "Unregister", "Failure sending request")
 
269
        }
 
270
 
 
271
        result, err = client.UnregisterResponder(resp)
 
272
        if err != nil {
 
273
                ae = autorest.NewErrorWithError(err, "resources/ProvidersClient", "Unregister", "Failure responding to request")
 
274
        }
 
275
 
 
276
        return
 
277
}
 
278
 
 
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),
 
284
        }
 
285
 
 
286
        queryParameters := map[string]interface{}{
 
287
                "api-version": APIVersion,
 
288
        }
 
289
 
 
290
        return autorest.Prepare(&http.Request{},
 
291
                autorest.AsJSON(),
 
292
                autorest.AsPost(),
 
293
                autorest.WithBaseURL(client.BaseURI),
 
294
                autorest.WithPath("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"),
 
295
                autorest.WithPathParameters(pathParameters),
 
296
                autorest.WithQueryParameters(queryParameters))
 
297
}
 
298
 
 
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)
 
303
}
 
304
 
 
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(
 
309
                resp,
 
310
                client.ByInspecting(),
 
311
                autorest.WithErrorUnlessStatusCode(http.StatusOK),
 
312
                autorest.ByUnmarshallingJSON(&result),
 
313
                autorest.ByClosing())
 
314
        result.Response = autorest.Response{Response: resp}
 
315
        return
 
316
}