1package batch
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/date"
25	"github.com/Azure/go-autorest/autorest/validation"
26	"github.com/Azure/go-autorest/tracing"
27	"github.com/gofrs/uuid"
28	"net/http"
29)
30
31// TaskClient is the a client for issuing REST requests to the Azure Batch service.
32type TaskClient struct {
33	BaseClient
34}
35
36// NewTaskClient creates an instance of the TaskClient client.
37func NewTaskClient() TaskClient {
38	return NewTaskClientWithBaseURI(DefaultBaseURI)
39}
40
41// NewTaskClientWithBaseURI creates an instance of the TaskClient client using a custom endpoint.  Use this when
42// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
43func NewTaskClientWithBaseURI(baseURI string) TaskClient {
44	return TaskClient{NewWithBaseURI(baseURI)}
45}
46
47// Add sends the add request.
48// Parameters:
49// jobID - the ID of the job to which the task is to be added.
50// task - the task to be added.
51// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
52// seconds.
53// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
54// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
55// returnClientRequestID - whether the server should return the client-request-id in the response.
56// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
57// time; set it explicitly if you are calling the REST API directly.
58func (client TaskClient) Add(ctx context.Context, jobID string, task TaskAddParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
59	if tracing.IsEnabled() {
60		ctx = tracing.StartSpan(ctx, fqdn+"/TaskClient.Add")
61		defer func() {
62			sc := -1
63			if result.Response != nil {
64				sc = result.Response.StatusCode
65			}
66			tracing.EndSpan(ctx, sc, err)
67		}()
68	}
69	if err := validation.Validate([]validation.Validation{
70		{TargetValue: task,
71			Constraints: []validation.Constraint{{Target: "task.ID", Name: validation.Null, Rule: true, Chain: nil},
72				{Target: "task.CommandLine", Name: validation.Null, Rule: true, Chain: nil},
73				{Target: "task.AffinityInfo", Name: validation.Null, Rule: false,
74					Chain: []validation.Constraint{{Target: "task.AffinityInfo.AffinityID", Name: validation.Null, Rule: true, Chain: nil}}},
75				{Target: "task.MultiInstanceSettings", Name: validation.Null, Rule: false,
76					Chain: []validation.Constraint{{Target: "task.MultiInstanceSettings.NumberOfInstances", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
77		return result, validation.NewError("batch.TaskClient", "Add", err.Error())
78	}
79
80	req, err := client.AddPreparer(ctx, jobID, task, timeout, clientRequestID, returnClientRequestID, ocpDate)
81	if err != nil {
82		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Add", nil, "Failure preparing request")
83		return
84	}
85
86	resp, err := client.AddSender(req)
87	if err != nil {
88		result.Response = resp
89		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Add", resp, "Failure sending request")
90		return
91	}
92
93	result, err = client.AddResponder(resp)
94	if err != nil {
95		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Add", resp, "Failure responding to request")
96		return
97	}
98
99	return
100}
101
102// AddPreparer prepares the Add request.
103func (client TaskClient) AddPreparer(ctx context.Context, jobID string, task TaskAddParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
104	pathParameters := map[string]interface{}{
105		"jobId": autorest.Encode("path", jobID),
106	}
107
108	const APIVersion = "2017-05-01.5.0"
109	queryParameters := map[string]interface{}{
110		"api-version": APIVersion,
111	}
112	if timeout != nil {
113		queryParameters["timeout"] = autorest.Encode("query", *timeout)
114	} else {
115		queryParameters["timeout"] = autorest.Encode("query", 30)
116	}
117
118	preparer := autorest.CreatePreparer(
119		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
120		autorest.AsPost(),
121		autorest.WithBaseURL(client.BaseURI),
122		autorest.WithPathParameters("/jobs/{jobId}/tasks", pathParameters),
123		autorest.WithJSON(task),
124		autorest.WithQueryParameters(queryParameters))
125	if clientRequestID != nil {
126		preparer = autorest.DecoratePreparer(preparer,
127			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
128	}
129	if returnClientRequestID != nil {
130		preparer = autorest.DecoratePreparer(preparer,
131			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
132	} else {
133		preparer = autorest.DecoratePreparer(preparer,
134			autorest.WithHeader("return-client-request-id", autorest.String(false)))
135	}
136	if ocpDate != nil {
137		preparer = autorest.DecoratePreparer(preparer,
138			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
139	}
140	return preparer.Prepare((&http.Request{}).WithContext(ctx))
141}
142
143// AddSender sends the Add request. The method will close the
144// http.Response Body if it receives an error.
145func (client TaskClient) AddSender(req *http.Request) (*http.Response, error) {
146	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
147}
148
149// AddResponder handles the response to the Add request. The method always
150// closes the http.Response Body.
151func (client TaskClient) AddResponder(resp *http.Response) (result autorest.Response, err error) {
152	err = autorest.Respond(
153		resp,
154		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
155		autorest.ByClosing())
156	result.Response = resp
157	return
158}
159
160// AddCollection note that each task must have a unique ID. The Batch service may not return the results for each task
161// in the same order the tasks were submitted in this request. If the server times out or the connection is closed
162// during the request, the request may have been partially or fully processed, or not at all. In such cases, the user
163// should re-issue the request. Note that it is up to the user to correctly handle failures when re-issuing a request.
164// For example, you should use the same task ids during a retry so that if the prior operation succeeded, the retry
165// will not create extra tasks unexpectedly.
166// Parameters:
167// jobID - the ID of the job to which the task collection is to be added.
168// taskCollection - the tasks to be added.
169// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
170// seconds.
171// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
172// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
173// returnClientRequestID - whether the server should return the client-request-id in the response.
174// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
175// time; set it explicitly if you are calling the REST API directly.
176func (client TaskClient) AddCollection(ctx context.Context, jobID string, taskCollection TaskAddCollectionParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result TaskAddCollectionResult, err error) {
177	if tracing.IsEnabled() {
178		ctx = tracing.StartSpan(ctx, fqdn+"/TaskClient.AddCollection")
179		defer func() {
180			sc := -1
181			if result.Response.Response != nil {
182				sc = result.Response.Response.StatusCode
183			}
184			tracing.EndSpan(ctx, sc, err)
185		}()
186	}
187	if err := validation.Validate([]validation.Validation{
188		{TargetValue: taskCollection,
189			Constraints: []validation.Constraint{{Target: "taskCollection.Value", Name: validation.Null, Rule: true,
190				Chain: []validation.Constraint{{Target: "taskCollection.Value", Name: validation.MaxItems, Rule: 100, Chain: nil}}}}}}); err != nil {
191		return result, validation.NewError("batch.TaskClient", "AddCollection", err.Error())
192	}
193
194	req, err := client.AddCollectionPreparer(ctx, jobID, taskCollection, timeout, clientRequestID, returnClientRequestID, ocpDate)
195	if err != nil {
196		err = autorest.NewErrorWithError(err, "batch.TaskClient", "AddCollection", nil, "Failure preparing request")
197		return
198	}
199
200	resp, err := client.AddCollectionSender(req)
201	if err != nil {
202		result.Response = autorest.Response{Response: resp}
203		err = autorest.NewErrorWithError(err, "batch.TaskClient", "AddCollection", resp, "Failure sending request")
204		return
205	}
206
207	result, err = client.AddCollectionResponder(resp)
208	if err != nil {
209		err = autorest.NewErrorWithError(err, "batch.TaskClient", "AddCollection", resp, "Failure responding to request")
210		return
211	}
212
213	return
214}
215
216// AddCollectionPreparer prepares the AddCollection request.
217func (client TaskClient) AddCollectionPreparer(ctx context.Context, jobID string, taskCollection TaskAddCollectionParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
218	pathParameters := map[string]interface{}{
219		"jobId": autorest.Encode("path", jobID),
220	}
221
222	const APIVersion = "2017-05-01.5.0"
223	queryParameters := map[string]interface{}{
224		"api-version": APIVersion,
225	}
226	if timeout != nil {
227		queryParameters["timeout"] = autorest.Encode("query", *timeout)
228	} else {
229		queryParameters["timeout"] = autorest.Encode("query", 30)
230	}
231
232	preparer := autorest.CreatePreparer(
233		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
234		autorest.AsPost(),
235		autorest.WithBaseURL(client.BaseURI),
236		autorest.WithPathParameters("/jobs/{jobId}/addtaskcollection", pathParameters),
237		autorest.WithJSON(taskCollection),
238		autorest.WithQueryParameters(queryParameters))
239	if clientRequestID != nil {
240		preparer = autorest.DecoratePreparer(preparer,
241			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
242	}
243	if returnClientRequestID != nil {
244		preparer = autorest.DecoratePreparer(preparer,
245			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
246	} else {
247		preparer = autorest.DecoratePreparer(preparer,
248			autorest.WithHeader("return-client-request-id", autorest.String(false)))
249	}
250	if ocpDate != nil {
251		preparer = autorest.DecoratePreparer(preparer,
252			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
253	}
254	return preparer.Prepare((&http.Request{}).WithContext(ctx))
255}
256
257// AddCollectionSender sends the AddCollection request. The method will close the
258// http.Response Body if it receives an error.
259func (client TaskClient) AddCollectionSender(req *http.Request) (*http.Response, error) {
260	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
261}
262
263// AddCollectionResponder handles the response to the AddCollection request. The method always
264// closes the http.Response Body.
265func (client TaskClient) AddCollectionResponder(resp *http.Response) (result TaskAddCollectionResult, err error) {
266	err = autorest.Respond(
267		resp,
268		azure.WithErrorUnlessStatusCode(http.StatusOK),
269		autorest.ByUnmarshallingJSON(&result),
270		autorest.ByClosing())
271	result.Response = autorest.Response{Response: resp}
272	return
273}
274
275// Delete when a task is deleted, all of the files in its directory on the compute node where it ran are also deleted
276// (regardless of the retention time). For multi-instance tasks, the delete task operation applies synchronously to the
277// primary task; subtasks and their files are then deleted asynchronously in the background.
278// Parameters:
279// jobID - the ID of the job from which to delete the task.
280// taskID - the ID of the task to delete.
281// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
282// seconds.
283// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
284// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
285// returnClientRequestID - whether the server should return the client-request-id in the response.
286// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
287// time; set it explicitly if you are calling the REST API directly.
288// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
289// be performed only if the resource's current ETag on the service exactly matches the value specified by the
290// client.
291// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
292// will be performed only if the resource's current ETag on the service does not match the value specified by
293// the client.
294// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
295// operation will be performed only if the resource on the service has been modified since the specified time.
296// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
297// operation will be performed only if the resource on the service has not been modified since the specified
298// time.
299func (client TaskClient) Delete(ctx context.Context, jobID string, taskID 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) {
300	if tracing.IsEnabled() {
301		ctx = tracing.StartSpan(ctx, fqdn+"/TaskClient.Delete")
302		defer func() {
303			sc := -1
304			if result.Response != nil {
305				sc = result.Response.StatusCode
306			}
307			tracing.EndSpan(ctx, sc, err)
308		}()
309	}
310	req, err := client.DeletePreparer(ctx, jobID, taskID, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
311	if err != nil {
312		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Delete", nil, "Failure preparing request")
313		return
314	}
315
316	resp, err := client.DeleteSender(req)
317	if err != nil {
318		result.Response = resp
319		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Delete", resp, "Failure sending request")
320		return
321	}
322
323	result, err = client.DeleteResponder(resp)
324	if err != nil {
325		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Delete", resp, "Failure responding to request")
326		return
327	}
328
329	return
330}
331
332// DeletePreparer prepares the Delete request.
333func (client TaskClient) DeletePreparer(ctx context.Context, jobID string, taskID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
334	pathParameters := map[string]interface{}{
335		"jobId":  autorest.Encode("path", jobID),
336		"taskId": autorest.Encode("path", taskID),
337	}
338
339	const APIVersion = "2017-05-01.5.0"
340	queryParameters := map[string]interface{}{
341		"api-version": APIVersion,
342	}
343	if timeout != nil {
344		queryParameters["timeout"] = autorest.Encode("query", *timeout)
345	} else {
346		queryParameters["timeout"] = autorest.Encode("query", 30)
347	}
348
349	preparer := autorest.CreatePreparer(
350		autorest.AsDelete(),
351		autorest.WithBaseURL(client.BaseURI),
352		autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}", pathParameters),
353		autorest.WithQueryParameters(queryParameters))
354	if clientRequestID != nil {
355		preparer = autorest.DecoratePreparer(preparer,
356			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
357	}
358	if returnClientRequestID != nil {
359		preparer = autorest.DecoratePreparer(preparer,
360			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
361	} else {
362		preparer = autorest.DecoratePreparer(preparer,
363			autorest.WithHeader("return-client-request-id", autorest.String(false)))
364	}
365	if ocpDate != nil {
366		preparer = autorest.DecoratePreparer(preparer,
367			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
368	}
369	if len(ifMatch) > 0 {
370		preparer = autorest.DecoratePreparer(preparer,
371			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
372	}
373	if len(ifNoneMatch) > 0 {
374		preparer = autorest.DecoratePreparer(preparer,
375			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
376	}
377	if ifModifiedSince != nil {
378		preparer = autorest.DecoratePreparer(preparer,
379			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
380	}
381	if ifUnmodifiedSince != nil {
382		preparer = autorest.DecoratePreparer(preparer,
383			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
384	}
385	return preparer.Prepare((&http.Request{}).WithContext(ctx))
386}
387
388// DeleteSender sends the Delete request. The method will close the
389// http.Response Body if it receives an error.
390func (client TaskClient) DeleteSender(req *http.Request) (*http.Response, error) {
391	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
392}
393
394// DeleteResponder handles the response to the Delete request. The method always
395// closes the http.Response Body.
396func (client TaskClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
397	err = autorest.Respond(
398		resp,
399		azure.WithErrorUnlessStatusCode(http.StatusOK),
400		autorest.ByClosing())
401	result.Response = resp
402	return
403}
404
405// Get for multi-instance tasks, information such as affinityId, executionInfo and nodeInfo refer to the primary task.
406// Use the list subtasks API to retrieve information about subtasks.
407// Parameters:
408// jobID - the ID of the job that contains the task.
409// taskID - the ID of the task to get information about.
410// selectParameter - an OData $select clause.
411// expand - an OData $expand clause.
412// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
413// seconds.
414// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
415// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
416// returnClientRequestID - whether the server should return the client-request-id in the response.
417// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
418// time; set it explicitly if you are calling the REST API directly.
419// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
420// be performed only if the resource's current ETag on the service exactly matches the value specified by the
421// client.
422// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
423// will be performed only if the resource's current ETag on the service does not match the value specified by
424// the client.
425// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
426// operation will be performed only if the resource on the service has been modified since the specified time.
427// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
428// operation will be performed only if the resource on the service has not been modified since the specified
429// time.
430func (client TaskClient) Get(ctx context.Context, jobID string, taskID 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 CloudTask, err error) {
431	if tracing.IsEnabled() {
432		ctx = tracing.StartSpan(ctx, fqdn+"/TaskClient.Get")
433		defer func() {
434			sc := -1
435			if result.Response.Response != nil {
436				sc = result.Response.Response.StatusCode
437			}
438			tracing.EndSpan(ctx, sc, err)
439		}()
440	}
441	req, err := client.GetPreparer(ctx, jobID, taskID, selectParameter, expand, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
442	if err != nil {
443		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Get", nil, "Failure preparing request")
444		return
445	}
446
447	resp, err := client.GetSender(req)
448	if err != nil {
449		result.Response = autorest.Response{Response: resp}
450		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Get", resp, "Failure sending request")
451		return
452	}
453
454	result, err = client.GetResponder(resp)
455	if err != nil {
456		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Get", resp, "Failure responding to request")
457		return
458	}
459
460	return
461}
462
463// GetPreparer prepares the Get request.
464func (client TaskClient) GetPreparer(ctx context.Context, jobID string, taskID 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) {
465	pathParameters := map[string]interface{}{
466		"jobId":  autorest.Encode("path", jobID),
467		"taskId": autorest.Encode("path", taskID),
468	}
469
470	const APIVersion = "2017-05-01.5.0"
471	queryParameters := map[string]interface{}{
472		"api-version": APIVersion,
473	}
474	if len(selectParameter) > 0 {
475		queryParameters["$select"] = autorest.Encode("query", selectParameter)
476	}
477	if len(expand) > 0 {
478		queryParameters["$expand"] = autorest.Encode("query", expand)
479	}
480	if timeout != nil {
481		queryParameters["timeout"] = autorest.Encode("query", *timeout)
482	} else {
483		queryParameters["timeout"] = autorest.Encode("query", 30)
484	}
485
486	preparer := autorest.CreatePreparer(
487		autorest.AsGet(),
488		autorest.WithBaseURL(client.BaseURI),
489		autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}", pathParameters),
490		autorest.WithQueryParameters(queryParameters))
491	if clientRequestID != nil {
492		preparer = autorest.DecoratePreparer(preparer,
493			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
494	}
495	if returnClientRequestID != nil {
496		preparer = autorest.DecoratePreparer(preparer,
497			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
498	} else {
499		preparer = autorest.DecoratePreparer(preparer,
500			autorest.WithHeader("return-client-request-id", autorest.String(false)))
501	}
502	if ocpDate != nil {
503		preparer = autorest.DecoratePreparer(preparer,
504			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
505	}
506	if len(ifMatch) > 0 {
507		preparer = autorest.DecoratePreparer(preparer,
508			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
509	}
510	if len(ifNoneMatch) > 0 {
511		preparer = autorest.DecoratePreparer(preparer,
512			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
513	}
514	if ifModifiedSince != nil {
515		preparer = autorest.DecoratePreparer(preparer,
516			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
517	}
518	if ifUnmodifiedSince != nil {
519		preparer = autorest.DecoratePreparer(preparer,
520			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
521	}
522	return preparer.Prepare((&http.Request{}).WithContext(ctx))
523}
524
525// GetSender sends the Get request. The method will close the
526// http.Response Body if it receives an error.
527func (client TaskClient) GetSender(req *http.Request) (*http.Response, error) {
528	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
529}
530
531// GetResponder handles the response to the Get request. The method always
532// closes the http.Response Body.
533func (client TaskClient) GetResponder(resp *http.Response) (result CloudTask, err error) {
534	err = autorest.Respond(
535		resp,
536		azure.WithErrorUnlessStatusCode(http.StatusOK),
537		autorest.ByUnmarshallingJSON(&result),
538		autorest.ByClosing())
539	result.Response = autorest.Response{Response: resp}
540	return
541}
542
543// List for multi-instance tasks, information such as affinityId, executionInfo and nodeInfo refer to the primary task.
544// Use the list subtasks API to retrieve information about subtasks.
545// Parameters:
546// jobID - the ID of the job.
547// filter - an OData $filter clause.
548// selectParameter - an OData $select clause.
549// expand - an OData $expand clause.
550// maxResults - the maximum number of items to return in the response. A maximum of 1000 tasks can be returned.
551// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
552// seconds.
553// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
554// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
555// returnClientRequestID - whether the server should return the client-request-id in the response.
556// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
557// time; set it explicitly if you are calling the REST API directly.
558func (client TaskClient) List(ctx context.Context, jobID string, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudTaskListResultPage, err error) {
559	if tracing.IsEnabled() {
560		ctx = tracing.StartSpan(ctx, fqdn+"/TaskClient.List")
561		defer func() {
562			sc := -1
563			if result.ctlr.Response.Response != nil {
564				sc = result.ctlr.Response.Response.StatusCode
565			}
566			tracing.EndSpan(ctx, sc, err)
567		}()
568	}
569	if err := validation.Validate([]validation.Validation{
570		{TargetValue: maxResults,
571			Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
572				Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
573					{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
574				}}}}}); err != nil {
575		return result, validation.NewError("batch.TaskClient", "List", err.Error())
576	}
577
578	result.fn = client.listNextResults
579	req, err := client.ListPreparer(ctx, jobID, filter, selectParameter, expand, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
580	if err != nil {
581		err = autorest.NewErrorWithError(err, "batch.TaskClient", "List", nil, "Failure preparing request")
582		return
583	}
584
585	resp, err := client.ListSender(req)
586	if err != nil {
587		result.ctlr.Response = autorest.Response{Response: resp}
588		err = autorest.NewErrorWithError(err, "batch.TaskClient", "List", resp, "Failure sending request")
589		return
590	}
591
592	result.ctlr, err = client.ListResponder(resp)
593	if err != nil {
594		err = autorest.NewErrorWithError(err, "batch.TaskClient", "List", resp, "Failure responding to request")
595		return
596	}
597	if result.ctlr.hasNextLink() && result.ctlr.IsEmpty() {
598		err = result.NextWithContext(ctx)
599		return
600	}
601
602	return
603}
604
605// ListPreparer prepares the List request.
606func (client TaskClient) ListPreparer(ctx context.Context, jobID string, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
607	pathParameters := map[string]interface{}{
608		"jobId": autorest.Encode("path", jobID),
609	}
610
611	const APIVersion = "2017-05-01.5.0"
612	queryParameters := map[string]interface{}{
613		"api-version": APIVersion,
614	}
615	if len(filter) > 0 {
616		queryParameters["$filter"] = autorest.Encode("query", filter)
617	}
618	if len(selectParameter) > 0 {
619		queryParameters["$select"] = autorest.Encode("query", selectParameter)
620	}
621	if len(expand) > 0 {
622		queryParameters["$expand"] = autorest.Encode("query", expand)
623	}
624	if maxResults != nil {
625		queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
626	} else {
627		queryParameters["maxresults"] = autorest.Encode("query", 1000)
628	}
629	if timeout != nil {
630		queryParameters["timeout"] = autorest.Encode("query", *timeout)
631	} else {
632		queryParameters["timeout"] = autorest.Encode("query", 30)
633	}
634
635	preparer := autorest.CreatePreparer(
636		autorest.AsGet(),
637		autorest.WithBaseURL(client.BaseURI),
638		autorest.WithPathParameters("/jobs/{jobId}/tasks", pathParameters),
639		autorest.WithQueryParameters(queryParameters))
640	if clientRequestID != nil {
641		preparer = autorest.DecoratePreparer(preparer,
642			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
643	}
644	if returnClientRequestID != nil {
645		preparer = autorest.DecoratePreparer(preparer,
646			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
647	} else {
648		preparer = autorest.DecoratePreparer(preparer,
649			autorest.WithHeader("return-client-request-id", autorest.String(false)))
650	}
651	if ocpDate != nil {
652		preparer = autorest.DecoratePreparer(preparer,
653			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
654	}
655	return preparer.Prepare((&http.Request{}).WithContext(ctx))
656}
657
658// ListSender sends the List request. The method will close the
659// http.Response Body if it receives an error.
660func (client TaskClient) ListSender(req *http.Request) (*http.Response, error) {
661	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
662}
663
664// ListResponder handles the response to the List request. The method always
665// closes the http.Response Body.
666func (client TaskClient) ListResponder(resp *http.Response) (result CloudTaskListResult, err error) {
667	err = autorest.Respond(
668		resp,
669		azure.WithErrorUnlessStatusCode(http.StatusOK),
670		autorest.ByUnmarshallingJSON(&result),
671		autorest.ByClosing())
672	result.Response = autorest.Response{Response: resp}
673	return
674}
675
676// listNextResults retrieves the next set of results, if any.
677func (client TaskClient) listNextResults(ctx context.Context, lastResults CloudTaskListResult) (result CloudTaskListResult, err error) {
678	req, err := lastResults.cloudTaskListResultPreparer(ctx)
679	if err != nil {
680		return result, autorest.NewErrorWithError(err, "batch.TaskClient", "listNextResults", nil, "Failure preparing next results request")
681	}
682	if req == nil {
683		return
684	}
685	resp, err := client.ListSender(req)
686	if err != nil {
687		result.Response = autorest.Response{Response: resp}
688		return result, autorest.NewErrorWithError(err, "batch.TaskClient", "listNextResults", resp, "Failure sending next results request")
689	}
690	result, err = client.ListResponder(resp)
691	if err != nil {
692		err = autorest.NewErrorWithError(err, "batch.TaskClient", "listNextResults", resp, "Failure responding to next results request")
693	}
694	return
695}
696
697// ListComplete enumerates all values, automatically crossing page boundaries as required.
698func (client TaskClient) ListComplete(ctx context.Context, jobID string, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudTaskListResultIterator, err error) {
699	if tracing.IsEnabled() {
700		ctx = tracing.StartSpan(ctx, fqdn+"/TaskClient.List")
701		defer func() {
702			sc := -1
703			if result.Response().Response.Response != nil {
704				sc = result.page.Response().Response.Response.StatusCode
705			}
706			tracing.EndSpan(ctx, sc, err)
707		}()
708	}
709	result.page, err = client.List(ctx, jobID, filter, selectParameter, expand, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
710	return
711}
712
713// ListSubtasks if the task is not a multi-instance task then this returns an empty collection.
714// Parameters:
715// jobID - the ID of the job.
716// taskID - the ID of the task.
717// selectParameter - an OData $select clause.
718// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
719// seconds.
720// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
721// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
722// returnClientRequestID - whether the server should return the client-request-id in the response.
723// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
724// time; set it explicitly if you are calling the REST API directly.
725func (client TaskClient) ListSubtasks(ctx context.Context, jobID string, taskID string, selectParameter string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudTaskListSubtasksResult, err error) {
726	if tracing.IsEnabled() {
727		ctx = tracing.StartSpan(ctx, fqdn+"/TaskClient.ListSubtasks")
728		defer func() {
729			sc := -1
730			if result.Response.Response != nil {
731				sc = result.Response.Response.StatusCode
732			}
733			tracing.EndSpan(ctx, sc, err)
734		}()
735	}
736	req, err := client.ListSubtasksPreparer(ctx, jobID, taskID, selectParameter, timeout, clientRequestID, returnClientRequestID, ocpDate)
737	if err != nil {
738		err = autorest.NewErrorWithError(err, "batch.TaskClient", "ListSubtasks", nil, "Failure preparing request")
739		return
740	}
741
742	resp, err := client.ListSubtasksSender(req)
743	if err != nil {
744		result.Response = autorest.Response{Response: resp}
745		err = autorest.NewErrorWithError(err, "batch.TaskClient", "ListSubtasks", resp, "Failure sending request")
746		return
747	}
748
749	result, err = client.ListSubtasksResponder(resp)
750	if err != nil {
751		err = autorest.NewErrorWithError(err, "batch.TaskClient", "ListSubtasks", resp, "Failure responding to request")
752		return
753	}
754
755	return
756}
757
758// ListSubtasksPreparer prepares the ListSubtasks request.
759func (client TaskClient) ListSubtasksPreparer(ctx context.Context, jobID string, taskID string, selectParameter string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
760	pathParameters := map[string]interface{}{
761		"jobId":  autorest.Encode("path", jobID),
762		"taskId": autorest.Encode("path", taskID),
763	}
764
765	const APIVersion = "2017-05-01.5.0"
766	queryParameters := map[string]interface{}{
767		"api-version": APIVersion,
768	}
769	if len(selectParameter) > 0 {
770		queryParameters["$select"] = autorest.Encode("query", selectParameter)
771	}
772	if timeout != nil {
773		queryParameters["timeout"] = autorest.Encode("query", *timeout)
774	} else {
775		queryParameters["timeout"] = autorest.Encode("query", 30)
776	}
777
778	preparer := autorest.CreatePreparer(
779		autorest.AsGet(),
780		autorest.WithBaseURL(client.BaseURI),
781		autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/subtasksinfo", pathParameters),
782		autorest.WithQueryParameters(queryParameters))
783	if clientRequestID != nil {
784		preparer = autorest.DecoratePreparer(preparer,
785			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
786	}
787	if returnClientRequestID != nil {
788		preparer = autorest.DecoratePreparer(preparer,
789			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
790	} else {
791		preparer = autorest.DecoratePreparer(preparer,
792			autorest.WithHeader("return-client-request-id", autorest.String(false)))
793	}
794	if ocpDate != nil {
795		preparer = autorest.DecoratePreparer(preparer,
796			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
797	}
798	return preparer.Prepare((&http.Request{}).WithContext(ctx))
799}
800
801// ListSubtasksSender sends the ListSubtasks request. The method will close the
802// http.Response Body if it receives an error.
803func (client TaskClient) ListSubtasksSender(req *http.Request) (*http.Response, error) {
804	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
805}
806
807// ListSubtasksResponder handles the response to the ListSubtasks request. The method always
808// closes the http.Response Body.
809func (client TaskClient) ListSubtasksResponder(resp *http.Response) (result CloudTaskListSubtasksResult, err error) {
810	err = autorest.Respond(
811		resp,
812		azure.WithErrorUnlessStatusCode(http.StatusOK),
813		autorest.ByUnmarshallingJSON(&result),
814		autorest.ByClosing())
815	result.Response = autorest.Response{Response: resp}
816	return
817}
818
819// Reactivate reactivation makes a task eligible to be retried again up to its maximum retry count. The task's state is
820// changed to active. As the task is no longer in the completed state, any previous exit code or scheduling error is no
821// longer available after reactivation. This will fail for tasks that are not completed or that previously completed
822// successfully (with an exit code of 0). Additionally, this will fail if the job has completed (or is terminating or
823// deleting).
824// Parameters:
825// jobID - the ID of the job containing the task.
826// taskID - the ID of the task to reactivate.
827// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
828// seconds.
829// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
830// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
831// returnClientRequestID - whether the server should return the client-request-id in the response.
832// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
833// time; set it explicitly if you are calling the REST API directly.
834// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
835// be performed only if the resource's current ETag on the service exactly matches the value specified by the
836// client.
837// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
838// will be performed only if the resource's current ETag on the service does not match the value specified by
839// the client.
840// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
841// operation will be performed only if the resource on the service has been modified since the specified time.
842// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
843// operation will be performed only if the resource on the service has not been modified since the specified
844// time.
845func (client TaskClient) Reactivate(ctx context.Context, jobID string, taskID 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) {
846	if tracing.IsEnabled() {
847		ctx = tracing.StartSpan(ctx, fqdn+"/TaskClient.Reactivate")
848		defer func() {
849			sc := -1
850			if result.Response != nil {
851				sc = result.Response.StatusCode
852			}
853			tracing.EndSpan(ctx, sc, err)
854		}()
855	}
856	req, err := client.ReactivatePreparer(ctx, jobID, taskID, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
857	if err != nil {
858		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Reactivate", nil, "Failure preparing request")
859		return
860	}
861
862	resp, err := client.ReactivateSender(req)
863	if err != nil {
864		result.Response = resp
865		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Reactivate", resp, "Failure sending request")
866		return
867	}
868
869	result, err = client.ReactivateResponder(resp)
870	if err != nil {
871		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Reactivate", resp, "Failure responding to request")
872		return
873	}
874
875	return
876}
877
878// ReactivatePreparer prepares the Reactivate request.
879func (client TaskClient) ReactivatePreparer(ctx context.Context, jobID string, taskID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
880	pathParameters := map[string]interface{}{
881		"jobId":  autorest.Encode("path", jobID),
882		"taskId": autorest.Encode("path", taskID),
883	}
884
885	const APIVersion = "2017-05-01.5.0"
886	queryParameters := map[string]interface{}{
887		"api-version": APIVersion,
888	}
889	if timeout != nil {
890		queryParameters["timeout"] = autorest.Encode("query", *timeout)
891	} else {
892		queryParameters["timeout"] = autorest.Encode("query", 30)
893	}
894
895	preparer := autorest.CreatePreparer(
896		autorest.AsPost(),
897		autorest.WithBaseURL(client.BaseURI),
898		autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/reactivate", pathParameters),
899		autorest.WithQueryParameters(queryParameters))
900	if clientRequestID != nil {
901		preparer = autorest.DecoratePreparer(preparer,
902			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
903	}
904	if returnClientRequestID != nil {
905		preparer = autorest.DecoratePreparer(preparer,
906			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
907	} else {
908		preparer = autorest.DecoratePreparer(preparer,
909			autorest.WithHeader("return-client-request-id", autorest.String(false)))
910	}
911	if ocpDate != nil {
912		preparer = autorest.DecoratePreparer(preparer,
913			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
914	}
915	if len(ifMatch) > 0 {
916		preparer = autorest.DecoratePreparer(preparer,
917			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
918	}
919	if len(ifNoneMatch) > 0 {
920		preparer = autorest.DecoratePreparer(preparer,
921			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
922	}
923	if ifModifiedSince != nil {
924		preparer = autorest.DecoratePreparer(preparer,
925			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
926	}
927	if ifUnmodifiedSince != nil {
928		preparer = autorest.DecoratePreparer(preparer,
929			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
930	}
931	return preparer.Prepare((&http.Request{}).WithContext(ctx))
932}
933
934// ReactivateSender sends the Reactivate request. The method will close the
935// http.Response Body if it receives an error.
936func (client TaskClient) ReactivateSender(req *http.Request) (*http.Response, error) {
937	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
938}
939
940// ReactivateResponder handles the response to the Reactivate request. The method always
941// closes the http.Response Body.
942func (client TaskClient) ReactivateResponder(resp *http.Response) (result autorest.Response, err error) {
943	err = autorest.Respond(
944		resp,
945		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
946		autorest.ByClosing())
947	result.Response = resp
948	return
949}
950
951// Terminate when the task has been terminated, it moves to the completed state. For multi-instance tasks, the
952// terminate task operation applies synchronously to the primary task; subtasks are then terminated asynchronously in
953// the background.
954// Parameters:
955// jobID - the ID of the job containing the task.
956// taskID - the ID of the task to terminate.
957// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
958// seconds.
959// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
960// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
961// returnClientRequestID - whether the server should return the client-request-id in the response.
962// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
963// time; set it explicitly if you are calling the REST API directly.
964// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
965// be performed only if the resource's current ETag on the service exactly matches the value specified by the
966// client.
967// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
968// will be performed only if the resource's current ETag on the service does not match the value specified by
969// the client.
970// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
971// operation will be performed only if the resource on the service has been modified since the specified time.
972// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
973// operation will be performed only if the resource on the service has not been modified since the specified
974// time.
975func (client TaskClient) Terminate(ctx context.Context, jobID string, taskID 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) {
976	if tracing.IsEnabled() {
977		ctx = tracing.StartSpan(ctx, fqdn+"/TaskClient.Terminate")
978		defer func() {
979			sc := -1
980			if result.Response != nil {
981				sc = result.Response.StatusCode
982			}
983			tracing.EndSpan(ctx, sc, err)
984		}()
985	}
986	req, err := client.TerminatePreparer(ctx, jobID, taskID, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
987	if err != nil {
988		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Terminate", nil, "Failure preparing request")
989		return
990	}
991
992	resp, err := client.TerminateSender(req)
993	if err != nil {
994		result.Response = resp
995		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Terminate", resp, "Failure sending request")
996		return
997	}
998
999	result, err = client.TerminateResponder(resp)
1000	if err != nil {
1001		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Terminate", resp, "Failure responding to request")
1002		return
1003	}
1004
1005	return
1006}
1007
1008// TerminatePreparer prepares the Terminate request.
1009func (client TaskClient) TerminatePreparer(ctx context.Context, jobID string, taskID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
1010	pathParameters := map[string]interface{}{
1011		"jobId":  autorest.Encode("path", jobID),
1012		"taskId": autorest.Encode("path", taskID),
1013	}
1014
1015	const APIVersion = "2017-05-01.5.0"
1016	queryParameters := map[string]interface{}{
1017		"api-version": APIVersion,
1018	}
1019	if timeout != nil {
1020		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1021	} else {
1022		queryParameters["timeout"] = autorest.Encode("query", 30)
1023	}
1024
1025	preparer := autorest.CreatePreparer(
1026		autorest.AsPost(),
1027		autorest.WithBaseURL(client.BaseURI),
1028		autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/terminate", pathParameters),
1029		autorest.WithQueryParameters(queryParameters))
1030	if clientRequestID != nil {
1031		preparer = autorest.DecoratePreparer(preparer,
1032			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1033	}
1034	if returnClientRequestID != nil {
1035		preparer = autorest.DecoratePreparer(preparer,
1036			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1037	} else {
1038		preparer = autorest.DecoratePreparer(preparer,
1039			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1040	}
1041	if ocpDate != nil {
1042		preparer = autorest.DecoratePreparer(preparer,
1043			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1044	}
1045	if len(ifMatch) > 0 {
1046		preparer = autorest.DecoratePreparer(preparer,
1047			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
1048	}
1049	if len(ifNoneMatch) > 0 {
1050		preparer = autorest.DecoratePreparer(preparer,
1051			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
1052	}
1053	if ifModifiedSince != nil {
1054		preparer = autorest.DecoratePreparer(preparer,
1055			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
1056	}
1057	if ifUnmodifiedSince != nil {
1058		preparer = autorest.DecoratePreparer(preparer,
1059			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
1060	}
1061	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1062}
1063
1064// TerminateSender sends the Terminate request. The method will close the
1065// http.Response Body if it receives an error.
1066func (client TaskClient) TerminateSender(req *http.Request) (*http.Response, error) {
1067	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1068}
1069
1070// TerminateResponder handles the response to the Terminate request. The method always
1071// closes the http.Response Body.
1072func (client TaskClient) TerminateResponder(resp *http.Response) (result autorest.Response, err error) {
1073	err = autorest.Respond(
1074		resp,
1075		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
1076		autorest.ByClosing())
1077	result.Response = resp
1078	return
1079}
1080
1081// Update updates the properties of the specified task.
1082// Parameters:
1083// jobID - the ID of the job containing the task.
1084// taskID - the ID of the task to update.
1085// taskUpdateParameter - the parameters for the request.
1086// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
1087// seconds.
1088// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
1089// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
1090// returnClientRequestID - whether the server should return the client-request-id in the response.
1091// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
1092// time; set it explicitly if you are calling the REST API directly.
1093// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will
1094// be performed only if the resource's current ETag on the service exactly matches the value specified by the
1095// client.
1096// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation
1097// will be performed only if the resource's current ETag on the service does not match the value specified by
1098// the client.
1099// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
1100// operation will be performed only if the resource on the service has been modified since the specified time.
1101// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The
1102// operation will be performed only if the resource on the service has not been modified since the specified
1103// time.
1104func (client TaskClient) Update(ctx context.Context, jobID string, taskID string, taskUpdateParameter TaskUpdateParameter, 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) {
1105	if tracing.IsEnabled() {
1106		ctx = tracing.StartSpan(ctx, fqdn+"/TaskClient.Update")
1107		defer func() {
1108			sc := -1
1109			if result.Response != nil {
1110				sc = result.Response.StatusCode
1111			}
1112			tracing.EndSpan(ctx, sc, err)
1113		}()
1114	}
1115	req, err := client.UpdatePreparer(ctx, jobID, taskID, taskUpdateParameter, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince)
1116	if err != nil {
1117		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Update", nil, "Failure preparing request")
1118		return
1119	}
1120
1121	resp, err := client.UpdateSender(req)
1122	if err != nil {
1123		result.Response = resp
1124		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Update", resp, "Failure sending request")
1125		return
1126	}
1127
1128	result, err = client.UpdateResponder(resp)
1129	if err != nil {
1130		err = autorest.NewErrorWithError(err, "batch.TaskClient", "Update", resp, "Failure responding to request")
1131		return
1132	}
1133
1134	return
1135}
1136
1137// UpdatePreparer prepares the Update request.
1138func (client TaskClient) UpdatePreparer(ctx context.Context, jobID string, taskID string, taskUpdateParameter TaskUpdateParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
1139	pathParameters := map[string]interface{}{
1140		"jobId":  autorest.Encode("path", jobID),
1141		"taskId": autorest.Encode("path", taskID),
1142	}
1143
1144	const APIVersion = "2017-05-01.5.0"
1145	queryParameters := map[string]interface{}{
1146		"api-version": APIVersion,
1147	}
1148	if timeout != nil {
1149		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1150	} else {
1151		queryParameters["timeout"] = autorest.Encode("query", 30)
1152	}
1153
1154	preparer := autorest.CreatePreparer(
1155		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
1156		autorest.AsPut(),
1157		autorest.WithBaseURL(client.BaseURI),
1158		autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}", pathParameters),
1159		autorest.WithJSON(taskUpdateParameter),
1160		autorest.WithQueryParameters(queryParameters))
1161	if clientRequestID != nil {
1162		preparer = autorest.DecoratePreparer(preparer,
1163			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1164	}
1165	if returnClientRequestID != nil {
1166		preparer = autorest.DecoratePreparer(preparer,
1167			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1168	} else {
1169		preparer = autorest.DecoratePreparer(preparer,
1170			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1171	}
1172	if ocpDate != nil {
1173		preparer = autorest.DecoratePreparer(preparer,
1174			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1175	}
1176	if len(ifMatch) > 0 {
1177		preparer = autorest.DecoratePreparer(preparer,
1178			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
1179	}
1180	if len(ifNoneMatch) > 0 {
1181		preparer = autorest.DecoratePreparer(preparer,
1182			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
1183	}
1184	if ifModifiedSince != nil {
1185		preparer = autorest.DecoratePreparer(preparer,
1186			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
1187	}
1188	if ifUnmodifiedSince != nil {
1189		preparer = autorest.DecoratePreparer(preparer,
1190			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
1191	}
1192	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1193}
1194
1195// UpdateSender sends the Update request. The method will close the
1196// http.Response Body if it receives an error.
1197func (client TaskClient) UpdateSender(req *http.Request) (*http.Response, error) {
1198	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1199}
1200
1201// UpdateResponder handles the response to the Update request. The method always
1202// closes the http.Response Body.
1203func (client TaskClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
1204	err = autorest.Respond(
1205		resp,
1206		azure.WithErrorUnlessStatusCode(http.StatusOK),
1207		autorest.ByClosing())
1208	result.Response = resp
1209	return
1210}
1211