1package batch
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
10	"context"
11	"github.com/Azure/go-autorest/autorest"
12	"github.com/Azure/go-autorest/autorest/azure"
13	"github.com/Azure/go-autorest/autorest/date"
14	"github.com/Azure/go-autorest/autorest/validation"
15	"github.com/Azure/go-autorest/tracing"
16	"github.com/gofrs/uuid"
17	"net/http"
18)
19
20// JobClient is the a client for issuing REST requests to the Azure Batch service.
21type JobClient struct {
22	BaseClient
23}
24
25// NewJobClient creates an instance of the JobClient client.
26func NewJobClient() JobClient {
27	return NewJobClientWithBaseURI(DefaultBaseURI)
28}
29
30// NewJobClientWithBaseURI creates an instance of the JobClient client using a custom endpoint.  Use this when
31// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
32func NewJobClientWithBaseURI(baseURI string) JobClient {
33	return JobClient{NewWithBaseURI(baseURI)}
34}
35
36// Add the Batch service supports two ways to control the work done as part of a job. In the first approach, the user
37// specifies a Job Manager task. The Batch service launches this task when it is ready to start the job. The Job
38// Manager task controls all other tasks that run under this job, by using the Task APIs. In the second approach, the
39// user directly controls the execution of tasks under an active job, by using the Task APIs. Also note: when naming
40// jobs, avoid including sensitive information such as user names or secret project names. This information may appear
41// in telemetry logs accessible to Microsoft Support engineers.
42// Parameters:
43// job - the job to be added.
44// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
45// seconds.
46// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
47// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
48// returnClientRequestID - whether the server should return the client-request-id in the response.
49// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
50// time; set it explicitly if you are calling the REST API directly.
51func (client JobClient) Add(ctx context.Context, job JobAddParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
52	if tracing.IsEnabled() {
53		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Add")
54		defer func() {
55			sc := -1
56			if result.Response != nil {
57				sc = result.Response.StatusCode
58			}
59			tracing.EndSpan(ctx, sc, err)
60		}()
61	}
62	if err := validation.Validate([]validation.Validation{
63		{TargetValue: job,
64			Constraints: []validation.Constraint{{Target: "job.ID", Name: validation.Null, Rule: true, Chain: nil},
65				{Target: "job.JobManagerTask", Name: validation.Null, Rule: false,
66					Chain: []validation.Constraint{{Target: "job.JobManagerTask.ID", Name: validation.Null, Rule: true, Chain: nil},
67						{Target: "job.JobManagerTask.CommandLine", Name: validation.Null, Rule: true, Chain: nil},
68					}},
69				{Target: "job.JobPreparationTask", Name: validation.Null, Rule: false,
70					Chain: []validation.Constraint{{Target: "job.JobPreparationTask.CommandLine", Name: validation.Null, Rule: true, Chain: nil}}},
71				{Target: "job.JobReleaseTask", Name: validation.Null, Rule: false,
72					Chain: []validation.Constraint{{Target: "job.JobReleaseTask.CommandLine", Name: validation.Null, Rule: true, Chain: nil}}},
73				{Target: "job.PoolInfo", Name: validation.Null, Rule: true,
74					Chain: []validation.Constraint{{Target: "job.PoolInfo.AutoPoolSpecification", Name: validation.Null, Rule: false,
75						Chain: []validation.Constraint{{Target: "job.PoolInfo.AutoPoolSpecification.Pool", Name: validation.Null, Rule: false,
76							Chain: []validation.Constraint{{Target: "job.PoolInfo.AutoPoolSpecification.Pool.VMSize", Name: validation.Null, Rule: true, Chain: nil},
77								{Target: "job.PoolInfo.AutoPoolSpecification.Pool.CloudServiceConfiguration", Name: validation.Null, Rule: false,
78									Chain: []validation.Constraint{{Target: "job.PoolInfo.AutoPoolSpecification.Pool.CloudServiceConfiguration.OsFamily", Name: validation.Null, Rule: true, Chain: nil}}},
79								{Target: "job.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration", Name: validation.Null, Rule: false,
80									Chain: []validation.Constraint{{Target: "job.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.ImageReference", Name: validation.Null, Rule: false,
81										Chain: []validation.Constraint{{Target: "job.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.ImageReference.Publisher", Name: validation.Null, Rule: true, Chain: nil},
82											{Target: "job.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.ImageReference.Offer", Name: validation.Null, Rule: true, Chain: nil},
83											{Target: "job.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.ImageReference.Sku", Name: validation.Null, Rule: true, Chain: nil},
84										}},
85										{Target: "job.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.OsDisk", Name: validation.Null, Rule: false,
86											Chain: []validation.Constraint{{Target: "job.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.OsDisk.ImageUris", Name: validation.Null, Rule: true, Chain: nil}}},
87										{Target: "job.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.NodeAgentSKUID", Name: validation.Null, Rule: true, Chain: nil},
88									}},
89								{Target: "job.PoolInfo.AutoPoolSpecification.Pool.StartTask", Name: validation.Null, Rule: false,
90									Chain: []validation.Constraint{{Target: "job.PoolInfo.AutoPoolSpecification.Pool.StartTask.CommandLine", Name: validation.Null, Rule: true, Chain: nil}}},
91							}},
92						}},
93					}}}}}); err != nil {
94		return result, validation.NewError("batch.JobClient", "Add", err.Error())
95	}
96
97	req, err := client.AddPreparer(ctx, job, timeout, clientRequestID, returnClientRequestID, ocpDate)
98	if err != nil {
99		err = autorest.NewErrorWithError(err, "batch.JobClient", "Add", nil, "Failure preparing request")
100		return
101	}
102
103	resp, err := client.AddSender(req)
104	if err != nil {
105		result.Response = resp
106		err = autorest.NewErrorWithError(err, "batch.JobClient", "Add", resp, "Failure sending request")
107		return
108	}
109
110	result, err = client.AddResponder(resp)
111	if err != nil {
112		err = autorest.NewErrorWithError(err, "batch.JobClient", "Add", resp, "Failure responding to request")
113		return
114	}
115
116	return
117}
118
119// AddPreparer prepares the Add request.
120func (client JobClient) AddPreparer(ctx context.Context, job JobAddParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
121	const APIVersion = "2017-05-01.5.0"
122	queryParameters := map[string]interface{}{
123		"api-version": APIVersion,
124	}
125	if timeout != nil {
126		queryParameters["timeout"] = autorest.Encode("query", *timeout)
127	} else {
128		queryParameters["timeout"] = autorest.Encode("query", 30)
129	}
130
131	preparer := autorest.CreatePreparer(
132		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
133		autorest.AsPost(),
134		autorest.WithBaseURL(client.BaseURI),
135		autorest.WithPath("/jobs"),
136		autorest.WithJSON(job),
137		autorest.WithQueryParameters(queryParameters))
138	if clientRequestID != nil {
139		preparer = autorest.DecoratePreparer(preparer,
140			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
141	}
142	if returnClientRequestID != nil {
143		preparer = autorest.DecoratePreparer(preparer,
144			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
145	} else {
146		preparer = autorest.DecoratePreparer(preparer,
147			autorest.WithHeader("return-client-request-id", autorest.String(false)))
148	}
149	if ocpDate != nil {
150		preparer = autorest.DecoratePreparer(preparer,
151			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
152	}
153	return preparer.Prepare((&http.Request{}).WithContext(ctx))
154}
155
156// AddSender sends the Add request. The method will close the
157// http.Response Body if it receives an error.
158func (client JobClient) AddSender(req *http.Request) (*http.Response, error) {
159	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
160}
161
162// AddResponder handles the response to the Add request. The method always
163// closes the http.Response Body.
164func (client JobClient) AddResponder(resp *http.Response) (result autorest.Response, err error) {
165	err = autorest.Respond(
166		resp,
167		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
168		autorest.ByClosing())
169	result.Response = resp
170	return
171}
172
173// Delete deleting a job also deletes all tasks that are part of that job, and all job statistics. This also overrides
174// the retention period for task data; that is, if the job contains tasks which are still retained on compute nodes,
175// the Batch services deletes those tasks' working directories and all their contents.
176// Parameters:
177// jobID - the ID of the job to delete.
178// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
179// seconds.
180// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
181// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
182// returnClientRequestID - whether the server should return the client-request-id in the response.
183// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
184// time; set it explicitly if you are calling the REST API directly.
185// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
186// be performed only if the resource's current ETag on the service exactly matches the value specified by the
187// client.
188// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
189// will be performed only if the resource's current ETag on the service does not match the value specified by
190// the client.
191// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
192// operation will be performed only if the resource on the service has been modified since the specified time.
193// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
194// operation will be performed only if the resource on the service has not been modified since the specified
195// time.
196func (client JobClient) Delete(ctx context.Context, jobID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) {
197	if tracing.IsEnabled() {
198		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Delete")
199		defer func() {
200			sc := -1
201			if result.Response != nil {
202				sc = result.Response.StatusCode
203			}
204			tracing.EndSpan(ctx, sc, err)
205		}()
206	}
207	req, err := client.DeletePreparer(ctx, jobID, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
208	if err != nil {
209		err = autorest.NewErrorWithError(err, "batch.JobClient", "Delete", nil, "Failure preparing request")
210		return
211	}
212
213	resp, err := client.DeleteSender(req)
214	if err != nil {
215		result.Response = resp
216		err = autorest.NewErrorWithError(err, "batch.JobClient", "Delete", resp, "Failure sending request")
217		return
218	}
219
220	result, err = client.DeleteResponder(resp)
221	if err != nil {
222		err = autorest.NewErrorWithError(err, "batch.JobClient", "Delete", resp, "Failure responding to request")
223		return
224	}
225
226	return
227}
228
229// DeletePreparer prepares the Delete request.
230func (client JobClient) DeletePreparer(ctx context.Context, jobID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
231	pathParameters := map[string]interface{}{
232		"jobId": autorest.Encode("path", jobID),
233	}
234
235	const APIVersion = "2017-05-01.5.0"
236	queryParameters := map[string]interface{}{
237		"api-version": APIVersion,
238	}
239	if timeout != nil {
240		queryParameters["timeout"] = autorest.Encode("query", *timeout)
241	} else {
242		queryParameters["timeout"] = autorest.Encode("query", 30)
243	}
244
245	preparer := autorest.CreatePreparer(
246		autorest.AsDelete(),
247		autorest.WithBaseURL(client.BaseURI),
248		autorest.WithPathParameters("/jobs/{jobId}", pathParameters),
249		autorest.WithQueryParameters(queryParameters))
250	if clientRequestID != nil {
251		preparer = autorest.DecoratePreparer(preparer,
252			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
253	}
254	if returnClientRequestID != nil {
255		preparer = autorest.DecoratePreparer(preparer,
256			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
257	} else {
258		preparer = autorest.DecoratePreparer(preparer,
259			autorest.WithHeader("return-client-request-id", autorest.String(false)))
260	}
261	if ocpDate != nil {
262		preparer = autorest.DecoratePreparer(preparer,
263			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
264	}
265	if len(ifMatch) > 0 {
266		preparer = autorest.DecoratePreparer(preparer,
267			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
268	}
269	if len(ifNoneMatch) > 0 {
270		preparer = autorest.DecoratePreparer(preparer,
271			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
272	}
273	if ifModifiedSince != nil {
274		preparer = autorest.DecoratePreparer(preparer,
275			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
276	}
277	if ifUnmodifiedSince != nil {
278		preparer = autorest.DecoratePreparer(preparer,
279			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
280	}
281	return preparer.Prepare((&http.Request{}).WithContext(ctx))
282}
283
284// DeleteSender sends the Delete request. The method will close the
285// http.Response Body if it receives an error.
286func (client JobClient) DeleteSender(req *http.Request) (*http.Response, error) {
287	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
288}
289
290// DeleteResponder handles the response to the Delete request. The method always
291// closes the http.Response Body.
292func (client JobClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
293	err = autorest.Respond(
294		resp,
295		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
296		autorest.ByClosing())
297	result.Response = resp
298	return
299}
300
301// Disable the Batch Service immediately moves the job to the disabling state. Batch then uses the disableTasks
302// parameter to determine what to do with the currently running tasks of the job. The job remains in the disabling
303// state until the disable operation is completed and all tasks have been dealt with according to the disableTasks
304// option; the job then moves to the disabled state. No new tasks are started under the job until it moves back to
305// active state. If you try to disable a job that is in any state other than active, disabling, or disabled, the
306// request fails with status code 409.
307// Parameters:
308// jobID - the ID of the job to disable.
309// jobDisableParameter - the parameters for the request.
310// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
311// seconds.
312// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
313// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
314// returnClientRequestID - whether the server should return the client-request-id in the response.
315// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
316// time; set it explicitly if you are calling the REST API directly.
317// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
318// be performed only if the resource's current ETag on the service exactly matches the value specified by the
319// client.
320// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
321// will be performed only if the resource's current ETag on the service does not match the value specified by
322// the client.
323// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
324// operation will be performed only if the resource on the service has been modified since the specified time.
325// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
326// operation will be performed only if the resource on the service has not been modified since the specified
327// time.
328func (client JobClient) Disable(ctx context.Context, jobID string, jobDisableParameter JobDisableParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) {
329	if tracing.IsEnabled() {
330		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Disable")
331		defer func() {
332			sc := -1
333			if result.Response != nil {
334				sc = result.Response.StatusCode
335			}
336			tracing.EndSpan(ctx, sc, err)
337		}()
338	}
339	req, err := client.DisablePreparer(ctx, jobID, jobDisableParameter, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
340	if err != nil {
341		err = autorest.NewErrorWithError(err, "batch.JobClient", "Disable", nil, "Failure preparing request")
342		return
343	}
344
345	resp, err := client.DisableSender(req)
346	if err != nil {
347		result.Response = resp
348		err = autorest.NewErrorWithError(err, "batch.JobClient", "Disable", resp, "Failure sending request")
349		return
350	}
351
352	result, err = client.DisableResponder(resp)
353	if err != nil {
354		err = autorest.NewErrorWithError(err, "batch.JobClient", "Disable", resp, "Failure responding to request")
355		return
356	}
357
358	return
359}
360
361// DisablePreparer prepares the Disable request.
362func (client JobClient) DisablePreparer(ctx context.Context, jobID string, jobDisableParameter JobDisableParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
363	pathParameters := map[string]interface{}{
364		"jobId": autorest.Encode("path", jobID),
365	}
366
367	const APIVersion = "2017-05-01.5.0"
368	queryParameters := map[string]interface{}{
369		"api-version": APIVersion,
370	}
371	if timeout != nil {
372		queryParameters["timeout"] = autorest.Encode("query", *timeout)
373	} else {
374		queryParameters["timeout"] = autorest.Encode("query", 30)
375	}
376
377	preparer := autorest.CreatePreparer(
378		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
379		autorest.AsPost(),
380		autorest.WithBaseURL(client.BaseURI),
381		autorest.WithPathParameters("/jobs/{jobId}/disable", pathParameters),
382		autorest.WithJSON(jobDisableParameter),
383		autorest.WithQueryParameters(queryParameters))
384	if clientRequestID != nil {
385		preparer = autorest.DecoratePreparer(preparer,
386			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
387	}
388	if returnClientRequestID != nil {
389		preparer = autorest.DecoratePreparer(preparer,
390			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
391	} else {
392		preparer = autorest.DecoratePreparer(preparer,
393			autorest.WithHeader("return-client-request-id", autorest.String(false)))
394	}
395	if ocpDate != nil {
396		preparer = autorest.DecoratePreparer(preparer,
397			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
398	}
399	if len(ifMatch) > 0 {
400		preparer = autorest.DecoratePreparer(preparer,
401			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
402	}
403	if len(ifNoneMatch) > 0 {
404		preparer = autorest.DecoratePreparer(preparer,
405			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
406	}
407	if ifModifiedSince != nil {
408		preparer = autorest.DecoratePreparer(preparer,
409			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
410	}
411	if ifUnmodifiedSince != nil {
412		preparer = autorest.DecoratePreparer(preparer,
413			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
414	}
415	return preparer.Prepare((&http.Request{}).WithContext(ctx))
416}
417
418// DisableSender sends the Disable request. The method will close the
419// http.Response Body if it receives an error.
420func (client JobClient) DisableSender(req *http.Request) (*http.Response, error) {
421	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
422}
423
424// DisableResponder handles the response to the Disable request. The method always
425// closes the http.Response Body.
426func (client JobClient) DisableResponder(resp *http.Response) (result autorest.Response, err error) {
427	err = autorest.Respond(
428		resp,
429		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
430		autorest.ByClosing())
431	result.Response = resp
432	return
433}
434
435// Enable when you call this API, the Batch service sets a disabled job to the enabling state. After the this operation
436// is completed, the job moves to the active state, and scheduling of new tasks under the job resumes. The Batch
437// service does not allow a task to remain in the active state for more than 7 days. Therefore, if you enable a job
438// containing active tasks which were added more than 7 days ago, those tasks will not run.
439// Parameters:
440// jobID - the ID of the job to enable.
441// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
442// seconds.
443// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
444// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
445// returnClientRequestID - whether the server should return the client-request-id in the response.
446// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
447// time; set it explicitly if you are calling the REST API directly.
448// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
449// be performed only if the resource's current ETag on the service exactly matches the value specified by the
450// client.
451// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
452// will be performed only if the resource's current ETag on the service does not match the value specified by
453// the client.
454// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
455// operation will be performed only if the resource on the service has been modified since the specified time.
456// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
457// operation will be performed only if the resource on the service has not been modified since the specified
458// time.
459func (client JobClient) Enable(ctx context.Context, jobID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) {
460	if tracing.IsEnabled() {
461		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Enable")
462		defer func() {
463			sc := -1
464			if result.Response != nil {
465				sc = result.Response.StatusCode
466			}
467			tracing.EndSpan(ctx, sc, err)
468		}()
469	}
470	req, err := client.EnablePreparer(ctx, jobID, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
471	if err != nil {
472		err = autorest.NewErrorWithError(err, "batch.JobClient", "Enable", nil, "Failure preparing request")
473		return
474	}
475
476	resp, err := client.EnableSender(req)
477	if err != nil {
478		result.Response = resp
479		err = autorest.NewErrorWithError(err, "batch.JobClient", "Enable", resp, "Failure sending request")
480		return
481	}
482
483	result, err = client.EnableResponder(resp)
484	if err != nil {
485		err = autorest.NewErrorWithError(err, "batch.JobClient", "Enable", resp, "Failure responding to request")
486		return
487	}
488
489	return
490}
491
492// EnablePreparer prepares the Enable request.
493func (client JobClient) EnablePreparer(ctx context.Context, jobID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
494	pathParameters := map[string]interface{}{
495		"jobId": autorest.Encode("path", jobID),
496	}
497
498	const APIVersion = "2017-05-01.5.0"
499	queryParameters := map[string]interface{}{
500		"api-version": APIVersion,
501	}
502	if timeout != nil {
503		queryParameters["timeout"] = autorest.Encode("query", *timeout)
504	} else {
505		queryParameters["timeout"] = autorest.Encode("query", 30)
506	}
507
508	preparer := autorest.CreatePreparer(
509		autorest.AsPost(),
510		autorest.WithBaseURL(client.BaseURI),
511		autorest.WithPathParameters("/jobs/{jobId}/enable", pathParameters),
512		autorest.WithQueryParameters(queryParameters))
513	if clientRequestID != nil {
514		preparer = autorest.DecoratePreparer(preparer,
515			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
516	}
517	if returnClientRequestID != nil {
518		preparer = autorest.DecoratePreparer(preparer,
519			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
520	} else {
521		preparer = autorest.DecoratePreparer(preparer,
522			autorest.WithHeader("return-client-request-id", autorest.String(false)))
523	}
524	if ocpDate != nil {
525		preparer = autorest.DecoratePreparer(preparer,
526			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
527	}
528	if len(ifMatch) > 0 {
529		preparer = autorest.DecoratePreparer(preparer,
530			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
531	}
532	if len(ifNoneMatch) > 0 {
533		preparer = autorest.DecoratePreparer(preparer,
534			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
535	}
536	if ifModifiedSince != nil {
537		preparer = autorest.DecoratePreparer(preparer,
538			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
539	}
540	if ifUnmodifiedSince != nil {
541		preparer = autorest.DecoratePreparer(preparer,
542			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
543	}
544	return preparer.Prepare((&http.Request{}).WithContext(ctx))
545}
546
547// EnableSender sends the Enable request. The method will close the
548// http.Response Body if it receives an error.
549func (client JobClient) EnableSender(req *http.Request) (*http.Response, error) {
550	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
551}
552
553// EnableResponder handles the response to the Enable request. The method always
554// closes the http.Response Body.
555func (client JobClient) EnableResponder(resp *http.Response) (result autorest.Response, err error) {
556	err = autorest.Respond(
557		resp,
558		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
559		autorest.ByClosing())
560	result.Response = resp
561	return
562}
563
564// Get sends the get request.
565// Parameters:
566// jobID - the ID of the job.
567// selectParameter - an OData $select clause.
568// expand - an OData $expand clause.
569// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
570// seconds.
571// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
572// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
573// returnClientRequestID - whether the server should return the client-request-id in the response.
574// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
575// time; set it explicitly if you are calling the REST API directly.
576// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
577// be performed only if the resource's current ETag on the service exactly matches the value specified by the
578// client.
579// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
580// will be performed only if the resource's current ETag on the service does not match the value specified by
581// the client.
582// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
583// operation will be performed only if the resource on the service has been modified since the specified time.
584// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
585// operation will be performed only if the resource on the service has not been modified since the specified
586// time.
587func (client JobClient) Get(ctx context.Context, jobID string, selectParameter string, expand string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result CloudJob, err error) {
588	if tracing.IsEnabled() {
589		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Get")
590		defer func() {
591			sc := -1
592			if result.Response.Response != nil {
593				sc = result.Response.Response.StatusCode
594			}
595			tracing.EndSpan(ctx, sc, err)
596		}()
597	}
598	req, err := client.GetPreparer(ctx, jobID, selectParameter, expand, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
599	if err != nil {
600		err = autorest.NewErrorWithError(err, "batch.JobClient", "Get", nil, "Failure preparing request")
601		return
602	}
603
604	resp, err := client.GetSender(req)
605	if err != nil {
606		result.Response = autorest.Response{Response: resp}
607		err = autorest.NewErrorWithError(err, "batch.JobClient", "Get", resp, "Failure sending request")
608		return
609	}
610
611	result, err = client.GetResponder(resp)
612	if err != nil {
613		err = autorest.NewErrorWithError(err, "batch.JobClient", "Get", resp, "Failure responding to request")
614		return
615	}
616
617	return
618}
619
620// GetPreparer prepares the Get request.
621func (client JobClient) GetPreparer(ctx context.Context, jobID string, selectParameter string, expand string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
622	pathParameters := map[string]interface{}{
623		"jobId": autorest.Encode("path", jobID),
624	}
625
626	const APIVersion = "2017-05-01.5.0"
627	queryParameters := map[string]interface{}{
628		"api-version": APIVersion,
629	}
630	if len(selectParameter) > 0 {
631		queryParameters["$select"] = autorest.Encode("query", selectParameter)
632	}
633	if len(expand) > 0 {
634		queryParameters["$expand"] = autorest.Encode("query", expand)
635	}
636	if timeout != nil {
637		queryParameters["timeout"] = autorest.Encode("query", *timeout)
638	} else {
639		queryParameters["timeout"] = autorest.Encode("query", 30)
640	}
641
642	preparer := autorest.CreatePreparer(
643		autorest.AsGet(),
644		autorest.WithBaseURL(client.BaseURI),
645		autorest.WithPathParameters("/jobs/{jobId}", pathParameters),
646		autorest.WithQueryParameters(queryParameters))
647	if clientRequestID != nil {
648		preparer = autorest.DecoratePreparer(preparer,
649			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
650	}
651	if returnClientRequestID != nil {
652		preparer = autorest.DecoratePreparer(preparer,
653			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
654	} else {
655		preparer = autorest.DecoratePreparer(preparer,
656			autorest.WithHeader("return-client-request-id", autorest.String(false)))
657	}
658	if ocpDate != nil {
659		preparer = autorest.DecoratePreparer(preparer,
660			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
661	}
662	if len(ifMatch) > 0 {
663		preparer = autorest.DecoratePreparer(preparer,
664			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
665	}
666	if len(ifNoneMatch) > 0 {
667		preparer = autorest.DecoratePreparer(preparer,
668			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
669	}
670	if ifModifiedSince != nil {
671		preparer = autorest.DecoratePreparer(preparer,
672			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
673	}
674	if ifUnmodifiedSince != nil {
675		preparer = autorest.DecoratePreparer(preparer,
676			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
677	}
678	return preparer.Prepare((&http.Request{}).WithContext(ctx))
679}
680
681// GetSender sends the Get request. The method will close the
682// http.Response Body if it receives an error.
683func (client JobClient) GetSender(req *http.Request) (*http.Response, error) {
684	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
685}
686
687// GetResponder handles the response to the Get request. The method always
688// closes the http.Response Body.
689func (client JobClient) GetResponder(resp *http.Response) (result CloudJob, err error) {
690	err = autorest.Respond(
691		resp,
692		azure.WithErrorUnlessStatusCode(http.StatusOK),
693		autorest.ByUnmarshallingJSON(&result),
694		autorest.ByClosing())
695	result.Response = autorest.Response{Response: resp}
696	return
697}
698
699// GetAllLifetimeStatistics statistics are aggregated across all jobs that have ever existed in the account, from
700// account creation to the last update time of the statistics.
701// Parameters:
702// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
703// seconds.
704// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
705// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
706// returnClientRequestID - whether the server should return the client-request-id in the response.
707// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
708// time; set it explicitly if you are calling the REST API directly.
709func (client JobClient) GetAllLifetimeStatistics(ctx context.Context, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result JobStatistics, err error) {
710	if tracing.IsEnabled() {
711		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.GetAllLifetimeStatistics")
712		defer func() {
713			sc := -1
714			if result.Response.Response != nil {
715				sc = result.Response.Response.StatusCode
716			}
717			tracing.EndSpan(ctx, sc, err)
718		}()
719	}
720	req, err := client.GetAllLifetimeStatisticsPreparer(ctx, timeout, clientRequestID, returnClientRequestID, ocpDate)
721	if err != nil {
722		err = autorest.NewErrorWithError(err, "batch.JobClient", "GetAllLifetimeStatistics", nil, "Failure preparing request")
723		return
724	}
725
726	resp, err := client.GetAllLifetimeStatisticsSender(req)
727	if err != nil {
728		result.Response = autorest.Response{Response: resp}
729		err = autorest.NewErrorWithError(err, "batch.JobClient", "GetAllLifetimeStatistics", resp, "Failure sending request")
730		return
731	}
732
733	result, err = client.GetAllLifetimeStatisticsResponder(resp)
734	if err != nil {
735		err = autorest.NewErrorWithError(err, "batch.JobClient", "GetAllLifetimeStatistics", resp, "Failure responding to request")
736		return
737	}
738
739	return
740}
741
742// GetAllLifetimeStatisticsPreparer prepares the GetAllLifetimeStatistics request.
743func (client JobClient) GetAllLifetimeStatisticsPreparer(ctx context.Context, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
744	const APIVersion = "2017-05-01.5.0"
745	queryParameters := map[string]interface{}{
746		"api-version": APIVersion,
747	}
748	if timeout != nil {
749		queryParameters["timeout"] = autorest.Encode("query", *timeout)
750	} else {
751		queryParameters["timeout"] = autorest.Encode("query", 30)
752	}
753
754	preparer := autorest.CreatePreparer(
755		autorest.AsGet(),
756		autorest.WithBaseURL(client.BaseURI),
757		autorest.WithPath("/lifetimejobstats"),
758		autorest.WithQueryParameters(queryParameters))
759	if clientRequestID != nil {
760		preparer = autorest.DecoratePreparer(preparer,
761			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
762	}
763	if returnClientRequestID != nil {
764		preparer = autorest.DecoratePreparer(preparer,
765			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
766	} else {
767		preparer = autorest.DecoratePreparer(preparer,
768			autorest.WithHeader("return-client-request-id", autorest.String(false)))
769	}
770	if ocpDate != nil {
771		preparer = autorest.DecoratePreparer(preparer,
772			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
773	}
774	return preparer.Prepare((&http.Request{}).WithContext(ctx))
775}
776
777// GetAllLifetimeStatisticsSender sends the GetAllLifetimeStatistics request. The method will close the
778// http.Response Body if it receives an error.
779func (client JobClient) GetAllLifetimeStatisticsSender(req *http.Request) (*http.Response, error) {
780	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
781}
782
783// GetAllLifetimeStatisticsResponder handles the response to the GetAllLifetimeStatistics request. The method always
784// closes the http.Response Body.
785func (client JobClient) GetAllLifetimeStatisticsResponder(resp *http.Response) (result JobStatistics, err error) {
786	err = autorest.Respond(
787		resp,
788		azure.WithErrorUnlessStatusCode(http.StatusOK),
789		autorest.ByUnmarshallingJSON(&result),
790		autorest.ByClosing())
791	result.Response = autorest.Response{Response: resp}
792	return
793}
794
795// List sends the list request.
796// Parameters:
797// filter - an OData $filter clause.
798// selectParameter - an OData $select clause.
799// expand - an OData $expand clause.
800// maxResults - the maximum number of items to return in the response. A maximum of 1000 jobs can be returned.
801// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
802// seconds.
803// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
804// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
805// returnClientRequestID - whether the server should return the client-request-id in the response.
806// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
807// time; set it explicitly if you are calling the REST API directly.
808func (client JobClient) List(ctx context.Context, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudJobListResultPage, err error) {
809	if tracing.IsEnabled() {
810		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.List")
811		defer func() {
812			sc := -1
813			if result.cjlr.Response.Response != nil {
814				sc = result.cjlr.Response.Response.StatusCode
815			}
816			tracing.EndSpan(ctx, sc, err)
817		}()
818	}
819	if err := validation.Validate([]validation.Validation{
820		{TargetValue: maxResults,
821			Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
822				Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
823					{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
824				}}}}}); err != nil {
825		return result, validation.NewError("batch.JobClient", "List", err.Error())
826	}
827
828	result.fn = client.listNextResults
829	req, err := client.ListPreparer(ctx, filter, selectParameter, expand, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
830	if err != nil {
831		err = autorest.NewErrorWithError(err, "batch.JobClient", "List", nil, "Failure preparing request")
832		return
833	}
834
835	resp, err := client.ListSender(req)
836	if err != nil {
837		result.cjlr.Response = autorest.Response{Response: resp}
838		err = autorest.NewErrorWithError(err, "batch.JobClient", "List", resp, "Failure sending request")
839		return
840	}
841
842	result.cjlr, err = client.ListResponder(resp)
843	if err != nil {
844		err = autorest.NewErrorWithError(err, "batch.JobClient", "List", resp, "Failure responding to request")
845		return
846	}
847	if result.cjlr.hasNextLink() && result.cjlr.IsEmpty() {
848		err = result.NextWithContext(ctx)
849		return
850	}
851
852	return
853}
854
855// ListPreparer prepares the List request.
856func (client JobClient) ListPreparer(ctx context.Context, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
857	const APIVersion = "2017-05-01.5.0"
858	queryParameters := map[string]interface{}{
859		"api-version": APIVersion,
860	}
861	if len(filter) > 0 {
862		queryParameters["$filter"] = autorest.Encode("query", filter)
863	}
864	if len(selectParameter) > 0 {
865		queryParameters["$select"] = autorest.Encode("query", selectParameter)
866	}
867	if len(expand) > 0 {
868		queryParameters["$expand"] = autorest.Encode("query", expand)
869	}
870	if maxResults != nil {
871		queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
872	} else {
873		queryParameters["maxresults"] = autorest.Encode("query", 1000)
874	}
875	if timeout != nil {
876		queryParameters["timeout"] = autorest.Encode("query", *timeout)
877	} else {
878		queryParameters["timeout"] = autorest.Encode("query", 30)
879	}
880
881	preparer := autorest.CreatePreparer(
882		autorest.AsGet(),
883		autorest.WithBaseURL(client.BaseURI),
884		autorest.WithPath("/jobs"),
885		autorest.WithQueryParameters(queryParameters))
886	if clientRequestID != nil {
887		preparer = autorest.DecoratePreparer(preparer,
888			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
889	}
890	if returnClientRequestID != nil {
891		preparer = autorest.DecoratePreparer(preparer,
892			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
893	} else {
894		preparer = autorest.DecoratePreparer(preparer,
895			autorest.WithHeader("return-client-request-id", autorest.String(false)))
896	}
897	if ocpDate != nil {
898		preparer = autorest.DecoratePreparer(preparer,
899			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
900	}
901	return preparer.Prepare((&http.Request{}).WithContext(ctx))
902}
903
904// ListSender sends the List request. The method will close the
905// http.Response Body if it receives an error.
906func (client JobClient) ListSender(req *http.Request) (*http.Response, error) {
907	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
908}
909
910// ListResponder handles the response to the List request. The method always
911// closes the http.Response Body.
912func (client JobClient) ListResponder(resp *http.Response) (result CloudJobListResult, err error) {
913	err = autorest.Respond(
914		resp,
915		azure.WithErrorUnlessStatusCode(http.StatusOK),
916		autorest.ByUnmarshallingJSON(&result),
917		autorest.ByClosing())
918	result.Response = autorest.Response{Response: resp}
919	return
920}
921
922// listNextResults retrieves the next set of results, if any.
923func (client JobClient) listNextResults(ctx context.Context, lastResults CloudJobListResult) (result CloudJobListResult, err error) {
924	req, err := lastResults.cloudJobListResultPreparer(ctx)
925	if err != nil {
926		return result, autorest.NewErrorWithError(err, "batch.JobClient", "listNextResults", nil, "Failure preparing next results request")
927	}
928	if req == nil {
929		return
930	}
931	resp, err := client.ListSender(req)
932	if err != nil {
933		result.Response = autorest.Response{Response: resp}
934		return result, autorest.NewErrorWithError(err, "batch.JobClient", "listNextResults", resp, "Failure sending next results request")
935	}
936	result, err = client.ListResponder(resp)
937	if err != nil {
938		err = autorest.NewErrorWithError(err, "batch.JobClient", "listNextResults", resp, "Failure responding to next results request")
939	}
940	return
941}
942
943// ListComplete enumerates all values, automatically crossing page boundaries as required.
944func (client JobClient) ListComplete(ctx context.Context, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudJobListResultIterator, err error) {
945	if tracing.IsEnabled() {
946		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.List")
947		defer func() {
948			sc := -1
949			if result.Response().Response.Response != nil {
950				sc = result.page.Response().Response.Response.StatusCode
951			}
952			tracing.EndSpan(ctx, sc, err)
953		}()
954	}
955	result.page, err = client.List(ctx, filter, selectParameter, expand, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
956	return
957}
958
959// ListFromJobSchedule sends the list from job schedule request.
960// Parameters:
961// jobScheduleID - the ID of the job schedule from which you want to get a list of jobs.
962// filter - an OData $filter clause.
963// selectParameter - an OData $select clause.
964// expand - an OData $expand clause.
965// maxResults - the maximum number of items to return in the response. A maximum of 1000 jobs can be returned.
966// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
967// seconds.
968// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
969// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
970// returnClientRequestID - whether the server should return the client-request-id in the response.
971// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
972// time; set it explicitly if you are calling the REST API directly.
973func (client JobClient) ListFromJobSchedule(ctx context.Context, jobScheduleID string, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudJobListResultPage, err error) {
974	if tracing.IsEnabled() {
975		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.ListFromJobSchedule")
976		defer func() {
977			sc := -1
978			if result.cjlr.Response.Response != nil {
979				sc = result.cjlr.Response.Response.StatusCode
980			}
981			tracing.EndSpan(ctx, sc, err)
982		}()
983	}
984	if err := validation.Validate([]validation.Validation{
985		{TargetValue: maxResults,
986			Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
987				Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
988					{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
989				}}}}}); err != nil {
990		return result, validation.NewError("batch.JobClient", "ListFromJobSchedule", err.Error())
991	}
992
993	result.fn = client.listFromJobScheduleNextResults
994	req, err := client.ListFromJobSchedulePreparer(ctx, jobScheduleID, filter, selectParameter, expand, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
995	if err != nil {
996		err = autorest.NewErrorWithError(err, "batch.JobClient", "ListFromJobSchedule", nil, "Failure preparing request")
997		return
998	}
999
1000	resp, err := client.ListFromJobScheduleSender(req)
1001	if err != nil {
1002		result.cjlr.Response = autorest.Response{Response: resp}
1003		err = autorest.NewErrorWithError(err, "batch.JobClient", "ListFromJobSchedule", resp, "Failure sending request")
1004		return
1005	}
1006
1007	result.cjlr, err = client.ListFromJobScheduleResponder(resp)
1008	if err != nil {
1009		err = autorest.NewErrorWithError(err, "batch.JobClient", "ListFromJobSchedule", resp, "Failure responding to request")
1010		return
1011	}
1012	if result.cjlr.hasNextLink() && result.cjlr.IsEmpty() {
1013		err = result.NextWithContext(ctx)
1014		return
1015	}
1016
1017	return
1018}
1019
1020// ListFromJobSchedulePreparer prepares the ListFromJobSchedule request.
1021func (client JobClient) ListFromJobSchedulePreparer(ctx context.Context, jobScheduleID string, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
1022	pathParameters := map[string]interface{}{
1023		"jobScheduleId": autorest.Encode("path", jobScheduleID),
1024	}
1025
1026	const APIVersion = "2017-05-01.5.0"
1027	queryParameters := map[string]interface{}{
1028		"api-version": APIVersion,
1029	}
1030	if len(filter) > 0 {
1031		queryParameters["$filter"] = autorest.Encode("query", filter)
1032	}
1033	if len(selectParameter) > 0 {
1034		queryParameters["$select"] = autorest.Encode("query", selectParameter)
1035	}
1036	if len(expand) > 0 {
1037		queryParameters["$expand"] = autorest.Encode("query", expand)
1038	}
1039	if maxResults != nil {
1040		queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
1041	} else {
1042		queryParameters["maxresults"] = autorest.Encode("query", 1000)
1043	}
1044	if timeout != nil {
1045		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1046	} else {
1047		queryParameters["timeout"] = autorest.Encode("query", 30)
1048	}
1049
1050	preparer := autorest.CreatePreparer(
1051		autorest.AsGet(),
1052		autorest.WithBaseURL(client.BaseURI),
1053		autorest.WithPathParameters("/jobschedules/{jobScheduleId}/jobs", pathParameters),
1054		autorest.WithQueryParameters(queryParameters))
1055	if clientRequestID != nil {
1056		preparer = autorest.DecoratePreparer(preparer,
1057			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1058	}
1059	if returnClientRequestID != nil {
1060		preparer = autorest.DecoratePreparer(preparer,
1061			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1062	} else {
1063		preparer = autorest.DecoratePreparer(preparer,
1064			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1065	}
1066	if ocpDate != nil {
1067		preparer = autorest.DecoratePreparer(preparer,
1068			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1069	}
1070	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1071}
1072
1073// ListFromJobScheduleSender sends the ListFromJobSchedule request. The method will close the
1074// http.Response Body if it receives an error.
1075func (client JobClient) ListFromJobScheduleSender(req *http.Request) (*http.Response, error) {
1076	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1077}
1078
1079// ListFromJobScheduleResponder handles the response to the ListFromJobSchedule request. The method always
1080// closes the http.Response Body.
1081func (client JobClient) ListFromJobScheduleResponder(resp *http.Response) (result CloudJobListResult, err error) {
1082	err = autorest.Respond(
1083		resp,
1084		azure.WithErrorUnlessStatusCode(http.StatusOK),
1085		autorest.ByUnmarshallingJSON(&result),
1086		autorest.ByClosing())
1087	result.Response = autorest.Response{Response: resp}
1088	return
1089}
1090
1091// listFromJobScheduleNextResults retrieves the next set of results, if any.
1092func (client JobClient) listFromJobScheduleNextResults(ctx context.Context, lastResults CloudJobListResult) (result CloudJobListResult, err error) {
1093	req, err := lastResults.cloudJobListResultPreparer(ctx)
1094	if err != nil {
1095		return result, autorest.NewErrorWithError(err, "batch.JobClient", "listFromJobScheduleNextResults", nil, "Failure preparing next results request")
1096	}
1097	if req == nil {
1098		return
1099	}
1100	resp, err := client.ListFromJobScheduleSender(req)
1101	if err != nil {
1102		result.Response = autorest.Response{Response: resp}
1103		return result, autorest.NewErrorWithError(err, "batch.JobClient", "listFromJobScheduleNextResults", resp, "Failure sending next results request")
1104	}
1105	result, err = client.ListFromJobScheduleResponder(resp)
1106	if err != nil {
1107		err = autorest.NewErrorWithError(err, "batch.JobClient", "listFromJobScheduleNextResults", resp, "Failure responding to next results request")
1108	}
1109	return
1110}
1111
1112// ListFromJobScheduleComplete enumerates all values, automatically crossing page boundaries as required.
1113func (client JobClient) ListFromJobScheduleComplete(ctx context.Context, jobScheduleID string, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudJobListResultIterator, err error) {
1114	if tracing.IsEnabled() {
1115		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.ListFromJobSchedule")
1116		defer func() {
1117			sc := -1
1118			if result.Response().Response.Response != nil {
1119				sc = result.page.Response().Response.Response.StatusCode
1120			}
1121			tracing.EndSpan(ctx, sc, err)
1122		}()
1123	}
1124	result.page, err = client.ListFromJobSchedule(ctx, jobScheduleID, filter, selectParameter, expand, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
1125	return
1126}
1127
1128// ListPreparationAndReleaseTaskStatus this API returns the Job Preparation and Job Release task status on all compute
1129// nodes that have run the Job Preparation or Job Release task. This includes nodes which have since been removed from
1130// the pool.
1131// Parameters:
1132// jobID - the ID of the job.
1133// filter - an OData $filter clause.
1134// selectParameter - an OData $select clause.
1135// maxResults - the maximum number of items to return in the response. A maximum of 1000 tasks can be returned.
1136// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
1137// seconds.
1138// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
1139// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
1140// returnClientRequestID - whether the server should return the client-request-id in the response.
1141// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
1142// time; set it explicitly if you are calling the REST API directly.
1143func (client JobClient) ListPreparationAndReleaseTaskStatus(ctx context.Context, jobID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudJobListPreparationAndReleaseTaskStatusResultPage, err error) {
1144	if tracing.IsEnabled() {
1145		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.ListPreparationAndReleaseTaskStatus")
1146		defer func() {
1147			sc := -1
1148			if result.cjlpartsr.Response.Response != nil {
1149				sc = result.cjlpartsr.Response.Response.StatusCode
1150			}
1151			tracing.EndSpan(ctx, sc, err)
1152		}()
1153	}
1154	if err := validation.Validate([]validation.Validation{
1155		{TargetValue: maxResults,
1156			Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
1157				Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
1158					{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
1159				}}}}}); err != nil {
1160		return result, validation.NewError("batch.JobClient", "ListPreparationAndReleaseTaskStatus", err.Error())
1161	}
1162
1163	result.fn = client.listPreparationAndReleaseTaskStatusNextResults
1164	req, err := client.ListPreparationAndReleaseTaskStatusPreparer(ctx, jobID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
1165	if err != nil {
1166		err = autorest.NewErrorWithError(err, "batch.JobClient", "ListPreparationAndReleaseTaskStatus", nil, "Failure preparing request")
1167		return
1168	}
1169
1170	resp, err := client.ListPreparationAndReleaseTaskStatusSender(req)
1171	if err != nil {
1172		result.cjlpartsr.Response = autorest.Response{Response: resp}
1173		err = autorest.NewErrorWithError(err, "batch.JobClient", "ListPreparationAndReleaseTaskStatus", resp, "Failure sending request")
1174		return
1175	}
1176
1177	result.cjlpartsr, err = client.ListPreparationAndReleaseTaskStatusResponder(resp)
1178	if err != nil {
1179		err = autorest.NewErrorWithError(err, "batch.JobClient", "ListPreparationAndReleaseTaskStatus", resp, "Failure responding to request")
1180		return
1181	}
1182	if result.cjlpartsr.hasNextLink() && result.cjlpartsr.IsEmpty() {
1183		err = result.NextWithContext(ctx)
1184		return
1185	}
1186
1187	return
1188}
1189
1190// ListPreparationAndReleaseTaskStatusPreparer prepares the ListPreparationAndReleaseTaskStatus request.
1191func (client JobClient) ListPreparationAndReleaseTaskStatusPreparer(ctx context.Context, jobID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
1192	pathParameters := map[string]interface{}{
1193		"jobId": autorest.Encode("path", jobID),
1194	}
1195
1196	const APIVersion = "2017-05-01.5.0"
1197	queryParameters := map[string]interface{}{
1198		"api-version": APIVersion,
1199	}
1200	if len(filter) > 0 {
1201		queryParameters["$filter"] = autorest.Encode("query", filter)
1202	}
1203	if len(selectParameter) > 0 {
1204		queryParameters["$select"] = autorest.Encode("query", selectParameter)
1205	}
1206	if maxResults != nil {
1207		queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
1208	} else {
1209		queryParameters["maxresults"] = autorest.Encode("query", 1000)
1210	}
1211	if timeout != nil {
1212		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1213	} else {
1214		queryParameters["timeout"] = autorest.Encode("query", 30)
1215	}
1216
1217	preparer := autorest.CreatePreparer(
1218		autorest.AsGet(),
1219		autorest.WithBaseURL(client.BaseURI),
1220		autorest.WithPathParameters("/jobs/{jobId}/jobpreparationandreleasetaskstatus", pathParameters),
1221		autorest.WithQueryParameters(queryParameters))
1222	if clientRequestID != nil {
1223		preparer = autorest.DecoratePreparer(preparer,
1224			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1225	}
1226	if returnClientRequestID != nil {
1227		preparer = autorest.DecoratePreparer(preparer,
1228			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1229	} else {
1230		preparer = autorest.DecoratePreparer(preparer,
1231			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1232	}
1233	if ocpDate != nil {
1234		preparer = autorest.DecoratePreparer(preparer,
1235			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1236	}
1237	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1238}
1239
1240// ListPreparationAndReleaseTaskStatusSender sends the ListPreparationAndReleaseTaskStatus request. The method will close the
1241// http.Response Body if it receives an error.
1242func (client JobClient) ListPreparationAndReleaseTaskStatusSender(req *http.Request) (*http.Response, error) {
1243	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1244}
1245
1246// ListPreparationAndReleaseTaskStatusResponder handles the response to the ListPreparationAndReleaseTaskStatus request. The method always
1247// closes the http.Response Body.
1248func (client JobClient) ListPreparationAndReleaseTaskStatusResponder(resp *http.Response) (result CloudJobListPreparationAndReleaseTaskStatusResult, err error) {
1249	err = autorest.Respond(
1250		resp,
1251		azure.WithErrorUnlessStatusCode(http.StatusOK),
1252		autorest.ByUnmarshallingJSON(&result),
1253		autorest.ByClosing())
1254	result.Response = autorest.Response{Response: resp}
1255	return
1256}
1257
1258// listPreparationAndReleaseTaskStatusNextResults retrieves the next set of results, if any.
1259func (client JobClient) listPreparationAndReleaseTaskStatusNextResults(ctx context.Context, lastResults CloudJobListPreparationAndReleaseTaskStatusResult) (result CloudJobListPreparationAndReleaseTaskStatusResult, err error) {
1260	req, err := lastResults.cloudJobListPreparationAndReleaseTaskStatusResultPreparer(ctx)
1261	if err != nil {
1262		return result, autorest.NewErrorWithError(err, "batch.JobClient", "listPreparationAndReleaseTaskStatusNextResults", nil, "Failure preparing next results request")
1263	}
1264	if req == nil {
1265		return
1266	}
1267	resp, err := client.ListPreparationAndReleaseTaskStatusSender(req)
1268	if err != nil {
1269		result.Response = autorest.Response{Response: resp}
1270		return result, autorest.NewErrorWithError(err, "batch.JobClient", "listPreparationAndReleaseTaskStatusNextResults", resp, "Failure sending next results request")
1271	}
1272	result, err = client.ListPreparationAndReleaseTaskStatusResponder(resp)
1273	if err != nil {
1274		err = autorest.NewErrorWithError(err, "batch.JobClient", "listPreparationAndReleaseTaskStatusNextResults", resp, "Failure responding to next results request")
1275	}
1276	return
1277}
1278
1279// ListPreparationAndReleaseTaskStatusComplete enumerates all values, automatically crossing page boundaries as required.
1280func (client JobClient) ListPreparationAndReleaseTaskStatusComplete(ctx context.Context, jobID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudJobListPreparationAndReleaseTaskStatusResultIterator, err error) {
1281	if tracing.IsEnabled() {
1282		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.ListPreparationAndReleaseTaskStatus")
1283		defer func() {
1284			sc := -1
1285			if result.Response().Response.Response != nil {
1286				sc = result.page.Response().Response.Response.StatusCode
1287			}
1288			tracing.EndSpan(ctx, sc, err)
1289		}()
1290	}
1291	result.page, err = client.ListPreparationAndReleaseTaskStatus(ctx, jobID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
1292	return
1293}
1294
1295// Patch this replaces only the job properties specified in the request. For example, if the job has constraints, and a
1296// request does not specify the constraints element, then the job keeps the existing constraints.
1297// Parameters:
1298// jobID - the ID of the job whose properties you want to update.
1299// jobPatchParameter - the parameters for the request.
1300// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
1301// seconds.
1302// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
1303// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
1304// returnClientRequestID - whether the server should return the client-request-id in the response.
1305// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
1306// time; set it explicitly if you are calling the REST API directly.
1307// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
1308// be performed only if the resource's current ETag on the service exactly matches the value specified by the
1309// client.
1310// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
1311// will be performed only if the resource's current ETag on the service does not match the value specified by
1312// the client.
1313// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
1314// operation will be performed only if the resource on the service has been modified since the specified time.
1315// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
1316// operation will be performed only if the resource on the service has not been modified since the specified
1317// time.
1318func (client JobClient) Patch(ctx context.Context, jobID string, jobPatchParameter JobPatchParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) {
1319	if tracing.IsEnabled() {
1320		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Patch")
1321		defer func() {
1322			sc := -1
1323			if result.Response != nil {
1324				sc = result.Response.StatusCode
1325			}
1326			tracing.EndSpan(ctx, sc, err)
1327		}()
1328	}
1329	req, err := client.PatchPreparer(ctx, jobID, jobPatchParameter, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
1330	if err != nil {
1331		err = autorest.NewErrorWithError(err, "batch.JobClient", "Patch", nil, "Failure preparing request")
1332		return
1333	}
1334
1335	resp, err := client.PatchSender(req)
1336	if err != nil {
1337		result.Response = resp
1338		err = autorest.NewErrorWithError(err, "batch.JobClient", "Patch", resp, "Failure sending request")
1339		return
1340	}
1341
1342	result, err = client.PatchResponder(resp)
1343	if err != nil {
1344		err = autorest.NewErrorWithError(err, "batch.JobClient", "Patch", resp, "Failure responding to request")
1345		return
1346	}
1347
1348	return
1349}
1350
1351// PatchPreparer prepares the Patch request.
1352func (client JobClient) PatchPreparer(ctx context.Context, jobID string, jobPatchParameter JobPatchParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
1353	pathParameters := map[string]interface{}{
1354		"jobId": autorest.Encode("path", jobID),
1355	}
1356
1357	const APIVersion = "2017-05-01.5.0"
1358	queryParameters := map[string]interface{}{
1359		"api-version": APIVersion,
1360	}
1361	if timeout != nil {
1362		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1363	} else {
1364		queryParameters["timeout"] = autorest.Encode("query", 30)
1365	}
1366
1367	preparer := autorest.CreatePreparer(
1368		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
1369		autorest.AsPatch(),
1370		autorest.WithBaseURL(client.BaseURI),
1371		autorest.WithPathParameters("/jobs/{jobId}", pathParameters),
1372		autorest.WithJSON(jobPatchParameter),
1373		autorest.WithQueryParameters(queryParameters))
1374	if clientRequestID != nil {
1375		preparer = autorest.DecoratePreparer(preparer,
1376			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1377	}
1378	if returnClientRequestID != nil {
1379		preparer = autorest.DecoratePreparer(preparer,
1380			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1381	} else {
1382		preparer = autorest.DecoratePreparer(preparer,
1383			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1384	}
1385	if ocpDate != nil {
1386		preparer = autorest.DecoratePreparer(preparer,
1387			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1388	}
1389	if len(ifMatch) > 0 {
1390		preparer = autorest.DecoratePreparer(preparer,
1391			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
1392	}
1393	if len(ifNoneMatch) > 0 {
1394		preparer = autorest.DecoratePreparer(preparer,
1395			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
1396	}
1397	if ifModifiedSince != nil {
1398		preparer = autorest.DecoratePreparer(preparer,
1399			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
1400	}
1401	if ifUnmodifiedSince != nil {
1402		preparer = autorest.DecoratePreparer(preparer,
1403			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
1404	}
1405	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1406}
1407
1408// PatchSender sends the Patch request. The method will close the
1409// http.Response Body if it receives an error.
1410func (client JobClient) PatchSender(req *http.Request) (*http.Response, error) {
1411	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1412}
1413
1414// PatchResponder handles the response to the Patch request. The method always
1415// closes the http.Response Body.
1416func (client JobClient) PatchResponder(resp *http.Response) (result autorest.Response, err error) {
1417	err = autorest.Respond(
1418		resp,
1419		azure.WithErrorUnlessStatusCode(http.StatusOK),
1420		autorest.ByClosing())
1421	result.Response = resp
1422	return
1423}
1424
1425// Terminate when a Terminate Job request is received, the Batch service sets the job to the terminating state. The
1426// Batch service then terminates any active or running tasks associated with the job, and runs any required Job Release
1427// tasks. The job then moves into the completed state.
1428// Parameters:
1429// jobID - the ID of the job to terminate.
1430// jobTerminateParameter - the parameters for the request.
1431// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
1432// seconds.
1433// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
1434// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
1435// returnClientRequestID - whether the server should return the client-request-id in the response.
1436// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
1437// time; set it explicitly if you are calling the REST API directly.
1438// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
1439// be performed only if the resource's current ETag on the service exactly matches the value specified by the
1440// client.
1441// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
1442// will be performed only if the resource's current ETag on the service does not match the value specified by
1443// the client.
1444// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
1445// operation will be performed only if the resource on the service has been modified since the specified time.
1446// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
1447// operation will be performed only if the resource on the service has not been modified since the specified
1448// time.
1449func (client JobClient) Terminate(ctx context.Context, jobID string, jobTerminateParameter *JobTerminateParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) {
1450	if tracing.IsEnabled() {
1451		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Terminate")
1452		defer func() {
1453			sc := -1
1454			if result.Response != nil {
1455				sc = result.Response.StatusCode
1456			}
1457			tracing.EndSpan(ctx, sc, err)
1458		}()
1459	}
1460	req, err := client.TerminatePreparer(ctx, jobID, jobTerminateParameter, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
1461	if err != nil {
1462		err = autorest.NewErrorWithError(err, "batch.JobClient", "Terminate", nil, "Failure preparing request")
1463		return
1464	}
1465
1466	resp, err := client.TerminateSender(req)
1467	if err != nil {
1468		result.Response = resp
1469		err = autorest.NewErrorWithError(err, "batch.JobClient", "Terminate", resp, "Failure sending request")
1470		return
1471	}
1472
1473	result, err = client.TerminateResponder(resp)
1474	if err != nil {
1475		err = autorest.NewErrorWithError(err, "batch.JobClient", "Terminate", resp, "Failure responding to request")
1476		return
1477	}
1478
1479	return
1480}
1481
1482// TerminatePreparer prepares the Terminate request.
1483func (client JobClient) TerminatePreparer(ctx context.Context, jobID string, jobTerminateParameter *JobTerminateParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
1484	pathParameters := map[string]interface{}{
1485		"jobId": autorest.Encode("path", jobID),
1486	}
1487
1488	const APIVersion = "2017-05-01.5.0"
1489	queryParameters := map[string]interface{}{
1490		"api-version": APIVersion,
1491	}
1492	if timeout != nil {
1493		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1494	} else {
1495		queryParameters["timeout"] = autorest.Encode("query", 30)
1496	}
1497
1498	preparer := autorest.CreatePreparer(
1499		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
1500		autorest.AsPost(),
1501		autorest.WithBaseURL(client.BaseURI),
1502		autorest.WithPathParameters("/jobs/{jobId}/terminate", pathParameters),
1503		autorest.WithQueryParameters(queryParameters))
1504	if jobTerminateParameter != nil {
1505		preparer = autorest.DecoratePreparer(preparer,
1506			autorest.WithJSON(jobTerminateParameter))
1507	}
1508	if clientRequestID != nil {
1509		preparer = autorest.DecoratePreparer(preparer,
1510			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1511	}
1512	if returnClientRequestID != nil {
1513		preparer = autorest.DecoratePreparer(preparer,
1514			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1515	} else {
1516		preparer = autorest.DecoratePreparer(preparer,
1517			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1518	}
1519	if ocpDate != nil {
1520		preparer = autorest.DecoratePreparer(preparer,
1521			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1522	}
1523	if len(ifMatch) > 0 {
1524		preparer = autorest.DecoratePreparer(preparer,
1525			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
1526	}
1527	if len(ifNoneMatch) > 0 {
1528		preparer = autorest.DecoratePreparer(preparer,
1529			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
1530	}
1531	if ifModifiedSince != nil {
1532		preparer = autorest.DecoratePreparer(preparer,
1533			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
1534	}
1535	if ifUnmodifiedSince != nil {
1536		preparer = autorest.DecoratePreparer(preparer,
1537			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
1538	}
1539	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1540}
1541
1542// TerminateSender sends the Terminate request. The method will close the
1543// http.Response Body if it receives an error.
1544func (client JobClient) TerminateSender(req *http.Request) (*http.Response, error) {
1545	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1546}
1547
1548// TerminateResponder handles the response to the Terminate request. The method always
1549// closes the http.Response Body.
1550func (client JobClient) TerminateResponder(resp *http.Response) (result autorest.Response, err error) {
1551	err = autorest.Respond(
1552		resp,
1553		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1554		autorest.ByClosing())
1555	result.Response = resp
1556	return
1557}
1558
1559// Update this fully replaces all the updatable properties of the job. For example, if the job has constraints
1560// associated with it and if constraints is not specified with this request, then the Batch service will remove the
1561// existing constraints.
1562// Parameters:
1563// jobID - the ID of the job whose properties you want to update.
1564// jobUpdateParameter - the parameters for the request.
1565// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
1566// seconds.
1567// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
1568// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
1569// returnClientRequestID - whether the server should return the client-request-id in the response.
1570// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
1571// time; set it explicitly if you are calling the REST API directly.
1572// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
1573// be performed only if the resource's current ETag on the service exactly matches the value specified by the
1574// client.
1575// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
1576// will be performed only if the resource's current ETag on the service does not match the value specified by
1577// the client.
1578// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
1579// operation will be performed only if the resource on the service has been modified since the specified time.
1580// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
1581// operation will be performed only if the resource on the service has not been modified since the specified
1582// time.
1583func (client JobClient) Update(ctx context.Context, jobID string, jobUpdateParameter JobUpdateParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) {
1584	if tracing.IsEnabled() {
1585		ctx = tracing.StartSpan(ctx, fqdn+"/JobClient.Update")
1586		defer func() {
1587			sc := -1
1588			if result.Response != nil {
1589				sc = result.Response.StatusCode
1590			}
1591			tracing.EndSpan(ctx, sc, err)
1592		}()
1593	}
1594	if err := validation.Validate([]validation.Validation{
1595		{TargetValue: jobUpdateParameter,
1596			Constraints: []validation.Constraint{{Target: "jobUpdateParameter.PoolInfo", Name: validation.Null, Rule: true,
1597				Chain: []validation.Constraint{{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification", Name: validation.Null, Rule: false,
1598					Chain: []validation.Constraint{{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool", Name: validation.Null, Rule: false,
1599						Chain: []validation.Constraint{{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.VMSize", Name: validation.Null, Rule: true, Chain: nil},
1600							{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.CloudServiceConfiguration", Name: validation.Null, Rule: false,
1601								Chain: []validation.Constraint{{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.CloudServiceConfiguration.OsFamily", Name: validation.Null, Rule: true, Chain: nil}}},
1602							{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration", Name: validation.Null, Rule: false,
1603								Chain: []validation.Constraint{{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.ImageReference", Name: validation.Null, Rule: false,
1604									Chain: []validation.Constraint{{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.ImageReference.Publisher", Name: validation.Null, Rule: true, Chain: nil},
1605										{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.ImageReference.Offer", Name: validation.Null, Rule: true, Chain: nil},
1606										{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.ImageReference.Sku", Name: validation.Null, Rule: true, Chain: nil},
1607									}},
1608									{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.OsDisk", Name: validation.Null, Rule: false,
1609										Chain: []validation.Constraint{{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.OsDisk.ImageUris", Name: validation.Null, Rule: true, Chain: nil}}},
1610									{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.VirtualMachineConfiguration.NodeAgentSKUID", Name: validation.Null, Rule: true, Chain: nil},
1611								}},
1612							{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.StartTask", Name: validation.Null, Rule: false,
1613								Chain: []validation.Constraint{{Target: "jobUpdateParameter.PoolInfo.AutoPoolSpecification.Pool.StartTask.CommandLine", Name: validation.Null, Rule: true, Chain: nil}}},
1614						}},
1615					}},
1616				}}}}}); err != nil {
1617		return result, validation.NewError("batch.JobClient", "Update", err.Error())
1618	}
1619
1620	req, err := client.UpdatePreparer(ctx, jobID, jobUpdateParameter, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
1621	if err != nil {
1622		err = autorest.NewErrorWithError(err, "batch.JobClient", "Update", nil, "Failure preparing request")
1623		return
1624	}
1625
1626	resp, err := client.UpdateSender(req)
1627	if err != nil {
1628		result.Response = resp
1629		err = autorest.NewErrorWithError(err, "batch.JobClient", "Update", resp, "Failure sending request")
1630		return
1631	}
1632
1633	result, err = client.UpdateResponder(resp)
1634	if err != nil {
1635		err = autorest.NewErrorWithError(err, "batch.JobClient", "Update", resp, "Failure responding to request")
1636		return
1637	}
1638
1639	return
1640}
1641
1642// UpdatePreparer prepares the Update request.
1643func (client JobClient) UpdatePreparer(ctx context.Context, jobID string, jobUpdateParameter JobUpdateParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
1644	pathParameters := map[string]interface{}{
1645		"jobId": autorest.Encode("path", jobID),
1646	}
1647
1648	const APIVersion = "2017-05-01.5.0"
1649	queryParameters := map[string]interface{}{
1650		"api-version": APIVersion,
1651	}
1652	if timeout != nil {
1653		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1654	} else {
1655		queryParameters["timeout"] = autorest.Encode("query", 30)
1656	}
1657
1658	preparer := autorest.CreatePreparer(
1659		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
1660		autorest.AsPut(),
1661		autorest.WithBaseURL(client.BaseURI),
1662		autorest.WithPathParameters("/jobs/{jobId}", pathParameters),
1663		autorest.WithJSON(jobUpdateParameter),
1664		autorest.WithQueryParameters(queryParameters))
1665	if clientRequestID != nil {
1666		preparer = autorest.DecoratePreparer(preparer,
1667			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1668	}
1669	if returnClientRequestID != nil {
1670		preparer = autorest.DecoratePreparer(preparer,
1671			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1672	} else {
1673		preparer = autorest.DecoratePreparer(preparer,
1674			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1675	}
1676	if ocpDate != nil {
1677		preparer = autorest.DecoratePreparer(preparer,
1678			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1679	}
1680	if len(ifMatch) > 0 {
1681		preparer = autorest.DecoratePreparer(preparer,
1682			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
1683	}
1684	if len(ifNoneMatch) > 0 {
1685		preparer = autorest.DecoratePreparer(preparer,
1686			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
1687	}
1688	if ifModifiedSince != nil {
1689		preparer = autorest.DecoratePreparer(preparer,
1690			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
1691	}
1692	if ifUnmodifiedSince != nil {
1693		preparer = autorest.DecoratePreparer(preparer,
1694			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
1695	}
1696	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1697}
1698
1699// UpdateSender sends the Update request. The method will close the
1700// http.Response Body if it receives an error.
1701func (client JobClient) UpdateSender(req *http.Request) (*http.Response, error) {
1702	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1703}
1704
1705// UpdateResponder handles the response to the Update request. The method always
1706// closes the http.Response Body.
1707func (client JobClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
1708	err = autorest.Respond(
1709		resp,
1710		azure.WithErrorUnlessStatusCode(http.StatusOK),
1711		autorest.ByClosing())
1712	result.Response = resp
1713	return
1714}
1715