Upgrade to service version 2020-02-10 (#47)
* Generated Code * Fixed Breaking Changes (Function Calls) * Fixed Breaking Tests * Reformatting + Added test case to check the limit of 4TiB for file and 5120GB for file share
This commit is contained in:
Родитель
68c161c838
Коммит
3c1754dc00
|
@ -47,7 +47,7 @@ func (f FileAttributeFlags) String() (out string) {
|
|||
"NoScrubData",
|
||||
}
|
||||
|
||||
for idx,flag := range attrFlags {
|
||||
for idx, flag := range attrFlags {
|
||||
if f.Has(flag) {
|
||||
out += attrStrings[idx] + "|"
|
||||
}
|
||||
|
@ -71,13 +71,13 @@ func (f FileAttributeFlags) Remove(old FileAttributeFlags) FileAttributeFlags {
|
|||
}
|
||||
|
||||
func (f FileAttributeFlags) Has(item FileAttributeFlags) bool {
|
||||
return f & item == item
|
||||
return f&item == item
|
||||
}
|
||||
|
||||
// ParseFileAttributeFlagsString parses the service-side file attribute strings that the above enum strongly types.
|
||||
func ParseFileAttributeFlagsString(input string) (out FileAttributeFlags) {
|
||||
// We don't worry about the order here, since the resulting bitflags will automagically be in order.
|
||||
attrStrings := map[string]FileAttributeFlags {
|
||||
attrStrings := map[string]FileAttributeFlags{
|
||||
"none": FileAttributeNone,
|
||||
"readonly": FileAttributeReadonly,
|
||||
"hidden": FileAttributeHidden,
|
||||
|
@ -89,7 +89,7 @@ func ParseFileAttributeFlagsString(input string) (out FileAttributeFlags) {
|
|||
"noscrubdata": FileAttributeNoScrubData,
|
||||
}
|
||||
|
||||
for _,v := range strings.Split(input, "|") {
|
||||
for _, v := range strings.Split(input, "|") {
|
||||
// We trim the space because the service returns the flags back with spaces in between the pipes
|
||||
// We also lowercase out of an abundance of caution to ensure we're getting what we think we're getting.
|
||||
key := strings.ToLower(strings.TrimSpace(v))
|
||||
|
@ -103,4 +103,4 @@ func ParseFileAttributeFlagsString(input string) (out FileAttributeFlags) {
|
|||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/Azure/azure-storage-file-go/azfile"
|
||||
)
|
||||
|
||||
type FileAttributeFlagsSuite struct{
|
||||
type FileAttributeFlagsSuite struct {
|
||||
// attributeTestList defines a list containing tests that can be used against both parsing and stringifying.
|
||||
attributeTestList map[azfile.FileAttributeFlags]string
|
||||
// parseOnlyList defines tests that should apply only to parsing,
|
||||
|
@ -25,13 +25,13 @@ var _ = chk.Suite(&FileAttributeFlagsSuite{
|
|||
|
||||
// Ensure that all attribs work
|
||||
azfile.FileAttributeReadonly.Add(
|
||||
azfile.FileAttributeHidden.Add(
|
||||
azfile.FileAttributeSystem.Add(
|
||||
azfile.FileAttributeArchive.Add(
|
||||
azfile.FileAttributeTemporary.Add(
|
||||
azfile.FileAttributeOffline.Add(
|
||||
azfile.FileAttributeNotContentIndexed.Add(
|
||||
azfile.FileAttributeNoScrubData))))))):"ReadOnly|Hidden|System|Archive|Temporary|Offline|NotContentIndexed|NoScrubData",
|
||||
azfile.FileAttributeHidden.Add(
|
||||
azfile.FileAttributeSystem.Add(
|
||||
azfile.FileAttributeArchive.Add(
|
||||
azfile.FileAttributeTemporary.Add(
|
||||
azfile.FileAttributeOffline.Add(
|
||||
azfile.FileAttributeNotContentIndexed.Add(
|
||||
azfile.FileAttributeNoScrubData))))))): "ReadOnly|Hidden|System|Archive|Temporary|Offline|NotContentIndexed|NoScrubData",
|
||||
},
|
||||
parseOnlyList: map[azfile.FileAttributeFlags]string{
|
||||
// Handle multiple but out of order.
|
||||
|
@ -44,11 +44,11 @@ var _ = chk.Suite(&FileAttributeFlagsSuite{
|
|||
func (s *FileAttributeFlagsSuite) appendMaps(a, b map[azfile.FileAttributeFlags]string) map[azfile.FileAttributeFlags]string {
|
||||
out := map[azfile.FileAttributeFlags]string{}
|
||||
|
||||
for k,v := range a {
|
||||
for k, v := range a {
|
||||
out[k] = v
|
||||
}
|
||||
|
||||
for k,v := range b {
|
||||
for k, v := range b {
|
||||
out[k] = v
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ func (s *FileAttributeFlagsSuite) TestOperations(c *chk.C) {
|
|||
}
|
||||
|
||||
func (s *FileAttributeFlagsSuite) TestParseFileAttributeFlags(c *chk.C) {
|
||||
for k,v := range s.appendMaps(s.attributeTestList, s.parseOnlyList) {
|
||||
for k, v := range s.appendMaps(s.attributeTestList, s.parseOnlyList) {
|
||||
flags := azfile.ParseFileAttributeFlagsString(v)
|
||||
|
||||
c.Assert(flags, chk.Equals, k)
|
||||
|
@ -108,7 +108,7 @@ func (s *FileAttributeFlagsSuite) TestParseFileAttributeFlags(c *chk.C) {
|
|||
}
|
||||
|
||||
func (s *FileAttributeFlagsSuite) TestStringifyFileAttributeFlags(c *chk.C) {
|
||||
for k,v := range s.attributeTestList {
|
||||
for k, v := range s.attributeTestList {
|
||||
flags := k.String()
|
||||
|
||||
c.Assert(flags, chk.Equals, v)
|
||||
|
@ -127,7 +127,7 @@ func (s *FileAttributeFlagsSuite) TestRoundTrippedFlags(c *chk.C) {
|
|||
setResp, err := fileURL.SetHTTPHeaders(
|
||||
ctx,
|
||||
azfile.FileHTTPHeaders{
|
||||
SMBProperties:azfile.SMBProperties{
|
||||
SMBProperties: azfile.SMBProperties{
|
||||
FileAttributes: &fileAttribs,
|
||||
},
|
||||
},
|
||||
|
@ -139,4 +139,4 @@ func (s *FileAttributeFlagsSuite) TestRoundTrippedFlags(c *chk.C) {
|
|||
c.Assert(azfile.ParseFileAttributeFlagsString(setResp.FileAttributes()), chk.Equals, fileAttribs)
|
||||
// Ensure that the response (once we clean spaces) equals our returned string.
|
||||
c.Assert(strings.ReplaceAll(setResp.FileAttributes(), " ", ""), chk.Equals, fileAttribs.String())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,18 +16,21 @@ const (
|
|||
// FileMaxUploadRangeBytes indicates the maximum number of bytes that can be sent in a call to UploadRange.
|
||||
FileMaxUploadRangeBytes = 4 * 1024 * 1024 // 4MB
|
||||
|
||||
// FileMaxSizeInBytes indicates the maxiumum file size, in bytes.
|
||||
FileMaxSizeInBytes int64 = 1 * 1024 * 1024 * 1024 * 1024 // 1TB
|
||||
// FileMaxSizeInBytes indicates the maximum file size, in bytes.
|
||||
//FileMaxSizeInBytes int64 = 1 * 1024 * 1024 * 1024 * 1024 // 1TB
|
||||
)
|
||||
|
||||
// For all intents and purposes, this is a constant.
|
||||
// But you can't take the address of a constant string, so it's a variable.
|
||||
// Inherit inherits permissions from the parent folder (default when creating files/folders)
|
||||
var defaultPermissionString = "inherit"
|
||||
|
||||
// Sets creation/last write times to now
|
||||
var defaultCurrentTimeString = "now"
|
||||
|
||||
// Preserves old permissions on the file/folder (default when updating properties)
|
||||
var defaultPreserveString = "preserve"
|
||||
|
||||
// Defaults for file attributes
|
||||
var defaultFileAttributes = "None"
|
||||
|
||||
|
@ -79,19 +82,29 @@ func (f FileURL) Create(ctx context.Context, size int64, h FileHTTPHeaders, meta
|
|||
|
||||
return f.fileClient.Create(ctx, size, fileAttr, fileCreateTime, FileLastWriteTime, nil,
|
||||
&h.ContentType, &h.ContentEncoding, &h.ContentLanguage, &h.CacheControl,
|
||||
h.ContentMD5, &h.ContentDisposition, metadata, permStr, permKey)
|
||||
h.ContentMD5, &h.ContentDisposition, metadata, permStr, permKey, nil)
|
||||
}
|
||||
|
||||
// StartCopy copies the data at the source URL to a file.
|
||||
// For more information, see https://docs.microsoft.com/rest/api/storageservices/copy-file.
|
||||
func (f FileURL) StartCopy(ctx context.Context, source url.URL, metadata Metadata) (*FileStartCopyResponse, error) {
|
||||
return f.fileClient.StartCopy(ctx, source.String(), nil, metadata)
|
||||
return f.fileClient.StartCopy(ctx, source.String(), nil, metadata,
|
||||
nil, // filePermission
|
||||
nil, // filePermissionKey
|
||||
PermissionCopyModeNone, //filePermissionMode
|
||||
nil, //ignoreReadOnly
|
||||
nil, //fileAttributes
|
||||
nil, //fileCreationTime
|
||||
nil, //fileLastWriteTime
|
||||
nil, //setArchiveAttribute
|
||||
nil, // leaseId
|
||||
)
|
||||
}
|
||||
|
||||
// AbortCopy stops a pending copy that was previously started and leaves a destination file with 0 length and metadata.
|
||||
// For more information, see https://docs.microsoft.com/rest/api/storageservices/abort-copy-file.
|
||||
func (f FileURL) AbortCopy(ctx context.Context, copyID string) (*FileAbortCopyResponse, error) {
|
||||
return f.fileClient.AbortCopy(ctx, copyID, nil)
|
||||
return f.fileClient.AbortCopy(ctx, copyID, nil, nil)
|
||||
}
|
||||
|
||||
// Download downloads count bytes of data from the start offset.
|
||||
|
@ -109,7 +122,7 @@ func (f FileURL) Download(ctx context.Context, offset int64, count int64, rangeG
|
|||
}
|
||||
xRangeGetContentMD5 = &rangeGetContentMD5
|
||||
}
|
||||
dr, err := f.fileClient.Download(ctx, nil, httpRange{offset: offset, count: count}.pointers(), xRangeGetContentMD5)
|
||||
dr, err := f.fileClient.Download(ctx, nil, httpRange{offset: offset, count: count}.pointers(), xRangeGetContentMD5, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -146,13 +159,13 @@ func (dr *RetryableDownloadResponse) Body(o RetryReaderOptions) io.ReadCloser {
|
|||
// Delete immediately removes the file from the storage account.
|
||||
// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-file2.
|
||||
func (f FileURL) Delete(ctx context.Context) (*FileDeleteResponse, error) {
|
||||
return f.fileClient.Delete(ctx, nil)
|
||||
return f.fileClient.Delete(ctx, nil, nil)
|
||||
}
|
||||
|
||||
// GetProperties returns the file's metadata and properties.
|
||||
// For more information, see https://docs.microsoft.com/rest/api/storageservices/get-file-properties.
|
||||
func (f FileURL) GetProperties(ctx context.Context) (*FileGetPropertiesResponse, error) {
|
||||
return f.fileClient.GetProperties(ctx, nil, nil)
|
||||
return f.fileClient.GetProperties(ctx, nil, nil, nil)
|
||||
}
|
||||
|
||||
// SetHTTPHeaders sets file's system properties.
|
||||
|
@ -166,13 +179,13 @@ func (f FileURL) SetHTTPHeaders(ctx context.Context, h FileHTTPHeaders) (*FileSe
|
|||
|
||||
return f.fileClient.SetHTTPHeaders(ctx, fileAttr, fileCreateTime, FileLastWriteTime, nil,
|
||||
nil, &h.ContentType, &h.ContentEncoding, &h.ContentLanguage, &h.CacheControl, h.ContentMD5,
|
||||
&h.ContentDisposition, permStr, permKey)
|
||||
&h.ContentDisposition, permStr, permKey, nil)
|
||||
}
|
||||
|
||||
// SetMetadata sets a file's metadata.
|
||||
// https://docs.microsoft.com/rest/api/storageservices/set-file-metadata.
|
||||
func (f FileURL) SetMetadata(ctx context.Context, metadata Metadata) (*FileSetMetadataResponse, error) {
|
||||
return f.fileClient.SetMetadata(ctx, nil, metadata)
|
||||
return f.fileClient.SetMetadata(ctx, nil, metadata, nil)
|
||||
}
|
||||
|
||||
// Resize resizes the file to the specified size.
|
||||
|
@ -180,7 +193,7 @@ func (f FileURL) SetMetadata(ctx context.Context, metadata Metadata) (*FileSetMe
|
|||
func (f FileURL) Resize(ctx context.Context, length int64) (*FileSetHTTPHeadersResponse, error) {
|
||||
return f.fileClient.SetHTTPHeaders(ctx, "preserve", "preserve", "preserve", nil,
|
||||
&length, nil, nil, nil, nil,
|
||||
nil, nil, &defaultPreserveString, nil)
|
||||
nil, nil, &defaultPreserveString, nil, nil)
|
||||
}
|
||||
|
||||
// UploadRange writes bytes to a file.
|
||||
|
@ -197,7 +210,7 @@ func (f FileURL) UploadRange(ctx context.Context, offset int64, body io.ReadSeek
|
|||
}
|
||||
|
||||
// TransactionalContentMD5 isn't supported currently.
|
||||
return f.fileClient.UploadRange(ctx, *toRange(offset, count), FileRangeWriteUpdate, count, body, nil, transactionalMD5)
|
||||
return f.fileClient.UploadRange(ctx, *toRange(offset, count), FileRangeWriteUpdate, count, body, nil, transactionalMD5, nil)
|
||||
}
|
||||
|
||||
// Update range with bytes from a specific URL.
|
||||
|
@ -206,12 +219,12 @@ func (f FileURL) UploadRangeFromURL(ctx context.Context, sourceURL url.URL, sour
|
|||
count int64) (*FileUploadRangeFromURLResponse, error) {
|
||||
|
||||
return f.fileClient.UploadRangeFromURL(ctx, *toRange(destOffset, count), sourceURL.String(), 0, nil,
|
||||
toRange(sourceOffset, count), nil, nil, nil)
|
||||
toRange(sourceOffset, count), nil, nil, nil, nil)
|
||||
}
|
||||
|
||||
// ClearRange clears the specified range and releases the space used in storage for that range.
|
||||
// offset means the start offset of the range to clear.
|
||||
// count means count of bytes to clean, it cannot be CountToEnd (0), and must be explictly specified.
|
||||
// count means count of bytes to clean, it cannot be CountToEnd (0), and must be explicitly specified.
|
||||
// If the range specified is not 512-byte aligned, the operation will write zeros to
|
||||
// the start or end of the range that is not 512-byte aligned and free the rest of the range inside that is 512-byte aligned.
|
||||
// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/put-range.
|
||||
|
@ -220,12 +233,18 @@ func (f FileURL) ClearRange(ctx context.Context, offset int64, count int64) (*Fi
|
|||
return nil, errors.New("invalid argument, count cannot be CountToEnd, and must be > 0")
|
||||
}
|
||||
|
||||
return f.fileClient.UploadRange(ctx, *toRange(offset, count), FileRangeWriteClear, 0, nil, nil, nil)
|
||||
return f.fileClient.UploadRange(ctx, *toRange(offset, count), FileRangeWriteClear, 0, nil, nil, nil, nil)
|
||||
}
|
||||
|
||||
// GetRangeList returns the list of valid ranges for a file.
|
||||
// Use a count with value CountToEnd (0) to indicate the left part of file start from offset.
|
||||
// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/list-ranges.
|
||||
func (f FileURL) GetRangeList(ctx context.Context, offset int64, count int64) (*Ranges, error) {
|
||||
return f.fileClient.GetRangeList(ctx, nil, nil, httpRange{offset: offset, count: count}.pointers())
|
||||
func (f FileURL) GetRangeList(ctx context.Context, offset int64, count int64) (*ShareFileRangeList, error) {
|
||||
return f.fileClient.GetRangeList(ctx,
|
||||
nil, // sharesnapshot
|
||||
nil, //prevsharesnapshot
|
||||
nil, // timeout
|
||||
nil, //rangeParameters
|
||||
nil, // leaseID
|
||||
)
|
||||
}
|
||||
|
|
|
@ -185,9 +185,11 @@ func (mp MetricProperties) toM() *Metrics {
|
|||
// GetProperties returns the properties of the File service.
|
||||
// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-service-properties.
|
||||
func (s ServiceURL) GetProperties(ctx context.Context) (*FileServiceProperties, error) {
|
||||
ssp, error := s.client.GetProperties(ctx, nil)
|
||||
|
||||
return ssp.toFsp(), error
|
||||
ssp, err := s.client.GetProperties(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ssp.toFsp(), err
|
||||
}
|
||||
|
||||
// SetProperties sets the properties of the File service.
|
||||
|
|
|
@ -71,7 +71,7 @@ func (s ShareURL) Create(ctx context.Context, metadata Metadata, quotaInGB int32
|
|||
if quotaInGB != 0 {
|
||||
quota = "aInGB
|
||||
}
|
||||
return s.shareClient.Create(ctx, nil, metadata, quota)
|
||||
return s.shareClient.Create(ctx, nil, metadata, quota, ShareAccessTierNone)
|
||||
}
|
||||
|
||||
// CreateSnapshot creates a read-only snapshot of a share.
|
||||
|
@ -84,36 +84,36 @@ func (s ShareURL) CreateSnapshot(ctx context.Context, metadata Metadata) (*Share
|
|||
// The share or share snapshot and any files contained within it are later deleted during garbage collection.
|
||||
// For more information, see https://docs.microsoft.com/rest/api/storageservices/delete-share.
|
||||
func (s ShareURL) Delete(ctx context.Context, deleteSnapshotsOption DeleteSnapshotsOptionType) (*ShareDeleteResponse, error) {
|
||||
return s.shareClient.Delete(ctx, nil, nil, deleteSnapshotsOption)
|
||||
return s.shareClient.Delete(ctx, nil, nil, deleteSnapshotsOption, nil)
|
||||
}
|
||||
|
||||
// GetProperties returns all user-defined metadata and system properties for the specified share or share snapshot.
|
||||
// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-properties.
|
||||
func (s ShareURL) GetProperties(ctx context.Context) (*ShareGetPropertiesResponse, error) {
|
||||
return s.shareClient.GetProperties(ctx, nil, nil)
|
||||
return s.shareClient.GetProperties(ctx, nil, nil, nil)
|
||||
}
|
||||
|
||||
// SetQuota sets service-defined properties for the specified share.
|
||||
// SetProperties sets service-defined properties for the specified share.
|
||||
// quotaInGB specifies the maximum size of the share in gigabytes, 0 means no quote and uses service's default value.
|
||||
// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-properties.
|
||||
func (s ShareURL) SetQuota(ctx context.Context, quotaInGB int32) (*ShareSetQuotaResponse, error) {
|
||||
func (s ShareURL) SetProperties(ctx context.Context, quotaInGB int32) (*ShareSetPropertiesResponse, error) {
|
||||
var quota *int32
|
||||
if quotaInGB != 0 {
|
||||
quota = "aInGB
|
||||
}
|
||||
return s.shareClient.SetQuota(ctx, nil, quota)
|
||||
return s.shareClient.SetProperties(ctx, nil, quota, ShareAccessTierNone, nil)
|
||||
}
|
||||
|
||||
// SetMetadata sets the share's metadata.
|
||||
// For more information, see https://docs.microsoft.com/rest/api/storageservices/set-share-metadata.
|
||||
func (s ShareURL) SetMetadata(ctx context.Context, metadata Metadata) (*ShareSetMetadataResponse, error) {
|
||||
return s.shareClient.SetMetadata(ctx, nil, metadata)
|
||||
return s.shareClient.SetMetadata(ctx, nil, metadata, nil)
|
||||
}
|
||||
|
||||
// GetPermissions returns information about stored access policies specified on the share.
|
||||
// For more information, see https://docs.microsoft.com/rest/api/storageservices/get-share-acl.
|
||||
func (s ShareURL) GetPermissions(ctx context.Context) (*SignedIdentifiers, error) {
|
||||
return s.shareClient.GetAccessPolicy(ctx, nil)
|
||||
return s.shareClient.GetAccessPolicy(ctx, nil, nil)
|
||||
}
|
||||
|
||||
// CreatePermission uploads a SDDL permission string, and returns a permission key to use in conjunction with a file or folder.
|
||||
|
@ -172,11 +172,11 @@ func (p *AccessPolicyPermission) Parse(s string) {
|
|||
// SetPermissions sets a stored access policy for use with shared access signatures.
|
||||
// For more information, see https://docs.microsoft.com/rest/api/storageservices/set-share-acl.
|
||||
func (s ShareURL) SetPermissions(ctx context.Context, permissions []SignedIdentifier) (*ShareSetAccessPolicyResponse, error) {
|
||||
return s.shareClient.SetAccessPolicy(ctx, permissions, nil)
|
||||
return s.shareClient.SetAccessPolicy(ctx, permissions, nil, nil)
|
||||
}
|
||||
|
||||
// GetStatistics retrieves statistics related to the share.
|
||||
// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-stats.
|
||||
func (s ShareURL) GetStatistics(ctx context.Context) (*ShareStats, error) {
|
||||
return s.shareClient.GetStatistics(ctx, nil)
|
||||
return s.shareClient.GetStatistics(ctx, nil, nil)
|
||||
}
|
||||
|
|
|
@ -39,6 +39,5 @@ func NewPipeline(c Credential, o PipelineOptions) pipeline.Pipeline {
|
|||
NewRequestLogPolicyFactory(o.RequestLog),
|
||||
pipeline.MethodFactoryMarker()) // indicates at what stage in the pipeline the method factory is invoked
|
||||
|
||||
|
||||
return pipeline.NewPipeline(f, pipeline.Options{HTTPSender: nil, Log: o.Log})
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ type RetryReaderOptions struct {
|
|||
MaxRetryRequests int
|
||||
doInjectError bool
|
||||
doInjectErrorRound int
|
||||
injectedError error
|
||||
injectedError error
|
||||
|
||||
// NotifyFailedRead is called, if non-nil, after any failure to read. Expected usage is diagnostic logging.
|
||||
NotifyFailedRead FailedReadNotifier
|
||||
|
|
|
@ -36,6 +36,7 @@ func FormatTimesForSASSigning(startTime, expiryTime time.Time) (string, string)
|
|||
}
|
||||
|
||||
const SASTimeFormat = "2006-01-02T15:04:05Z"
|
||||
|
||||
// SASTimeFormats represents the format of a SAS start or expiry time. Use it when formatting/parsing a time.Time.
|
||||
var SASTimeFormats = []string{"2006-01-02T15:04:05.0000000Z", SASTimeFormat, "2006-01-02T15:04Z", "2006-01-02"} // ISO 8601 formats, please refer to https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas for more details.
|
||||
|
||||
|
|
|
@ -496,10 +496,10 @@ func ExampleShareURL_SetQuota() {
|
|||
// Check current usage stats for the share.
|
||||
// Note that the ShareStats object is part of the protocol layer for the File service.
|
||||
if statistics, err := shareURL.GetStatistics(ctx); err == nil {
|
||||
shareUsageGB := statistics.ShareUsageBytes/1024/1024/1024
|
||||
shareUsageGB := statistics.ShareUsageBytes / 1024 / 1024 / 1024
|
||||
fmt.Printf("Current share usage: %d GB\n", shareUsageGB)
|
||||
|
||||
shareURL.SetQuota(ctx, 10+shareUsageGB)
|
||||
shareURL.SetProperties(ctx, 10+shareUsageGB)
|
||||
|
||||
properties, err := shareURL.GetProperties(ctx)
|
||||
if err != nil {
|
||||
|
|
|
@ -344,4 +344,4 @@ func (s *ParsingURLSuite) TestFileURLPartsSASQueryTimes(c *chk.C) {
|
|||
uResult := parts.URL()
|
||||
c.Assert(uResult.String(), chk.Equals, urlString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ func createNewFileFromShareWithPermissions(c *chk.C, share azfile.ShareURL, file
|
|||
|
||||
file, name = getFileURLFromDirectory(c, dir)
|
||||
|
||||
cResp, err := file.Create(ctx, fileSize, azfile.FileHTTPHeaders{SMBProperties:azfile.SMBProperties{
|
||||
cResp, err := file.Create(ctx, fileSize, azfile.FileHTTPHeaders{SMBProperties: azfile.SMBProperties{
|
||||
PermissionString: &sampleSDDL,
|
||||
}}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
|
|
@ -121,7 +121,7 @@ func (s *DirectoryURLSuite) TestDirCreateDeleteNonDefault(c *chk.C) {
|
|||
"bar": "bArvaLue",
|
||||
}
|
||||
|
||||
cResp, err := directory.Create(context.Background(), md, azfile.SMBProperties{ PermissionString: &sampleSDDL })
|
||||
cResp, err := directory.Create(context.Background(), md, azfile.SMBProperties{PermissionString: &sampleSDDL})
|
||||
c.Assert(err, chk.IsNil)
|
||||
// Ensure that the file key isn't empty, but don't worry about checking the permission. We just need to know it exists.
|
||||
c.Assert(cResp.FilePermissionKey(), chk.Not(chk.Equals), "")
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -22,7 +23,9 @@ type FileURLSuite struct{}
|
|||
var _ = chk.Suite(&FileURLSuite{})
|
||||
|
||||
const (
|
||||
testFileRangeSize = 512 // Use this number considering clear range's function
|
||||
testFileRangeSize = 512 // Use this number considering clear range's function
|
||||
fileShareMaxQuota = 5120 // Size is in GB (Service Version 2020-02-10)
|
||||
fileMaxAllowedSizeInBytes = 4398046511104 // 4 TiB (Service Version 2020-02-10)
|
||||
)
|
||||
|
||||
func delFile(c *chk.C, file azfile.FileURL) {
|
||||
|
@ -160,7 +163,7 @@ func (s *FileURLSuite) TestFileGetSetPropertiesNonDefault(c *chk.C) {
|
|||
|
||||
attribs := azfile.FileAttributeTemporary.Add(azfile.FileAttributeHidden)
|
||||
creationTime := time.Now().Add(-time.Hour)
|
||||
lastWriteTime := time.Now().Add(-time.Minute*15)
|
||||
lastWriteTime := time.Now().Add(-time.Minute * 15)
|
||||
|
||||
// Format and re-parse the times so we have the same precision
|
||||
creationTime, err := time.Parse(azfile.ISO8601, creationTime.Format(azfile.ISO8601))
|
||||
|
@ -177,8 +180,8 @@ func (s *FileURLSuite) TestFileGetSetPropertiesNonDefault(c *chk.C) {
|
|||
ContentDisposition: "attachment",
|
||||
SMBProperties: azfile.SMBProperties{
|
||||
PermissionString: &sampleSDDL, // Because our permission string is less than 9KB, it can be used here.
|
||||
FileAttributes: &attribs,
|
||||
FileCreationTime: &creationTime,
|
||||
FileAttributes: &attribs,
|
||||
FileCreationTime: &creationTime,
|
||||
FileLastWriteTime: &lastWriteTime,
|
||||
},
|
||||
}
|
||||
|
@ -253,7 +256,7 @@ func (s *FileURLSuite) TestFilePreservePermissions(c *chk.C) {
|
|||
ContentMD5: testMd5,
|
||||
CacheControl: "no-transform",
|
||||
ContentDisposition: "attachment",
|
||||
SMBProperties: azfile.SMBProperties{
|
||||
SMBProperties: azfile.SMBProperties{
|
||||
// SMBProperties, when options are left nil, leads to preserving.
|
||||
},
|
||||
}
|
||||
|
@ -797,7 +800,7 @@ func (s *FileURLSuite) TestFileResizeInvalidSizeNegative(c *chk.C) {
|
|||
|
||||
_, err := fileURL.Resize(ctx, -4)
|
||||
c.Assert(err, chk.NotNil)
|
||||
sErr := (err.(azfile.StorageError))
|
||||
sErr := err.(azfile.StorageError)
|
||||
c.Assert(sErr.Response().StatusCode, chk.Equals, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
@ -1309,8 +1312,8 @@ func (s *FileURLSuite) TestGetRangeListNonDefaultExact(c *chk.C) {
|
|||
c.Assert(rangeList.RequestID(), chk.Not(chk.Equals), "")
|
||||
c.Assert(rangeList.Version(), chk.Not(chk.Equals), "")
|
||||
c.Assert(rangeList.Date().IsZero(), chk.Equals, false)
|
||||
c.Assert(rangeList.Items, chk.HasLen, 1)
|
||||
c.Assert(rangeList.Items[0], chk.DeepEquals, azfile.Range{Start: 0, End: 1022})
|
||||
c.Assert(rangeList.Ranges, chk.HasLen, 1)
|
||||
c.Assert(rangeList.Ranges[0], chk.DeepEquals, azfile.FileRange{XMLName: xml.Name{Space: "", Local: "Range"}, Start: 0, End: 1023})
|
||||
}
|
||||
|
||||
// Default means clear the entire file's range
|
||||
|
@ -1331,7 +1334,7 @@ func (s *FileURLSuite) TestClearRangeDefault(c *chk.C) {
|
|||
|
||||
rangeList, err := fileURL.GetRangeList(context.Background(), 0, azfile.CountToEnd)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(rangeList.Items, chk.HasLen, 0)
|
||||
c.Assert(rangeList.Ranges, chk.HasLen, 0)
|
||||
}
|
||||
|
||||
func (s *FileURLSuite) TestClearRangeNonDefault(c *chk.C) {
|
||||
|
@ -1351,7 +1354,7 @@ func (s *FileURLSuite) TestClearRangeNonDefault(c *chk.C) {
|
|||
|
||||
rangeList, err := fileURL.GetRangeList(context.Background(), 0, azfile.CountToEnd)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(rangeList.Items, chk.HasLen, 0)
|
||||
c.Assert(rangeList.Ranges, chk.HasLen, 0)
|
||||
}
|
||||
|
||||
func (s *FileURLSuite) TestClearRangeMultipleRanges(c *chk.C) {
|
||||
|
@ -1371,8 +1374,8 @@ func (s *FileURLSuite) TestClearRangeMultipleRanges(c *chk.C) {
|
|||
|
||||
rangeList, err := fileURL.GetRangeList(context.Background(), 0, azfile.CountToEnd)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(rangeList.Items, chk.HasLen, 1)
|
||||
c.Assert(rangeList.Items[0], chk.DeepEquals, azfile.Range{Start: 0, End: 1023})
|
||||
c.Assert(rangeList.Ranges, chk.HasLen, 1)
|
||||
c.Assert(rangeList.Ranges[0], chk.DeepEquals, azfile.FileRange{XMLName: xml.Name{Space: "", Local: "Range"}, Start: 0, End: 1023})
|
||||
}
|
||||
|
||||
// When not 512 aligned, clear range will set 0 the non-512 aligned range, and will not eliminate the range.
|
||||
|
@ -1394,8 +1397,8 @@ func (s *FileURLSuite) TestClearRangeNonDefault1Count(c *chk.C) {
|
|||
|
||||
rangeList, err := fileURL.GetRangeList(context.Background(), 0, azfile.CountToEnd)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(rangeList.Items, chk.HasLen, 1)
|
||||
c.Assert(rangeList.Items[0], chk.DeepEquals, azfile.Range{Start: 0, End: 0})
|
||||
c.Assert(rangeList.Ranges, chk.HasLen, 1)
|
||||
c.Assert(rangeList.Ranges[0], chk.DeepEquals, azfile.FileRange{XMLName: xml.Name{Space: "", Local: "Range"}, Start: 0, End: 0})
|
||||
|
||||
dResp, err := fileURL.Download(ctx, 0, azfile.CountToEnd, false)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
@ -1436,10 +1439,10 @@ func setupGetRangeListTest(c *chk.C) (shareURL azfile.ShareURL, fileURL azfile.F
|
|||
return
|
||||
}
|
||||
|
||||
func validateBasicGetRangeList(c *chk.C, resp *azfile.Ranges, err error) {
|
||||
func validateBasicGetRangeList(c *chk.C, resp *azfile.ShareFileRangeList, err error) {
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Items, chk.HasLen, 1)
|
||||
c.Assert(resp.Items[0], chk.Equals, azfile.Range{Start: 0, End: testFileRangeSize - 1})
|
||||
c.Assert(resp.Ranges, chk.HasLen, 1)
|
||||
c.Assert(resp.Ranges[0], chk.Equals, azfile.FileRange{XMLName: xml.Name{Space: "", Local: "Range"}, Start: 0, End: testFileRangeSize - 1})
|
||||
}
|
||||
|
||||
func (s *FileURLSuite) TestFileGetRangeListDefaultEmptyFile(c *chk.C) {
|
||||
|
@ -1450,7 +1453,7 @@ func (s *FileURLSuite) TestFileGetRangeListDefaultEmptyFile(c *chk.C) {
|
|||
|
||||
resp, err := fileURL.GetRangeList(ctx, 0, azfile.CountToEnd)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Items, chk.HasLen, 0)
|
||||
c.Assert(resp.Ranges, chk.HasLen, 0)
|
||||
}
|
||||
|
||||
func (s *FileURLSuite) TestFileGetRangeListDefault1Range(c *chk.C) {
|
||||
|
@ -1472,9 +1475,9 @@ func (s *FileURLSuite) TestFileGetRangeListNonContiguousRanges(c *chk.C) {
|
|||
c.Assert(err, chk.IsNil)
|
||||
resp, err := fileURL.GetRangeList(ctx, 0, azfile.CountToEnd)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Items, chk.HasLen, 2)
|
||||
c.Assert(resp.Items[0], chk.Equals, azfile.Range{Start: 0, End: testFileRangeSize - 1})
|
||||
c.Assert(resp.Items[1], chk.Equals, azfile.Range{Start: testFileRangeSize * 2, End: (testFileRangeSize * 3) - 1})
|
||||
c.Assert(resp.Ranges, chk.HasLen, 2)
|
||||
c.Assert(resp.Ranges[0], chk.Equals, azfile.FileRange{XMLName: xml.Name{Space: "", Local: "Range"}, Start: 0, End: testFileRangeSize - 1})
|
||||
c.Assert(resp.Ranges[1], chk.Equals, azfile.FileRange{XMLName: xml.Name{Space: "", Local: "Range"}, Start: testFileRangeSize * 2, End: (testFileRangeSize * 3) - 1})
|
||||
}
|
||||
|
||||
func (s *FileURLSuite) TestFileGetRangeListNonContiguousRangesCountLess(c *chk.C) {
|
||||
|
@ -1483,8 +1486,8 @@ func (s *FileURLSuite) TestFileGetRangeListNonContiguousRangesCountLess(c *chk.C
|
|||
|
||||
resp, err := fileURL.GetRangeList(ctx, 0, testFileRangeSize-1)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Items, chk.HasLen, 1)
|
||||
c.Assert(resp.Items[0], chk.Equals, azfile.Range{Start: 0, End: testFileRangeSize - 2})
|
||||
c.Assert(resp.Ranges, chk.HasLen, 1)
|
||||
c.Assert(resp.Ranges[0], chk.Equals, azfile.FileRange{XMLName: xml.Name{Space: "", Local: "Range"}, Start: 0, End: testFileRangeSize - 1})
|
||||
}
|
||||
|
||||
func (s *FileURLSuite) TestFileGetRangeListNonContiguousRangesCountExceed(c *chk.C) {
|
||||
|
@ -1539,24 +1542,18 @@ func (s *FileURLSuite) TestUnexpectedEOFRecovery(c *chk.C) {
|
|||
c.Assert(buf, chk.DeepEquals, contentD)
|
||||
}
|
||||
|
||||
// Don't check offset by design.
|
||||
// func (s *FileURLSuite) TestFileGetRangeListNegativeInvalidOffset(c *chk.C) {
|
||||
// fsu := getFSU()
|
||||
// shareURL, _ := getShareURL(c, fsu)
|
||||
// fileURL, _ := getFileURLFromShare(c, shareURL)
|
||||
func (s *FileURLSuite) TestCreateMaximumSizeFileShare(c *chk.C) {
|
||||
fsu := getFSU()
|
||||
share, _ := getShareURL(c, fsu)
|
||||
cResp, err := share.Create(ctx, nil, fileShareMaxQuota)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(cResp.StatusCode(), chk.Equals, 201)
|
||||
defer delShare(c, share, azfile.DeleteSnapshotsOptionInclude)
|
||||
dir := share.NewRootDirectoryURL()
|
||||
|
||||
// _, err := fileURL.GetRangeList(ctx, -2, 500)
|
||||
// c.Assert(err, chk.NotNil)
|
||||
// c.Assert(strings.Contains(err.Error(), "offset must be >= 0"), chk.Equals, true)
|
||||
// }
|
||||
file, _ := getFileURLFromDirectory(c, dir)
|
||||
|
||||
// Don't check count by design.
|
||||
// func (s *FileURLSuite) TestFileGetRangeListNegativeInvalidCount(c *chk.C) {
|
||||
// fsu := getFSU()
|
||||
// shareURL, _ := getShareURL(c, fsu)
|
||||
// fileURL, _ := getFileURLFromShare(c, shareURL)
|
||||
|
||||
// _, err := fileURL.GetRangeList(ctx, 0, -3)
|
||||
// c.Assert(err, chk.NotNil)
|
||||
// c.Assert(strings.Contains(err.Error(), "count must be >= 0"), chk.Equals, true)
|
||||
// }
|
||||
_, err = file.Create(ctx, fileMaxAllowedSizeInBytes, azfile.FileHTTPHeaders{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(cResp.StatusCode(), chk.Equals, 201)
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ func (s *StorageAccountSuite) TestAccountGetSetPropertiesNonDefaultWithEnable(c
|
|||
RetentionDays: 2,
|
||||
},
|
||||
Cors: []azfile.CorsRule{
|
||||
azfile.CorsRule{
|
||||
{
|
||||
AllowedOrigins: "*",
|
||||
AllowedMethods: "PUT",
|
||||
AllowedHeaders: "x-ms-client-request-id",
|
||||
|
@ -127,7 +127,7 @@ func (s *StorageAccountSuite) TestAccountGetSetPropertiesNonDefaultWithEnable(c
|
|||
RetentionDays: 2,
|
||||
})
|
||||
c.Assert(props.Cors, chk.DeepEquals, []azfile.CorsRule{
|
||||
azfile.CorsRule{
|
||||
{
|
||||
AllowedOrigins: "*",
|
||||
AllowedMethods: "PUT",
|
||||
AllowedHeaders: "x-ms-client-request-id",
|
||||
|
|
|
@ -41,12 +41,12 @@ func (s *ShareURLSuite) TestPutAndGetPermission(c *chk.C) {
|
|||
|
||||
getResp, err := shareURL.GetPermission(ctx, createResp.FilePermissionKey())
|
||||
c.Assert(err, chk.IsNil)
|
||||
// Rather than checking against the original, we check for emptiness, as Azure Files has set a nilness flag on SACLs
|
||||
// Rather than checking against the original, we check for emptiness, as Azure Files has set a nil-ness flag on SACLs
|
||||
// and converted our well-known SID.
|
||||
/*
|
||||
Expected :string = "O:S-1-5-32-548G:S-1-5-21-397955417-626881126-188441444-512D:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
|
||||
Actual :string = "O:AOG:S-1-5-21-397955417-626881126-188441444-512D:(A;;CCDCLCSWRPWPRCWDWOGA;;;S-1-0-0)S:NO_ACCESS_CONTROL"
|
||||
*/
|
||||
Expected :string = "O:S-1-5-32-548G:S-1-5-21-397955417-626881126-188441444-512D:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
|
||||
Actual :string = "O:AOG:S-1-5-21-397955417-626881126-188441444-512D:(A;;CCDCLCSWRPWPRCWDWOGA;;;S-1-0-0)S:NO_ACCESS_CONTROL"
|
||||
*/
|
||||
c.Assert(getResp.Permission, chk.Not(chk.Equals), "")
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ func (s *ShareURLSuite) TestShareCreateNegativeInvalidMetadata(c *chk.C) {
|
|||
c.Assert(err, chk.NotNil)
|
||||
}
|
||||
|
||||
func (s *ShareURLSuite) TestShareDeleteNegativeNonExistant(c *chk.C) {
|
||||
func (s *ShareURLSuite) TestShareDeleteNegativeNonExistent(c *chk.C) {
|
||||
fsu := getFSU()
|
||||
shareURL, _ := getShareURL(c, fsu)
|
||||
|
||||
|
@ -168,7 +168,7 @@ func (s *ShareURLSuite) TestShareGetSetPropertiesNonDefault(c *chk.C) {
|
|||
|
||||
newQuota := int32(1234)
|
||||
|
||||
sResp, err := share.SetQuota(ctx, newQuota)
|
||||
sResp, err := share.SetProperties(ctx, newQuota)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(sResp.Response().StatusCode, chk.Equals, 200)
|
||||
c.Assert(sResp.ETag(), chk.Not(chk.Equals), azfile.ETagNone)
|
||||
|
@ -193,7 +193,7 @@ func (s *ShareURLSuite) TestShareGetSetPropertiesDefault(c *chk.C) {
|
|||
share, _ := createNewShare(c, fsu)
|
||||
defer delShare(c, share, azfile.DeleteSnapshotsOptionNone)
|
||||
|
||||
sResp, err := share.SetQuota(ctx, 0)
|
||||
sResp, err := share.SetProperties(ctx, 0)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(sResp.Response().StatusCode, chk.Equals, 200)
|
||||
c.Assert(sResp.ETag(), chk.Not(chk.Equals), azfile.ETagNone)
|
||||
|
@ -218,7 +218,7 @@ func (s *ShareURLSuite) TestShareSetQuotaNegative(c *chk.C) {
|
|||
share, _ := createNewShare(c, fsu)
|
||||
defer delShare(c, share, azfile.DeleteSnapshotsOptionNone)
|
||||
|
||||
_, err := share.SetQuota(ctx, -1)
|
||||
_, err := share.SetProperties(ctx, -1)
|
||||
c.Assert(err, chk.NotNil)
|
||||
c.Assert(strings.Contains(err.Error(), validationErrorSubstring), chk.Equals, true)
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ func (s *ShareURLSuite) TestShareSetPermissionsDeleteAllPolicies(c *chk.C) {
|
|||
c.Assert(resp.Items, chk.HasLen, 0)
|
||||
}
|
||||
|
||||
// Note: No error happend
|
||||
// Note: No error happened
|
||||
func (s *ShareURLSuite) TestShareSetPermissionsNegativeInvalidPolicyTimes(c *chk.C) {
|
||||
fsu := getFSU()
|
||||
shareURL, _ := createNewShare(c, fsu)
|
||||
|
@ -582,7 +582,7 @@ func (s *ShareURLSuite) TestShareGetStats(c *chk.C) {
|
|||
newQuota := int32(300)
|
||||
|
||||
// In order to test and get LastModified property.
|
||||
sResp, err := share.SetQuota(context.Background(), newQuota)
|
||||
sResp, err := share.SetProperties(context.Background(), newQuota)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(sResp.Response().StatusCode, chk.Equals, 200)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
const (
|
||||
// ServiceVersion specifies the version of the operations used in this package.
|
||||
ServiceVersion = "2019-02-02"
|
||||
ServiceVersion = "2020-02-10"
|
||||
)
|
||||
|
||||
// managementClient is the base client for Azfile.
|
||||
|
|
|
@ -149,7 +149,7 @@ func (client directoryClient) deleteResponder(resp pipeline.Response) (pipeline.
|
|||
|
||||
// ForceCloseHandles closes all handles open for given directory.
|
||||
//
|
||||
// handleID is specifies handle ID opened on the file or directory to be closed. Asterix (‘*’) is a wildcard that
|
||||
// handleID is specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard that
|
||||
// specifies all handles. timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> marker is a string value that identifies the portion of the list to be
|
||||
|
|
|
@ -30,15 +30,16 @@ func newFileClient(url url.URL, p pipeline.Pipeline) fileClient {
|
|||
// copyID is the copy identifier provided in the x-ms-copy-id header of the original Copy File operation. timeout is
|
||||
// the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a>
|
||||
func (client fileClient) AbortCopy(ctx context.Context, copyID string, timeout *int32) (*FileAbortCopyResponse, error) {
|
||||
// Timeouts for File Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID.
|
||||
func (client fileClient) AbortCopy(ctx context.Context, copyID string, timeout *int32, leaseID *string) (*FileAbortCopyResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.abortCopyPreparer(copyID, timeout)
|
||||
req, err := client.abortCopyPreparer(copyID, timeout, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -50,7 +51,7 @@ func (client fileClient) AbortCopy(ctx context.Context, copyID string, timeout *
|
|||
}
|
||||
|
||||
// abortCopyPreparer prepares the AbortCopy request.
|
||||
func (client fileClient) abortCopyPreparer(copyID string, timeout *int32) (pipeline.Request, error) {
|
||||
func (client fileClient) abortCopyPreparer(copyID string, timeout *int32, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -64,6 +65,9 @@ func (client fileClient) abortCopyPreparer(copyID string, timeout *int32) (pipel
|
|||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-copy-action", "abort")
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -78,9 +82,198 @@ func (client fileClient) abortCopyResponder(resp pipeline.Response) (pipeline.Re
|
|||
return &FileAbortCopyResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// AcquireLease [Update] The Lease File operation establishes and manages a lock on a file for write and delete
|
||||
// operations
|
||||
//
|
||||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> duration is specifies the duration of the lease, in seconds, or negative
|
||||
// one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration
|
||||
// cannot be changed using renew or change. proposedLeaseID is proposed lease ID, in a GUID string format. The File
|
||||
// service returns 400 (Invalid request) if the proposed lease ID is not in the correct format. See Guid Constructor
|
||||
// (String) for a list of valid GUID string formats. requestID is provides a client-generated, opaque value with a 1 KB
|
||||
// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
|
||||
func (client fileClient) AcquireLease(ctx context.Context, timeout *int32, duration *int32, proposedLeaseID *string, requestID *string) (*FileAcquireLeaseResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.acquireLeasePreparer(timeout, duration, proposedLeaseID, requestID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.acquireLeaseResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*FileAcquireLeaseResponse), err
|
||||
}
|
||||
|
||||
// acquireLeasePreparer prepares the AcquireLease request.
|
||||
func (client fileClient) acquireLeasePreparer(timeout *int32, duration *int32, proposedLeaseID *string, requestID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
}
|
||||
params := req.URL.Query()
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
params.Set("comp", "lease")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
if duration != nil {
|
||||
req.Header.Set("x-ms-lease-duration", strconv.FormatInt(int64(*duration), 10))
|
||||
}
|
||||
if proposedLeaseID != nil {
|
||||
req.Header.Set("x-ms-proposed-lease-id", *proposedLeaseID)
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if requestID != nil {
|
||||
req.Header.Set("x-ms-client-request-id", *requestID)
|
||||
}
|
||||
req.Header.Set("x-ms-lease-action", "acquire")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// acquireLeaseResponder handles the response to the AcquireLease request.
|
||||
func (client fileClient) acquireLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK, http.StatusCreated)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &FileAcquireLeaseResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// BreakLease [Update] The Lease File operation establishes and manages a lock on a file for write and delete
|
||||
// operations
|
||||
//
|
||||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID. requestID is provides a client-generated, opaque value with a 1 KB character
|
||||
// limit that is recorded in the analytics logs when storage analytics logging is enabled.
|
||||
func (client fileClient) BreakLease(ctx context.Context, timeout *int32, leaseID *string, requestID *string) (*FileBreakLeaseResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.breakLeasePreparer(timeout, leaseID, requestID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.breakLeaseResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*FileBreakLeaseResponse), err
|
||||
}
|
||||
|
||||
// breakLeasePreparer prepares the BreakLease request.
|
||||
func (client fileClient) breakLeasePreparer(timeout *int32, leaseID *string, requestID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
}
|
||||
params := req.URL.Query()
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
params.Set("comp", "lease")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if requestID != nil {
|
||||
req.Header.Set("x-ms-client-request-id", *requestID)
|
||||
}
|
||||
req.Header.Set("x-ms-lease-action", "break")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// breakLeaseResponder handles the response to the BreakLease request.
|
||||
func (client fileClient) breakLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK, http.StatusAccepted)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &FileBreakLeaseResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// ChangeLease [Update] The Lease File operation establishes and manages a lock on a file for write and delete
|
||||
// operations
|
||||
//
|
||||
// leaseID is specifies the current lease ID on the resource. timeout is the timeout parameter is expressed in seconds.
|
||||
// For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> proposedLeaseID is proposed lease ID, in a GUID string format. The File
|
||||
// service returns 400 (Invalid request) if the proposed lease ID is not in the correct format. See Guid Constructor
|
||||
// (String) for a list of valid GUID string formats. requestID is provides a client-generated, opaque value with a 1 KB
|
||||
// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
|
||||
func (client fileClient) ChangeLease(ctx context.Context, leaseID string, timeout *int32, proposedLeaseID *string, requestID *string) (*FileChangeLeaseResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.changeLeasePreparer(leaseID, timeout, proposedLeaseID, requestID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.changeLeaseResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*FileChangeLeaseResponse), err
|
||||
}
|
||||
|
||||
// changeLeasePreparer prepares the ChangeLease request.
|
||||
func (client fileClient) changeLeasePreparer(leaseID string, timeout *int32, proposedLeaseID *string, requestID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
}
|
||||
params := req.URL.Query()
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
params.Set("comp", "lease")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-lease-id", leaseID)
|
||||
if proposedLeaseID != nil {
|
||||
req.Header.Set("x-ms-proposed-lease-id", *proposedLeaseID)
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if requestID != nil {
|
||||
req.Header.Set("x-ms-client-request-id", *requestID)
|
||||
}
|
||||
req.Header.Set("x-ms-lease-action", "change")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// changeLeaseResponder handles the response to the ChangeLease request.
|
||||
func (client fileClient) changeLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &FileChangeLeaseResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// Create creates a new file or replaces a file. Note it only initializes the file with no content.
|
||||
//
|
||||
// fileContentLength is specifies the maximum size for the file, up to 1 TB. fileAttributes is if specified, the
|
||||
// fileContentLength is specifies the maximum size for the file, up to 4 TB. fileAttributes is if specified, the
|
||||
// provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can
|
||||
// also be specified as default. fileCreationTime is creation time for the file/directory. Default value: Now.
|
||||
// fileLastWriteTime is last write time for the file/directory. Default value: Now. timeout is the timeout parameter is
|
||||
|
@ -96,15 +289,16 @@ func (client fileClient) abortCopyResponder(resp pipeline.Response) (pipeline.Re
|
|||
// header shall be used. Default value: Inherit. If SDDL is specified as input, it must have owner, group and dacl.
|
||||
// Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be specified. filePermissionKey is key
|
||||
// of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or
|
||||
// x-ms-file-permission-key should be specified.
|
||||
func (client fileClient) Create(ctx context.Context, fileContentLength int64, fileAttributes string, fileCreationTime string, fileLastWriteTime string, timeout *int32, fileContentType *string, fileContentEncoding *string, fileContentLanguage *string, fileCacheControl *string, fileContentMD5 []byte, fileContentDisposition *string, metadata map[string]string, filePermission *string, filePermissionKey *string) (*FileCreateResponse, error) {
|
||||
// x-ms-file-permission-key should be specified. leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID.
|
||||
func (client fileClient) Create(ctx context.Context, fileContentLength int64, fileAttributes string, fileCreationTime string, fileLastWriteTime string, timeout *int32, fileContentType *string, fileContentEncoding *string, fileContentLanguage *string, fileCacheControl *string, fileContentMD5 []byte, fileContentDisposition *string, metadata map[string]string, filePermission *string, filePermissionKey *string, leaseID *string) (*FileCreateResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.createPreparer(fileContentLength, fileAttributes, fileCreationTime, fileLastWriteTime, timeout, fileContentType, fileContentEncoding, fileContentLanguage, fileCacheControl, fileContentMD5, fileContentDisposition, metadata, filePermission, filePermissionKey)
|
||||
req, err := client.createPreparer(fileContentLength, fileAttributes, fileCreationTime, fileLastWriteTime, timeout, fileContentType, fileContentEncoding, fileContentLanguage, fileCacheControl, fileContentMD5, fileContentDisposition, metadata, filePermission, filePermissionKey, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -116,7 +310,7 @@ func (client fileClient) Create(ctx context.Context, fileContentLength int64, fi
|
|||
}
|
||||
|
||||
// createPreparer prepares the Create request.
|
||||
func (client fileClient) createPreparer(fileContentLength int64, fileAttributes string, fileCreationTime string, fileLastWriteTime string, timeout *int32, fileContentType *string, fileContentEncoding *string, fileContentLanguage *string, fileCacheControl *string, fileContentMD5 []byte, fileContentDisposition *string, metadata map[string]string, filePermission *string, filePermissionKey *string) (pipeline.Request, error) {
|
||||
func (client fileClient) createPreparer(fileContentLength int64, fileAttributes string, fileCreationTime string, fileLastWriteTime string, timeout *int32, fileContentType *string, fileContentEncoding *string, fileContentLanguage *string, fileCacheControl *string, fileContentMD5 []byte, fileContentDisposition *string, metadata map[string]string, filePermission *string, filePermissionKey *string, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -161,6 +355,9 @@ func (client fileClient) createPreparer(fileContentLength int64, fileAttributes
|
|||
req.Header.Set("x-ms-file-attributes", fileAttributes)
|
||||
req.Header.Set("x-ms-file-creation-time", fileCreationTime)
|
||||
req.Header.Set("x-ms-file-last-write-time", fileLastWriteTime)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -179,15 +376,16 @@ func (client fileClient) createResponder(resp pipeline.Response) (pipeline.Respo
|
|||
//
|
||||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a>
|
||||
func (client fileClient) Delete(ctx context.Context, timeout *int32) (*FileDeleteResponse, error) {
|
||||
// Timeouts for File Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID.
|
||||
func (client fileClient) Delete(ctx context.Context, timeout *int32, leaseID *string) (*FileDeleteResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.deletePreparer(timeout)
|
||||
req, err := client.deletePreparer(timeout, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -199,7 +397,7 @@ func (client fileClient) Delete(ctx context.Context, timeout *int32) (*FileDelet
|
|||
}
|
||||
|
||||
// deletePreparer prepares the Delete request.
|
||||
func (client fileClient) deletePreparer(timeout *int32) (pipeline.Request, error) {
|
||||
func (client fileClient) deletePreparer(timeout *int32, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("DELETE", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -210,6 +408,9 @@ func (client fileClient) deletePreparer(timeout *int32) (pipeline.Request, error
|
|||
}
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -230,15 +431,16 @@ func (client fileClient) deleteResponder(resp pipeline.Response) (pipeline.Respo
|
|||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> rangeParameter is return file data only from the specified byte range.
|
||||
// rangeGetContentMD5 is when this header is set to true and specified together with the Range header, the service
|
||||
// returns the MD5 hash for the range, as long as the range is less than or equal to 4 MB in size.
|
||||
func (client fileClient) Download(ctx context.Context, timeout *int32, rangeParameter *string, rangeGetContentMD5 *bool) (*DownloadResponse, error) {
|
||||
// returns the MD5 hash for the range, as long as the range is less than or equal to 4 MB in size. leaseID is if
|
||||
// specified, the operation only succeeds if the resource's lease is active and matches this ID.
|
||||
func (client fileClient) Download(ctx context.Context, timeout *int32, rangeParameter *string, rangeGetContentMD5 *bool, leaseID *string) (*DownloadResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.downloadPreparer(timeout, rangeParameter, rangeGetContentMD5)
|
||||
req, err := client.downloadPreparer(timeout, rangeParameter, rangeGetContentMD5, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -250,7 +452,7 @@ func (client fileClient) Download(ctx context.Context, timeout *int32, rangePara
|
|||
}
|
||||
|
||||
// downloadPreparer prepares the Download request.
|
||||
func (client fileClient) downloadPreparer(timeout *int32, rangeParameter *string, rangeGetContentMD5 *bool) (pipeline.Request, error) {
|
||||
func (client fileClient) downloadPreparer(timeout *int32, rangeParameter *string, rangeGetContentMD5 *bool, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("GET", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -267,6 +469,9 @@ func (client fileClient) downloadPreparer(timeout *int32, rangeParameter *string
|
|||
if rangeGetContentMD5 != nil {
|
||||
req.Header.Set("x-ms-range-get-content-md5", strconv.FormatBool(*rangeGetContentMD5))
|
||||
}
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -281,7 +486,7 @@ func (client fileClient) downloadResponder(resp pipeline.Response) (pipeline.Res
|
|||
|
||||
// ForceCloseHandles closes all handles open for given file
|
||||
//
|
||||
// handleID is specifies handle ID opened on the file or directory to be closed. Asterix (‘*’) is a wildcard that
|
||||
// handleID is specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard that
|
||||
// specifies all handles. timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> marker is a string value that identifies the portion of the list to be
|
||||
|
@ -347,15 +552,16 @@ func (client fileClient) forceCloseHandlesResponder(resp pipeline.Response) (pip
|
|||
// sharesnapshot is the snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot
|
||||
// to query. timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a>
|
||||
func (client fileClient) GetProperties(ctx context.Context, sharesnapshot *string, timeout *int32) (*FileGetPropertiesResponse, error) {
|
||||
// Timeouts for File Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID.
|
||||
func (client fileClient) GetProperties(ctx context.Context, sharesnapshot *string, timeout *int32, leaseID *string) (*FileGetPropertiesResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.getPropertiesPreparer(sharesnapshot, timeout)
|
||||
req, err := client.getPropertiesPreparer(sharesnapshot, timeout, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -367,7 +573,7 @@ func (client fileClient) GetProperties(ctx context.Context, sharesnapshot *strin
|
|||
}
|
||||
|
||||
// getPropertiesPreparer prepares the GetProperties request.
|
||||
func (client fileClient) getPropertiesPreparer(sharesnapshot *string, timeout *int32) (pipeline.Request, error) {
|
||||
func (client fileClient) getPropertiesPreparer(sharesnapshot *string, timeout *int32, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("HEAD", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -381,6 +587,9 @@ func (client fileClient) getPropertiesPreparer(sharesnapshot *string, timeout *i
|
|||
}
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -398,18 +607,21 @@ func (client fileClient) getPropertiesResponder(resp pipeline.Response) (pipelin
|
|||
// GetRangeList returns the list of valid ranges for a file.
|
||||
//
|
||||
// sharesnapshot is the snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot
|
||||
// to query. timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// to query. prevsharesnapshot is the previous snapshot parameter is an opaque DateTime value that, when present,
|
||||
// specifies the previous snapshot. timeout is the timeout parameter is expressed in seconds. For more information, see
|
||||
// <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> rangeParameter is specifies the range of bytes over which to list ranges,
|
||||
// inclusively.
|
||||
func (client fileClient) GetRangeList(ctx context.Context, sharesnapshot *string, timeout *int32, rangeParameter *string) (*Ranges, error) {
|
||||
// inclusively. leaseID is if specified, the operation only succeeds if the resource's lease is active and matches this
|
||||
// ID.
|
||||
func (client fileClient) GetRangeList(ctx context.Context, sharesnapshot *string, prevsharesnapshot *string, timeout *int32, rangeParameter *string, leaseID *string) (*ShareFileRangeList, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.getRangeListPreparer(sharesnapshot, timeout, rangeParameter)
|
||||
req, err := client.getRangeListPreparer(sharesnapshot, prevsharesnapshot, timeout, rangeParameter, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -417,11 +629,11 @@ func (client fileClient) GetRangeList(ctx context.Context, sharesnapshot *string
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*Ranges), err
|
||||
return resp.(*ShareFileRangeList), err
|
||||
}
|
||||
|
||||
// getRangeListPreparer prepares the GetRangeList request.
|
||||
func (client fileClient) getRangeListPreparer(sharesnapshot *string, timeout *int32, rangeParameter *string) (pipeline.Request, error) {
|
||||
func (client fileClient) getRangeListPreparer(sharesnapshot *string, prevsharesnapshot *string, timeout *int32, rangeParameter *string, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("GET", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -430,6 +642,9 @@ func (client fileClient) getRangeListPreparer(sharesnapshot *string, timeout *in
|
|||
if sharesnapshot != nil && len(*sharesnapshot) > 0 {
|
||||
params.Set("sharesnapshot", *sharesnapshot)
|
||||
}
|
||||
if prevsharesnapshot != nil && len(*prevsharesnapshot) > 0 {
|
||||
params.Set("prevsharesnapshot", *prevsharesnapshot)
|
||||
}
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
|
@ -439,6 +654,9 @@ func (client fileClient) getRangeListPreparer(sharesnapshot *string, timeout *in
|
|||
if rangeParameter != nil {
|
||||
req.Header.Set("x-ms-range", *rangeParameter)
|
||||
}
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -448,7 +666,7 @@ func (client fileClient) getRangeListResponder(resp pipeline.Response) (pipeline
|
|||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &Ranges{rawResponse: resp.Response()}
|
||||
result := &ShareFileRangeList{rawResponse: resp.Response()}
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
@ -549,6 +767,64 @@ func (client fileClient) listHandlesResponder(resp pipeline.Response) (pipeline.
|
|||
return result, nil
|
||||
}
|
||||
|
||||
// ReleaseLease [Update] The Lease File operation establishes and manages a lock on a file for write and delete
|
||||
// operations
|
||||
//
|
||||
// leaseID is specifies the current lease ID on the resource. timeout is the timeout parameter is expressed in seconds.
|
||||
// For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> requestID is provides a client-generated, opaque value with a 1 KB
|
||||
// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
|
||||
func (client fileClient) ReleaseLease(ctx context.Context, leaseID string, timeout *int32, requestID *string) (*FileReleaseLeaseResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.releaseLeasePreparer(leaseID, timeout, requestID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.releaseLeaseResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*FileReleaseLeaseResponse), err
|
||||
}
|
||||
|
||||
// releaseLeasePreparer prepares the ReleaseLease request.
|
||||
func (client fileClient) releaseLeasePreparer(leaseID string, timeout *int32, requestID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
}
|
||||
params := req.URL.Query()
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
params.Set("comp", "lease")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-lease-id", leaseID)
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if requestID != nil {
|
||||
req.Header.Set("x-ms-client-request-id", *requestID)
|
||||
}
|
||||
req.Header.Set("x-ms-lease-action", "release")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// releaseLeaseResponder handles the response to the ReleaseLease request.
|
||||
func (client fileClient) releaseLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &FileReleaseLeaseResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// SetHTTPHeaders sets HTTP headers on the file.
|
||||
//
|
||||
// fileAttributes is if specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and
|
||||
|
@ -567,15 +843,16 @@ func (client fileClient) listHandlesResponder(resp pipeline.Response) (pipeline.
|
|||
// else x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as input, it must
|
||||
// have owner, group and dacl. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be
|
||||
// specified. filePermissionKey is key of the permission to be set for the directory/file. Note: Only one of the
|
||||
// x-ms-file-permission or x-ms-file-permission-key should be specified.
|
||||
func (client fileClient) SetHTTPHeaders(ctx context.Context, fileAttributes string, fileCreationTime string, fileLastWriteTime string, timeout *int32, fileContentLength *int64, fileContentType *string, fileContentEncoding *string, fileContentLanguage *string, fileCacheControl *string, fileContentMD5 []byte, fileContentDisposition *string, filePermission *string, filePermissionKey *string) (*FileSetHTTPHeadersResponse, error) {
|
||||
// x-ms-file-permission or x-ms-file-permission-key should be specified. leaseID is if specified, the operation only
|
||||
// succeeds if the resource's lease is active and matches this ID.
|
||||
func (client fileClient) SetHTTPHeaders(ctx context.Context, fileAttributes string, fileCreationTime string, fileLastWriteTime string, timeout *int32, fileContentLength *int64, fileContentType *string, fileContentEncoding *string, fileContentLanguage *string, fileCacheControl *string, fileContentMD5 []byte, fileContentDisposition *string, filePermission *string, filePermissionKey *string, leaseID *string) (*FileSetHTTPHeadersResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.setHTTPHeadersPreparer(fileAttributes, fileCreationTime, fileLastWriteTime, timeout, fileContentLength, fileContentType, fileContentEncoding, fileContentLanguage, fileCacheControl, fileContentMD5, fileContentDisposition, filePermission, filePermissionKey)
|
||||
req, err := client.setHTTPHeadersPreparer(fileAttributes, fileCreationTime, fileLastWriteTime, timeout, fileContentLength, fileContentType, fileContentEncoding, fileContentLanguage, fileCacheControl, fileContentMD5, fileContentDisposition, filePermission, filePermissionKey, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -587,7 +864,7 @@ func (client fileClient) SetHTTPHeaders(ctx context.Context, fileAttributes stri
|
|||
}
|
||||
|
||||
// setHTTPHeadersPreparer prepares the SetHTTPHeaders request.
|
||||
func (client fileClient) setHTTPHeadersPreparer(fileAttributes string, fileCreationTime string, fileLastWriteTime string, timeout *int32, fileContentLength *int64, fileContentType *string, fileContentEncoding *string, fileContentLanguage *string, fileCacheControl *string, fileContentMD5 []byte, fileContentDisposition *string, filePermission *string, filePermissionKey *string) (pipeline.Request, error) {
|
||||
func (client fileClient) setHTTPHeadersPreparer(fileAttributes string, fileCreationTime string, fileLastWriteTime string, timeout *int32, fileContentLength *int64, fileContentType *string, fileContentEncoding *string, fileContentLanguage *string, fileCacheControl *string, fileContentMD5 []byte, fileContentDisposition *string, filePermission *string, filePermissionKey *string, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -629,6 +906,9 @@ func (client fileClient) setHTTPHeadersPreparer(fileAttributes string, fileCreat
|
|||
req.Header.Set("x-ms-file-attributes", fileAttributes)
|
||||
req.Header.Set("x-ms-file-creation-time", fileCreationTime)
|
||||
req.Header.Set("x-ms-file-last-write-time", fileLastWriteTime)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -648,14 +928,15 @@ func (client fileClient) setHTTPHeadersResponder(resp pipeline.Response) (pipeli
|
|||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> metadata is a name-value pair to associate with a file storage object.
|
||||
func (client fileClient) SetMetadata(ctx context.Context, timeout *int32, metadata map[string]string) (*FileSetMetadataResponse, error) {
|
||||
// leaseID is if specified, the operation only succeeds if the resource's lease is active and matches this ID.
|
||||
func (client fileClient) SetMetadata(ctx context.Context, timeout *int32, metadata map[string]string, leaseID *string) (*FileSetMetadataResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.setMetadataPreparer(timeout, metadata)
|
||||
req, err := client.setMetadataPreparer(timeout, metadata, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -667,7 +948,7 @@ func (client fileClient) SetMetadata(ctx context.Context, timeout *int32, metada
|
|||
}
|
||||
|
||||
// setMetadataPreparer prepares the SetMetadata request.
|
||||
func (client fileClient) setMetadataPreparer(timeout *int32, metadata map[string]string) (pipeline.Request, error) {
|
||||
func (client fileClient) setMetadataPreparer(timeout *int32, metadata map[string]string, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -684,6 +965,9 @@ func (client fileClient) setMetadataPreparer(timeout *int32, metadata map[string
|
|||
}
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -708,14 +992,30 @@ func (client fileClient) setMetadataResponder(resp pipeline.Response) (pipeline.
|
|||
// copy source. timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> metadata is a name-value pair to associate with a file storage object.
|
||||
func (client fileClient) StartCopy(ctx context.Context, copySource string, timeout *int32, metadata map[string]string) (*FileStartCopyResponse, error) {
|
||||
// filePermission is if specified the permission (security descriptor) shall be set for the directory/file. This header
|
||||
// can be used if Permission size is <= 8KB, else x-ms-file-permission-key header shall be used. Default value:
|
||||
// Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the
|
||||
// x-ms-file-permission or x-ms-file-permission-key should be specified. filePermissionKey is key of the permission to
|
||||
// be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be
|
||||
// specified. filePermissionCopyMode is specifies the option to copy file security descriptor from source file or to
|
||||
// set it using the value which is defined by the header value of x-ms-file-permission or x-ms-file-permission-key.
|
||||
// ignoreReadOnly is specifies the option to overwrite the target file if it already exists and has read-only attribute
|
||||
// set. fileAttributes is specifies either the option to copy file attributes from a source file(source) to a target
|
||||
// file or a list of attributes to set on a target file. fileCreationTime is specifies either the option to copy file
|
||||
// creation time from a source file(source) to a target file or a time value in ISO 8601 format to set as creation time
|
||||
// on a target file. fileLastWriteTime is specifies either the option to copy file last write time from a source
|
||||
// file(source) to a target file or a time value in ISO 8601 format to set as last write time on a target file.
|
||||
// setArchiveAttribute is specifies the option to set archive attribute on a target file. True means archive attribute
|
||||
// will be set on a target file despite attribute overrides or a source file state. leaseID is if specified, the
|
||||
// operation only succeeds if the resource's lease is active and matches this ID.
|
||||
func (client fileClient) StartCopy(ctx context.Context, copySource string, timeout *int32, metadata map[string]string, filePermission *string, filePermissionKey *string, filePermissionCopyMode PermissionCopyModeType, ignoreReadOnly *bool, fileAttributes *string, fileCreationTime *string, fileLastWriteTime *string, setArchiveAttribute *bool, leaseID *string) (*FileStartCopyResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.startCopyPreparer(copySource, timeout, metadata)
|
||||
req, err := client.startCopyPreparer(copySource, timeout, metadata, filePermission, filePermissionKey, filePermissionCopyMode, ignoreReadOnly, fileAttributes, fileCreationTime, fileLastWriteTime, setArchiveAttribute, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -727,7 +1027,7 @@ func (client fileClient) StartCopy(ctx context.Context, copySource string, timeo
|
|||
}
|
||||
|
||||
// startCopyPreparer prepares the StartCopy request.
|
||||
func (client fileClient) startCopyPreparer(copySource string, timeout *int32, metadata map[string]string) (pipeline.Request, error) {
|
||||
func (client fileClient) startCopyPreparer(copySource string, timeout *int32, metadata map[string]string, filePermission *string, filePermissionKey *string, filePermissionCopyMode PermissionCopyModeType, ignoreReadOnly *bool, fileAttributes *string, fileCreationTime *string, fileLastWriteTime *string, setArchiveAttribute *bool, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -744,6 +1044,33 @@ func (client fileClient) startCopyPreparer(copySource string, timeout *int32, me
|
|||
}
|
||||
}
|
||||
req.Header.Set("x-ms-copy-source", copySource)
|
||||
if filePermission != nil {
|
||||
req.Header.Set("x-ms-file-permission", *filePermission)
|
||||
}
|
||||
if filePermissionKey != nil {
|
||||
req.Header.Set("x-ms-file-permission-key", *filePermissionKey)
|
||||
}
|
||||
if filePermissionCopyMode != PermissionCopyModeNone {
|
||||
req.Header.Set("x-ms-file-permission-copy-mode", string(filePermissionCopyMode))
|
||||
}
|
||||
if ignoreReadOnly != nil {
|
||||
req.Header.Set("x-ms-file-copy-ignore-read-only", strconv.FormatBool(*ignoreReadOnly))
|
||||
}
|
||||
if fileAttributes != nil {
|
||||
req.Header.Set("x-ms-file-attributes", *fileAttributes)
|
||||
}
|
||||
if fileCreationTime != nil {
|
||||
req.Header.Set("x-ms-file-creation-time", *fileCreationTime)
|
||||
}
|
||||
if fileLastWriteTime != nil {
|
||||
req.Header.Set("x-ms-file-last-write-time", *fileLastWriteTime)
|
||||
}
|
||||
if setArchiveAttribute != nil {
|
||||
req.Header.Set("x-ms-file-copy-set-archive", strconv.FormatBool(*setArchiveAttribute))
|
||||
}
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -776,15 +1103,16 @@ func (client fileClient) startCopyResponder(resp pipeline.Response) (pipeline.Re
|
|||
// Timeouts for File Service Operations.</a> contentMD5 is an MD5 hash of the content. This hash is used to verify the
|
||||
// integrity of the data during transport. When the Content-MD5 header is specified, the File service compares the hash
|
||||
// of the content that has arrived with the header value that was sent. If the two hashes do not match, the operation
|
||||
// will fail with error code 400 (Bad Request).
|
||||
func (client fileClient) UploadRange(ctx context.Context, rangeParameter string, fileRangeWrite FileRangeWriteType, contentLength int64, body io.ReadSeeker, timeout *int32, contentMD5 []byte) (*FileUploadRangeResponse, error) {
|
||||
// will fail with error code 400 (Bad Request). leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID.
|
||||
func (client fileClient) UploadRange(ctx context.Context, rangeParameter string, fileRangeWrite FileRangeWriteType, contentLength int64, body io.ReadSeeker, timeout *int32, contentMD5 []byte, leaseID *string) (*FileUploadRangeResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.uploadRangePreparer(rangeParameter, fileRangeWrite, contentLength, body, timeout, contentMD5)
|
||||
req, err := client.uploadRangePreparer(rangeParameter, fileRangeWrite, contentLength, body, timeout, contentMD5, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -796,7 +1124,7 @@ func (client fileClient) UploadRange(ctx context.Context, rangeParameter string,
|
|||
}
|
||||
|
||||
// uploadRangePreparer prepares the UploadRange request.
|
||||
func (client fileClient) uploadRangePreparer(rangeParameter string, fileRangeWrite FileRangeWriteType, contentLength int64, body io.ReadSeeker, timeout *int32, contentMD5 []byte) (pipeline.Request, error) {
|
||||
func (client fileClient) uploadRangePreparer(rangeParameter string, fileRangeWrite FileRangeWriteType, contentLength int64, body io.ReadSeeker, timeout *int32, contentMD5 []byte, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, body)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -814,6 +1142,9 @@ func (client fileClient) uploadRangePreparer(rangeParameter string, fileRangeWri
|
|||
req.Header.Set("Content-MD5", base64.StdEncoding.EncodeToString(contentMD5))
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -844,14 +1175,15 @@ func (client fileClient) uploadRangeResponder(resp pipeline.Response) (pipeline.
|
|||
// sourceContentCrc64 is specify the crc64 calculated for the range of bytes that must be read from the copy source.
|
||||
// sourceIfMatchCrc64 is specify the crc64 value to operate only on range with a matching crc64 checksum.
|
||||
// sourceIfNoneMatchCrc64 is specify the crc64 value to operate only on range without a matching crc64 checksum.
|
||||
func (client fileClient) UploadRangeFromURL(ctx context.Context, rangeParameter string, copySource string, contentLength int64, timeout *int32, sourceRange *string, sourceContentCrc64 []byte, sourceIfMatchCrc64 []byte, sourceIfNoneMatchCrc64 []byte) (*FileUploadRangeFromURLResponse, error) {
|
||||
// leaseID is if specified, the operation only succeeds if the resource's lease is active and matches this ID.
|
||||
func (client fileClient) UploadRangeFromURL(ctx context.Context, rangeParameter string, copySource string, contentLength int64, timeout *int32, sourceRange *string, sourceContentCrc64 []byte, sourceIfMatchCrc64 []byte, sourceIfNoneMatchCrc64 []byte, leaseID *string) (*FileUploadRangeFromURLResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.uploadRangeFromURLPreparer(rangeParameter, copySource, contentLength, timeout, sourceRange, sourceContentCrc64, sourceIfMatchCrc64, sourceIfNoneMatchCrc64)
|
||||
req, err := client.uploadRangeFromURLPreparer(rangeParameter, copySource, contentLength, timeout, sourceRange, sourceContentCrc64, sourceIfMatchCrc64, sourceIfNoneMatchCrc64, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -863,7 +1195,7 @@ func (client fileClient) UploadRangeFromURL(ctx context.Context, rangeParameter
|
|||
}
|
||||
|
||||
// uploadRangeFromURLPreparer prepares the UploadRangeFromURL request.
|
||||
func (client fileClient) uploadRangeFromURLPreparer(rangeParameter string, copySource string, contentLength int64, timeout *int32, sourceRange *string, sourceContentCrc64 []byte, sourceIfMatchCrc64 []byte, sourceIfNoneMatchCrc64 []byte) (pipeline.Request, error) {
|
||||
func (client fileClient) uploadRangeFromURLPreparer(rangeParameter string, copySource string, contentLength int64, timeout *int32, sourceRange *string, sourceContentCrc64 []byte, sourceIfMatchCrc64 []byte, sourceIfNoneMatchCrc64 []byte, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -891,6 +1223,9 @@ func (client fileClient) uploadRangeFromURLPreparer(rangeParameter string, copyS
|
|||
req.Header.Set("x-ms-source-if-none-match-crc64", base64.StdEncoding.EncodeToString(sourceIfNoneMatchCrc64))
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -26,14 +26,227 @@ func newShareClient(url url.URL, p pipeline.Pipeline) shareClient {
|
|||
return shareClient{newManagementClient(url, p)}
|
||||
}
|
||||
|
||||
// AcquireLease the Lease Share operation establishes and manages a lock on a share, or the specified snapshot for set
|
||||
// and delete share operations.
|
||||
//
|
||||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> duration is specifies the duration of the lease, in seconds, or negative
|
||||
// one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration
|
||||
// cannot be changed using renew or change. proposedLeaseID is proposed lease ID, in a GUID string format. The File
|
||||
// service returns 400 (Invalid request) if the proposed lease ID is not in the correct format. See Guid Constructor
|
||||
// (String) for a list of valid GUID string formats. sharesnapshot is the snapshot parameter is an opaque DateTime
|
||||
// value that, when present, specifies the share snapshot to query. requestID is provides a client-generated, opaque
|
||||
// value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
|
||||
func (client shareClient) AcquireLease(ctx context.Context, timeout *int32, duration *int32, proposedLeaseID *string, sharesnapshot *string, requestID *string) (*ShareAcquireLeaseResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.acquireLeasePreparer(timeout, duration, proposedLeaseID, sharesnapshot, requestID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.acquireLeaseResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*ShareAcquireLeaseResponse), err
|
||||
}
|
||||
|
||||
// acquireLeasePreparer prepares the AcquireLease request.
|
||||
func (client shareClient) acquireLeasePreparer(timeout *int32, duration *int32, proposedLeaseID *string, sharesnapshot *string, requestID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
}
|
||||
params := req.URL.Query()
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
if sharesnapshot != nil && len(*sharesnapshot) > 0 {
|
||||
params.Set("sharesnapshot", *sharesnapshot)
|
||||
}
|
||||
params.Set("comp", "lease")
|
||||
params.Set("restype", "share")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
if duration != nil {
|
||||
req.Header.Set("x-ms-lease-duration", strconv.FormatInt(int64(*duration), 10))
|
||||
}
|
||||
if proposedLeaseID != nil {
|
||||
req.Header.Set("x-ms-proposed-lease-id", *proposedLeaseID)
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if requestID != nil {
|
||||
req.Header.Set("x-ms-client-request-id", *requestID)
|
||||
}
|
||||
req.Header.Set("x-ms-lease-action", "acquire")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// acquireLeaseResponder handles the response to the AcquireLease request.
|
||||
func (client shareClient) acquireLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK, http.StatusCreated)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &ShareAcquireLeaseResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// BreakLease the Lease Share operation establishes and manages a lock on a share, or the specified snapshot for set
|
||||
// and delete share operations.
|
||||
//
|
||||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> breakPeriod is for a break operation, proposed duration the lease should
|
||||
// continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is shorter than the
|
||||
// time remaining on the lease. If longer, the time remaining on the lease is used. A new lease will not be available
|
||||
// before the break period has expired, but the lease may be held for longer than the break period. If this header does
|
||||
// not appear with a break operation, a fixed-duration lease breaks after the remaining lease period elapses, and an
|
||||
// infinite lease breaks immediately. leaseID is if specified, the operation only succeeds if the resource's lease is
|
||||
// active and matches this ID. requestID is provides a client-generated, opaque value with a 1 KB character limit that
|
||||
// is recorded in the analytics logs when storage analytics logging is enabled. sharesnapshot is the snapshot parameter
|
||||
// is an opaque DateTime value that, when present, specifies the share snapshot to query.
|
||||
func (client shareClient) BreakLease(ctx context.Context, timeout *int32, breakPeriod *int32, leaseID *string, requestID *string, sharesnapshot *string) (*ShareBreakLeaseResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.breakLeasePreparer(timeout, breakPeriod, leaseID, requestID, sharesnapshot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.breakLeaseResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*ShareBreakLeaseResponse), err
|
||||
}
|
||||
|
||||
// breakLeasePreparer prepares the BreakLease request.
|
||||
func (client shareClient) breakLeasePreparer(timeout *int32, breakPeriod *int32, leaseID *string, requestID *string, sharesnapshot *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
}
|
||||
params := req.URL.Query()
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
if sharesnapshot != nil && len(*sharesnapshot) > 0 {
|
||||
params.Set("sharesnapshot", *sharesnapshot)
|
||||
}
|
||||
params.Set("comp", "lease")
|
||||
params.Set("restype", "share")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
if breakPeriod != nil {
|
||||
req.Header.Set("x-ms-lease-break-period", strconv.FormatInt(int64(*breakPeriod), 10))
|
||||
}
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if requestID != nil {
|
||||
req.Header.Set("x-ms-client-request-id", *requestID)
|
||||
}
|
||||
req.Header.Set("x-ms-lease-action", "break")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// breakLeaseResponder handles the response to the BreakLease request.
|
||||
func (client shareClient) breakLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK, http.StatusAccepted)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &ShareBreakLeaseResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// ChangeLease the Lease Share operation establishes and manages a lock on a share, or the specified snapshot for set
|
||||
// and delete share operations.
|
||||
//
|
||||
// leaseID is specifies the current lease ID on the resource. timeout is the timeout parameter is expressed in seconds.
|
||||
// For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> proposedLeaseID is proposed lease ID, in a GUID string format. The File
|
||||
// service returns 400 (Invalid request) if the proposed lease ID is not in the correct format. See Guid Constructor
|
||||
// (String) for a list of valid GUID string formats. sharesnapshot is the snapshot parameter is an opaque DateTime
|
||||
// value that, when present, specifies the share snapshot to query. requestID is provides a client-generated, opaque
|
||||
// value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
|
||||
func (client shareClient) ChangeLease(ctx context.Context, leaseID string, timeout *int32, proposedLeaseID *string, sharesnapshot *string, requestID *string) (*ShareChangeLeaseResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.changeLeasePreparer(leaseID, timeout, proposedLeaseID, sharesnapshot, requestID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.changeLeaseResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*ShareChangeLeaseResponse), err
|
||||
}
|
||||
|
||||
// changeLeasePreparer prepares the ChangeLease request.
|
||||
func (client shareClient) changeLeasePreparer(leaseID string, timeout *int32, proposedLeaseID *string, sharesnapshot *string, requestID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
}
|
||||
params := req.URL.Query()
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
if sharesnapshot != nil && len(*sharesnapshot) > 0 {
|
||||
params.Set("sharesnapshot", *sharesnapshot)
|
||||
}
|
||||
params.Set("comp", "lease")
|
||||
params.Set("restype", "share")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-lease-id", leaseID)
|
||||
if proposedLeaseID != nil {
|
||||
req.Header.Set("x-ms-proposed-lease-id", *proposedLeaseID)
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if requestID != nil {
|
||||
req.Header.Set("x-ms-client-request-id", *requestID)
|
||||
}
|
||||
req.Header.Set("x-ms-lease-action", "change")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// changeLeaseResponder handles the response to the ChangeLease request.
|
||||
func (client shareClient) changeLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &ShareChangeLeaseResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// Create creates a new share under the specified account. If the share with the same name already exists, the
|
||||
// operation fails.
|
||||
//
|
||||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> metadata is a name-value pair to associate with a file storage object.
|
||||
// quota is specifies the maximum size of the share, in gigabytes.
|
||||
func (client shareClient) Create(ctx context.Context, timeout *int32, metadata map[string]string, quota *int32) (*ShareCreateResponse, error) {
|
||||
// quota is specifies the maximum size of the share, in gigabytes. accessTier is specifies the access tier of the
|
||||
// share.
|
||||
func (client shareClient) Create(ctx context.Context, timeout *int32, metadata map[string]string, quota *int32, accessTier ShareAccessTierType) (*ShareCreateResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
|
@ -43,7 +256,7 @@ func (client shareClient) Create(ctx context.Context, timeout *int32, metadata m
|
|||
chain: []constraint{{target: "quota", name: inclusiveMinimum, rule: 1, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.createPreparer(timeout, metadata, quota)
|
||||
req, err := client.createPreparer(timeout, metadata, quota, accessTier)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -55,7 +268,7 @@ func (client shareClient) Create(ctx context.Context, timeout *int32, metadata m
|
|||
}
|
||||
|
||||
// createPreparer prepares the Create request.
|
||||
func (client shareClient) createPreparer(timeout *int32, metadata map[string]string, quota *int32) (pipeline.Request, error) {
|
||||
func (client shareClient) createPreparer(timeout *int32, metadata map[string]string, quota *int32, accessTier ShareAccessTierType) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -74,6 +287,9 @@ func (client shareClient) createPreparer(timeout *int32, metadata map[string]str
|
|||
if quota != nil {
|
||||
req.Header.Set("x-ms-share-quota", strconv.FormatInt(int64(*quota), 10))
|
||||
}
|
||||
if accessTier != ShareAccessTierNone {
|
||||
req.Header.Set("x-ms-access-tier", string(accessTier))
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
return req, nil
|
||||
}
|
||||
|
@ -213,15 +429,16 @@ func (client shareClient) createSnapshotResponder(resp pipeline.Response) (pipel
|
|||
// to query. timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> deleteSnapshots is specifies the option include to delete the base share
|
||||
// and all of its snapshots.
|
||||
func (client shareClient) Delete(ctx context.Context, sharesnapshot *string, timeout *int32, deleteSnapshots DeleteSnapshotsOptionType) (*ShareDeleteResponse, error) {
|
||||
// and all of its snapshots. leaseID is if specified, the operation only succeeds if the resource's lease is active and
|
||||
// matches this ID.
|
||||
func (client shareClient) Delete(ctx context.Context, sharesnapshot *string, timeout *int32, deleteSnapshots DeleteSnapshotsOptionType, leaseID *string) (*ShareDeleteResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.deletePreparer(sharesnapshot, timeout, deleteSnapshots)
|
||||
req, err := client.deletePreparer(sharesnapshot, timeout, deleteSnapshots, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -233,7 +450,7 @@ func (client shareClient) Delete(ctx context.Context, sharesnapshot *string, tim
|
|||
}
|
||||
|
||||
// deletePreparer prepares the Delete request.
|
||||
func (client shareClient) deletePreparer(sharesnapshot *string, timeout *int32, deleteSnapshots DeleteSnapshotsOptionType) (pipeline.Request, error) {
|
||||
func (client shareClient) deletePreparer(sharesnapshot *string, timeout *int32, deleteSnapshots DeleteSnapshotsOptionType, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("DELETE", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -251,6 +468,9 @@ func (client shareClient) deletePreparer(sharesnapshot *string, timeout *int32,
|
|||
if deleteSnapshots != DeleteSnapshotsOptionNone {
|
||||
req.Header.Set("x-ms-delete-snapshots", string(deleteSnapshots))
|
||||
}
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -269,15 +489,16 @@ func (client shareClient) deleteResponder(resp pipeline.Response) (pipeline.Resp
|
|||
//
|
||||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a>
|
||||
func (client shareClient) GetAccessPolicy(ctx context.Context, timeout *int32) (*SignedIdentifiers, error) {
|
||||
// Timeouts for File Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID.
|
||||
func (client shareClient) GetAccessPolicy(ctx context.Context, timeout *int32, leaseID *string) (*SignedIdentifiers, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.getAccessPolicyPreparer(timeout)
|
||||
req, err := client.getAccessPolicyPreparer(timeout, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -289,7 +510,7 @@ func (client shareClient) GetAccessPolicy(ctx context.Context, timeout *int32) (
|
|||
}
|
||||
|
||||
// getAccessPolicyPreparer prepares the GetAccessPolicy request.
|
||||
func (client shareClient) getAccessPolicyPreparer(timeout *int32) (pipeline.Request, error) {
|
||||
func (client shareClient) getAccessPolicyPreparer(timeout *int32, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("GET", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -302,6 +523,9 @@ func (client shareClient) getAccessPolicyPreparer(timeout *int32) (pipeline.Requ
|
|||
params.Set("comp", "acl")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -403,15 +627,16 @@ func (client shareClient) getPermissionResponder(resp pipeline.Response) (pipeli
|
|||
// sharesnapshot is the snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot
|
||||
// to query. timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a>
|
||||
func (client shareClient) GetProperties(ctx context.Context, sharesnapshot *string, timeout *int32) (*ShareGetPropertiesResponse, error) {
|
||||
// Timeouts for File Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID.
|
||||
func (client shareClient) GetProperties(ctx context.Context, sharesnapshot *string, timeout *int32, leaseID *string) (*ShareGetPropertiesResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.getPropertiesPreparer(sharesnapshot, timeout)
|
||||
req, err := client.getPropertiesPreparer(sharesnapshot, timeout, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -423,7 +648,7 @@ func (client shareClient) GetProperties(ctx context.Context, sharesnapshot *stri
|
|||
}
|
||||
|
||||
// getPropertiesPreparer prepares the GetProperties request.
|
||||
func (client shareClient) getPropertiesPreparer(sharesnapshot *string, timeout *int32) (pipeline.Request, error) {
|
||||
func (client shareClient) getPropertiesPreparer(sharesnapshot *string, timeout *int32, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("GET", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -438,6 +663,9 @@ func (client shareClient) getPropertiesPreparer(sharesnapshot *string, timeout *
|
|||
params.Set("restype", "share")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -456,15 +684,16 @@ func (client shareClient) getPropertiesResponder(resp pipeline.Response) (pipeli
|
|||
//
|
||||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a>
|
||||
func (client shareClient) GetStatistics(ctx context.Context, timeout *int32) (*ShareStats, error) {
|
||||
// Timeouts for File Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID.
|
||||
func (client shareClient) GetStatistics(ctx context.Context, timeout *int32, leaseID *string) (*ShareStats, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.getStatisticsPreparer(timeout)
|
||||
req, err := client.getStatisticsPreparer(timeout, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -476,7 +705,7 @@ func (client shareClient) GetStatistics(ctx context.Context, timeout *int32) (*S
|
|||
}
|
||||
|
||||
// getStatisticsPreparer prepares the GetStatistics request.
|
||||
func (client shareClient) getStatisticsPreparer(timeout *int32) (pipeline.Request, error) {
|
||||
func (client shareClient) getStatisticsPreparer(timeout *int32, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("GET", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -489,6 +718,9 @@ func (client shareClient) getStatisticsPreparer(timeout *int32) (pipeline.Reques
|
|||
params.Set("comp", "stats")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -517,20 +749,210 @@ func (client shareClient) getStatisticsResponder(resp pipeline.Response) (pipeli
|
|||
return result, nil
|
||||
}
|
||||
|
||||
// SetAccessPolicy sets a stored access policy for use with shared access signatures.
|
||||
// ReleaseLease the Lease Share operation establishes and manages a lock on a share, or the specified snapshot for set
|
||||
// and delete share operations.
|
||||
//
|
||||
// shareACL is the ACL for the share. timeout is the timeout parameter is expressed in seconds. For more information,
|
||||
// see <a
|
||||
// leaseID is specifies the current lease ID on the resource. timeout is the timeout parameter is expressed in seconds.
|
||||
// For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a>
|
||||
func (client shareClient) SetAccessPolicy(ctx context.Context, shareACL []SignedIdentifier, timeout *int32) (*ShareSetAccessPolicyResponse, error) {
|
||||
// Timeouts for File Service Operations.</a> sharesnapshot is the snapshot parameter is an opaque DateTime value that,
|
||||
// when present, specifies the share snapshot to query. requestID is provides a client-generated, opaque value with a 1
|
||||
// KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
|
||||
func (client shareClient) ReleaseLease(ctx context.Context, leaseID string, timeout *int32, sharesnapshot *string, requestID *string) (*ShareReleaseLeaseResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.setAccessPolicyPreparer(shareACL, timeout)
|
||||
req, err := client.releaseLeasePreparer(leaseID, timeout, sharesnapshot, requestID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.releaseLeaseResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*ShareReleaseLeaseResponse), err
|
||||
}
|
||||
|
||||
// releaseLeasePreparer prepares the ReleaseLease request.
|
||||
func (client shareClient) releaseLeasePreparer(leaseID string, timeout *int32, sharesnapshot *string, requestID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
}
|
||||
params := req.URL.Query()
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
if sharesnapshot != nil && len(*sharesnapshot) > 0 {
|
||||
params.Set("sharesnapshot", *sharesnapshot)
|
||||
}
|
||||
params.Set("comp", "lease")
|
||||
params.Set("restype", "share")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-lease-id", leaseID)
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if requestID != nil {
|
||||
req.Header.Set("x-ms-client-request-id", *requestID)
|
||||
}
|
||||
req.Header.Set("x-ms-lease-action", "release")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// releaseLeaseResponder handles the response to the ReleaseLease request.
|
||||
func (client shareClient) releaseLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &ShareReleaseLeaseResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// RenewLease the Lease Share operation establishes and manages a lock on a share, or the specified snapshot for set
|
||||
// and delete share operations.
|
||||
//
|
||||
// leaseID is specifies the current lease ID on the resource. timeout is the timeout parameter is expressed in seconds.
|
||||
// For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> sharesnapshot is the snapshot parameter is an opaque DateTime value that,
|
||||
// when present, specifies the share snapshot to query. requestID is provides a client-generated, opaque value with a 1
|
||||
// KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
|
||||
func (client shareClient) RenewLease(ctx context.Context, leaseID string, timeout *int32, sharesnapshot *string, requestID *string) (*ShareRenewLeaseResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.renewLeasePreparer(leaseID, timeout, sharesnapshot, requestID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.renewLeaseResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*ShareRenewLeaseResponse), err
|
||||
}
|
||||
|
||||
// renewLeasePreparer prepares the RenewLease request.
|
||||
func (client shareClient) renewLeasePreparer(leaseID string, timeout *int32, sharesnapshot *string, requestID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
}
|
||||
params := req.URL.Query()
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
if sharesnapshot != nil && len(*sharesnapshot) > 0 {
|
||||
params.Set("sharesnapshot", *sharesnapshot)
|
||||
}
|
||||
params.Set("comp", "lease")
|
||||
params.Set("restype", "share")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-lease-id", leaseID)
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if requestID != nil {
|
||||
req.Header.Set("x-ms-client-request-id", *requestID)
|
||||
}
|
||||
req.Header.Set("x-ms-lease-action", "renew")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// renewLeaseResponder handles the response to the RenewLease request.
|
||||
func (client shareClient) renewLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &ShareRenewLeaseResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// Restore restores a previously deleted Share.
|
||||
//
|
||||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> requestID is provides a client-generated, opaque value with a 1 KB
|
||||
// character limit that is recorded in the analytics logs when storage analytics logging is enabled. deletedShareName
|
||||
// is specifies the name of the preivously-deleted share. deletedShareVersion is specifies the version of the
|
||||
// preivously-deleted share.
|
||||
func (client shareClient) Restore(ctx context.Context, timeout *int32, requestID *string, deletedShareName *string, deletedShareVersion *string) (*ShareRestoreResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.restorePreparer(timeout, requestID, deletedShareName, deletedShareVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.restoreResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*ShareRestoreResponse), err
|
||||
}
|
||||
|
||||
// restorePreparer prepares the Restore request.
|
||||
func (client shareClient) restorePreparer(timeout *int32, requestID *string, deletedShareName *string, deletedShareVersion *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
}
|
||||
params := req.URL.Query()
|
||||
if timeout != nil {
|
||||
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
||||
}
|
||||
params.Set("restype", "share")
|
||||
params.Set("comp", "undelete")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if requestID != nil {
|
||||
req.Header.Set("x-ms-client-request-id", *requestID)
|
||||
}
|
||||
if deletedShareName != nil {
|
||||
req.Header.Set("x-ms-deleted-share-name", *deletedShareName)
|
||||
}
|
||||
if deletedShareVersion != nil {
|
||||
req.Header.Set("x-ms-deleted-share-version", *deletedShareVersion)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// restoreResponder handles the response to the Restore request.
|
||||
func (client shareClient) restoreResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK, http.StatusCreated)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &ShareRestoreResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// SetAccessPolicy sets a stored access policy for use with shared access signatures.
|
||||
//
|
||||
// shareACL is the ACL for the share. timeout is the timeout parameter is expressed in seconds. For more information,
|
||||
// see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID.
|
||||
func (client shareClient) SetAccessPolicy(ctx context.Context, shareACL []SignedIdentifier, timeout *int32, leaseID *string) (*ShareSetAccessPolicyResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.setAccessPolicyPreparer(shareACL, timeout, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -542,7 +964,7 @@ func (client shareClient) SetAccessPolicy(ctx context.Context, shareACL []Signed
|
|||
}
|
||||
|
||||
// setAccessPolicyPreparer prepares the SetAccessPolicy request.
|
||||
func (client shareClient) setAccessPolicyPreparer(shareACL []SignedIdentifier, timeout *int32) (pipeline.Request, error) {
|
||||
func (client shareClient) setAccessPolicyPreparer(shareACL []SignedIdentifier, timeout *int32, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -555,6 +977,9 @@ func (client shareClient) setAccessPolicyPreparer(shareACL []SignedIdentifier, t
|
|||
params.Set("comp", "acl")
|
||||
req.URL.RawQuery = params.Encode()
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
b, err := xml.Marshal(SignedIdentifiers{Items: shareACL})
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to marshal request body")
|
||||
|
@ -583,14 +1008,15 @@ func (client shareClient) setAccessPolicyResponder(resp pipeline.Response) (pipe
|
|||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> metadata is a name-value pair to associate with a file storage object.
|
||||
func (client shareClient) SetMetadata(ctx context.Context, timeout *int32, metadata map[string]string) (*ShareSetMetadataResponse, error) {
|
||||
// leaseID is if specified, the operation only succeeds if the resource's lease is active and matches this ID.
|
||||
func (client shareClient) SetMetadata(ctx context.Context, timeout *int32, metadata map[string]string, leaseID *string) (*ShareSetMetadataResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.setMetadataPreparer(timeout, metadata)
|
||||
req, err := client.setMetadataPreparer(timeout, metadata, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -602,7 +1028,7 @@ func (client shareClient) SetMetadata(ctx context.Context, timeout *int32, metad
|
|||
}
|
||||
|
||||
// setMetadataPreparer prepares the SetMetadata request.
|
||||
func (client shareClient) setMetadataPreparer(timeout *int32, metadata map[string]string) (pipeline.Request, error) {
|
||||
func (client shareClient) setMetadataPreparer(timeout *int32, metadata map[string]string, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -620,6 +1046,9 @@ func (client shareClient) setMetadataPreparer(timeout *int32, metadata map[strin
|
|||
}
|
||||
}
|
||||
req.Header.Set("x-ms-version", ServiceVersion)
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
@ -634,12 +1063,14 @@ func (client shareClient) setMetadataResponder(resp pipeline.Response) (pipeline
|
|||
return &ShareSetMetadataResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
||||
// SetQuota sets quota for the specified share.
|
||||
// SetProperties sets properties for the specified share.
|
||||
//
|
||||
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
|
||||
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
|
||||
// Timeouts for File Service Operations.</a> quota is specifies the maximum size of the share, in gigabytes.
|
||||
func (client shareClient) SetQuota(ctx context.Context, timeout *int32, quota *int32) (*ShareSetQuotaResponse, error) {
|
||||
// Timeouts for File Service Operations.</a> quota is specifies the maximum size of the share, in gigabytes. accessTier
|
||||
// is specifies the access tier of the share. leaseID is if specified, the operation only succeeds if the resource's
|
||||
// lease is active and matches this ID.
|
||||
func (client shareClient) SetProperties(ctx context.Context, timeout *int32, quota *int32, accessTier ShareAccessTierType, leaseID *string) (*ShareSetPropertiesResponse, error) {
|
||||
if err := validate([]validation{
|
||||
{targetValue: timeout,
|
||||
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
||||
|
@ -649,19 +1080,19 @@ func (client shareClient) SetQuota(ctx context.Context, timeout *int32, quota *i
|
|||
chain: []constraint{{target: "quota", name: inclusiveMinimum, rule: 1, chain: nil}}}}}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := client.setQuotaPreparer(timeout, quota)
|
||||
req, err := client.setPropertiesPreparer(timeout, quota, accessTier, leaseID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.setQuotaResponder}, req)
|
||||
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.setPropertiesResponder}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*ShareSetQuotaResponse), err
|
||||
return resp.(*ShareSetPropertiesResponse), err
|
||||
}
|
||||
|
||||
// setQuotaPreparer prepares the SetQuota request.
|
||||
func (client shareClient) setQuotaPreparer(timeout *int32, quota *int32) (pipeline.Request, error) {
|
||||
// setPropertiesPreparer prepares the SetProperties request.
|
||||
func (client shareClient) setPropertiesPreparer(timeout *int32, quota *int32, accessTier ShareAccessTierType, leaseID *string) (pipeline.Request, error) {
|
||||
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
||||
if err != nil {
|
||||
return req, pipeline.NewError(err, "failed to create request")
|
||||
|
@ -677,16 +1108,22 @@ func (client shareClient) setQuotaPreparer(timeout *int32, quota *int32) (pipeli
|
|||
if quota != nil {
|
||||
req.Header.Set("x-ms-share-quota", strconv.FormatInt(int64(*quota), 10))
|
||||
}
|
||||
if accessTier != ShareAccessTierNone {
|
||||
req.Header.Set("x-ms-access-tier", string(accessTier))
|
||||
}
|
||||
if leaseID != nil {
|
||||
req.Header.Set("x-ms-lease-id", *leaseID)
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// setQuotaResponder handles the response to the SetQuota request.
|
||||
func (client shareClient) setQuotaResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
// setPropertiesResponder handles the response to the SetProperties request.
|
||||
func (client shareClient) setPropertiesResponder(resp pipeline.Response) (pipeline.Response, error) {
|
||||
err := validateResponse(resp, http.StatusOK)
|
||||
if resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Response().Body)
|
||||
resp.Response().Body.Close()
|
||||
return &ShareSetQuotaResponse{rawResponse: resp.Response()}, err
|
||||
return &ShareSetPropertiesResponse{rawResponse: resp.Response()}, err
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ package azfile
|
|||
|
||||
// UserAgent returns the UserAgent string to use when sending http.Requests.
|
||||
func UserAgent() string {
|
||||
return "Azure-SDK-For-Go/0.0.0 azfile/2019-02-02"
|
||||
return "Azure-SDK-For-Go/0.0.0 azfile/2020-02-10"
|
||||
}
|
||||
|
||||
// Version returns the semantic version (see http://semver.org) of the client.
|
||||
|
|
|
@ -23,7 +23,7 @@ type FileHTTPHeaders struct {
|
|||
|
||||
// FileCreationTime and FileLastWriteTime are handled by the Azure Files service with high-precision ISO-8601 timestamps.
|
||||
// Use this format to parse these fields and format them.
|
||||
const ISO8601 = "2006-01-02T15:04:05.0000000Z" // must have 0's for fractional seconds, because Files Service requires fixed width
|
||||
const ISO8601 = "2006-01-02T15:04:05.0000000Z" // must have 0's for fractional seconds, because Files Service requires fixed width
|
||||
|
||||
// SMBPropertyHolder is an interface designed for SMBPropertyAdapter, to identify valid response types for adapting.
|
||||
type SMBPropertyHolder interface {
|
||||
|
@ -70,11 +70,11 @@ type SMBProperties struct {
|
|||
// NOTE: If pointers are nil, we infer that you wish to preserve these properties. To clear them, point to an empty string.
|
||||
// NOTE: Permission strings are required to be sub-9KB. Please upload the permission to the share, and submit a key instead if yours exceeds this limit.
|
||||
PermissionString *string
|
||||
PermissionKey *string
|
||||
PermissionKey *string
|
||||
// In Windows, a 32 bit file attributes integer exists. This is that.
|
||||
FileAttributes *FileAttributeFlags
|
||||
// A UTC time-date string is specified below. A value of 'now' defaults to now. 'preserve' defaults to preserving the old case.
|
||||
FileCreationTime *time.Time
|
||||
FileCreationTime *time.Time
|
||||
FileLastWriteTime *time.Time
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ func (sp *SMBProperties) selectSMBPropertyValues(isDir bool, defaultPerm, defaul
|
|||
attribs = defaultAttribs
|
||||
if sp.FileAttributes != nil {
|
||||
attribs = sp.FileAttributes.String()
|
||||
if isDir && strings.ToLower(attribs) != "none" { // must test string, not sp.FileAttributes, since it may contain set bits that we don't convert
|
||||
if isDir && strings.ToLower(attribs) != "none" { // must test string, not sp.FileAttributes, since it may contain set bits that we don't convert
|
||||
// Directories need to have this attribute included, if setting any attributes.
|
||||
// We don't expose it in FileAttributes because it doesn't do anything useful to consumers of
|
||||
// this SDK. And because it always needs to be set for directories and not for non-directories,
|
||||
|
|
|
@ -15,7 +15,7 @@ More modifications have to be made after generation in order to fix issues that
|
|||
|
||||
### Settings
|
||||
``` yaml
|
||||
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/storage-dataplane-preview/specification/storage/data-plane/Microsoft.FileStorage/preview/2019-02-02/file.json
|
||||
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/storage-dataplane-preview/specification/storage/data-plane/Microsoft.FileStorage/preview/2020-02-10/file.json
|
||||
go: true
|
||||
output-folder: Go_FileStorage
|
||||
namespace: azfile
|
||||
|
|
Загрузка…
Ссылка в новой задаче