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