package batch

// Copyright (c) Microsoft and contributors.  All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

import (
	"context"
	"github.com/Azure/go-autorest/autorest"
	"github.com/Azure/go-autorest/autorest/azure"
	"github.com/Azure/go-autorest/autorest/date"
	"net/http"
)

// FileClient is the a client for issuing REST requests to the Azure Batch service.
type FileClient struct {
	BaseClient
}

// NewFileClient creates an instance of the FileClient client.
func NewFileClient() FileClient {
	return NewFileClientWithBaseURI(DefaultBaseURI)
}

// NewFileClientWithBaseURI creates an instance of the FileClient client.
func NewFileClientWithBaseURI(baseURI string) FileClient {
	return FileClient{NewWithBaseURI(baseURI)}
}

// DeleteFromComputeNode deletes the specified task file from the compute node.
//
// poolID is the id of the pool that contains the compute node. nodeID is the id of the compute node from which you
// want to delete the file. fileName is the path to the file that you want to delete. recursive is sets whether to
// delete children of a directory. If the fileName parameter represents a directory instead of a file, you can set
// Recursive to true to delete the directory and all of the files and subdirectories in it. If Recursive is false
// then the directory must be empty or deletion will fail. timeout is sets the maximum time that the server can
// spend processing the request, in seconds. The default is 30 seconds. clientRequestID is caller generated request
// identity, in the form of a GUID with no decoration such as curly braces e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the
// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this
// header will be automatically populated with the current system clock time.
func (client FileClient) DeleteFromComputeNode(ctx context.Context, poolID string, nodeID string, fileName string, recursive *bool, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
	req, err := client.DeleteFromComputeNodePreparer(ctx, poolID, nodeID, fileName, recursive, timeout, clientRequestID, returnClientRequestID, ocpDate)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromComputeNode", nil, "Failure preparing request")
		return
	}

	resp, err := client.DeleteFromComputeNodeSender(req)
	if err != nil {
		result.Response = resp
		err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromComputeNode", resp, "Failure sending request")
		return
	}

	result, err = client.DeleteFromComputeNodeResponder(resp)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromComputeNode", resp, "Failure responding to request")
	}

	return
}

// DeleteFromComputeNodePreparer prepares the DeleteFromComputeNode request.
func (client FileClient) DeleteFromComputeNodePreparer(ctx context.Context, poolID string, nodeID string, fileName string, recursive *bool, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
	pathParameters := map[string]interface{}{
		"fileName": autorest.Encode("path", fileName),
		"nodeId":   autorest.Encode("path", nodeID),
		"poolId":   autorest.Encode("path", poolID),
	}

	const APIVersion = "2015-12-01.2.2"
	queryParameters := map[string]interface{}{
		"api-version": APIVersion,
	}
	if recursive != nil {
		queryParameters["recursive"] = autorest.Encode("query", *recursive)
	}
	if timeout != nil {
		queryParameters["timeout"] = autorest.Encode("query", *timeout)
	} else {
		queryParameters["timeout"] = autorest.Encode("query", 30)
	}

	preparer := autorest.CreatePreparer(
		autorest.AsDelete(),
		autorest.WithBaseURL(client.BaseURI),
		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/files/{fileName}", pathParameters),
		autorest.WithQueryParameters(queryParameters))
	if len(clientRequestID) > 0 {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
	}
	if returnClientRequestID != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
	}
	if ocpDate != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
	}
	return preparer.Prepare((&http.Request{}).WithContext(ctx))
}

// DeleteFromComputeNodeSender sends the DeleteFromComputeNode request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) DeleteFromComputeNodeSender(req *http.Request) (*http.Response, error) {
	return autorest.SendWithSender(client, req,
		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}

// DeleteFromComputeNodeResponder handles the response to the DeleteFromComputeNode request. The method always
// closes the http.Response Body.
func (client FileClient) DeleteFromComputeNodeResponder(resp *http.Response) (result autorest.Response, err error) {
	err = autorest.Respond(
		resp,
		client.ByInspecting(),
		azure.WithErrorUnlessStatusCode(http.StatusOK),
		autorest.ByClosing())
	result.Response = resp
	return
}

