1package network 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/tracing" 14 "net/http" 15) 16 17// ProfilesClient is the network Client 18type ProfilesClient struct { 19 BaseClient 20} 21 22// NewProfilesClient creates an instance of the ProfilesClient client. 23func NewProfilesClient(subscriptionID string) ProfilesClient { 24 return NewProfilesClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewProfilesClientWithBaseURI creates an instance of the ProfilesClient client using a custom endpoint. Use this 28// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 29func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) ProfilesClient { 30 return ProfilesClient{NewWithBaseURI(baseURI, subscriptionID)} 31} 32 33// CreateOrUpdate creates or updates a network profile. 34// Parameters: 35// resourceGroupName - the name of the resource group. 36// networkProfileName - the name of the network profile. 37// parameters - parameters supplied to the create or update network profile operation. 38func (client ProfilesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, networkProfileName string, parameters Profile) (result Profile, err error) { 39 if tracing.IsEnabled() { 40 ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.CreateOrUpdate") 41 defer func() { 42 sc := -1 43 if result.Response.Response != nil { 44 sc = result.Response.Response.StatusCode 45 } 46 tracing.EndSpan(ctx, sc, err) 47 }() 48 } 49 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, networkProfileName, parameters) 50 if err != nil { 51 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") 52 return 53 } 54 55 resp, err := client.CreateOrUpdateSender(req) 56 if err != nil { 57 result.Response = autorest.Response{Response: resp} 58 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "CreateOrUpdate", resp, "Failure sending request") 59 return 60 } 61 62 result, err = client.CreateOrUpdateResponder(resp) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "CreateOrUpdate", resp, "Failure responding to request") 65 return 66 } 67 68 return 69} 70 71// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 72func (client ProfilesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, networkProfileName string, parameters Profile) (*http.Request, error) { 73 pathParameters := map[string]interface{}{ 74 "networkProfileName": autorest.Encode("path", networkProfileName), 75 "resourceGroupName": autorest.Encode("path", resourceGroupName), 76 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 77 } 78 79 const APIVersion = "2019-07-01" 80 queryParameters := map[string]interface{}{ 81 "api-version": APIVersion, 82 } 83 84 preparer := autorest.CreatePreparer( 85 autorest.AsContentType("application/json; charset=utf-8"), 86 autorest.AsPut(), 87 autorest.WithBaseURL(client.BaseURI), 88 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkProfiles/{networkProfileName}", pathParameters), 89 autorest.WithJSON(parameters), 90 autorest.WithQueryParameters(queryParameters)) 91 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 92} 93 94// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 95// http.Response Body if it receives an error. 96func (client ProfilesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 97 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 98} 99 100// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 101// closes the http.Response Body. 102func (client ProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result Profile, err error) { 103 err = autorest.Respond( 104 resp, 105 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 106 autorest.ByUnmarshallingJSON(&result), 107 autorest.ByClosing()) 108 result.Response = autorest.Response{Response: resp} 109 return 110} 111 112// Delete deletes the specified network profile. 113// Parameters: 114// resourceGroupName - the name of the resource group. 115// networkProfileName - the name of the NetworkProfile. 116func (client ProfilesClient) Delete(ctx context.Context, resourceGroupName string, networkProfileName string) (result ProfilesDeleteFuture, err error) { 117 if tracing.IsEnabled() { 118 ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.Delete") 119 defer func() { 120 sc := -1 121 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 122 sc = result.FutureAPI.Response().StatusCode 123 } 124 tracing.EndSpan(ctx, sc, err) 125 }() 126 } 127 req, err := client.DeletePreparer(ctx, resourceGroupName, networkProfileName) 128 if err != nil { 129 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "Delete", nil, "Failure preparing request") 130 return 131 } 132 133 result, err = client.DeleteSender(req) 134 if err != nil { 135 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "Delete", nil, "Failure sending request") 136 return 137 } 138 139 return 140} 141 142// DeletePreparer prepares the Delete request. 143func (client ProfilesClient) DeletePreparer(ctx context.Context, resourceGroupName string, networkProfileName string) (*http.Request, error) { 144 pathParameters := map[string]interface{}{ 145 "networkProfileName": autorest.Encode("path", networkProfileName), 146 "resourceGroupName": autorest.Encode("path", resourceGroupName), 147 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 148 } 149 150 const APIVersion = "2019-07-01" 151 queryParameters := map[string]interface{}{ 152 "api-version": APIVersion, 153 } 154 155 preparer := autorest.CreatePreparer( 156 autorest.AsDelete(), 157 autorest.WithBaseURL(client.BaseURI), 158 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkProfiles/{networkProfileName}", pathParameters), 159 autorest.WithQueryParameters(queryParameters)) 160 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 161} 162 163// DeleteSender sends the Delete request. The method will close the 164// http.Response Body if it receives an error. 165func (client ProfilesClient) DeleteSender(req *http.Request) (future ProfilesDeleteFuture, err error) { 166 var resp *http.Response 167 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 168 if err != nil { 169 return 170 } 171 var azf azure.Future 172 azf, err = azure.NewFutureFromResponse(resp) 173 future.FutureAPI = &azf 174 future.Result = future.result 175 return 176} 177 178// DeleteResponder handles the response to the Delete request. The method always 179// closes the http.Response Body. 180func (client ProfilesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 181 err = autorest.Respond( 182 resp, 183 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 184 autorest.ByClosing()) 185 result.Response = resp 186 return 187} 188 189// Get gets the specified network profile in a specified resource group. 190// Parameters: 191// resourceGroupName - the name of the resource group. 192// networkProfileName - the name of the public IP prefix. 193// expand - expands referenced resources. 194func (client ProfilesClient) Get(ctx context.Context, resourceGroupName string, networkProfileName string, expand string) (result Profile, err error) { 195 if tracing.IsEnabled() { 196 ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.Get") 197 defer func() { 198 sc := -1 199 if result.Response.Response != nil { 200 sc = result.Response.Response.StatusCode 201 } 202 tracing.EndSpan(ctx, sc, err) 203 }() 204 } 205 req, err := client.GetPreparer(ctx, resourceGroupName, networkProfileName, expand) 206 if err != nil { 207 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "Get", nil, "Failure preparing request") 208 return 209 } 210 211 resp, err := client.GetSender(req) 212 if err != nil { 213 result.Response = autorest.Response{Response: resp} 214 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "Get", resp, "Failure sending request") 215 return 216 } 217 218 result, err = client.GetResponder(resp) 219 if err != nil { 220 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "Get", resp, "Failure responding to request") 221 return 222 } 223 224 return 225} 226 227// GetPreparer prepares the Get request. 228func (client ProfilesClient) GetPreparer(ctx context.Context, resourceGroupName string, networkProfileName string, expand string) (*http.Request, error) { 229 pathParameters := map[string]interface{}{ 230 "networkProfileName": autorest.Encode("path", networkProfileName), 231 "resourceGroupName": autorest.Encode("path", resourceGroupName), 232 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 233 } 234 235 const APIVersion = "2019-07-01" 236 queryParameters := map[string]interface{}{ 237 "api-version": APIVersion, 238 } 239 if len(expand) > 0 { 240 queryParameters["$expand"] = autorest.Encode("query", expand) 241 } 242 243 preparer := autorest.CreatePreparer( 244 autorest.AsGet(), 245 autorest.WithBaseURL(client.BaseURI), 246 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkProfiles/{networkProfileName}", pathParameters), 247 autorest.WithQueryParameters(queryParameters)) 248 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 249} 250 251// GetSender sends the Get request. The method will close the 252// http.Response Body if it receives an error. 253func (client ProfilesClient) GetSender(req *http.Request) (*http.Response, error) { 254 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 255} 256 257// GetResponder handles the response to the Get request. The method always 258// closes the http.Response Body. 259func (client ProfilesClient) GetResponder(resp *http.Response) (result Profile, err error) { 260 err = autorest.Respond( 261 resp, 262 azure.WithErrorUnlessStatusCode(http.StatusOK), 263 autorest.ByUnmarshallingJSON(&result), 264 autorest.ByClosing()) 265 result.Response = autorest.Response{Response: resp} 266 return 267} 268 269// List gets all network profiles in a resource group. 270// Parameters: 271// resourceGroupName - the name of the resource group. 272func (client ProfilesClient) List(ctx context.Context, resourceGroupName string) (result ProfileListResultPage, err error) { 273 if tracing.IsEnabled() { 274 ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.List") 275 defer func() { 276 sc := -1 277 if result.plr.Response.Response != nil { 278 sc = result.plr.Response.Response.StatusCode 279 } 280 tracing.EndSpan(ctx, sc, err) 281 }() 282 } 283 result.fn = client.listNextResults 284 req, err := client.ListPreparer(ctx, resourceGroupName) 285 if err != nil { 286 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "List", nil, "Failure preparing request") 287 return 288 } 289 290 resp, err := client.ListSender(req) 291 if err != nil { 292 result.plr.Response = autorest.Response{Response: resp} 293 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "List", resp, "Failure sending request") 294 return 295 } 296 297 result.plr, err = client.ListResponder(resp) 298 if err != nil { 299 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "List", resp, "Failure responding to request") 300 return 301 } 302 if result.plr.hasNextLink() && result.plr.IsEmpty() { 303 err = result.NextWithContext(ctx) 304 return 305 } 306 307 return 308} 309 310// ListPreparer prepares the List request. 311func (client ProfilesClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 312 pathParameters := map[string]interface{}{ 313 "resourceGroupName": autorest.Encode("path", resourceGroupName), 314 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 315 } 316 317 const APIVersion = "2019-07-01" 318 queryParameters := map[string]interface{}{ 319 "api-version": APIVersion, 320 } 321 322 preparer := autorest.CreatePreparer( 323 autorest.AsGet(), 324 autorest.WithBaseURL(client.BaseURI), 325 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkProfiles", pathParameters), 326 autorest.WithQueryParameters(queryParameters)) 327 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 328} 329 330// ListSender sends the List request. The method will close the 331// http.Response Body if it receives an error. 332func (client ProfilesClient) ListSender(req *http.Request) (*http.Response, error) { 333 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 334} 335 336// ListResponder handles the response to the List request. The method always 337// closes the http.Response Body. 338func (client ProfilesClient) ListResponder(resp *http.Response) (result ProfileListResult, err error) { 339 err = autorest.Respond( 340 resp, 341 azure.WithErrorUnlessStatusCode(http.StatusOK), 342 autorest.ByUnmarshallingJSON(&result), 343 autorest.ByClosing()) 344 result.Response = autorest.Response{Response: resp} 345 return 346} 347 348// listNextResults retrieves the next set of results, if any. 349func (client ProfilesClient) listNextResults(ctx context.Context, lastResults ProfileListResult) (result ProfileListResult, err error) { 350 req, err := lastResults.profileListResultPreparer(ctx) 351 if err != nil { 352 return result, autorest.NewErrorWithError(err, "network.ProfilesClient", "listNextResults", nil, "Failure preparing next results request") 353 } 354 if req == nil { 355 return 356 } 357 resp, err := client.ListSender(req) 358 if err != nil { 359 result.Response = autorest.Response{Response: resp} 360 return result, autorest.NewErrorWithError(err, "network.ProfilesClient", "listNextResults", resp, "Failure sending next results request") 361 } 362 result, err = client.ListResponder(resp) 363 if err != nil { 364 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "listNextResults", resp, "Failure responding to next results request") 365 } 366 return 367} 368 369// ListComplete enumerates all values, automatically crossing page boundaries as required. 370func (client ProfilesClient) ListComplete(ctx context.Context, resourceGroupName string) (result ProfileListResultIterator, err error) { 371 if tracing.IsEnabled() { 372 ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.List") 373 defer func() { 374 sc := -1 375 if result.Response().Response.Response != nil { 376 sc = result.page.Response().Response.Response.StatusCode 377 } 378 tracing.EndSpan(ctx, sc, err) 379 }() 380 } 381 result.page, err = client.List(ctx, resourceGroupName) 382 return 383} 384 385// ListAll gets all the network profiles in a subscription. 386func (client ProfilesClient) ListAll(ctx context.Context) (result ProfileListResultPage, err error) { 387 if tracing.IsEnabled() { 388 ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.ListAll") 389 defer func() { 390 sc := -1 391 if result.plr.Response.Response != nil { 392 sc = result.plr.Response.Response.StatusCode 393 } 394 tracing.EndSpan(ctx, sc, err) 395 }() 396 } 397 result.fn = client.listAllNextResults 398 req, err := client.ListAllPreparer(ctx) 399 if err != nil { 400 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "ListAll", nil, "Failure preparing request") 401 return 402 } 403 404 resp, err := client.ListAllSender(req) 405 if err != nil { 406 result.plr.Response = autorest.Response{Response: resp} 407 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "ListAll", resp, "Failure sending request") 408 return 409 } 410 411 result.plr, err = client.ListAllResponder(resp) 412 if err != nil { 413 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "ListAll", resp, "Failure responding to request") 414 return 415 } 416 if result.plr.hasNextLink() && result.plr.IsEmpty() { 417 err = result.NextWithContext(ctx) 418 return 419 } 420 421 return 422} 423 424// ListAllPreparer prepares the ListAll request. 425func (client ProfilesClient) ListAllPreparer(ctx context.Context) (*http.Request, error) { 426 pathParameters := map[string]interface{}{ 427 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 428 } 429 430 const APIVersion = "2019-07-01" 431 queryParameters := map[string]interface{}{ 432 "api-version": APIVersion, 433 } 434 435 preparer := autorest.CreatePreparer( 436 autorest.AsGet(), 437 autorest.WithBaseURL(client.BaseURI), 438 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkProfiles", pathParameters), 439 autorest.WithQueryParameters(queryParameters)) 440 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 441} 442 443// ListAllSender sends the ListAll request. The method will close the 444// http.Response Body if it receives an error. 445func (client ProfilesClient) ListAllSender(req *http.Request) (*http.Response, error) { 446 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 447} 448 449// ListAllResponder handles the response to the ListAll request. The method always 450// closes the http.Response Body. 451func (client ProfilesClient) ListAllResponder(resp *http.Response) (result ProfileListResult, err error) { 452 err = autorest.Respond( 453 resp, 454 azure.WithErrorUnlessStatusCode(http.StatusOK), 455 autorest.ByUnmarshallingJSON(&result), 456 autorest.ByClosing()) 457 result.Response = autorest.Response{Response: resp} 458 return 459} 460 461// listAllNextResults retrieves the next set of results, if any. 462func (client ProfilesClient) listAllNextResults(ctx context.Context, lastResults ProfileListResult) (result ProfileListResult, err error) { 463 req, err := lastResults.profileListResultPreparer(ctx) 464 if err != nil { 465 return result, autorest.NewErrorWithError(err, "network.ProfilesClient", "listAllNextResults", nil, "Failure preparing next results request") 466 } 467 if req == nil { 468 return 469 } 470 resp, err := client.ListAllSender(req) 471 if err != nil { 472 result.Response = autorest.Response{Response: resp} 473 return result, autorest.NewErrorWithError(err, "network.ProfilesClient", "listAllNextResults", resp, "Failure sending next results request") 474 } 475 result, err = client.ListAllResponder(resp) 476 if err != nil { 477 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "listAllNextResults", resp, "Failure responding to next results request") 478 } 479 return 480} 481 482// ListAllComplete enumerates all values, automatically crossing page boundaries as required. 483func (client ProfilesClient) ListAllComplete(ctx context.Context) (result ProfileListResultIterator, err error) { 484 if tracing.IsEnabled() { 485 ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.ListAll") 486 defer func() { 487 sc := -1 488 if result.Response().Response.Response != nil { 489 sc = result.page.Response().Response.Response.StatusCode 490 } 491 tracing.EndSpan(ctx, sc, err) 492 }() 493 } 494 result.page, err = client.ListAll(ctx) 495 return 496} 497 498// UpdateTags updates network profile tags. 499// Parameters: 500// resourceGroupName - the name of the resource group. 501// networkProfileName - the name of the network profile. 502// parameters - parameters supplied to update network profile tags. 503func (client ProfilesClient) UpdateTags(ctx context.Context, resourceGroupName string, networkProfileName string, parameters TagsObject) (result Profile, err error) { 504 if tracing.IsEnabled() { 505 ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.UpdateTags") 506 defer func() { 507 sc := -1 508 if result.Response.Response != nil { 509 sc = result.Response.Response.StatusCode 510 } 511 tracing.EndSpan(ctx, sc, err) 512 }() 513 } 514 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, networkProfileName, parameters) 515 if err != nil { 516 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "UpdateTags", nil, "Failure preparing request") 517 return 518 } 519 520 resp, err := client.UpdateTagsSender(req) 521 if err != nil { 522 result.Response = autorest.Response{Response: resp} 523 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "UpdateTags", resp, "Failure sending request") 524 return 525 } 526 527 result, err = client.UpdateTagsResponder(resp) 528 if err != nil { 529 err = autorest.NewErrorWithError(err, "network.ProfilesClient", "UpdateTags", resp, "Failure responding to request") 530 return 531 } 532 533 return 534} 535 536// UpdateTagsPreparer prepares the UpdateTags request. 537func (client ProfilesClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, networkProfileName string, parameters TagsObject) (*http.Request, error) { 538 pathParameters := map[string]interface{}{ 539 "networkProfileName": autorest.Encode("path", networkProfileName), 540 "resourceGroupName": autorest.Encode("path", resourceGroupName), 541 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 542 } 543 544 const APIVersion = "2019-07-01" 545 queryParameters := map[string]interface{}{ 546 "api-version": APIVersion, 547 } 548 549 preparer := autorest.CreatePreparer( 550 autorest.AsContentType("application/json; charset=utf-8"), 551 autorest.AsPatch(), 552 autorest.WithBaseURL(client.BaseURI), 553 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkProfiles/{networkProfileName}", pathParameters), 554 autorest.WithJSON(parameters), 555 autorest.WithQueryParameters(queryParameters)) 556 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 557} 558 559// UpdateTagsSender sends the UpdateTags request. The method will close the 560// http.Response Body if it receives an error. 561func (client ProfilesClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { 562 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 563} 564 565// UpdateTagsResponder handles the response to the UpdateTags request. The method always 566// closes the http.Response Body. 567func (client ProfilesClient) UpdateTagsResponder(resp *http.Response) (result Profile, err error) { 568 err = autorest.Respond( 569 resp, 570 azure.WithErrorUnlessStatusCode(http.StatusOK), 571 autorest.ByUnmarshallingJSON(&result), 572 autorest.ByClosing()) 573 result.Response = autorest.Response{Response: resp} 574 return 575} 576