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