// DeleteFromTask deletes the specified task file from the compute node where the task ran.
//
// jobID is the id of the job that contains the task. taskID is the id of the task whose file you want to delete.
// fileName is the path to the task file that you want to delete. recursive is sets whether to delete children of a
// directory. If the fileName parameter represents a directory instead of a file, you can set Recursive to true to
// delete the directory and all of the files and subdirectories in it. If Recursive is false then the directory
// must be empty or deletion will fail. timeout is sets the maximum time that the server can spend processing the
// request, in seconds. The default is 30 seconds. clientRequestID is caller generated request identity, in the
// form of a GUID with no decoration such as curly braces e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
// returnClientRequestID is specifies if the server should return the client-request-id identifier in the response.
// ocpDate is the time the request was issued. If not specified, this header will be automatically populated with
// the current system clock time.
func (client FileClient) DeleteFromTask(ctx context.Context, jobID string, taskID string, fileName string, recursive *bool, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
	req, err := client.DeleteFromTaskPreparer(ctx, jobID, taskID, fileName, recursive, timeout, clientRequestID, returnClientRequestID, ocpDate)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromTask", nil, "Failure preparing request")
		return
	}

	resp, err := client.DeleteFromTaskSender(req)
	if err != nil {
		result.Response = resp
		err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromTask", resp, "Failure sending request")
		return
	}

	result, err = client.DeleteFromTaskResponder(resp)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "DeleteFromTask", resp, "Failure responding to request")
	}

	return
}

// DeleteFromTaskPreparer prepares the DeleteFromTask request.
func (client FileClient) DeleteFromTaskPreparer(ctx context.Context, jobID string, taskID string, fileName string, recursive *bool, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
	pathParameters := map[string]interface{}{
		"fileName": autorest.Encode("path", fileName),
		"jobId":    autorest.Encode("path", jobID),
		"taskId":   autorest.Encode("path", taskID),
	}

	const APIVersion = "2015-12-01.2.2"
	queryParameters := map[string]interface{}{
		"api-version": APIVersion,
	}
	if recursive != nil {
		queryParameters["recursive"] = autorest.Encode("query", *recursive)
	}
	if timeout != nil {
		queryParameters["timeout"] = autorest.Encode("query", *timeout)
	} else {
		queryParameters["timeout"] = autorest.Encode("query", 30)
	}

	preparer := autorest.CreatePreparer(
		autorest.AsDelete(),
		autorest.WithBaseURL(client.BaseURI),
		autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/files/{fileName}", pathParameters),
		autorest.WithQueryParameters(queryParameters))
	if len(clientRequestID) > 0 {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
	}
	if returnClientRequestID != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
	}
	if ocpDate != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
	}
	return preparer.Prepare((&http.Request{}).WithContext(ctx))
}

// DeleteFromTaskSender sends the DeleteFromTask request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) DeleteFromTaskSender(req *http.Request) (*http.Response, error) {
	return autorest.SendWithSender(client, req,
		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}

// DeleteFromTaskResponder handles the response to the DeleteFromTask request. The method always
// closes the http.Response Body.
func (client FileClient) DeleteFromTaskResponder(resp *http.Response) (result autorest.Response, err error) {
	err = autorest.Respond(
		resp,
		client.ByInspecting(),
		azure.WithErrorUnlessStatusCode(http.StatusOK),
		autorest.ByClosing())
	result.Response = resp
	return
}

// GetFromComputeNode gets the content of the specified task file.
//
// poolID is the id of the pool that contains the compute node. nodeID is the id of the compute node that contains
// the file. fileName is the path to the task file that you want to get the content of. timeout is sets the maximum
// time that the server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is
// caller generated request identity, in the form of a GUID with no decoration such as curly braces e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the
// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this
// header will be automatically populated with the current system clock time. ocpRange is specifies the byte range
// to be retrieved. The default is to retrieve the entire file.  The format is startRange-endRange. ifModifiedSince
// is specify this header to perform the operation only if the resource has been modified since the specified
// date/time. ifUnmodifiedSince is specify this header to perform the operation only if the resource has not been
// modified since the specified date/time.
func (client FileClient) GetFromComputeNode(ctx context.Context, poolID string, nodeID string, fileName string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ocpRange string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result ReadCloser, err error) {
	req, err := client.GetFromComputeNodePreparer(ctx, poolID, nodeID, fileName, timeout, clientRequestID, returnClientRequestID, ocpDate, ocpRange, ifModifiedSince, ifUnmodifiedSince)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromComputeNode", nil, "Failure preparing request")
		return
	}

	resp, err := client.GetFromComputeNodeSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromComputeNode", resp, "Failure sending request")
		return
	}

	result, err = client.GetFromComputeNodeResponder(resp)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromComputeNode", resp, "Failure responding to request")
	}

	return
}

