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 "net/http" 26) 27 28// RunbookClient is the automation Client 29type RunbookClient struct { 30 BaseClient 31} 32 33// NewRunbookClient creates an instance of the RunbookClient client. 34func NewRunbookClient(subscriptionID string) RunbookClient { 35 return NewRunbookClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewRunbookClientWithBaseURI creates an instance of the RunbookClient client. 39func NewRunbookClientWithBaseURI(baseURI string, subscriptionID string) RunbookClient { 40 return RunbookClient{NewWithBaseURI(baseURI, subscriptionID)} 41} 42 43// CreateOrUpdate create the runbook identified by runbook name. 44// Parameters: 45// resourceGroupName - name of an Azure Resource group. 46// automationAccountName - the name of the automation account. 47// runbookName - the runbook name. 48// parameters - the create or update parameters for runbook. Provide either content link for a published 49// runbook or draft, not both. 50func (client RunbookClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookCreateOrUpdateParameters) (result Runbook, err error) { 51 if err := validation.Validate([]validation.Validation{ 52 {TargetValue: resourceGroupName, 53 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 54 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 55 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, 56 {TargetValue: parameters, 57 Constraints: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties", Name: validation.Null, Rule: true, 58 Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft", Name: validation.Null, Rule: false, 59 Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink", Name: validation.Null, Rule: false, 60 Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash", Name: validation.Null, Rule: false, 61 Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, 62 {Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, 63 }}, 64 }}, 65 }}, 66 {Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink", Name: validation.Null, Rule: false, 67 Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash", Name: validation.Null, Rule: false, 68 Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, 69 {Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, 70 }}, 71 }}, 72 }}}}}); err != nil { 73 return result, validation.NewError("automation.RunbookClient", "CreateOrUpdate", err.Error()) 74 } 75 76 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, runbookName, parameters) 77 if err != nil { 78 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", nil, "Failure preparing request") 79 return 80 } 81 82 resp, err := client.CreateOrUpdateSender(req) 83 if err != nil { 84 result.Response = autorest.Response{Response: resp} 85 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", resp, "Failure sending request") 86 return 87 } 88 89 result, err = client.CreateOrUpdateResponder(resp) 90 if err != nil { 91 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", resp, "Failure responding to request") 92 } 93 94 return 95} 96 97// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 98func (client RunbookClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookCreateOrUpdateParameters) (*http.Request, error) { 99 pathParameters := map[string]interface{}{ 100 "automationAccountName": autorest.Encode("path", automationAccountName), 101 "resourceGroupName": autorest.Encode("path", resourceGroupName), 102 "runbookName": autorest.Encode("path", runbookName), 103 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 104 } 105 106 const APIVersion = "2015-10-31" 107 queryParameters := map[string]interface{}{ 108 "api-version": APIVersion, 109 } 110 111 preparer := autorest.CreatePreparer( 112 autorest.AsContentType("application/json; charset=utf-8"), 113 autorest.AsPut(), 114 autorest.WithBaseURL(client.BaseURI), 115 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), 116 autorest.WithJSON(parameters), 117 autorest.WithQueryParameters(queryParameters)) 118 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 119} 120 121// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 122// http.Response Body if it receives an error. 123func (client RunbookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 124 return autorest.SendWithSender(client, req, 125 azure.DoRetryWithRegistration(client.Client)) 126} 127 128// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 129// closes the http.Response Body. 130func (client RunbookClient) CreateOrUpdateResponder(resp *http.Response) (result Runbook, err error) { 131 err = autorest.Respond( 132 resp, 133 client.ByInspecting(), 134 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusBadRequest), 135 autorest.ByUnmarshallingJSON(&result), 136 autorest.ByClosing()) 137 result.Response = autorest.Response{Response: resp} 138 return 139} 140 141// Delete delete the runbook by name. 142// Parameters: 143// resourceGroupName - name of an Azure Resource group. 144// automationAccountName - the name of the automation account. 145// runbookName - the runbook name. 146func (client RunbookClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { 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.RunbookClient", "Delete", err.Error()) 153 } 154 155 req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, runbookName) 156 if err != nil { 157 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "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.RunbookClient", "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.RunbookClient", "Delete", resp, "Failure responding to request") 171 } 172 173 return 174} 175 176// DeletePreparer prepares the Delete request. 177func (client RunbookClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { 178 pathParameters := map[string]interface{}{ 179 "automationAccountName": autorest.Encode("path", automationAccountName), 180 "resourceGroupName": autorest.Encode("path", resourceGroupName), 181 "runbookName": autorest.Encode("path", runbookName), 182 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 183 } 184 185 const APIVersion = "2015-10-31" 186 queryParameters := map[string]interface{}{ 187 "api-version": APIVersion, 188 } 189 190 preparer := autorest.CreatePreparer( 191 autorest.AsDelete(), 192 autorest.WithBaseURL(client.BaseURI), 193 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), 194 autorest.WithQueryParameters(queryParameters)) 195 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 196} 197 198// DeleteSender sends the Delete request. The method will close the 199// http.Response Body if it receives an error. 200func (client RunbookClient) DeleteSender(req *http.Request) (*http.Response, error) { 201 return autorest.SendWithSender(client, req, 202 azure.DoRetryWithRegistration(client.Client)) 203} 204 205// DeleteResponder handles the response to the Delete request. The method always 206// closes the http.Response Body. 207func (client RunbookClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 208 err = autorest.Respond( 209 resp, 210 client.ByInspecting(), 211 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 212 autorest.ByClosing()) 213 result.Response = resp 214 return 215} 216 217// Get retrieve the runbook identified by runbook name. 218// Parameters: 219// resourceGroupName - name of an Azure Resource group. 220// automationAccountName - the name of the automation account. 221// runbookName - the runbook name. 222func (client RunbookClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result Runbook, err error) { 223 if err := validation.Validate([]validation.Validation{ 224 {TargetValue: resourceGroupName, 225 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 226 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 227 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 228 return result, validation.NewError("automation.RunbookClient", "Get", err.Error()) 229 } 230 231 req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, runbookName) 232 if err != nil { 233 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", nil, "Failure preparing request") 234 return 235 } 236 237 resp, err := client.GetSender(req) 238 if err != nil { 239 result.Response = autorest.Response{Response: resp} 240 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", resp, "Failure sending request") 241 return 242 } 243 244 result, err = client.GetResponder(resp) 245 if err != nil { 246 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", resp, "Failure responding to request") 247 } 248 249 return 250} 251 252// GetPreparer prepares the Get request. 253func (client RunbookClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { 254 pathParameters := map[string]interface{}{ 255 "automationAccountName": autorest.Encode("path", automationAccountName), 256 "resourceGroupName": autorest.Encode("path", resourceGroupName), 257 "runbookName": autorest.Encode("path", runbookName), 258 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 259 } 260 261 const APIVersion = "2015-10-31" 262 queryParameters := map[string]interface{}{ 263 "api-version": APIVersion, 264 } 265 266 preparer := autorest.CreatePreparer( 267 autorest.AsGet(), 268 autorest.WithBaseURL(client.BaseURI), 269 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), 270 autorest.WithQueryParameters(queryParameters)) 271 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 272} 273 274// GetSender sends the Get request. The method will close the 275// http.Response Body if it receives an error. 276func (client RunbookClient) GetSender(req *http.Request) (*http.Response, error) { 277 return autorest.SendWithSender(client, req, 278 azure.DoRetryWithRegistration(client.Client)) 279} 280 281// GetResponder handles the response to the Get request. The method always 282// closes the http.Response Body. 283func (client RunbookClient) GetResponder(resp *http.Response) (result Runbook, err error) { 284 err = autorest.Respond( 285 resp, 286 client.ByInspecting(), 287 azure.WithErrorUnlessStatusCode(http.StatusOK), 288 autorest.ByUnmarshallingJSON(&result), 289 autorest.ByClosing()) 290 result.Response = autorest.Response{Response: resp} 291 return 292} 293 294// GetContent retrieve the content of runbook identified by runbook name. 295// Parameters: 296// resourceGroupName - name of an Azure Resource group. 297// automationAccountName - the name of the automation account. 298// runbookName - the runbook name. 299func (client RunbookClient) GetContent(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result ReadCloser, err error) { 300 if err := validation.Validate([]validation.Validation{ 301 {TargetValue: resourceGroupName, 302 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 303 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 304 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 305 return result, validation.NewError("automation.RunbookClient", "GetContent", err.Error()) 306 } 307 308 req, err := client.GetContentPreparer(ctx, resourceGroupName, automationAccountName, runbookName) 309 if err != nil { 310 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", nil, "Failure preparing request") 311 return 312 } 313 314 resp, err := client.GetContentSender(req) 315 if err != nil { 316 result.Response = autorest.Response{Response: resp} 317 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", resp, "Failure sending request") 318 return 319 } 320 321 result, err = client.GetContentResponder(resp) 322 if err != nil { 323 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", resp, "Failure responding to request") 324 } 325 326 return 327} 328 329// GetContentPreparer prepares the GetContent request. 330func (client RunbookClient) GetContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { 331 pathParameters := map[string]interface{}{ 332 "automationAccountName": autorest.Encode("path", automationAccountName), 333 "resourceGroupName": autorest.Encode("path", resourceGroupName), 334 "runbookName": autorest.Encode("path", runbookName), 335 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 336 } 337 338 const APIVersion = "2015-10-31" 339 queryParameters := map[string]interface{}{ 340 "api-version": APIVersion, 341 } 342 343 preparer := autorest.CreatePreparer( 344 autorest.AsGet(), 345 autorest.WithBaseURL(client.BaseURI), 346 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content", pathParameters), 347 autorest.WithQueryParameters(queryParameters)) 348 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 349} 350 351// GetContentSender sends the GetContent request. The method will close the 352// http.Response Body if it receives an error. 353func (client RunbookClient) GetContentSender(req *http.Request) (*http.Response, error) { 354 return autorest.SendWithSender(client, req, 355 azure.DoRetryWithRegistration(client.Client)) 356} 357 358// GetContentResponder handles the response to the GetContent request. The method always 359// closes the http.Response Body. 360func (client RunbookClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { 361 result.Value = &resp.Body 362 err = autorest.Respond( 363 resp, 364 client.ByInspecting(), 365 azure.WithErrorUnlessStatusCode(http.StatusOK)) 366 result.Response = autorest.Response{Response: resp} 367 return 368} 369 370// ListByAutomationAccount retrieve a list of runbooks. 371// Parameters: 372// resourceGroupName - name of an Azure Resource group. 373// automationAccountName - the name of the automation account. 374func (client RunbookClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result RunbookListResultPage, err error) { 375 if err := validation.Validate([]validation.Validation{ 376 {TargetValue: resourceGroupName, 377 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 378 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 379 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 380 return result, validation.NewError("automation.RunbookClient", "ListByAutomationAccount", err.Error()) 381 } 382 383 result.fn = client.listByAutomationAccountNextResults 384 req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) 385 if err != nil { 386 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", nil, "Failure preparing request") 387 return 388 } 389 390 resp, err := client.ListByAutomationAccountSender(req) 391 if err != nil { 392 result.rlr.Response = autorest.Response{Response: resp} 393 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure sending request") 394 return 395 } 396 397 result.rlr, err = client.ListByAutomationAccountResponder(resp) 398 if err != nil { 399 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure responding to request") 400 } 401 402 return 403} 404 405// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. 406func (client RunbookClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { 407 pathParameters := map[string]interface{}{ 408 "automationAccountName": autorest.Encode("path", automationAccountName), 409 "resourceGroupName": autorest.Encode("path", resourceGroupName), 410 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 411 } 412 413 const APIVersion = "2015-10-31" 414 queryParameters := map[string]interface{}{ 415 "api-version": APIVersion, 416 } 417 418 preparer := autorest.CreatePreparer( 419 autorest.AsGet(), 420 autorest.WithBaseURL(client.BaseURI), 421 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks", pathParameters), 422 autorest.WithQueryParameters(queryParameters)) 423 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 424} 425 426// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the 427// http.Response Body if it receives an error. 428func (client RunbookClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { 429 return autorest.SendWithSender(client, req, 430 azure.DoRetryWithRegistration(client.Client)) 431} 432 433// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always 434// closes the http.Response Body. 435func (client RunbookClient) ListByAutomationAccountResponder(resp *http.Response) (result RunbookListResult, err error) { 436 err = autorest.Respond( 437 resp, 438 client.ByInspecting(), 439 azure.WithErrorUnlessStatusCode(http.StatusOK), 440 autorest.ByUnmarshallingJSON(&result), 441 autorest.ByClosing()) 442 result.Response = autorest.Response{Response: resp} 443 return 444} 445 446// listByAutomationAccountNextResults retrieves the next set of results, if any. 447func (client RunbookClient) listByAutomationAccountNextResults(lastResults RunbookListResult) (result RunbookListResult, err error) { 448 req, err := lastResults.runbookListResultPreparer() 449 if err != nil { 450 return result, autorest.NewErrorWithError(err, "automation.RunbookClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") 451 } 452 if req == nil { 453 return 454 } 455 resp, err := client.ListByAutomationAccountSender(req) 456 if err != nil { 457 result.Response = autorest.Response{Response: resp} 458 return result, autorest.NewErrorWithError(err, "automation.RunbookClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") 459 } 460 result, err = client.ListByAutomationAccountResponder(resp) 461 if err != nil { 462 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") 463 } 464 return 465} 466 467// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. 468func (client RunbookClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result RunbookListResultIterator, err error) { 469 result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) 470 return 471} 472 473// Update update the runbook identified by runbook name. 474// Parameters: 475// resourceGroupName - name of an Azure Resource group. 476// automationAccountName - the name of the automation account. 477// runbookName - the runbook name. 478// parameters - the update parameters for runbook. 479func (client RunbookClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookUpdateParameters) (result Runbook, err error) { 480 if err := validation.Validate([]validation.Validation{ 481 {TargetValue: resourceGroupName, 482 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 483 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 484 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 485 return result, validation.NewError("automation.RunbookClient", "Update", err.Error()) 486 } 487 488 req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, runbookName, parameters) 489 if err != nil { 490 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", nil, "Failure preparing request") 491 return 492 } 493 494 resp, err := client.UpdateSender(req) 495 if err != nil { 496 result.Response = autorest.Response{Response: resp} 497 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", resp, "Failure sending request") 498 return 499 } 500 501 result, err = client.UpdateResponder(resp) 502 if err != nil { 503 err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", resp, "Failure responding to request") 504 } 505 506 return 507} 508 509// UpdatePreparer prepares the Update request. 510func (client RunbookClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookUpdateParameters) (*http.Request, error) { 511 pathParameters := map[string]interface{}{ 512 "automationAccountName": autorest.Encode("path", automationAccountName), 513 "resourceGroupName": autorest.Encode("path", resourceGroupName), 514 "runbookName": autorest.Encode("path", runbookName), 515 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 516 } 517 518 const APIVersion = "2015-10-31" 519 queryParameters := map[string]interface{}{ 520 "api-version": APIVersion, 521 } 522 523 preparer := autorest.CreatePreparer( 524 autorest.AsContentType("application/json; charset=utf-8"), 525 autorest.AsPatch(), 526 autorest.WithBaseURL(client.BaseURI), 527 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), 528 autorest.WithJSON(parameters), 529 autorest.WithQueryParameters(queryParameters)) 530 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 531} 532 533// UpdateSender sends the Update request. The method will close the 534// http.Response Body if it receives an error. 535func (client RunbookClient) UpdateSender(req *http.Request) (*http.Response, error) { 536 return autorest.SendWithSender(client, req, 537 azure.DoRetryWithRegistration(client.Client)) 538} 539 540// UpdateResponder handles the response to the Update request. The method always 541// closes the http.Response Body. 542func (client RunbookClient) UpdateResponder(resp *http.Response) (result Runbook, err error) { 543 err = autorest.Respond( 544 resp, 545 client.ByInspecting(), 546 azure.WithErrorUnlessStatusCode(http.StatusOK), 547 autorest.ByUnmarshallingJSON(&result), 548 autorest.ByClosing()) 549 result.Response = autorest.Response{Response: resp} 550 return 551} 552