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
// 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
32
type SecurityRulesClient struct {
36
// NewSecurityRulesClient creates an instance of the SecurityRulesClient
38
func NewSecurityRulesClient(subscriptionID string) SecurityRulesClient {
39
return NewSecurityRulesClientWithBaseURI(DefaultBaseURI, subscriptionID)
42
// NewSecurityRulesClientWithBaseURI creates an instance of the
43
// SecurityRulesClient client.
44
func NewSecurityRulesClientWithBaseURI(baseURI string, subscriptionID string) SecurityRulesClient {
45
return SecurityRulesClient{NewWithBaseURI(baseURI, subscriptionID)}
48
// CreateOrUpdate the Put network security rule operation creates/updates a
49
// security rule in the specified network security group
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
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)
59
return result, autorest.NewErrorWithError(err, "network/SecurityRulesClient", "CreateOrUpdate", "Failure preparing request")
62
resp, err := client.CreateOrUpdateSender(req)
64
result.Response = autorest.Response{Response: resp}
65
return result, autorest.NewErrorWithError(err, "network/SecurityRulesClient", "CreateOrUpdate", "Failure sending request")
68
result, err = client.CreateOrUpdateResponder(resp)
70
ae = autorest.NewErrorWithError(err, "network/SecurityRulesClient", "CreateOrUpdate", "Failure responding to request")
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),
85
queryParameters := map[string]interface{}{
86
"api-version": APIVersion,
89
return autorest.Prepare(&http.Request{},
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))
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)
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(
110
client.ByInspecting(),
111
autorest.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
112
autorest.ByUnmarshallingJSON(&result),
113
autorest.ByClosing())
114
result.Response = autorest.Response{Response: resp}
118
// Delete the delete network security rule operation deletes the specified
119
// network security rule.
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)
127
return result, autorest.NewErrorWithError(err, "network/SecurityRulesClient", "Delete", "Failure preparing request")
130
resp, err := client.DeleteSender(req)
132
result.Response = resp
133
return result, autorest.NewErrorWithError(err, "network/SecurityRulesClient", "Delete", "Failure sending request")
136
result, err = client.DeleteResponder(resp)
138
ae = autorest.NewErrorWithError(err, "network/SecurityRulesClient", "Delete", "Failure responding to request")
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),
153
queryParameters := map[string]interface{}{
154
"api-version": APIVersion,
157
return autorest.Prepare(&http.Request{},
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))
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)
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(
177
client.ByInspecting(),
178
autorest.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusAccepted, http.StatusOK),
179
autorest.ByClosing())
180
result.Response = resp
184
// Get the Get NetworkSecurityRule operation retreives information about the
185
// specified network security rule.
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)
193
return result, autorest.NewErrorWithError(err, "network/SecurityRulesClient", "Get", "Failure preparing request")
196
resp, err := client.GetSender(req)
198
result.Response = autorest.Response{Response: resp}
199
return result, autorest.NewErrorWithError(err, "network/SecurityRulesClient", "Get", "Failure sending request")
202
result, err = client.GetResponder(resp)
204
ae = autorest.NewErrorWithError(err, "network/SecurityRulesClient", "Get", "Failure responding to request")
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),
219
queryParameters := map[string]interface{}{
220
"api-version": APIVersion,
223
return autorest.Prepare(&http.Request{},
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))
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)
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(
243
client.ByInspecting(),
244
autorest.WithErrorUnlessStatusCode(http.StatusOK),
245
autorest.ByUnmarshallingJSON(&result),
246
autorest.ByClosing())
247
result.Response = autorest.Response{Response: resp}
251
// List the List network security rule opertion retrieves all the security
252
// rules in a network security group.
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)
259
return result, autorest.NewErrorWithError(err, "network/SecurityRulesClient", "List", "Failure preparing request")
262
resp, err := client.ListSender(req)
264
result.Response = autorest.Response{Response: resp}
265
return result, autorest.NewErrorWithError(err, "network/SecurityRulesClient", "List", "Failure sending request")
268
result, err = client.ListResponder(resp)
270
ae = autorest.NewErrorWithError(err, "network/SecurityRulesClient", "List", "Failure responding to request")
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),
284
queryParameters := map[string]interface{}{
285
"api-version": APIVersion,
288
return autorest.Prepare(&http.Request{},
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))
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)
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(
308
client.ByInspecting(),
309
autorest.WithErrorUnlessStatusCode(http.StatusOK),
310
autorest.ByUnmarshallingJSON(&result),
311
autorest.ByClosing())
312
result.Response = autorest.Response{Response: resp}
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()
320
return result, autorest.NewErrorWithError(err, "network/SecurityRulesClient", "List", "Failure preparing next results request request")
326
resp, err := client.ListSender(req)
328
result.Response = autorest.Response{Response: resp}
329
return result, autorest.NewErrorWithError(err, "network/SecurityRulesClient", "List", "Failure sending next results request request")
332
result, err = client.ListResponder(resp)
334
ae = autorest.NewErrorWithError(err, "network/SecurityRulesClient", "List", "Failure responding to next results request request")