// GetFromComputeNodePreparer prepares the GetFromComputeNode request.
func (client FileClient) GetFromComputeNodePreparer(ctx context.Context, poolID string, nodeID string, fileName string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ocpRange string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
	pathParameters := map[string]interface{}{
		"fileName": autorest.Encode("path", fileName),
		"nodeId":   autorest.Encode("path", nodeID),
		"poolId":   autorest.Encode("path", poolID),
	}

	const APIVersion = "2015-12-01.2.2"
	queryParameters := map[string]interface{}{
		"api-version": APIVersion,
	}
	if timeout != nil {
		queryParameters["timeout"] = autorest.Encode("query", *timeout)
	} else {
		queryParameters["timeout"] = autorest.Encode("query", 30)
	}

	preparer := autorest.CreatePreparer(
		autorest.AsGet(),
		autorest.WithBaseURL(client.BaseURI),
		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/files/{fileName}", pathParameters),
		autorest.WithQueryParameters(queryParameters))
	if len(clientRequestID) > 0 {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
	}
	if returnClientRequestID != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
	}
	if ocpDate != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
	}
	if len(ocpRange) > 0 {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("ocp-range", autorest.String(ocpRange)))
	}
	if ifModifiedSince != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
	}
	if ifUnmodifiedSince != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
	}
	return preparer.Prepare((&http.Request{}).WithContext(ctx))
}

// GetFromComputeNodeSender sends the GetFromComputeNode request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) GetFromComputeNodeSender(req *http.Request) (*http.Response, error) {
	return autorest.SendWithSender(client, req,
		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}

// GetFromComputeNodeResponder handles the response to the GetFromComputeNode request. The method always
// closes the http.Response Body.
func (client FileClient) GetFromComputeNodeResponder(resp *http.Response) (result ReadCloser, err error) {
	result.Value = &resp.Body
	err = autorest.Respond(
		resp,
		client.ByInspecting(),
		azure.WithErrorUnlessStatusCode(http.StatusOK))
	result.Response = autorest.Response{Response: resp}
	return
}

// GetFromTask gets the content of the specified task file.
//
// jobID is the id of the job that contains the task. taskID is the id of the task whose file you want to retrieve.
// fileName is the path to the task file that you want to get the content of. timeout is sets the maximum time that
// the server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is caller
// generated request identity, in the form of a GUID with no decoration such as curly braces e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the
// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this
// header will be automatically populated with the current system clock time. ocpRange is specifies the byte range
// to be retrieved. The default is to retrieve the entire file.  The format is startRange-endRange. ifModifiedSince
// is specify this header to perform the operation only if the resource has been modified since the specified
// date/time. ifUnmodifiedSince is specify this header to perform the operation only if the resource has not been
// modified since the specified date/time.
func (client FileClient) GetFromTask(ctx context.Context, jobID string, taskID string, fileName string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ocpRange string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result ReadCloser, err error) {
	req, err := client.GetFromTaskPreparer(ctx, jobID, taskID, fileName, timeout, clientRequestID, returnClientRequestID, ocpDate, ocpRange, ifModifiedSince, ifUnmodifiedSince)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromTask", nil, "Failure preparing request")
		return
	}

	resp, err := client.GetFromTaskSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromTask", resp, "Failure sending request")
		return
	}

	result, err = client.GetFromTaskResponder(resp)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetFromTask", resp, "Failure responding to request")
	}

	return
}

// GetFromTaskPreparer prepares the GetFromTask request.
func (client FileClient) GetFromTaskPreparer(ctx context.Context, jobID string, taskID string, fileName string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ocpRange string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
	pathParameters := map[string]interface{}{
		"fileName": autorest.Encode("path", fileName),
		"jobId":    autorest.Encode("path", jobID),
		"taskId":   autorest.Encode("path", taskID),
	}

	const APIVersion = "2015-12-01.2.2"
	queryParameters := map[string]interface{}{
		"api-version": APIVersion,
	}
	if timeout != nil {
		queryParameters["timeout"] = autorest.Encode("query", *timeout)
	} else {
		queryParameters["timeout"] = autorest.Encode("query", 30)
	}

	preparer := autorest.CreatePreparer(
		autorest.AsGet(),
		autorest.WithBaseURL(client.BaseURI),
		autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/files/{fileName}", pathParameters),
		autorest.WithQueryParameters(queryParameters))
	if len(clientRequestID) > 0 {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
	}
	if returnClientRequestID != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
	}
	if ocpDate != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
	}
	if len(ocpRange) > 0 {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("ocp-range", autorest.String(ocpRange)))
	}
	if ifModifiedSince != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
	}
	if ifUnmodifiedSince != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
	}
	return preparer.Prepare((&http.Request{}).WithContext(ctx))
}

