1package maps 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// AccountsClient is the resource Provider 30type AccountsClient struct { 31 BaseClient 32} 33 34// NewAccountsClient creates an instance of the AccountsClient client. 35func NewAccountsClient(subscriptionID string) AccountsClient { 36 return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewAccountsClientWithBaseURI creates an instance of the AccountsClient client using a custom endpoint. Use this 40// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 41func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { 42 return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// CreateOrUpdate create or update a Maps Account. A Maps Account holds the keys which allow access to the Maps REST 46// APIs. 47// Parameters: 48// resourceGroupName - the name of the Azure Resource Group. 49// accountName - the name of the Maps Account. 50// mapsAccountCreateParameters - the new or updated parameters for the Maps Account. 51func (client AccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, mapsAccountCreateParameters AccountCreateParameters) (result Account, err error) { 52 if tracing.IsEnabled() { 53 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.CreateOrUpdate") 54 defer func() { 55 sc := -1 56 if result.Response.Response != nil { 57 sc = result.Response.Response.StatusCode 58 } 59 tracing.EndSpan(ctx, sc, err) 60 }() 61 } 62 if err := validation.Validate([]validation.Validation{ 63 {TargetValue: mapsAccountCreateParameters, 64 Constraints: []validation.Constraint{{Target: "mapsAccountCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil}, 65 {Target: "mapsAccountCreateParameters.Sku", Name: validation.Null, Rule: true, 66 Chain: []validation.Constraint{{Target: "mapsAccountCreateParameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { 67 return result, validation.NewError("maps.AccountsClient", "CreateOrUpdate", err.Error()) 68 } 69 70 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, mapsAccountCreateParameters) 71 if err != nil { 72 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "CreateOrUpdate", nil, "Failure preparing request") 73 return 74 } 75 76 resp, err := client.CreateOrUpdateSender(req) 77 if err != nil { 78 result.Response = autorest.Response{Response: resp} 79 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "CreateOrUpdate", resp, "Failure sending request") 80 return 81 } 82 83 result, err = client.CreateOrUpdateResponder(resp) 84 if err != nil { 85 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "CreateOrUpdate", resp, "Failure responding to request") 86 return 87 } 88 89 return 90} 91 92// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 93func (client AccountsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, mapsAccountCreateParameters AccountCreateParameters) (*http.Request, error) { 94 pathParameters := map[string]interface{}{ 95 "accountName": autorest.Encode("path", accountName), 96 "resourceGroupName": autorest.Encode("path", resourceGroupName), 97 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 98 } 99 100 const APIVersion = "2018-05-01" 101 queryParameters := map[string]interface{}{ 102 "api-version": APIVersion, 103 } 104 105 preparer := autorest.CreatePreparer( 106 autorest.AsContentType("application/json; charset=utf-8"), 107 autorest.AsPut(), 108 autorest.WithBaseURL(client.BaseURI), 109 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters), 110 autorest.WithJSON(mapsAccountCreateParameters), 111 autorest.WithQueryParameters(queryParameters)) 112 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 113} 114 115// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 116// http.Response Body if it receives an error. 117func (client AccountsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 118 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 119} 120 121// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 122// closes the http.Response Body. 123func (client AccountsClient) CreateOrUpdateResponder(resp *http.Response) (result Account, err error) { 124 err = autorest.Respond( 125 resp, 126 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 127 autorest.ByUnmarshallingJSON(&result), 128 autorest.ByClosing()) 129 result.Response = autorest.Response{Response: resp} 130 return 131} 132 133// Delete delete a Maps Account. 134// Parameters: 135// resourceGroupName - the name of the Azure Resource Group. 136// accountName - the name of the Maps Account. 137func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result autorest.Response, err error) { 138 if tracing.IsEnabled() { 139 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Delete") 140 defer func() { 141 sc := -1 142 if result.Response != nil { 143 sc = result.Response.StatusCode 144 } 145 tracing.EndSpan(ctx, sc, err) 146 }() 147 } 148 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) 149 if err != nil { 150 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Delete", nil, "Failure preparing request") 151 return 152 } 153 154 resp, err := client.DeleteSender(req) 155 if err != nil { 156 result.Response = resp 157 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Delete", resp, "Failure sending request") 158 return 159 } 160 161 result, err = client.DeleteResponder(resp) 162 if err != nil { 163 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Delete", resp, "Failure responding to request") 164 return 165 } 166 167 return 168} 169 170// DeletePreparer prepares the Delete request. 171func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 172 pathParameters := map[string]interface{}{ 173 "accountName": autorest.Encode("path", accountName), 174 "resourceGroupName": autorest.Encode("path", resourceGroupName), 175 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 176 } 177 178 const APIVersion = "2018-05-01" 179 queryParameters := map[string]interface{}{ 180 "api-version": APIVersion, 181 } 182 183 preparer := autorest.CreatePreparer( 184 autorest.AsDelete(), 185 autorest.WithBaseURL(client.BaseURI), 186 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters), 187 autorest.WithQueryParameters(queryParameters)) 188 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 189} 190 191// DeleteSender sends the Delete request. The method will close the 192// http.Response Body if it receives an error. 193func (client AccountsClient) DeleteSender(req *http.Request) (*http.Response, error) { 194 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 195} 196 197// DeleteResponder handles the response to the Delete request. The method always 198// closes the http.Response Body. 199func (client AccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 200 err = autorest.Respond( 201 resp, 202 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 203 autorest.ByClosing()) 204 result.Response = resp 205 return 206} 207 208// Get get a Maps Account. 209// Parameters: 210// resourceGroupName - the name of the Azure Resource Group. 211// accountName - the name of the Maps Account. 212func (client AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result Account, err error) { 213 if tracing.IsEnabled() { 214 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Get") 215 defer func() { 216 sc := -1 217 if result.Response.Response != nil { 218 sc = result.Response.Response.StatusCode 219 } 220 tracing.EndSpan(ctx, sc, err) 221 }() 222 } 223 req, err := client.GetPreparer(ctx, resourceGroupName, accountName) 224 if err != nil { 225 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Get", nil, "Failure preparing request") 226 return 227 } 228 229 resp, err := client.GetSender(req) 230 if err != nil { 231 result.Response = autorest.Response{Response: resp} 232 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Get", resp, "Failure sending request") 233 return 234 } 235 236 result, err = client.GetResponder(resp) 237 if err != nil { 238 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Get", resp, "Failure responding to request") 239 return 240 } 241 242 return 243} 244 245// GetPreparer prepares the Get request. 246func (client AccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 247 pathParameters := map[string]interface{}{ 248 "accountName": autorest.Encode("path", accountName), 249 "resourceGroupName": autorest.Encode("path", resourceGroupName), 250 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 251 } 252 253 const APIVersion = "2018-05-01" 254 queryParameters := map[string]interface{}{ 255 "api-version": APIVersion, 256 } 257 258 preparer := autorest.CreatePreparer( 259 autorest.AsGet(), 260 autorest.WithBaseURL(client.BaseURI), 261 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters), 262 autorest.WithQueryParameters(queryParameters)) 263 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 264} 265 266// GetSender sends the Get request. The method will close the 267// http.Response Body if it receives an error. 268func (client AccountsClient) GetSender(req *http.Request) (*http.Response, error) { 269 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 270} 271 272// GetResponder handles the response to the Get request. The method always 273// closes the http.Response Body. 274func (client AccountsClient) GetResponder(resp *http.Response) (result Account, err error) { 275 err = autorest.Respond( 276 resp, 277 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), 278 autorest.ByUnmarshallingJSON(&result), 279 autorest.ByClosing()) 280 result.Response = autorest.Response{Response: resp} 281 return 282} 283 284// ListByResourceGroup get all Maps Accounts in a Resource Group 285// Parameters: 286// resourceGroupName - the name of the Azure Resource Group. 287func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result Accounts, err error) { 288 if tracing.IsEnabled() { 289 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup") 290 defer func() { 291 sc := -1 292 if result.Response.Response != nil { 293 sc = result.Response.Response.StatusCode 294 } 295 tracing.EndSpan(ctx, sc, err) 296 }() 297 } 298 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 299 if err != nil { 300 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") 301 return 302 } 303 304 resp, err := client.ListByResourceGroupSender(req) 305 if err != nil { 306 result.Response = autorest.Response{Response: resp} 307 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") 308 return 309 } 310 311 result, err = client.ListByResourceGroupResponder(resp) 312 if err != nil { 313 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request") 314 return 315 } 316 317 return 318} 319 320// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 321func (client AccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 322 pathParameters := map[string]interface{}{ 323 "resourceGroupName": autorest.Encode("path", resourceGroupName), 324 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 325 } 326 327 const APIVersion = "2018-05-01" 328 queryParameters := map[string]interface{}{ 329 "api-version": APIVersion, 330 } 331 332 preparer := autorest.CreatePreparer( 333 autorest.AsGet(), 334 autorest.WithBaseURL(client.BaseURI), 335 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts", pathParameters), 336 autorest.WithQueryParameters(queryParameters)) 337 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 338} 339 340// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 341// http.Response Body if it receives an error. 342func (client AccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 343 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 344} 345 346// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 347// closes the http.Response Body. 348func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result Accounts, err error) { 349 err = autorest.Respond( 350 resp, 351 azure.WithErrorUnlessStatusCode(http.StatusOK), 352 autorest.ByUnmarshallingJSON(&result), 353 autorest.ByClosing()) 354 result.Response = autorest.Response{Response: resp} 355 return 356} 357 358// ListBySubscription get all Maps Accounts in a Subscription 359func (client AccountsClient) ListBySubscription(ctx context.Context) (result Accounts, err error) { 360 if tracing.IsEnabled() { 361 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListBySubscription") 362 defer func() { 363 sc := -1 364 if result.Response.Response != nil { 365 sc = result.Response.Response.StatusCode 366 } 367 tracing.EndSpan(ctx, sc, err) 368 }() 369 } 370 req, err := client.ListBySubscriptionPreparer(ctx) 371 if err != nil { 372 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListBySubscription", nil, "Failure preparing request") 373 return 374 } 375 376 resp, err := client.ListBySubscriptionSender(req) 377 if err != nil { 378 result.Response = autorest.Response{Response: resp} 379 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListBySubscription", resp, "Failure sending request") 380 return 381 } 382 383 result, err = client.ListBySubscriptionResponder(resp) 384 if err != nil { 385 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListBySubscription", resp, "Failure responding to request") 386 return 387 } 388 389 return 390} 391 392// ListBySubscriptionPreparer prepares the ListBySubscription request. 393func (client AccountsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { 394 pathParameters := map[string]interface{}{ 395 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 396 } 397 398 const APIVersion = "2018-05-01" 399 queryParameters := map[string]interface{}{ 400 "api-version": APIVersion, 401 } 402 403 preparer := autorest.CreatePreparer( 404 autorest.AsGet(), 405 autorest.WithBaseURL(client.BaseURI), 406 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Maps/accounts", pathParameters), 407 autorest.WithQueryParameters(queryParameters)) 408 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 409} 410 411// ListBySubscriptionSender sends the ListBySubscription request. The method will close the 412// http.Response Body if it receives an error. 413func (client AccountsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { 414 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 415} 416 417// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always 418// closes the http.Response Body. 419func (client AccountsClient) ListBySubscriptionResponder(resp *http.Response) (result Accounts, err error) { 420 err = autorest.Respond( 421 resp, 422 azure.WithErrorUnlessStatusCode(http.StatusOK), 423 autorest.ByUnmarshallingJSON(&result), 424 autorest.ByClosing()) 425 result.Response = autorest.Response{Response: resp} 426 return 427} 428 429// ListKeys get the keys to use with the Maps APIs. A key is used to authenticate and authorize access to the Maps REST 430// APIs. Only one key is needed at a time; two are given to provide seamless key regeneration. 431// Parameters: 432// resourceGroupName - the name of the Azure Resource Group. 433// accountName - the name of the Maps Account. 434func (client AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result AccountKeys, err error) { 435 if tracing.IsEnabled() { 436 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListKeys") 437 defer func() { 438 sc := -1 439 if result.Response.Response != nil { 440 sc = result.Response.Response.StatusCode 441 } 442 tracing.EndSpan(ctx, sc, err) 443 }() 444 } 445 req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName) 446 if err != nil { 447 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListKeys", nil, "Failure preparing request") 448 return 449 } 450 451 resp, err := client.ListKeysSender(req) 452 if err != nil { 453 result.Response = autorest.Response{Response: resp} 454 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListKeys", resp, "Failure sending request") 455 return 456 } 457 458 result, err = client.ListKeysResponder(resp) 459 if err != nil { 460 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListKeys", resp, "Failure responding to request") 461 return 462 } 463 464 return 465} 466 467// ListKeysPreparer prepares the ListKeys request. 468func (client AccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 469 pathParameters := map[string]interface{}{ 470 "accountName": autorest.Encode("path", accountName), 471 "resourceGroupName": autorest.Encode("path", resourceGroupName), 472 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 473 } 474 475 const APIVersion = "2018-05-01" 476 queryParameters := map[string]interface{}{ 477 "api-version": APIVersion, 478 } 479 480 preparer := autorest.CreatePreparer( 481 autorest.AsPost(), 482 autorest.WithBaseURL(client.BaseURI), 483 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listKeys", pathParameters), 484 autorest.WithQueryParameters(queryParameters)) 485 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 486} 487 488// ListKeysSender sends the ListKeys request. The method will close the 489// http.Response Body if it receives an error. 490func (client AccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) { 491 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 492} 493 494// ListKeysResponder handles the response to the ListKeys request. The method always 495// closes the http.Response Body. 496func (client AccountsClient) ListKeysResponder(resp *http.Response) (result AccountKeys, err error) { 497 err = autorest.Respond( 498 resp, 499 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), 500 autorest.ByUnmarshallingJSON(&result), 501 autorest.ByClosing()) 502 result.Response = autorest.Response{Response: resp} 503 return 504} 505 506// ListOperations list operations available for the Maps Resource Provider 507func (client AccountsClient) ListOperations(ctx context.Context) (result Operations, err error) { 508 if tracing.IsEnabled() { 509 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListOperations") 510 defer func() { 511 sc := -1 512 if result.Response.Response != nil { 513 sc = result.Response.Response.StatusCode 514 } 515 tracing.EndSpan(ctx, sc, err) 516 }() 517 } 518 req, err := client.ListOperationsPreparer(ctx) 519 if err != nil { 520 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListOperations", nil, "Failure preparing request") 521 return 522 } 523 524 resp, err := client.ListOperationsSender(req) 525 if err != nil { 526 result.Response = autorest.Response{Response: resp} 527 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListOperations", resp, "Failure sending request") 528 return 529 } 530 531 result, err = client.ListOperationsResponder(resp) 532 if err != nil { 533 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListOperations", resp, "Failure responding to request") 534 return 535 } 536 537 return 538} 539 540// ListOperationsPreparer prepares the ListOperations request. 541func (client AccountsClient) ListOperationsPreparer(ctx context.Context) (*http.Request, error) { 542 const APIVersion = "2018-05-01" 543 queryParameters := map[string]interface{}{ 544 "api-version": APIVersion, 545 } 546 547 preparer := autorest.CreatePreparer( 548 autorest.AsGet(), 549 autorest.WithBaseURL(client.BaseURI), 550 autorest.WithPath("/providers/Microsoft.Maps/operations"), 551 autorest.WithQueryParameters(queryParameters)) 552 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 553} 554 555// ListOperationsSender sends the ListOperations request. The method will close the 556// http.Response Body if it receives an error. 557func (client AccountsClient) ListOperationsSender(req *http.Request) (*http.Response, error) { 558 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 559} 560 561// ListOperationsResponder handles the response to the ListOperations request. The method always 562// closes the http.Response Body. 563func (client AccountsClient) ListOperationsResponder(resp *http.Response) (result Operations, err error) { 564 err = autorest.Respond( 565 resp, 566 azure.WithErrorUnlessStatusCode(http.StatusOK), 567 autorest.ByUnmarshallingJSON(&result), 568 autorest.ByClosing()) 569 result.Response = autorest.Response{Response: resp} 570 return 571} 572 573// Move moves Maps Accounts from one ResourceGroup (or Subscription) to another 574// Parameters: 575// resourceGroupName - the name of the resource group that contains Maps Account to move. 576// moveRequest - the details of the Maps Account move. 577func (client AccountsClient) Move(ctx context.Context, resourceGroupName string, moveRequest AccountsMoveRequest) (result autorest.Response, err error) { 578 if tracing.IsEnabled() { 579 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Move") 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 if err := validation.Validate([]validation.Validation{ 589 {TargetValue: moveRequest, 590 Constraints: []validation.Constraint{{Target: "moveRequest.TargetResourceGroup", Name: validation.Null, Rule: true, Chain: nil}, 591 {Target: "moveRequest.ResourceIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 592 return result, validation.NewError("maps.AccountsClient", "Move", err.Error()) 593 } 594 595 req, err := client.MovePreparer(ctx, resourceGroupName, moveRequest) 596 if err != nil { 597 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Move", nil, "Failure preparing request") 598 return 599 } 600 601 resp, err := client.MoveSender(req) 602 if err != nil { 603 result.Response = resp 604 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Move", resp, "Failure sending request") 605 return 606 } 607 608 result, err = client.MoveResponder(resp) 609 if err != nil { 610 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Move", resp, "Failure responding to request") 611 return 612 } 613 614 return 615} 616 617// MovePreparer prepares the Move request. 618func (client AccountsClient) MovePreparer(ctx context.Context, resourceGroupName string, moveRequest AccountsMoveRequest) (*http.Request, error) { 619 pathParameters := map[string]interface{}{ 620 "resourceGroupName": autorest.Encode("path", resourceGroupName), 621 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 622 } 623 624 const APIVersion = "2018-05-01" 625 queryParameters := map[string]interface{}{ 626 "api-version": APIVersion, 627 } 628 629 preparer := autorest.CreatePreparer( 630 autorest.AsContentType("application/json; charset=utf-8"), 631 autorest.AsPost(), 632 autorest.WithBaseURL(client.BaseURI), 633 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/moveResources", pathParameters), 634 autorest.WithJSON(moveRequest), 635 autorest.WithQueryParameters(queryParameters)) 636 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 637} 638 639// MoveSender sends the Move request. The method will close the 640// http.Response Body if it receives an error. 641func (client AccountsClient) MoveSender(req *http.Request) (*http.Response, error) { 642 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 643} 644 645// MoveResponder handles the response to the Move request. The method always 646// closes the http.Response Body. 647func (client AccountsClient) MoveResponder(resp *http.Response) (result autorest.Response, err error) { 648 err = autorest.Respond( 649 resp, 650 azure.WithErrorUnlessStatusCode(http.StatusOK), 651 autorest.ByClosing()) 652 result.Response = resp 653 return 654} 655 656// RegenerateKeys regenerate either the primary or secondary key for use with the Maps APIs. The old key will stop 657// working immediately. 658// Parameters: 659// resourceGroupName - the name of the Azure Resource Group. 660// accountName - the name of the Maps Account. 661// keySpecification - which key to regenerate: primary or secondary. 662func (client AccountsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, keySpecification KeySpecification) (result AccountKeys, err error) { 663 if tracing.IsEnabled() { 664 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.RegenerateKeys") 665 defer func() { 666 sc := -1 667 if result.Response.Response != nil { 668 sc = result.Response.Response.StatusCode 669 } 670 tracing.EndSpan(ctx, sc, err) 671 }() 672 } 673 req, err := client.RegenerateKeysPreparer(ctx, resourceGroupName, accountName, keySpecification) 674 if err != nil { 675 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "RegenerateKeys", nil, "Failure preparing request") 676 return 677 } 678 679 resp, err := client.RegenerateKeysSender(req) 680 if err != nil { 681 result.Response = autorest.Response{Response: resp} 682 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "RegenerateKeys", resp, "Failure sending request") 683 return 684 } 685 686 result, err = client.RegenerateKeysResponder(resp) 687 if err != nil { 688 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "RegenerateKeys", resp, "Failure responding to request") 689 return 690 } 691 692 return 693} 694 695// RegenerateKeysPreparer prepares the RegenerateKeys request. 696func (client AccountsClient) RegenerateKeysPreparer(ctx context.Context, resourceGroupName string, accountName string, keySpecification KeySpecification) (*http.Request, error) { 697 pathParameters := map[string]interface{}{ 698 "accountName": autorest.Encode("path", accountName), 699 "resourceGroupName": autorest.Encode("path", resourceGroupName), 700 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 701 } 702 703 const APIVersion = "2018-05-01" 704 queryParameters := map[string]interface{}{ 705 "api-version": APIVersion, 706 } 707 708 preparer := autorest.CreatePreparer( 709 autorest.AsContentType("application/json; charset=utf-8"), 710 autorest.AsPost(), 711 autorest.WithBaseURL(client.BaseURI), 712 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/regenerateKey", pathParameters), 713 autorest.WithJSON(keySpecification), 714 autorest.WithQueryParameters(queryParameters)) 715 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 716} 717 718// RegenerateKeysSender sends the RegenerateKeys request. The method will close the 719// http.Response Body if it receives an error. 720func (client AccountsClient) RegenerateKeysSender(req *http.Request) (*http.Response, error) { 721 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 722} 723 724// RegenerateKeysResponder handles the response to the RegenerateKeys request. The method always 725// closes the http.Response Body. 726func (client AccountsClient) RegenerateKeysResponder(resp *http.Response) (result AccountKeys, err error) { 727 err = autorest.Respond( 728 resp, 729 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), 730 autorest.ByUnmarshallingJSON(&result), 731 autorest.ByClosing()) 732 result.Response = autorest.Response{Response: resp} 733 return 734} 735 736// Update updates a Maps Account. Only a subset of the parameters may be updated after creation, such as Sku and Tags. 737// Parameters: 738// resourceGroupName - the name of the Azure Resource Group. 739// accountName - the name of the Maps Account. 740// mapsAccountUpdateParameters - the updated parameters for the Maps Account. 741func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, mapsAccountUpdateParameters AccountUpdateParameters) (result Account, err error) { 742 if tracing.IsEnabled() { 743 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update") 744 defer func() { 745 sc := -1 746 if result.Response.Response != nil { 747 sc = result.Response.Response.StatusCode 748 } 749 tracing.EndSpan(ctx, sc, err) 750 }() 751 } 752 req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, mapsAccountUpdateParameters) 753 if err != nil { 754 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Update", nil, "Failure preparing request") 755 return 756 } 757 758 resp, err := client.UpdateSender(req) 759 if err != nil { 760 result.Response = autorest.Response{Response: resp} 761 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Update", resp, "Failure sending request") 762 return 763 } 764 765 result, err = client.UpdateResponder(resp) 766 if err != nil { 767 err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Update", resp, "Failure responding to request") 768 return 769 } 770 771 return 772} 773 774// UpdatePreparer prepares the Update request. 775func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, mapsAccountUpdateParameters AccountUpdateParameters) (*http.Request, error) { 776 pathParameters := map[string]interface{}{ 777 "accountName": autorest.Encode("path", accountName), 778 "resourceGroupName": autorest.Encode("path", resourceGroupName), 779 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 780 } 781 782 const APIVersion = "2018-05-01" 783 queryParameters := map[string]interface{}{ 784 "api-version": APIVersion, 785 } 786 787 preparer := autorest.CreatePreparer( 788 autorest.AsContentType("application/json; charset=utf-8"), 789 autorest.AsPatch(), 790 autorest.WithBaseURL(client.BaseURI), 791 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters), 792 autorest.WithJSON(mapsAccountUpdateParameters), 793 autorest.WithQueryParameters(queryParameters)) 794 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 795} 796 797// UpdateSender sends the Update request. The method will close the 798// http.Response Body if it receives an error. 799func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, error) { 800 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 801} 802 803// UpdateResponder handles the response to the Update request. The method always 804// closes the http.Response Body. 805func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) { 806 err = autorest.Respond( 807 resp, 808 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), 809 autorest.ByUnmarshallingJSON(&result), 810 autorest.ByClosing()) 811 result.Response = autorest.Response{Response: resp} 812 return 813} 814