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