// GetFromTaskSender sends the GetFromTask request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) GetFromTaskSender(req *http.Request) (*http.Response, error) {
	return autorest.SendWithSender(client, req,
		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}

// GetFromTaskResponder handles the response to the GetFromTask request. The method always
// closes the http.Response Body.
func (client FileClient) GetFromTaskResponder(resp *http.Response) (result ReadCloser, err error) {
	result.Value = &resp.Body
	err = autorest.Respond(
		resp,
		client.ByInspecting(),
		azure.WithErrorUnlessStatusCode(http.StatusOK))
	result.Response = autorest.Response{Response: resp}
	return
}

// GetNodeFilePropertiesFromComputeNode gets the properties of the specified compute node file.
//
// poolID is the id of the pool that contains the compute node. nodeID is the id of the compute node that contains
// the file. fileName is the path to the compute node file that you want to get the properties of. timeout is sets
// the maximum time that the server can spend processing the request, in seconds. The default is 30 seconds.
// clientRequestID is caller generated request identity, in the form of a GUID with no decoration such as curly
// braces e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return
// the client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified,
// this header will be automatically populated with the current system clock time. ifModifiedSince is specify this
// header to perform the operation only if the resource has been modified since the specified date/time.
// ifUnmodifiedSince is specify this header to perform the operation only if the resource has not been modified
// since the specified date/time.
func (client FileClient) GetNodeFilePropertiesFromComputeNode(ctx context.Context, poolID string, nodeID string, fileName string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) {
	req, err := client.GetNodeFilePropertiesFromComputeNodePreparer(ctx, poolID, nodeID, fileName, timeout, clientRequestID, returnClientRequestID, ocpDate, ifModifiedSince, ifUnmodifiedSince)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetNodeFilePropertiesFromComputeNode", nil, "Failure preparing request")
		return
	}

	resp, err := client.GetNodeFilePropertiesFromComputeNodeSender(req)
	if err != nil {
		result.Response = resp
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetNodeFilePropertiesFromComputeNode", resp, "Failure sending request")
		return
	}

	result, err = client.GetNodeFilePropertiesFromComputeNodeResponder(resp)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetNodeFilePropertiesFromComputeNode", resp, "Failure responding to request")
	}

	return
}

// GetNodeFilePropertiesFromComputeNodePreparer prepares the GetNodeFilePropertiesFromComputeNode request.
func (client FileClient) GetNodeFilePropertiesFromComputeNodePreparer(ctx context.Context, poolID string, nodeID string, fileName string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
	pathParameters := map[string]interface{}{
		"fileName": autorest.Encode("path", fileName),
		"nodeId":   autorest.Encode("path", nodeID),
		"poolId":   autorest.Encode("path", poolID),
	}

	const APIVersion = "2015-12-01.2.2"
	queryParameters := map[string]interface{}{
		"api-version": APIVersion,
	}
	if timeout != nil {
		queryParameters["timeout"] = autorest.Encode("query", *timeout)
	} else {
		queryParameters["timeout"] = autorest.Encode("query", 30)
	}

	preparer := autorest.CreatePreparer(
		autorest.AsHead(),
		autorest.WithBaseURL(client.BaseURI),
		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/files/{fileName}", pathParameters),
		autorest.WithQueryParameters(queryParameters))
	if len(clientRequestID) > 0 {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
	}
	if returnClientRequestID != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
	}
	if ocpDate != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
	}
	if ifModifiedSince != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
	}
	if ifUnmodifiedSince != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
	}
	return preparer.Prepare((&http.Request{}).WithContext(ctx))
}

// GetNodeFilePropertiesFromComputeNodeSender sends the GetNodeFilePropertiesFromComputeNode request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) GetNodeFilePropertiesFromComputeNodeSender(req *http.Request) (*http.Response, error) {
	return autorest.SendWithSender(client, req,
		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}

