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