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