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// JobClient is the automation Client 30type JobClient struct { 31 BaseClient 32} 33 34// NewJobClient creates an instance of the JobClient client. 35func NewJobClient(subscriptionID string) JobClient { 36 return NewJobClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewJobClientWithBaseURI creates an instance of the JobClient 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 NewJobClientWithBaseURI(baseURI string, subscriptionID string) JobClient { 42 return JobClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// Create create a job of the runbook. 46// Parameters: 47// resourceGroupName - name of an Azure Resource group. 48// automationAccountName - the name of the automation account. 49// jobName - the job name. 50// parameters - the parameters supplied to the create job operation. 51// clientRequestID - identifies this specific client request. 52func (client JobClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, parameters JobCreateParameters, clientRequestID string) (result Job, err error) { 53 if tracing.IsEnabled() { 54 ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Create") 55 defer func() { 56 sc := -1 57 if result.Response.Response != nil { 58 sc = result.Response.Response.StatusCode 59 } 60 tracing.EndSpan(ctx, sc, err) 61 }() 62 } 63 if err := validation.Validate([]validation.Validation{ 64 {TargetValue: resourceGroupName, 65 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 66 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 67 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, 68 {TargetValue: parameters, 69 Constraints: []validation.Constraint{{Target: "parameters.JobCreateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 70 return result, validation.NewError("automation.JobClient", "Create", err.Error()) 71 } 72 73 req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, jobName, parameters, clientRequestID) 74 if err != nil { 75 err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", nil, "Failure preparing request") 76 return 77 } 78 79 resp, err := client.CreateSender(req) 80 if err != nil { 81 result.Response = autorest.Response{Response: resp} 82 err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", resp, "Failure sending request") 83 return 84 } 85 86 result, err = client.CreateResponder(resp) 87 if err != nil { 88 err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", resp, "Failure responding to request") 89 } 90 91 return 92} 93 94// CreatePreparer prepares the Create request. 95func (client JobClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, parameters JobCreateParameters, clientRequestID string) (*http.Request, error) { 96 pathParameters := map[string]interface{}{ 97 "automationAccountName": autorest.Encode("path", automationAccountName), 98 "jobName": autorest.Encode("path", jobName), 99 "resourceGroupName": autorest.Encode("path", resourceGroupName), 100 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 101 } 102 103 const APIVersion = "2017-05-15-preview" 104 queryParameters := map[string]interface{}{ 105 "api-version": APIVersion, 106 } 107 108 preparer := autorest.CreatePreparer( 109 autorest.AsContentType("application/json; charset=utf-8"), 110 autorest.AsPut(), 111 autorest.WithBaseURL(client.BaseURI), 112 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}", pathParameters), 113 autorest.WithJSON(parameters), 114 autorest.WithQueryParameters(queryParameters)) 115 if len(clientRequestID) > 0 { 116 preparer = autorest.DecoratePreparer(preparer, 117 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) 118 } 119 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 120} 121 122// CreateSender sends the Create request. The method will close the 123// http.Response Body if it receives an error. 124func (client JobClient) CreateSender(req *http.Request) (*http.Response, error) { 125 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 126} 127 128// CreateResponder handles the response to the Create request. The method always 129// closes the http.Response Body. 130func (client JobClient) CreateResponder(resp *http.Response) (result Job, err error) { 131 err = autorest.Respond( 132 resp, 133 client.ByInspecting(), 134 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 135 autorest.ByUnmarshallingJSON(&result), 136 autorest.ByClosing()) 137 result.Response = autorest.Response{Response: resp} 138 return 139} 140 141// Get retrieve the job identified by job name. 142// Parameters: 143// resourceGroupName - name of an Azure Resource group. 144// automationAccountName - the name of the automation account. 145// jobName - the job name. 146// clientRequestID - identifies this specific client request. 147func (client JobClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result Job, err error) { 148 if tracing.IsEnabled() { 149 ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Get") 150 defer func() { 151 sc := -1 152 if result.Response.Response != nil { 153 sc = result.Response.Response.StatusCode 154 } 155 tracing.EndSpan(ctx, sc, err) 156 }() 157 } 158 if err := validation.Validate([]validation.Validation{ 159 {TargetValue: resourceGroupName, 160 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 161 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 162 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 163 return result, validation.NewError("automation.JobClient", "Get", err.Error()) 164 } 165 166 req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) 167 if err != nil { 168 err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", nil, "Failure preparing request") 169 return 170 } 171 172 resp, err := client.GetSender(req) 173 if err != nil { 174 result.Response = autorest.Response{Response: resp} 175 err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", resp, "Failure sending request") 176 return 177 } 178 179 result, err = client.GetResponder(resp) 180 if err != nil { 181 err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", resp, "Failure responding to request") 182 } 183 184 return 185} 186 187// GetPreparer prepares the Get request. 188func (client JobClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { 189 pathParameters := map[string]interface{}{ 190 "automationAccountName": autorest.Encode("path", automationAccountName), 191 "jobName": autorest.Encode("path", jobName), 192 "resourceGroupName": autorest.Encode("path", resourceGroupName), 193 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 194 } 195 196 const APIVersion = "2017-05-15-preview" 197 queryParameters := map[string]interface{}{ 198 "api-version": APIVersion, 199 } 200 201 preparer := autorest.CreatePreparer( 202 autorest.AsGet(), 203 autorest.WithBaseURL(client.BaseURI), 204 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}", pathParameters), 205 autorest.WithQueryParameters(queryParameters)) 206 if len(clientRequestID) > 0 { 207 preparer = autorest.DecoratePreparer(preparer, 208 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) 209 } 210 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 211} 212 213// GetSender sends the Get request. The method will close the 214// http.Response Body if it receives an error. 215func (client JobClient) GetSender(req *http.Request) (*http.Response, error) { 216 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 217} 218 219// GetResponder handles the response to the Get request. The method always 220// closes the http.Response Body. 221func (client JobClient) GetResponder(resp *http.Response) (result Job, err error) { 222 err = autorest.Respond( 223 resp, 224 client.ByInspecting(), 225 azure.WithErrorUnlessStatusCode(http.StatusOK), 226 autorest.ByUnmarshallingJSON(&result), 227 autorest.ByClosing()) 228 result.Response = autorest.Response{Response: resp} 229 return 230} 231 232// GetOutput retrieve the job output identified by job name. 233// Parameters: 234// resourceGroupName - name of an Azure Resource group. 235// automationAccountName - the name of the automation account. 236// jobName - the name of the job to be created. 237// clientRequestID - identifies this specific client request. 238func (client JobClient) GetOutput(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result ReadCloser, err error) { 239 if tracing.IsEnabled() { 240 ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.GetOutput") 241 defer func() { 242 sc := -1 243 if result.Response.Response != nil { 244 sc = result.Response.Response.StatusCode 245 } 246 tracing.EndSpan(ctx, sc, err) 247 }() 248 } 249 if err := validation.Validate([]validation.Validation{ 250 {TargetValue: resourceGroupName, 251 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 252 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 253 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 254 return result, validation.NewError("automation.JobClient", "GetOutput", err.Error()) 255 } 256 257 req, err := client.GetOutputPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) 258 if err != nil { 259 err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", nil, "Failure preparing request") 260 return 261 } 262 263 resp, err := client.GetOutputSender(req) 264 if err != nil { 265 result.Response = autorest.Response{Response: resp} 266 err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", resp, "Failure sending request") 267 return 268 } 269 270 result, err = client.GetOutputResponder(resp) 271 if err != nil { 272 err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", resp, "Failure responding to request") 273 } 274 275 return 276} 277 278// GetOutputPreparer prepares the GetOutput request. 279func (client JobClient) GetOutputPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { 280 pathParameters := map[string]interface{}{ 281 "automationAccountName": autorest.Encode("path", automationAccountName), 282 "jobName": autorest.Encode("path", jobName), 283 "resourceGroupName": autorest.Encode("path", resourceGroupName), 284 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 285 } 286 287 const APIVersion = "2017-05-15-preview" 288 queryParameters := map[string]interface{}{ 289 "api-version": APIVersion, 290 } 291 292 preparer := autorest.CreatePreparer( 293 autorest.AsGet(), 294 autorest.WithBaseURL(client.BaseURI), 295 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output", pathParameters), 296 autorest.WithQueryParameters(queryParameters)) 297 if len(clientRequestID) > 0 { 298 preparer = autorest.DecoratePreparer(preparer, 299 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) 300 } 301 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 302} 303 304// GetOutputSender sends the GetOutput request. The method will close the 305// http.Response Body if it receives an error. 306func (client JobClient) GetOutputSender(req *http.Request) (*http.Response, error) { 307 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 308} 309 310// GetOutputResponder handles the response to the GetOutput request. The method always 311// closes the http.Response Body. 312func (client JobClient) GetOutputResponder(resp *http.Response) (result ReadCloser, err error) { 313 result.Value = &resp.Body 314 err = autorest.Respond( 315 resp, 316 client.ByInspecting(), 317 azure.WithErrorUnlessStatusCode(http.StatusOK)) 318 result.Response = autorest.Response{Response: resp} 319 return 320} 321 322// GetRunbookContent retrieve the runbook content of the job identified by job name. 323// Parameters: 324// resourceGroupName - name of an Azure Resource group. 325// automationAccountName - the name of the automation account. 326// jobName - the job name. 327// clientRequestID - identifies this specific client request. 328func (client JobClient) GetRunbookContent(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result ReadCloser, err error) { 329 if tracing.IsEnabled() { 330 ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.GetRunbookContent") 331 defer func() { 332 sc := -1 333 if result.Response.Response != nil { 334 sc = result.Response.Response.StatusCode 335 } 336 tracing.EndSpan(ctx, sc, err) 337 }() 338 } 339 if err := validation.Validate([]validation.Validation{ 340 {TargetValue: resourceGroupName, 341 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 342 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 343 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 344 return result, validation.NewError("automation.JobClient", "GetRunbookContent", err.Error()) 345 } 346 347 req, err := client.GetRunbookContentPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) 348 if err != nil { 349 err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", nil, "Failure preparing request") 350 return 351 } 352 353 resp, err := client.GetRunbookContentSender(req) 354 if err != nil { 355 result.Response = autorest.Response{Response: resp} 356 err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", resp, "Failure sending request") 357 return 358 } 359 360 result, err = client.GetRunbookContentResponder(resp) 361 if err != nil { 362 err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", resp, "Failure responding to request") 363 } 364 365 return 366} 367 368// GetRunbookContentPreparer prepares the GetRunbookContent request. 369func (client JobClient) GetRunbookContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { 370 pathParameters := map[string]interface{}{ 371 "automationAccountName": autorest.Encode("path", automationAccountName), 372 "jobName": autorest.Encode("path", jobName), 373 "resourceGroupName": autorest.Encode("path", resourceGroupName), 374 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 375 } 376 377 const APIVersion = "2017-05-15-preview" 378 queryParameters := map[string]interface{}{ 379 "api-version": APIVersion, 380 } 381 382 preparer := autorest.CreatePreparer( 383 autorest.AsGet(), 384 autorest.WithBaseURL(client.BaseURI), 385 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent", pathParameters), 386 autorest.WithQueryParameters(queryParameters)) 387 if len(clientRequestID) > 0 { 388 preparer = autorest.DecoratePreparer(preparer, 389 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) 390 } 391 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 392} 393 394// GetRunbookContentSender sends the GetRunbookContent request. The method will close the 395// http.Response Body if it receives an error. 396func (client JobClient) GetRunbookContentSender(req *http.Request) (*http.Response, error) { 397 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 398} 399 400// GetRunbookContentResponder handles the response to the GetRunbookContent request. The method always 401// closes the http.Response Body. 402func (client JobClient) GetRunbookContentResponder(resp *http.Response) (result ReadCloser, err error) { 403 result.Value = &resp.Body 404 err = autorest.Respond( 405 resp, 406 client.ByInspecting(), 407 azure.WithErrorUnlessStatusCode(http.StatusOK)) 408 result.Response = autorest.Response{Response: resp} 409 return 410} 411 412// ListByAutomationAccount retrieve a list of jobs. 413// Parameters: 414// resourceGroupName - name of an Azure Resource group. 415// automationAccountName - the name of the automation account. 416// filter - the filter to apply on the operation. 417// clientRequestID - identifies this specific client request. 418func (client JobClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, clientRequestID string) (result JobListResultV2Page, err error) { 419 if tracing.IsEnabled() { 420 ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.ListByAutomationAccount") 421 defer func() { 422 sc := -1 423 if result.jlrv.Response.Response != nil { 424 sc = result.jlrv.Response.Response.StatusCode 425 } 426 tracing.EndSpan(ctx, sc, err) 427 }() 428 } 429 if err := validation.Validate([]validation.Validation{ 430 {TargetValue: resourceGroupName, 431 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 432 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 433 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 434 return result, validation.NewError("automation.JobClient", "ListByAutomationAccount", err.Error()) 435 } 436 437 result.fn = client.listByAutomationAccountNextResults 438 req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter, clientRequestID) 439 if err != nil { 440 err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", nil, "Failure preparing request") 441 return 442 } 443 444 resp, err := client.ListByAutomationAccountSender(req) 445 if err != nil { 446 result.jlrv.Response = autorest.Response{Response: resp} 447 err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure sending request") 448 return 449 } 450 451 result.jlrv, err = client.ListByAutomationAccountResponder(resp) 452 if err != nil { 453 err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure responding to request") 454 } 455 456 return 457} 458 459// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. 460func (client JobClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, clientRequestID string) (*http.Request, error) { 461 pathParameters := map[string]interface{}{ 462 "automationAccountName": autorest.Encode("path", automationAccountName), 463 "resourceGroupName": autorest.Encode("path", resourceGroupName), 464 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 465 } 466 467 const APIVersion = "2017-05-15-preview" 468 queryParameters := map[string]interface{}{ 469 "api-version": APIVersion, 470 } 471 if len(filter) > 0 { 472 queryParameters["$filter"] = autorest.Encode("query", filter) 473 } 474 475 preparer := autorest.CreatePreparer( 476 autorest.AsGet(), 477 autorest.WithBaseURL(client.BaseURI), 478 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs", pathParameters), 479 autorest.WithQueryParameters(queryParameters)) 480 if len(clientRequestID) > 0 { 481 preparer = autorest.DecoratePreparer(preparer, 482 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) 483 } 484 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 485} 486 487// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the 488// http.Response Body if it receives an error. 489func (client JobClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { 490 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 491} 492 493// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always 494// closes the http.Response Body. 495func (client JobClient) ListByAutomationAccountResponder(resp *http.Response) (result JobListResultV2, err error) { 496 err = autorest.Respond( 497 resp, 498 client.ByInspecting(), 499 azure.WithErrorUnlessStatusCode(http.StatusOK), 500 autorest.ByUnmarshallingJSON(&result), 501 autorest.ByClosing()) 502 result.Response = autorest.Response{Response: resp} 503 return 504} 505 506// listByAutomationAccountNextResults retrieves the next set of results, if any. 507func (client JobClient) listByAutomationAccountNextResults(ctx context.Context, lastResults JobListResultV2) (result JobListResultV2, err error) { 508 req, err := lastResults.jobListResultV2Preparer(ctx) 509 if err != nil { 510 return result, autorest.NewErrorWithError(err, "automation.JobClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") 511 } 512 if req == nil { 513 return 514 } 515 resp, err := client.ListByAutomationAccountSender(req) 516 if err != nil { 517 result.Response = autorest.Response{Response: resp} 518 return result, autorest.NewErrorWithError(err, "automation.JobClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") 519 } 520 result, err = client.ListByAutomationAccountResponder(resp) 521 if err != nil { 522 err = autorest.NewErrorWithError(err, "automation.JobClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") 523 } 524 return 525} 526 527// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. 528func (client JobClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, clientRequestID string) (result JobListResultV2Iterator, err error) { 529 if tracing.IsEnabled() { 530 ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.ListByAutomationAccount") 531 defer func() { 532 sc := -1 533 if result.Response().Response.Response != nil { 534 sc = result.page.Response().Response.Response.StatusCode 535 } 536 tracing.EndSpan(ctx, sc, err) 537 }() 538 } 539 result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter, clientRequestID) 540 return 541} 542 543// Resume resume the job identified by jobName. 544// Parameters: 545// resourceGroupName - name of an Azure Resource group. 546// automationAccountName - the name of the automation account. 547// jobName - the job name. 548// clientRequestID - identifies this specific client request. 549func (client JobClient) Resume(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result autorest.Response, err error) { 550 if tracing.IsEnabled() { 551 ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Resume") 552 defer func() { 553 sc := -1 554 if result.Response != nil { 555 sc = result.Response.StatusCode 556 } 557 tracing.EndSpan(ctx, sc, err) 558 }() 559 } 560 if err := validation.Validate([]validation.Validation{ 561 {TargetValue: resourceGroupName, 562 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 563 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 564 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 565 return result, validation.NewError("automation.JobClient", "Resume", err.Error()) 566 } 567 568 req, err := client.ResumePreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) 569 if err != nil { 570 err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", nil, "Failure preparing request") 571 return 572 } 573 574 resp, err := client.ResumeSender(req) 575 if err != nil { 576 result.Response = resp 577 err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", resp, "Failure sending request") 578 return 579 } 580 581 result, err = client.ResumeResponder(resp) 582 if err != nil { 583 err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", resp, "Failure responding to request") 584 } 585 586 return 587} 588 589// ResumePreparer prepares the Resume request. 590func (client JobClient) ResumePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { 591 pathParameters := map[string]interface{}{ 592 "automationAccountName": autorest.Encode("path", automationAccountName), 593 "jobName": autorest.Encode("path", jobName), 594 "resourceGroupName": autorest.Encode("path", resourceGroupName), 595 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 596 } 597 598 const APIVersion = "2017-05-15-preview" 599 queryParameters := map[string]interface{}{ 600 "api-version": APIVersion, 601 } 602 603 preparer := autorest.CreatePreparer( 604 autorest.AsPost(), 605 autorest.WithBaseURL(client.BaseURI), 606 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume", pathParameters), 607 autorest.WithQueryParameters(queryParameters)) 608 if len(clientRequestID) > 0 { 609 preparer = autorest.DecoratePreparer(preparer, 610 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) 611 } 612 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 613} 614 615// ResumeSender sends the Resume request. The method will close the 616// http.Response Body if it receives an error. 617func (client JobClient) ResumeSender(req *http.Request) (*http.Response, error) { 618 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 619} 620 621// ResumeResponder handles the response to the Resume request. The method always 622// closes the http.Response Body. 623func (client JobClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { 624 err = autorest.Respond( 625 resp, 626 client.ByInspecting(), 627 azure.WithErrorUnlessStatusCode(http.StatusOK), 628 autorest.ByClosing()) 629 result.Response = resp 630 return 631} 632 633// Stop stop the job identified by jobName. 634// Parameters: 635// resourceGroupName - name of an Azure Resource group. 636// automationAccountName - the name of the automation account. 637// jobName - the job name. 638// clientRequestID - identifies this specific client request. 639func (client JobClient) Stop(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result autorest.Response, err error) { 640 if tracing.IsEnabled() { 641 ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Stop") 642 defer func() { 643 sc := -1 644 if result.Response != nil { 645 sc = result.Response.StatusCode 646 } 647 tracing.EndSpan(ctx, sc, err) 648 }() 649 } 650 if err := validation.Validate([]validation.Validation{ 651 {TargetValue: resourceGroupName, 652 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 653 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 654 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 655 return result, validation.NewError("automation.JobClient", "Stop", err.Error()) 656 } 657 658 req, err := client.StopPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) 659 if err != nil { 660 err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", nil, "Failure preparing request") 661 return 662 } 663 664 resp, err := client.StopSender(req) 665 if err != nil { 666 result.Response = resp 667 err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", resp, "Failure sending request") 668 return 669 } 670 671 result, err = client.StopResponder(resp) 672 if err != nil { 673 err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", resp, "Failure responding to request") 674 } 675 676 return 677} 678 679// StopPreparer prepares the Stop request. 680func (client JobClient) StopPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { 681 pathParameters := map[string]interface{}{ 682 "automationAccountName": autorest.Encode("path", automationAccountName), 683 "jobName": autorest.Encode("path", jobName), 684 "resourceGroupName": autorest.Encode("path", resourceGroupName), 685 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 686 } 687 688 const APIVersion = "2017-05-15-preview" 689 queryParameters := map[string]interface{}{ 690 "api-version": APIVersion, 691 } 692 693 preparer := autorest.CreatePreparer( 694 autorest.AsPost(), 695 autorest.WithBaseURL(client.BaseURI), 696 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop", pathParameters), 697 autorest.WithQueryParameters(queryParameters)) 698 if len(clientRequestID) > 0 { 699 preparer = autorest.DecoratePreparer(preparer, 700 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) 701 } 702 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 703} 704 705// StopSender sends the Stop request. The method will close the 706// http.Response Body if it receives an error. 707func (client JobClient) StopSender(req *http.Request) (*http.Response, error) { 708 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 709} 710 711// StopResponder handles the response to the Stop request. The method always 712// closes the http.Response Body. 713func (client JobClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { 714 err = autorest.Respond( 715 resp, 716 client.ByInspecting(), 717 azure.WithErrorUnlessStatusCode(http.StatusOK), 718 autorest.ByClosing()) 719 result.Response = resp 720 return 721} 722 723// Suspend suspend the job identified by job name. 724// Parameters: 725// resourceGroupName - name of an Azure Resource group. 726// automationAccountName - the name of the automation account. 727// jobName - the job name. 728// clientRequestID - identifies this specific client request. 729func (client JobClient) Suspend(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result autorest.Response, err error) { 730 if tracing.IsEnabled() { 731 ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Suspend") 732 defer func() { 733 sc := -1 734 if result.Response != nil { 735 sc = result.Response.StatusCode 736 } 737 tracing.EndSpan(ctx, sc, err) 738 }() 739 } 740 if err := validation.Validate([]validation.Validation{ 741 {TargetValue: resourceGroupName, 742 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 743 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 744 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 745 return result, validation.NewError("automation.JobClient", "Suspend", err.Error()) 746 } 747 748 req, err := client.SuspendPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) 749 if err != nil { 750 err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", nil, "Failure preparing request") 751 return 752 } 753 754 resp, err := client.SuspendSender(req) 755 if err != nil { 756 result.Response = resp 757 err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", resp, "Failure sending request") 758 return 759 } 760 761 result, err = client.SuspendResponder(resp) 762 if err != nil { 763 err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", resp, "Failure responding to request") 764 } 765 766 return 767} 768 769// SuspendPreparer prepares the Suspend request. 770func (client JobClient) SuspendPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { 771 pathParameters := map[string]interface{}{ 772 "automationAccountName": autorest.Encode("path", automationAccountName), 773 "jobName": autorest.Encode("path", jobName), 774 "resourceGroupName": autorest.Encode("path", resourceGroupName), 775 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 776 } 777 778 const APIVersion = "2017-05-15-preview" 779 queryParameters := map[string]interface{}{ 780 "api-version": APIVersion, 781 } 782 783 preparer := autorest.CreatePreparer( 784 autorest.AsPost(), 785 autorest.WithBaseURL(client.BaseURI), 786 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend", pathParameters), 787 autorest.WithQueryParameters(queryParameters)) 788 if len(clientRequestID) > 0 { 789 preparer = autorest.DecoratePreparer(preparer, 790 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) 791 } 792 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 793} 794 795// SuspendSender sends the Suspend request. The method will close the 796// http.Response Body if it receives an error. 797func (client JobClient) SuspendSender(req *http.Request) (*http.Response, error) { 798 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 799} 800 801// SuspendResponder handles the response to the Suspend request. The method always 802// closes the http.Response Body. 803func (client JobClient) SuspendResponder(resp *http.Response) (result autorest.Response, err error) { 804 err = autorest.Respond( 805 resp, 806 client.ByInspecting(), 807 azure.WithErrorUnlessStatusCode(http.StatusOK), 808 autorest.ByClosing()) 809 result.Response = resp 810 return 811} 812