From eed74031d9facac14e77543ae43cb3b2fb6630b7 Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Fri, 17 Feb 2023 15:21:09 +0530 Subject: [PATCH] API View for azfile (#19873) * API View for azfile --- sdk/storage/azfile/directory/client.go | 119 ++++++++ sdk/storage/azfile/directory/constants.go | 24 ++ sdk/storage/azfile/directory/models.go | 97 ++++++ sdk/storage/azfile/directory/responses.go | 30 ++ sdk/storage/azfile/file/client.go | 175 +++++++++++ sdk/storage/azfile/file/constants.go | 89 ++++++ sdk/storage/azfile/file/models.go | 279 +++++++++++++++++ sdk/storage/azfile/file/responses.go | 56 ++++ sdk/storage/azfile/file/retry_reader.go | 48 +++ sdk/storage/azfile/internal/base/clients.go | 24 ++ .../exported/shared_key_credential.go | 45 +++ .../azfile/internal/generated/autorest.md | 166 ++++++++-- .../internal/generated/zz_directory_client.go | 21 +- .../internal/generated/zz_file_client.go | 75 ++--- .../azfile/internal/generated/zz_models.go | 283 +++++++++--------- .../internal/generated/zz_models_serde.go | 111 ++++--- .../internal/generated/zz_response_types.go | 121 ++++---- .../internal/generated/zz_service_client.go | 12 +- .../internal/generated/zz_share_client.go | 29 +- sdk/storage/azfile/lease/constants.go | 51 ++++ sdk/storage/azfile/lease/file_client.go | 69 +++++ sdk/storage/azfile/lease/models.go | 84 ++++++ sdk/storage/azfile/lease/responses.go | 36 +++ sdk/storage/azfile/lease/share_client.go | 75 +++++ sdk/storage/azfile/service/client.go | 123 ++++++++ sdk/storage/azfile/service/constants.go | 37 +++ sdk/storage/azfile/service/models.go | 101 +++++++ sdk/storage/azfile/service/responses.go | 30 ++ sdk/storage/azfile/share/client.go | 160 ++++++++++ sdk/storage/azfile/share/constants.go | 50 ++++ sdk/storage/azfile/share/models.go | 149 +++++++++ sdk/storage/azfile/share/responses.go | 45 +++ 32 files changed, 2462 insertions(+), 352 deletions(-) create mode 100644 sdk/storage/azfile/directory/client.go create mode 100644 sdk/storage/azfile/directory/constants.go create mode 100644 sdk/storage/azfile/directory/models.go create mode 100644 sdk/storage/azfile/directory/responses.go create mode 100644 sdk/storage/azfile/file/client.go create mode 100644 sdk/storage/azfile/file/constants.go create mode 100644 sdk/storage/azfile/file/models.go create mode 100644 sdk/storage/azfile/file/responses.go create mode 100644 sdk/storage/azfile/file/retry_reader.go create mode 100644 sdk/storage/azfile/internal/base/clients.go create mode 100644 sdk/storage/azfile/internal/exported/shared_key_credential.go create mode 100644 sdk/storage/azfile/lease/constants.go create mode 100644 sdk/storage/azfile/lease/file_client.go create mode 100644 sdk/storage/azfile/lease/models.go create mode 100644 sdk/storage/azfile/lease/responses.go create mode 100644 sdk/storage/azfile/lease/share_client.go create mode 100644 sdk/storage/azfile/service/client.go create mode 100644 sdk/storage/azfile/service/constants.go create mode 100644 sdk/storage/azfile/service/models.go create mode 100644 sdk/storage/azfile/service/responses.go create mode 100644 sdk/storage/azfile/share/client.go create mode 100644 sdk/storage/azfile/share/constants.go create mode 100644 sdk/storage/azfile/share/models.go create mode 100644 sdk/storage/azfile/share/responses.go diff --git a/sdk/storage/azfile/directory/client.go b/sdk/storage/azfile/directory/client.go new file mode 100644 index 000000000000..579d917991af --- /dev/null +++ b/sdk/storage/azfile/directory/client.go @@ -0,0 +1,119 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package directory + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "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/generated" +) + +// ClientOptions contains the optional parameters when creating a Client. +type ClientOptions struct { + azcore.ClientOptions +} + +// Client represents a URL to the Azure Storage directory allowing you to manipulate its directories and files. +type Client base.Client[generated.DirectoryClient] + +// NewClient creates an instance of Client with the specified values. +// - directoryURL - the URL of the directory e.g. https://.file.core.windows.net/share/directory +// - cred - an Azure AD credential, typically obtained via the azidentity module +// - options - client options; pass nil to accept the default values +func NewClient(directoryURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientWithNoCredential creates an instance of Client with the specified values. +// This is used to anonymously access a directory or with a shared access signature (SAS) token. +// - directoryURL - the URL of the directory e.g. https://.file.core.windows.net/share/directory? +// - options - client options; pass nil to accept the default values +func NewClientWithNoCredential(directoryURL string, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientWithSharedKeyCredential creates an instance of Client with the specified values. +// - directoryURL - the URL of the directory e.g. https://.file.core.windows.net/share/directory +// - cred - a SharedKeyCredential created with the matching directory's storage account and access key +// - options - client options; pass nil to accept the default values +func NewClientWithSharedKeyCredential(directoryURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientFromConnectionString creates an instance of Client with the specified values. +// - connectionString - a connection string for the desired storage account +// - shareName - the name of the share within the storage account +// - directoryName - the name of the directory within the storage account +// - options - client options; pass nil to accept the default values +func NewClientFromConnectionString(connectionString string, shareName string, directoryName string, options *ClientOptions) (*Client, error) { + return nil, nil +} + +func (d *Client) generated() *generated.DirectoryClient { + return base.InnerClient((*base.Client[generated.DirectoryClient])(d)) +} + +func (d *Client) sharedKey() *SharedKeyCredential { + return base.SharedKey((*base.Client[generated.DirectoryClient])(d)) +} + +// URL returns the URL endpoint used by the Client object. +func (d *Client) URL() string { + return "s.generated().Endpoint()" +} + +// NewSubdirectoryClient creates a new Client object by concatenating subDirectoryName to the end of this Client's URL. +// The new subdirectory Client uses the same request policy pipeline as the parent directory Client. +func (d *Client) NewSubdirectoryClient(subDirectoryName string) *Client { + return nil +} + +// NewFileClient creates a new file.Client object by concatenating fileName to the end of this Client's URL. +// The new file.Client uses the same request policy pipeline as the Client. +func (d *Client) NewFileClient(fileName string) *file.Client { + return nil +} + +// Create operation creates a new directory under the specified share or parent directory. +// 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) { + return CreateResponse{}, nil +} + +// Delete operation removes the specified empty directory. Note that the directory must be empty before it can be deleted. +// Deleting directories that aren't empty returns error 409 (Directory Not Empty). +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/delete-directory. +func (d *Client) Delete(ctx context.Context, options *DeleteOptions) (DeleteResponse, error) { + return DeleteResponse{}, nil +} + +// GetProperties operation returns all system properties for the specified directory, and it can also be used to check the existence of a directory. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-directory-properties. +func (d *Client) GetProperties(ctx context.Context, options *GetPropertiesOptions) (GetPropertiesResponse, error) { + return GetPropertiesResponse{}, nil +} + +// SetProperties operation sets system properties for the specified directory. +// 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) { + return SetPropertiesResponse{}, nil +} + +// SetMetadata operation sets user-defined metadata for the specified directory. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-directory-metadata. +func (d *Client) SetMetadata(ctx context.Context, options *SetMetadataOptions) (SetMetadataResponse, error) { + return SetMetadataResponse{}, nil +} + +// NewListFilesAndDirectoriesPager operation returns a pager for the files and directories starting from the specified Marker. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/list-directories-and-files. +func (d *Client) NewListFilesAndDirectoriesPager(options *ListFilesAndDirectoriesOptions) *runtime.Pager[ListFilesAndDirectoriesResponse] { + return nil +} diff --git a/sdk/storage/azfile/directory/constants.go b/sdk/storage/azfile/directory/constants.go new file mode 100644 index 000000000000..2574d573fc2c --- /dev/null +++ b/sdk/storage/azfile/directory/constants.go @@ -0,0 +1,24 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package directory + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// ListFilesIncludeType defines values for ListFilesIncludeType +type ListFilesIncludeType = generated.ListFilesIncludeType + +const ( + ListFilesIncludeTypeTimestamps ListFilesIncludeType = generated.ListFilesIncludeTypeTimestamps + ListFilesIncludeTypeEtag ListFilesIncludeType = generated.ListFilesIncludeTypeEtag + ListFilesIncludeTypeAttributes ListFilesIncludeType = generated.ListFilesIncludeTypeAttributes + ListFilesIncludeTypePermissionKey ListFilesIncludeType = generated.ListFilesIncludeTypePermissionKey +) + +// PossibleListFilesIncludeTypeValues returns the possible values for the ListFilesIncludeType const type. +func PossibleListFilesIncludeTypeValues() []ListFilesIncludeType { + return generated.PossibleListFilesIncludeTypeValues() +} diff --git a/sdk/storage/azfile/directory/models.go b/sdk/storage/azfile/directory/models.go new file mode 100644 index 000000000000..033a4a8bd30b --- /dev/null +++ b/sdk/storage/azfile/directory/models.go @@ -0,0 +1,97 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package directory + +import ( + "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" +) + +// SharedKeyCredential contains an account's name and its primary or secondary key. +type SharedKeyCredential = exported.SharedKeyCredential + +// --------------------------------------------------------------------------------------------------------------------- + +// CreateOptions contains the optional parameters for the Client.Create method. +type CreateOptions struct { + // The default value is 'Directory' for Attributes and 'now' for CreationTime and LastWriteTime fields in file.SMBProperties. + // TODO: Change the types of creation time and last write time to string from time.Time to include values like 'now', 'preserve', etc. + FileSMBProperties *file.SMBProperties + // The default value is 'inherit' for Permission field in file.Permissions. + FilePermissions *file.Permissions + // A name-value pair to associate with a file storage object. + Metadata map[string]*string +} + +// --------------------------------------------------------------------------------------------------------------------- + +// DeleteOptions contains the optional parameters for the Client.Delete method. +type DeleteOptions struct { + // placeholder for future options +} + +// --------------------------------------------------------------------------------------------------------------------- + +// GetPropertiesOptions contains the optional parameters for the Client.GetProperties method. +type GetPropertiesOptions struct { + // ShareSnapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query for the directory properties. + ShareSnapshot *string +} + +// --------------------------------------------------------------------------------------------------------------------- + +// SetPropertiesOptions contains the optional parameters for the Client.SetProperties method. +type SetPropertiesOptions struct { + // The default value is 'preserve' for Attributes, CreationTime and LastWriteTime fields in file.SMBProperties. + // TODO: Change the types of creation time and last write time to string from time.Time to include values like 'now', 'preserve', etc. + FileSMBProperties *file.SMBProperties + // The default value is 'preserve' for Permission field in file.Permissions. + FilePermissions *file.Permissions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// SetMetadataOptions contains the optional parameters for the Client.SetMetadata method. +type SetMetadataOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string +} + +// --------------------------------------------------------------------------------------------------------------------- + +// ListFilesAndDirectoriesOptions contains the optional parameters for the Client.NewListFilesAndDirectoriesPager method. +type ListFilesAndDirectoriesOptions struct { + // Include this parameter to specify one or more datasets to include in the response. + Include []ListFilesIncludeType + // Include extended information. + IncludeExtendedInfo *bool + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater + // than 5,000, the server will return up to 5,000 items. + MaxResults *int32 + // Filters the results to return only entries whose name begins with the specified prefix. + Prefix *string + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query for the list of files and directories. + ShareSnapshot *string +} + +// FilesAndDirectoriesListSegment - Abstract for entries that can be listed from directory. +type FilesAndDirectoriesListSegment = generated.FilesAndDirectoriesListSegment + +// Directory - A listed directory item. +type Directory = generated.Directory + +// File - A listed file item. +type File = generated.File + +// FileProperty - File properties. +type FileProperty = generated.FileProperty diff --git a/sdk/storage/azfile/directory/responses.go b/sdk/storage/azfile/directory/responses.go new file mode 100644 index 000000000000..f057fed8538f --- /dev/null +++ b/sdk/storage/azfile/directory/responses.go @@ -0,0 +1,30 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package directory + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// CreateResponse contains the response from method Client.Create. +type CreateResponse = generated.DirectoryClientCreateResponse + +// DeleteResponse contains the response from method Client.Delete. +type DeleteResponse = generated.DirectoryClientDeleteResponse + +// GetPropertiesResponse contains the response from method Client.GetProperties. +type GetPropertiesResponse = generated.DirectoryClientGetPropertiesResponse + +// SetPropertiesResponse contains the response from method Client.SetProperties. +type SetPropertiesResponse = generated.DirectoryClientSetPropertiesResponse + +// SetMetadataResponse contains the response from method Client.SetMetadata. +type SetMetadataResponse = generated.DirectoryClientSetMetadataResponse + +// ListFilesAndDirectoriesResponse contains the response from method Client.NewListFilesAndDirectoriesPager. +type ListFilesAndDirectoriesResponse = generated.DirectoryClientListFilesAndDirectoriesSegmentResponse + +// ListFilesAndDirectoriesSegmentResponse - An enumeration of directories and files. +type ListFilesAndDirectoriesSegmentResponse = generated.ListFilesAndDirectoriesSegmentResponse diff --git a/sdk/storage/azfile/file/client.go b/sdk/storage/azfile/file/client.go new file mode 100644 index 000000000000..9c259804f4e8 --- /dev/null +++ b/sdk/storage/azfile/file/client.go @@ -0,0 +1,175 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package file + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/base" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + "io" + "os" +) + +// ClientOptions contains the optional parameters when creating a Client. +type ClientOptions struct { + azcore.ClientOptions +} + +// Client represents a URL to the Azure Storage file. +type Client base.Client[generated.FileClient] + +// NewClient creates an instance of Client with the specified values. +// - fileURL - the URL of the file e.g. https://.file.core.windows.net/share/directoryPath/file +// - cred - an Azure AD credential, typically obtained via the azidentity module +// - options - client options; pass nil to accept the default values +func NewClient(fileURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientWithNoCredential creates an instance of Client with the specified values. +// This is used to anonymously access a file or with a shared access signature (SAS) token. +// - fileURL - the URL of the file e.g. https://.file.core.windows.net/share/directoryPath/file? +// - options - client options; pass nil to accept the default values +func NewClientWithNoCredential(fileURL string, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientWithSharedKeyCredential creates an instance of Client with the specified values. +// - fileURL - the URL of the file e.g. https://.file.core.windows.net/share/directoryPath/file +// - cred - a SharedKeyCredential created with the matching file's storage account and access key +// - options - client options; pass nil to accept the default values +func NewClientWithSharedKeyCredential(fileURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientFromConnectionString creates an instance of Client with the specified values. +// - connectionString - a connection string for the desired storage account +// - shareName - the name of the share within the storage account +// - directoryName - the name of the directory within the storage account +// - fileName - the name of the file within the storage account +// - options - client options; pass nil to accept the default values +func NewClientFromConnectionString(connectionString string, shareName string, directoryName string, fileName string, options *ClientOptions) (*Client, error) { + return nil, nil +} + +func (f *Client) generated() *generated.FileClient { + return base.InnerClient((*base.Client[generated.FileClient])(f)) +} + +func (f *Client) sharedKey() *SharedKeyCredential { + return base.SharedKey((*base.Client[generated.FileClient])(f)) +} + +// URL returns the URL endpoint used by the Client object. +func (f *Client) URL() string { + return "s.generated().Endpoint()" +} + +// Create operation creates a new file or replaces a file. Note it only initializes the file with no content. +// - fileContentLength: Specifies the maximum size for the file, up to 4 TB. +// +// 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) { + return CreateResponse{}, nil +} + +// Delete operation removes the file from the storage account. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/delete-file2. +func (f *Client) Delete(ctx context.Context, options *DeleteOptions) (DeleteResponse, error) { + return DeleteResponse{}, nil +} + +// GetProperties operation returns all user-defined metadata, standard HTTP properties, and system properties for the file. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-file-properties. +func (f *Client) GetProperties(ctx context.Context, options *GetPropertiesOptions) (GetPropertiesResponse, error) { + return GetPropertiesResponse{}, nil +} + +// SetHTTPHeaders operation sets HTTP headers on the file. +// 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) { + return SetHTTPHeadersResponse{}, nil +} + +// SetMetadata operation sets user-defined metadata for the specified file. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-file-metadata. +func (f *Client) SetMetadata(ctx context.Context, options *SetMetadataOptions) (SetMetadataResponse, error) { + return SetMetadataResponse{}, nil +} + +// StartCopyFromURL operation copies the data at the source URL to a file. +// - copySource: specifies the URL of the source file or blob, up to 2KiB in length. +// +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/copy-file. +func (f *Client) StartCopyFromURL(ctx context.Context, copySource string, options *StartCopyFromURLOptions) (StartCopyFromURLResponse, error) { + return StartCopyFromURLResponse{}, nil +} + +// AbortCopy operation cancels a pending Copy File operation, and leaves a destination file with zero length and full metadata. +// - copyID: the copy identifier provided in the x-ms-copy-id header of the original Copy File operation. +// +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/abort-copy-file. +func (f *Client) AbortCopy(ctx context.Context, copyID string, options *AbortCopyOptions) (AbortCopyResponse, error) { + return AbortCopyResponse{}, nil +} + +// DownloadStream operation reads or downloads a file from the system, including its metadata and properties. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-file. +func (f *Client) DownloadStream(ctx context.Context, options *DownloadStreamOptions) (DownloadStreamResponse, error) { + return DownloadStreamResponse{}, nil +} + +// DownloadBuffer downloads an Azure blob to a buffer with parallel. +func (f *Client) DownloadBuffer(ctx context.Context, buffer []byte, o *DownloadBufferOptions) (int64, error) { + return 0, nil +} + +// DownloadFile downloads an Azure blob to a local file. +// The file would be truncated if the size doesn't match. +func (f *Client) DownloadFile(ctx context.Context, file *os.File, o *DownloadFileOptions) (int64, error) { + return 0, nil +} + +// 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) { + return ResizeResponse{}, nil +} + +// UploadRange operation uploads a range of bytes to a file. +// - contentRange: Specifies the range of bytes to be written. +// - body: Specifies the data to be uploaded. +// +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/put-range. +func (f *Client) UploadRange(ctx context.Context, contentRange HTTPRange, body io.ReadSeekCloser, options *UploadRangeOptions) (UploadRangeResponse, error) { + return UploadRangeResponse{}, nil +} + +// ClearRange operation clears the specified range and releases the space used in storage for that range. +// - contentRange: Specifies the range of bytes to be cleared. +// +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/put-range. +func (f *Client) ClearRange(ctx context.Context, contentRange HTTPRange, options *ClearRangeOptions) (ClearRangeResponse, error) { + return ClearRangeResponse{}, nil +} + +// UploadRangeFromURL operation uploads a range of bytes to a file where the contents are read from a URL. +// - copySource: Specifies the URL of the source file or blob, up to 2 KB in length. +// - destinationRange: Specifies the range of bytes in the file to be written. +// - sourceRange: Bytes of source data in the specified range. +// +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/put-range-from-url. +func (f *Client) UploadRangeFromURL(ctx context.Context, copySource string, destinationRange HTTPRange, sourceRange HTTPRange, options *UploadRangeFromURLOptions) (UploadRangeFromURLResponse, error) { + return UploadRangeFromURLResponse{}, nil +} + +// GetRangeList operation returns the list of valid ranges for a file. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/list-ranges. +func (f *Client) GetRangeList(ctx context.Context, options *GetRangeListOptions) (GetRangeListResponse, error) { + return GetRangeListResponse{}, nil +} diff --git a/sdk/storage/azfile/file/constants.go b/sdk/storage/azfile/file/constants.go new file mode 100644 index 000000000000..ace31128a979 --- /dev/null +++ b/sdk/storage/azfile/file/constants.go @@ -0,0 +1,89 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package file + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// NTFSFileAttributes for Files and Directories. +// The subset of attributes is listed at: https://learn.microsoft.com/en-us/rest/api/storageservices/set-file-properties#file-system-attributes. +// Their respective values are listed at: https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants. +type NTFSFileAttributes uint32 + +const ( + Readonly NTFSFileAttributes = 1 + Hidden NTFSFileAttributes = 2 + System NTFSFileAttributes = 4 + Directory NTFSFileAttributes = 16 + Archive NTFSFileAttributes = 32 + None NTFSFileAttributes = 128 + Temporary NTFSFileAttributes = 256 + Offline NTFSFileAttributes = 4096 + NotContentIndexed NTFSFileAttributes = 8192 + NoScrubData NTFSFileAttributes = 131072 +) + +// PossibleNTFSFileAttributesValues returns the possible values for the NTFSFileAttributes const type. +func PossibleNTFSFileAttributesValues() []NTFSFileAttributes { + return []NTFSFileAttributes{ + Readonly, + Hidden, + System, + Directory, + Archive, + None, + Temporary, + Offline, + NotContentIndexed, + NoScrubData, + } +} + +// CopyStatusType defines the states of the copy operation. +type CopyStatusType = generated.CopyStatusType + +const ( + CopyStatusTypePending CopyStatusType = generated.CopyStatusTypePending + CopyStatusTypeSuccess CopyStatusType = generated.CopyStatusTypeSuccess + CopyStatusTypeAborted CopyStatusType = generated.CopyStatusTypeAborted + CopyStatusTypeFailed CopyStatusType = generated.CopyStatusTypeFailed +) + +// PossibleCopyStatusTypeValues returns the possible values for the CopyStatusType const type. +func PossibleCopyStatusTypeValues() []CopyStatusType { + return generated.PossibleCopyStatusTypeValues() +} + +// PermissionCopyModeType determines the copy behavior of the security descriptor of the file. +// - source: The security descriptor on the destination file is copied from the source file. +// - override: The security descriptor on the destination file is determined via the x-ms-file-permission or x-ms-file-permission-key header. +type PermissionCopyModeType = generated.PermissionCopyModeType + +const ( + PermissionCopyModeTypeSource PermissionCopyModeType = generated.PermissionCopyModeTypeSource + PermissionCopyModeTypeOverride PermissionCopyModeType = generated.PermissionCopyModeTypeOverride +) + +// PossiblePermissionCopyModeTypeValues returns the possible values for the PermissionCopyModeType const type. +func PossiblePermissionCopyModeTypeValues() []PermissionCopyModeType { + return generated.PossiblePermissionCopyModeTypeValues() +} + +// RangeWriteType represents one of the following options. +// - update: Writes the bytes specified by the request body into the specified range. The Range and Content-Length headers must match to perform the update. +// - clear: Clears the specified range and releases the space used in storage for that range. To clear a range, set the Content-Length header to zero, +// and set the Range header to a value that indicates the range to clear, up to maximum file size. +type RangeWriteType = generated.FileRangeWriteType + +const ( + RangeWriteTypeUpdate RangeWriteType = generated.FileRangeWriteTypeUpdate + RangeWriteTypeClear RangeWriteType = generated.FileRangeWriteTypeClear +) + +// PossibleRangeWriteTypeValues returns the possible values for the RangeWriteType const type. +func PossibleRangeWriteTypeValues() []RangeWriteType { + return generated.PossibleFileRangeWriteTypeValues() +} diff --git a/sdk/storage/azfile/file/models.go b/sdk/storage/azfile/file/models.go new file mode 100644 index 000000000000..5c95b0835a64 --- /dev/null +++ b/sdk/storage/azfile/file/models.go @@ -0,0 +1,279 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package file + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + "time" +) + +// SharedKeyCredential contains an account's name and its primary or secondary key. +type SharedKeyCredential = exported.SharedKeyCredential + +// SMBProperties contains the optional parameters regarding the SMB/NTFS properties for a file. +type SMBProperties struct { + // NTFSFileAttributes for Files and Directories. Default value is ‘None’ for file and ‘Directory’ + // for directory. ‘None’ can also be specified as default. + Attributes *NTFSFileAttributes + // The Coordinated Universal Time (UTC) creation time for the file/directory. Default value is 'now'. + CreationTime *time.Time + // The Coordinated Universal Time (UTC) last write time for the file/directory. Default value is 'now'. + LastWriteTime *time.Time +} + +// Permissions contains the optional parameters for the permissions on the file. +type Permissions 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. + Permission *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. + PermissionKey *string +} + +// HTTPHeaders contains optional parameters for the Client.Create method. +type HTTPHeaders = generated.ShareFileHTTPHeaders + +// LeaseAccessConditions contains optional parameters to access leased entity. +type LeaseAccessConditions = generated.LeaseAccessConditions + +// SourceModifiedAccessConditions contains a group of parameters for the FileClient.UploadRangeFromURL method. +type SourceModifiedAccessConditions = generated.SourceModifiedAccessConditions + +// CopyFileSMBInfo contains a group of parameters for the FileClient.StartCopy method. +type CopyFileSMBInfo = generated.CopyFileSMBInfo + +// HTTPRange defines a range of bytes within an HTTP resource, starting at offset and +// ending at offset+count. A zero-value HTTPRange indicates the entire resource. An HTTPRange +// which has an offset but no zero value count indicates from the offset to the resource's end. +type HTTPRange struct { + Offset int64 + Count int64 +} + +// ShareFileRangeList - The list of file ranges. +type ShareFileRangeList = generated.ShareFileRangeList + +// ClearRange - Ranges there were cleared. +type ClearRange = generated.ClearRange + +// ShareFileRange - An Azure Storage file range. +type ShareFileRange = generated.FileRange + +// --------------------------------------------------------------------------------------------------------------------- + +// CreateOptions contains the optional parameters for the Client.Create method. +type CreateOptions struct { + // The default value is 'None' for Attributes and 'now' for CreationTime and LastWriteTime fields in file.SMBProperties. + // TODO: Change the types of creation time and last write time to string from time.Time to include values like 'now', 'preserve', etc. + SMBProperties *SMBProperties + // The default value is 'inherit' for Permission field in file.Permissions. + Permissions *Permissions + HTTPHeaders *HTTPHeaders + LeaseAccessConditions *LeaseAccessConditions + // A name-value pair to associate with a file storage object. + Metadata map[string]*string +} + +// --------------------------------------------------------------------------------------------------------------------- + +// DeleteOptions contains the optional parameters for the Client.Delete method. +type DeleteOptions struct { + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// GetPropertiesOptions contains the optional parameters for the Client.GetProperties method. +type GetPropertiesOptions struct { + // ShareSnapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query for the file properties. + ShareSnapshot *string + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// SetHTTPHeadersOptions contains the optional parameters for the Client.SetHTTPHeaders method. +type SetHTTPHeadersOptions struct { + // 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 + // The default value is 'preserve' for Attributes, CreationTime and LastWriteTime fields in file.SMBProperties. + // TODO: Change the types of creation time and last write time to string from time.Time to include values like 'now', 'preserve', etc. + SMBProperties *SMBProperties + // The default value is 'preserve' for Permission field in file.Permissions. + Permissions *Permissions + HTTPHeaders *HTTPHeaders + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// SetMetadataOptions contains the optional parameters for the Client.SetMetadata method. +type SetMetadataOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// StartCopyFromURLOptions contains the optional parameters for the Client.StartCopyFromURL method. +type StartCopyFromURLOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + // required if x-ms-file-permission-copy-mode is specified as override + Permissions *Permissions + CopyFileSMBInfo *CopyFileSMBInfo + // LeaseAccessConditions contains optional parameters to access leased entity. + // Required if the destination file has an active lease. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// AbortCopyOptions contains the optional parameters for the Client.AbortCopy method. +type AbortCopyOptions struct { + // LeaseAccessConditions contains optional parameters to access leased entity. + // Required if the destination file has an active lease. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// DownloadStreamOptions contains the optional parameters for the Client.DownloadStream method. +type DownloadStreamOptions struct { + // Range specifies a range of bytes. The default value is all bytes. + Range HTTPRange + // When this header is set to true and specified together with the Range header, the service returns the MD5 hash for the + // range, as long as the range is less than or equal to 4 MB in size. + RangeGetContentMD5 *bool + // LeaseAccessConditions contains optional parameters to access leased entity. + // If specified, the operation is performed only if the file's lease is currently active and + // the lease ID that's specified in the request matches the lease ID of the file. + // Otherwise, the operation fails with status code 412 (Precondition Failed). + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// DownloadBufferOptions contains the optional parameters for the Client.DownloadBuffer method. +type DownloadBufferOptions struct { + // Range specifies a range of bytes. The default value is all bytes. + Range HTTPRange + + // When this header is set to true and specified together with the Range header, the service returns the MD5 hash for the + // range, as long as the range is less than or equal to 4 MB in size. + RangeGetContentMD5 *bool + + // ChunkSize specifies the block size to use for each parallel download; the default size is 4MB. + ChunkSize int64 + + // Progress is a function that is invoked periodically as bytes are received. + Progress func(bytesTransferred int64) + + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions + + // Concurrency indicates the maximum number of blocks to download in parallel (0=default). + Concurrency uint16 + + // RetryReaderOptionsPerBlock is used when downloading each block. + RetryReaderOptionsPerBlock RetryReaderOptions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// DownloadFileOptions contains the optional parameters for the Client.DownloadFile method. +type DownloadFileOptions struct { + // Range specifies a range of bytes. The default value is all bytes. + Range HTTPRange + + // When this header is set to true and specified together with the Range header, the service returns the MD5 hash for the + // range, as long as the range is less than or equal to 4 MB in size. + RangeGetContentMD5 *bool + + // ChunkSize specifies the block size to use for each parallel download; the default size is 4MB. + ChunkSize int64 + + // Progress is a function that is invoked periodically as bytes are received. + Progress func(bytesTransferred int64) + + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions + + // Concurrency indicates the maximum number of blocks to download in parallel (0=default). + Concurrency uint16 + + // RetryReaderOptionsPerBlock is used when downloading each block. + RetryReaderOptionsPerBlock RetryReaderOptions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// ResizeOptions contains the optional parameters for the Client.Resize method. +type ResizeOptions struct { + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// UploadRangeOptions contains the optional parameters for the Client.UploadRange method. +type UploadRangeOptions struct { + // An MD5 hash of the content. This hash is used to verify the integrity of the data during transport. When the Content-MD5 + // header is specified, the File service compares the hash of the content that has + // arrived with the header value that was sent. If the two hashes do not match, the operation will fail with error code 400 (Bad Request). + ContentMD5 []byte + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// ClearRangeOptions contains the optional parameters for the Client.ClearRange method. +type ClearRangeOptions struct { + // An MD5 hash of the content. This hash is used to verify the integrity of the data during transport. When the Content-MD5 + // header is specified, the File service compares the hash of the content that has + // arrived with the header value that was sent. If the two hashes do not match, the operation will fail with error code 400 (Bad Request). + ContentMD5 []byte + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// UploadRangeFromURLOptions contains the optional parameters for the Client.UploadRangeFromURL method. +type UploadRangeFromURLOptions struct { + // Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. + CopySourceAuthorization *string + // Specify the crc64 calculated for the range of bytes that must be read from the copy source. + SourceContentCRC64 []byte + SourceModifiedAccessConditions *SourceModifiedAccessConditions + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// GetRangeListOptions contains the optional parameters for the Client.GetRangeList method. +type GetRangeListOptions struct { + // The previous snapshot parameter is an opaque DateTime value that, when present, specifies the previous snapshot. + PrevShareSnapshot *string + // Specifies the range of bytes over which to list ranges, inclusively. + Range *HTTPRange + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + ShareSnapshot *string + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} diff --git a/sdk/storage/azfile/file/responses.go b/sdk/storage/azfile/file/responses.go new file mode 100644 index 000000000000..2c037fe8b996 --- /dev/null +++ b/sdk/storage/azfile/file/responses.go @@ -0,0 +1,56 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package file + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// CreateResponse contains the response from method Client.Create. +type CreateResponse = generated.FileClientCreateResponse + +// DeleteResponse contains the response from method Client.Delete. +type DeleteResponse = generated.FileClientDeleteResponse + +// GetPropertiesResponse contains the response from method Client.GetProperties. +type GetPropertiesResponse = generated.FileClientGetPropertiesResponse + +// SetMetadataResponse contains the response from method Client.SetMetadata. +type SetMetadataResponse = generated.FileClientSetMetadataResponse + +// SetHTTPHeadersResponse contains the response from method Client.SetHTTPHeaders. +type SetHTTPHeadersResponse = generated.FileClientSetHTTPHeadersResponse + +// StartCopyFromURLResponse contains the response from method Client.StartCopyFromURL. +type StartCopyFromURLResponse = generated.FileClientStartCopyResponse + +// AbortCopyResponse contains the response from method Client.AbortCopy. +type AbortCopyResponse = generated.FileClientAbortCopyResponse + +// DownloadResponse contains the response from method FileClient.Download. +type DownloadResponse = generated.FileClientDownloadResponse + +// DownloadStreamResponse contains the response from method Client.DownloadStream. +// To read from the stream, read from the Body field, or call the NewRetryReader method. +type DownloadStreamResponse struct { + DownloadResponse + client *Client + getInfo httpGetterInfo +} + +// ResizeResponse contains the response from method Client.Resize. +type ResizeResponse = generated.FileClientSetHTTPHeadersResponse + +// UploadRangeResponse contains the response from method Client.UploadRange. +type UploadRangeResponse = generated.FileClientUploadRangeResponse + +// ClearRangeResponse contains the response from method Client.ClearRange. +type ClearRangeResponse = generated.FileClientUploadRangeResponse + +// UploadRangeFromURLResponse contains the response from method Client.UploadRangeFromURL. +type UploadRangeFromURLResponse = generated.FileClientUploadRangeFromURLResponse + +// GetRangeListResponse contains the response from method Client.GetRangeList. +type GetRangeListResponse = generated.FileClientGetRangeListResponse diff --git a/sdk/storage/azfile/file/retry_reader.go b/sdk/storage/azfile/file/retry_reader.go new file mode 100644 index 000000000000..723f31fe72f4 --- /dev/null +++ b/sdk/storage/azfile/file/retry_reader.go @@ -0,0 +1,48 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package file + +import "github.com/Azure/azure-sdk-for-go/sdk/azcore" + +// httpGetterInfo is passed to an HTTPGetter function passing it parameters +// that should be used to make an HTTP GET request. +type httpGetterInfo struct { + Range HTTPRange + + // ETag specifies the resource's etag that should be used when creating + // the HTTP GET request's If-Match header + ETag *azcore.ETag +} + +// RetryReaderOptions configures the retry reader's behavior. +// Zero-value fields will have their specified default values applied during use. +// This allows for modification of a subset of fields. +type RetryReaderOptions struct { + // MaxRetries specifies the maximum number of attempts a failed read will be retried + // before producing an error. + // The default value is three. + MaxRetries int32 + + // OnFailedRead, when non-nil, is called after any failure to read. Expected usage is diagnostic logging. + OnFailedRead func(failureCount int32, lastError error, rnge HTTPRange, willRetry bool) + + // EarlyCloseAsError can be set to true to prevent retries after "read on closed response body". By default, + // retryReader has the following special behaviour: closing the response body before it is all read is treated as a + // retryable error. This is to allow callers to force a retry by closing the body from another goroutine (e.g. if the = + // read is too slow, caller may want to force a retry in the hope that the retry will be quicker). If + // TreatEarlyCloseAsError is true, then retryReader's special behaviour is suppressed, and "read on closed body" is instead + // treated as a fatal (non-retryable) error. + // Note that setting TreatEarlyCloseAsError only guarantees that Closing will produce a fatal error if the Close happens + // from the same "thread" (goroutine) as Read. Concurrent Close calls from other goroutines may instead produce network errors + // which will be retried. + // The default value is false. + EarlyCloseAsError bool + + doInjectError bool + doInjectErrorRound int32 + injectedError error +} diff --git a/sdk/storage/azfile/internal/base/clients.go b/sdk/storage/azfile/internal/base/clients.go new file mode 100644 index 000000000000..5661feff2f01 --- /dev/null +++ b/sdk/storage/azfile/internal/base/clients.go @@ -0,0 +1,24 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package base + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported" +) + +type Client[T any] struct { + inner *T + sharedKey *exported.SharedKeyCredential +} + +func InnerClient[T any](client *Client[T]) *T { + return client.inner +} + +func SharedKey[T any](client *Client[T]) *exported.SharedKeyCredential { + return client.sharedKey +} diff --git a/sdk/storage/azfile/internal/exported/shared_key_credential.go b/sdk/storage/azfile/internal/exported/shared_key_credential.go new file mode 100644 index 000000000000..44f2bc7b652b --- /dev/null +++ b/sdk/storage/azfile/internal/exported/shared_key_credential.go @@ -0,0 +1,45 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package exported + +import ( + "encoding/base64" + "fmt" + "sync/atomic" +) + +// SharedKeyCredential contains an account's name and its primary or secondary key. +type SharedKeyCredential struct { + // Only the NewSharedKeyCredential method should set these; all other methods should treat them as read-only + accountName string + accountKey atomic.Value // []byte +} + +// NewSharedKeyCredential creates an immutable SharedKeyCredential containing the +// storage account's name and either its primary or secondary key. +func NewSharedKeyCredential(accountName string, accountKey string) (*SharedKeyCredential, error) { + c := SharedKeyCredential{accountName: accountName} + if err := c.SetAccountKey(accountKey); err != nil { + return nil, err + } + return &c, nil +} + +// AccountName returns the Storage account's name. +func (c *SharedKeyCredential) AccountName() string { + return c.accountName +} + +// SetAccountKey replaces the existing account key with the specified account key. +func (c *SharedKeyCredential) SetAccountKey(accountKey string) error { + _bytes, err := base64.StdEncoding.DecodeString(accountKey) + if err != nil { + return fmt.Errorf("decode account key: %w", err) + } + c.accountKey.Store(_bytes) + return nil +} diff --git a/sdk/storage/azfile/internal/generated/autorest.md b/sdk/storage/azfile/internal/generated/autorest.md index 73717b6c227a..3ebe6634b6e8 100644 --- a/sdk/storage/azfile/internal/generated/autorest.md +++ b/sdk/storage/azfile/internal/generated/autorest.md @@ -74,35 +74,6 @@ directive: } ``` -### ShareServiceProperties, ShareMetrics, ShareCorsRule, and ShareRetentionPolicy - -``` yaml -directive: -- rename-model: - from: Metrics - to: ShareMetrics -- rename-model: - from: CorsRule - to: ShareCorsRule -- rename-model: - from: RetentionPolicy - to: ShareRetentionPolicy -- rename-model: - from: StorageServiceProperties - to: ShareServiceProperties - -- from: swagger-document - where: $.definitions - transform: > - $.ShareMetrics.properties.IncludeAPIs["x-ms-client-name"] = "IncludeApis"; - $.ShareServiceProperties.xml = {"name": "StorageServiceProperties"}; - $.ShareCorsRule.xml = {"name": "CorsRule"}; -- from: swagger-document - where: $.parameters - transform: > - $.StorageServiceProperties.name = "ShareServiceProperties"; -``` - ### Rename FileHttpHeaders to ShareFileHTTPHeaders and remove file prefix from properties ``` yaml @@ -123,3 +94,140 @@ directive: $.FileContentType["x-ms-parameter-grouping"].name = "share-file-http-headers"; $.FileContentType["x-ms-client-name"] = "contentType"; ``` + +### use azcore.ETag + +``` yaml +directive: +- from: zz_models.go + where: $ + transform: >- + return $. + replace(/import "time"/, `import (\n\t"time"\n\t"github.com/Azure/azure-sdk-for-go/sdk/azcore"\n)`). + replace(/Etag\s+\*string/g, `ETag *azcore.ETag`); + +- from: zz_response_types.go + where: $ + transform: >- + return $. + replace(/"time"/, `"time"\n\t"github.com/Azure/azure-sdk-for-go/sdk/azcore"`). + replace(/ETag\s+\*string/g, `ETag *azcore.ETag`); + +- from: + - zz_directory_client.go + - zz_file_client.go + - zz_share_client.go + where: $ + transform: >- + return $. + replace(/"github\.com\/Azure\/azure\-sdk\-for\-go\/sdk\/azcore\/policy"/, `"github.com/Azure/azure-sdk-for-go/sdk/azcore"\n\t"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"`). + replace(/result\.ETag\s+=\s+&val/g, `result.ETag = (*azcore.ETag)(&val)`); +``` + +### Rename models - remove `Share` prefix + +``` yaml +directive: +- rename-model: + from: ShareProtocolSettings + to: ProtocolSettings +- rename-model: + from: ShareSmbSettings + to: SMBSettings +``` + +### Capitalise SMB field + +``` yaml +directive: +- from: + - zz_file_client.go + - zz_models.go + where: $ + transform: >- + return $. + replace(/SmbMultichannel/g, `SMBMultichannel`). + replace(/copyFileSmbInfo/g, `copyFileSMBInfo`). + replace(/CopyFileSmbInfo/g, `CopyFileSMBInfo`). + replace(/Smb\s+\*ShareSMBSettings/g, `SMB *ShareSMBSettings`); +``` + +### Rename models - remove `Item` and `Internal` suffix + +``` yaml +directive: +- rename-model: + from: DirectoryItem + to: Directory +- rename-model: + from: FileItem + to: File +- rename-model: + from: HandleItem + to: Handle +- rename-model: + from: ShareItemInternal + to: Share +- rename-model: + from: SharePropertiesInternal + to: ShareProperties +``` + +### Remove `Items` and `List` suffix + +``` yaml +directive: + - from: source-file-go + where: $ + transform: >- + return $. + replace(/DirectoryItems/g, "Directories"). + replace(/FileItems/g, "Files"). + replace(/ShareItems/g, "Shares"). + replace(/HandleList/g, "Handles"); +``` + +### Rename `FileID` to `ID` (except for Handle object) + +``` yaml +directive: +- from: swagger-document + where: $.definitions + transform: > + $.Directory.properties.FileId["x-ms-client-name"] = "ID"; + $.File.properties.FileId["x-ms-client-name"] = "ID"; + $.Handle.properties.HandleId["x-ms-client-name"] = "ID"; + +- from: + - zz_directory_client.go + - zz_file_client.go + - zz_response_types.go + where: $ + transform: >- + return $. + replace(/FileID/g, `ID`); +``` + + +### Change CORS acronym to be all caps and rename `FileParentID` to `ParentID` + +``` yaml +directive: + - from: source-file-go + where: $ + transform: >- + return $. + replace(/Cors/g, "CORS"). + replace(/FileParentID/g, "ParentID"); +``` + +### Change cors xml to be correct + +``` yaml +directive: + - from: source-file-go + where: $ + transform: >- + return $. + replace(/xml:"CORS>CORSRule"/g, "xml:\"Cors>CorsRule\""); +``` diff --git a/sdk/storage/azfile/internal/generated/zz_directory_client.go b/sdk/storage/azfile/internal/generated/zz_directory_client.go index 481632599c8b..b6256d2c5448 100644 --- a/sdk/storage/azfile/internal/generated/zz_directory_client.go +++ b/sdk/storage/azfile/internal/generated/zz_directory_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" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" @@ -100,7 +101,7 @@ func (client *DirectoryClient) createCreateRequest(ctx context.Context, fileAttr func (client *DirectoryClient) createHandleResponse(resp *http.Response) (DirectoryClientCreateResponse, error) { result := DirectoryClientCreateResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -157,10 +158,10 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct result.FileChangeTime = &fileChangeTime } if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.FileID = &val + result.ID = &val } if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.FileParentID = &val + result.ParentID = &val } return result, nil } @@ -363,7 +364,7 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) } } if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -420,10 +421,10 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) result.FilePermissionKey = &val } if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.FileID = &val + result.ID = &val } if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.FileParentID = &val + result.ParentID = &val } return result, nil } @@ -646,7 +647,7 @@ func (client *DirectoryClient) setMetadataCreateRequest(ctx context.Context, opt func (client *DirectoryClient) setMetadataHandleResponse(resp *http.Response) (DirectoryClientSetMetadataResponse, error) { result := DirectoryClientSetMetadataResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val @@ -726,7 +727,7 @@ func (client *DirectoryClient) setPropertiesCreateRequest(ctx context.Context, f func (client *DirectoryClient) setPropertiesHandleResponse(resp *http.Response) (DirectoryClientSetPropertiesResponse, error) { result := DirectoryClientSetPropertiesResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val @@ -783,10 +784,10 @@ func (client *DirectoryClient) setPropertiesHandleResponse(resp *http.Response) result.FileChangeTime = &fileChangeTime } if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.FileID = &val + result.ID = &val } if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.FileParentID = &val + result.ParentID = &val } return result, nil } diff --git a/sdk/storage/azfile/internal/generated/zz_file_client.go b/sdk/storage/azfile/internal/generated/zz_file_client.go index c325e8b393a4..28c9a23feca1 100644 --- a/sdk/storage/azfile/internal/generated/zz_file_client.go +++ b/sdk/storage/azfile/internal/generated/zz_file_client.go @@ -12,6 +12,7 @@ package generated import ( "context" "encoding/base64" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" @@ -154,7 +155,7 @@ func (client *FileClient) acquireLeaseCreateRequest(ctx context.Context, options func (client *FileClient) acquireLeaseHandleResponse(resp *http.Response) (FileClientAcquireLeaseResponse, error) { result := FileClientAcquireLeaseResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -234,7 +235,7 @@ func (client *FileClient) breakLeaseCreateRequest(ctx context.Context, options * func (client *FileClient) breakLeaseHandleResponse(resp *http.Response) (FileClientBreakLeaseResponse, error) { result := FileClientBreakLeaseResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -315,7 +316,7 @@ func (client *FileClient) changeLeaseCreateRequest(ctx context.Context, leaseID func (client *FileClient) changeLeaseHandleResponse(resp *http.Response) (FileClientChangeLeaseResponse, error) { result := FileClientChangeLeaseResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -432,7 +433,7 @@ func (client *FileClient) createCreateRequest(ctx context.Context, fileContentLe func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientCreateResponse, error) { result := FileClientCreateResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -489,10 +490,10 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC result.FileChangeTime = &fileChangeTime } if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.FileID = &val + result.ID = &val } if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.FileParentID = &val + result.ParentID = &val } return result, nil } @@ -635,7 +636,7 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien result.ContentRange = &val } if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Content-MD5"); val != "" { contentMD5, err := base64.StdEncoding.DecodeString(val) @@ -736,10 +737,10 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien result.FilePermissionKey = &val } if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.FileID = &val + result.ID = &val } if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.FileParentID = &val + result.ParentID = &val } if val := resp.Header.Get("x-ms-lease-duration"); val != "" { result.LeaseDuration = (*LeaseDurationType)(&val) @@ -913,7 +914,7 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File result.ContentType = &val } if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Content-MD5"); val != "" { contentMD5, err := base64.StdEncoding.DecodeString(val) @@ -1004,10 +1005,10 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File result.FilePermissionKey = &val } if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.FileID = &val + result.ID = &val } if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.FileParentID = &val + result.ParentID = &val } if val := resp.Header.Get("x-ms-lease-duration"); val != "" { result.LeaseDuration = (*LeaseDurationType)(&val) @@ -1082,7 +1083,7 @@ func (client *FileClient) getRangeListHandleResponse(resp *http.Response) (FileC result.LastModified = &lastModified } if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-content-length"); val != "" { fileContentLength, err := strconv.ParseInt(val, 10, 64) @@ -1228,7 +1229,7 @@ func (client *FileClient) releaseLeaseCreateRequest(ctx context.Context, leaseID func (client *FileClient) releaseLeaseHandleResponse(resp *http.Response) (FileClientReleaseLeaseResponse, error) { result := FileClientReleaseLeaseResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -1336,7 +1337,7 @@ func (client *FileClient) setHTTPHeadersCreateRequest(ctx context.Context, fileA func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (FileClientSetHTTPHeadersResponse, error) { result := FileClientSetHTTPHeadersResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -1393,10 +1394,10 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil result.FileChangeTime = &fileChangeTime } if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.FileID = &val + result.ID = &val } if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.FileParentID = &val + result.ParentID = &val } return result, nil } @@ -1453,7 +1454,7 @@ func (client *FileClient) setMetadataCreateRequest(ctx context.Context, options func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileClientSetMetadataResponse, error) { result := FileClientSetMetadataResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val @@ -1496,10 +1497,10 @@ 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 FileClient.StartCopy 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) +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 } @@ -1514,7 +1515,7 @@ func (client *FileClient) StartCopy(ctx context.Context, copySource string, opti } // startCopyCreateRequest creates the StartCopy request. -func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource string, options *FileClientStartCopyOptions, copyFileSmbInfo *CopyFileSmbInfo, leaseAccessConditions *LeaseAccessConditions) (*policy.Request, error) { +func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource string, options *FileClientStartCopyOptions, copyFileSMBInfo *CopyFileSMBInfo, leaseAccessConditions *LeaseAccessConditions) (*policy.Request, error) { req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err @@ -1539,23 +1540,23 @@ func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource if options != nil && options.FilePermissionKey != nil { req.Raw().Header["x-ms-file-permission-key"] = []string{*options.FilePermissionKey} } - if copyFileSmbInfo != nil && copyFileSmbInfo.FilePermissionCopyMode != nil { - req.Raw().Header["x-ms-file-permission-copy-mode"] = []string{string(*copyFileSmbInfo.FilePermissionCopyMode)} + if copyFileSMBInfo != nil && copyFileSMBInfo.FilePermissionCopyMode != nil { + req.Raw().Header["x-ms-file-permission-copy-mode"] = []string{string(*copyFileSMBInfo.FilePermissionCopyMode)} } - if copyFileSmbInfo != nil && copyFileSmbInfo.IgnoreReadOnly != nil { - req.Raw().Header["x-ms-file-copy-ignore-readonly"] = []string{strconv.FormatBool(*copyFileSmbInfo.IgnoreReadOnly)} + if copyFileSMBInfo != nil && copyFileSMBInfo.IgnoreReadOnly != nil { + req.Raw().Header["x-ms-file-copy-ignore-readonly"] = []string{strconv.FormatBool(*copyFileSMBInfo.IgnoreReadOnly)} } - if copyFileSmbInfo != nil && copyFileSmbInfo.FileAttributes != nil { - req.Raw().Header["x-ms-file-attributes"] = []string{*copyFileSmbInfo.FileAttributes} + 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.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.FileLastWriteTime != nil { + req.Raw().Header["x-ms-file-last-write-time"] = []string{*copyFileSMBInfo.FileLastWriteTime} } - if copyFileSmbInfo != nil && copyFileSmbInfo.SetArchiveAttribute != nil { - req.Raw().Header["x-ms-file-copy-set-archive"] = []string{strconv.FormatBool(*copyFileSmbInfo.SetArchiveAttribute)} + 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} @@ -1568,7 +1569,7 @@ func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource func (client *FileClient) startCopyHandleResponse(resp *http.Response) (FileClientStartCopyResponse, error) { result := FileClientStartCopyResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -1663,7 +1664,7 @@ func (client *FileClient) uploadRangeCreateRequest(ctx context.Context, rangePar func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileClientUploadRangeResponse, error) { result := FileClientUploadRangeResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -1777,7 +1778,7 @@ func (client *FileClient) uploadRangeFromURLCreateRequest(ctx context.Context, r func (client *FileClient) uploadRangeFromURLHandleResponse(resp *http.Response) (FileClientUploadRangeFromURLResponse, error) { result := FileClientUploadRangeFromURLResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) diff --git a/sdk/storage/azfile/internal/generated/zz_models.go b/sdk/storage/azfile/internal/generated/zz_models.go index d922e6e252dd..d328d388c9e0 100644 --- a/sdk/storage/azfile/internal/generated/zz_models.go +++ b/sdk/storage/azfile/internal/generated/zz_models.go @@ -9,7 +9,10 @@ package generated -import "time" +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "time" +) // AccessPolicy - An Access policy. type AccessPolicy struct { @@ -31,8 +34,8 @@ type ClearRange struct { Start *int64 `xml:"Start"` } -// CopyFileSmbInfo contains a group of parameters for the FileClient.StartCopy method. -type CopyFileSmbInfo struct { +// CopyFileSMBInfo contains a group of parameters for the FileClient.StartCopy 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 @@ -52,6 +55,43 @@ type CopyFileSmbInfo struct { SetArchiveAttribute *bool } +// CORSRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in another +// domain. Web browsers implement a security restriction known as same-origin policy that +// prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin +// domain) to call APIs in another domain. +type CORSRule struct { + // REQUIRED; The request headers that the origin domain may specify on the CORS request. + AllowedHeaders *string `xml:"AllowedHeaders"` + + // REQUIRED; The methods (HTTP request verbs) that the origin domain may use for a CORS request. (comma separated) + AllowedMethods *string `xml:"AllowedMethods"` + + // REQUIRED; The origin domains that are permitted to make a request against the storage service via CORS. The origin domain + // is the domain from which the request originates. Note that the origin must be an exact + // case-sensitive match with the origin that the user age sends to the service. You can also use the wildcard character '*' + // to allow all origin domains to make requests via CORS. + AllowedOrigins *string `xml:"AllowedOrigins"` + + // REQUIRED; The response headers that may be sent in the response to the CORS request and exposed by the browser to the request + // issuer. + ExposedHeaders *string `xml:"ExposedHeaders"` + + // REQUIRED; The maximum amount time that a browser should cache the preflight OPTIONS request. + MaxAgeInSeconds *int32 `xml:"MaxAgeInSeconds"` +} + +// Directory - A listed directory item. +type Directory struct { + // REQUIRED + Name *string `xml:"Name"` + Attributes *string `xml:"Attributes"` + ID *string `xml:"FileId"` + PermissionKey *string `xml:"PermissionKey"` + + // File properties. + Properties *FileProperty `xml:"Properties"` +} + // DirectoryClientCreateOptions contains the optional parameters for the DirectoryClient.Create method. type DirectoryClientCreateOptions struct { // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission @@ -168,16 +208,16 @@ type DirectoryClientSetPropertiesOptions struct { Timeout *int32 } -// DirectoryItem - A listed directory item. -type DirectoryItem struct { +// File - A listed file item. +type File struct { // REQUIRED - Name *string `xml:"Name"` - Attributes *string `xml:"Attributes"` - FileID *string `xml:"FileId"` - PermissionKey *string `xml:"PermissionKey"` + Name *string `xml:"Name"` - // File properties. - Properties *FileProperty `xml:"Properties"` + // REQUIRED; File properties. + Properties *FileProperty `xml:"Properties"` + Attributes *string `xml:"Attributes"` + ID *string `xml:"FileId"` + PermissionKey *string `xml:"PermissionKey"` } // FileClientAbortCopyOptions contains the optional parameters for the FileClient.AbortCopy method. @@ -397,30 +437,18 @@ type FileClientUploadRangeOptions struct { Timeout *int32 } -// FileItem - A listed file item. -type FileItem struct { - // REQUIRED - Name *string `xml:"Name"` - - // REQUIRED; File properties. - Properties *FileProperty `xml:"Properties"` - Attributes *string `xml:"Attributes"` - FileID *string `xml:"FileId"` - PermissionKey *string `xml:"PermissionKey"` -} - // FileProperty - File properties. type FileProperty struct { // REQUIRED; Content length of the file. This value may not be up-to-date since an SMB client may have modified the file locally. // The value of Content-Length may not reflect that fact until the handle is closed or // the op-lock is broken. To retrieve current property values, call Get File Properties. - ContentLength *int64 `xml:"Content-Length"` - ChangeTime *time.Time `xml:"ChangeTime"` - CreationTime *time.Time `xml:"CreationTime"` - Etag *string `xml:"Etag"` - LastAccessTime *time.Time `xml:"LastAccessTime"` - LastModified *time.Time `xml:"Last-Modified"` - LastWriteTime *time.Time `xml:"LastWriteTime"` + ContentLength *int64 `xml:"Content-Length"` + ChangeTime *time.Time `xml:"ChangeTime"` + CreationTime *time.Time `xml:"CreationTime"` + ETag *azcore.ETag `xml:"Etag"` + LastAccessTime *time.Time `xml:"LastAccessTime"` + LastModified *time.Time `xml:"Last-Modified"` + LastWriteTime *time.Time `xml:"LastWriteTime"` } // FileRange - An Azure Storage file range. @@ -435,14 +463,14 @@ type FileRange struct { // FilesAndDirectoriesListSegment - Abstract for entries that can be listed from Directory. type FilesAndDirectoriesListSegment struct { // REQUIRED - DirectoryItems []*DirectoryItem `xml:"Directory"` + Directories []*Directory `xml:"Directory"` // REQUIRED - FileItems []*FileItem `xml:"File"` + Files []*File `xml:"File"` } -// HandleItem - A listed Azure Storage handle item. -type HandleItem struct { +// Handle - A listed Azure Storage handle item. +type Handle struct { // REQUIRED; Client IP that opened the handle ClientIP *string `xml:"ClientIp"` @@ -450,7 +478,7 @@ type HandleItem struct { FileID *string `xml:"FileId"` // REQUIRED; XSMB service handle ID - HandleID *string `xml:"HandleId"` + ID *string `xml:"HandleId"` // REQUIRED; Time when the session that previously opened the handle has last been reconnected. (UTC) OpenTime *time.Time `xml:"OpenTime"` @@ -502,8 +530,8 @@ type ListFilesAndDirectoriesSegmentResponse struct { // ListHandlesResponse - An enumeration of handles. type ListHandlesResponse struct { // REQUIRED - NextMarker *string `xml:"NextMarker"` - HandleList []*HandleItem `xml:"Entries>Handle"` + NextMarker *string `xml:"NextMarker"` + Handles []*Handle `xml:"Entries>Handle"` } // ListSharesResponse - An enumeration of shares. @@ -512,11 +540,49 @@ type ListSharesResponse struct { NextMarker *string `xml:"NextMarker"` // REQUIRED - ServiceEndpoint *string `xml:"ServiceEndpoint,attr"` - Marker *string `xml:"Marker"` - MaxResults *int32 `xml:"MaxResults"` - Prefix *string `xml:"Prefix"` - ShareItems []*ShareItemInternal `xml:"Shares>Share"` + ServiceEndpoint *string `xml:"ServiceEndpoint,attr"` + Marker *string `xml:"Marker"` + MaxResults *int32 `xml:"MaxResults"` + Prefix *string `xml:"Prefix"` + Shares []*Share `xml:"Shares>Share"` +} + +// Metrics - Storage Analytics metrics for file service. +type Metrics struct { + // REQUIRED; Indicates whether metrics are enabled for the File service. + Enabled *bool `xml:"Enabled"` + + // REQUIRED; The version of Storage Analytics to configure. + Version *string `xml:"Version"` + + // Indicates whether metrics should generate summary statistics for called API operations. + IncludeAPIs *bool `xml:"IncludeAPIs"` + + // The retention policy. + RetentionPolicy *RetentionPolicy `xml:"RetentionPolicy"` +} + +// ProtocolSettings - Protocol settings +type ProtocolSettings struct { + // Settings for SMB protocol. + Smb *SMBSettings `xml:"SMB"` +} + +// RetentionPolicy - The retention policy. +type RetentionPolicy struct { + // REQUIRED; Indicates whether a retention policy is enabled for the File service. If false, metrics data is retained, and + // the user is responsible for deleting it. + Enabled *bool `xml:"Enabled"` + + // Indicates the number of days that metrics data should be retained. All data older than this value will be deleted. Metrics + // data is deleted on a best-effort basis after the retention period expires. + Days *int32 `xml:"Days"` +} + +// SMBSettings - Settings for SMB protocol. +type SMBSettings struct { + // Settings for SMB Multichannel. + Multichannel *SMBMultichannel `xml:"Multichannel"` } // ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. @@ -553,6 +619,21 @@ type ServiceClientSetPropertiesOptions struct { Timeout *int32 } +// Share - A listed Azure Storage share item. +type Share struct { + // REQUIRED + Name *string `xml:"Name"` + + // REQUIRED; Properties of a share. + Properties *ShareProperties `xml:"Properties"` + Deleted *bool `xml:"Deleted"` + + // Dictionary of + Metadata map[string]*string `xml:"Metadata"` + Snapshot *string `xml:"Snapshot"` + Version *string `xml:"Version"` +} + // ShareClientAcquireLeaseOptions contains the optional parameters for the ShareClient.AcquireLease method. type ShareClientAcquireLeaseOptions struct { // Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite lease @@ -749,31 +830,6 @@ type ShareClientSetPropertiesOptions struct { Timeout *int32 } -// ShareCorsRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in -// another domain. Web browsers implement a security restriction known as same-origin policy that -// prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin -// domain) to call APIs in another domain. -type ShareCorsRule struct { - // REQUIRED; The request headers that the origin domain may specify on the CORS request. - AllowedHeaders *string `xml:"AllowedHeaders"` - - // REQUIRED; The methods (HTTP request verbs) that the origin domain may use for a CORS request. (comma separated) - AllowedMethods *string `xml:"AllowedMethods"` - - // REQUIRED; The origin domains that are permitted to make a request against the storage service via CORS. The origin domain - // is the domain from which the request originates. Note that the origin must be an exact - // case-sensitive match with the origin that the user age sends to the service. You can also use the wildcard character '*' - // to allow all origin domains to make requests via CORS. - AllowedOrigins *string `xml:"AllowedOrigins"` - - // REQUIRED; The response headers that may be sent in the response to the CORS request and exposed by the browser to the request - // issuer. - ExposedHeaders *string `xml:"ExposedHeaders"` - - // REQUIRED; The maximum amount time that a browser should cache the preflight OPTIONS request. - MaxAgeInSeconds *int32 `xml:"MaxAgeInSeconds"` -} - // ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. type ShareFileHTTPHeaders struct { // Sets the file's cache control. The File service stores this value but does not use or modify it. @@ -796,46 +852,16 @@ type ShareFileRangeList struct { Ranges []*FileRange `xml:"Range"` } -// ShareItemInternal - A listed Azure Storage share item. -type ShareItemInternal struct { - // REQUIRED - Name *string `xml:"Name"` - - // REQUIRED; Properties of a share. - Properties *SharePropertiesInternal `xml:"Properties"` - Deleted *bool `xml:"Deleted"` - - // Dictionary of - Metadata map[string]*string `xml:"Metadata"` - Snapshot *string `xml:"Snapshot"` - Version *string `xml:"Version"` -} - -// ShareMetrics - Storage Analytics metrics for file service. -type ShareMetrics struct { - // REQUIRED; Indicates whether metrics are enabled for the File service. - Enabled *bool `xml:"Enabled"` - - // REQUIRED; The version of Storage Analytics to configure. - Version *string `xml:"Version"` - - // Indicates whether metrics should generate summary statistics for called API operations. - IncludeApis *bool `xml:"IncludeAPIs"` - - // The retention policy. - RetentionPolicy *ShareRetentionPolicy `xml:"RetentionPolicy"` -} - // 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"` } -// SharePropertiesInternal - Properties of a share. -type SharePropertiesInternal struct { +// ShareProperties - Properties of a share. +type ShareProperties struct { // REQUIRED - Etag *string `xml:"Etag"` + ETag *azcore.ETag `xml:"Etag"` // REQUIRED LastModified *time.Time `xml:"Last-Modified"` @@ -864,44 +890,6 @@ type SharePropertiesInternal struct { RootSquash *ShareRootSquash `xml:"RootSquash"` } -// ShareProtocolSettings - Protocol settings -type ShareProtocolSettings struct { - // Settings for SMB protocol. - Smb *ShareSmbSettings `xml:"SMB"` -} - -// ShareRetentionPolicy - The retention policy. -type ShareRetentionPolicy struct { - // REQUIRED; Indicates whether a retention policy is enabled for the File service. If false, metrics data is retained, and - // the user is responsible for deleting it. - Enabled *bool `xml:"Enabled"` - - // Indicates the number of days that metrics data should be retained. All data older than this value will be deleted. Metrics - // data is deleted on a best-effort basis after the retention period expires. - Days *int32 `xml:"Days"` -} - -// ShareServiceProperties - Storage service properties. -type ShareServiceProperties struct { - // The set of CORS rules. - Cors []*ShareCorsRule `xml:"Cors>CorsRule"` - - // A summary of request statistics grouped by API in hourly aggregates for files. - HourMetrics *ShareMetrics `xml:"HourMetrics"` - - // A summary of request statistics grouped by API in minute aggregates for files. - MinuteMetrics *ShareMetrics `xml:"MinuteMetrics"` - - // Protocol settings - Protocol *ShareProtocolSettings `xml:"ProtocolSettings"` -} - -// ShareSmbSettings - Settings for SMB protocol. -type ShareSmbSettings struct { - // Settings for SMB Multichannel. - Multichannel *SmbMultichannel `xml:"Multichannel"` -} - // ShareStats - Stats for the share. type ShareStats struct { // REQUIRED; The approximate size of the data stored in bytes. Note that this value may not include all recently created or @@ -918,8 +906,8 @@ type SignedIdentifier struct { AccessPolicy *AccessPolicy `xml:"AccessPolicy"` } -// SmbMultichannel - Settings for SMB multichannel -type SmbMultichannel struct { +// SMBMultichannel - Settings for SMB multichannel +type SMBMultichannel struct { // If SMB multichannel is enabled. Enabled *bool `xml:"Enabled"` } @@ -935,3 +923,18 @@ type SourceModifiedAccessConditions struct { type StorageError struct { Message *string `json:"Message,omitempty"` } + +// StorageServiceProperties - Storage service properties. +type StorageServiceProperties struct { + // The set of CORS rules. + CORS []*CORSRule `xml:"Cors>CorsRule"` + + // A summary of request statistics grouped by API in hourly aggregates for files. + HourMetrics *Metrics `xml:"HourMetrics"` + + // A summary of request statistics grouped by API in minute aggregates for files. + MinuteMetrics *Metrics `xml:"MinuteMetrics"` + + // Protocol settings + Protocol *ProtocolSettings `xml:"ProtocolSettings"` +} diff --git a/sdk/storage/azfile/internal/generated/zz_models_serde.go b/sdk/storage/azfile/internal/generated/zz_models_serde.go index d7e8c78ffb98..7f837baac65c 100644 --- a/sdk/storage/azfile/internal/generated/zz_models_serde.go +++ b/sdk/storage/azfile/internal/generated/zz_models_serde.go @@ -101,23 +101,23 @@ func (f FilesAndDirectoriesListSegment) MarshalXML(enc *xml.Encoder, start xml.S type alias FilesAndDirectoriesListSegment aux := &struct { *alias - DirectoryItems *[]*DirectoryItem `xml:"Directory"` - FileItems *[]*FileItem `xml:"File"` + Directories *[]*Directory `xml:"Directory"` + Files *[]*File `xml:"File"` }{ alias: (*alias)(&f), } - if f.DirectoryItems != nil { - aux.DirectoryItems = &f.DirectoryItems + if f.Directories != nil { + aux.Directories = &f.Directories } - if f.FileItems != nil { - aux.FileItems = &f.FileItems + if f.Files != nil { + aux.Files = &f.Files } return enc.EncodeElement(aux, start) } -// MarshalXML implements the xml.Marshaller interface for type HandleItem. -func (h HandleItem) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { - type alias HandleItem +// 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"` @@ -130,9 +130,9 @@ func (h HandleItem) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { return enc.EncodeElement(aux, start) } -// UnmarshalXML implements the xml.Unmarshaller interface for type HandleItem. -func (h *HandleItem) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { - type alias HandleItem +// 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"` @@ -153,12 +153,12 @@ func (l ListHandlesResponse) MarshalXML(enc *xml.Encoder, start xml.StartElement type alias ListHandlesResponse aux := &struct { *alias - HandleList *[]*HandleItem `xml:"Entries>Handle"` + Handles *[]*Handle `xml:"Entries>Handle"` }{ alias: (*alias)(&l), } - if l.HandleList != nil { - aux.HandleList = &l.HandleList + if l.Handles != nil { + aux.Handles = &l.Handles } return enc.EncodeElement(aux, start) } @@ -168,16 +168,32 @@ func (l ListSharesResponse) MarshalXML(enc *xml.Encoder, start xml.StartElement) type alias ListSharesResponse aux := &struct { *alias - ShareItems *[]*ShareItemInternal `xml:"Shares>Share"` + Shares *[]*Share `xml:"Shares>Share"` }{ alias: (*alias)(&l), } - if l.ShareItems != nil { - aux.ShareItems = &l.ShareItems + if l.Shares != nil { + aux.Shares = &l.Shares } return enc.EncodeElement(aux, start) } +// UnmarshalXML implements the xml.Unmarshaller interface for type Share. +func (s *Share) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { + type alias Share + aux := &struct { + *alias + Metadata additionalProperties `xml:"Metadata"` + }{ + alias: (*alias)(s), + } + if err := dec.DecodeElement(aux, &start); err != nil { + return err + } + s.Metadata = (map[string]*string)(aux.Metadata) + return nil +} + // MarshalXML implements the xml.Marshaller interface for type ShareFileRangeList. func (s ShareFileRangeList) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias ShareFileRangeList @@ -197,22 +213,6 @@ func (s ShareFileRangeList) MarshalXML(enc *xml.Encoder, start xml.StartElement) return enc.EncodeElement(aux, start) } -// UnmarshalXML implements the xml.Unmarshaller interface for type ShareItemInternal. -func (s *ShareItemInternal) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { - type alias ShareItemInternal - aux := &struct { - *alias - Metadata additionalProperties `xml:"Metadata"` - }{ - alias: (*alias)(s), - } - if err := dec.DecodeElement(aux, &start); err != nil { - return err - } - s.Metadata = (map[string]*string)(aux.Metadata) - return nil -} - // MarshalJSON implements the json.Marshaller interface for type SharePermission. func (s SharePermission) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -240,9 +240,9 @@ func (s *SharePermission) UnmarshalJSON(data []byte) error { return nil } -// MarshalXML implements the xml.Marshaller interface for type SharePropertiesInternal. -func (s SharePropertiesInternal) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { - type alias SharePropertiesInternal +// MarshalXML implements the xml.Marshaller interface for type ShareProperties. +func (s ShareProperties) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { + type alias ShareProperties aux := &struct { *alias AccessTierChangeTime *timeRFC1123 `xml:"AccessTierChangeTime"` @@ -259,9 +259,9 @@ func (s SharePropertiesInternal) MarshalXML(enc *xml.Encoder, start xml.StartEle return enc.EncodeElement(aux, start) } -// UnmarshalXML implements the xml.Unmarshaller interface for type SharePropertiesInternal. -func (s *SharePropertiesInternal) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { - type alias SharePropertiesInternal +// UnmarshalXML implements the xml.Unmarshaller interface for type ShareProperties. +func (s *ShareProperties) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { + type alias ShareProperties aux := &struct { *alias AccessTierChangeTime *timeRFC1123 `xml:"AccessTierChangeTime"` @@ -281,22 +281,6 @@ func (s *SharePropertiesInternal) UnmarshalXML(dec *xml.Decoder, start xml.Start return nil } -// MarshalXML implements the xml.Marshaller interface for type ShareServiceProperties. -func (s ShareServiceProperties) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { - start.Name.Local = "StorageServiceProperties" - type alias ShareServiceProperties - aux := &struct { - *alias - Cors *[]*ShareCorsRule `xml:"Cors>CorsRule"` - }{ - alias: (*alias)(&s), - } - if s.Cors != nil { - aux.Cors = &s.Cors - } - return enc.EncodeElement(aux, start) -} - // MarshalJSON implements the json.Marshaller interface for type StorageError. func (s StorageError) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -324,6 +308,21 @@ func (s *StorageError) UnmarshalJSON(data []byte) error { return nil } +// MarshalXML implements the xml.Marshaller interface for type StorageServiceProperties. +func (s StorageServiceProperties) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { + type alias StorageServiceProperties + aux := &struct { + *alias + CORS *[]*CORSRule `xml:"Cors>CorsRule"` + }{ + alias: (*alias)(&s), + } + if s.CORS != nil { + aux.CORS = &s.CORS + } + return enc.EncodeElement(aux, start) +} + func populate(m map[string]any, k string, v any) { if v == nil { return diff --git a/sdk/storage/azfile/internal/generated/zz_response_types.go b/sdk/storage/azfile/internal/generated/zz_response_types.go index 6304bd3c5bed..be6bf1f60562 100644 --- a/sdk/storage/azfile/internal/generated/zz_response_types.go +++ b/sdk/storage/azfile/internal/generated/zz_response_types.go @@ -10,6 +10,7 @@ package generated import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "io" "time" ) @@ -20,7 +21,7 @@ type DirectoryClientCreateResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // FileAttributes contains the information returned from the x-ms-file-attributes header response. FileAttributes *string @@ -31,14 +32,14 @@ type DirectoryClientCreateResponse struct { // FileCreationTime contains the information returned from the x-ms-file-creation-time header response. FileCreationTime *time.Time - // FileID contains the information returned from the x-ms-file-id header response. - FileID *string + // 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 - // FileParentID contains the information returned from the x-ms-file-parent-id header response. - FileParentID *string + // 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 @@ -95,7 +96,7 @@ type DirectoryClientGetPropertiesResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // FileAttributes contains the information returned from the x-ms-file-attributes header response. FileAttributes *string @@ -106,14 +107,14 @@ type DirectoryClientGetPropertiesResponse struct { // FileCreationTime contains the information returned from the x-ms-file-creation-time header response. FileCreationTime *time.Time - // FileID contains the information returned from the x-ms-file-id header response. - FileID *string + // 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 - // FileParentID contains the information returned from the x-ms-file-parent-id header response. - FileParentID *string + // 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 @@ -172,7 +173,7 @@ type DirectoryClientSetMetadataResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // IsServerEncrypted contains the information returned from the x-ms-request-server-encrypted header response. IsServerEncrypted *bool @@ -190,7 +191,7 @@ type DirectoryClientSetPropertiesResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // FileAttributes contains the information returned from the x-ms-file-attributes header response. FileAttributes *string @@ -201,14 +202,14 @@ type DirectoryClientSetPropertiesResponse struct { // FileCreationTime contains the information returned from the x-ms-file-creation-time header response. FileCreationTime *time.Time - // FileID contains the information returned from the x-ms-file-id header response. - FileID *string + // 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 - // FileParentID contains the information returned from the x-ms-file-parent-id header response. - FileParentID *string + // 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 @@ -247,7 +248,7 @@ type FileClientAcquireLeaseResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -271,7 +272,7 @@ type FileClientBreakLeaseResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -295,7 +296,7 @@ type FileClientChangeLeaseResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -316,7 +317,7 @@ type FileClientCreateResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // FileAttributes contains the information returned from the x-ms-file-attributes header response. FileAttributes *string @@ -327,14 +328,14 @@ type FileClientCreateResponse struct { // FileCreationTime contains the information returned from the x-ms-file-creation-time header response. FileCreationTime *time.Time - // FileID contains the information returned from the x-ms-file-id header response. - FileID *string + // 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 - // FileParentID contains the information returned from the x-ms-file-parent-id header response. - FileParentID *string + // 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 @@ -418,7 +419,7 @@ type FileClientDownloadResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // FileAttributes contains the information returned from the x-ms-file-attributes header response. FileAttributes *string @@ -432,14 +433,14 @@ type FileClientDownloadResponse struct { // FileCreationTime contains the information returned from the x-ms-file-creation-time header response. FileCreationTime *time.Time - // FileID contains the information returned from the x-ms-file-id header response. - FileID *string + // 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 - // FileParentID contains the information returned from the x-ms-file-parent-id header response. - FileParentID *string + // 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 @@ -535,7 +536,7 @@ type FileClientGetPropertiesResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // FileAttributes contains the information returned from the x-ms-file-attributes header response. FileAttributes *string @@ -546,14 +547,14 @@ type FileClientGetPropertiesResponse struct { // FileCreationTime contains the information returned from the x-ms-file-creation-time header response. FileCreationTime *time.Time - // FileID contains the information returned from the x-ms-file-id header response. - FileID *string + // 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 - // FileParentID contains the information returned from the x-ms-file-parent-id header response. - FileParentID *string + // 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 @@ -593,7 +594,7 @@ type FileClientGetRangeListResponse struct { Date *time.Time `xml:"Date"` // ETag contains the information returned from the ETag header response. - ETag *string `xml:"ETag"` + ETag *azcore.ETag `xml:"ETag"` // FileContentLength contains the information returned from the x-ms-content-length header response. FileContentLength *int64 `xml:"FileContentLength"` @@ -633,7 +634,7 @@ type FileClientReleaseLeaseResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -651,7 +652,7 @@ type FileClientSetHTTPHeadersResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // FileAttributes contains the information returned from the x-ms-file-attributes header response. FileAttributes *string @@ -662,14 +663,14 @@ type FileClientSetHTTPHeadersResponse struct { // FileCreationTime contains the information returned from the x-ms-file-creation-time header response. FileCreationTime *time.Time - // FileID contains the information returned from the x-ms-file-id header response. - FileID *string + // 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 - // FileParentID contains the information returned from the x-ms-file-parent-id header response. - FileParentID *string + // 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 @@ -693,7 +694,7 @@ type FileClientSetMetadataResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // IsServerEncrypted contains the information returned from the x-ms-request-server-encrypted header response. IsServerEncrypted *bool @@ -720,7 +721,7 @@ type FileClientStartCopyResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -741,7 +742,7 @@ type FileClientUploadRangeFromURLResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // IsServerEncrypted contains the information returned from the x-ms-request-server-encrypted header response. IsServerEncrypted *bool @@ -768,7 +769,7 @@ type FileClientUploadRangeResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // IsServerEncrypted contains the information returned from the x-ms-request-server-encrypted header response. IsServerEncrypted *bool @@ -785,7 +786,7 @@ type FileClientUploadRangeResponse struct { // ServiceClientGetPropertiesResponse contains the response from method ServiceClient.GetProperties. type ServiceClientGetPropertiesResponse struct { - ShareServiceProperties + StorageServiceProperties // RequestID contains the information returned from the x-ms-request-id header response. RequestID *string `xml:"RequestID"` @@ -821,7 +822,7 @@ type ShareClientAcquireLeaseResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -845,7 +846,7 @@ type ShareClientBreakLeaseResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -872,7 +873,7 @@ type ShareClientChangeLeaseResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -908,7 +909,7 @@ type ShareClientCreateResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -926,7 +927,7 @@ type ShareClientCreateSnapshotResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -959,7 +960,7 @@ type ShareClientGetAccessPolicyResponse struct { Date *time.Time `xml:"Date"` // ETag contains the information returned from the ETag header response. - ETag *string `xml:"ETag"` + ETag *azcore.ETag `xml:"ETag"` // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time `xml:"LastModified"` @@ -1002,7 +1003,7 @@ type ShareClientGetPropertiesResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // EnabledProtocols contains the information returned from the x-ms-enabled-protocols header response. EnabledProtocols *string @@ -1055,7 +1056,7 @@ type ShareClientGetStatisticsResponse struct { Date *time.Time `xml:"Date"` // ETag contains the information returned from the ETag header response. - ETag *string `xml:"ETag"` + ETag *azcore.ETag `xml:"ETag"` // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time `xml:"LastModified"` @@ -1076,7 +1077,7 @@ type ShareClientReleaseLeaseResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -1097,7 +1098,7 @@ type ShareClientRenewLeaseResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -1121,7 +1122,7 @@ type ShareClientRestoreResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -1139,7 +1140,7 @@ type ShareClientSetAccessPolicyResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -1157,7 +1158,7 @@ type ShareClientSetMetadataResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time @@ -1175,7 +1176,7 @@ type ShareClientSetPropertiesResponse struct { Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *string + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. LastModified *time.Time diff --git a/sdk/storage/azfile/internal/generated/zz_service_client.go b/sdk/storage/azfile/internal/generated/zz_service_client.go index 18fd7dddc872..8b388a79c3e3 100644 --- a/sdk/storage/azfile/internal/generated/zz_service_client.go +++ b/sdk/storage/azfile/internal/generated/zz_service_client.go @@ -85,7 +85,7 @@ func (client *ServiceClient) getPropertiesHandleResponse(resp *http.Response) (S if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if err := runtime.UnmarshalAsXML(resp, &result.ShareServiceProperties); err != nil { + if err := runtime.UnmarshalAsXML(resp, &result.StorageServiceProperties); err != nil { return ServiceClientGetPropertiesResponse{}, err } return result, nil @@ -174,10 +174,10 @@ func (client *ServiceClient) listSharesSegmentHandleResponse(resp *http.Response // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2020-10-02 -// - shareServiceProperties - The StorageService properties. +// - storageServiceProperties - The StorageService properties. // - options - ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. -func (client *ServiceClient) SetProperties(ctx context.Context, shareServiceProperties ShareServiceProperties, options *ServiceClientSetPropertiesOptions) (ServiceClientSetPropertiesResponse, error) { - req, err := client.setPropertiesCreateRequest(ctx, shareServiceProperties, options) +func (client *ServiceClient) SetProperties(ctx context.Context, storageServiceProperties StorageServiceProperties, options *ServiceClientSetPropertiesOptions) (ServiceClientSetPropertiesResponse, error) { + req, err := client.setPropertiesCreateRequest(ctx, storageServiceProperties, options) if err != nil { return ServiceClientSetPropertiesResponse{}, err } @@ -192,7 +192,7 @@ func (client *ServiceClient) SetProperties(ctx context.Context, shareServiceProp } // setPropertiesCreateRequest creates the SetProperties request. -func (client *ServiceClient) setPropertiesCreateRequest(ctx context.Context, shareServiceProperties ShareServiceProperties, options *ServiceClientSetPropertiesOptions) (*policy.Request, error) { +func (client *ServiceClient) setPropertiesCreateRequest(ctx context.Context, storageServiceProperties StorageServiceProperties, options *ServiceClientSetPropertiesOptions) (*policy.Request, error) { req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err @@ -206,7 +206,7 @@ func (client *ServiceClient) setPropertiesCreateRequest(ctx context.Context, sha req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-version"] = []string{"2020-10-02"} req.Raw().Header["Accept"] = []string{"application/xml"} - return req, runtime.MarshalAsXML(req, shareServiceProperties) + return req, runtime.MarshalAsXML(req, storageServiceProperties) } // 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 fddc21c9d147..729f7c16801a 100644 --- a/sdk/storage/azfile/internal/generated/zz_share_client.go +++ b/sdk/storage/azfile/internal/generated/zz_share_client.go @@ -12,6 +12,7 @@ package generated import ( "context" "encoding/xml" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" @@ -95,7 +96,7 @@ func (client *ShareClient) acquireLeaseCreateRequest(ctx context.Context, option func (client *ShareClient) acquireLeaseHandleResponse(resp *http.Response) (ShareClientAcquireLeaseResponse, error) { result := ShareClientAcquireLeaseResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -183,7 +184,7 @@ func (client *ShareClient) breakLeaseCreateRequest(ctx context.Context, options func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareClientBreakLeaseResponse, error) { result := ShareClientBreakLeaseResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -277,7 +278,7 @@ func (client *ShareClient) changeLeaseCreateRequest(ctx context.Context, leaseID func (client *ShareClient) changeLeaseHandleResponse(resp *http.Response) (ShareClientChangeLeaseResponse, error) { result := ShareClientChangeLeaseResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -369,7 +370,7 @@ func (client *ShareClient) createCreateRequest(ctx context.Context, options *Sha func (client *ShareClient) createHandleResponse(resp *http.Response) (ShareClientCreateResponse, error) { result := ShareClientCreateResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -507,7 +508,7 @@ func (client *ShareClient) createSnapshotHandleResponse(resp *http.Response) (Sh result.Snapshot = &val } if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -645,7 +646,7 @@ func (client *ShareClient) getAccessPolicyCreateRequest(ctx context.Context, opt func (client *ShareClient) getAccessPolicyHandleResponse(resp *http.Response) (ShareClientGetAccessPolicyResponse, error) { result := ShareClientGetAccessPolicyResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -792,7 +793,7 @@ func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (Sha } } if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -930,7 +931,7 @@ func (client *ShareClient) getStatisticsCreateRequest(ctx context.Context, optio func (client *ShareClient) getStatisticsHandleResponse(resp *http.Response) (ShareClientGetStatisticsResponse, error) { result := ShareClientGetStatisticsResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -1010,7 +1011,7 @@ func (client *ShareClient) releaseLeaseCreateRequest(ctx context.Context, leaseI func (client *ShareClient) releaseLeaseHandleResponse(resp *http.Response) (ShareClientReleaseLeaseResponse, error) { result := ShareClientReleaseLeaseResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -1090,7 +1091,7 @@ func (client *ShareClient) renewLeaseCreateRequest(ctx context.Context, leaseID func (client *ShareClient) renewLeaseHandleResponse(resp *http.Response) (ShareClientRenewLeaseResponse, error) { result := ShareClientRenewLeaseResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -1172,7 +1173,7 @@ func (client *ShareClient) restoreCreateRequest(ctx context.Context, options *Sh func (client *ShareClient) restoreHandleResponse(resp *http.Response) (ShareClientRestoreResponse, error) { result := ShareClientRestoreResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -1251,7 +1252,7 @@ func (client *ShareClient) setAccessPolicyCreateRequest(ctx context.Context, sha func (client *ShareClient) setAccessPolicyHandleResponse(resp *http.Response) (ShareClientSetAccessPolicyResponse, error) { result := ShareClientSetAccessPolicyResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -1329,7 +1330,7 @@ func (client *ShareClient) setMetadataCreateRequest(ctx context.Context, options func (client *ShareClient) setMetadataHandleResponse(resp *http.Response) (ShareClientSetMetadataResponse, error) { result := ShareClientSetMetadataResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) @@ -1409,7 +1410,7 @@ func (client *ShareClient) setPropertiesCreateRequest(ctx context.Context, optio func (client *ShareClient) setPropertiesHandleResponse(resp *http.Response) (ShareClientSetPropertiesResponse, error) { result := ShareClientSetPropertiesResponse{} if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("Last-Modified"); val != "" { lastModified, err := time.Parse(time.RFC1123, val) diff --git a/sdk/storage/azfile/lease/constants.go b/sdk/storage/azfile/lease/constants.go new file mode 100644 index 000000000000..3b384475deb0 --- /dev/null +++ b/sdk/storage/azfile/lease/constants.go @@ -0,0 +1,51 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package lease + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// DurationType - When a share is leased, specifies whether the lease is of infinite or fixed duration. +type DurationType = generated.LeaseDurationType + +const ( + DurationTypeInfinite DurationType = generated.LeaseDurationTypeInfinite + DurationTypeFixed DurationType = generated.LeaseDurationTypeFixed +) + +// PossibleDurationTypeValues returns the possible values for the DurationType const type. +func PossibleDurationTypeValues() []DurationType { + return generated.PossibleLeaseDurationTypeValues() +} + +// StateType - Lease state of the share. +type StateType = generated.LeaseStateType + +const ( + StateTypeAvailable StateType = generated.LeaseStateTypeAvailable + StateTypeLeased StateType = generated.LeaseStateTypeLeased + StateTypeExpired StateType = generated.LeaseStateTypeExpired + StateTypeBreaking StateType = generated.LeaseStateTypeBreaking + StateTypeBroken StateType = generated.LeaseStateTypeBroken +) + +// PossibleStateTypeValues returns the possible values for the StateType const type. +func PossibleStateTypeValues() []StateType { + return generated.PossibleLeaseStateTypeValues() +} + +// StatusType - The current lease status of the share. +type StatusType = generated.LeaseStatusType + +const ( + StatusTypeLocked StatusType = generated.LeaseStatusTypeLocked + StatusTypeUnlocked StatusType = generated.LeaseStatusTypeUnlocked +) + +// PossibleStatusTypeValues returns the possible values for the StatusType const type. +func PossibleStatusTypeValues() []StatusType { + return generated.PossibleLeaseStatusTypeValues() +} diff --git a/sdk/storage/azfile/lease/file_client.go b/sdk/storage/azfile/lease/file_client.go new file mode 100644 index 000000000000..aa2a0c4b366d --- /dev/null +++ b/sdk/storage/azfile/lease/file_client.go @@ -0,0 +1,69 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package lease + +import ( + "context" + "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/generated" +) + +// FileClient provides lease functionality for the underlying file client. +type FileClient struct { + fileClient *file.Client + leaseID *string +} + +// FileClientOptions contains the optional values when creating a FileClient. +type FileClientOptions struct { + // LeaseID contains a caller-provided lease ID. + LeaseID *string +} + +// NewFileClient creates a file lease client for the provided file client. +// - client - an instance of a file client +// - options - client options; pass nil to accept the default values +func NewFileClient(client *file.Client, options *FileClientOptions) (*FileClient, error) { + return nil, nil +} + +func (f *FileClient) generated() *generated.FileClient { + return base.InnerClient((*base.Client[generated.FileClient])(f.fileClient)) +} + +// LeaseID returns leaseID of the client. +func (f *FileClient) LeaseID() *string { + return f.leaseID +} + +// Acquire operation can be used to request a new lease. +// The lease duration must be between 15 and 60 seconds, or infinite (-1). +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/lease-file. +func (f *FileClient) Acquire(ctx context.Context, duration int32, options *FileAcquireOptions) (FileAcquireResponse, error) { + // TODO: update generated code to make duration as required parameter + return FileAcquireResponse{}, nil +} + +// Break operation can be used to break the lease, if the file has an active lease. Once a lease is broken, it cannot be renewed. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/lease-file. +func (f *FileClient) Break(ctx context.Context, options *FileBreakOptions) (FileBreakResponse, error) { + return FileBreakResponse{}, nil +} + +// Change operation can be used to change the lease ID of an active lease. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/lease-file. +func (f *FileClient) Change(ctx context.Context, leaseID string, proposedLeaseID string, options *FileChangeOptions) (FileChangeResponse, error) { + // TODO: update generated code to make proposedLeaseID as required parameter + return FileChangeResponse{}, nil +} + +// Release operation can be used to free the lease if it is no longer needed so that another client may immediately acquire a lease against the file. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/lease-file. +func (f *FileClient) Release(ctx context.Context, leaseID string, options *FileReleaseOptions) (FileReleaseResponse, error) { + return FileReleaseResponse{}, nil +} diff --git a/sdk/storage/azfile/lease/models.go b/sdk/storage/azfile/lease/models.go new file mode 100644 index 000000000000..38fcf798abda --- /dev/null +++ b/sdk/storage/azfile/lease/models.go @@ -0,0 +1,84 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package lease + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// AccessConditions contains optional parameters to access leased entity. +type AccessConditions = generated.LeaseAccessConditions + +// FileAcquireOptions contains the optional parameters for the FileClient.Acquire method. +type FileAcquireOptions struct { + // Proposed lease ID, in a GUID string format. + // The File service returns 400 (Invalid request) if the proposed lease ID is not in the correct format. + ProposedLeaseID *string +} + +// FileBreakOptions contains the optional parameters for the FileClient.Break method. +type FileBreakOptions struct { + // AccessConditions contains optional parameters to access leased entity. + AccessConditions *AccessConditions +} + +// FileChangeOptions contains the optional parameters for the FileClient.Change method. +type FileChangeOptions struct { + // placeholder for future options +} + +// FileReleaseOptions contains the optional parameters for the FileClient.Release method. +type FileReleaseOptions struct { + // placeholder for future options +} + +// --------------------------------------------------------------------------------------------------------------------- + +// ShareAcquireOptions contains the optional parameters for the ShareClient.Acquire method. +type ShareAcquireOptions struct { + // Proposed lease ID, in a GUID string format. + // The File service returns 400 (Invalid request) if the proposed lease ID is not in the correct format. + ProposedLeaseID *string + // TODO: Should snapshot be removed from the option bag + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Snapshot *string +} + +// ShareBreakOptions contains the optional parameters for the ShareClient.Break method. +type ShareBreakOptions struct { + // For a break operation, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. This + // break period is only used if it is shorter than the time remaining on the + // lease. If longer, the time remaining on the lease is used. A new lease will not be available before the break period has + // expired, but the lease may be held for longer than the break period. If this + // header does not appear with a break operation, a fixed-duration lease breaks after the remaining lease period elapses, + // and an infinite lease breaks immediately. + BreakPeriod *int32 + // TODO: Should snapshot be removed from the option bag + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Snapshot *string + // AccessConditions contains optional parameters to access leased entity. + AccessConditions *AccessConditions +} + +// ShareChangeOptions contains the optional parameters for the ShareClient.Change method. +type ShareChangeOptions struct { + // TODO: Should snapshot be removed from the option bag + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Snapshot *string +} + +// ShareReleaseOptions contains the optional parameters for the ShareClient.Release method. +type ShareReleaseOptions struct { + // TODO: Should snapshot be removed from the option bag + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Snapshot *string +} + +// ShareRenewOptions contains the optional parameters for the ShareClient.Renew method. +type ShareRenewOptions struct { + // TODO: Should snapshot be removed from the option bag + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Snapshot *string +} diff --git a/sdk/storage/azfile/lease/responses.go b/sdk/storage/azfile/lease/responses.go new file mode 100644 index 000000000000..23a5a1db3063 --- /dev/null +++ b/sdk/storage/azfile/lease/responses.go @@ -0,0 +1,36 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package lease + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// FileAcquireResponse contains the response from method FileClient.Acquire. +type FileAcquireResponse = generated.FileClientAcquireLeaseResponse + +// FileBreakResponse contains the response from method FileClient.Break. +type FileBreakResponse = generated.FileClientBreakLeaseResponse + +// FileChangeResponse contains the response from method FileClient.Change. +type FileChangeResponse = generated.FileClientChangeLeaseResponse + +// FileReleaseResponse contains the response from method FileClient.Release. +type FileReleaseResponse = generated.FileClientReleaseLeaseResponse + +// ShareAcquireResponse contains the response from method ShareClient.Acquire. +type ShareAcquireResponse = generated.ShareClientAcquireLeaseResponse + +// ShareBreakResponse contains the response from method ShareClient.Break. +type ShareBreakResponse = generated.ShareClientBreakLeaseResponse + +// ShareChangeResponse contains the response from method ShareClient.Change. +type ShareChangeResponse = generated.ShareClientChangeLeaseResponse + +// ShareReleaseResponse contains the response from method ShareClient.Release. +type ShareReleaseResponse = generated.ShareClientReleaseLeaseResponse + +// ShareRenewResponse contains the response from method ShareClient.Renew. +type ShareRenewResponse = generated.ShareClientRenewLeaseResponse diff --git a/sdk/storage/azfile/lease/share_client.go b/sdk/storage/azfile/lease/share_client.go new file mode 100644 index 000000000000..6b11c0da1582 --- /dev/null +++ b/sdk/storage/azfile/lease/share_client.go @@ -0,0 +1,75 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package lease + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/base" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/share" +) + +// ShareClient provides lease functionality for the underlying share client. +type ShareClient struct { + shareClient *share.Client + leaseID *string +} + +// ShareClientOptions contains the optional values when creating a ShareClient. +type ShareClientOptions struct { + // LeaseID contains a caller-provided lease ID. + LeaseID *string +} + +// NewShareClient creates a share lease client for the provided share client. +// - client - an instance of a share client +// - options - client options; pass nil to accept the default values +func NewShareClient(client *share.Client, options *ShareClientOptions) (*ShareClient, error) { + return nil, nil +} + +func (s *ShareClient) generated() *generated.ShareClient { + return base.InnerClient((*base.Client[generated.ShareClient])(s.shareClient)) +} + +// LeaseID returns leaseID of the client. +func (s *ShareClient) LeaseID() *string { + return s.leaseID +} + +// Acquire operation can be used to request a new lease. +// The lease duration must be between 15 and 60 seconds, or infinite (-1). +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/lease-share. +func (s *ShareClient) Acquire(ctx context.Context, duration int32, options *ShareAcquireOptions) (ShareAcquireResponse, error) { + // TODO: update generated code to make duration as required parameter + return ShareAcquireResponse{}, nil +} + +// Break operation can be used to break the lease, if the file share has an active lease. Once a lease is broken, it cannot be renewed. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/lease-share. +func (s *ShareClient) Break(ctx context.Context, options *ShareBreakOptions) (ShareBreakResponse, error) { + return ShareBreakResponse{}, nil +} + +// Change operation can be used to change the lease ID of an active lease. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/lease-share. +func (s *ShareClient) Change(ctx context.Context, leaseID string, proposedLeaseID string, options *ShareChangeOptions) (ShareChangeResponse, error) { + // TODO: update generated code to make proposedLeaseID as required parameter + return ShareChangeResponse{}, nil +} + +// Release operation can be used to free the lease if it is no longer needed so that another client may immediately acquire a lease against the file share. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/lease-share. +func (s *ShareClient) Release(ctx context.Context, leaseID string, options *ShareReleaseOptions) (ShareReleaseResponse, error) { + return ShareReleaseResponse{}, nil +} + +// Renew operation can be used to renew an existing lease. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/lease-share. +func (s *ShareClient) Renew(ctx context.Context, leaseID string, options *ShareRenewOptions) (ShareRenewResponse, error) { + return ShareRenewResponse{}, nil +} diff --git a/sdk/storage/azfile/service/client.go b/sdk/storage/azfile/service/client.go new file mode 100644 index 000000000000..5c3c3564e40f --- /dev/null +++ b/sdk/storage/azfile/service/client.go @@ -0,0 +1,123 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package service + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/base" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/share" +) + +// ClientOptions contains the optional parameters when creating a Client. +type ClientOptions struct { + azcore.ClientOptions +} + +// Client represents a URL to the Azure File Storage service allowing you to manipulate file shares. +type Client base.Client[generated.ServiceClient] + +// NewClient creates an instance of Client with the specified values. +// - serviceURL - the URL of the storage account e.g. https://.file.core.windows.net/ +// - cred - an Azure AD credential, typically obtained via the azidentity module +// - options - client options; pass nil to accept the default values +func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientWithNoCredential creates an instance of Client with the specified values. +// This is used to anonymously access a storage account or with a shared access signature (SAS) token. +// - serviceURL - the URL of the storage account e.g. https://.file.core.windows.net/? +// - options - client options; pass nil to accept the default values +func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientWithSharedKeyCredential creates an instance of Client with the specified values. +// - serviceURL - the URL of the storage account e.g. https://.file.core.windows.net/ +// - cred - a SharedKeyCredential created with the matching storage account and access key +// - options - client options; pass nil to accept the default values +func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientFromConnectionString creates an instance of Client with the specified values. +// - connectionString - a connection string for the desired storage account +// - options - client options; pass nil to accept the default values +func NewClientFromConnectionString(connectionString string, options *ClientOptions) (*Client, error) { + return nil, nil +} + +func (s *Client) generated() *generated.ServiceClient { + return base.InnerClient((*base.Client[generated.ServiceClient])(s)) +} + +func (s *Client) sharedKey() *SharedKeyCredential { + return base.SharedKey((*base.Client[generated.ServiceClient])(s)) +} + +// URL returns the URL endpoint used by the Client object. +func (s *Client) URL() string { + return "s.generated().Endpoint()" +} + +// NewShareClient creates a new share.Client object by concatenating shareName to the end of this Client's URL. +// The new share.Client uses the same request policy pipeline as the Client. +func (s *Client) NewShareClient(shareName string) *share.Client { + return nil +} + +// CreateShare is a lifecycle method to creates a new share under the specified account. +// If the share with the same name already exists, a ResourceExistsError will be raised. +// This method returns a client with which to interact with the newly created share. +// For more information see, https://learn.microsoft.com/en-us/rest/api/storageservices/create-share. +func (s *Client) CreateShare(ctx context.Context, shareName string, options *CreateShareOptions) (CreateShareResponse, error) { + shareClient := s.NewShareClient(shareName) + createShareResp, err := shareClient.Create(ctx, options) + return createShareResp, err +} + +// DeleteShare is a lifecycle method that marks the specified share for deletion. +// The share and any files contained within it are later deleted during garbage collection. +// If the share is not found, a ResourceNotFoundError will be raised. +// For more information see, https://learn.microsoft.com/en-us/rest/api/storageservices/delete-share. +func (s *Client) DeleteShare(ctx context.Context, shareName string, options *DeleteShareOptions) (DeleteShareResponse, error) { + shareClient := s.NewShareClient(shareName) + deleteShareResp, err := shareClient.Delete(ctx, options) + return deleteShareResp, err +} + +// RestoreShare restores soft-deleted share. +// Operation will only be successful if used within the specified number of days set in the delete retention policy. +// For more information see, https://learn.microsoft.com/en-us/rest/api/storageservices/restore-share. +func (s *Client) RestoreShare(ctx context.Context, deletedShareName string, deletedShareVersion string, options *RestoreShareOptions) (RestoreShareResponse, error) { + shareClient := s.NewShareClient(deletedShareName) + createShareResp, err := shareClient.Restore(ctx, deletedShareVersion, options) + return createShareResp, err +} + +// GetProperties operation gets the properties of a storage account's File service. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-file-service-properties. +func (s *Client) GetProperties(ctx context.Context, options *GetPropertiesOptions) (GetPropertiesResponse, error) { + opts := options.format() + resp, err := s.generated().GetProperties(ctx, opts) + return resp, err +} + +// SetProperties operation sets properties for a storage account's File service endpoint. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-file-service-properties. +func (s *Client) SetProperties(ctx context.Context, options *SetPropertiesOptions) (SetPropertiesResponse, error) { + return SetPropertiesResponse{}, nil +} + +// NewListSharesPager operation returns a pager of the shares under the specified account. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/list-shares +func (s *Client) NewListSharesPager(options *ListSharesOptions) *runtime.Pager[ListSharesSegmentResponse] { + return nil +} diff --git a/sdk/storage/azfile/service/constants.go b/sdk/storage/azfile/service/constants.go new file mode 100644 index 000000000000..a936067376b4 --- /dev/null +++ b/sdk/storage/azfile/service/constants.go @@ -0,0 +1,37 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package service + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// ListSharesIncludeType defines values for ListSharesIncludeType +type ListSharesIncludeType = generated.ListSharesIncludeType + +const ( + ListSharesIncludeTypeSnapshots ListSharesIncludeType = generated.ListSharesIncludeTypeSnapshots + ListSharesIncludeTypeMetadata ListSharesIncludeType = generated.ListSharesIncludeTypeMetadata + ListSharesIncludeTypeDeleted ListSharesIncludeType = generated.ListSharesIncludeTypeDeleted +) + +// PossibleListSharesIncludeTypeValues returns the possible values for the ListSharesIncludeType const type. +func PossibleListSharesIncludeTypeValues() []ListSharesIncludeType { + return generated.PossibleListSharesIncludeTypeValues() +} + +// ShareRootSquash defines values for the root squashing behavior on the share when NFS is enabled. If it's not specified, the default is NoRootSquash. +type ShareRootSquash = generated.ShareRootSquash + +const ( + RootSquashNoRootSquash ShareRootSquash = generated.ShareRootSquashNoRootSquash + RootSquashRootSquash ShareRootSquash = generated.ShareRootSquashRootSquash + RootSquashAllSquash ShareRootSquash = generated.ShareRootSquashAllSquash +) + +// PossibleShareRootSquashValues returns the possible values for the RootSquash const type. +func PossibleShareRootSquashValues() []ShareRootSquash { + return generated.PossibleShareRootSquashValues() +} diff --git a/sdk/storage/azfile/service/models.go b/sdk/storage/azfile/service/models.go new file mode 100644 index 000000000000..5d3412dbaa3e --- /dev/null +++ b/sdk/storage/azfile/service/models.go @@ -0,0 +1,101 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package service + +import ( + "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/share" +) + +// SharedKeyCredential contains an account's name and its primary or secondary key. +type SharedKeyCredential = exported.SharedKeyCredential + +// CreateShareOptions contains the optional parameters for the share.Client.Create method. +type CreateShareOptions = share.CreateOptions + +// DeleteShareOptions contains the optional parameters for the share.Client.Delete method. +type DeleteShareOptions = share.DeleteOptions + +// RestoreShareOptions contains the optional parameters for the share.Client.Restore method. +type RestoreShareOptions = share.RestoreOptions + +// --------------------------------------------------------------------------------------------------------------------- + +// GetPropertiesOptions provides set of options for Client.GetProperties +type GetPropertiesOptions struct { + // placeholder for future options +} + +func (o *GetPropertiesOptions) format() *generated.ServiceClientGetPropertiesOptions { + return nil +} + +// --------------------------------------------------------------------------------------------------------------------- + +// SetPropertiesOptions provides set of options for Client.SetProperties +type SetPropertiesOptions struct { + // The set of CORS rules. + CORS []*CORSRule + + // A summary of request statistics grouped by API in hourly aggregates for files. + HourMetrics *Metrics + + // A summary of request statistics grouped by API in minute aggregates for files. + MinuteMetrics *Metrics + + // Protocol settings + Protocol *ProtocolSettings +} + +// StorageServiceProperties - Storage service properties. +type StorageServiceProperties = generated.StorageServiceProperties + +// CORSRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in +// another domain. Web browsers implement a security restriction known as same-origin policy that +// prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin +// domain) to call APIs in another domain. +type CORSRule = generated.CORSRule + +// Metrics - Storage Analytics metrics for file service. +type Metrics = generated.Metrics + +// RetentionPolicy - The retention policy. +type RetentionPolicy = generated.RetentionPolicy + +// ProtocolSettings - Protocol settings +type ProtocolSettings = generated.ProtocolSettings + +// SMBSettings - Settings for SMB protocol. +type SMBSettings = generated.SMBSettings + +// SMBMultichannel - Settings for SMB multichannel +type SMBMultichannel = generated.SMBMultichannel + +// --------------------------------------------------------------------------------------------------------------------- + +// ListSharesOptions contains the optional parameters for the Client.NewListSharesPager method. +type ListSharesOptions struct { + // Include this parameter to specify one or more datasets to include in the responseBody. + Include []ListSharesIncludeType + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the responseBody body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater + // than 5,000, the server will return up to 5,000 items. + MaxResults *int32 + // Filters the results to return only entries whose name begins with the specified prefix. + Prefix *string +} + +// Share - A listed Azure Storage share item. +type Share = generated.Share + +// ShareProperties - Properties of a share. +type ShareProperties = generated.ShareProperties diff --git a/sdk/storage/azfile/service/responses.go b/sdk/storage/azfile/service/responses.go new file mode 100644 index 000000000000..fad91de63547 --- /dev/null +++ b/sdk/storage/azfile/service/responses.go @@ -0,0 +1,30 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package service + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// CreateShareResponse contains the response from method share.Client.Create. +type CreateShareResponse = generated.ShareClientCreateResponse + +// DeleteShareResponse contains the response from method share.Client.Delete. +type DeleteShareResponse = generated.ShareClientDeleteResponse + +// RestoreShareResponse contains the response from method share.Client.Restore. +type RestoreShareResponse = generated.ShareClientRestoreResponse + +// GetPropertiesResponse contains the response from method Client.GetProperties. +type GetPropertiesResponse = generated.ServiceClientGetPropertiesResponse + +// SetPropertiesResponse contains the response from method Client.SetProperties. +type SetPropertiesResponse = generated.ServiceClientSetPropertiesResponse + +// ListSharesSegmentResponse contains the response from method Client.NewListSharesPager. +type ListSharesSegmentResponse = generated.ServiceClientListSharesSegmentResponse + +// ListSharesResponse - An enumeration of shares. +type ListSharesResponse = generated.ListSharesResponse diff --git a/sdk/storage/azfile/share/client.go b/sdk/storage/azfile/share/client.go new file mode 100644 index 000000000000..9ccf095bdfd8 --- /dev/null +++ b/sdk/storage/azfile/share/client.go @@ -0,0 +1,160 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package share + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/directory" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/base" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" +) + +// ClientOptions contains the optional parameters when creating a Client. +type ClientOptions struct { + azcore.ClientOptions +} + +// Client represents a URL to the Azure Storage share allowing you to manipulate its directories and files. +type Client base.Client[generated.ShareClient] + +// NewClient creates an instance of Client with the specified values. +// - shareURL - the URL of the share e.g. https://.file.core.windows.net/share +// - cred - an Azure AD credential, typically obtained via the azidentity module +// - options - client options; pass nil to accept the default values +func NewClient(shareURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientWithNoCredential creates an instance of Client with the specified values. +// This is used to anonymously access a share or with a shared access signature (SAS) token. +// - shareURL - the URL of the share e.g. https://.file.core.windows.net/share? +// - options - client options; pass nil to accept the default values +func NewClientWithNoCredential(shareURL string, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientWithSharedKeyCredential creates an instance of Client with the specified values. +// - shareURL - the URL of the share e.g. https://.file.core.windows.net/share +// - cred - a SharedKeyCredential created with the matching share's storage account and access key +// - options - client options; pass nil to accept the default values +func NewClientWithSharedKeyCredential(shareURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error) { + return nil, nil +} + +// NewClientFromConnectionString creates an instance of Client with the specified values. +// - connectionString - a connection string for the desired storage account +// - shareName - the name of the share within the storage account +// - options - client options; pass nil to accept the default values +func NewClientFromConnectionString(connectionString string, shareName string, options *ClientOptions) (*Client, error) { + return nil, nil +} + +func (s *Client) generated() *generated.ShareClient { + return base.InnerClient((*base.Client[generated.ShareClient])(s)) +} + +func (s *Client) sharedKey() *SharedKeyCredential { + return base.SharedKey((*base.Client[generated.ShareClient])(s)) +} + +// URL returns the URL endpoint used by the Client object. +func (s *Client) URL() string { + return "s.generated().Endpoint()" +} + +// NewDirectoryClient creates a new directory.Client object by concatenating directoryName to the end of this Client's URL. +// The new directory.Client uses the same request policy pipeline as the Client. +func (s *Client) NewDirectoryClient(directoryName string) *directory.Client { + return nil +} + +// NewRootDirectoryClient creates a new directory.Client object using the Client's URL. +// The new directory.Client uses the same request policy pipeline as the Client. +func (s *Client) NewRootDirectoryClient() *directory.Client { + return nil +} + +// WithSnapshot creates a new Client object identical to the source but with the specified share snapshot timestamp. +// Pass "" to remove the snapshot returning a URL to the base share. +func (s *Client) WithSnapshot(shareSnapshot string) (*Client, error) { + return nil, nil +} + +// Create operation creates a new share within a storage account. If a share with the same name already exists, the operation fails. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/create-share. +func (s *Client) Create(ctx context.Context, options *CreateOptions) (CreateResponse, error) { + return CreateResponse{}, nil +} + +// Delete operation marks the specified share for deletion. The share and any files contained within it are later deleted during garbage collection. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/delete-share. +func (s *Client) Delete(ctx context.Context, options *DeleteOptions) (DeleteResponse, error) { + return DeleteResponse{}, nil +} + +// Restore operation restores a share that had previously been soft-deleted. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/restore-share. +func (s *Client) Restore(ctx context.Context, deletedShareVersion string, options *RestoreOptions) (RestoreResponse, error) { + return RestoreResponse{}, nil +} + +// GetProperties operation returns all user-defined metadata and system properties for the specified share or share snapshot. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-share-properties. +func (s *Client) GetProperties(ctx context.Context, options *GetPropertiesOptions) (GetPropertiesResponse, error) { + return GetPropertiesResponse{}, nil +} + +// SetProperties operation sets properties for the specified share. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-share-properties. +func (s *Client) SetProperties(ctx context.Context, options *SetPropertiesOptions) (SetPropertiesResponse, error) { + return SetPropertiesResponse{}, nil +} + +// CreateSnapshot operation creates a read-only snapshot of a share. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/snapshot-share. +func (s *Client) CreateSnapshot(ctx context.Context, options *CreateSnapshotOptions) (CreateSnapshotResponse, error) { + return CreateSnapshotResponse{}, nil +} + +// GetAccessPolicy operation returns information about stored access policies specified on the share. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-share-acl. +func (s *Client) GetAccessPolicy(ctx context.Context, o *GetAccessPolicyOptions) (GetAccessPolicyResponse, error) { + return GetAccessPolicyResponse{}, nil +} + +// SetAccessPolicy operation sets a stored access policy for use with shared access signatures. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-share-acl. +func (s *Client) SetAccessPolicy(ctx context.Context, o *SetAccessPolicyOptions) (SetAccessPolicyResponse, error) { + return SetAccessPolicyResponse{}, nil +} + +// CreatePermission operation creates a permission (a security descriptor) at the share level. +// The created security descriptor can be used for the files and directories in the share. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/create-permission. +func (s *Client) CreatePermission(ctx context.Context, sharePermission string, o *CreatePermissionOptions) (CreatePermissionResponse, error) { + return CreatePermissionResponse{}, nil +} + +// GetPermission operation gets the SDDL permission string from the service using a known permission key. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-permission. +func (s *Client) GetPermission(ctx context.Context, filePermissionKey string, o *GetPermissionOptions) (GetPermissionResponse, error) { + return GetPermissionResponse{}, nil +} + +// SetMetadata operation sets one or more user-defined name-value pairs for the specified share. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-share-metadata. +func (s *Client) SetMetadata(ctx context.Context, options *SetMetadataOptions) (SetMetadataResponse, error) { + return SetMetadataResponse{}, nil + +} + +// GetStatistics operation retrieves statistics related to the share. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-share-stats. +func (s *Client) GetStatistics(ctx context.Context, options *GetStatisticsOptions) (GetStatisticsResponse, error) { + return GetStatisticsResponse{}, nil +} diff --git a/sdk/storage/azfile/share/constants.go b/sdk/storage/azfile/share/constants.go new file mode 100644 index 000000000000..231ab9e27e09 --- /dev/null +++ b/sdk/storage/azfile/share/constants.go @@ -0,0 +1,50 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package share + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// AccessTier defines values for the access tier of the share. +type AccessTier = generated.ShareAccessTier + +const ( + AccessTierCool AccessTier = generated.ShareAccessTierCool + AccessTierHot AccessTier = generated.ShareAccessTierHot + AccessTierTransactionOptimized AccessTier = generated.ShareAccessTierTransactionOptimized +) + +// PossibleAccessTierValues returns the possible values for the AccessTier const type. +func PossibleAccessTierValues() []AccessTier { + return generated.PossibleShareAccessTierValues() +} + +// RootSquash defines values for the root squashing behavior on the share when NFS is enabled. If it's not specified, the default is NoRootSquash. +type RootSquash = generated.ShareRootSquash + +const ( + RootSquashNoRootSquash RootSquash = generated.ShareRootSquashNoRootSquash + RootSquashRootSquash RootSquash = generated.ShareRootSquashRootSquash + RootSquashAllSquash RootSquash = generated.ShareRootSquashAllSquash +) + +// PossibleRootSquashValues returns the possible values for the RootSquash const type. +func PossibleRootSquashValues() []RootSquash { + return generated.PossibleShareRootSquashValues() +} + +// DeleteSnapshotsOptionType defines values for DeleteSnapshotsOptionType +type DeleteSnapshotsOptionType = generated.DeleteSnapshotsOptionType + +const ( + DeleteSnapshotsOptionTypeInclude DeleteSnapshotsOptionType = generated.DeleteSnapshotsOptionTypeInclude + DeleteSnapshotsOptionTypeIncludeLeased DeleteSnapshotsOptionType = generated.DeleteSnapshotsOptionTypeIncludeLeased +) + +// PossibleDeleteSnapshotsOptionTypeValues returns the possible values for the DeleteSnapshotsOptionType const type. +func PossibleDeleteSnapshotsOptionTypeValues() []DeleteSnapshotsOptionType { + return generated.PossibleDeleteSnapshotsOptionTypeValues() +} diff --git a/sdk/storage/azfile/share/models.go b/sdk/storage/azfile/share/models.go new file mode 100644 index 000000000000..792f73e5caac --- /dev/null +++ b/sdk/storage/azfile/share/models.go @@ -0,0 +1,149 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package share + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" +) + +// SharedKeyCredential contains an account's name and its primary or secondary key. +type SharedKeyCredential = exported.SharedKeyCredential + +// --------------------------------------------------------------------------------------------------------------------- + +// CreateOptions contains the optional parameters for the Client.Create method. +type CreateOptions struct { + // Specifies the access tier of the share. + AccessTier *AccessTier + // Protocols to enable on the share. + EnabledProtocols *string + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + // Specifies the maximum size of the share, in gigabytes. + Quota *int32 + // Root squash to set on the share. Only valid for NFS shares. + RootSquash *RootSquash +} + +// --------------------------------------------------------------------------------------------------------------------- + +// DeleteOptions contains the optional parameters for the Client.Delete method. +type DeleteOptions struct { + // Specifies the option include to delete the base share and all of its snapshots. + DeleteSnapshots *DeleteSnapshotsOptionType + // TODO: Should snapshot be removed from the option bag + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Snapshot *string + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// LeaseAccessConditions contains optional parameters to access leased entity. +type LeaseAccessConditions = generated.LeaseAccessConditions + +// --------------------------------------------------------------------------------------------------------------------- + +// RestoreOptions contains the optional parameters for the Client.Restore method. +type RestoreOptions struct { + // placeholder for future options +} + +// --------------------------------------------------------------------------------------------------------------------- + +// GetPropertiesOptions contains the optional parameters for the Client.GetProperties method. +type GetPropertiesOptions struct { + // TODO: Should snapshot be removed from the option bag + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Snapshot *string + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// SetPropertiesOptions contains the optional parameters for the Client.SetProperties method. +type SetPropertiesOptions struct { + // Specifies the access tier of the share. + AccessTier *AccessTier + // Specifies the maximum size of the share, in gigabytes. + Quota *int32 + // Root squash to set on the share. Only valid for NFS shares. + RootSquash *RootSquash + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// CreateSnapshotOptions contains the optional parameters for the Client.CreateSnapshot method. +type CreateSnapshotOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string +} + +// --------------------------------------------------------------------------------------------------------------------- + +// GetAccessPolicyOptions contains the optional parameters for the Client.GetAccessPolicy method. +type GetAccessPolicyOptions struct { + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// SignedIdentifier - Signed identifier. +type SignedIdentifier = generated.SignedIdentifier + +// AccessPolicy - An Access policy. +type AccessPolicy = generated.AccessPolicy + +// --------------------------------------------------------------------------------------------------------------------- + +// SetAccessPolicyOptions contains the optional parameters for the Client.SetAccessPolicy method. +type SetAccessPolicyOptions struct { + // Specifies the ACL for the share. + ShareACL []*SignedIdentifier + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// CreatePermissionOptions contains the optional parameters for the Client.CreatePermission method. +type CreatePermissionOptions struct { + // placeholder for future options +} + +// Permission - A permission (a security descriptor) at the share level. +type Permission = generated.SharePermission + +// --------------------------------------------------------------------------------------------------------------------- + +// GetPermissionOptions contains the optional parameters for the Client.GetPermission method. +type GetPermissionOptions struct { + // placeholder for future options +} + +// --------------------------------------------------------------------------------------------------------------------- + +// SetMetadataOptions contains the optional parameters for the Client.SetMetadata method. +type SetMetadataOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// --------------------------------------------------------------------------------------------------------------------- + +// GetStatisticsOptions contains the optional parameters for the Client.GetStatistics method. +type GetStatisticsOptions struct { + // LeaseAccessConditions contains optional parameters to access leased entity. + LeaseAccessConditions *LeaseAccessConditions +} + +// Stats - Stats for the share. +type Stats = generated.ShareStats diff --git a/sdk/storage/azfile/share/responses.go b/sdk/storage/azfile/share/responses.go new file mode 100644 index 000000000000..2932e7ec93a9 --- /dev/null +++ b/sdk/storage/azfile/share/responses.go @@ -0,0 +1,45 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package share + +import "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + +// CreateResponse contains the response from method Client.Create. +type CreateResponse = generated.ShareClientCreateResponse + +// DeleteResponse contains the response from method Client.Delete. +type DeleteResponse = generated.ShareClientDeleteResponse + +// RestoreResponse contains the response from method Client.Restore. +type RestoreResponse = generated.ShareClientRestoreResponse + +// GetPropertiesResponse contains the response from method Client.GetProperties. +type GetPropertiesResponse = generated.ShareClientGetPropertiesResponse + +// SetPropertiesResponse contains the response from method Client.SetProperties. +type SetPropertiesResponse = generated.ShareClientSetPropertiesResponse + +// CreateSnapshotResponse contains the response from method Client.CreateSnapshot. +type CreateSnapshotResponse = generated.ShareClientCreateSnapshotResponse + +// GetAccessPolicyResponse contains the response from method Client.GetAccessPolicy. +type GetAccessPolicyResponse = generated.ShareClientGetAccessPolicyResponse + +// SetAccessPolicyResponse contains the response from method Client.SetAccessPolicy. +type SetAccessPolicyResponse = generated.ShareClientSetAccessPolicyResponse + +// CreatePermissionResponse contains the response from method Client.CreatePermission. +type CreatePermissionResponse = generated.ShareClientCreatePermissionResponse + +// GetPermissionResponse contains the response from method Client.GetPermission. +type GetPermissionResponse = generated.ShareClientGetPermissionResponse + +// SetMetadataResponse contains the response from method Client.SetMetadata. +type SetMetadataResponse = generated.ShareClientSetMetadataResponse + +// GetStatisticsResponse contains the response from method Client.GetStatistics. +type GetStatisticsResponse = generated.ShareClientGetStatisticsResponse