// GetNodeFilePropertiesFromComputeNodeResponder handles the response to the GetNodeFilePropertiesFromComputeNode request. The method always
// closes the http.Response Body.
func (client FileClient) GetNodeFilePropertiesFromComputeNodeResponder(resp *http.Response) (result autorest.Response, err error) {
	err = autorest.Respond(
		resp,
		client.ByInspecting(),
		azure.WithErrorUnlessStatusCode(http.StatusOK),
		autorest.ByClosing())
	result.Response = resp
	return
}

// GetNodeFilePropertiesFromTask gets the properties of the specified task file.
//
// jobID is the id of the job that contains the task. taskID is the id of the task whose file you want to get the
// properties of. fileName is the path to the task file that you want to get the properties of. timeout is sets the
// maximum time that the server can spend processing the request, in seconds. The default is 30 seconds.
// clientRequestID is caller generated request identity, in the form of a GUID with no decoration such as curly
// braces e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return
// the client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified,
// this header will be automatically populated with the current system clock time. ifModifiedSince is specify this
// header to perform the operation only if the resource has been modified since the specified date/time.
// ifUnmodifiedSince is specify this header to perform the operation only if the resource has not been modified
// since the specified date/time.
func (client FileClient) GetNodeFilePropertiesFromTask(ctx context.Context, jobID string, taskID string, fileName string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) {
	req, err := client.GetNodeFilePropertiesFromTaskPreparer(ctx, jobID, taskID, fileName, timeout, clientRequestID, returnClientRequestID, ocpDate, ifModifiedSince, ifUnmodifiedSince)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetNodeFilePropertiesFromTask", nil, "Failure preparing request")
		return
	}

	resp, err := client.GetNodeFilePropertiesFromTaskSender(req)
	if err != nil {
		result.Response = resp
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetNodeFilePropertiesFromTask", resp, "Failure sending request")
		return
	}

	result, err = client.GetNodeFilePropertiesFromTaskResponder(resp)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "GetNodeFilePropertiesFromTask", resp, "Failure responding to request")
	}

	return
}

// GetNodeFilePropertiesFromTaskPreparer prepares the GetNodeFilePropertiesFromTask request.
func (client FileClient) GetNodeFilePropertiesFromTaskPreparer(ctx context.Context, jobID string, taskID string, fileName string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) {
	pathParameters := map[string]interface{}{
		"fileName": autorest.Encode("path", fileName),
		"jobId":    autorest.Encode("path", jobID),
		"taskId":   autorest.Encode("path", taskID),
	}

	const APIVersion = "2015-12-01.2.2"
	queryParameters := map[string]interface{}{
		"api-version": APIVersion,
	}
	if timeout != nil {
		queryParameters["timeout"] = autorest.Encode("query", *timeout)
	} else {
		queryParameters["timeout"] = autorest.Encode("query", 30)
	}

	preparer := autorest.CreatePreparer(
		autorest.AsHead(),
		autorest.WithBaseURL(client.BaseURI),
		autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/files/{fileName}", pathParameters),
		autorest.WithQueryParameters(queryParameters))
	if len(clientRequestID) > 0 {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
	}
	if returnClientRequestID != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
	}
	if ocpDate != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
	}
	if ifModifiedSince != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
	}
	if ifUnmodifiedSince != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
	}
	return preparer.Prepare((&http.Request{}).WithContext(ctx))
}

// GetNodeFilePropertiesFromTaskSender sends the GetNodeFilePropertiesFromTask request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) GetNodeFilePropertiesFromTaskSender(req *http.Request) (*http.Response, error) {
	return autorest.SendWithSender(client, req,
		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}

// GetNodeFilePropertiesFromTaskResponder handles the response to the GetNodeFilePropertiesFromTask request. The method always
// closes the http.Response Body.
func (client FileClient) GetNodeFilePropertiesFromTaskResponder(resp *http.Response) (result autorest.Response, err error) {
	err = autorest.Respond(
		resp,
		client.ByInspecting(),
		azure.WithErrorUnlessStatusCode(http.StatusOK),
		autorest.ByClosing())
	result.Response = resp
	return
}

