~nskaggs/+junk/xenial-test

« back to all changes in this revision

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