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