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