// ListFromComputeNode lists all of the files in task directories on the specified compute node.
//
// poolID is the id of the pool that contains the compute node. nodeID is the id of the compute node whose files
// you want to list. filter is sets an OData $filter clause. recursive is sets whether to list children of a
// directory. maxResults is sets the maximum number of items to return in the response. timeout is sets the maximum
// time that the server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is
// caller generated request identity, in the form of a GUID with no decoration such as curly braces e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the
// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this
// header will be automatically populated with the current system clock time.
func (client FileClient) ListFromComputeNode(ctx context.Context, poolID string, nodeID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result NodeFileListResultPage, err error) {
	result.fn = client.listFromComputeNodeNextResults
	req, err := client.ListFromComputeNodePreparer(ctx, poolID, nodeID, filter, recursive, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromComputeNode", nil, "Failure preparing request")
		return
	}

	resp, err := client.ListFromComputeNodeSender(req)
	if err != nil {
		result.nflr.Response = autorest.Response{Response: resp}
		err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromComputeNode", resp, "Failure sending request")
		return
	}

	result.nflr, err = client.ListFromComputeNodeResponder(resp)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromComputeNode", resp, "Failure responding to request")
	}

	return
}

// ListFromComputeNodePreparer prepares the ListFromComputeNode request.
func (client FileClient) ListFromComputeNodePreparer(ctx context.Context, poolID string, nodeID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
	pathParameters := map[string]interface{}{
		"nodeId": autorest.Encode("path", nodeID),
		"poolId": autorest.Encode("path", poolID),
	}

	const APIVersion = "2015-12-01.2.2"
	queryParameters := map[string]interface{}{
		"api-version": APIVersion,
	}
	if len(filter) > 0 {
		queryParameters["$filter"] = autorest.Encode("query", filter)
	}
	if recursive != nil {
		queryParameters["recursive"] = autorest.Encode("query", *recursive)
	}
	if maxResults != nil {
		queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
	}
	if timeout != nil {
		queryParameters["timeout"] = autorest.Encode("query", *timeout)
	} else {
		queryParameters["timeout"] = autorest.Encode("query", 30)
	}

	preparer := autorest.CreatePreparer(
		autorest.AsGet(),
		autorest.WithBaseURL(client.BaseURI),
		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/files", pathParameters),
		autorest.WithQueryParameters(queryParameters))
	if len(clientRequestID) > 0 {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
	}
	if returnClientRequestID != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
	}
	if ocpDate != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
	}
	return preparer.Prepare((&http.Request{}).WithContext(ctx))
}

// ListFromComputeNodeSender sends the ListFromComputeNode request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) ListFromComputeNodeSender(req *http.Request) (*http.Response, error) {
	return autorest.SendWithSender(client, req,
		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}

// ListFromComputeNodeResponder handles the response to the ListFromComputeNode request. The method always
// closes the http.Response Body.
func (client FileClient) ListFromComputeNodeResponder(resp *http.Response) (result NodeFileListResult, err error) {
	err = autorest.Respond(
		resp,
		client.ByInspecting(),
		azure.WithErrorUnlessStatusCode(http.StatusOK),
		autorest.ByUnmarshallingJSON(&result),
		autorest.ByClosing())
	result.Response = autorest.Response{Response: resp}
	return
}

// listFromComputeNodeNextResults retrieves the next set of results, if any.
func (client FileClient) listFromComputeNodeNextResults(lastResults NodeFileListResult) (result NodeFileListResult, err error) {
	req, err := lastResults.nodeFileListResultPreparer()
	if err != nil {
		return result, autorest.NewErrorWithError(err, "batch.FileClient", "listFromComputeNodeNextResults", nil, "Failure preparing next results request")
	}
	if req == nil {
		return
	}
	resp, err := client.ListFromComputeNodeSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "batch.FileClient", "listFromComputeNodeNextResults", resp, "Failure sending next results request")
	}
	result, err = client.ListFromComputeNodeResponder(resp)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "listFromComputeNodeNextResults", resp, "Failure responding to next results request")
	}
	return
}

