~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/Azure/azure-sdk-for-go/arm/network/routes.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 network
 
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
// RoutesClient is the the Windows Azure Network management API provides a
 
28
// RESTful set of web services that interact with Windows Azure Networks
 
29
// service to manage your network resrources. The API has entities that
 
30
// capture the relationship between an end user and the Windows Azure
 
31
// Networks service.
 
32
type RoutesClient struct {
 
33
        ManagementClient
 
34
}
 
35
 
 
36
// NewRoutesClient creates an instance of the RoutesClient client.
 
37
func NewRoutesClient(subscriptionID string) RoutesClient {
 
38
        return NewRoutesClientWithBaseURI(DefaultBaseURI, subscriptionID)
 
39
}
 
40
 
 
41
// NewRoutesClientWithBaseURI creates an instance of the RoutesClient client.
 
42
func NewRoutesClientWithBaseURI(baseURI string, subscriptionID string) RoutesClient {
 
43
        return RoutesClient{NewWithBaseURI(baseURI, subscriptionID)}
 
44
}
 
45
 
 
46
// CreateOrUpdate the Put route operation creates/updates a route in the
 
47
// specified route table
 
48
//
 
49
// resourceGroupName is the name of the resource group. routeTableName is the
 
50
// name of the route table. routeName is the name of the route.
 
51
// routeParameters is parameters supplied to the create/update routeoperation
 
52
func (client RoutesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, routeName string, routeParameters Route) (result Route, ae error) {
 
53
        req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, routeName, routeParameters)
 
54
        if err != nil {
 
55
                return result, autorest.NewErrorWithError(err, "network/RoutesClient", "CreateOrUpdate", "Failure preparing request")
 
56
        }
 
57
 
 
58
        resp, err := client.CreateOrUpdateSender(req)
 
59
        if err != nil {
 
60
                result.Response = autorest.Response{Response: resp}
 
61
                return result, autorest.NewErrorWithError(err, "network/RoutesClient", "CreateOrUpdate", "Failure sending request")
 
62
        }
 
63
 
 
64
        result, err = client.CreateOrUpdateResponder(resp)
 
65
        if err != nil {
 
66
                ae = autorest.NewErrorWithError(err, "network/RoutesClient", "CreateOrUpdate", "Failure responding to request")
 
67
        }
 
68
 
 
69
        return
 
70
}
 
71
 
 
72
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
 
73
func (client RoutesClient) CreateOrUpdatePreparer(resourceGroupName string, routeTableName string, routeName string, routeParameters Route) (*http.Request, error) {
 
74
        pathParameters := map[string]interface{}{
 
75
                "resourceGroupName": url.QueryEscape(resourceGroupName),
 
76
                "routeName":         url.QueryEscape(routeName),
 
77
                "routeTableName":    url.QueryEscape(routeTableName),
 
78
                "subscriptionId":    url.QueryEscape(client.SubscriptionID),
 
79
        }
 
80
 
 
81
        queryParameters := map[string]interface{}{
 
82
                "api-version": APIVersion,
 
83
        }
 
84
 
 
85
        return autorest.Prepare(&http.Request{},
 
86
                autorest.AsJSON(),
 
87
                autorest.AsPut(),
 
88
                autorest.WithBaseURL(client.BaseURI),
 
89
                autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}"),
 
90
                autorest.WithJSON(routeParameters),
 
91
                autorest.WithPathParameters(pathParameters),
 
92
                autorest.WithQueryParameters(queryParameters))
 
93
}
 
94
 
 
95
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
 
96
// http.Response Body if it receives an error.
 
97
func (client RoutesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
 
98
        return client.Send(req, http.StatusCreated, http.StatusOK)
 
99
}
 
100
 
 
101
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
 
102
// closes the http.Response Body.
 
103
func (client RoutesClient) CreateOrUpdateResponder(resp *http.Response) (result Route, err error) {
 
104
        err = autorest.Respond(
 
105
                resp,
 
106
                client.ByInspecting(),
 
107
                autorest.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
 
108
                autorest.ByUnmarshallingJSON(&result),
 
109
                autorest.ByClosing())
 
110
        result.Response = autorest.Response{Response: resp}
 
111
        return
 
112
}
 
113
 
 
114
// Delete the delete route operation deletes the specified route from a route
 
115
// table.
 
116
//
 
117
// resourceGroupName is the name of the resource group. routeTableName is the
 
118
// name of the route table. routeName is the name of the route.
 
