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