// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT.

package generated

import (
	"context"
	"encoding/base64"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"net/http"
	"strconv"
	"strings"
	"time"
)

// FileClient contains the methods for the File group.
// Don't use this type directly, use a constructor function instead.
//
// Generated from API version 2026-10-06
type FileClient struct {
	internal *azcore.Client
	url      string
}

// AbortCopy - Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.
// If the operation fails it returns an *azcore.ResponseError type.
//   - copyid - The copy identifier provided in the x-ms-copy-id header of the original Copy File operation.
//   - options - FileClientAbortCopyOptions contains the optional parameters for the FileClient.AbortCopy method.
func (client *FileClient) AbortCopy(ctx context.Context, copyid string, options *FileClientAbortCopyOptions) (FileClientAbortCopyResponse, error) {
	var err error
	req, err := client.abortCopyCreateRequest(ctx, copyid, options)
	if err != nil {
		return FileClientAbortCopyResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientAbortCopyResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return FileClientAbortCopyResponse{}, err
	}
	resp, err := client.abortCopyHandleResponse(httpResp)
	return resp, err
}

// abortCopyCreateRequest creates the AbortCopy request.
func (client *FileClient) abortCopyCreateRequest(ctx context.Context, copyid string, options *FileClientAbortCopyOptions) (*policy.Request, error) {
	urlPath := "?comp=copy"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("copyid", copyid)
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	req.Raw().Header["x-ms-copy-action"] = []string{"abort"}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// abortCopyHandleResponse handles the AbortCopy response.
func (client *FileClient) abortCopyHandleResponse(resp *http.Response) (FileClientAbortCopyResponse, error) {
	result := FileClientAbortCopyResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientAbortCopyResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// AcquireLease - The Lease File operation establishes and manages a lock on a file for write and delete operations.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientAcquireLeaseOptions contains the optional parameters for the FileClient.AcquireLease method.
func (client *FileClient) AcquireLease(ctx context.Context, options *FileClientAcquireLeaseOptions) (FileClientAcquireLeaseResponse, error) {
	var err error
	req, err := client.acquireLeaseCreateRequest(ctx, options)
	if err != nil {
		return FileClientAcquireLeaseResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientAcquireLeaseResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusCreated) {
		err = runtime.NewResponseError(httpResp)
		return FileClientAcquireLeaseResponse{}, err
	}
	resp, err := client.acquireLeaseHandleResponse(httpResp)
	return resp, err
}

// acquireLeaseCreateRequest creates the AcquireLease request.
func (client *FileClient) acquireLeaseCreateRequest(ctx context.Context, options *FileClientAcquireLeaseOptions) (*policy.Request, error) {
	urlPath := "?comp=lease"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	req.Raw().Header["x-ms-lease-action"] = []string{"acquire"}
	if options != nil && options.LeaseDuration != nil {
		req.Raw().Header["x-ms-lease-duration"] = []string{strconv.FormatInt(int64(*options.LeaseDuration), 10)}
	}
	if options != nil && options.ProposedLeaseID != nil {
		req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// acquireLeaseHandleResponse handles the AcquireLease response.
func (client *FileClient) acquireLeaseHandleResponse(resp *http.Response) (FileClientAcquireLeaseResponse, error) {
	result := FileClientAcquireLeaseResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientAcquireLeaseResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientAcquireLeaseResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-lease-id"); val != "" {
		result.LeaseID = &val
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// BreakLease - The Lease File operation establishes and manages a lock on a file for write and delete operations.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientBreakLeaseOptions contains the optional parameters for the FileClient.BreakLease method.
func (client *FileClient) BreakLease(ctx context.Context, options *FileClientBreakLeaseOptions) (FileClientBreakLeaseResponse, error) {
	var err error
	req, err := client.breakLeaseCreateRequest(ctx, options)
	if err != nil {
		return FileClientBreakLeaseResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientBreakLeaseResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return FileClientBreakLeaseResponse{}, err
	}
	resp, err := client.breakLeaseHandleResponse(httpResp)
	return resp, err
}

// breakLeaseCreateRequest creates the BreakLease request.
func (client *FileClient) breakLeaseCreateRequest(ctx context.Context, options *FileClientBreakLeaseOptions) (*policy.Request, error) {
	urlPath := "?comp=lease"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	req.Raw().Header["x-ms-lease-action"] = []string{"break"}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// breakLeaseHandleResponse handles the BreakLease response.
func (client *FileClient) breakLeaseHandleResponse(resp *http.Response) (FileClientBreakLeaseResponse, error) {
	result := FileClientBreakLeaseResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientBreakLeaseResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientBreakLeaseResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-lease-id"); val != "" {
		result.LeaseID = &val
	}
	if val := resp.Header.Get("x-ms-lease-time"); val != "" {
		leaseTime32, err := strconv.ParseInt(val, 10, 32)
		leaseTime := int32(leaseTime32)
		if err != nil {
			return FileClientBreakLeaseResponse{}, err
		}
		result.LeaseTime = &leaseTime
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// ChangeLease - The Lease File operation establishes and manages a lock on a file for write and delete operations.
// If the operation fails it returns an *azcore.ResponseError type.
//   - leaseID - Specifies the current lease ID on the resource.
//   - options - FileClientChangeLeaseOptions contains the optional parameters for the FileClient.ChangeLease method.
func (client *FileClient) ChangeLease(ctx context.Context, leaseID string, options *FileClientChangeLeaseOptions) (FileClientChangeLeaseResponse, error) {
	var err error
	req, err := client.changeLeaseCreateRequest(ctx, leaseID, options)
	if err != nil {
		return FileClientChangeLeaseResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientChangeLeaseResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientChangeLeaseResponse{}, err
	}
	resp, err := client.changeLeaseHandleResponse(httpResp)
	return resp, err
}

// changeLeaseCreateRequest creates the ChangeLease request.
func (client *FileClient) changeLeaseCreateRequest(ctx context.Context, leaseID string, options *FileClientChangeLeaseOptions) (*policy.Request, error) {
	urlPath := "?comp=lease"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	req.Raw().Header["x-ms-lease-action"] = []string{"change"}
	req.Raw().Header["x-ms-lease-id"] = []string{leaseID}
	if options != nil && options.ProposedLeaseID != nil {
		req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// changeLeaseHandleResponse handles the ChangeLease response.
func (client *FileClient) changeLeaseHandleResponse(resp *http.Response) (FileClientChangeLeaseResponse, error) {
	result := FileClientChangeLeaseResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientChangeLeaseResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientChangeLeaseResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-lease-id"); val != "" {
		result.LeaseID = &val
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// Create - Creates a new file or replaces a file. Note it only initializes the file with no content.
// If the operation fails it returns an *azcore.ResponseError type.
//   - fileContentLength - Specifies the maximum size for the file, up to 4 TB.
//   - options - FileClientCreateOptions contains the optional parameters for the FileClient.Create method.
func (client *FileClient) Create(ctx context.Context, fileContentLength int64, options *FileClientCreateOptions) (FileClientCreateResponse, error) {
	var err error
	req, err := client.createCreateRequest(ctx, fileContentLength, options)
	if err != nil {
		return FileClientCreateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientCreateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusCreated) {
		err = runtime.NewResponseError(httpResp)
		return FileClientCreateResponse{}, err
	}
	resp, err := client.createHandleResponse(httpResp)
	return resp, err
}

// createCreateRequest creates the Create request.
func (client *FileClient) createCreateRequest(ctx context.Context, fileContentLength int64, options *FileClientCreateOptions) (*policy.Request, error) {
	req, err := runtime.NewRequest(ctx, http.MethodPut, client.url)
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.ContentLength != nil {
		req.Raw().Header["Content-Length"] = []string{strconv.FormatInt(*options.ContentLength, 10)}
	}
	if options != nil && options.ContentMD5 != nil {
		req.Raw().Header["Content-MD5"] = []string{base64.StdEncoding.EncodeToString(options.ContentMD5)}
	}
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.FileCacheControl != nil {
		req.Raw().Header["x-ms-cache-control"] = []string{*options.FileCacheControl}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileContentDisposition != nil {
		req.Raw().Header["x-ms-content-disposition"] = []string{*options.FileContentDisposition}
	}
	if options != nil && options.FileContentEncoding != nil {
		req.Raw().Header["x-ms-content-encoding"] = []string{*options.FileContentEncoding}
	}
	if options != nil && options.FileContentLanguage != nil {
		req.Raw().Header["x-ms-content-language"] = []string{*options.FileContentLanguage}
	}
	req.Raw().Header["x-ms-content-length"] = []string{strconv.FormatInt(fileContentLength, 10)}
	if options != nil && options.FileContentMD5 != nil {
		req.Raw().Header["x-ms-content-md5"] = []string{base64.StdEncoding.EncodeToString(options.FileContentMD5)}
	}
	if options != nil && options.FileContentType != nil {
		req.Raw().Header["x-ms-content-type"] = []string{*options.FileContentType}
	}
	if options != nil && options.FileAttributes != nil {
		req.Raw().Header["x-ms-file-attributes"] = []string{*options.FileAttributes}
	}
	if options != nil && options.FileChangeTime != nil {
		req.Raw().Header["x-ms-file-change-time"] = []string{*options.FileChangeTime}
	}
	if options != nil && options.FileCreationTime != nil {
		req.Raw().Header["x-ms-file-creation-time"] = []string{*options.FileCreationTime}
	}
	if options != nil && options.NFSFileType != nil {
		req.Raw().Header["x-ms-file-file-type"] = []string{string(*options.NFSFileType)}
	}
	if options != nil && options.FileLastWriteTime != nil {
		req.Raw().Header["x-ms-file-last-write-time"] = []string{*options.FileLastWriteTime}
	}
	if options != nil && options.FilePermission != nil {
		req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission}
	}
	if options != nil && options.FilePermissionFormat != nil {
		req.Raw().Header["x-ms-file-permission-format"] = []string{string(*options.FilePermissionFormat)}
	}
	if options != nil && options.FilePermissionKey != nil {
		req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey}
	}
	if options != nil && options.FilePropertySemantics != nil {
		req.Raw().Header["x-ms-file-property-semantics"] = []string{string(*options.FilePropertySemantics)}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.Group != nil {
		req.Raw().Header["x-ms-group"] = []string{*options.Group}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	if options != nil && options.Metadata != nil {
		for k, v := range options.Metadata {
			if v != nil {
				req.Raw().Header["x-ms-meta-"+k] = []string{*v}
			}
		}
	}
	if options != nil && options.FileMode != nil {
		req.Raw().Header["x-ms-mode"] = []string{*options.FileMode}
	}
	if options != nil && options.Owner != nil {
		req.Raw().Header["x-ms-owner"] = []string{*options.Owner}
	}
	if options != nil && options.StructuredBodyType != nil {
		req.Raw().Header["x-ms-structured-body"] = []string{*options.StructuredBodyType}
	}
	if options != nil && options.StructuredContentLength != nil {
		req.Raw().Header["x-ms-structured-content-length"] = []string{strconv.FormatInt(*options.StructuredContentLength, 10)}
	}
	req.Raw().Header["x-ms-type"] = []string{"file"}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	if options != nil && options.Optionalbody != nil {
		req.Raw().Header["Content-Type"] = []string{"application/octet-stream"}
		if err := req.SetBody(options.Optionalbody, "application/octet-stream"); err != nil {
			return nil, err
		}
		return req, nil
	}
	return req, nil
}

// createHandleResponse handles the Create response.
func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientCreateResponse, error) {
	result := FileClientCreateResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Content-Length"); val != "" {
		contentLength, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientCreateResponse{}, err
		}
		result.ContentLength = &contentLength
	}
	if val := resp.Header.Get("Content-MD5"); val != "" {
		contentMD5, err := base64.StdEncoding.DecodeString(val)
		if err != nil {
			return FileClientCreateResponse{}, err
		}
		result.ContentMD5 = contentMD5
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientCreateResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-file-attributes"); val != "" {
		result.FileAttributes = &val
	}
	if val := resp.Header.Get("x-ms-file-change-time"); val != "" {
		fileChangeTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientCreateResponse{}, err
		}
		result.FileChangeTime = &fileChangeTime
	}
	if val := resp.Header.Get("x-ms-file-creation-time"); val != "" {
		fileCreationTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientCreateResponse{}, err
		}
		result.FileCreationTime = &fileCreationTime
	}
	if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" {
		fileLastWriteTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientCreateResponse{}, err
		}
		result.FileLastWriteTime = &fileLastWriteTime
	}
	if val := resp.Header.Get("x-ms-mode"); val != "" {
		result.FileMode = &val
	}
	if val := resp.Header.Get("x-ms-file-permission-key"); val != "" {
		result.FilePermissionKey = &val
	}
	if val := resp.Header.Get("x-ms-group"); val != "" {
		result.Group = &val
	}
	if val := resp.Header.Get("x-ms-file-id"); val != "" {
		result.ID = &val
	}
	if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" {
		isServerEncrypted, err := strconv.ParseBool(val)
		if err != nil {
			return FileClientCreateResponse{}, err
		}
		result.IsServerEncrypted = &isServerEncrypted
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientCreateResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-file-file-type"); val != "" {
		result.NFSFileType = (*NFSFileType)(&val)
	}
	if val := resp.Header.Get("x-ms-owner"); val != "" {
		result.Owner = &val
	}
	if val := resp.Header.Get("x-ms-file-parent-id"); val != "" {
		result.ParentID = &val
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-structured-body"); val != "" {
		result.StructuredBodyType = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// CreateHardLink - Creates a hard link to a target file. NFS only.
// If the operation fails it returns an *azcore.ResponseError type.
//   - targetFile - NFS only. Required. Specifies the path of the target file to which the link will be created, up to 2 KiB in
//     length.
//   - options - FileClientCreateHardLinkOptions contains the optional parameters for the FileClient.CreateHardLink method.
func (client *FileClient) CreateHardLink(ctx context.Context, targetFile string, options *FileClientCreateHardLinkOptions) (FileClientCreateHardLinkResponse, error) {
	var err error
	req, err := client.createHardLinkCreateRequest(ctx, targetFile, options)
	if err != nil {
		return FileClientCreateHardLinkResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientCreateHardLinkResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusCreated) {
		err = runtime.NewResponseError(httpResp)
		return FileClientCreateHardLinkResponse{}, err
	}
	resp, err := client.createHardLinkHandleResponse(httpResp)
	return resp, err
}

// createHardLinkCreateRequest creates the CreateHardLink request.
func (client *FileClient) createHardLinkCreateRequest(ctx context.Context, targetFile string, options *FileClientCreateHardLinkOptions) (*policy.Request, error) {
	urlPath := "?restype=hardlink"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	req.Raw().Header["x-ms-file-target-file"] = []string{targetFile}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	req.Raw().Header["x-ms-type"] = []string{"file"}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// createHardLinkHandleResponse handles the CreateHardLink response.
func (client *FileClient) createHardLinkHandleResponse(resp *http.Response) (FileClientCreateHardLinkResponse, error) {
	result := FileClientCreateHardLinkResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientCreateHardLinkResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-file-change-time"); val != "" {
		fileChangeTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientCreateHardLinkResponse{}, err
		}
		result.FileChangeTime = &fileChangeTime
	}
	if val := resp.Header.Get("x-ms-file-creation-time"); val != "" {
		fileCreationTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientCreateHardLinkResponse{}, err
		}
		result.FileCreationTime = &fileCreationTime
	}
	if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" {
		fileLastWriteTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientCreateHardLinkResponse{}, err
		}
		result.FileLastWriteTime = &fileLastWriteTime
	}
	if val := resp.Header.Get("x-ms-mode"); val != "" {
		result.FileMode = &val
	}
	if val := resp.Header.Get("x-ms-group"); val != "" {
		result.Group = &val
	}
	if val := resp.Header.Get("x-ms-file-id"); val != "" {
		result.ID = &val
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientCreateHardLinkResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-link-count"); val != "" {
		linkCount, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientCreateHardLinkResponse{}, err
		}
		result.LinkCount = &linkCount
	}
	if val := resp.Header.Get("x-ms-file-file-type"); val != "" {
		result.NFSFileType = (*NFSFileType)(&val)
	}
	if val := resp.Header.Get("x-ms-owner"); val != "" {
		result.Owner = &val
	}
	if val := resp.Header.Get("x-ms-file-parent-id"); val != "" {
		result.ParentID = &val
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// CreateSymbolicLink - Creates a symbolic link to a target file. NFS only.
// If the operation fails it returns an *azcore.ResponseError type.
//   - linkText - NFS only. The path to the original file, the symbolic link is pointing to.
//   - options - FileClientCreateSymbolicLinkOptions contains the optional parameters for the FileClient.CreateSymbolicLink method.
func (client *FileClient) CreateSymbolicLink(ctx context.Context, linkText string, options *FileClientCreateSymbolicLinkOptions) (FileClientCreateSymbolicLinkResponse, error) {
	var err error
	req, err := client.createSymbolicLinkCreateRequest(ctx, linkText, options)
	if err != nil {
		return FileClientCreateSymbolicLinkResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientCreateSymbolicLinkResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusCreated) {
		err = runtime.NewResponseError(httpResp)
		return FileClientCreateSymbolicLinkResponse{}, err
	}
	resp, err := client.createSymbolicLinkHandleResponse(httpResp)
	return resp, err
}

// createSymbolicLinkCreateRequest creates the CreateSymbolicLink request.
func (client *FileClient) createSymbolicLinkCreateRequest(ctx context.Context, linkText string, options *FileClientCreateSymbolicLinkOptions) (*policy.Request, error) {
	urlPath := "?restype=symboliclink"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileCreationTime != nil {
		req.Raw().Header["x-ms-file-creation-time"] = []string{*options.FileCreationTime}
	}
	if options != nil && options.FileLastWriteTime != nil {
		req.Raw().Header["x-ms-file-last-write-time"] = []string{*options.FileLastWriteTime}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.Group != nil {
		req.Raw().Header["x-ms-group"] = []string{*options.Group}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	req.Raw().Header["x-ms-link-text"] = []string{linkText}
	if options != nil && options.Metadata != nil {
		for k, v := range options.Metadata {
			if v != nil {
				req.Raw().Header["x-ms-meta-"+k] = []string{*v}
			}
		}
	}
	if options != nil && options.Owner != nil {
		req.Raw().Header["x-ms-owner"] = []string{*options.Owner}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// createSymbolicLinkHandleResponse handles the CreateSymbolicLink response.
func (client *FileClient) createSymbolicLinkHandleResponse(resp *http.Response) (FileClientCreateSymbolicLinkResponse, error) {
	result := FileClientCreateSymbolicLinkResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientCreateSymbolicLinkResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-file-change-time"); val != "" {
		fileChangeTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientCreateSymbolicLinkResponse{}, err
		}
		result.FileChangeTime = &fileChangeTime
	}
	if val := resp.Header.Get("x-ms-file-creation-time"); val != "" {
		fileCreationTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientCreateSymbolicLinkResponse{}, err
		}
		result.FileCreationTime = &fileCreationTime
	}
	if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" {
		fileLastWriteTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientCreateSymbolicLinkResponse{}, err
		}
		result.FileLastWriteTime = &fileLastWriteTime
	}
	if val := resp.Header.Get("x-ms-mode"); val != "" {
		result.FileMode = &val
	}
	if val := resp.Header.Get("x-ms-group"); val != "" {
		result.Group = &val
	}
	if val := resp.Header.Get("x-ms-file-id"); val != "" {
		result.ID = &val
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientCreateSymbolicLinkResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-file-file-type"); val != "" {
		result.NFSFileType = (*NFSFileType)(&val)
	}
	if val := resp.Header.Get("x-ms-owner"); val != "" {
		result.Owner = &val
	}
	if val := resp.Header.Get("x-ms-file-parent-id"); val != "" {
		result.ParentID = &val
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// Delete - Removes the file from the storage account.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientDeleteOptions contains the optional parameters for the FileClient.Delete method.
func (client *FileClient) Delete(ctx context.Context, options *FileClientDeleteOptions) (FileClientDeleteResponse, error) {
	var err error
	req, err := client.deleteCreateRequest(ctx, options)
	if err != nil {
		return FileClientDeleteResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientDeleteResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return FileClientDeleteResponse{}, err
	}
	resp, err := client.deleteHandleResponse(httpResp)
	return resp, err
}

// deleteCreateRequest creates the Delete request.
func (client *FileClient) deleteCreateRequest(ctx context.Context, options *FileClientDeleteOptions) (*policy.Request, error) {
	req, err := runtime.NewRequest(ctx, http.MethodDelete, client.url)
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// deleteHandleResponse handles the Delete response.
func (client *FileClient) deleteHandleResponse(resp *http.Response) (FileClientDeleteResponse, error) {
	result := FileClientDeleteResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientDeleteResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("x-ms-link-count"); val != "" {
		linkCount, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientDeleteResponse{}, err
		}
		result.LinkCount = &linkCount
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// Download - Reads or downloads a file from the system, including its metadata and properties.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientDownloadOptions contains the optional parameters for the FileClient.Download method.
func (client *FileClient) Download(ctx context.Context, options *FileClientDownloadOptions) (FileClientDownloadResponse, error) {
	var err error
	req, err := client.downloadCreateRequest(ctx, options)
	if err != nil {
		return FileClientDownloadResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientDownloadResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusPartialContent) {
		err = runtime.NewResponseError(httpResp)
		return FileClientDownloadResponse{}, err
	}
	resp, err := client.downloadHandleResponse(httpResp)
	return resp, err
}

// downloadCreateRequest creates the Download request.
func (client *FileClient) downloadCreateRequest(ctx context.Context, options *FileClientDownloadOptions) (*policy.Request, error) {
	req, err := runtime.NewRequest(ctx, http.MethodGet, client.url)
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	runtime.SkipBodyDownload(req)
	req.Raw().Header["Accept"] = []string{"application/octet-stream"}
	if options != nil && options.Range != nil {
		req.Raw().Header["Range"] = []string{*options.Range}
	}
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	if options != nil && options.RangeGetContentMD5 != nil {
		req.Raw().Header["x-ms-range-get-content-md5"] = []string{strconv.FormatBool(*options.RangeGetContentMD5)}
	}
	if options != nil && options.StructuredBodyType != nil {
		req.Raw().Header["x-ms-structured-body"] = []string{*options.StructuredBodyType}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// downloadHandleResponse handles the Download response.
func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClientDownloadResponse, error) {
	result := FileClientDownloadResponse{Body: resp.Body}
	if val := resp.Header.Get("Accept-Ranges"); val != "" {
		result.AcceptRanges = &val
	}
	if val := resp.Header.Get("Cache-Control"); val != "" {
		result.CacheControl = &val
	}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Content-Disposition"); val != "" {
		result.ContentDisposition = &val
	}
	if val := resp.Header.Get("Content-Encoding"); val != "" {
		result.ContentEncoding = &val
	}
	if val := resp.Header.Get("Content-Language"); val != "" {
		result.ContentLanguage = &val
	}
	if val := resp.Header.Get("Content-Length"); val != "" {
		contentLength, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.ContentLength = &contentLength
	}
	if val := resp.Header.Get("Content-MD5"); val != "" {
		contentMD5, err := base64.StdEncoding.DecodeString(val)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.ContentMD5 = contentMD5
	}
	if val := resp.Header.Get("Content-Range"); val != "" {
		result.ContentRange = &val
	}
	if val := resp.Header.Get("Content-Type"); val != "" {
		result.ContentType = &val
	}
	if val := resp.Header.Get("x-ms-copy-completion-time"); val != "" {
		copyCompletionTime, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.CopyCompletionTime = &copyCompletionTime
	}
	if val := resp.Header.Get("x-ms-copy-id"); val != "" {
		result.CopyID = &val
	}
	if val := resp.Header.Get("x-ms-copy-progress"); val != "" {
		result.CopyProgress = &val
	}
	if val := resp.Header.Get("x-ms-copy-source"); val != "" {
		result.CopySource = &val
	}
	if val := resp.Header.Get("x-ms-copy-status"); val != "" {
		result.CopyStatus = (*CopyStatusType)(&val)
	}
	if val := resp.Header.Get("x-ms-copy-status-description"); val != "" {
		result.CopyStatusDescription = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-file-attributes"); val != "" {
		result.FileAttributes = &val
	}
	if val := resp.Header.Get("x-ms-file-change-time"); val != "" {
		fileChangeTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.FileChangeTime = &fileChangeTime
	}
	if val := resp.Header.Get("x-ms-content-md5"); val != "" {
		fileContentMD5, err := base64.StdEncoding.DecodeString(val)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.FileContentMD5 = fileContentMD5
	}
	if val := resp.Header.Get("x-ms-file-creation-time"); val != "" {
		fileCreationTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.FileCreationTime = &fileCreationTime
	}
	if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" {
		fileLastWriteTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.FileLastWriteTime = &fileLastWriteTime
	}
	if val := resp.Header.Get("x-ms-mode"); val != "" {
		result.FileMode = &val
	}
	if val := resp.Header.Get("x-ms-file-permission-key"); val != "" {
		result.FilePermissionKey = &val
	}
	if val := resp.Header.Get("x-ms-group"); val != "" {
		result.Group = &val
	}
	if val := resp.Header.Get("x-ms-file-id"); val != "" {
		result.ID = &val
	}
	if val := resp.Header.Get("x-ms-server-encrypted"); val != "" {
		isServerEncrypted, err := strconv.ParseBool(val)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.IsServerEncrypted = &isServerEncrypted
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-lease-duration"); val != "" {
		result.LeaseDuration = (*LeaseDurationType)(&val)
	}
	if val := resp.Header.Get("x-ms-lease-state"); val != "" {
		result.LeaseState = (*LeaseStateType)(&val)
	}
	if val := resp.Header.Get("x-ms-lease-status"); val != "" {
		result.LeaseStatus = (*LeaseStatusType)(&val)
	}
	if val := resp.Header.Get("x-ms-link-count"); val != "" {
		linkCount, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.LinkCount = &linkCount
	}
	for hh := range resp.Header {
		if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") {
			if result.Metadata == nil {
				result.Metadata = map[string]*string{}
			}
			result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh))
		}
	}
	if val := resp.Header.Get("x-ms-owner"); val != "" {
		result.Owner = &val
	}
	if val := resp.Header.Get("x-ms-file-parent-id"); val != "" {
		result.ParentID = &val
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-structured-body"); val != "" {
		result.StructuredBodyType = &val
	}
	if val := resp.Header.Get("x-ms-structured-content-length"); val != "" {
		structuredContentLength, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientDownloadResponse{}, err
		}
		result.StructuredContentLength = &structuredContentLength
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// ForceCloseHandles - Closes all handles open for given file.
// If the operation fails it returns an *azcore.ResponseError type.
//   - handleID - Specifies handle ID opened on the file or directory to be closed. Asterisk ('*') is a wildcard that specifies
//     all handles.
//   - options - FileClientForceCloseHandlesOptions contains the optional parameters for the FileClient.ForceCloseHandles method.
func (client *FileClient) ForceCloseHandles(ctx context.Context, handleID string, options *FileClientForceCloseHandlesOptions) (FileClientForceCloseHandlesResponse, error) {
	var err error
	req, err := client.forceCloseHandlesCreateRequest(ctx, handleID, options)
	if err != nil {
		return FileClientForceCloseHandlesResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientForceCloseHandlesResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientForceCloseHandlesResponse{}, err
	}
	resp, err := client.forceCloseHandlesHandleResponse(httpResp)
	return resp, err
}

// forceCloseHandlesCreateRequest creates the ForceCloseHandles request.
func (client *FileClient) forceCloseHandlesCreateRequest(ctx context.Context, handleID string, options *FileClientForceCloseHandlesOptions) (*policy.Request, error) {
	urlPath := "?comp=forceclosehandles"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Marker != nil {
		reqQP.Set("marker", *options.Marker)
	}
	if options != nil && options.Sharesnapshot != nil {
		reqQP.Set("sharesnapshot", *options.Sharesnapshot)
	}
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	req.Raw().Header["x-ms-handle-id"] = []string{handleID}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// forceCloseHandlesHandleResponse handles the ForceCloseHandles response.
func (client *FileClient) forceCloseHandlesHandleResponse(resp *http.Response) (FileClientForceCloseHandlesResponse, error) {
	result := FileClientForceCloseHandlesResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientForceCloseHandlesResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("x-ms-marker"); val != "" {
		result.Marker = &val
	}
	if val := resp.Header.Get("x-ms-number-of-handles-closed"); val != "" {
		numberOfHandlesClosed32, err := strconv.ParseInt(val, 10, 32)
		numberOfHandlesClosed := int32(numberOfHandlesClosed32)
		if err != nil {
			return FileClientForceCloseHandlesResponse{}, err
		}
		result.NumberOfHandlesClosed = &numberOfHandlesClosed
	}
	if val := resp.Header.Get("x-ms-number-of-handles-failed"); val != "" {
		numberOfHandlesFailedToClose32, err := strconv.ParseInt(val, 10, 32)
		numberOfHandlesFailedToClose := int32(numberOfHandlesFailedToClose32)
		if err != nil {
			return FileClientForceCloseHandlesResponse{}, err
		}
		result.NumberOfHandlesFailedToClose = &numberOfHandlesFailedToClose
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// GetProperties - Returns all user-defined metadata, standard HTTP properties, and system properties for the file.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientGetPropertiesOptions contains the optional parameters for the FileClient.GetProperties method.
func (client *FileClient) GetProperties(ctx context.Context, options *FileClientGetPropertiesOptions) (FileClientGetPropertiesResponse, error) {
	var err error
	req, err := client.getPropertiesCreateRequest(ctx, options)
	if err != nil {
		return FileClientGetPropertiesResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientGetPropertiesResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientGetPropertiesResponse{}, err
	}
	resp, err := client.getPropertiesHandleResponse(httpResp)
	return resp, err
}

// getPropertiesCreateRequest creates the GetProperties request.
func (client *FileClient) getPropertiesCreateRequest(ctx context.Context, options *FileClientGetPropertiesOptions) (*policy.Request, error) {
	req, err := runtime.NewRequest(ctx, http.MethodHead, client.url)
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Sharesnapshot != nil {
		reqQP.Set("sharesnapshot", *options.Sharesnapshot)
	}
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// getPropertiesHandleResponse handles the GetProperties response.
func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (FileClientGetPropertiesResponse, error) {
	result := FileClientGetPropertiesResponse{}
	if val := resp.Header.Get("Cache-Control"); val != "" {
		result.CacheControl = &val
	}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Content-Disposition"); val != "" {
		result.ContentDisposition = &val
	}
	if val := resp.Header.Get("Content-Encoding"); val != "" {
		result.ContentEncoding = &val
	}
	if val := resp.Header.Get("Content-Language"); val != "" {
		result.ContentLanguage = &val
	}
	if val := resp.Header.Get("Content-Length"); val != "" {
		contentLength, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientGetPropertiesResponse{}, err
		}
		result.ContentLength = &contentLength
	}
	if val := resp.Header.Get("Content-MD5"); val != "" {
		contentMD5, err := base64.StdEncoding.DecodeString(val)
		if err != nil {
			return FileClientGetPropertiesResponse{}, err
		}
		result.ContentMD5 = contentMD5
	}
	if val := resp.Header.Get("Content-Type"); val != "" {
		result.ContentType = &val
	}
	if val := resp.Header.Get("x-ms-copy-completion-time"); val != "" {
		copyCompletionTime, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientGetPropertiesResponse{}, err
		}
		result.CopyCompletionTime = &copyCompletionTime
	}
	if val := resp.Header.Get("x-ms-copy-id"); val != "" {
		result.CopyID = &val
	}
	if val := resp.Header.Get("x-ms-copy-progress"); val != "" {
		result.CopyProgress = &val
	}
	if val := resp.Header.Get("x-ms-copy-source"); val != "" {
		result.CopySource = &val
	}
	if val := resp.Header.Get("x-ms-copy-status"); val != "" {
		result.CopyStatus = (*CopyStatusType)(&val)
	}
	if val := resp.Header.Get("x-ms-copy-status-description"); val != "" {
		result.CopyStatusDescription = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientGetPropertiesResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-file-attributes"); val != "" {
		result.FileAttributes = &val
	}
	if val := resp.Header.Get("x-ms-file-change-time"); val != "" {
		fileChangeTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientGetPropertiesResponse{}, err
		}
		result.FileChangeTime = &fileChangeTime
	}
	if val := resp.Header.Get("x-ms-file-creation-time"); val != "" {
		fileCreationTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientGetPropertiesResponse{}, err
		}
		result.FileCreationTime = &fileCreationTime
	}
	if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" {
		fileLastWriteTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientGetPropertiesResponse{}, err
		}
		result.FileLastWriteTime = &fileLastWriteTime
	}
	if val := resp.Header.Get("x-ms-mode"); val != "" {
		result.FileMode = &val
	}
	if val := resp.Header.Get("x-ms-file-permission-key"); val != "" {
		result.FilePermissionKey = &val
	}
	if val := resp.Header.Get("x-ms-type"); val != "" {
		result.FileType = &val
	}
	if val := resp.Header.Get("x-ms-group"); val != "" {
		result.Group = &val
	}
	if val := resp.Header.Get("x-ms-file-id"); val != "" {
		result.ID = &val
	}
	if val := resp.Header.Get("x-ms-server-encrypted"); val != "" {
		isServerEncrypted, err := strconv.ParseBool(val)
		if err != nil {
			return FileClientGetPropertiesResponse{}, err
		}
		result.IsServerEncrypted = &isServerEncrypted
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientGetPropertiesResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-lease-duration"); val != "" {
		result.LeaseDuration = (*LeaseDurationType)(&val)
	}
	if val := resp.Header.Get("x-ms-lease-state"); val != "" {
		result.LeaseState = (*LeaseStateType)(&val)
	}
	if val := resp.Header.Get("x-ms-lease-status"); val != "" {
		result.LeaseStatus = (*LeaseStatusType)(&val)
	}
	if val := resp.Header.Get("x-ms-link-count"); val != "" {
		linkCount, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientGetPropertiesResponse{}, err
		}
		result.LinkCount = &linkCount
	}
	for hh := range resp.Header {
		if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") {
			if result.Metadata == nil {
				result.Metadata = map[string]*string{}
			}
			result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh))
		}
	}
	if val := resp.Header.Get("x-ms-file-file-type"); val != "" {
		result.NFSFileType = (*NFSFileType)(&val)
	}
	if val := resp.Header.Get("x-ms-owner"); val != "" {
		result.Owner = &val
	}
	if val := resp.Header.Get("x-ms-file-parent-id"); val != "" {
		result.ParentID = &val
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// GetRangeList - Returns the list of valid page ranges for a file or snapshot of a file.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientGetRangeListOptions contains the optional parameters for the FileClient.GetRangeList method.
func (client *FileClient) GetRangeList(ctx context.Context, options *FileClientGetRangeListOptions) (FileClientGetRangeListResponse, error) {
	var err error
	req, err := client.getRangeListCreateRequest(ctx, options)
	if err != nil {
		return FileClientGetRangeListResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientGetRangeListResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientGetRangeListResponse{}, err
	}
	resp, err := client.getRangeListHandleResponse(httpResp)
	return resp, err
}

// getRangeListCreateRequest creates the GetRangeList request.
func (client *FileClient) getRangeListCreateRequest(ctx context.Context, options *FileClientGetRangeListOptions) (*policy.Request, error) {
	urlPath := "?comp=rangelist"
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Prevsharesnapshot != nil {
		reqQP.Set("prevsharesnapshot", *options.Prevsharesnapshot)
	}
	if options != nil && options.Sharesnapshot != nil {
		reqQP.Set("sharesnapshot", *options.Sharesnapshot)
	}
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/xml"}
	if options != nil && options.Range != nil {
		req.Raw().Header["Range"] = []string{*options.Range}
	}
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.SupportRename != nil {
		req.Raw().Header["x-ms-file-support-rename"] = []string{strconv.FormatBool(*options.SupportRename)}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// getRangeListHandleResponse handles the GetRangeList response.
func (client *FileClient) getRangeListHandleResponse(resp *http.Response) (FileClientGetRangeListResponse, error) {
	result := FileClientGetRangeListResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientGetRangeListResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-content-length"); val != "" {
		fileContentLength, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientGetRangeListResponse{}, err
		}
		result.FileContentLength = &fileContentLength
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientGetRangeListResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	if err := runtime.UnmarshalAsXML(resp, &result.ShareFileRangeList); err != nil {
		return FileClientGetRangeListResponse{}, err
	}
	return result, nil
}

// GetSymbolicLink - Returns the target of a symbolic link. NFS only.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientGetSymbolicLinkOptions contains the optional parameters for the FileClient.GetSymbolicLink method.
func (client *FileClient) GetSymbolicLink(ctx context.Context, options *FileClientGetSymbolicLinkOptions) (FileClientGetSymbolicLinkResponse, error) {
	var err error
	req, err := client.getSymbolicLinkCreateRequest(ctx, options)
	if err != nil {
		return FileClientGetSymbolicLinkResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientGetSymbolicLinkResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientGetSymbolicLinkResponse{}, err
	}
	resp, err := client.getSymbolicLinkHandleResponse(httpResp)
	return resp, err
}

// getSymbolicLinkCreateRequest creates the GetSymbolicLink request.
func (client *FileClient) getSymbolicLinkCreateRequest(ctx context.Context, options *FileClientGetSymbolicLinkOptions) (*policy.Request, error) {
	urlPath := "?restype=symboliclink"
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Sharesnapshot != nil {
		reqQP.Set("sharesnapshot", *options.Sharesnapshot)
	}
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// getSymbolicLinkHandleResponse handles the GetSymbolicLink response.
func (client *FileClient) getSymbolicLinkHandleResponse(resp *http.Response) (FileClientGetSymbolicLinkResponse, error) {
	result := FileClientGetSymbolicLinkResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientGetSymbolicLinkResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientGetSymbolicLinkResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-link-text"); val != "" {
		result.LinkText = &val
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// ListAllRanges - Returns a paginated list of valid page ranges for a file or snapshot of a file.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientListAllRangesOptions contains the optional parameters for the FileClient.ListAllRanges method.
func (client *FileClient) ListAllRanges(ctx context.Context, options *FileClientListAllRangesOptions) (FileClientListAllRangesResponse, error) {
	var err error
	req, err := client.listAllRangesCreateRequest(ctx, options)
	if err != nil {
		return FileClientListAllRangesResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientListAllRangesResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientListAllRangesResponse{}, err
	}
	resp, err := client.listAllRangesHandleResponse(httpResp)
	return resp, err
}

// listAllRangesCreateRequest creates the ListAllRanges request.
func (client *FileClient) listAllRangesCreateRequest(ctx context.Context, options *FileClientListAllRangesOptions) (*policy.Request, error) {
	urlPath := "?comp=rangelist"
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Marker != nil {
		reqQP.Set("marker", *options.Marker)
	}
	if options != nil && options.Maxresults != nil {
		reqQP.Set("maxresults", strconv.FormatInt(int64(*options.Maxresults), 10))
	}
	if options != nil && options.Prevsharesnapshot != nil {
		reqQP.Set("prevsharesnapshot", *options.Prevsharesnapshot)
	}
	if options != nil && options.Sharesnapshot != nil {
		reqQP.Set("sharesnapshot", *options.Sharesnapshot)
	}
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/xml"}
	if options != nil && options.Range != nil {
		req.Raw().Header["Range"] = []string{*options.Range}
	}
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.SupportRename != nil {
		req.Raw().Header["x-ms-file-support-rename"] = []string{strconv.FormatBool(*options.SupportRename)}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// listAllRangesHandleResponse handles the ListAllRanges response.
func (client *FileClient) listAllRangesHandleResponse(resp *http.Response) (FileClientListAllRangesResponse, error) {
	result := FileClientListAllRangesResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientListAllRangesResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-content-length"); val != "" {
		fileContentLength, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientListAllRangesResponse{}, err
		}
		result.FileContentLength = &fileContentLength
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientListAllRangesResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	if err := runtime.UnmarshalAsXML(resp, &result.ShareFileRangeListSegment); err != nil {
		return FileClientListAllRangesResponse{}, err
	}
	return result, nil
}

// ListHandles - Lists handles for file.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientListHandlesOptions contains the optional parameters for the FileClient.ListHandles method.
func (client *FileClient) ListHandles(ctx context.Context, options *FileClientListHandlesOptions) (FileClientListHandlesResponse, error) {
	var err error
	req, err := client.listHandlesCreateRequest(ctx, options)
	if err != nil {
		return FileClientListHandlesResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientListHandlesResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientListHandlesResponse{}, err
	}
	resp, err := client.listHandlesHandleResponse(httpResp)
	return resp, err
}

// listHandlesCreateRequest creates the ListHandles request.
func (client *FileClient) listHandlesCreateRequest(ctx context.Context, options *FileClientListHandlesOptions) (*policy.Request, error) {
	urlPath := "?comp=listhandles"
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Marker != nil {
		reqQP.Set("marker", *options.Marker)
	}
	if options != nil && options.Maxresults != nil {
		reqQP.Set("maxresults", strconv.FormatInt(int64(*options.Maxresults), 10))
	}
	if options != nil && options.Sharesnapshot != nil {
		reqQP.Set("sharesnapshot", *options.Sharesnapshot)
	}
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/xml"}
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// listHandlesHandleResponse handles the ListHandles response.
func (client *FileClient) listHandlesHandleResponse(resp *http.Response) (FileClientListHandlesResponse, error) {
	result := FileClientListHandlesResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Content-Type"); val != "" {
		result.ContentType = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientListHandlesResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	if err := runtime.UnmarshalAsXML(resp, &result.ListHandlesResponse); err != nil {
		return FileClientListHandlesResponse{}, err
	}
	return result, nil
}

// ReleaseLease - The Lease File operation establishes and manages a lock on a file for write and delete operations.
// If the operation fails it returns an *azcore.ResponseError type.
//   - leaseID - Specifies the current lease ID on the resource.
//   - options - FileClientReleaseLeaseOptions contains the optional parameters for the FileClient.ReleaseLease method.
func (client *FileClient) ReleaseLease(ctx context.Context, leaseID string, options *FileClientReleaseLeaseOptions) (FileClientReleaseLeaseResponse, error) {
	var err error
	req, err := client.releaseLeaseCreateRequest(ctx, leaseID, options)
	if err != nil {
		return FileClientReleaseLeaseResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientReleaseLeaseResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientReleaseLeaseResponse{}, err
	}
	resp, err := client.releaseLeaseHandleResponse(httpResp)
	return resp, err
}

// releaseLeaseCreateRequest creates the ReleaseLease request.
func (client *FileClient) releaseLeaseCreateRequest(ctx context.Context, leaseID string, options *FileClientReleaseLeaseOptions) (*policy.Request, error) {
	urlPath := "?comp=lease"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	req.Raw().Header["x-ms-lease-action"] = []string{"release"}
	req.Raw().Header["x-ms-lease-id"] = []string{leaseID}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// releaseLeaseHandleResponse handles the ReleaseLease response.
func (client *FileClient) releaseLeaseHandleResponse(resp *http.Response) (FileClientReleaseLeaseResponse, error) {
	result := FileClientReleaseLeaseResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientReleaseLeaseResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientReleaseLeaseResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// Rename - Renames a file. By default, the destination is overwritten and if the destination already exists and has a read-only
// attribute set, the operation will fail.
// If the operation fails it returns an *azcore.ResponseError type.
//   - renameSource - Required. Specifies the URI-style path of the source file, up to 2 KB in length.
//   - options - FileClientRenameOptions contains the optional parameters for the FileClient.Rename method.
func (client *FileClient) Rename(ctx context.Context, renameSource string, options *FileClientRenameOptions) (FileClientRenameResponse, error) {
	var err error
	req, err := client.renameCreateRequest(ctx, renameSource, options)
	if err != nil {
		return FileClientRenameResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientRenameResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientRenameResponse{}, err
	}
	resp, err := client.renameHandleResponse(httpResp)
	return resp, err
}

// renameCreateRequest creates the Rename request.
func (client *FileClient) renameCreateRequest(ctx context.Context, renameSource string, options *FileClientRenameOptions) (*policy.Request, error) {
	urlPath := "?comp=rename"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileContentType != nil {
		req.Raw().Header["x-ms-content-type"] = []string{*options.FileContentType}
	}
	if options != nil && options.DestinationLeaseID != nil {
		req.Raw().Header["x-ms-destination-lease-id"] = []string{*options.DestinationLeaseID}
	}
	if options != nil && options.FileAttributes != nil {
		req.Raw().Header["x-ms-file-attributes"] = []string{*options.FileAttributes}
	}
	if options != nil && options.FileChangeTime != nil {
		req.Raw().Header["x-ms-file-change-time"] = []string{*options.FileChangeTime}
	}
	if options != nil && options.FileCreationTime != nil {
		req.Raw().Header["x-ms-file-creation-time"] = []string{*options.FileCreationTime}
	}
	if options != nil && options.FileLastWriteTime != nil {
		req.Raw().Header["x-ms-file-last-write-time"] = []string{*options.FileLastWriteTime}
	}
	if options != nil && options.FilePermission != nil {
		req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission}
	}
	if options != nil && options.FilePermissionFormat != nil {
		req.Raw().Header["x-ms-file-permission-format"] = []string{string(*options.FilePermissionFormat)}
	}
	if options != nil && options.FilePermissionKey != nil {
		req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey}
	}
	if options != nil && options.IgnoreReadOnly != nil {
		req.Raw().Header["x-ms-file-rename-ignore-readonly"] = []string{strconv.FormatBool(*options.IgnoreReadOnly)}
	}
	if options != nil && options.ReplaceIfExists != nil {
		req.Raw().Header["x-ms-file-rename-replace-if-exists"] = []string{strconv.FormatBool(*options.ReplaceIfExists)}
	}
	req.Raw().Header["x-ms-file-rename-source"] = []string{renameSource}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.Metadata != nil {
		for k, v := range options.Metadata {
			if v != nil {
				req.Raw().Header["x-ms-meta-"+k] = []string{*v}
			}
		}
	}
	if options != nil && options.AllowSourceTrailingDot != nil {
		req.Raw().Header["x-ms-source-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowSourceTrailingDot)}
	}
	if options != nil && options.SourceLeaseID != nil {
		req.Raw().Header["x-ms-source-lease-id"] = []string{*options.SourceLeaseID}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// renameHandleResponse handles the Rename response.
func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientRenameResponse, error) {
	result := FileClientRenameResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientRenameResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-file-attributes"); val != "" {
		result.FileAttributes = &val
	}
	if val := resp.Header.Get("x-ms-file-change-time"); val != "" {
		fileChangeTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientRenameResponse{}, err
		}
		result.FileChangeTime = &fileChangeTime
	}
	if val := resp.Header.Get("x-ms-file-creation-time"); val != "" {
		fileCreationTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientRenameResponse{}, err
		}
		result.FileCreationTime = &fileCreationTime
	}
	if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" {
		fileLastWriteTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientRenameResponse{}, err
		}
		result.FileLastWriteTime = &fileLastWriteTime
	}
	if val := resp.Header.Get("x-ms-file-permission-key"); val != "" {
		result.FilePermissionKey = &val
	}
	if val := resp.Header.Get("x-ms-file-id"); val != "" {
		result.ID = &val
	}
	if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" {
		isServerEncrypted, err := strconv.ParseBool(val)
		if err != nil {
			return FileClientRenameResponse{}, err
		}
		result.IsServerEncrypted = &isServerEncrypted
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientRenameResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-file-parent-id"); val != "" {
		result.ParentID = &val
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// SetHTTPHeaders - Sets HTTP headers on a file.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientSetHTTPHeadersOptions contains the optional parameters for the FileClient.SetHTTPHeaders method.
func (client *FileClient) SetHTTPHeaders(ctx context.Context, options *FileClientSetHTTPHeadersOptions) (FileClientSetHTTPHeadersResponse, error) {
	var err error
	req, err := client.setHTTPHeadersCreateRequest(ctx, options)
	if err != nil {
		return FileClientSetHTTPHeadersResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientSetHTTPHeadersResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientSetHTTPHeadersResponse{}, err
	}
	resp, err := client.setHTTPHeadersHandleResponse(httpResp)
	return resp, err
}

// setHTTPHeadersCreateRequest creates the SetHTTPHeaders request.
func (client *FileClient) setHTTPHeadersCreateRequest(ctx context.Context, options *FileClientSetHTTPHeadersOptions) (*policy.Request, error) {
	urlPath := "?comp=properties"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.FileCacheControl != nil {
		req.Raw().Header["x-ms-cache-control"] = []string{*options.FileCacheControl}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileContentDisposition != nil {
		req.Raw().Header["x-ms-content-disposition"] = []string{*options.FileContentDisposition}
	}
	if options != nil && options.FileContentEncoding != nil {
		req.Raw().Header["x-ms-content-encoding"] = []string{*options.FileContentEncoding}
	}
	if options != nil && options.FileContentLanguage != nil {
		req.Raw().Header["x-ms-content-language"] = []string{*options.FileContentLanguage}
	}
	if options != nil && options.FileContentLength != nil {
		req.Raw().Header["x-ms-content-length"] = []string{strconv.FormatInt(*options.FileContentLength, 10)}
	}
	if options != nil && options.FileContentMD5 != nil {
		req.Raw().Header["x-ms-content-md5"] = []string{base64.StdEncoding.EncodeToString(options.FileContentMD5)}
	}
	if options != nil && options.FileContentType != nil {
		req.Raw().Header["x-ms-content-type"] = []string{*options.FileContentType}
	}
	if options != nil && options.FileAttributes != nil {
		req.Raw().Header["x-ms-file-attributes"] = []string{*options.FileAttributes}
	}
	if options != nil && options.FileChangeTime != nil {
		req.Raw().Header["x-ms-file-change-time"] = []string{*options.FileChangeTime}
	}
	if options != nil && options.FileCreationTime != nil {
		req.Raw().Header["x-ms-file-creation-time"] = []string{*options.FileCreationTime}
	}
	if options != nil && options.FileLastWriteTime != nil {
		req.Raw().Header["x-ms-file-last-write-time"] = []string{*options.FileLastWriteTime}
	}
	if options != nil && options.FilePermission != nil {
		req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission}
	}
	if options != nil && options.FilePermissionFormat != nil {
		req.Raw().Header["x-ms-file-permission-format"] = []string{string(*options.FilePermissionFormat)}
	}
	if options != nil && options.FilePermissionKey != nil {
		req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.Group != nil {
		req.Raw().Header["x-ms-group"] = []string{*options.Group}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	if options != nil && options.FileMode != nil {
		req.Raw().Header["x-ms-mode"] = []string{*options.FileMode}
	}
	if options != nil && options.Owner != nil {
		req.Raw().Header["x-ms-owner"] = []string{*options.Owner}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// setHTTPHeadersHandleResponse handles the SetHTTPHeaders response.
func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (FileClientSetHTTPHeadersResponse, error) {
	result := FileClientSetHTTPHeadersResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientSetHTTPHeadersResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-file-attributes"); val != "" {
		result.FileAttributes = &val
	}
	if val := resp.Header.Get("x-ms-file-change-time"); val != "" {
		fileChangeTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientSetHTTPHeadersResponse{}, err
		}
		result.FileChangeTime = &fileChangeTime
	}
	if val := resp.Header.Get("x-ms-file-creation-time"); val != "" {
		fileCreationTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientSetHTTPHeadersResponse{}, err
		}
		result.FileCreationTime = &fileCreationTime
	}
	if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" {
		fileLastWriteTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientSetHTTPHeadersResponse{}, err
		}
		result.FileLastWriteTime = &fileLastWriteTime
	}
	if val := resp.Header.Get("x-ms-mode"); val != "" {
		result.FileMode = &val
	}
	if val := resp.Header.Get("x-ms-file-permission-key"); val != "" {
		result.FilePermissionKey = &val
	}
	if val := resp.Header.Get("x-ms-group"); val != "" {
		result.Group = &val
	}
	if val := resp.Header.Get("x-ms-file-id"); val != "" {
		result.ID = &val
	}
	if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" {
		isServerEncrypted, err := strconv.ParseBool(val)
		if err != nil {
			return FileClientSetHTTPHeadersResponse{}, err
		}
		result.IsServerEncrypted = &isServerEncrypted
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientSetHTTPHeadersResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-link-count"); val != "" {
		linkCount, err := strconv.ParseInt(val, 10, 64)
		if err != nil {
			return FileClientSetHTTPHeadersResponse{}, err
		}
		result.LinkCount = &linkCount
	}
	if val := resp.Header.Get("x-ms-owner"); val != "" {
		result.Owner = &val
	}
	if val := resp.Header.Get("x-ms-file-parent-id"); val != "" {
		result.ParentID = &val
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// SetMetadata - Sets one or more user-defined name-value pairs for the specified file.
// If the operation fails it returns an *azcore.ResponseError type.
//   - options - FileClientSetMetadataOptions contains the optional parameters for the FileClient.SetMetadata method.
func (client *FileClient) SetMetadata(ctx context.Context, options *FileClientSetMetadataOptions) (FileClientSetMetadataResponse, error) {
	var err error
	req, err := client.setMetadataCreateRequest(ctx, options)
	if err != nil {
		return FileClientSetMetadataResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientSetMetadataResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return FileClientSetMetadataResponse{}, err
	}
	resp, err := client.setMetadataHandleResponse(httpResp)
	return resp, err
}

// setMetadataCreateRequest creates the SetMetadata request.
func (client *FileClient) setMetadataCreateRequest(ctx context.Context, options *FileClientSetMetadataOptions) (*policy.Request, error) {
	urlPath := "?comp=metadata"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	if options != nil && options.Metadata != nil {
		for k, v := range options.Metadata {
			if v != nil {
				req.Raw().Header["x-ms-meta-"+k] = []string{*v}
			}
		}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// setMetadataHandleResponse handles the SetMetadata response.
func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileClientSetMetadataResponse, error) {
	result := FileClientSetMetadataResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientSetMetadataResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" {
		isServerEncrypted, err := strconv.ParseBool(val)
		if err != nil {
			return FileClientSetMetadataResponse{}, err
		}
		result.IsServerEncrypted = &isServerEncrypted
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientSetMetadataResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// StartCopy - Copies a blob or file to a destination file within the storage account.
// If the operation fails it returns an *azcore.ResponseError type.
//   - copySource - Specifies the URL of the source file or blob, up to 2 KB in length.
//   - options - FileClientStartCopyOptions contains the optional parameters for the FileClient.StartCopy method.
func (client *FileClient) StartCopy(ctx context.Context, copySource string, options *FileClientStartCopyOptions) (FileClientStartCopyResponse, error) {
	var err error
	req, err := client.startCopyCreateRequest(ctx, copySource, options)
	if err != nil {
		return FileClientStartCopyResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientStartCopyResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return FileClientStartCopyResponse{}, err
	}
	resp, err := client.startCopyHandleResponse(httpResp)
	return resp, err
}

// startCopyCreateRequest creates the StartCopy request.
func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource string, options *FileClientStartCopyOptions) (*policy.Request, error) {
	req, err := runtime.NewRequest(ctx, http.MethodPut, client.url)
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	req.Raw().Header["x-ms-copy-source"] = []string{copySource}
	if options != nil && options.FileAttributes != nil {
		req.Raw().Header["x-ms-file-attributes"] = []string{*options.FileAttributes}
	}
	if options != nil && options.FileChangeTime != nil {
		req.Raw().Header["x-ms-file-change-time"] = []string{*options.FileChangeTime}
	}
	if options != nil && options.IgnoreReadOnly != nil {
		req.Raw().Header["x-ms-file-copy-ignore-readonly"] = []string{strconv.FormatBool(*options.IgnoreReadOnly)}
	}
	if options != nil && options.SetArchiveAttribute != nil {
		req.Raw().Header["x-ms-file-copy-set-archive"] = []string{strconv.FormatBool(*options.SetArchiveAttribute)}
	}
	if options != nil && options.FileCreationTime != nil {
		req.Raw().Header["x-ms-file-creation-time"] = []string{*options.FileCreationTime}
	}
	if options != nil && options.FileLastWriteTime != nil {
		req.Raw().Header["x-ms-file-last-write-time"] = []string{*options.FileLastWriteTime}
	}
	if options != nil && options.FileModeCopyMode != nil {
		req.Raw().Header["x-ms-file-mode-copy-mode"] = []string{string(*options.FileModeCopyMode)}
	}
	if options != nil && options.FileOwnerCopyMode != nil {
		req.Raw().Header["x-ms-file-owner-copy-mode"] = []string{string(*options.FileOwnerCopyMode)}
	}
	if options != nil && options.FilePermission != nil {
		req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission}
	}
	if options != nil && options.FilePermissionCopyMode != nil {
		req.Raw().Header["x-ms-file-permission-copy-mode"] = []string{string(*options.FilePermissionCopyMode)}
	}
	if options != nil && options.FilePermissionFormat != nil {
		req.Raw().Header["x-ms-file-permission-format"] = []string{string(*options.FilePermissionFormat)}
	}
	if options != nil && options.FilePermissionKey != nil {
		req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.Group != nil {
		req.Raw().Header["x-ms-group"] = []string{*options.Group}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	if options != nil && options.Metadata != nil {
		for k, v := range options.Metadata {
			if v != nil {
				req.Raw().Header["x-ms-meta-"+k] = []string{*v}
			}
		}
	}
	if options != nil && options.FileMode != nil {
		req.Raw().Header["x-ms-mode"] = []string{*options.FileMode}
	}
	if options != nil && options.Owner != nil {
		req.Raw().Header["x-ms-owner"] = []string{*options.Owner}
	}
	if options != nil && options.AllowSourceTrailingDot != nil {
		req.Raw().Header["x-ms-source-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowSourceTrailingDot)}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	return req, nil
}

// startCopyHandleResponse handles the StartCopy response.
func (client *FileClient) startCopyHandleResponse(resp *http.Response) (FileClientStartCopyResponse, error) {
	result := FileClientStartCopyResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("x-ms-copy-id"); val != "" {
		result.CopyID = &val
	}
	if val := resp.Header.Get("x-ms-copy-status"); val != "" {
		result.CopyStatus = (*CopyStatusType)(&val)
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientStartCopyResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientStartCopyResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// UploadRange - Upload a range of bytes to a file.
// If the operation fails it returns an *azcore.ResponseError type.
//   - rangeParam - Specifies the range of bytes to be written. Both the start and end of the range must be specified.
//   - fileRangeWrite - Specify one of the following options: - Update: Writes the bytes specified by the request body into the
//     specified range. - Clear: Clears the specified range and releases the space used in storage for that range.
//   - contentLength - The number of bytes being transmitted in the request body.
//   - options - FileClientUploadRangeOptions contains the optional parameters for the FileClient.UploadRange method.
func (client *FileClient) UploadRange(ctx context.Context, rangeParam string, fileRangeWrite FileRangeWriteType, contentLength int64, options *FileClientUploadRangeOptions) (FileClientUploadRangeResponse, error) {
	var err error
	req, err := client.uploadRangeCreateRequest(ctx, rangeParam, fileRangeWrite, contentLength, options)
	if err != nil {
		return FileClientUploadRangeResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientUploadRangeResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusCreated) {
		err = runtime.NewResponseError(httpResp)
		return FileClientUploadRangeResponse{}, err
	}
	resp, err := client.uploadRangeHandleResponse(httpResp)
	return resp, err
}

// uploadRangeCreateRequest creates the UploadRange request.
func (client *FileClient) uploadRangeCreateRequest(ctx context.Context, rangeParam string, fileRangeWrite FileRangeWriteType, contentLength int64, options *FileClientUploadRangeOptions) (*policy.Request, error) {
	urlPath := "?comp=range"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Content-Length"] = []string{strconv.FormatInt(contentLength, 10)}
	if options != nil && options.ContentMD5 != nil {
		req.Raw().Header["Content-MD5"] = []string{base64.StdEncoding.EncodeToString(options.ContentMD5)}
	}
	req.Raw().Header["Range"] = []string{rangeParam}
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	if options != nil && options.FileLastWrittenMode != nil {
		req.Raw().Header["x-ms-file-last-write-time"] = []string{string(*options.FileLastWrittenMode)}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	if options != nil && options.StructuredBodyType != nil {
		req.Raw().Header["x-ms-structured-body"] = []string{*options.StructuredBodyType}
	}
	if options != nil && options.StructuredContentLength != nil {
		req.Raw().Header["x-ms-structured-content-length"] = []string{strconv.FormatInt(*options.StructuredContentLength, 10)}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	req.Raw().Header["x-ms-write"] = []string{string(fileRangeWrite)}
	if options != nil && options.Optionalbody != nil {
		req.Raw().Header["Content-Type"] = []string{"application/octet-stream"}
		if err := req.SetBody(options.Optionalbody, "application/octet-stream"); err != nil {
			return nil, err
		}
		return req, nil
	}
	return req, nil
}

// uploadRangeHandleResponse handles the UploadRange response.
func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileClientUploadRangeResponse, error) {
	result := FileClientUploadRangeResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Content-MD5"); val != "" {
		contentMD5, err := base64.StdEncoding.DecodeString(val)
		if err != nil {
			return FileClientUploadRangeResponse{}, err
		}
		result.ContentMD5 = contentMD5
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientUploadRangeResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" {
		fileLastWriteTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientUploadRangeResponse{}, err
		}
		result.FileLastWriteTime = &fileLastWriteTime
	}
	if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" {
		isServerEncrypted, err := strconv.ParseBool(val)
		if err != nil {
			return FileClientUploadRangeResponse{}, err
		}
		result.IsServerEncrypted = &isServerEncrypted
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientUploadRangeResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-structured-body"); val != "" {
		result.StructuredBodyType = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	return result, nil
}

// UploadRangeFromURL - Upload a range of bytes to a file where the contents are read from a URL.
// If the operation fails it returns an *azcore.ResponseError type.
//   - rangeParam - Specifies the range of bytes to be written. Both the start and end of the range must be specified.
//   - copySource - Specifies the URL of the source file or blob, up to 2 KB in length.
//   - fileRangeWriteFromURL - Only update is supported.
//   - contentLength - The number of bytes being transmitted in the request body.
//   - options - FileClientUploadRangeFromURLOptions contains the optional parameters for the FileClient.UploadRangeFromURL method.
func (client *FileClient) UploadRangeFromURL(ctx context.Context, rangeParam string, copySource string, fileRangeWriteFromURL FileRangeWriteFromURLType, contentLength int64, options *FileClientUploadRangeFromURLOptions) (FileClientUploadRangeFromURLResponse, error) {
	var err error
	req, err := client.uploadRangeFromURLCreateRequest(ctx, rangeParam, copySource, fileRangeWriteFromURL, contentLength, options)
	if err != nil {
		return FileClientUploadRangeFromURLResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return FileClientUploadRangeFromURLResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusCreated) {
		err = runtime.NewResponseError(httpResp)
		return FileClientUploadRangeFromURLResponse{}, err
	}
	resp, err := client.uploadRangeFromURLHandleResponse(httpResp)
	return resp, err
}

// uploadRangeFromURLCreateRequest creates the UploadRangeFromURL request.
func (client *FileClient) uploadRangeFromURLCreateRequest(ctx context.Context, rangeParam string, copySource string, fileRangeWriteFromURL FileRangeWriteFromURLType, contentLength int64, options *FileClientUploadRangeFromURLOptions) (*policy.Request, error) {
	urlPath := "?comp=range"
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.url, urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Timeout != nil {
		reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Content-Length"] = []string{strconv.FormatInt(contentLength, 10)}
	req.Raw().Header["Range"] = []string{rangeParam}
	if options != nil && options.AllowTrailingDot != nil {
		req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowTrailingDot)}
	}
	if options != nil && options.RequestID != nil {
		req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID}
	}
	req.Raw().Header["x-ms-copy-source"] = []string{copySource}
	if options != nil && options.CopySourceAuthorization != nil {
		req.Raw().Header["x-ms-copy-source-authorization"] = []string{*options.CopySourceAuthorization}
	}
	if options != nil && options.FileLastWrittenMode != nil {
		req.Raw().Header["x-ms-file-last-write-time"] = []string{string(*options.FileLastWrittenMode)}
	}
	if options != nil && options.FileRequestIntent != nil {
		req.Raw().Header["x-ms-file-request-intent"] = []string{string(*options.FileRequestIntent)}
	}
	if options != nil && options.LeaseID != nil {
		req.Raw().Header["x-ms-lease-id"] = []string{*options.LeaseID}
	}
	if options != nil && options.AllowSourceTrailingDot != nil {
		req.Raw().Header["x-ms-source-allow-trailing-dot"] = []string{strconv.FormatBool(*options.AllowSourceTrailingDot)}
	}
	if options != nil && options.SourceContentCRC64 != nil {
		req.Raw().Header["x-ms-source-content-crc64"] = []string{base64.StdEncoding.EncodeToString(options.SourceContentCRC64)}
	}
	if options != nil && options.SourceIfMatchCRC64 != nil {
		req.Raw().Header["x-ms-source-if-match-crc64"] = []string{base64.StdEncoding.EncodeToString(options.SourceIfMatchCRC64)}
	}
	if options != nil && options.SourceIfNoneMatchCRC64 != nil {
		req.Raw().Header["x-ms-source-if-none-match-crc64"] = []string{base64.StdEncoding.EncodeToString(options.SourceIfNoneMatchCRC64)}
	}
	if options != nil && options.SourceRange != nil {
		req.Raw().Header["x-ms-source-range"] = []string{*options.SourceRange}
	}
	req.Raw().Header["x-ms-version"] = []string{version20261006}
	req.Raw().Header["x-ms-write"] = []string{string(fileRangeWriteFromURL)}
	return req, nil
}

// uploadRangeFromURLHandleResponse handles the UploadRangeFromURL response.
func (client *FileClient) uploadRangeFromURLHandleResponse(resp *http.Response) (FileClientUploadRangeFromURLResponse, error) {
	result := FileClientUploadRangeFromURLResponse{}
	if val := resp.Header.Get("x-ms-client-request-id"); val != "" {
		result.ClientRequestID = &val
	}
	if val := resp.Header.Get("Content-MD5"); val != "" {
		contentMD5, err := base64.StdEncoding.DecodeString(val)
		if err != nil {
			return FileClientUploadRangeFromURLResponse{}, err
		}
		result.ContentMD5 = contentMD5
	}
	if val := resp.Header.Get("Date"); val != "" {
		date, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientUploadRangeFromURLResponse{}, err
		}
		result.Date = &date
	}
	if val := resp.Header.Get("ETag"); val != "" {
		result.ETag = (*azcore.ETag)(&val)
	}
	if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" {
		fileLastWriteTime, err := time.Parse(time.RFC3339Nano, val)
		if err != nil {
			return FileClientUploadRangeFromURLResponse{}, err
		}
		result.FileLastWriteTime = &fileLastWriteTime
	}
	if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" {
		isServerEncrypted, err := strconv.ParseBool(val)
		if err != nil {
			return FileClientUploadRangeFromURLResponse{}, err
		}
		result.IsServerEncrypted = &isServerEncrypted
	}
	if val := resp.Header.Get("Last-Modified"); val != "" {
		lastModified, err := time.Parse(time.RFC1123, val)
		if err != nil {
			return FileClientUploadRangeFromURLResponse{}, err
		}
		result.LastModified = &lastModified
	}
	if val := resp.Header.Get("x-ms-request-id"); val != "" {
		result.RequestID = &val
	}
	if val := resp.Header.Get("x-ms-version"); val != "" {
		result.Version = &val
	}
	if val := resp.Header.Get("x-ms-content-crc64"); val != "" {
		xMSContentCRC64, err := base64.StdEncoding.DecodeString(val)
		if err != nil {
			return FileClientUploadRangeFromURLResponse{}, err
		}
		result.XMSContentCRC64 = xMSContentCRC64
	}
	return result, nil
}
