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