// ListFromComputeNodeComplete enumerates all values, automatically crossing page boundaries as required.
func (client FileClient) ListFromComputeNodeComplete(ctx context.Context, poolID string, nodeID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result NodeFileListResultIterator, err error) {
	result.page, err = client.ListFromComputeNode(ctx, poolID, nodeID, filter, recursive, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
	return
}

// ListFromTask lists the files in a task's directory on its compute node.
//
// jobID is the id of the job that contains the task. taskID is the id of the task whose files you want to list.
// filter is sets an OData $filter clause. recursive is sets whether to list children of a directory. maxResults is
// sets the maximum number of items to return in the response. timeout is sets the maximum time that the server can
// spend processing the request, in seconds. The default is 30 seconds. clientRequestID is caller generated request
// identity, in the form of a GUID with no decoration such as curly braces e.g.
// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the
// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this
// header will be automatically populated with the current system clock time.
func (client FileClient) ListFromTask(ctx context.Context, jobID string, taskID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result NodeFileListResultPage, err error) {
	result.fn = client.listFromTaskNextResults
	req, err := client.ListFromTaskPreparer(ctx, jobID, taskID, filter, recursive, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromTask", nil, "Failure preparing request")
		return
	}

	resp, err := client.ListFromTaskSender(req)
	if err != nil {
		result.nflr.Response = autorest.Response{Response: resp}
		err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromTask", resp, "Failure sending request")
		return
	}

	result.nflr, err = client.ListFromTaskResponder(resp)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "ListFromTask", resp, "Failure responding to request")
	}

	return
}

// ListFromTaskPreparer prepares the ListFromTask request.
func (client FileClient) ListFromTaskPreparer(ctx context.Context, jobID string, taskID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
	pathParameters := map[string]interface{}{
		"jobId":  autorest.Encode("path", jobID),
		"taskId": autorest.Encode("path", taskID),
	}

	const APIVersion = "2015-12-01.2.2"
	queryParameters := map[string]interface{}{
		"api-version": APIVersion,
	}
	if len(filter) > 0 {
		queryParameters["$filter"] = autorest.Encode("query", filter)
	}
	if recursive != nil {
		queryParameters["recursive"] = autorest.Encode("query", *recursive)
	}
	if maxResults != nil {
		queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
	}
	if timeout != nil {
		queryParameters["timeout"] = autorest.Encode("query", *timeout)
	} else {
		queryParameters["timeout"] = autorest.Encode("query", 30)
	}

	preparer := autorest.CreatePreparer(
		autorest.AsGet(),
		autorest.WithBaseURL(client.BaseURI),
		autorest.WithPathParameters("/jobs/{jobId}/tasks/{taskId}/files", pathParameters),
		autorest.WithQueryParameters(queryParameters))
	if len(clientRequestID) > 0 {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
	}
	if returnClientRequestID != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
	}
	if ocpDate != nil {
		preparer = autorest.DecoratePreparer(preparer,
			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
	}
	return preparer.Prepare((&http.Request{}).WithContext(ctx))
}

// ListFromTaskSender sends the ListFromTask request. The method will close the
// http.Response Body if it receives an error.
func (client FileClient) ListFromTaskSender(req *http.Request) (*http.Response, error) {
	return autorest.SendWithSender(client, req,
		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}

// ListFromTaskResponder handles the response to the ListFromTask request. The method always
// closes the http.Response Body.
func (client FileClient) ListFromTaskResponder(resp *http.Response) (result NodeFileListResult, err error) {
	err = autorest.Respond(
		resp,
		client.ByInspecting(),
		azure.WithErrorUnlessStatusCode(http.StatusOK),
		autorest.ByUnmarshallingJSON(&result),
		autorest.ByClosing())
	result.Response = autorest.Response{Response: resp}
	return
}

// listFromTaskNextResults retrieves the next set of results, if any.
func (client FileClient) listFromTaskNextResults(lastResults NodeFileListResult) (result NodeFileListResult, err error) {
	req, err := lastResults.nodeFileListResultPreparer()
	if err != nil {
		return result, autorest.NewErrorWithError(err, "batch.FileClient", "listFromTaskNextResults", nil, "Failure preparing next results request")
	}
	if req == nil {
		return
	}
	resp, err := client.ListFromTaskSender(req)
	if err != nil {
		result.Response = autorest.Response{Response: resp}
		return result, autorest.NewErrorWithError(err, "batch.FileClient", "listFromTaskNextResults", resp, "Failure sending next results request")
	}
	result, err = client.ListFromTaskResponder(resp)
	if err != nil {
		err = autorest.NewErrorWithError(err, "batch.FileClient", "listFromTaskNextResults", resp, "Failure responding to next results request")
	}
	return
}

// ListFromTaskComplete enumerates all values, automatically crossing page boundaries as required.
func (client FileClient) ListFromTaskComplete(ctx context.Context, jobID string, taskID string, filter string, recursive *bool, maxResults *int32, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result NodeFileListResultIterator, err error) {
	result.page, err = client.ListFromTask(ctx, jobID, taskID, filter, recursive, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
	return
}
