Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API View for azfile #19873

Merged
merged 33 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9fba771
Init
souravgupta-msft Jan 4, 2023
62e45d0
Reformat code
souravgupta-msft Jan 5, 2023
0493788
Adding transforms
souravgupta-msft Jan 5, 2023
9ddaf65
Adding transforms
souravgupta-msft Jan 5, 2023
023f75a
Adding transforms
souravgupta-msft Jan 5, 2023
51235e4
Typo
souravgupta-msft Jan 5, 2023
340204f
Updating go version
souravgupta-msft Jan 6, 2023
264812d
Converting to time.Time
souravgupta-msft Jan 12, 2023
8967e3a
Adding service client
souravgupta-msft Jan 16, 2023
b6f6c3f
Updating autorest version
souravgupta-msft Jan 18, 2023
01c699d
Adding changelog and build.go files
souravgupta-msft Jan 18, 2023
c1a8c31
Merge branch 'sourav/auto-generation' of https://github.com/Azure/azu…
souravgupta-msft Jan 18, 2023
e111ae0
Adding methods in share client
souravgupta-msft Jan 18, 2023
5ad7696
Adding lease methods in share client
souravgupta-msft Jan 18, 2023
fb5c2c5
Pulling from feature branch
souravgupta-msft Jan 23, 2023
09adce6
changes in lease share methods
souravgupta-msft Jan 23, 2023
cc31841
Adding methods for directory client
souravgupta-msft Jan 24, 2023
dfa3679
Adding methods for file client
souravgupta-msft Jan 25, 2023
70a31a5
File client methods
souravgupta-msft Jan 27, 2023
0e12299
Format checks
souravgupta-msft Jan 27, 2023
e2c970c
Format checks
souravgupta-msft Jan 27, 2023
b660ce0
Changing type of Etag from *string to *azcore.Etag
souravgupta-msft Feb 1, 2023
2cf6002
Capitalise NTFS and SMB fields
souravgupta-msft Feb 1, 2023
b22ae02
Adding download methods same as azblob
souravgupta-msft Feb 2, 2023
7f715dd
Adding lease client
souravgupta-msft Feb 2, 2023
de69fe8
Capitalise SMB
souravgupta-msft Feb 2, 2023
d557aa3
Renaming the lease methods
souravgupta-msft Feb 9, 2023
0b73838
autorest transform - remove item suffix
souravgupta-msft Feb 13, 2023
65d93fd
Renaming FileID to ID and capitalising cors
souravgupta-msft Feb 13, 2023
734fe0e
Review comments
souravgupta-msft Feb 15, 2023
6f891f4
Service properties rename
souravgupta-msft Feb 15, 2023
a454119
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-go into…
souravgupta-msft Feb 17, 2023
de3a239
Merge branch 'feature/azfile' of https://github.com/Azure/azure-sdk-f…
souravgupta-msft Feb 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions sdk/storage/azfile/directory/client.go
Original file line number Diff line number Diff line change
@@ -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://<account>.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://<account>.file.core.windows.net/share/directory?<sas token>
// - 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://<account>.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
}
24 changes: 24 additions & 0 deletions sdk/storage/azfile/directory/constants.go
Original file line number Diff line number Diff line change
@@ -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()
}
97 changes: 97 additions & 0 deletions sdk/storage/azfile/directory/models.go
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions sdk/storage/azfile/directory/responses.go
Original file line number Diff line number Diff line change
@@ -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
Loading