1package 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.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"github.com/Azure/go-autorest/tracing"
25	"net/http"
26)
27
28// SecurityGroupsClient is the network Client
29type SecurityGroupsClient struct {
30	BaseClient
31}
32
33// NewSecurityGroupsClient creates an instance of the SecurityGroupsClient client.
34func NewSecurityGroupsClient(subscriptionID string) SecurityGroupsClient {
35	return NewSecurityGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID)
36}
37
38// NewSecurityGroupsClientWithBaseURI creates an instance of the SecurityGroupsClient client using a custom endpoint.
39// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
40func NewSecurityGroupsClientWithBaseURI(baseURI string, subscriptionID string) SecurityGroupsClient {
41	return SecurityGroupsClient{NewWithBaseURI(baseURI, subscriptionID)}
42}
43
44// CreateOrUpdate creates or updates a network security group in the specified resource group.
45// Parameters:
46// resourceGroupName - the name of the resource group.
47// networkSecurityGroupName - the name of the network security group.
48// parameters - parameters supplied to the create or update network security group operation.
49func (client SecurityGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, parameters SecurityGroup) (result SecurityGroupsCreateOrUpdateFuture, err error) {
50	if tracing.IsEnabled() {
51		ctx = tracing.StartSpan(ctx, fqdn+"/SecurityGroupsClient.CreateOrUpdate")
52		defer func() {
53			sc := -1
54			if result.Response() != nil {
55				sc = result.Response().StatusCode
56			}
57			tracing.EndSpan(ctx, sc, err)
58		}()
59	}
60	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, networkSecurityGroupName, parameters)
61	if err != nil {
62		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
63		return
64	}
65
66	result, err = client.CreateOrUpdateSender(req)
67	if err != nil {
68		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", nil, "Failure sending request")
69		return
70	}
71
72	return
73}
74
75// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
76func (client SecurityGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, parameters SecurityGroup) (*http.Request, error) {
77	pathParameters := map[string]interface{}{
78		"networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName),
79		"resourceGroupName":        autorest.Encode("path", resourceGroupName),
80		"subscriptionId":           autorest.Encode("path", client.SubscriptionID),
81	}
82
83	const APIVersion = "2019-07-01"
84	queryParameters := map[string]interface{}{
85		"api-version": APIVersion,
86	}
87
88	preparer := autorest.CreatePreparer(
89		autorest.AsContentType("application/json; charset=utf-8"),
90		autorest.AsPut(),
91		autorest.WithBaseURL(client.BaseURI),
92		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}", pathParameters),
93		autorest.WithJSON(parameters),
94		autorest.WithQueryParameters(queryParameters))
95	return preparer.Prepare((&http.Request{}).WithContext(ctx))
96}
97
98// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
99// http.Response Body if it receives an error.
100func (client SecurityGroupsClient) CreateOrUpdateSender(req *http.Request) (future SecurityGroupsCreateOrUpdateFuture, err error) {
101	var resp *http.Response
102	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
103	if err != nil {
104		return
105	}
106	var azf azure.Future
107	azf, err = azure.NewFutureFromResponse(resp)
108	future.FutureAPI = &azf
109	future.Result = func(client SecurityGroupsClient) (sg SecurityGroup, err error) {
110		var done bool
111		done, err = future.DoneWithContext(context.Background(), client)
112		if err != nil {
113			err = autorest.NewErrorWithError(err, "network.SecurityGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
114			return
115		}
116		if !done {
117			err = azure.NewAsyncOpIncompleteError("network.SecurityGroupsCreateOrUpdateFuture")
118			return
119		}
120		sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
121		if sg.Response.Response, err = future.GetResult(sender); err == nil && sg.Response.Response.StatusCode != http.StatusNoContent {
122			sg, err = client.CreateOrUpdateResponder(sg.Response.Response)
123			if err != nil {
124				err = autorest.NewErrorWithError(err, "network.SecurityGroupsCreateOrUpdateFuture", "Result", sg.Response.Response, "Failure responding to request")
125			}
126		}
127		return
128	}
129	return
130}
131
132// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
133// closes the http.Response Body.
134func (client SecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result SecurityGroup, err error) {
135	err = autorest.Respond(
136		resp,
137		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
138		autorest.ByUnmarshallingJSON(&result),
139		autorest.ByClosing())
140	result.Response = autorest.Response{Response: resp}
141	return
142}
143
144// Delete deletes the specified network security group.
145// Parameters:
146// resourceGroupName - the name of the resource group.
147// networkSecurityGroupName - the name of the network security group.
148func (client SecurityGroupsClient) Delete(ctx context.Context, resourceGroupName string, networkSecurityGroupName string) (result SecurityGroupsDeleteFuture, err error) {
149	if tracing.IsEnabled() {
150		ctx = tracing.StartSpan(ctx, fqdn+"/SecurityGroupsClient.Delete")
151		defer func() {
152			sc := -1
153			if result.Response() != nil {
154				sc = result.Response().StatusCode
155			}
156			tracing.EndSpan(ctx, sc, err)
157		}()
158	}
159	req, err := client.DeletePreparer(ctx, resourceGroupName, networkSecurityGroupName)
160	if err != nil {
161		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", nil, "Failure preparing request")
162		return
163	}
164
165	result, err = client.DeleteSender(req)
166	if err != nil {
167		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", nil, "Failure sending request")
168		return
169	}
170
171	return
172}
173
174// DeletePreparer prepares the Delete request.
175func (client SecurityGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, networkSecurityGroupName string) (*http.Request, error) {
176	pathParameters := map[string]interface{}{
177		"networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName),
178		"resourceGroupName":        autorest.Encode("path", resourceGroupName),
179		"subscriptionId":           autorest.Encode("path", client.SubscriptionID),
180	}
181
182	const APIVersion = "2019-07-01"
183	queryParameters := map[string]interface{}{
184		"api-version": APIVersion,
185	}
186
187	preparer := autorest.CreatePreparer(
188		autorest.AsDelete(),
189		autorest.WithBaseURL(client.BaseURI),
190		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}", pathParameters),
191		autorest.WithQueryParameters(queryParameters))
192	return preparer.Prepare((&http.Request{}).WithContext(ctx))
193}
194
195// DeleteSender sends the Delete request. The method will close the
196// http.Response Body if it receives an error.
197func (client SecurityGroupsClient) DeleteSender(req *http.Request) (future SecurityGroupsDeleteFuture, err error) {
198	var resp *http.Response
199	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
200	if err != nil {
201		return
202	}
203	var azf azure.Future
204	azf, err = azure.NewFutureFromResponse(resp)
205	future.FutureAPI = &azf
206	future.Result = func(client SecurityGroupsClient) (ar autorest.Response, err error) {
207		var done bool
208		done, err = future.DoneWithContext(context.Background(), client)
209		if err != nil {
210			err = autorest.NewErrorWithError(err, "network.SecurityGroupsDeleteFuture", "Result", future.Response(), "Polling failure")
211			return
212		}
213		if !done {
214			err = azure.NewAsyncOpIncompleteError("network.SecurityGroupsDeleteFuture")
215			return
216		}
217		ar.Response = future.Response()
218		return
219	}
220	return
221}
222
223// DeleteResponder handles the response to the Delete request. The method always
224// closes the http.Response Body.
225func (client SecurityGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
226	err = autorest.Respond(
227		resp,
228		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
229		autorest.ByClosing())
230	result.Response = resp
231	return
232}
233
234// Get gets the specified network security group.
235// Parameters:
236// resourceGroupName - the name of the resource group.
237// networkSecurityGroupName - the name of the network security group.
238// expand - expands referenced resources.
239func (client SecurityGroupsClient) Get(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, expand string) (result SecurityGroup, err error) {
240	if tracing.IsEnabled() {
241		ctx = tracing.StartSpan(ctx, fqdn+"/SecurityGroupsClient.Get")
242		defer func() {
243			sc := -1
244			if result.Response.Response != nil {
245				sc = result.Response.Response.StatusCode
246			}
247			tracing.EndSpan(ctx, sc, err)
248		}()
249	}
250	req, err := client.GetPreparer(ctx, resourceGroupName, networkSecurityGroupName, expand)
251	if err != nil {
252		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", nil, "Failure preparing request")
253		return
254	}
255
256	resp, err := client.GetSender(req)
257	if err != nil {
258		result.Response = autorest.Response{Response: resp}
259		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", resp, "Failure sending request")
260		return
261	}
262
263	result, err = client.GetResponder(resp)
264	if err != nil {
265		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", resp, "Failure responding to request")
266		return
267	}
268
269	return
270}
271
272// GetPreparer prepares the Get request.
273func (client SecurityGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, expand string) (*http.Request, error) {
274	pathParameters := map[string]interface{}{
275		"networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName),
276		"resourceGroupName":        autorest.Encode("path", resourceGroupName),
277		"subscriptionId":           autorest.Encode("path", client.SubscriptionID),
278	}
279
280	const APIVersion = "2019-07-01"
281	queryParameters := map[string]interface{}{
282		"api-version": APIVersion,
283	}
284	if len(expand) > 0 {
285		queryParameters["$expand"] = autorest.Encode("query", expand)
286	}
287
288	preparer := autorest.CreatePreparer(
289		autorest.AsGet(),
290		autorest.WithBaseURL(client.BaseURI),
291		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}", pathParameters),
292		autorest.WithQueryParameters(queryParameters))
293	return preparer.Prepare((&http.Request{}).WithContext(ctx))
294}
295
296// GetSender sends the Get request. The method will close the
297// http.Response Body if it receives an error.
298func (client SecurityGroupsClient) GetSender(req *http.Request) (*http.Response, error) {
299	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
300}
301
302// GetResponder handles the response to the Get request. The method always
303// closes the http.Response Body.
304func (client SecurityGroupsClient) GetResponder(resp *http.Response) (result SecurityGroup, err error) {
305	err = autorest.Respond(
306		resp,
307		azure.WithErrorUnlessStatusCode(http.StatusOK),
308		autorest.ByUnmarshallingJSON(&result),
309		autorest.ByClosing())
310	result.Response = autorest.Response{Response: resp}
311	return
312}
313
314// List gets all network security groups in a resource group.
315// Parameters:
316// resourceGroupName - the name of the resource group.
317func (client SecurityGroupsClient) List(ctx context.Context, resourceGroupName string) (result SecurityGroupListResultPage, err error) {
318	if tracing.IsEnabled() {
319		ctx = tracing.StartSpan(ctx, fqdn+"/SecurityGroupsClient.List")
320		defer func() {
321			sc := -1
322			if result.sglr.Response.Response != nil {
323				sc = result.sglr.Response.Response.StatusCode
324			}
325			tracing.EndSpan(ctx, sc, err)
326		}()
327	}
328	result.fn = client.listNextResults
329	req, err := client.ListPreparer(ctx, resourceGroupName)
330	if err != nil {
331		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", nil, "Failure preparing request")
332		return
333	}
334
335	resp, err := client.ListSender(req)
336	if err != nil {
337		result.sglr.Response = autorest.Response{Response: resp}
338		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure sending request")
339		return
340	}
341
342	result.sglr, err = client.ListResponder(resp)
343	if err != nil {
344		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure responding to request")
345		return
346	}
347	if result.sglr.hasNextLink() && result.sglr.IsEmpty() {
348		err = result.NextWithContext(ctx)
349		return
350	}
351
352	return
353}
354
355// ListPreparer prepares the List request.
356func (client SecurityGroupsClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
357	pathParameters := map[string]interface{}{
358		"resourceGroupName": autorest.Encode("path", resourceGroupName),
359		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
360	}
361
362	const APIVersion = "2019-07-01"
363	queryParameters := map[string]interface{}{
364		"api-version": APIVersion,
365	}
366
367	preparer := autorest.CreatePreparer(
368		autorest.AsGet(),
369		autorest.WithBaseURL(client.BaseURI),
370		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups", pathParameters),
371		autorest.WithQueryParameters(queryParameters))
372	return preparer.Prepare((&http.Request{}).WithContext(ctx))
373}
374
375// ListSender sends the List request. The method will close the
376// http.Response Body if it receives an error.
377func (client SecurityGroupsClient) ListSender(req *http.Request) (*http.Response, error) {
378	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
379}
380
381// ListResponder handles the response to the List request. The method always
382// closes the http.Response Body.
383func (client SecurityGroupsClient) ListResponder(resp *http.Response) (result SecurityGroupListResult, err error) {
384	err = autorest.Respond(
385		resp,
386		azure.WithErrorUnlessStatusCode(http.StatusOK),
387		autorest.ByUnmarshallingJSON(&result),
388		autorest.ByClosing())
389	result.Response = autorest.Response{Response: resp}
390	return
391}
392
393// listNextResults retrieves the next set of results, if any.
394func (client SecurityGroupsClient) listNextResults(ctx context.Context, lastResults SecurityGroupListResult) (result SecurityGroupListResult, err error) {
395	req, err := lastResults.securityGroupListResultPreparer(ctx)
396	if err != nil {
397		return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "listNextResults", nil, "Failure preparing next results request")
398	}
399	if req == nil {
400		return
401	}
402	resp, err := client.ListSender(req)
403	if err != nil {
404		result.Response = autorest.Response{Response: resp}
405		return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "listNextResults", resp, "Failure sending next results request")
406	}
407	result, err = client.ListResponder(resp)
408	if err != nil {
409		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "listNextResults", resp, "Failure responding to next results request")
410	}
411	return
412}
413
414// ListComplete enumerates all values, automatically crossing page boundaries as required.
415func (client SecurityGroupsClient) ListComplete(ctx context.Context, resourceGroupName string) (result SecurityGroupListResultIterator, err error) {
416	if tracing.IsEnabled() {
417		ctx = tracing.StartSpan(ctx, fqdn+"/SecurityGroupsClient.List")
418		defer func() {
419			sc := -1
420			if result.Response().Response.Response != nil {
421				sc = result.page.Response().Response.Response.StatusCode
422			}
423			tracing.EndSpan(ctx, sc, err)
424		}()
425	}
426	result.page, err = client.List(ctx, resourceGroupName)
427	return
428}
429
430// ListAll gets all network security groups in a subscription.
431func (client SecurityGroupsClient) ListAll(ctx context.Context) (result SecurityGroupListResultPage, err error) {
432	if tracing.IsEnabled() {
433		ctx = tracing.StartSpan(ctx, fqdn+"/SecurityGroupsClient.ListAll")
434		defer func() {
435			sc := -1
436			if result.sglr.Response.Response != nil {
437				sc = result.sglr.Response.Response.StatusCode
438			}
439			tracing.EndSpan(ctx, sc, err)
440		}()
441	}
442	result.fn = client.listAllNextResults
443	req, err := client.ListAllPreparer(ctx)
444	if err != nil {
445		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", nil, "Failure preparing request")
446		return
447	}
448
449	resp, err := client.ListAllSender(req)
450	if err != nil {
451		result.sglr.Response = autorest.Response{Response: resp}
452		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure sending request")
453		return
454	}
455
456	result.sglr, err = client.ListAllResponder(resp)
457	if err != nil {
458		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure responding to request")
459		return
460	}
461	if result.sglr.hasNextLink() && result.sglr.IsEmpty() {
462		err = result.NextWithContext(ctx)
463		return
464	}
465
466	return
467}
468
469// ListAllPreparer prepares the ListAll request.
470func (client SecurityGroupsClient) ListAllPreparer(ctx context.Context) (*http.Request, error) {
471	pathParameters := map[string]interface{}{
472		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
473	}
474
475	const APIVersion = "2019-07-01"
476	queryParameters := map[string]interface{}{
477		"api-version": APIVersion,
478	}
479
480	preparer := autorest.CreatePreparer(
481		autorest.AsGet(),
482		autorest.WithBaseURL(client.BaseURI),
483		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkSecurityGroups", pathParameters),
484		autorest.WithQueryParameters(queryParameters))
485	return preparer.Prepare((&http.Request{}).WithContext(ctx))
486}
487
488// ListAllSender sends the ListAll request. The method will close the
489// http.Response Body if it receives an error.
490func (client SecurityGroupsClient) ListAllSender(req *http.Request) (*http.Response, error) {
491	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
492}
493
494// ListAllResponder handles the response to the ListAll request. The method always
495// closes the http.Response Body.
496func (client SecurityGroupsClient) ListAllResponder(resp *http.Response) (result SecurityGroupListResult, err error) {
497	err = autorest.Respond(
498		resp,
499		azure.WithErrorUnlessStatusCode(http.StatusOK),
500		autorest.ByUnmarshallingJSON(&result),
501		autorest.ByClosing())
502	result.Response = autorest.Response{Response: resp}
503	return
504}
505
506// listAllNextResults retrieves the next set of results, if any.
507func (client SecurityGroupsClient) listAllNextResults(ctx context.Context, lastResults SecurityGroupListResult) (result SecurityGroupListResult, err error) {
508	req, err := lastResults.securityGroupListResultPreparer(ctx)
509	if err != nil {
510		return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "listAllNextResults", nil, "Failure preparing next results request")
511	}
512	if req == nil {
513		return
514	}
515	resp, err := client.ListAllSender(req)
516	if err != nil {
517		result.Response = autorest.Response{Response: resp}
518		return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "listAllNextResults", resp, "Failure sending next results request")
519	}
520	result, err = client.ListAllResponder(resp)
521	if err != nil {
522		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "listAllNextResults", resp, "Failure responding to next results request")
523	}
524	return
525}
526
527// ListAllComplete enumerates all values, automatically crossing page boundaries as required.
528func (client SecurityGroupsClient) ListAllComplete(ctx context.Context) (result SecurityGroupListResultIterator, err error) {
529	if tracing.IsEnabled() {
530		ctx = tracing.StartSpan(ctx, fqdn+"/SecurityGroupsClient.ListAll")
531		defer func() {
532			sc := -1
533			if result.Response().Response.Response != nil {
534				sc = result.page.Response().Response.Response.StatusCode
535			}
536			tracing.EndSpan(ctx, sc, err)
537		}()
538	}
539	result.page, err = client.ListAll(ctx)
540	return
541}
542
543// UpdateTags updates a network security group tags.
544// Parameters:
545// resourceGroupName - the name of the resource group.
546// networkSecurityGroupName - the name of the network security group.
547// parameters - parameters supplied to update network security group tags.
548func (client SecurityGroupsClient) UpdateTags(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, parameters TagsObject) (result SecurityGroupsUpdateTagsFuture, err error) {
549	if tracing.IsEnabled() {
550		ctx = tracing.StartSpan(ctx, fqdn+"/SecurityGroupsClient.UpdateTags")
551		defer func() {
552			sc := -1
553			if result.Response() != nil {
554				sc = result.Response().StatusCode
555			}
556			tracing.EndSpan(ctx, sc, err)
557		}()
558	}
559	req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, networkSecurityGroupName, parameters)
560	if err != nil {
561		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "UpdateTags", nil, "Failure preparing request")
562		return
563	}
564
565	result, err = client.UpdateTagsSender(req)
566	if err != nil {
567		err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "UpdateTags", nil, "Failure sending request")
568		return
569	}
570
571	return
572}
573
574// UpdateTagsPreparer prepares the UpdateTags request.
575func (client SecurityGroupsClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, parameters TagsObject) (*http.Request, error) {
576	pathParameters := map[string]interface{}{
577		"networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName),
578		"resourceGroupName":        autorest.Encode("path", resourceGroupName),
579		"subscriptionId":           autorest.Encode("path", client.SubscriptionID),
580	}
581
582	const APIVersion = "2019-07-01"
583	queryParameters := map[string]interface{}{
584		"api-version": APIVersion,
585	}
586
587	preparer := autorest.CreatePreparer(
588		autorest.AsContentType("application/json; charset=utf-8"),
589		autorest.AsPatch(),
590		autorest.WithBaseURL(client.BaseURI),
591		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}", pathParameters),
592		autorest.WithJSON(parameters),
593		autorest.WithQueryParameters(queryParameters))
594	return preparer.Prepare((&http.Request{}).WithContext(ctx))
595}
596
597// UpdateTagsSender sends the UpdateTags request. The method will close the
598// http.Response Body if it receives an error.
599func (client SecurityGroupsClient) UpdateTagsSender(req *http.Request) (future SecurityGroupsUpdateTagsFuture, err error) {
600	var resp *http.Response
601	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
602	if err != nil {
603		return
604	}
605	var azf azure.Future
606	azf, err = azure.NewFutureFromResponse(resp)
607	future.FutureAPI = &azf
608	future.Result = func(client SecurityGroupsClient) (sg SecurityGroup, err error) {
609		var done bool
610		done, err = future.DoneWithContext(context.Background(), client)
611		if err != nil {
612			err = autorest.NewErrorWithError(err, "network.SecurityGroupsUpdateTagsFuture", "Result", future.Response(), "Polling failure")
613			return
614		}
615		if !done {
616			err = azure.NewAsyncOpIncompleteError("network.SecurityGroupsUpdateTagsFuture")
617			return
618		}
619		sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
620		if sg.Response.Response, err = future.GetResult(sender); err == nil && sg.Response.Response.StatusCode != http.StatusNoContent {
621			sg, err = client.UpdateTagsResponder(sg.Response.Response)
622			if err != nil {
623				err = autorest.NewErrorWithError(err, "network.SecurityGroupsUpdateTagsFuture", "Result", sg.Response.Response, "Failure responding to request")
624			}
625		}
626		return
627	}
628	return
629}
630
631// UpdateTagsResponder handles the response to the UpdateTags request. The method always
632// closes the http.Response Body.
633func (client SecurityGroupsClient) UpdateTagsResponder(resp *http.Response) (result SecurityGroup, err error) {
634	err = autorest.Respond(
635		resp,
636		azure.WithErrorUnlessStatusCode(http.StatusOK),
637		autorest.ByUnmarshallingJSON(&result),
638		autorest.ByClosing())
639	result.Response = autorest.Response{Response: resp}
640	return
641}
642