119
func (client RoutesClient) Delete(resourceGroupName string, routeTableName string, routeName string) (result autorest.Response, ae error) {
 
120
        req, err := client.DeletePreparer(resourceGroupName, routeTableName, routeName)
 
121
        if err != nil {
 
122
                return result, autorest.NewErrorWithError(err, "network/RoutesClient", "Delete", "Failure preparing request")
 
123
        }
 
124
 
 
125
        resp, err := client.DeleteSender(req)
 
126
        if err != nil {
 
127
                result.Response = resp
 
128
                return result, autorest.NewErrorWithError(err, "network/RoutesClient", "Delete", "Failure sending request")
 
129
        }
 
130
 
 
131
        result, err = client.DeleteResponder(resp)
 
132
        if err != nil {
 
133
                ae = autorest.NewErrorWithError(err, "network/RoutesClient", "Delete", "Failure responding to request")
 
134
        }
 
135
 
 
136
        return
 
137
}
 
138
 
 
139
// DeletePreparer prepares the Delete request.
 
140
func (client RoutesClient) DeletePreparer(resourceGroupName string, routeTableName string, routeName string) (*http.Request, error) {
 
141
        pathParameters := map[string]interface{}{
 
142
                "resourceGroupName": url.QueryEscape(resourceGroupName),
 
143
                "routeName":         url.QueryEscape(routeName),
 
144
                "routeTableName":    url.QueryEscape(routeTableName),
 
145
                "subscriptionId":    url.QueryEscape(client.SubscriptionID),
 
146
        }
 
147
 
 
148
        queryParameters := map[string]interface{}{
 
149
                "api-version": APIVersion,
 
150
        }
 
151
 
 
152
        return autorest.Prepare(&http.Request{},
 
153
                autorest.AsJSON(),
 
154
                autorest.AsDelete(),
 
155
                autorest.WithBaseURL(client.BaseURI),
 
156
                autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}"),
 
157
                autorest.WithPathParameters(pathParameters),
 
158
                autorest.WithQueryParameters(queryParameters))
 
159
}
 
160
 
 
161
// DeleteSender sends the Delete request. The method will close the
 
162
// http.Response Body if it receives an error.
 
163
func (client RoutesClient) DeleteSender(req *http.Request) (*http.Response, error) {
 
164
        return client.Send(req, http.StatusNoContent, http.StatusAccepted, http.StatusOK)
 
165
}
 
166
 
 
167
// DeleteResponder handles the response to the Delete request. The method always
 
168
// closes the http.Response Body.
 
169
func (client RoutesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
 
170
        err = autorest.Respond(
 
171
                resp,
 
172
                client.ByInspecting(),
 
173
                autorest.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusAccepted, http.StatusOK),
 
174
                autorest.ByClosing())
 
175
        result.Response = resp
 
176
        return
 
177
}
 
178
 
 
179
// Get the Get route operation retreives information about the specified route
 
180
// from the route table.
 
181
//
 
182
// resourceGroupName is the name of the resource group. routeTableName is the
 
183
// name of the route table. routeName is the name of the route.
 
184
func (client RoutesClient) Get(resourceGroupName string, routeTableName string, routeName string) (result Route, ae error) {
 
185
        req, err := client.GetPreparer(resourceGroupName, routeTableName, routeName)
 
186
        if err != nil {
 
187
                return result, autorest.NewErrorWithError(err, "network/RoutesClient", "Get", "Failure preparing request")
 
188
        }
 
189
 
 
190
        resp, err := client.GetSender(req)
 
191
        if err != nil {
 
192
                result.Response = autorest.Response{Response: resp}
 
193
                return result, autorest.NewErrorWithError(err, "network/RoutesClient", "Get", "Failure sending request")
 
194
        }
 
195
 
 
196
        result, err = client.GetResponder(resp)
 
197
        if err != nil {
 
198
                ae = autorest.NewErrorWithError(err, "network/RoutesClient", "Get", "Failure responding to request")
 
199
        }
 
200
 
 
201
        return
 
202
}
 
203
 
 
204
// GetPreparer prepares the Get request.
 
205
func (client RoutesClient) GetPreparer(resourceGroupName string, routeTableName string, routeName string) (*http.Request, error) {
 
206
        pathParameters := map[string]interface{}{
 
207
                "resourceGroupName": url.QueryEscape(resourceGroupName),
 
208
                "routeName":         url.QueryEscape(routeName),
 
209
                "routeTableName":    url.QueryEscape(routeTableName),
 
210
                "subscriptionId":    url.QueryEscape(client.SubscriptionID),
 
211
        }
 
212
 
 
213
        queryParameters := map[string]interface{}{
 
214
                "api-version": APIVersion,
 
215
        }
 
216
 
 
217
        return autorest.Prepare(&http.Request{},
 
218
                autorest.AsJSON(),
 
219
                autorest.AsGet(),
 
220
                autorest.WithBaseURL(client.BaseURI),
 
221
                autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}"),
 
222
                autorest.WithPathParameters(pathParameters),
 
223
                autorest.WithQueryParameters(queryParameters))
 
224
}
 
225
 
 
226
// GetSender sends the Get request. The method will close the
 
227
// http.Response Body if it receives an error.
 
