diff --git a/sdk/storage/azfile/CHANGELOG.md b/sdk/storage/azfile/CHANGELOG.md index f5369973f825..cab1236b22d6 100644 --- a/sdk/storage/azfile/CHANGELOG.md +++ b/sdk/storage/azfile/CHANGELOG.md @@ -1,5 +1,19 @@ # Release History +## 0.2.0 (Unreleased) + +### Features Added + +* Updated service version to STG 87(2022-11-02). + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + +* Updated version of azcore to 1.6.1 and azidentity to 1.3.0. + ## 0.1.1 (Unreleased) ### Features Added diff --git a/sdk/storage/azfile/assets.json b/sdk/storage/azfile/assets.json index 297645fadc04..5f867d599ba1 100644 --- a/sdk/storage/azfile/assets.json +++ b/sdk/storage/azfile/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azfile", - "Tag": "go/storage/azfile_600a15563c" + "Tag": "go/storage/azfile_fd8affe5ad" } diff --git a/sdk/storage/azfile/directory/client.go b/sdk/storage/azfile/directory/client.go index 3a0182e9b9b4..07a609261282 100644 --- a/sdk/storage/azfile/directory/client.go +++ b/sdk/storage/azfile/directory/client.go @@ -8,8 +8,10 @@ package directory import ( "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/internal/log" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/file" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/base" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported" @@ -32,9 +34,15 @@ type Client base.Client[generated.DirectoryClient] // - options - client options; pass nil to accept the default values func NewClientWithNoCredential(directoryURL string, options *ClientOptions) (*Client, error) { conOptions := shared.GetClientOptions(options) - pl := runtime.NewPipeline(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + plOpts := runtime.PipelineOptions{} + base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - return (*Client)(base.NewDirectoryClient(directoryURL, pl, nil)), nil + azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + if err != nil { + return nil, err + } + + return (*Client)(base.NewDirectoryClient(directoryURL, azClient, nil, (*base.ClientOptions)(conOptions))), nil } // NewClientWithSharedKeyCredential creates an instance of Client with the specified values. @@ -44,10 +52,17 @@ func NewClientWithNoCredential(directoryURL string, options *ClientOptions) (*Cl func NewClientWithSharedKeyCredential(directoryURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error) { authPolicy := exported.NewSharedKeyCredPolicy(cred) conOptions := shared.GetClientOptions(options) - conOptions.PerRetryPolicies = append(conOptions.PerRetryPolicies, authPolicy) - pl := runtime.NewPipeline(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + plOpts := runtime.PipelineOptions{ + PerRetry: []policy.Policy{authPolicy}, + } + base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) + + azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + if err != nil { + return nil, err + } - return (*Client)(base.NewDirectoryClient(directoryURL, pl, cred)), nil + return (*Client)(base.NewDirectoryClient(directoryURL, azClient, cred, (*base.ClientOptions)(conOptions))), nil } // NewClientFromConnectionString creates an instance of Client with the specified values. @@ -83,6 +98,10 @@ func (d *Client) sharedKey() *SharedKeyCredential { return base.SharedKey((*base.Client[generated.DirectoryClient])(d)) } +func (d *Client) getClientOptions() *base.ClientOptions { + return base.GetClientOptions((*base.Client[generated.DirectoryClient])(d)) +} + // URL returns the URL endpoint used by the Client object. func (d *Client) URL() string { return d.generated().Endpoint() @@ -93,7 +112,7 @@ func (d *Client) URL() string { func (d *Client) NewSubdirectoryClient(subDirectoryName string) *Client { subDirectoryName = url.PathEscape(strings.TrimRight(subDirectoryName, "/")) subDirectoryURL := runtime.JoinPaths(d.URL(), subDirectoryName) - return (*Client)(base.NewDirectoryClient(subDirectoryURL, d.generated().Pipeline(), d.sharedKey())) + return (*Client)(base.NewDirectoryClient(subDirectoryURL, d.generated().InternalClient(), d.sharedKey(), d.getClientOptions())) } // NewFileClient creates a new file.Client object by concatenating fileName to the end of this Client's URL. @@ -101,15 +120,26 @@ func (d *Client) NewSubdirectoryClient(subDirectoryName string) *Client { func (d *Client) NewFileClient(fileName string) *file.Client { fileName = url.PathEscape(fileName) fileURL := runtime.JoinPaths(d.URL(), fileName) - return (*file.Client)(base.NewFileClient(fileURL, d.generated().Pipeline(), d.sharedKey())) + + // TODO: remove new azcore.Client creation after the API for shallow copying with new client name is implemented + clOpts := d.getClientOptions() + azClient, err := azcore.NewClient(shared.FileClient, exported.ModuleVersion, *(base.GetPipelineOptions(clOpts)), &(clOpts.ClientOptions)) + if err != nil { + if log.Should(exported.EventError) { + log.Writef(exported.EventError, err.Error()) + } + return nil + } + + return (*file.Client)(base.NewFileClient(fileURL, azClient, d.sharedKey(), clOpts)) } // Create operation creates a new directory under the specified share or parent directory. // file.ParseNTFSFileAttributes method can be used to convert the file attributes returned in response to NTFSFileAttributes. // For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/create-directory. func (d *Client) Create(ctx context.Context, options *CreateOptions) (CreateResponse, error) { - fileAttributes, fileCreationTime, fileLastWriteTime, opts := options.format() - resp, err := d.generated().Create(ctx, fileAttributes, fileCreationTime, fileLastWriteTime, opts) + fileAttributes, opts := options.format() + resp, err := d.generated().Create(ctx, fileAttributes, opts) return resp, err } @@ -135,8 +165,8 @@ func (d *Client) GetProperties(ctx context.Context, options *GetPropertiesOption // file.ParseNTFSFileAttributes method can be used to convert the file attributes returned in response to NTFSFileAttributes. // For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-directory-properties. func (d *Client) SetProperties(ctx context.Context, options *SetPropertiesOptions) (SetPropertiesResponse, error) { - fileAttributes, fileCreationTime, fileLastWriteTime, opts := options.format() - resp, err := d.generated().SetProperties(ctx, fileAttributes, fileCreationTime, fileLastWriteTime, opts) + fileAttributes, opts := options.format() + resp, err := d.generated().SetProperties(ctx, fileAttributes, opts) return resp, err } @@ -195,7 +225,7 @@ func (d *Client) NewListFilesAndDirectoriesPager(options *ListFilesAndDirectorie if err != nil { return ListFilesAndDirectoriesResponse{}, err } - resp, err := d.generated().Pipeline().Do(req) + resp, err := d.generated().InternalClient().Pipeline().Do(req) if err != nil { return ListFilesAndDirectoriesResponse{}, err } diff --git a/sdk/storage/azfile/directory/client_test.go b/sdk/storage/azfile/directory/client_test.go index c1d6a372b1cb..0403ffd2859a 100644 --- a/sdk/storage/azfile/directory/client_test.go +++ b/sdk/storage/azfile/directory/client_test.go @@ -778,6 +778,7 @@ func (d *DirectoryRecordedTestsSuite) TestDirListFilesAndDirsDefault() { fileCtr += len(resp.Segment.Files) for _, dir := range resp.Segment.Directories { _require.NotNil(dir.Name) + _require.Greater(len(*dir.Name), 0) _require.NotNil(dir.ID) _require.Nil(dir.Attributes) _require.Nil(dir.PermissionKey) @@ -788,6 +789,7 @@ func (d *DirectoryRecordedTestsSuite) TestDirListFilesAndDirsDefault() { } for _, f := range resp.Segment.Files { _require.NotNil(f.Name) + _require.Greater(len(*f.Name), 0) _require.NotNil(f.ID) _require.Nil(f.Attributes) _require.Nil(f.PermissionKey) @@ -934,12 +936,16 @@ func (d *DirectoryRecordedTestsSuite) TestDirListFilesAndDirsWithPrefix() { _require.NoError(err) dirCtr += len(resp.Segment.Directories) fileCtr += len(resp.Segment.Files) + _require.NotNil(resp.Prefix) + _require.Equal(*resp.Prefix, "1") if len(resp.Segment.Directories) > 0 { _require.NotNil(resp.Segment.Directories[0].Name) + _require.Greater(len(*resp.Segment.Directories[0].Name), 0) _require.Equal(*resp.Segment.Directories[0].Name, "1"+dirName) } if len(resp.Segment.Files) > 0 { _require.NotNil(resp.Segment.Files[0].Name) + _require.Greater(len(*resp.Segment.Files[0].Name), 0) _require.Equal(*resp.Segment.Files[0].Name, "1"+fileName) } } diff --git a/sdk/storage/azfile/directory/constants.go b/sdk/storage/azfile/directory/constants.go index 2b16931bbc56..9c07ec47e6cb 100644 --- a/sdk/storage/azfile/directory/constants.go +++ b/sdk/storage/azfile/directory/constants.go @@ -22,3 +22,15 @@ const ( func PossibleListFilesIncludeTypeValues() []ListFilesIncludeType { return generated.PossibleListFilesIncludeTypeValues() } + +// ShareTokenIntent defines values for ShareTokenIntent +type ShareTokenIntent = generated.ShareTokenIntent + +const ( + ShareTokenIntentBackup ShareTokenIntent = generated.ShareTokenIntentBackup +) + +// PossibleShareTokenIntentValues returns the possible values for the ShareTokenIntent const type. +func PossibleShareTokenIntentValues() []ShareTokenIntent { + return generated.PossibleShareTokenIntentValues() +} diff --git a/sdk/storage/azfile/directory/models.go b/sdk/storage/azfile/directory/models.go index 950cf1a91d63..3902af8b1a7a 100644 --- a/sdk/storage/azfile/directory/models.go +++ b/sdk/storage/azfile/directory/models.go @@ -7,7 +7,6 @@ package directory import ( - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/file" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" @@ -36,24 +35,25 @@ type CreateOptions struct { Metadata map[string]*string } -func (o *CreateOptions) format() (fileAttributes string, fileCreationTime string, fileLastWriteTime string, createOptions *generated.DirectoryClientCreateOptions) { +func (o *CreateOptions) format() (string, *generated.DirectoryClientCreateOptions) { if o == nil { - return shared.FileAttributesDirectory, shared.DefaultCurrentTimeString, shared.DefaultCurrentTimeString, &generated.DirectoryClientCreateOptions{ - FilePermission: to.Ptr(shared.DefaultFilePermissionString), - } + return shared.FileAttributesDirectory, nil } - fileAttributes, fileCreationTime, fileLastWriteTime = o.FileSMBProperties.Format(true, shared.FileAttributesDirectory, shared.DefaultCurrentTimeString) + fileAttributes, fileCreationTime, fileLastWriteTime, fileChangeTime := o.FileSMBProperties.Format(true, shared.FileAttributesDirectory) - permission, permissionKey := o.FilePermissions.Format(shared.DefaultFilePermissionString) + permission, permissionKey := o.FilePermissions.Format() - createOptions = &generated.DirectoryClientCreateOptions{ + createOptions := &generated.DirectoryClientCreateOptions{ + FileChangeTime: fileChangeTime, + FileCreationTime: fileCreationTime, + FileLastWriteTime: fileLastWriteTime, FilePermission: permission, FilePermissionKey: permissionKey, Metadata: o.Metadata, } - return + return fileAttributes, createOptions } // --------------------------------------------------------------------------------------------------------------------- @@ -95,22 +95,23 @@ type SetPropertiesOptions struct { FilePermissions *file.Permissions } -func (o *SetPropertiesOptions) format() (fileAttributes string, fileCreationTime string, fileLastWriteTime string, setPropertiesOptions *generated.DirectoryClientSetPropertiesOptions) { +func (o *SetPropertiesOptions) format() (string, *generated.DirectoryClientSetPropertiesOptions) { if o == nil { - return shared.DefaultPreserveString, shared.DefaultPreserveString, shared.DefaultPreserveString, &generated.DirectoryClientSetPropertiesOptions{ - FilePermission: to.Ptr(shared.DefaultPreserveString), - } + return shared.DefaultPreserveString, nil } - fileAttributes, fileCreationTime, fileLastWriteTime = o.FileSMBProperties.Format(true, shared.DefaultPreserveString, shared.DefaultPreserveString) + fileAttributes, fileCreationTime, fileLastWriteTime, fileChangeTime := o.FileSMBProperties.Format(true, shared.DefaultPreserveString) - permission, permissionKey := o.FilePermissions.Format(shared.DefaultPreserveString) + permission, permissionKey := o.FilePermissions.Format() - setPropertiesOptions = &generated.DirectoryClientSetPropertiesOptions{ + setPropertiesOptions := &generated.DirectoryClientSetPropertiesOptions{ + FileChangeTime: fileChangeTime, + FileCreationTime: fileCreationTime, + FileLastWriteTime: fileLastWriteTime, FilePermission: permission, FilePermissionKey: permissionKey, } - return + return fileAttributes, setPropertiesOptions } // --------------------------------------------------------------------------------------------------------------------- diff --git a/sdk/storage/azfile/file/client.go b/sdk/storage/azfile/file/client.go index ad91fea6255a..235babcd9653 100644 --- a/sdk/storage/azfile/file/client.go +++ b/sdk/storage/azfile/file/client.go @@ -10,6 +10,8 @@ import ( "bytes" "context" "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming" "github.com/Azure/azure-sdk-for-go/sdk/internal/log" @@ -40,9 +42,15 @@ type Client base.Client[generated.FileClient] // The directoryPath is optional in the fileURL. If omitted, it points to file within the specified share. func NewClientWithNoCredential(fileURL string, options *ClientOptions) (*Client, error) { conOptions := shared.GetClientOptions(options) - pl := runtime.NewPipeline(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + plOpts := runtime.PipelineOptions{} + base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - return (*Client)(base.NewFileClient(fileURL, pl, nil)), nil + azClient, err := azcore.NewClient(shared.FileClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + if err != nil { + return nil, err + } + + return (*Client)(base.NewFileClient(fileURL, azClient, nil, (*base.ClientOptions)(conOptions))), nil } // NewClientWithSharedKeyCredential creates an instance of Client with the specified values. @@ -54,10 +62,17 @@ func NewClientWithNoCredential(fileURL string, options *ClientOptions) (*Client, func NewClientWithSharedKeyCredential(fileURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error) { authPolicy := exported.NewSharedKeyCredPolicy(cred) conOptions := shared.GetClientOptions(options) - conOptions.PerRetryPolicies = append(conOptions.PerRetryPolicies, authPolicy) - pl := runtime.NewPipeline(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + plOpts := runtime.PipelineOptions{ + PerRetry: []policy.Policy{authPolicy}, + } + base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) + + azClient, err := azcore.NewClient(shared.FileClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + if err != nil { + return nil, err + } - return (*Client)(base.NewFileClient(fileURL, pl, cred)), nil + return (*Client)(base.NewFileClient(fileURL, azClient, cred, (*base.ClientOptions)(conOptions))), nil } // NewClientFromConnectionString creates an instance of Client with the specified values. @@ -104,8 +119,8 @@ func (f *Client) URL() string { // ParseNTFSFileAttributes method can be used to convert the file attributes returned in response to NTFSFileAttributes. // For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/create-file. func (f *Client) Create(ctx context.Context, fileContentLength int64, options *CreateOptions) (CreateResponse, error) { - fileAttributes, fileCreationTime, fileLastWriteTime, fileCreateOptions, fileHTTPHeaders, leaseAccessConditions := options.format() - resp, err := f.generated().Create(ctx, fileContentLength, fileAttributes, fileCreationTime, fileLastWriteTime, fileCreateOptions, fileHTTPHeaders, leaseAccessConditions) + fileAttributes, fileCreateOptions, fileHTTPHeaders, leaseAccessConditions := options.format() + resp, err := f.generated().Create(ctx, fileContentLength, fileAttributes, fileCreateOptions, fileHTTPHeaders, leaseAccessConditions) return resp, err } @@ -130,8 +145,8 @@ func (f *Client) GetProperties(ctx context.Context, options *GetPropertiesOption // ParseNTFSFileAttributes method can be used to convert the file attributes returned in response to NTFSFileAttributes. // For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-file-properties. func (f *Client) SetHTTPHeaders(ctx context.Context, options *SetHTTPHeadersOptions) (SetHTTPHeadersResponse, error) { - fileAttributes, fileCreationTime, fileLastWriteTime, opts, fileHTTPHeaders, leaseAccessConditions := options.format() - resp, err := f.generated().SetHTTPHeaders(ctx, fileAttributes, fileCreationTime, fileLastWriteTime, opts, fileHTTPHeaders, leaseAccessConditions) + fileAttributes, opts, fileHTTPHeaders, leaseAccessConditions := options.format() + resp, err := f.generated().SetHTTPHeaders(ctx, fileAttributes, opts, fileHTTPHeaders, leaseAccessConditions) return resp, err } @@ -166,8 +181,8 @@ func (f *Client) AbortCopy(ctx context.Context, copyID string, options *AbortCop // Resize operation resizes the file to the specified size. // For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-file-properties. func (f *Client) Resize(ctx context.Context, size int64, options *ResizeOptions) (ResizeResponse, error) { - fileAttributes, fileCreationTime, fileLastWriteTime, opts, leaseAccessConditions := options.format(size) - resp, err := f.generated().SetHTTPHeaders(ctx, fileAttributes, fileCreationTime, fileLastWriteTime, opts, nil, leaseAccessConditions) + fileAttributes, opts, leaseAccessConditions := options.format(size) + resp, err := f.generated().SetHTTPHeaders(ctx, fileAttributes, opts, nil, leaseAccessConditions) return resp, err } diff --git a/sdk/storage/azfile/file/constants.go b/sdk/storage/azfile/file/constants.go index c5687bd1b3b5..b6eea46e2d93 100644 --- a/sdk/storage/azfile/file/constants.go +++ b/sdk/storage/azfile/file/constants.go @@ -76,3 +76,15 @@ type TransferValidationType = exported.TransferValidationType // TransferValidationTypeMD5 is a TransferValidationType used to provide a precomputed MD5. type TransferValidationTypeMD5 = exported.TransferValidationTypeMD5 + +// ShareTokenIntent defines values for ShareTokenIntent +type ShareTokenIntent = generated.ShareTokenIntent + +const ( + ShareTokenIntentBackup ShareTokenIntent = generated.ShareTokenIntentBackup +) + +// PossibleShareTokenIntentValues returns the possible values for the ShareTokenIntent const type. +func PossibleShareTokenIntentValues() []ShareTokenIntent { + return generated.PossibleShareTokenIntentValues() +} diff --git a/sdk/storage/azfile/file/models.go b/sdk/storage/azfile/file/models.go index 22f9f814fee5..f0c10114df85 100644 --- a/sdk/storage/azfile/file/models.go +++ b/sdk/storage/azfile/file/models.go @@ -9,7 +9,6 @@ package file import ( "encoding/binary" "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/shared" @@ -81,28 +80,25 @@ type CreateOptions struct { Metadata map[string]*string } -func (o *CreateOptions) format() (fileAttributes string, fileCreationTime string, fileLastWriteTime string, - createOptions *generated.FileClientCreateOptions, fileHTTPHeaders *generated.ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) { +func (o *CreateOptions) format() (string, *generated.FileClientCreateOptions, *generated.ShareFileHTTPHeaders, *LeaseAccessConditions) { if o == nil { - return shared.FileAttributesNone, shared.DefaultCurrentTimeString, shared.DefaultCurrentTimeString, &generated.FileClientCreateOptions{ - FilePermission: to.Ptr(shared.DefaultFilePermissionString), - }, nil, nil + return shared.FileAttributesNone, nil, nil, nil } - fileAttributes, fileCreationTime, fileLastWriteTime = o.SMBProperties.Format(false, shared.FileAttributesNone, shared.DefaultCurrentTimeString) + fileAttributes, fileCreationTime, fileLastWriteTime, fileChangeTime := o.SMBProperties.Format(false, shared.FileAttributesNone) - permission, permissionKey := o.Permissions.Format(shared.DefaultFilePermissionString) + permission, permissionKey := o.Permissions.Format() - createOptions = &generated.FileClientCreateOptions{ + createOptions := &generated.FileClientCreateOptions{ + FileChangeTime: fileChangeTime, + FileCreationTime: fileCreationTime, + FileLastWriteTime: fileLastWriteTime, FilePermission: permission, FilePermissionKey: permissionKey, Metadata: o.Metadata, } - fileHTTPHeaders = o.HTTPHeaders - leaseAccessConditions = o.LeaseAccessConditions - - return + return fileAttributes, createOptions, o.HTTPHeaders, o.LeaseAccessConditions } // --------------------------------------------------------------------------------------------------------------------- @@ -156,28 +152,25 @@ type SetHTTPHeadersOptions struct { LeaseAccessConditions *LeaseAccessConditions } -func (o *SetHTTPHeadersOptions) format() (fileAttributes string, fileCreationTime string, fileLastWriteTime string, - opts *generated.FileClientSetHTTPHeadersOptions, fileHTTPHeaders *generated.ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) { +func (o *SetHTTPHeadersOptions) format() (string, *generated.FileClientSetHTTPHeadersOptions, *generated.ShareFileHTTPHeaders, *LeaseAccessConditions) { if o == nil { - return shared.DefaultPreserveString, shared.DefaultPreserveString, shared.DefaultPreserveString, &generated.FileClientSetHTTPHeadersOptions{ - FilePermission: to.Ptr(shared.DefaultPreserveString), - }, nil, nil + return shared.DefaultPreserveString, nil, nil, nil } - fileAttributes, fileCreationTime, fileLastWriteTime = o.SMBProperties.Format(false, shared.DefaultPreserveString, shared.DefaultPreserveString) + fileAttributes, fileCreationTime, fileLastWriteTime, fileChangeTime := o.SMBProperties.Format(false, shared.DefaultPreserveString) - permission, permissionKey := o.Permissions.Format(shared.DefaultPreserveString) + permission, permissionKey := o.Permissions.Format() - opts = &generated.FileClientSetHTTPHeadersOptions{ + opts := &generated.FileClientSetHTTPHeadersOptions{ + FileChangeTime: fileChangeTime, + FileCreationTime: fileCreationTime, + FileLastWriteTime: fileLastWriteTime, FileContentLength: o.FileContentLength, FilePermission: permission, FilePermissionKey: permissionKey, } - fileHTTPHeaders = o.HTTPHeaders - leaseAccessConditions = o.LeaseAccessConditions - - return + return fileAttributes, opts, o.HTTPHeaders, o.LeaseAccessConditions } // --------------------------------------------------------------------------------------------------------------------- @@ -444,20 +437,19 @@ type ResizeOptions struct { LeaseAccessConditions *LeaseAccessConditions } -func (o *ResizeOptions) format(contentLength int64) (fileAttributes string, fileCreationTime string, fileLastWriteTime string, - opts *generated.FileClientSetHTTPHeadersOptions, leaseAccessConditions *LeaseAccessConditions) { - fileAttributes, fileCreationTime, fileLastWriteTime = shared.DefaultPreserveString, shared.DefaultPreserveString, shared.DefaultPreserveString +func (o *ResizeOptions) format(contentLength int64) (string, *generated.FileClientSetHTTPHeadersOptions, *LeaseAccessConditions) { + fileAttributes := shared.DefaultPreserveString - opts = &generated.FileClientSetHTTPHeadersOptions{ + opts := &generated.FileClientSetHTTPHeadersOptions{ FileContentLength: &contentLength, - FilePermission: to.Ptr(shared.DefaultPreserveString), } + var leaseAccessConditions *LeaseAccessConditions = nil if o != nil { leaseAccessConditions = o.LeaseAccessConditions } - return + return fileAttributes, opts, leaseAccessConditions } // --------------------------------------------------------------------------------------------------------------------- diff --git a/sdk/storage/azfile/go.mod b/sdk/storage/azfile/go.mod index cbd96fa64efc..c05d498eee5b 100644 --- a/sdk/storage/azfile/go.mod +++ b/sdk/storage/azfile/go.mod @@ -3,26 +3,26 @@ module github.com/Azure/azure-sdk-for-go/sdk/storage/azfile go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 github.com/stretchr/testify v1.7.1 ) require ( - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dnaeon/go-vcr v1.1.0 // indirect + github.com/dnaeon/go-vcr v1.2.0 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.7.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/crypto v0.10.0 // indirect + golang.org/x/net v0.11.0 // indirect + golang.org/x/sys v0.9.0 // indirect + golang.org/x/text v0.10.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/storage/azfile/go.sum b/sdk/storage/azfile/go.sum index 8f03fb9639d6..34f33e9e8e7c 100644 --- a/sdk/storage/azfile/go.sum +++ b/sdk/storage/azfile/go.sum @@ -1,18 +1,18 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 h1:u/LLAOFgsMv7HmNL4Qufg58y+qElGOt5qv0z1mURkRY= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0/go.mod h1:2e8rMJtl2+2j+HXbTBwnyGpm5Nou7KhvSfxOq8JpTag= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -27,20 +27,20 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/storage/azfile/internal/base/clients.go b/sdk/storage/azfile/internal/base/clients.go index 93317d4dc29b..101a58a5f85e 100644 --- a/sdk/storage/azfile/internal/base/clients.go +++ b/sdk/storage/azfile/internal/base/clients.go @@ -16,11 +16,16 @@ import ( // ClientOptions contains the optional parameters when creating a Client. type ClientOptions struct { azcore.ClientOptions + AllowTrailingDot *bool + FileRequestIntent *generated.ShareTokenIntent + AllowSourceTrailingDot *bool + pipelineOptions *runtime.PipelineOptions } type Client[T any] struct { inner *T sharedKey *exported.SharedKeyCredential + options *ClientOptions } func InnerClient[T any](client *Client[T]) *T { @@ -31,30 +36,46 @@ func SharedKey[T any](client *Client[T]) *exported.SharedKeyCredential { return client.sharedKey } -func NewServiceClient(serviceURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.ServiceClient] { +func GetClientOptions[T any](client *Client[T]) *ClientOptions { + return client.options +} + +func GetPipelineOptions(clOpts *ClientOptions) *runtime.PipelineOptions { + return clOpts.pipelineOptions +} + +func SetPipelineOptions(clOpts *ClientOptions, plOpts *runtime.PipelineOptions) { + clOpts.pipelineOptions = plOpts +} + +func NewServiceClient(serviceURL string, azClient *azcore.Client, sharedKey *exported.SharedKeyCredential, options *ClientOptions) *Client[generated.ServiceClient] { return &Client[generated.ServiceClient]{ - inner: generated.NewServiceClient(serviceURL, pipeline), + inner: generated.NewServiceClient(serviceURL, azClient), sharedKey: sharedKey, + options: options, } } -func NewShareClient(shareURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.ShareClient] { +func NewShareClient(shareURL string, azClient *azcore.Client, sharedKey *exported.SharedKeyCredential, options *ClientOptions) *Client[generated.ShareClient] { return &Client[generated.ShareClient]{ - inner: generated.NewShareClient(shareURL, pipeline), + inner: generated.NewShareClient(shareURL, options.FileRequestIntent, azClient), sharedKey: sharedKey, + options: options, } } -func NewDirectoryClient(directoryURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.DirectoryClient] { +func NewDirectoryClient(directoryURL string, azClient *azcore.Client, sharedKey *exported.SharedKeyCredential, options *ClientOptions) *Client[generated.DirectoryClient] { return &Client[generated.DirectoryClient]{ - inner: generated.NewDirectoryClient(directoryURL, pipeline), + inner: generated.NewDirectoryClient(directoryURL, options.AllowTrailingDot, options.FileRequestIntent, options.AllowSourceTrailingDot, azClient), sharedKey: sharedKey, + options: options, } } -func NewFileClient(fileURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.FileClient] { +func NewFileClient(fileURL string, azClient *azcore.Client, sharedKey *exported.SharedKeyCredential, options *ClientOptions) *Client[generated.FileClient] { return &Client[generated.FileClient]{ - inner: generated.NewFileClient(fileURL, pipeline), + inner: generated.NewFileClient(fileURL, options.AllowTrailingDot, options.FileRequestIntent, options.AllowSourceTrailingDot, azClient), sharedKey: sharedKey, + options: options, } } diff --git a/sdk/storage/azfile/internal/exported/file_permissions.go b/sdk/storage/azfile/internal/exported/file_permissions.go index 73fce6afb27c..3e38790818a2 100644 --- a/sdk/storage/azfile/internal/exported/file_permissions.go +++ b/sdk/storage/azfile/internal/exported/file_permissions.go @@ -19,13 +19,13 @@ type Permissions struct { } // Format returns file permission string and permission key. -func (p *Permissions) Format(defaultFilePermissionStr string) (*string, *string) { +func (p *Permissions) Format() (*string, *string) { if p == nil { - return &defaultFilePermissionStr, nil + return nil, nil } if p.Permission == nil && p.PermissionKey == nil { - return &defaultFilePermissionStr, nil + return nil, nil } else { return p.Permission, p.PermissionKey } diff --git a/sdk/storage/azfile/internal/exported/log_events.go b/sdk/storage/azfile/internal/exported/log_events.go index d33528ea8eb2..af65aa898334 100644 --- a/sdk/storage/azfile/internal/exported/log_events.go +++ b/sdk/storage/azfile/internal/exported/log_events.go @@ -14,4 +14,7 @@ import ( const ( // EventUpload is used when we compute number of chunks to upload and size of each chunk. EventUpload log.Event = "azfile.Upload" + + // EventError is used for logging errors. + EventError log.Event = "azfile.Error" ) diff --git a/sdk/storage/azfile/internal/exported/smb_property.go b/sdk/storage/azfile/internal/exported/smb_property.go index d5957561963b..c59e7210c591 100644 --- a/sdk/storage/azfile/internal/exported/smb_property.go +++ b/sdk/storage/azfile/internal/exported/smb_property.go @@ -8,6 +8,7 @@ package exported import ( "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" "strings" "time" @@ -22,12 +23,14 @@ type SMBProperties struct { CreationTime *time.Time // The Coordinated Universal Time (UTC) last write time for the file/directory. Default value is 'now'. LastWriteTime *time.Time + // The Coordinated Universal Time (UTC) change time for the file/directory. Default value is 'now'. + ChangeTime *time.Time } // Format returns file attributes, creation time and last write time. -func (sp *SMBProperties) Format(isDir bool, defaultFileAttributes string, defaultCurrentTimeString string) (fileAttributes string, creationTime string, lastWriteTime string) { +func (sp *SMBProperties) Format(isDir bool, defaultFileAttributes string) (fileAttributes string, creationTime *string, lastWriteTime *string, changeTime *string) { if sp == nil { - return defaultFileAttributes, defaultCurrentTimeString, defaultCurrentTimeString + return defaultFileAttributes, nil, nil, nil } fileAttributes = defaultFileAttributes @@ -41,14 +44,19 @@ func (sp *SMBProperties) Format(isDir bool, defaultFileAttributes string, defaul } } - creationTime = defaultCurrentTimeString + creationTime = nil if sp.CreationTime != nil { - creationTime = sp.CreationTime.UTC().Format(generated.ISO8601) + creationTime = to.Ptr(sp.CreationTime.UTC().Format(generated.ISO8601)) } - lastWriteTime = defaultCurrentTimeString + lastWriteTime = nil if sp.LastWriteTime != nil { - lastWriteTime = sp.LastWriteTime.UTC().Format(generated.ISO8601) + lastWriteTime = to.Ptr(sp.LastWriteTime.UTC().Format(generated.ISO8601)) + } + + changeTime = nil + if sp.ChangeTime != nil { + changeTime = to.Ptr(sp.ChangeTime.UTC().Format(generated.ISO8601)) } return diff --git a/sdk/storage/azfile/internal/generated/autorest.md b/sdk/storage/azfile/internal/generated/autorest.md index 634ccff33f46..a8b1c8ddd098 100644 --- a/sdk/storage/azfile/internal/generated/autorest.md +++ b/sdk/storage/azfile/internal/generated/autorest.md @@ -7,7 +7,7 @@ go: true clear-output-folder: false version: "^3.0.0" license-header: MICROSOFT_MIT_NO_VERSION -input-file: "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/bbea558ac43d6ebec72455233c84b0158c89fcda/specification/storage/data-plane/Microsoft.FileStorage/preview/2020-10-02/file.json" +input-file: "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/7dcd41cd28d46eb256bac034760a7e2f0a036238/specification/storage/data-plane/Microsoft.FileStorage/preview/2022-11-02/file.json" credential-scope: "https://storage.azure.com/.default" output-folder: ../generated file-prefix: "zz_" @@ -19,7 +19,7 @@ modelerfour: seal-single-value-enum-by-default: true lenient-model-deduplication: true export-clients: true -use: "@autorest/go@4.0.0-preview.45" +use: "@autorest/go@4.0.0-preview.49" ``` ### Don't include share name, directory, or file name in path - we have direct URIs @@ -141,6 +141,7 @@ directive: ``` yaml directive: - from: + - zz_directory_client.go - zz_file_client.go - zz_models.go where: $ @@ -257,6 +258,10 @@ directive: where: $.parameters.FileLastWriteTime transform: > $.format = "str"; +- from: swagger-document + where: $.parameters.FileChangeTime + transform: > + $.format = "str"; ``` ### Remove pager methods and export various generated methods in directory client @@ -307,3 +312,24 @@ directive: return $. replace(/ShareUsageBytes\s+\*int32/g, `ShareUsageBytes *int64`); ``` + +### Convert StringEncoded to string type + +``` yaml +directive: + - from: zz_models.go + where: $ + transform: >- + return $. + replace(/\*StringEncoded/g, `*string`); +``` + +### Removing UnmarshalXML for Handle to create custom UnmarshalXML function + +``` yaml +directive: +- from: swagger-document + where: $.definitions + transform: > + $.Handle["x-ms-go-omit-serde-methods"] = true; +``` diff --git a/sdk/storage/azfile/internal/generated/directory_client.go b/sdk/storage/azfile/internal/generated/directory_client.go index 11a75a9f50c8..cd81b4db8272 100644 --- a/sdk/storage/azfile/internal/generated/directory_client.go +++ b/sdk/storage/azfile/internal/generated/directory_client.go @@ -6,7 +6,9 @@ package generated -import "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) const ( // ISO8601 is used for formatting file creation, last write and change time. @@ -17,6 +19,23 @@ func (client *DirectoryClient) Endpoint() string { return client.endpoint } -func (client *DirectoryClient) Pipeline() runtime.Pipeline { - return client.pl +func (client *DirectoryClient) InternalClient() *azcore.Client { + return client.internal +} + +// NewDirectoryClient creates a new instance of DirectoryClient with the specified values. +// - endpoint - The URL of the service account, share, directory or file that is the target of the desired operation. +// - allowTrailingDot - If true, the trailing dot will not be trimmed from the target URI. +// - fileRequestIntent - Valid value is backup +// - allowSourceTrailingDot - If true, the trailing dot will not be trimmed from the source URI. +// - azClient - azcore.Client is a basic HTTP client. It consists of a pipeline and tracing provider. +func NewDirectoryClient(endpoint string, allowTrailingDot *bool, fileRequestIntent *ShareTokenIntent, allowSourceTrailingDot *bool, azClient *azcore.Client) *DirectoryClient { + client := &DirectoryClient{ + internal: azClient, + endpoint: endpoint, + allowTrailingDot: allowTrailingDot, + fileRequestIntent: fileRequestIntent, + allowSourceTrailingDot: allowSourceTrailingDot, + } + return client } diff --git a/sdk/storage/azfile/internal/generated/file_client.go b/sdk/storage/azfile/internal/generated/file_client.go index f4a01a783938..e3c415e7529d 100644 --- a/sdk/storage/azfile/internal/generated/file_client.go +++ b/sdk/storage/azfile/internal/generated/file_client.go @@ -6,12 +6,31 @@ package generated -import "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) func (client *FileClient) Endpoint() string { return client.endpoint } -func (client *FileClient) Pipeline() runtime.Pipeline { - return client.pl +func (client *FileClient) InternalClient() *azcore.Client { + return client.internal +} + +// NewFileClient creates a new instance of FileClient with the specified values. +// - endpoint - The URL of the service account, share, directory or file that is the target of the desired operation. +// - allowTrailingDot - If true, the trailing dot will not be trimmed from the target URI. +// - fileRequestIntent - Valid value is backup +// - allowSourceTrailingDot - If true, the trailing dot will not be trimmed from the source URI. +// - azClient - azcore.Client is a basic HTTP client. It consists of a pipeline and tracing provider. +func NewFileClient(endpoint string, allowTrailingDot *bool, fileRequestIntent *ShareTokenIntent, allowSourceTrailingDot *bool, azClient *azcore.Client) *FileClient { + client := &FileClient{ + internal: azClient, + endpoint: endpoint, + allowTrailingDot: allowTrailingDot, + fileRequestIntent: fileRequestIntent, + allowSourceTrailingDot: allowSourceTrailingDot, + } + return client } diff --git a/sdk/storage/azfile/internal/generated/models.go b/sdk/storage/azfile/internal/generated/models.go index 6450b7de2e82..ca84814f3392 100644 --- a/sdk/storage/azfile/internal/generated/models.go +++ b/sdk/storage/azfile/internal/generated/models.go @@ -6,6 +6,13 @@ package generated +import ( + "encoding/base64" + "encoding/xml" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "time" +) + type TransactionalContentSetter interface { SetMD5([]byte) // add SetCRC64() when Azure File service starts supporting it. @@ -23,3 +30,128 @@ type SourceContentSetter interface { func (f *FileClientUploadRangeFromURLOptions) SetSourceContentCRC64(v []byte) { f.SourceContentCRC64 = v } + +// Custom MarshalXML/UnmarshalXML functions for types that need special handling. + +// MarshalXML implements the xml.Marshaller interface for type Handle. +func (h Handle) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { + type alias Handle + aux := &struct { + *alias + LastReconnectTime *timeRFC1123 `xml:"LastReconnectTime"` + OpenTime *timeRFC1123 `xml:"OpenTime"` + }{ + alias: (*alias)(&h), + LastReconnectTime: (*timeRFC1123)(h.LastReconnectTime), + OpenTime: (*timeRFC1123)(h.OpenTime), + } + return enc.EncodeElement(aux, start) +} + +// UnmarshalXML implements the xml.Unmarshaller interface for type Handle. +func (h *Handle) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { + type alias Handle + aux := &struct { + *alias + Path *StringEncoded `xml:"Path"` + LastReconnectTime *timeRFC1123 `xml:"LastReconnectTime"` + OpenTime *timeRFC1123 `xml:"OpenTime"` + }{ + alias: (*alias)(h), + } + if err := dec.DecodeElement(aux, &start); err != nil { + return err + } + h.LastReconnectTime = (*time.Time)(aux.LastReconnectTime) + h.OpenTime = (*time.Time)(aux.OpenTime) + if aux.Path != nil { + if aux.Path.Encoded != nil && *aux.Path.Encoded { + name, err := base64.StdEncoding.DecodeString(*aux.Path.Content) + if err != nil { + return err + } + h.Path = to.Ptr(string(name)) + } else { + h.Path = aux.Path.Content + } + } + return nil +} + +// UnmarshalXML implements the xml.Unmarshaller interface for type Directory. +func (d *Directory) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { + type alias Directory + aux := &struct { + *alias + Name *StringEncoded `xml:"Name"` + }{ + alias: (*alias)(d), + } + if err := dec.DecodeElement(aux, &start); err != nil { + return err + } + if aux.Name != nil { + if aux.Name.Encoded != nil && *aux.Name.Encoded { + name, err := base64.StdEncoding.DecodeString(*aux.Name.Content) + if err != nil { + return err + } + d.Name = to.Ptr(string(name)) + } else { + d.Name = aux.Name.Content + } + } + return nil +} + +// UnmarshalXML implements the xml.Unmarshaller interface for type Directory. +func (f *File) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { + type alias File + aux := &struct { + *alias + Name *StringEncoded `xml:"Name"` + }{ + alias: (*alias)(f), + } + if err := dec.DecodeElement(aux, &start); err != nil { + return err + } + if aux.Name != nil { + if aux.Name.Encoded != nil && *aux.Name.Encoded { + name, err := base64.StdEncoding.DecodeString(*aux.Name.Content) + if err != nil { + return err + } + f.Name = to.Ptr(string(name)) + } else { + f.Name = aux.Name.Content + } + } + return nil +} + +// UnmarshalXML implements the xml.Unmarshaller interface for type Directory. +func (l *ListFilesAndDirectoriesSegmentResponse) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { + type alias ListFilesAndDirectoriesSegmentResponse + aux := &struct { + *alias + Prefix *StringEncoded `xml:"Prefix"` + }{ + alias: (*alias)(l), + } + if err := dec.DecodeElement(aux, &start); err != nil { + return err + } + if aux.Prefix != nil { + if aux.Prefix.Encoded != nil && *aux.Prefix.Encoded { + name, err := base64.StdEncoding.DecodeString(*aux.Prefix.Content) + if err != nil { + return err + } + l.Prefix = to.Ptr(string(name)) + } else { + l.Prefix = aux.Prefix.Content + } + } + return nil +} diff --git a/sdk/storage/azfile/internal/generated/service_client.go b/sdk/storage/azfile/internal/generated/service_client.go index 1f449b955e82..8c99594b7dbd 100644 --- a/sdk/storage/azfile/internal/generated/service_client.go +++ b/sdk/storage/azfile/internal/generated/service_client.go @@ -6,12 +6,25 @@ package generated -import "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) func (client *ServiceClient) Endpoint() string { return client.endpoint } -func (client *ServiceClient) Pipeline() runtime.Pipeline { - return client.pl +func (client *ServiceClient) InternalClient() *azcore.Client { + return client.internal +} + +// NewServiceClient creates a new instance of ServiceClient with the specified values. +// - endpoint - The URL of the service account, share, directory or file that is the target of the desired operation. +// - azClient - azcore.Client is a basic HTTP client. It consists of a pipeline and tracing provider. +func NewServiceClient(endpoint string, azClient *azcore.Client) *ServiceClient { + client := &ServiceClient{ + internal: azClient, + endpoint: endpoint, + } + return client } diff --git a/sdk/storage/azfile/internal/generated/share_client.go b/sdk/storage/azfile/internal/generated/share_client.go index 040785814606..14f4d5bdefa2 100644 --- a/sdk/storage/azfile/internal/generated/share_client.go +++ b/sdk/storage/azfile/internal/generated/share_client.go @@ -6,12 +6,27 @@ package generated -import "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) func (client *ShareClient) Endpoint() string { return client.endpoint } -func (client *ShareClient) Pipeline() runtime.Pipeline { - return client.pl +func (client *ShareClient) InternalClient() *azcore.Client { + return client.internal +} + +// NewShareClient creates a new instance of ShareClient with the specified values. +// - endpoint - The URL of the service account, share, directory or file that is the target of the desired operation. +// - fileRequestIntent - Valid value is backup +// - azClient - azcore.Client is a basic HTTP client. It consists of a pipeline and tracing provider. +func NewShareClient(endpoint string, fileRequestIntent *ShareTokenIntent, azClient *azcore.Client) *ShareClient { + client := &ShareClient{ + internal: azClient, + endpoint: endpoint, + fileRequestIntent: fileRequestIntent, + } + return client } diff --git a/sdk/storage/azfile/internal/generated/zz_constants.go b/sdk/storage/azfile/internal/generated/zz_constants.go index 13ee55aa841e..2f356c7c3f63 100644 --- a/sdk/storage/azfile/internal/generated/zz_constants.go +++ b/sdk/storage/azfile/internal/generated/zz_constants.go @@ -12,19 +12,19 @@ package generated type CopyStatusType string const ( - CopyStatusTypePending CopyStatusType = "pending" - CopyStatusTypeSuccess CopyStatusType = "success" CopyStatusTypeAborted CopyStatusType = "aborted" CopyStatusTypeFailed CopyStatusType = "failed" + CopyStatusTypePending CopyStatusType = "pending" + CopyStatusTypeSuccess CopyStatusType = "success" ) // PossibleCopyStatusTypeValues returns the possible values for the CopyStatusType const type. func PossibleCopyStatusTypeValues() []CopyStatusType { return []CopyStatusType{ - CopyStatusTypePending, - CopyStatusTypeSuccess, CopyStatusTypeAborted, CopyStatusTypeFailed, + CopyStatusTypePending, + CopyStatusTypeSuccess, } } @@ -43,18 +43,33 @@ func PossibleDeleteSnapshotsOptionTypeValues() []DeleteSnapshotsOptionType { } } +type FileLastWrittenMode string + +const ( + FileLastWrittenModeNow FileLastWrittenMode = "Now" + FileLastWrittenModePreserve FileLastWrittenMode = "Preserve" +) + +// PossibleFileLastWrittenModeValues returns the possible values for the FileLastWrittenMode const type. +func PossibleFileLastWrittenModeValues() []FileLastWrittenMode { + return []FileLastWrittenMode{ + FileLastWrittenModeNow, + FileLastWrittenModePreserve, + } +} + type FileRangeWriteType string const ( - FileRangeWriteTypeUpdate FileRangeWriteType = "update" FileRangeWriteTypeClear FileRangeWriteType = "clear" + FileRangeWriteTypeUpdate FileRangeWriteType = "update" ) // PossibleFileRangeWriteTypeValues returns the possible values for the FileRangeWriteType const type. func PossibleFileRangeWriteTypeValues() []FileRangeWriteType { return []FileRangeWriteType{ - FileRangeWriteTypeUpdate, FileRangeWriteTypeClear, + FileRangeWriteTypeUpdate, } } @@ -62,15 +77,15 @@ func PossibleFileRangeWriteTypeValues() []FileRangeWriteType { type LeaseDurationType string const ( - LeaseDurationTypeInfinite LeaseDurationType = "infinite" LeaseDurationTypeFixed LeaseDurationType = "fixed" + LeaseDurationTypeInfinite LeaseDurationType = "infinite" ) // PossibleLeaseDurationTypeValues returns the possible values for the LeaseDurationType const type. func PossibleLeaseDurationTypeValues() []LeaseDurationType { return []LeaseDurationType{ - LeaseDurationTypeInfinite, LeaseDurationTypeFixed, + LeaseDurationTypeInfinite, } } @@ -79,20 +94,20 @@ type LeaseStateType string const ( LeaseStateTypeAvailable LeaseStateType = "available" - LeaseStateTypeLeased LeaseStateType = "leased" - LeaseStateTypeExpired LeaseStateType = "expired" LeaseStateTypeBreaking LeaseStateType = "breaking" LeaseStateTypeBroken LeaseStateType = "broken" + LeaseStateTypeExpired LeaseStateType = "expired" + LeaseStateTypeLeased LeaseStateType = "leased" ) // PossibleLeaseStateTypeValues returns the possible values for the LeaseStateType const type. func PossibleLeaseStateTypeValues() []LeaseStateType { return []LeaseStateType{ LeaseStateTypeAvailable, - LeaseStateTypeLeased, - LeaseStateTypeExpired, LeaseStateTypeBreaking, LeaseStateTypeBroken, + LeaseStateTypeExpired, + LeaseStateTypeLeased, } } @@ -115,51 +130,51 @@ func PossibleLeaseStatusTypeValues() []LeaseStatusType { type ListFilesIncludeType string const ( - ListFilesIncludeTypeTimestamps ListFilesIncludeType = "Timestamps" - ListFilesIncludeTypeEtag ListFilesIncludeType = "Etag" ListFilesIncludeTypeAttributes ListFilesIncludeType = "Attributes" + ListFilesIncludeTypeEtag ListFilesIncludeType = "Etag" ListFilesIncludeTypePermissionKey ListFilesIncludeType = "PermissionKey" + ListFilesIncludeTypeTimestamps ListFilesIncludeType = "Timestamps" ) // PossibleListFilesIncludeTypeValues returns the possible values for the ListFilesIncludeType const type. func PossibleListFilesIncludeTypeValues() []ListFilesIncludeType { return []ListFilesIncludeType{ - ListFilesIncludeTypeTimestamps, - ListFilesIncludeTypeEtag, ListFilesIncludeTypeAttributes, + ListFilesIncludeTypeEtag, ListFilesIncludeTypePermissionKey, + ListFilesIncludeTypeTimestamps, } } type ListSharesIncludeType string const ( - ListSharesIncludeTypeSnapshots ListSharesIncludeType = "snapshots" - ListSharesIncludeTypeMetadata ListSharesIncludeType = "metadata" ListSharesIncludeTypeDeleted ListSharesIncludeType = "deleted" + ListSharesIncludeTypeMetadata ListSharesIncludeType = "metadata" + ListSharesIncludeTypeSnapshots ListSharesIncludeType = "snapshots" ) // PossibleListSharesIncludeTypeValues returns the possible values for the ListSharesIncludeType const type. func PossibleListSharesIncludeTypeValues() []ListSharesIncludeType { return []ListSharesIncludeType{ - ListSharesIncludeTypeSnapshots, - ListSharesIncludeTypeMetadata, ListSharesIncludeTypeDeleted, + ListSharesIncludeTypeMetadata, + ListSharesIncludeTypeSnapshots, } } type PermissionCopyModeType string const ( - PermissionCopyModeTypeSource PermissionCopyModeType = "source" PermissionCopyModeTypeOverride PermissionCopyModeType = "override" + PermissionCopyModeTypeSource PermissionCopyModeType = "source" ) // PossiblePermissionCopyModeTypeValues returns the possible values for the PermissionCopyModeType const type. func PossiblePermissionCopyModeTypeValues() []PermissionCopyModeType { return []PermissionCopyModeType{ - PermissionCopyModeTypeSource, PermissionCopyModeTypeOverride, + PermissionCopyModeTypeSource, } } @@ -183,17 +198,30 @@ func PossibleShareAccessTierValues() []ShareAccessTier { type ShareRootSquash string const ( + ShareRootSquashAllSquash ShareRootSquash = "AllSquash" ShareRootSquashNoRootSquash ShareRootSquash = "NoRootSquash" ShareRootSquashRootSquash ShareRootSquash = "RootSquash" - ShareRootSquashAllSquash ShareRootSquash = "AllSquash" ) // PossibleShareRootSquashValues returns the possible values for the ShareRootSquash const type. func PossibleShareRootSquashValues() []ShareRootSquash { return []ShareRootSquash{ + ShareRootSquashAllSquash, ShareRootSquashNoRootSquash, ShareRootSquashRootSquash, - ShareRootSquashAllSquash, + } +} + +type ShareTokenIntent string + +const ( + ShareTokenIntentBackup ShareTokenIntent = "backup" +) + +// PossibleShareTokenIntentValues returns the possible values for the ShareTokenIntent const type. +func PossibleShareTokenIntentValues() []ShareTokenIntent { + return []ShareTokenIntent{ + ShareTokenIntentBackup, } } diff --git a/sdk/storage/azfile/internal/generated/zz_directory_client.go b/sdk/storage/azfile/internal/generated/zz_directory_client.go index 1b1eed71d03f..d520e4951dfd 100644 --- a/sdk/storage/azfile/internal/generated/zz_directory_client.go +++ b/sdk/storage/azfile/internal/generated/zz_directory_client.go @@ -23,38 +23,28 @@ import ( ) // DirectoryClient contains the methods for the Directory group. -// Don't use this type directly, use NewDirectoryClient() instead. +// Don't use this type directly, use a constructor function instead. type DirectoryClient struct { - endpoint string - pl runtime.Pipeline -} - -// NewDirectoryClient creates a new instance of DirectoryClient with the specified values. -// - endpoint - The URL of the service account, share, directory or file that is the target of the desired operation. -// - pl - the pipeline used for sending requests and handling responses. -func NewDirectoryClient(endpoint string, pl runtime.Pipeline) *DirectoryClient { - client := &DirectoryClient{ - endpoint: endpoint, - pl: pl, - } - return client + internal *azcore.Client + endpoint string + allowTrailingDot *bool + fileRequestIntent *ShareTokenIntent + allowSourceTrailingDot *bool } // Create - Creates a new directory under the specified share or parent directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - fileAttributes - 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 - Creation time for the file/directory. Default value: Now. -// - fileLastWriteTime - Last write time for the file/directory. Default value: Now. // - options - DirectoryClientCreateOptions contains the optional parameters for the DirectoryClient.Create method. -func (client *DirectoryClient) Create(ctx context.Context, fileAttributes string, fileCreationTime string, fileLastWriteTime string, options *DirectoryClientCreateOptions) (DirectoryClientCreateResponse, error) { - req, err := client.createCreateRequest(ctx, fileAttributes, fileCreationTime, fileLastWriteTime, options) +func (client *DirectoryClient) Create(ctx context.Context, fileAttributes string, options *DirectoryClientCreateOptions) (DirectoryClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, fileAttributes, options) if err != nil { return DirectoryClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientCreateResponse{}, err } @@ -65,7 +55,7 @@ func (client *DirectoryClient) Create(ctx context.Context, fileAttributes string } // createCreateRequest creates the Create request. -func (client *DirectoryClient) createCreateRequest(ctx context.Context, fileAttributes string, fileCreationTime string, fileLastWriteTime string, options *DirectoryClientCreateOptions) (*policy.Request, error) { +func (client *DirectoryClient) createCreateRequest(ctx context.Context, fileAttributes string, options *DirectoryClientCreateOptions) (*policy.Request, error) { req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err @@ -76,6 +66,9 @@ func (client *DirectoryClient) createCreateRequest(ctx context.Context, fileAttr reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } if options != nil && options.Metadata != nil { for k, v := range options.Metadata { if v != nil { @@ -83,7 +76,7 @@ func (client *DirectoryClient) createCreateRequest(ctx context.Context, fileAttr } } } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.FilePermission != nil { req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission} } @@ -91,8 +84,18 @@ func (client *DirectoryClient) createCreateRequest(ctx context.Context, fileAttr req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey} } req.Raw().Header["x-ms-file-attributes"] = []string{fileAttributes} - req.Raw().Header["x-ms-file-creation-time"] = []string{fileCreationTime} - req.Raw().Header["x-ms-file-last-write-time"] = []string{fileLastWriteTime} + if options != nil && options.FileCreationTime != nil { + req.Raw().Header["x-ms-file-creation-time"] = []string{*options.FileCreationTime} + } + if options != nil && options.FileLastWriteTime != nil { + req.Raw().Header["x-ms-file-last-write-time"] = []string{*options.FileLastWriteTime} + } + if options != nil && options.FileChangeTime != nil { + req.Raw().Header["x-ms-file-change-time"] = []string{*options.FileChangeTime} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -169,14 +172,14 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct // Delete - Removes the specified empty directory. Note that the directory must be empty before it can be deleted. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - DirectoryClientDeleteOptions contains the optional parameters for the DirectoryClient.Delete method. func (client *DirectoryClient) Delete(ctx context.Context, options *DirectoryClientDeleteOptions) (DirectoryClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, options) if err != nil { return DirectoryClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientDeleteResponse{}, err } @@ -198,7 +201,13 @@ func (client *DirectoryClient) deleteCreateRequest(ctx context.Context, options reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -225,7 +234,7 @@ func (client *DirectoryClient) deleteHandleResponse(resp *http.Response) (Direct // ForceCloseHandles - Closes all handles open for given directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - handleID - Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard that specifies // all handles. // - options - DirectoryClientForceCloseHandlesOptions contains the optional parameters for the DirectoryClient.ForceCloseHandles @@ -235,7 +244,7 @@ func (client *DirectoryClient) ForceCloseHandles(ctx context.Context, handleID s if err != nil { return DirectoryClientForceCloseHandlesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientForceCloseHandlesResponse{}, err } @@ -267,7 +276,13 @@ func (client *DirectoryClient) forceCloseHandlesCreateRequest(ctx context.Contex if options != nil && options.Recursive != nil { req.Raw().Header["x-ms-recursive"] = []string{strconv.FormatBool(*options.Recursive)} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -315,14 +330,14 @@ func (client *DirectoryClient) forceCloseHandlesHandleResponse(resp *http.Respon // subdirectories. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - DirectoryClientGetPropertiesOptions contains the optional parameters for the DirectoryClient.GetProperties method. func (client *DirectoryClient) GetProperties(ctx context.Context, options *DirectoryClientGetPropertiesOptions) (DirectoryClientGetPropertiesResponse, error) { req, err := client.getPropertiesCreateRequest(ctx, options) if err != nil { return DirectoryClientGetPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientGetPropertiesResponse{}, err } @@ -347,7 +362,13 @@ func (client *DirectoryClient) getPropertiesCreateRequest(ctx context.Context, o reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -432,7 +453,7 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) // NewListFilesAndDirectoriesSegmentPager - Returns a list of files or directories under the specified share or directory. // It lists the contents only for a single level of the directory hierarchy. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - DirectoryClientListFilesAndDirectoriesSegmentOptions contains the optional parameters for the DirectoryClient.NewListFilesAndDirectoriesSegmentPager // method. // @@ -464,10 +485,16 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentCreateRequest(ctx c reqQP.Set("include", strings.Join(strings.Fields(strings.Trim(fmt.Sprint(options.Include), "[]")), ",")) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.IncludeExtendedInfo != nil { req.Raw().Header["x-ms-file-extended-info"] = []string{strconv.FormatBool(*options.IncludeExtendedInfo)} } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -500,14 +527,14 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentHandleResponse(resp // ListHandles - Lists handles for directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - DirectoryClientListHandlesOptions contains the optional parameters for the DirectoryClient.ListHandles method. func (client *DirectoryClient) ListHandles(ctx context.Context, options *DirectoryClientListHandlesOptions) (DirectoryClientListHandlesResponse, error) { req, err := client.listHandlesCreateRequest(ctx, options) if err != nil { return DirectoryClientListHandlesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientListHandlesResponse{}, err } @@ -541,7 +568,13 @@ func (client *DirectoryClient) listHandlesCreateRequest(ctx context.Context, opt if options != nil && options.Recursive != nil { req.Raw().Header["x-ms-recursive"] = []string{strconv.FormatBool(*options.Recursive)} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -571,17 +604,177 @@ func (client *DirectoryClient) listHandlesHandleResponse(resp *http.Response) (D return result, nil } +// Rename - Renames a directory +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-11-02 +// - renameSource - Required. Specifies the URI-style path of the source file, up to 2 KB in length. +// - options - DirectoryClientRenameOptions contains the optional parameters for the DirectoryClient.Rename method. +// - SourceLeaseAccessConditions - SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename +// method. +// - DestinationLeaseAccessConditions - DestinationLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename +// method. +// - CopyFileSMBInfo - CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. +func (client *DirectoryClient) Rename(ctx context.Context, renameSource string, options *DirectoryClientRenameOptions, sourceLeaseAccessConditions *SourceLeaseAccessConditions, destinationLeaseAccessConditions *DestinationLeaseAccessConditions, copyFileSMBInfo *CopyFileSMBInfo) (DirectoryClientRenameResponse, error) { + req, err := client.renameCreateRequest(ctx, renameSource, options, sourceLeaseAccessConditions, destinationLeaseAccessConditions, copyFileSMBInfo) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DirectoryClientRenameResponse{}, runtime.NewResponseError(resp) + } + return client.renameHandleResponse(resp) +} + +// renameCreateRequest creates the Rename request. +func (client *DirectoryClient) renameCreateRequest(ctx context.Context, renameSource string, options *DirectoryClientRenameOptions, sourceLeaseAccessConditions *SourceLeaseAccessConditions, destinationLeaseAccessConditions *DestinationLeaseAccessConditions, copyFileSMBInfo *CopyFileSMBInfo) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("restype", "directory") + reqQP.Set("comp", "rename") + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-file-rename-source"] = []string{renameSource} + if options != nil && options.ReplaceIfExists != nil { + req.Raw().Header["x-ms-file-rename-replace-if-exists"] = []string{strconv.FormatBool(*options.ReplaceIfExists)} + } + if options != nil && options.IgnoreReadOnly != nil { + req.Raw().Header["x-ms-file-rename-ignore-readonly"] = []string{strconv.FormatBool(*options.IgnoreReadOnly)} + } + if sourceLeaseAccessConditions != nil && sourceLeaseAccessConditions.SourceLeaseID != nil { + req.Raw().Header["x-ms-source-lease-id"] = []string{*sourceLeaseAccessConditions.SourceLeaseID} + } + if destinationLeaseAccessConditions != nil && destinationLeaseAccessConditions.DestinationLeaseID != nil { + req.Raw().Header["x-ms-destination-lease-id"] = []string{*destinationLeaseAccessConditions.DestinationLeaseID} + } + if copyFileSMBInfo != nil && copyFileSMBInfo.FileAttributes != nil { + req.Raw().Header["x-ms-file-attributes"] = []string{*copyFileSMBInfo.FileAttributes} + } + if copyFileSMBInfo != nil && copyFileSMBInfo.FileCreationTime != nil { + req.Raw().Header["x-ms-file-creation-time"] = []string{*copyFileSMBInfo.FileCreationTime} + } + if copyFileSMBInfo != nil && copyFileSMBInfo.FileLastWriteTime != nil { + req.Raw().Header["x-ms-file-last-write-time"] = []string{*copyFileSMBInfo.FileLastWriteTime} + } + if copyFileSMBInfo != nil && copyFileSMBInfo.FileChangeTime != nil { + req.Raw().Header["x-ms-file-change-time"] = []string{*copyFileSMBInfo.FileChangeTime} + } + if options != nil && options.FilePermission != nil { + req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission} + } + if options != nil && options.FilePermissionKey != nil { + req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey} + } + if options != nil && options.Metadata != nil { + for k, v := range options.Metadata { + if v != nil { + req.Raw().Header["x-ms-meta-"+k] = []string{*v} + } + } + } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.allowSourceTrailingDot != nil { + req.Raw().Header["x-ms-source-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowSourceTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// renameHandleResponse handles the Rename response. +func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (DirectoryClientRenameResponse, error) { + result := DirectoryClientRenameResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + result.LastModified = &lastModified + } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + result.Date = &date + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + result.IsServerEncrypted = &isServerEncrypted + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-file-attributes"); val != "" { + result.FileAttributes = &val + } + if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { + fileCreationTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + result.FileCreationTime = &fileCreationTime + } + if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { + fileLastWriteTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + result.FileLastWriteTime = &fileLastWriteTime + } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + return result, nil +} + // SetMetadata - Updates user defined metadata for the specified directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - DirectoryClientSetMetadataOptions contains the optional parameters for the DirectoryClient.SetMetadata method. func (client *DirectoryClient) SetMetadata(ctx context.Context, options *DirectoryClientSetMetadataOptions) (DirectoryClientSetMetadataResponse, error) { req, err := client.setMetadataCreateRequest(ctx, options) if err != nil { return DirectoryClientSetMetadataResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientSetMetadataResponse{}, err } @@ -611,7 +804,13 @@ func (client *DirectoryClient) setMetadataCreateRequest(ctx context.Context, opt } } } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -648,18 +847,16 @@ func (client *DirectoryClient) setMetadataHandleResponse(resp *http.Response) (D // SetProperties - Sets properties on the directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - fileAttributes - 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 - Creation time for the file/directory. Default value: Now. -// - fileLastWriteTime - Last write time for the file/directory. Default value: Now. // - options - DirectoryClientSetPropertiesOptions contains the optional parameters for the DirectoryClient.SetProperties method. -func (client *DirectoryClient) SetProperties(ctx context.Context, fileAttributes string, fileCreationTime string, fileLastWriteTime string, options *DirectoryClientSetPropertiesOptions) (DirectoryClientSetPropertiesResponse, error) { - req, err := client.setPropertiesCreateRequest(ctx, fileAttributes, fileCreationTime, fileLastWriteTime, options) +func (client *DirectoryClient) SetProperties(ctx context.Context, fileAttributes string, options *DirectoryClientSetPropertiesOptions) (DirectoryClientSetPropertiesResponse, error) { + req, err := client.setPropertiesCreateRequest(ctx, fileAttributes, options) if err != nil { return DirectoryClientSetPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientSetPropertiesResponse{}, err } @@ -670,7 +867,7 @@ func (client *DirectoryClient) SetProperties(ctx context.Context, fileAttributes } // setPropertiesCreateRequest creates the SetProperties request. -func (client *DirectoryClient) setPropertiesCreateRequest(ctx context.Context, fileAttributes string, fileCreationTime string, fileLastWriteTime string, options *DirectoryClientSetPropertiesOptions) (*policy.Request, error) { +func (client *DirectoryClient) setPropertiesCreateRequest(ctx context.Context, fileAttributes string, options *DirectoryClientSetPropertiesOptions) (*policy.Request, error) { req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err @@ -682,7 +879,7 @@ func (client *DirectoryClient) setPropertiesCreateRequest(ctx context.Context, f reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.FilePermission != nil { req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission} } @@ -690,8 +887,21 @@ func (client *DirectoryClient) setPropertiesCreateRequest(ctx context.Context, f req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey} } req.Raw().Header["x-ms-file-attributes"] = []string{fileAttributes} - req.Raw().Header["x-ms-file-creation-time"] = []string{fileCreationTime} - req.Raw().Header["x-ms-file-last-write-time"] = []string{fileLastWriteTime} + if options != nil && options.FileCreationTime != nil { + req.Raw().Header["x-ms-file-creation-time"] = []string{*options.FileCreationTime} + } + if options != nil && options.FileLastWriteTime != nil { + req.Raw().Header["x-ms-file-last-write-time"] = []string{*options.FileLastWriteTime} + } + if options != nil && options.FileChangeTime != nil { + req.Raw().Header["x-ms-file-change-time"] = []string{*options.FileChangeTime} + } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } diff --git a/sdk/storage/azfile/internal/generated/zz_file_client.go b/sdk/storage/azfile/internal/generated/zz_file_client.go index cfe2ea780a3b..b840422e237f 100644 --- a/sdk/storage/azfile/internal/generated/zz_file_client.go +++ b/sdk/storage/azfile/internal/generated/zz_file_client.go @@ -24,27 +24,19 @@ import ( ) // FileClient contains the methods for the File group. -// Don't use this type directly, use NewFileClient() instead. +// Don't use this type directly, use a constructor function instead. type FileClient struct { - endpoint string - pl runtime.Pipeline -} - -// NewFileClient creates a new instance of FileClient with the specified values. -// - endpoint - The URL of the service account, share, directory or file that is the target of the desired operation. -// - pl - the pipeline used for sending requests and handling responses. -func NewFileClient(endpoint string, pl runtime.Pipeline) *FileClient { - client := &FileClient{ - endpoint: endpoint, - pl: pl, - } - return client + internal *azcore.Client + endpoint string + allowTrailingDot *bool + fileRequestIntent *ShareTokenIntent + allowSourceTrailingDot *bool } // AbortCopy - Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - copyID - The copy identifier provided in the x-ms-copy-id header of the original Copy File operation. // - options - FileClientAbortCopyOptions contains the optional parameters for the FileClient.AbortCopy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. @@ -53,7 +45,7 @@ func (client *FileClient) AbortCopy(ctx context.Context, copyID string, options if err != nil { return FileClientAbortCopyResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientAbortCopyResponse{}, err } @@ -77,10 +69,16 @@ func (client *FileClient) abortCopyCreateRequest(ctx context.Context, copyID str } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-copy-action"] = []string{"abort"} - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -107,7 +105,7 @@ func (client *FileClient) abortCopyHandleResponse(resp *http.Response) (FileClie // AcquireLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - duration - 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. @@ -117,7 +115,7 @@ func (client *FileClient) AcquireLease(ctx context.Context, duration int32, opti if err != nil { return FileClientAcquireLeaseResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientAcquireLeaseResponse{}, err } @@ -144,10 +142,16 @@ func (client *FileClient) acquireLeaseCreateRequest(ctx context.Context, duratio if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -190,7 +194,7 @@ func (client *FileClient) acquireLeaseHandleResponse(resp *http.Response) (FileC // BreakLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - FileClientBreakLeaseOptions contains the optional parameters for the FileClient.BreakLease method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) BreakLease(ctx context.Context, options *FileClientBreakLeaseOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientBreakLeaseResponse, error) { @@ -198,7 +202,7 @@ func (client *FileClient) BreakLease(ctx context.Context, options *FileClientBre if err != nil { return FileClientBreakLeaseResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientBreakLeaseResponse{}, err } @@ -224,10 +228,16 @@ func (client *FileClient) breakLeaseCreateRequest(ctx context.Context, options * if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -270,7 +280,7 @@ func (client *FileClient) breakLeaseHandleResponse(resp *http.Response) (FileCli // ChangeLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - leaseID - Specifies the current lease ID on the resource. // - options - FileClientChangeLeaseOptions contains the optional parameters for the FileClient.ChangeLease method. func (client *FileClient) ChangeLease(ctx context.Context, leaseID string, options *FileClientChangeLeaseOptions) (FileClientChangeLeaseResponse, error) { @@ -278,7 +288,7 @@ func (client *FileClient) ChangeLease(ctx context.Context, leaseID string, optio if err != nil { return FileClientChangeLeaseResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientChangeLeaseResponse{}, err } @@ -305,10 +315,16 @@ func (client *FileClient) changeLeaseCreateRequest(ctx context.Context, leaseID if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -351,21 +367,19 @@ func (client *FileClient) changeLeaseHandleResponse(resp *http.Response) (FileCl // Create - Creates a new file or replaces a file. Note it only initializes the file with no content. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - fileContentLength - Specifies the maximum size for the file, up to 4 TB. // - fileAttributes - 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 - Creation time for the file/directory. Default value: Now. -// - fileLastWriteTime - Last write time for the file/directory. Default value: Now. // - options - FileClientCreateOptions contains the optional parameters for the FileClient.Create method. // - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. -func (client *FileClient) Create(ctx context.Context, fileContentLength int64, fileAttributes string, fileCreationTime string, fileLastWriteTime string, options *FileClientCreateOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (FileClientCreateResponse, error) { - req, err := client.createCreateRequest(ctx, fileContentLength, fileAttributes, fileCreationTime, fileLastWriteTime, options, shareFileHTTPHeaders, leaseAccessConditions) +func (client *FileClient) Create(ctx context.Context, fileContentLength int64, fileAttributes string, options *FileClientCreateOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (FileClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, fileContentLength, fileAttributes, options, shareFileHTTPHeaders, leaseAccessConditions) if err != nil { return FileClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientCreateResponse{}, err } @@ -376,7 +390,7 @@ func (client *FileClient) Create(ctx context.Context, fileContentLength int64, f } // createCreateRequest creates the Create request. -func (client *FileClient) createCreateRequest(ctx context.Context, fileContentLength int64, fileAttributes string, fileCreationTime string, fileLastWriteTime string, options *FileClientCreateOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (*policy.Request, error) { +func (client *FileClient) createCreateRequest(ctx context.Context, fileContentLength int64, fileAttributes string, options *FileClientCreateOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (*policy.Request, error) { req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err @@ -386,7 +400,10 @@ func (client *FileClient) createCreateRequest(ctx context.Context, fileContentLe reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} req.Raw().Header["x-ms-content-length"] = []string{strconv.FormatInt(fileContentLength, 10)} req.Raw().Header["x-ms-type"] = []string{"file"} if shareFileHTTPHeaders != nil && shareFileHTTPHeaders.ContentType != nil { @@ -421,11 +438,21 @@ func (client *FileClient) createCreateRequest(ctx context.Context, fileContentLe req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey} } req.Raw().Header["x-ms-file-attributes"] = []string{fileAttributes} - req.Raw().Header["x-ms-file-creation-time"] = []string{fileCreationTime} - req.Raw().Header["x-ms-file-last-write-time"] = []string{fileLastWriteTime} + if options != nil && options.FileCreationTime != nil { + req.Raw().Header["x-ms-file-creation-time"] = []string{*options.FileCreationTime} + } + if options != nil && options.FileLastWriteTime != nil { + req.Raw().Header["x-ms-file-last-write-time"] = []string{*options.FileLastWriteTime} + } + if options != nil && options.FileChangeTime != nil { + req.Raw().Header["x-ms-file-change-time"] = []string{*options.FileChangeTime} + } if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -502,7 +529,7 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC // Delete - removes the file from the storage account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - FileClientDeleteOptions contains the optional parameters for the FileClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) Delete(ctx context.Context, options *FileClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientDeleteResponse, error) { @@ -510,7 +537,7 @@ func (client *FileClient) Delete(ctx context.Context, options *FileClientDeleteO if err != nil { return FileClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientDeleteResponse{}, err } @@ -531,10 +558,16 @@ func (client *FileClient) deleteCreateRequest(ctx context.Context, options *File reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -561,7 +594,7 @@ func (client *FileClient) deleteHandleResponse(resp *http.Response) (FileClientD // Download - Reads or downloads a file from the system, including its metadata and properties. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - FileClientDownloadOptions contains the optional parameters for the FileClient.Download method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) Download(ctx context.Context, options *FileClientDownloadOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientDownloadResponse, error) { @@ -569,7 +602,7 @@ func (client *FileClient) Download(ctx context.Context, options *FileClientDownl if err != nil { return FileClientDownloadResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientDownloadResponse{}, err } @@ -591,7 +624,10 @@ func (client *FileClient) downloadCreateRequest(ctx context.Context, options *Fi } req.Raw().URL.RawQuery = reqQP.Encode() runtime.SkipBodyDownload(req) - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.Range != nil { req.Raw().Header["x-ms-range"] = []string{*options.Range} } @@ -601,6 +637,9 @@ func (client *FileClient) downloadCreateRequest(ctx context.Context, options *Fi if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -758,7 +797,7 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien // ForceCloseHandles - Closes all handles open for given file // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - handleID - Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard that specifies // all handles. // - options - FileClientForceCloseHandlesOptions contains the optional parameters for the FileClient.ForceCloseHandles method. @@ -767,7 +806,7 @@ func (client *FileClient) ForceCloseHandles(ctx context.Context, handleID string if err != nil { return FileClientForceCloseHandlesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientForceCloseHandlesResponse{}, err } @@ -796,7 +835,13 @@ func (client *FileClient) forceCloseHandlesCreateRequest(ctx context.Context, ha } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-handle-id"] = []string{handleID} - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -843,7 +888,7 @@ func (client *FileClient) forceCloseHandlesHandleResponse(resp *http.Response) ( // not return the content of the file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - FileClientGetPropertiesOptions contains the optional parameters for the FileClient.GetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) GetProperties(ctx context.Context, options *FileClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientGetPropertiesResponse, error) { @@ -851,7 +896,7 @@ func (client *FileClient) GetProperties(ctx context.Context, options *FileClient if err != nil { return FileClientGetPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientGetPropertiesResponse{}, err } @@ -875,10 +920,16 @@ func (client *FileClient) getPropertiesCreateRequest(ctx context.Context, option reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -1026,7 +1077,7 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File // GetRangeList - Returns the list of valid ranges for a file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - FileClientGetRangeListOptions contains the optional parameters for the FileClient.GetRangeList method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) GetRangeList(ctx context.Context, options *FileClientGetRangeListOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientGetRangeListResponse, error) { @@ -1034,7 +1085,7 @@ func (client *FileClient) GetRangeList(ctx context.Context, options *FileClientG if err != nil { return FileClientGetRangeListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientGetRangeListResponse{}, err } @@ -1062,13 +1113,19 @@ func (client *FileClient) getRangeListCreateRequest(ctx context.Context, options reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.Range != nil { req.Raw().Header["x-ms-range"] = []string{*options.Range} } if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -1115,14 +1172,14 @@ func (client *FileClient) getRangeListHandleResponse(resp *http.Response) (FileC // ListHandles - Lists handles for file // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - FileClientListHandlesOptions contains the optional parameters for the FileClient.ListHandles method. func (client *FileClient) ListHandles(ctx context.Context, options *FileClientListHandlesOptions) (FileClientListHandlesResponse, error) { req, err := client.listHandlesCreateRequest(ctx, options) if err != nil { return FileClientListHandlesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientListHandlesResponse{}, err } @@ -1153,7 +1210,13 @@ func (client *FileClient) listHandlesCreateRequest(ctx context.Context, options reqQP.Set("sharesnapshot", *options.Sharesnapshot) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -1186,7 +1249,7 @@ func (client *FileClient) listHandlesHandleResponse(resp *http.Response) (FileCl // ReleaseLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - leaseID - Specifies the current lease ID on the resource. // - options - FileClientReleaseLeaseOptions contains the optional parameters for the FileClient.ReleaseLease method. func (client *FileClient) ReleaseLease(ctx context.Context, leaseID string, options *FileClientReleaseLeaseOptions) (FileClientReleaseLeaseResponse, error) { @@ -1194,7 +1257,7 @@ func (client *FileClient) ReleaseLease(ctx context.Context, leaseID string, opti if err != nil { return FileClientReleaseLeaseResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientReleaseLeaseResponse{}, err } @@ -1218,10 +1281,16 @@ func (client *FileClient) releaseLeaseCreateRequest(ctx context.Context, leaseID req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-lease-action"] = []string{"release"} req.Raw().Header["x-ms-lease-id"] = []string{leaseID} - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -1258,23 +1327,184 @@ func (client *FileClient) releaseLeaseHandleResponse(resp *http.Response) (FileC return result, nil } +// Rename - Renames a file +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-11-02 +// - renameSource - Required. Specifies the URI-style path of the source file, up to 2 KB in length. +// - options - FileClientRenameOptions contains the optional parameters for the FileClient.Rename method. +// - SourceLeaseAccessConditions - SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename +// method. +// - DestinationLeaseAccessConditions - DestinationLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename +// method. +// - CopyFileSMBInfo - CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. +// - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. +func (client *FileClient) Rename(ctx context.Context, renameSource string, options *FileClientRenameOptions, sourceLeaseAccessConditions *SourceLeaseAccessConditions, destinationLeaseAccessConditions *DestinationLeaseAccessConditions, copyFileSMBInfo *CopyFileSMBInfo, shareFileHTTPHeaders *ShareFileHTTPHeaders) (FileClientRenameResponse, error) { + req, err := client.renameCreateRequest(ctx, renameSource, options, sourceLeaseAccessConditions, destinationLeaseAccessConditions, copyFileSMBInfo, shareFileHTTPHeaders) + if err != nil { + return FileClientRenameResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FileClientRenameResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FileClientRenameResponse{}, runtime.NewResponseError(resp) + } + return client.renameHandleResponse(resp) +} + +// renameCreateRequest creates the Rename request. +func (client *FileClient) renameCreateRequest(ctx context.Context, renameSource string, options *FileClientRenameOptions, sourceLeaseAccessConditions *SourceLeaseAccessConditions, destinationLeaseAccessConditions *DestinationLeaseAccessConditions, copyFileSMBInfo *CopyFileSMBInfo, shareFileHTTPHeaders *ShareFileHTTPHeaders) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("comp", "rename") + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-file-rename-source"] = []string{renameSource} + if options != nil && options.ReplaceIfExists != nil { + req.Raw().Header["x-ms-file-rename-replace-if-exists"] = []string{strconv.FormatBool(*options.ReplaceIfExists)} + } + if options != nil && options.IgnoreReadOnly != nil { + req.Raw().Header["x-ms-file-rename-ignore-readonly"] = []string{strconv.FormatBool(*options.IgnoreReadOnly)} + } + if sourceLeaseAccessConditions != nil && sourceLeaseAccessConditions.SourceLeaseID != nil { + req.Raw().Header["x-ms-source-lease-id"] = []string{*sourceLeaseAccessConditions.SourceLeaseID} + } + if destinationLeaseAccessConditions != nil && destinationLeaseAccessConditions.DestinationLeaseID != nil { + req.Raw().Header["x-ms-destination-lease-id"] = []string{*destinationLeaseAccessConditions.DestinationLeaseID} + } + if copyFileSMBInfo != nil && copyFileSMBInfo.FileAttributes != nil { + req.Raw().Header["x-ms-file-attributes"] = []string{*copyFileSMBInfo.FileAttributes} + } + if copyFileSMBInfo != nil && copyFileSMBInfo.FileCreationTime != nil { + req.Raw().Header["x-ms-file-creation-time"] = []string{*copyFileSMBInfo.FileCreationTime} + } + if copyFileSMBInfo != nil && copyFileSMBInfo.FileLastWriteTime != nil { + req.Raw().Header["x-ms-file-last-write-time"] = []string{*copyFileSMBInfo.FileLastWriteTime} + } + if copyFileSMBInfo != nil && copyFileSMBInfo.FileChangeTime != nil { + req.Raw().Header["x-ms-file-change-time"] = []string{*copyFileSMBInfo.FileChangeTime} + } + if options != nil && options.FilePermission != nil { + req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission} + } + if options != nil && options.FilePermissionKey != nil { + req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey} + } + if options != nil && options.Metadata != nil { + for k, v := range options.Metadata { + if v != nil { + req.Raw().Header["x-ms-meta-"+k] = []string{*v} + } + } + } + if shareFileHTTPHeaders != nil && shareFileHTTPHeaders.ContentType != nil { + req.Raw().Header["x-ms-content-type"] = []string{*shareFileHTTPHeaders.ContentType} + } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.allowSourceTrailingDot != nil { + req.Raw().Header["x-ms-source-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowSourceTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// renameHandleResponse handles the Rename response. +func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientRenameResponse, error) { + result := FileClientRenameResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientRenameResponse{}, err + } + result.LastModified = &lastModified + } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientRenameResponse{}, err + } + result.Date = &date + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) + if err != nil { + return FileClientRenameResponse{}, err + } + result.IsServerEncrypted = &isServerEncrypted + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-file-attributes"); val != "" { + result.FileAttributes = &val + } + if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { + fileCreationTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientRenameResponse{}, err + } + result.FileCreationTime = &fileCreationTime + } + if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { + fileLastWriteTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientRenameResponse{}, err + } + result.FileLastWriteTime = &fileLastWriteTime + } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientRenameResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + return result, nil +} + // SetHTTPHeaders - Sets HTTP headers on the file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - fileAttributes - 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 - Creation time for the file/directory. Default value: Now. -// - fileLastWriteTime - Last write time for the file/directory. Default value: Now. // - options - FileClientSetHTTPHeadersOptions contains the optional parameters for the FileClient.SetHTTPHeaders method. // - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. -func (client *FileClient) SetHTTPHeaders(ctx context.Context, fileAttributes string, fileCreationTime string, fileLastWriteTime string, options *FileClientSetHTTPHeadersOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (FileClientSetHTTPHeadersResponse, error) { - req, err := client.setHTTPHeadersCreateRequest(ctx, fileAttributes, fileCreationTime, fileLastWriteTime, options, shareFileHTTPHeaders, leaseAccessConditions) +func (client *FileClient) SetHTTPHeaders(ctx context.Context, fileAttributes string, options *FileClientSetHTTPHeadersOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (FileClientSetHTTPHeadersResponse, error) { + req, err := client.setHTTPHeadersCreateRequest(ctx, fileAttributes, options, shareFileHTTPHeaders, leaseAccessConditions) if err != nil { return FileClientSetHTTPHeadersResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientSetHTTPHeadersResponse{}, err } @@ -1285,7 +1515,7 @@ func (client *FileClient) SetHTTPHeaders(ctx context.Context, fileAttributes str } // setHTTPHeadersCreateRequest creates the SetHTTPHeaders request. -func (client *FileClient) setHTTPHeadersCreateRequest(ctx context.Context, fileAttributes string, fileCreationTime string, fileLastWriteTime string, options *FileClientSetHTTPHeadersOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (*policy.Request, error) { +func (client *FileClient) setHTTPHeadersCreateRequest(ctx context.Context, fileAttributes string, options *FileClientSetHTTPHeadersOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (*policy.Request, error) { req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err @@ -1296,7 +1526,7 @@ func (client *FileClient) setHTTPHeadersCreateRequest(ctx context.Context, fileA reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.FileContentLength != nil { req.Raw().Header["x-ms-content-length"] = []string{strconv.FormatInt(*options.FileContentLength, 10)} } @@ -1325,11 +1555,24 @@ func (client *FileClient) setHTTPHeadersCreateRequest(ctx context.Context, fileA req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey} } req.Raw().Header["x-ms-file-attributes"] = []string{fileAttributes} - req.Raw().Header["x-ms-file-creation-time"] = []string{fileCreationTime} - req.Raw().Header["x-ms-file-last-write-time"] = []string{fileLastWriteTime} + if options != nil && options.FileCreationTime != nil { + req.Raw().Header["x-ms-file-creation-time"] = []string{*options.FileCreationTime} + } + if options != nil && options.FileLastWriteTime != nil { + req.Raw().Header["x-ms-file-last-write-time"] = []string{*options.FileLastWriteTime} + } + if options != nil && options.FileChangeTime != nil { + req.Raw().Header["x-ms-file-change-time"] = []string{*options.FileChangeTime} + } if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -1406,7 +1649,7 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil // SetMetadata - Updates user-defined metadata for the specified file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - FileClientSetMetadataOptions contains the optional parameters for the FileClient.SetMetadata method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) SetMetadata(ctx context.Context, options *FileClientSetMetadataOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientSetMetadataResponse, error) { @@ -1414,7 +1657,7 @@ func (client *FileClient) SetMetadata(ctx context.Context, options *FileClientSe if err != nil { return FileClientSetMetadataResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientSetMetadataResponse{}, err } @@ -1443,10 +1686,16 @@ func (client *FileClient) setMetadataCreateRequest(ctx context.Context, options } } } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -1490,7 +1739,7 @@ func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileCl // StartCopy - Copies a blob or file to a destination file within the storage account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - copySource - Specifies the URL of the source file or blob, up to 2 KB in length. To copy a file to another file within // the same storage account, you may use Shared Key to authenticate the source file. If you are // copying a file from another storage account, or if you are copying a blob from the same storage account or another storage @@ -1498,14 +1747,14 @@ func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileCl // access signature. If the source is a public blob, no authentication is required to perform the copy operation. A file in // a share snapshot can also be specified as a copy source. // - options - FileClientStartCopyOptions contains the optional parameters for the FileClient.StartCopy method. -// - CopyFileSMBInfo - CopyFileSMBInfo contains a group of parameters for the FileClient.StartCopy method. +// - CopyFileSMBInfo - CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) StartCopy(ctx context.Context, copySource string, options *FileClientStartCopyOptions, copyFileSMBInfo *CopyFileSMBInfo, leaseAccessConditions *LeaseAccessConditions) (FileClientStartCopyResponse, error) { req, err := client.startCopyCreateRequest(ctx, copySource, options, copyFileSMBInfo, leaseAccessConditions) if err != nil { return FileClientStartCopyResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientStartCopyResponse{}, err } @@ -1526,7 +1775,7 @@ func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.Metadata != nil { for k, v := range options.Metadata { if v != nil { @@ -1556,12 +1805,24 @@ func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource if copyFileSMBInfo != nil && copyFileSMBInfo.FileLastWriteTime != nil { req.Raw().Header["x-ms-file-last-write-time"] = []string{*copyFileSMBInfo.FileLastWriteTime} } + if copyFileSMBInfo != nil && copyFileSMBInfo.FileChangeTime != nil { + req.Raw().Header["x-ms-file-change-time"] = []string{*copyFileSMBInfo.FileChangeTime} + } if copyFileSMBInfo != nil && copyFileSMBInfo.SetArchiveAttribute != nil { req.Raw().Header["x-ms-file-copy-set-archive"] = []string{strconv.FormatBool(*copyFileSMBInfo.SetArchiveAttribute)} } if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.allowSourceTrailingDot != nil { + req.Raw().Header["x-ms-source-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowSourceTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -1604,7 +1865,7 @@ func (client *FileClient) startCopyHandleResponse(resp *http.Response) (FileClie // UploadRange - Upload a range of bytes to a file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - rangeParam - Specifies the range of bytes to be written. Both the start and end of the range must be specified. For an // update operation, the range can be up to 4 MB in size. For a clear operation, the range can be // up to the value of the file's full size. The File service accepts only a single byte range for the Range and 'x-ms-range' @@ -1625,7 +1886,7 @@ func (client *FileClient) UploadRange(ctx context.Context, rangeParam string, fi if err != nil { return FileClientUploadRangeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientUploadRangeResponse{}, err } @@ -1653,12 +1914,24 @@ func (client *FileClient) uploadRangeCreateRequest(ctx context.Context, rangePar if options != nil && options.ContentMD5 != nil { req.Raw().Header["Content-MD5"] = []string{base64.StdEncoding.EncodeToString(options.ContentMD5)} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } + if options != nil && options.FileLastWrittenMode != nil { + req.Raw().Header["x-ms-file-last-write-time"] = []string{string(*options.FileLastWrittenMode)} + } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} - return req, req.SetBody(optionalbody, "application/octet-stream") + if err := req.SetBody(optionalbody, "application/octet-stream"); err != nil { + return nil, err + } + return req, nil } // uploadRangeHandleResponse handles the UploadRange response. @@ -1701,13 +1974,20 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl } result.IsServerEncrypted = &isServerEncrypted } + if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { + fileLastWriteTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientUploadRangeResponse{}, err + } + result.FileLastWriteTime = &fileLastWriteTime + } return result, nil } // UploadRangeFromURL - Upload a range of bytes to a file where the contents are read from a URL. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - rangeParam - Writes data to the specified byte range in the file. // - copySource - Specifies the URL of the source file or blob, up to 2 KB in length. To copy a file to another file within // the same storage account, you may use Shared Key to authenticate the source file. If you are @@ -1726,7 +2006,7 @@ func (client *FileClient) UploadRangeFromURL(ctx context.Context, rangeParam str if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } @@ -1764,13 +2044,22 @@ func (client *FileClient) uploadRangeFromURLCreateRequest(ctx context.Context, r if sourceModifiedAccessConditions != nil && sourceModifiedAccessConditions.SourceIfNoneMatchCRC64 != nil { req.Raw().Header["x-ms-source-if-none-match-crc64"] = []string{base64.StdEncoding.EncodeToString(sourceModifiedAccessConditions.SourceIfNoneMatchCRC64)} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } if options != nil && options.CopySourceAuthorization != nil { req.Raw().Header["x-ms-copy-source-authorization"] = []string{*options.CopySourceAuthorization} } + if options != nil && options.FileLastWrittenMode != nil { + req.Raw().Header["x-ms-file-last-write-time"] = []string{string(*options.FileLastWrittenMode)} + } + if client.allowTrailingDot != nil { + req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} + } + if client.allowSourceTrailingDot != nil { + req.Raw().Header["x-ms-source-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowSourceTrailingDot)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -1815,6 +2104,13 @@ func (client *FileClient) uploadRangeFromURLHandleResponse(resp *http.Response) } result.IsServerEncrypted = &isServerEncrypted } + if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { + fileLastWriteTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientUploadRangeFromURLResponse{}, err + } + result.FileLastWriteTime = &fileLastWriteTime + } if val := resp.Header.Get("Content-MD5"); val != "" { contentMD5, err := base64.StdEncoding.DecodeString(val) if err != nil { diff --git a/sdk/storage/azfile/internal/generated/zz_models.go b/sdk/storage/azfile/internal/generated/zz_models.go index 95443aea430f..0262e1346140 100644 --- a/sdk/storage/azfile/internal/generated/zz_models.go +++ b/sdk/storage/azfile/internal/generated/zz_models.go @@ -34,11 +34,14 @@ type ClearRange struct { Start *int64 `xml:"Start"` } -// CopyFileSMBInfo contains a group of parameters for the FileClient.StartCopy method. +// CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. type CopyFileSMBInfo struct { // 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. FileAttributes *string + // 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. + FileChangeTime *string // 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. FileCreationTime *string @@ -80,6 +83,16 @@ type CORSRule struct { MaxAgeInSeconds *int32 `xml:"MaxAgeInSeconds"` } +// DestinationLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename method. +type DestinationLeaseAccessConditions struct { + // Required if the destination file has an active infinite lease. The lease ID specified for this header must match the lease + // ID of the destination file. If the request does not include the lease ID or + // it is not valid, the operation fails with status code 412 (Precondition Failed). If this header is specified and the destination + // file does not currently have an active lease, the operation will also + // fail with status code 412 (Precondition Failed). + DestinationLeaseID *string +} + // Directory - A listed directory item. type Directory struct { // REQUIRED @@ -94,6 +107,12 @@ type Directory struct { // DirectoryClientCreateOptions contains the optional parameters for the DirectoryClient.Create method. type DirectoryClientCreateOptions struct { + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string // 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 @@ -184,6 +203,33 @@ type DirectoryClientListHandlesOptions struct { Timeout *int32 } +// DirectoryClientRenameOptions contains the optional parameters for the DirectoryClient.Rename method. +type DirectoryClientRenameOptions struct { + // 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. + FilePermission *string + // 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. + FilePermissionKey *string + // Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting destination file should be respected. + // If true, the rename will succeed, otherwise, a previous file at the + // destination with the ReadOnly attribute set will cause the rename to fail. + IgnoreReadOnly *bool + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + // Optional. A boolean value for if the destination file already exists, whether this request will overwrite the file or not. + // If true, the rename will succeed and will overwrite the destination file. If + // not provided or if false and the destination file does exist, the request will not overwrite the destination file. If provided + // and the destination file doesn’t exist, the rename will succeed. Note: + // This value does not override the x-ms-file-copy-ignore-read-only header value. + ReplaceIfExists *bool + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + // DirectoryClientSetMetadataOptions contains the optional parameters for the DirectoryClient.SetMetadata method. type DirectoryClientSetMetadataOptions struct { // A name-value pair to associate with a file storage object. @@ -195,6 +241,12 @@ type DirectoryClientSetMetadataOptions struct { // DirectoryClientSetPropertiesOptions contains the optional parameters for the DirectoryClient.SetProperties method. type DirectoryClientSetPropertiesOptions struct { + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string // 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 @@ -267,6 +319,12 @@ type FileClientChangeLeaseOptions struct { // FileClientCreateOptions contains the optional parameters for the FileClient.Create method. type FileClientCreateOptions struct { + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string // 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 @@ -364,11 +422,44 @@ type FileClientReleaseLeaseOptions struct { Timeout *int32 } +// FileClientRenameOptions contains the optional parameters for the FileClient.Rename method. +type FileClientRenameOptions struct { + // 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. + FilePermission *string + // 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. + FilePermissionKey *string + // Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting destination file should be respected. + // If true, the rename will succeed, otherwise, a previous file at the + // destination with the ReadOnly attribute set will cause the rename to fail. + IgnoreReadOnly *bool + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + // Optional. A boolean value for if the destination file already exists, whether this request will overwrite the file or not. + // If true, the rename will succeed and will overwrite the destination file. If + // not provided or if false and the destination file does exist, the request will not overwrite the destination file. If provided + // and the destination file doesn’t exist, the rename will succeed. Note: + // This value does not override the x-ms-file-copy-ignore-read-only header value. + ReplaceIfExists *bool + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + // FileClientSetHTTPHeadersOptions contains the optional parameters for the FileClient.SetHTTPHeaders method. type FileClientSetHTTPHeadersOptions struct { + // Change time for the file/directory. Default value: Now. + FileChangeTime *string // Resizes a file to the specified size. If the specified byte value is less than the current size of the file, then all ranges // above the specified byte value are cleared. FileContentLength *int64 + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string // 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 @@ -412,6 +503,8 @@ type FileClientStartCopyOptions struct { type FileClientUploadRangeFromURLOptions struct { // Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. CopySourceAuthorization *string + // If the file last write time should be preserved or overwritten + FileLastWrittenMode *FileLastWrittenMode // Specify the crc64 calculated for the range of bytes that must be read from the copy source. SourceContentCRC64 []byte // Bytes of source data in the specified range. @@ -428,6 +521,8 @@ type FileClientUploadRangeOptions struct { // 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). ContentMD5 []byte + // If the file last write time should be preserved or overwritten + FileLastWrittenMode *FileLastWrittenMode // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] Timeout *int32 @@ -479,7 +574,7 @@ type Handle struct { // REQUIRED; Time when the session that previously opened the handle has last been reconnected. (UTC) OpenTime *time.Time `xml:"OpenTime"` - // REQUIRED; File or directory name including full path starting from share root + // REQUIRED Path *string `xml:"Path"` // REQUIRED; SMB session ID in context of which the file handle was opened @@ -518,6 +613,7 @@ type ListFilesAndDirectoriesSegmentResponse struct { // REQUIRED ShareName *string `xml:"ShareName,attr"` DirectoryID *string `xml:"DirectoryId"` + Encoded *bool `xml:"Encoded,attr"` Marker *string `xml:"Marker"` MaxResults *int32 `xml:"MaxResults"` ShareSnapshot *string `xml:"ShareSnapshot,attr"` @@ -847,7 +943,7 @@ type ShareFileRangeList struct { // SharePermission - A permission (a security descriptor) at the share level. type SharePermission struct { // REQUIRED; The permission in the Security Descriptor Definition Language (SDDL). - Permission *string `json:"permission,omitempty"` + Permission *string } // ShareProperties - Properties of a share. @@ -875,6 +971,7 @@ type ShareProperties struct { // The current lease status of the share. LeaseStatus *LeaseStatusType `xml:"LeaseStatus"` NextAllowedQuotaDowngradeTime *time.Time `xml:"NextAllowedQuotaDowngradeTime"` + ProvisionedBandwidthMiBps *int32 `xml:"ProvisionedBandwidthMiBps"` ProvisionedEgressMBps *int32 `xml:"ProvisionedEgressMBps"` ProvisionedIngressMBps *int32 `xml:"ProvisionedIngressMBps"` ProvisionedIops *int32 `xml:"ProvisionedIops"` @@ -904,6 +1001,12 @@ type SMBMultichannel struct { Enabled *bool `xml:"Enabled"` } +// SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename method. +type SourceLeaseAccessConditions struct { + // Required if the source file has an active infinite lease. + SourceLeaseID *string +} + // SourceModifiedAccessConditions contains a group of parameters for the FileClient.UploadRangeFromURL method. type SourceModifiedAccessConditions struct { // Specify the crc64 value to operate only on range with a matching crc64 checksum. @@ -913,7 +1016,7 @@ type SourceModifiedAccessConditions struct { } type StorageError struct { - Message *string `json:"Message,omitempty"` + Message *string } // StorageServiceProperties - Storage service properties. @@ -930,3 +1033,8 @@ type StorageServiceProperties struct { // Protocol settings Protocol *ProtocolSettings `xml:"ProtocolSettings"` } + +type StringEncoded struct { + Content *string `xml:",chardata"` + Encoded *bool `xml:"Encoded,attr"` +} diff --git a/sdk/storage/azfile/internal/generated/zz_models_serde.go b/sdk/storage/azfile/internal/generated/zz_models_serde.go index 7f837baac65c..94664adc2280 100644 --- a/sdk/storage/azfile/internal/generated/zz_models_serde.go +++ b/sdk/storage/azfile/internal/generated/zz_models_serde.go @@ -115,39 +115,6 @@ func (f FilesAndDirectoriesListSegment) MarshalXML(enc *xml.Encoder, start xml.S return enc.EncodeElement(aux, start) } -// MarshalXML implements the xml.Marshaller interface for type Handle. -func (h Handle) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { - type alias Handle - aux := &struct { - *alias - LastReconnectTime *timeRFC1123 `xml:"LastReconnectTime"` - OpenTime *timeRFC1123 `xml:"OpenTime"` - }{ - alias: (*alias)(&h), - LastReconnectTime: (*timeRFC1123)(h.LastReconnectTime), - OpenTime: (*timeRFC1123)(h.OpenTime), - } - return enc.EncodeElement(aux, start) -} - -// UnmarshalXML implements the xml.Unmarshaller interface for type Handle. -func (h *Handle) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { - type alias Handle - aux := &struct { - *alias - LastReconnectTime *timeRFC1123 `xml:"LastReconnectTime"` - OpenTime *timeRFC1123 `xml:"OpenTime"` - }{ - alias: (*alias)(h), - } - if err := dec.DecodeElement(aux, &start); err != nil { - return err - } - h.LastReconnectTime = (*time.Time)(aux.LastReconnectTime) - h.OpenTime = (*time.Time)(aux.OpenTime) - return nil -} - // MarshalXML implements the xml.Marshaller interface for type ListHandlesResponse. func (l ListHandlesResponse) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias ListHandlesResponse diff --git a/sdk/storage/azfile/internal/generated/zz_response_types.go b/sdk/storage/azfile/internal/generated/zz_response_types.go index be6bf1f60562..2d63886e3d71 100644 --- a/sdk/storage/azfile/internal/generated/zz_response_types.go +++ b/sdk/storage/azfile/internal/generated/zz_response_types.go @@ -167,6 +167,48 @@ type DirectoryClientListHandlesResponse struct { Version *string `xml:"Version"` } +// DirectoryClientRenameResponse contains the response from method DirectoryClient.Rename. +type DirectoryClientRenameResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time + + // ETag contains the information returned from the ETag header response. + ETag *azcore.ETag + + // FileAttributes contains the information returned from the x-ms-file-attributes header response. + FileAttributes *string + + // FileChangeTime contains the information returned from the x-ms-file-change-time header response. + FileChangeTime *time.Time + + // FileCreationTime contains the information returned from the x-ms-file-creation-time header response. + FileCreationTime *time.Time + + // ID contains the information returned from the x-ms-file-id header response. + ID *string + + // FileLastWriteTime contains the information returned from the x-ms-file-last-write-time header response. + FileLastWriteTime *time.Time + + // ParentID contains the information returned from the x-ms-file-parent-id header response. + ParentID *string + + // FilePermissionKey contains the information returned from the x-ms-file-permission-key header response. + FilePermissionKey *string + + // IsServerEncrypted contains the information returned from the x-ms-request-server-encrypted header response. + IsServerEncrypted *bool + + // LastModified contains the information returned from the Last-Modified header response. + LastModified *time.Time + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + // DirectoryClientSetMetadataResponse contains the response from method DirectoryClient.SetMetadata. type DirectoryClientSetMetadataResponse struct { // Date contains the information returned from the Date header response. @@ -646,6 +688,48 @@ type FileClientReleaseLeaseResponse struct { Version *string } +// FileClientRenameResponse contains the response from method FileClient.Rename. +type FileClientRenameResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time + + // ETag contains the information returned from the ETag header response. + ETag *azcore.ETag + + // FileAttributes contains the information returned from the x-ms-file-attributes header response. + FileAttributes *string + + // FileChangeTime contains the information returned from the x-ms-file-change-time header response. + FileChangeTime *time.Time + + // FileCreationTime contains the information returned from the x-ms-file-creation-time header response. + FileCreationTime *time.Time + + // ID contains the information returned from the x-ms-file-id header response. + ID *string + + // FileLastWriteTime contains the information returned from the x-ms-file-last-write-time header response. + FileLastWriteTime *time.Time + + // ParentID contains the information returned from the x-ms-file-parent-id header response. + ParentID *string + + // FilePermissionKey contains the information returned from the x-ms-file-permission-key header response. + FilePermissionKey *string + + // IsServerEncrypted contains the information returned from the x-ms-request-server-encrypted header response. + IsServerEncrypted *bool + + // LastModified contains the information returned from the Last-Modified header response. + LastModified *time.Time + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + // FileClientSetHTTPHeadersResponse contains the response from method FileClient.SetHTTPHeaders. type FileClientSetHTTPHeadersResponse struct { // Date contains the information returned from the Date header response. @@ -744,6 +828,9 @@ type FileClientUploadRangeFromURLResponse struct { // ETag contains the information returned from the ETag header response. ETag *azcore.ETag + // FileLastWriteTime contains the information returned from the x-ms-file-last-write-time header response. + FileLastWriteTime *time.Time + // IsServerEncrypted contains the information returned from the x-ms-request-server-encrypted header response. IsServerEncrypted *bool @@ -771,6 +858,9 @@ type FileClientUploadRangeResponse struct { // ETag contains the information returned from the ETag header response. ETag *azcore.ETag + // FileLastWriteTime contains the information returned from the x-ms-file-last-write-time header response. + FileLastWriteTime *time.Time + // IsServerEncrypted contains the information returned from the x-ms-request-server-encrypted header response. IsServerEncrypted *bool @@ -1027,6 +1117,9 @@ type ShareClientGetPropertiesResponse struct { // response. NextAllowedQuotaDowngradeTime *time.Time + // ProvisionedBandwidthMibps contains the information returned from the x-ms-share-provisioned-bandwidth-mibps header response. + ProvisionedBandwidthMibps *int32 + // ProvisionedEgressMBps contains the information returned from the x-ms-share-provisioned-egress-mbps header response. ProvisionedEgressMBps *int32 diff --git a/sdk/storage/azfile/internal/generated/zz_service_client.go b/sdk/storage/azfile/internal/generated/zz_service_client.go index efd5f4708912..847b97903bae 100644 --- a/sdk/storage/azfile/internal/generated/zz_service_client.go +++ b/sdk/storage/azfile/internal/generated/zz_service_client.go @@ -12,6 +12,7 @@ package generated import ( "context" "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -20,35 +21,24 @@ import ( ) // ServiceClient contains the methods for the Service group. -// Don't use this type directly, use NewServiceClient() instead. +// Don't use this type directly, use a constructor function instead. type ServiceClient struct { + internal *azcore.Client endpoint string - pl runtime.Pipeline -} - -// NewServiceClient creates a new instance of ServiceClient with the specified values. -// - endpoint - The URL of the service account, share, directory or file that is the target of the desired operation. -// - pl - the pipeline used for sending requests and handling responses. -func NewServiceClient(endpoint string, pl runtime.Pipeline) *ServiceClient { - client := &ServiceClient{ - endpoint: endpoint, - pl: pl, - } - return client } // GetProperties - Gets the properties of a storage account's File service, including properties for Storage Analytics metrics // and CORS (Cross-Origin Resource Sharing) rules. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. func (client *ServiceClient) GetProperties(ctx context.Context, options *ServiceClientGetPropertiesOptions) (ServiceClientGetPropertiesResponse, error) { req, err := client.getPropertiesCreateRequest(ctx, options) if err != nil { return ServiceClientGetPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceClientGetPropertiesResponse{}, err } @@ -71,7 +61,7 @@ func (client *ServiceClient) getPropertiesCreateRequest(ctx context.Context, opt reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -94,7 +84,7 @@ func (client *ServiceClient) getPropertiesHandleResponse(resp *http.Response) (S // NewListSharesSegmentPager - The List Shares Segment operation returns a list of the shares and share snapshots under the // specified account. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ServiceClientListSharesSegmentOptions contains the optional parameters for the ServiceClient.NewListSharesSegmentPager // method. // @@ -122,7 +112,7 @@ func (client *ServiceClient) ListSharesSegmentCreateRequest(ctx context.Context, reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -146,7 +136,7 @@ func (client *ServiceClient) ListSharesSegmentHandleResponse(resp *http.Response // metrics and CORS (Cross-Origin Resource Sharing) rules. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - storageServiceProperties - The StorageService properties. // - options - ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. func (client *ServiceClient) SetProperties(ctx context.Context, storageServiceProperties StorageServiceProperties, options *ServiceClientSetPropertiesOptions) (ServiceClientSetPropertiesResponse, error) { @@ -154,7 +144,7 @@ func (client *ServiceClient) SetProperties(ctx context.Context, storageServicePr if err != nil { return ServiceClientSetPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceClientSetPropertiesResponse{}, err } @@ -177,9 +167,12 @@ func (client *ServiceClient) setPropertiesCreateRequest(ctx context.Context, sto reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} req.Raw().Header["Accept"] = []string{"application/xml"} - return req, runtime.MarshalAsXML(req, storageServiceProperties) + if err := runtime.MarshalAsXML(req, storageServiceProperties); err != nil { + return nil, err + } + return req, nil } // setPropertiesHandleResponse handles the SetProperties response. diff --git a/sdk/storage/azfile/internal/generated/zz_share_client.go b/sdk/storage/azfile/internal/generated/zz_share_client.go index 1ba2fda44963..aa0cff6b803b 100644 --- a/sdk/storage/azfile/internal/generated/zz_share_client.go +++ b/sdk/storage/azfile/internal/generated/zz_share_client.go @@ -23,28 +23,18 @@ import ( ) // ShareClient contains the methods for the Share group. -// Don't use this type directly, use NewShareClient() instead. +// Don't use this type directly, use a constructor function instead. type ShareClient struct { - endpoint string - pl runtime.Pipeline -} - -// NewShareClient creates a new instance of ShareClient with the specified values. -// - endpoint - The URL of the service account, share, directory or file that is the target of the desired operation. -// - pl - the pipeline used for sending requests and handling responses. -func NewShareClient(endpoint string, pl runtime.Pipeline) *ShareClient { - client := &ShareClient{ - endpoint: endpoint, - pl: pl, - } - return client + internal *azcore.Client + endpoint string + fileRequestIntent *ShareTokenIntent } // AcquireLease - The Lease Share operation establishes and manages a lock on a share, or the specified snapshot for set and // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - duration - 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. @@ -54,7 +44,7 @@ func (client *ShareClient) AcquireLease(ctx context.Context, duration int32, opt if err != nil { return ShareClientAcquireLeaseResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientAcquireLeaseResponse{}, err } @@ -85,7 +75,7 @@ func (client *ShareClient) acquireLeaseCreateRequest(ctx context.Context, durati if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -132,7 +122,7 @@ func (client *ShareClient) acquireLeaseHandleResponse(resp *http.Response) (Shar // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ShareClientBreakLeaseOptions contains the optional parameters for the ShareClient.BreakLease method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) BreakLease(ctx context.Context, options *ShareClientBreakLeaseOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientBreakLeaseResponse, error) { @@ -140,7 +130,7 @@ func (client *ShareClient) BreakLease(ctx context.Context, options *ShareClientB if err != nil { return ShareClientBreakLeaseResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientBreakLeaseResponse{}, err } @@ -173,7 +163,7 @@ func (client *ShareClient) breakLeaseCreateRequest(ctx context.Context, options if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -228,7 +218,7 @@ func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareC // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientChangeLeaseOptions contains the optional parameters for the ShareClient.ChangeLease method. func (client *ShareClient) ChangeLease(ctx context.Context, leaseID string, options *ShareClientChangeLeaseOptions) (ShareClientChangeLeaseResponse, error) { @@ -236,7 +226,7 @@ func (client *ShareClient) ChangeLease(ctx context.Context, leaseID string, opti if err != nil { return ShareClientChangeLeaseResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientChangeLeaseResponse{}, err } @@ -267,7 +257,7 @@ func (client *ShareClient) changeLeaseCreateRequest(ctx context.Context, leaseID if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -314,14 +304,14 @@ func (client *ShareClient) changeLeaseHandleResponse(resp *http.Response) (Share // fails. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ShareClientCreateOptions contains the optional parameters for the ShareClient.Create method. func (client *ShareClient) Create(ctx context.Context, options *ShareClientCreateOptions) (ShareClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, options) if err != nil { return ShareClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientCreateResponse{}, err } @@ -356,7 +346,7 @@ func (client *ShareClient) createCreateRequest(ctx context.Context, options *Sha if options != nil && options.AccessTier != nil { req.Raw().Header["x-ms-access-tier"] = []string{string(*options.AccessTier)} } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.EnabledProtocols != nil { req.Raw().Header["x-ms-enabled-protocols"] = []string{*options.EnabledProtocols} } @@ -399,7 +389,7 @@ func (client *ShareClient) createHandleResponse(resp *http.Response) (ShareClien // CreatePermission - Create a permission (a security descriptor). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - sharePermission - A permission (a security descriptor) at the share level. // - options - ShareClientCreatePermissionOptions contains the optional parameters for the ShareClient.CreatePermission method. func (client *ShareClient) CreatePermission(ctx context.Context, sharePermission SharePermission, options *ShareClientCreatePermissionOptions) (ShareClientCreatePermissionResponse, error) { @@ -407,7 +397,7 @@ func (client *ShareClient) CreatePermission(ctx context.Context, sharePermission if err != nil { return ShareClientCreatePermissionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientCreatePermissionResponse{}, err } @@ -430,9 +420,15 @@ func (client *ShareClient) createPermissionCreateRequest(ctx context.Context, sh reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} - return req, runtime.MarshalAsJSON(req, sharePermission) + if err := runtime.MarshalAsJSON(req, sharePermission); err != nil { + return nil, err + } + return req, nil } // createPermissionHandleResponse handles the CreatePermission response. @@ -460,14 +456,14 @@ func (client *ShareClient) createPermissionHandleResponse(resp *http.Response) ( // CreateSnapshot - Creates a read-only snapshot of a share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ShareClientCreateSnapshotOptions contains the optional parameters for the ShareClient.CreateSnapshot method. func (client *ShareClient) CreateSnapshot(ctx context.Context, options *ShareClientCreateSnapshotOptions) (ShareClientCreateSnapshotResponse, error) { req, err := client.createSnapshotCreateRequest(ctx, options) if err != nil { return ShareClientCreateSnapshotResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientCreateSnapshotResponse{}, err } @@ -497,7 +493,7 @@ func (client *ShareClient) createSnapshotCreateRequest(ctx context.Context, opti } } } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -538,7 +534,7 @@ func (client *ShareClient) createSnapshotHandleResponse(resp *http.Response) (Sh // contained within it are later deleted during garbage collection. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ShareClientDeleteOptions contains the optional parameters for the ShareClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) Delete(ctx context.Context, options *ShareClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientDeleteResponse, error) { @@ -546,7 +542,7 @@ func (client *ShareClient) Delete(ctx context.Context, options *ShareClientDelet if err != nil { return ShareClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientDeleteResponse{}, err } @@ -571,7 +567,7 @@ func (client *ShareClient) deleteCreateRequest(ctx context.Context, options *Sha reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.DeleteSnapshots != nil { req.Raw().Header["x-ms-delete-snapshots"] = []string{string(*options.DeleteSnapshots)} } @@ -604,7 +600,7 @@ func (client *ShareClient) deleteHandleResponse(resp *http.Response) (ShareClien // GetAccessPolicy - Returns information about stored access policies specified on the share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ShareClientGetAccessPolicyOptions contains the optional parameters for the ShareClient.GetAccessPolicy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetAccessPolicy(ctx context.Context, options *ShareClientGetAccessPolicyOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetAccessPolicyResponse, error) { @@ -612,7 +608,7 @@ func (client *ShareClient) GetAccessPolicy(ctx context.Context, options *ShareCl if err != nil { return ShareClientGetAccessPolicyResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetAccessPolicyResponse{}, err } @@ -635,7 +631,7 @@ func (client *ShareClient) getAccessPolicyCreateRequest(ctx context.Context, opt reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -678,7 +674,7 @@ func (client *ShareClient) getAccessPolicyHandleResponse(resp *http.Response) (S // GetPermission - Returns the permission (security descriptor) for a given key // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - filePermissionKey - Key of the permission to be set for the directory/file. // - options - ShareClientGetPermissionOptions contains the optional parameters for the ShareClient.GetPermission method. func (client *ShareClient) GetPermission(ctx context.Context, filePermissionKey string, options *ShareClientGetPermissionOptions) (ShareClientGetPermissionResponse, error) { @@ -686,7 +682,7 @@ func (client *ShareClient) GetPermission(ctx context.Context, filePermissionKey if err != nil { return ShareClientGetPermissionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetPermissionResponse{}, err } @@ -710,7 +706,10 @@ func (client *ShareClient) getPermissionCreateRequest(ctx context.Context, fileP } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-file-permission-key"] = []string{filePermissionKey} - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -741,7 +740,7 @@ func (client *ShareClient) getPermissionHandleResponse(resp *http.Response) (Sha // data returned does not include the share's list of files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ShareClientGetPropertiesOptions contains the optional parameters for the ShareClient.GetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetProperties(ctx context.Context, options *ShareClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetPropertiesResponse, error) { @@ -749,7 +748,7 @@ func (client *ShareClient) GetProperties(ctx context.Context, options *ShareClie if err != nil { return ShareClientGetPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetPropertiesResponse{}, err } @@ -774,7 +773,7 @@ func (client *ShareClient) getPropertiesCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -855,6 +854,14 @@ func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (Sha } result.NextAllowedQuotaDowngradeTime = &nextAllowedQuotaDowngradeTime } + if val := resp.Header.Get("x-ms-share-provisioned-bandwidth-mibps"); val != "" { + provisionedBandwidthMibps32, err := strconv.ParseInt(val, 10, 32) + provisionedBandwidthMibps := int32(provisionedBandwidthMibps32) + if err != nil { + return ShareClientGetPropertiesResponse{}, err + } + result.ProvisionedBandwidthMibps = &provisionedBandwidthMibps + } if val := resp.Header.Get("x-ms-lease-duration"); val != "" { result.LeaseDuration = (*LeaseDurationType)(&val) } @@ -889,7 +896,7 @@ func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (Sha // GetStatistics - Retrieves statistics related to the share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ShareClientGetStatisticsOptions contains the optional parameters for the ShareClient.GetStatistics method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetStatistics(ctx context.Context, options *ShareClientGetStatisticsOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetStatisticsResponse, error) { @@ -897,7 +904,7 @@ func (client *ShareClient) GetStatistics(ctx context.Context, options *ShareClie if err != nil { return ShareClientGetStatisticsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetStatisticsResponse{}, err } @@ -920,7 +927,7 @@ func (client *ShareClient) getStatisticsCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -964,7 +971,7 @@ func (client *ShareClient) getStatisticsHandleResponse(resp *http.Response) (Sha // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientReleaseLeaseOptions contains the optional parameters for the ShareClient.ReleaseLease method. func (client *ShareClient) ReleaseLease(ctx context.Context, leaseID string, options *ShareClientReleaseLeaseOptions) (ShareClientReleaseLeaseResponse, error) { @@ -972,7 +979,7 @@ func (client *ShareClient) ReleaseLease(ctx context.Context, leaseID string, opt if err != nil { return ShareClientReleaseLeaseResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientReleaseLeaseResponse{}, err } @@ -1000,7 +1007,7 @@ func (client *ShareClient) releaseLeaseCreateRequest(ctx context.Context, leaseI req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-lease-action"] = []string{"release"} req.Raw().Header["x-ms-lease-id"] = []string{leaseID} - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1044,7 +1051,7 @@ func (client *ShareClient) releaseLeaseHandleResponse(resp *http.Response) (Shar // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientRenewLeaseOptions contains the optional parameters for the ShareClient.RenewLease method. func (client *ShareClient) RenewLease(ctx context.Context, leaseID string, options *ShareClientRenewLeaseOptions) (ShareClientRenewLeaseResponse, error) { @@ -1052,7 +1059,7 @@ func (client *ShareClient) RenewLease(ctx context.Context, leaseID string, optio if err != nil { return ShareClientRenewLeaseResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientRenewLeaseResponse{}, err } @@ -1080,7 +1087,7 @@ func (client *ShareClient) renewLeaseCreateRequest(ctx context.Context, leaseID req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-lease-action"] = []string{"renew"} req.Raw().Header["x-ms-lease-id"] = []string{leaseID} - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1126,14 +1133,14 @@ func (client *ShareClient) renewLeaseHandleResponse(resp *http.Response) (ShareC // Restore - Restores a previously deleted Share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ShareClientRestoreOptions contains the optional parameters for the ShareClient.Restore method. func (client *ShareClient) Restore(ctx context.Context, options *ShareClientRestoreOptions) (ShareClientRestoreResponse, error) { req, err := client.restoreCreateRequest(ctx, options) if err != nil { return ShareClientRestoreResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientRestoreResponse{}, err } @@ -1156,7 +1163,7 @@ func (client *ShareClient) restoreCreateRequest(ctx context.Context, options *Sh reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1205,7 +1212,7 @@ func (client *ShareClient) restoreHandleResponse(resp *http.Response) (ShareClie // SetAccessPolicy - Sets a stored access policy for use with shared access signatures. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - shareACL - The ACL for the share. // - options - ShareClientSetAccessPolicyOptions contains the optional parameters for the ShareClient.SetAccessPolicy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. @@ -1214,7 +1221,7 @@ func (client *ShareClient) SetAccessPolicy(ctx context.Context, shareACL []*Sign if err != nil { return ShareClientSetAccessPolicyResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientSetAccessPolicyResponse{}, err } @@ -1237,7 +1244,7 @@ func (client *ShareClient) setAccessPolicyCreateRequest(ctx context.Context, sha reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1246,7 +1253,10 @@ func (client *ShareClient) setAccessPolicyCreateRequest(ctx context.Context, sha XMLName xml.Name `xml:"SignedIdentifiers"` ShareACL *[]*SignedIdentifier `xml:"SignedIdentifier"` } - return req, runtime.MarshalAsXML(req, wrapper{ShareACL: &shareACL}) + if err := runtime.MarshalAsXML(req, wrapper{ShareACL: &shareACL}); err != nil { + return nil, err + } + return req, nil } // setAccessPolicyHandleResponse handles the SetAccessPolicy response. @@ -1281,7 +1291,7 @@ func (client *ShareClient) setAccessPolicyHandleResponse(resp *http.Response) (S // SetMetadata - Sets one or more user-defined name-value pairs for the specified share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ShareClientSetMetadataOptions contains the optional parameters for the ShareClient.SetMetadata method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) SetMetadata(ctx context.Context, options *ShareClientSetMetadataOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientSetMetadataResponse, error) { @@ -1289,7 +1299,7 @@ func (client *ShareClient) SetMetadata(ctx context.Context, options *ShareClient if err != nil { return ShareClientSetMetadataResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientSetMetadataResponse{}, err } @@ -1319,7 +1329,7 @@ func (client *ShareClient) setMetadataCreateRequest(ctx context.Context, options } } } - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1359,7 +1369,7 @@ func (client *ShareClient) setMetadataHandleResponse(resp *http.Response) (Share // SetProperties - Sets properties for the specified share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-02 +// Generated from API version 2022-11-02 // - options - ShareClientSetPropertiesOptions contains the optional parameters for the ShareClient.SetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) SetProperties(ctx context.Context, options *ShareClientSetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientSetPropertiesResponse, error) { @@ -1367,7 +1377,7 @@ func (client *ShareClient) SetProperties(ctx context.Context, options *ShareClie if err != nil { return ShareClientSetPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientSetPropertiesResponse{}, err } @@ -1390,7 +1400,7 @@ func (client *ShareClient) setPropertiesCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} + req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} if options != nil && options.Quota != nil { req.Raw().Header["x-ms-share-quota"] = []string{strconv.FormatInt(int64(*options.Quota), 10)} } diff --git a/sdk/storage/azfile/internal/shared/shared.go b/sdk/storage/azfile/internal/shared/shared.go index 0b819c28ea5a..4b8140f68556 100644 --- a/sdk/storage/azfile/internal/shared/shared.go +++ b/sdk/storage/azfile/internal/shared/shared.go @@ -62,6 +62,13 @@ const ( FileAttributesDirectory = "Directory" ) +const ( + ServiceClient = "azfile/service.Client" + ShareClient = "azfile/share.Client" + DirectoryClient = "azfile/directory.Client" + FileClient = "azfile/file.Client" +) + func GetClientOptions[T any](o *T) *T { if o == nil { return new(T) diff --git a/sdk/storage/azfile/log.go b/sdk/storage/azfile/log.go index f59215653531..36783797589b 100644 --- a/sdk/storage/azfile/log.go +++ b/sdk/storage/azfile/log.go @@ -13,4 +13,7 @@ import ( const ( // EventUpload is used for logging events related to upload operation. EventUpload = exported.EventUpload + + // EventError is used for logging errors. + EventError = exported.EventError ) diff --git a/sdk/storage/azfile/service/client.go b/sdk/storage/azfile/service/client.go index 89bf5f02c5a3..372313f78eb5 100644 --- a/sdk/storage/azfile/service/client.go +++ b/sdk/storage/azfile/service/client.go @@ -8,8 +8,10 @@ package service import ( "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/internal/log" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/fileerror" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/base" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported" @@ -34,9 +36,15 @@ type Client base.Client[generated.ServiceClient] // - options - client options; pass nil to accept the default values func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Client, error) { conOptions := shared.GetClientOptions(options) - pl := runtime.NewPipeline(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + plOpts := runtime.PipelineOptions{} + base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - return (*Client)(base.NewServiceClient(serviceURL, pl, nil)), nil + azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + if err != nil { + return nil, err + } + + return (*Client)(base.NewServiceClient(serviceURL, azClient, nil, (*base.ClientOptions)(conOptions))), nil } // NewClientWithSharedKeyCredential creates an instance of Client with the specified values. @@ -46,10 +54,17 @@ func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Clie func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error) { authPolicy := exported.NewSharedKeyCredPolicy(cred) conOptions := shared.GetClientOptions(options) - conOptions.PerRetryPolicies = append(conOptions.PerRetryPolicies, authPolicy) - pl := runtime.NewPipeline(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + plOpts := runtime.PipelineOptions{ + PerRetry: []policy.Policy{authPolicy}, + } + base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) + + azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + if err != nil { + return nil, err + } - return (*Client)(base.NewServiceClient(serviceURL, pl, cred)), nil + return (*Client)(base.NewServiceClient(serviceURL, azClient, cred, (*base.ClientOptions)(conOptions))), nil } // NewClientFromConnectionString creates an instance of Client with the specified values. @@ -80,6 +95,10 @@ func (s *Client) sharedKey() *SharedKeyCredential { return base.SharedKey((*base.Client[generated.ServiceClient])(s)) } +func (s *Client) getClientOptions() *base.ClientOptions { + return base.GetClientOptions((*base.Client[generated.ServiceClient])(s)) +} + // URL returns the URL endpoint used by the Client object. func (s *Client) URL() string { return s.generated().Endpoint() @@ -89,7 +108,18 @@ func (s *Client) URL() string { // The new share.Client uses the same request policy pipeline as the Client. func (s *Client) NewShareClient(shareName string) *share.Client { shareURL := runtime.JoinPaths(s.generated().Endpoint(), shareName) - return (*share.Client)(base.NewShareClient(shareURL, s.generated().Pipeline(), s.sharedKey())) + + // TODO: remove new azcore.Client creation after the API for shallow copying with new client name is implemented + clOpts := s.getClientOptions() + azClient, err := azcore.NewClient(shared.ShareClient, exported.ModuleVersion, *(base.GetPipelineOptions(clOpts)), &(clOpts.ClientOptions)) + if err != nil { + if log.Should(exported.EventError) { + log.Writef(exported.EventError, err.Error()) + } + return nil + } + + return (*share.Client)(base.NewShareClient(shareURL, azClient, s.sharedKey(), clOpts)) } // CreateShare is a lifecycle method to creates a new share under the specified account. @@ -172,7 +202,7 @@ func (s *Client) NewListSharesPager(options *ListSharesOptions) *runtime.Pager[L if err != nil { return ListSharesSegmentResponse{}, err } - resp, err := s.generated().Pipeline().Do(req) + resp, err := s.generated().InternalClient().Pipeline().Do(req) if err != nil { return ListSharesSegmentResponse{}, err } diff --git a/sdk/storage/azfile/service/constants.go b/sdk/storage/azfile/service/constants.go index a936067376b4..6e20819844be 100644 --- a/sdk/storage/azfile/service/constants.go +++ b/sdk/storage/azfile/service/constants.go @@ -35,3 +35,15 @@ const ( func PossibleShareRootSquashValues() []ShareRootSquash { return generated.PossibleShareRootSquashValues() } + +// ShareTokenIntent defines values for ShareTokenIntent +type ShareTokenIntent = generated.ShareTokenIntent + +const ( + ShareTokenIntentBackup ShareTokenIntent = generated.ShareTokenIntentBackup +) + +// PossibleShareTokenIntentValues returns the possible values for the ShareTokenIntent const type. +func PossibleShareTokenIntentValues() []ShareTokenIntent { + return generated.PossibleShareTokenIntentValues() +} diff --git a/sdk/storage/azfile/share/client.go b/sdk/storage/azfile/share/client.go index 5e557edd4f3d..4f797404cfbb 100644 --- a/sdk/storage/azfile/share/client.go +++ b/sdk/storage/azfile/share/client.go @@ -8,7 +8,10 @@ package share import ( "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/internal/log" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/directory" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/fileerror" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/base" @@ -33,9 +36,15 @@ type Client base.Client[generated.ShareClient] // - options - client options; pass nil to accept the default values func NewClientWithNoCredential(shareURL string, options *ClientOptions) (*Client, error) { conOptions := shared.GetClientOptions(options) - pl := runtime.NewPipeline(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + plOpts := runtime.PipelineOptions{} + base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - return (*Client)(base.NewShareClient(shareURL, pl, nil)), nil + azClient, err := azcore.NewClient(shared.ShareClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + if err != nil { + return nil, err + } + + return (*Client)(base.NewShareClient(shareURL, azClient, nil, (*base.ClientOptions)(conOptions))), nil } // NewClientWithSharedKeyCredential creates an instance of Client with the specified values. @@ -45,10 +54,17 @@ func NewClientWithNoCredential(shareURL string, options *ClientOptions) (*Client func NewClientWithSharedKeyCredential(shareURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error) { authPolicy := exported.NewSharedKeyCredPolicy(cred) conOptions := shared.GetClientOptions(options) - conOptions.PerRetryPolicies = append(conOptions.PerRetryPolicies, authPolicy) - pl := runtime.NewPipeline(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + plOpts := runtime.PipelineOptions{ + PerRetry: []policy.Policy{authPolicy}, + } + base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - return (*Client)(base.NewShareClient(shareURL, pl, cred)), nil + azClient, err := azcore.NewClient(shared.ShareClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + if err != nil { + return nil, err + } + + return (*Client)(base.NewShareClient(shareURL, azClient, cred, (*base.ClientOptions)(conOptions))), nil } // NewClientFromConnectionString creates an instance of Client with the specified values. @@ -81,6 +97,10 @@ func (s *Client) sharedKey() *SharedKeyCredential { return base.SharedKey((*base.Client[generated.ShareClient])(s)) } +func (s *Client) getClientOptions() *base.ClientOptions { + return base.GetClientOptions((*base.Client[generated.ShareClient])(s)) +} + // URL returns the URL endpoint used by the Client object. func (s *Client) URL() string { return s.generated().Endpoint() @@ -91,14 +111,36 @@ func (s *Client) URL() string { func (s *Client) NewDirectoryClient(directoryName string) *directory.Client { directoryName = url.PathEscape(strings.TrimRight(directoryName, "/")) directoryURL := runtime.JoinPaths(s.URL(), directoryName) - return (*directory.Client)(base.NewDirectoryClient(directoryURL, s.generated().Pipeline(), s.sharedKey())) + + // TODO: remove new azcore.Client creation after the API for shallow copying with new client name is implemented + clOpts := s.getClientOptions() + azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, *(base.GetPipelineOptions(clOpts)), &(clOpts.ClientOptions)) + if err != nil { + if log.Should(exported.EventError) { + log.Writef(exported.EventError, err.Error()) + } + return nil + } + + return (*directory.Client)(base.NewDirectoryClient(directoryURL, azClient, s.sharedKey(), clOpts)) } // NewRootDirectoryClient creates a new directory.Client object for the root of the share using the Client's URL. // The new directory.Client uses the same request policy pipeline as the Client. func (s *Client) NewRootDirectoryClient() *directory.Client { rootDirURL := s.URL() - return (*directory.Client)(base.NewDirectoryClient(rootDirURL, s.generated().Pipeline(), s.sharedKey())) + + // TODO: remove new azcore.Client creation after the API for shallow copying with new client name is implemented + clOpts := s.getClientOptions() + azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, *(base.GetPipelineOptions(clOpts)), &(clOpts.ClientOptions)) + if err != nil { + if log.Should(exported.EventError) { + log.Writef(exported.EventError, err.Error()) + } + return nil + } + + return (*directory.Client)(base.NewDirectoryClient(rootDirURL, azClient, s.sharedKey(), clOpts)) } // WithSnapshot creates a new Client object identical to the source but with the specified share snapshot timestamp. @@ -109,8 +151,9 @@ func (s *Client) WithSnapshot(shareSnapshot string) (*Client, error) { return nil, err } p.ShareSnapshot = shareSnapshot + clientOptions := base.GetClientOptions((*base.Client[generated.ShareClient])(s)) - return (*Client)(base.NewShareClient(p.String(), s.generated().Pipeline(), s.sharedKey())), nil + return (*Client)(base.NewShareClient(p.String(), s.generated().InternalClient(), s.sharedKey(), clientOptions)), nil } // Create operation creates a new share within a storage account. If a share with the same name already exists, the operation fails. diff --git a/sdk/storage/azfile/share/constants.go b/sdk/storage/azfile/share/constants.go index 231ab9e27e09..b6ac0bb4a75e 100644 --- a/sdk/storage/azfile/share/constants.go +++ b/sdk/storage/azfile/share/constants.go @@ -48,3 +48,15 @@ const ( func PossibleDeleteSnapshotsOptionTypeValues() []DeleteSnapshotsOptionType { return generated.PossibleDeleteSnapshotsOptionTypeValues() } + +// TokenIntent defines values for TokenIntent +type TokenIntent = generated.ShareTokenIntent + +const ( + TokenIntentBackup TokenIntent = generated.ShareTokenIntentBackup +) + +// PossibleTokenIntentValues returns the possible values for the TokenIntent const type. +func PossibleTokenIntentValues() []TokenIntent { + return generated.PossibleShareTokenIntentValues() +}