228
func (client RoutesClient) GetSender(req *http.Request) (*http.Response, error) {
 
229
        return client.Send(req, http.StatusOK)
 
230
}
 
231
 
 
232
// GetResponder handles the response to the Get request. The method always
 
233
// closes the http.Response Body.
 
234
func (client RoutesClient) GetResponder(resp *http.Response) (result Route, err error) {
 
235
        err = autorest.Respond(
 
236
                resp,
 
237
                client.ByInspecting(),
 
238
                autorest.WithErrorUnlessStatusCode(http.StatusOK),
 
239
                autorest.ByUnmarshallingJSON(&result),
 
240
                autorest.ByClosing())
 
241
        result.Response = autorest.Response{Response: resp}
 
242
        return
 
243
}
 
244
 
 
245
// List the List network security rule opertion retrieves all the routes in a
 
246
// route table.
 
247
//
 
248
// resourceGroupName is the name of the resource group. routeTableName is the
 
249
// name of the route table.
 
250
func (client RoutesClient) List(resourceGroupName string, routeTableName string) (result RouteListResult, ae error) {
 
251
        req, err := client.ListPreparer(resourceGroupName, routeTableName)
 
252
        if err != nil {
 
253
                return result, autorest.NewErrorWithError(err, "network/RoutesClient", "List", "Failure preparing request")
 
254
        }
 
255
 
 
256
        resp, err := client.ListSender(req)
 
257
        if err != nil {
 
258
                result.Response = autorest.Response{Response: resp}
 
259
                return result, autorest.NewErrorWithError(err, "network/RoutesClient", "List", "Failure sending request")
 
260
        }
 
261
 
 
262
        result, err = client.ListResponder(resp)
 
263
        if err != nil {
 
264
                ae = autorest.NewErrorWithError(err, "network/RoutesClient", "List", "Failure responding to request")
 
265
        }
 
266
 
 
267
        return
 
268
}
 
269
 
 
270
// ListPreparer prepares the List request.
 
271
func (client RoutesClient) ListPreparer(resourceGroupName string, routeTableName string) (*http.Request, error) {
 
272
        pathParameters := map[string]interface{}{
 
273
                "resourceGroupName": url.QueryEscape(resourceGroupName),
 
274
                "routeTableName":    url.QueryEscape(routeTableName),
 
275
                "subscriptionId":    url.QueryEscape(client.SubscriptionID),
 
276
        }
 
277
 
 
278
        queryParameters := map[string]interface{}{
 
279
                "api-version": APIVersion,
 
280
        }
 
281
 
 
282
        return autorest.Prepare(&http.Request{},
 
283
                autorest.AsJSON(),
 
284
                autorest.AsGet(),
 
285
                autorest.WithBaseURL(client.BaseURI),
 
286
                autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes"),
 
287
                autorest.WithPathParameters(pathParameters),
 
288
                autorest.WithQueryParameters(queryParameters))
 
289
}
 
290
 
 
291
// ListSender sends the List request. The method will close the
 
292
// http.Response Body if it receives an error.
 
293
func (client RoutesClient) ListSender(req *http.Request) (*http.Response, error) {
 
294
        return client.Send(req, http.StatusOK)
 
295
}
 
296
 
 
297
// ListResponder handles the response to the List request. The method always
 
298
// closes the http.Response Body.
 
299
func (client RoutesClient) ListResponder(resp *http.Response) (result RouteListResult, err error) {
 
300
        err = autorest.Respond(
 
301
                resp,
 
302
                client.ByInspecting(),
 
303
                autorest.WithErrorUnlessStatusCode(http.StatusOK),
 
304
                autorest.ByUnmarshallingJSON(&result),
 
305
                autorest.ByClosing())
 
306
        result.Response = autorest.Response{Response: resp}
 
307
        return
 
308
}
 
309
 
 
310
// ListNextResults retrieves the next set of results, if any.
 
311
func (client RoutesClient) ListNextResults(lastResults RouteListResult) (result RouteListResult, ae error) {
 
312
        req, err := lastResults.RouteListResultPreparer()
 
313
        if err != nil {
 
314
                return result, autorest.NewErrorWithError(err, "network/RoutesClient", "List", "Failure preparing next results request request")
 
315
        }
 
316
        if req == nil {
 
317
                return
 
318
        }
 
319
 
 
320
        resp, err := client.ListSender(req)
 
321
        if err != nil {
 
322
                result.Response = autorest.Response{Response: resp}
 
323
                return result, autorest.NewErrorWithError(err, "network/RoutesClient", "List", "Failure sending next results request request")
 
324
        }
 
325
 
 
326
        result, err = client.ListResponder(resp)
 
327
        if err != nil {
 
328
                ae = autorest.NewErrorWithError(err, "network/RoutesClient", "List", "Failure responding to next results request request")
 
329
        }
 
330
 
 
331
        return
 
332
}