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

azfile: Service Client #20035

Merged
merged 47 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 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
ee4e518
adding internal package code
souravgupta-msft Feb 15, 2023
734fe0e
Review comments
souravgupta-msft Feb 15, 2023
604da07
Merge branch 'sourav/serviceClient' of https://github.com/Azure/azure…
souravgupta-msft Feb 15, 2023
6f891f4
Service properties rename
souravgupta-msft Feb 15, 2023
ed2407b
Merge branch 'sourav/serviceClient' of https://github.com/Azure/azure…
souravgupta-msft Feb 16, 2023
f4b2d3b
Adding list and set properties
souravgupta-msft Feb 16, 2023
88b392f
service client tests
souravgupta-msft Feb 16, 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
706b503
Merge branch 'sourav/serviceClient' of https://github.com/Azure/azure…
souravgupta-msft Feb 17, 2023
d997002
Adding error codes
souravgupta-msft Feb 17, 2023
da163c1
Merging from feature branch
souravgupta-msft Feb 17, 2023
226ef3b
removing container error code
souravgupta-msft Feb 20, 2023
58a7389
Removing client creation using OAuth
souravgupta-msft Feb 20, 2023
84d3a03
Adding assets.json
souravgupta-msft Feb 20, 2023
13a982c
Adding few recordings
souravgupta-msft Feb 20, 2023
d9edf3a
Few tests to unrecorded
souravgupta-msft Feb 20, 2023
752b838
Few lint error fixes
souravgupta-msft Feb 23, 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
6 changes: 6 additions & 0 deletions sdk/storage/azfile/assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/storage/azfile",
"Tag": "go/storage/azfile_33b8efd383"
}
10 changes: 1 addition & 9 deletions sdk/storage/azfile/directory/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ type ClientOptions struct {
// 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>
Expand Down Expand Up @@ -66,7 +58,7 @@ func (d *Client) sharedKey() *SharedKeyCredential {

// URL returns the URL endpoint used by the Client object.
func (d *Client) URL() string {
return "s.generated().Endpoint()"
return d.generated().Endpoint()
}

// NewSubdirectoryClient creates a new Client object by concatenating subDirectoryName to the end of this Client's URL.
Expand Down
14 changes: 3 additions & 11 deletions sdk/storage/azfile/file/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ type ClientOptions struct {
// 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://<account>.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://<account>.file.core.windows.net/share/directoryPath/file?<sas token>
Expand Down Expand Up @@ -67,7 +59,7 @@ func (f *Client) sharedKey() *SharedKeyCredential {

// URL returns the URL endpoint used by the Client object.
func (f *Client) URL() string {
return "s.generated().Endpoint()"
return f.generated().Endpoint()
}

// Create operation creates a new file or replaces a file. Note it only initializes the file with no content.
Expand Down Expand Up @@ -124,12 +116,12 @@ func (f *Client) DownloadStream(ctx context.Context, options *DownloadStreamOpti
return DownloadStreamResponse{}, nil
}

// DownloadBuffer downloads an Azure blob to a buffer with parallel.
// DownloadBuffer downloads an Azure file 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.
// DownloadFile downloads an Azure file 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
Expand Down
102 changes: 102 additions & 0 deletions sdk/storage/azfile/fileerror/error_codes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//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 fileerror

import (
"errors"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated"
)

// HasCode returns true if the provided error is an *azcore.ResponseError
// with its ErrorCode field equal to one of the specified Codes.
func HasCode(err error, codes ...Code) bool {
var respErr *azcore.ResponseError
if !errors.As(err, &respErr) {
return false
}

for _, code := range codes {
if respErr.ErrorCode == string(code) {
return true
}
}

return false
}

// Code - Error codes returned by the service
type Code = generated.StorageErrorCode

const (
AccountAlreadyExists Code = "AccountAlreadyExists"
AccountBeingCreated Code = "AccountBeingCreated"
AccountIsDisabled Code = "AccountIsDisabled"
AuthenticationFailed Code = "AuthenticationFailed"
AuthorizationFailure Code = "AuthorizationFailure"
AuthorizationPermissionMismatch Code = "AuthorizationPermissionMismatch"
AuthorizationProtocolMismatch Code = "AuthorizationProtocolMismatch"
AuthorizationResourceTypeMismatch Code = "AuthorizationResourceTypeMismatch"
AuthorizationServiceMismatch Code = "AuthorizationServiceMismatch"
AuthorizationSourceIPMismatch Code = "AuthorizationSourceIPMismatch"
CannotDeleteFileOrDirectory Code = "CannotDeleteFileOrDirectory"
ClientCacheFlushDelay Code = "ClientCacheFlushDelay"
ConditionHeadersNotSupported Code = "ConditionHeadersNotSupported"
ConditionNotMet Code = "ConditionNotMet"
DeletePending Code = "DeletePending"
DirectoryNotEmpty Code = "DirectoryNotEmpty"
EmptyMetadataKey Code = "EmptyMetadataKey"
FeatureVersionMismatch Code = "FeatureVersionMismatch"
FileLockConflict Code = "FileLockConflict"
InsufficientAccountPermissions Code = "InsufficientAccountPermissions"
InternalError Code = "InternalError"
InvalidAuthenticationInfo Code = "InvalidAuthenticationInfo"
InvalidFileOrDirectoryPathName Code = "InvalidFileOrDirectoryPathName"
InvalidHTTPVerb Code = "InvalidHttpVerb"
InvalidHeaderValue Code = "InvalidHeaderValue"
InvalidInput Code = "InvalidInput"
InvalidMD5 Code = "InvalidMd5"
InvalidMetadata Code = "InvalidMetadata"
InvalidQueryParameterValue Code = "InvalidQueryParameterValue"
InvalidRange Code = "InvalidRange"
InvalidResourceName Code = "InvalidResourceName"
InvalidURI Code = "InvalidUri"
InvalidXMLDocument Code = "InvalidXmlDocument"
InvalidXMLNodeValue Code = "InvalidXmlNodeValue"
MD5Mismatch Code = "Md5Mismatch"
MetadataTooLarge Code = "MetadataTooLarge"
MissingContentLengthHeader Code = "MissingContentLengthHeader"
MissingRequiredHeader Code = "MissingRequiredHeader"
MissingRequiredQueryParameter Code = "MissingRequiredQueryParameter"
MissingRequiredXMLNode Code = "MissingRequiredXmlNode"
MultipleConditionHeadersNotSupported Code = "MultipleConditionHeadersNotSupported"
OperationTimedOut Code = "OperationTimedOut"
OutOfRangeInput Code = "OutOfRangeInput"
OutOfRangeQueryParameterValue Code = "OutOfRangeQueryParameterValue"
ParentNotFound Code = "ParentNotFound"
ReadOnlyAttribute Code = "ReadOnlyAttribute"
RequestBodyTooLarge Code = "RequestBodyTooLarge"
RequestURLFailedToParse Code = "RequestUrlFailedToParse"
ResourceAlreadyExists Code = "ResourceAlreadyExists"
ResourceNotFound Code = "ResourceNotFound"
ResourceTypeMismatch Code = "ResourceTypeMismatch"
ServerBusy Code = "ServerBusy"
ShareAlreadyExists Code = "ShareAlreadyExists"
ShareBeingDeleted Code = "ShareBeingDeleted"
ShareDisabled Code = "ShareDisabled"
ShareHasSnapshots Code = "ShareHasSnapshots"
ShareNotFound Code = "ShareNotFound"
ShareSnapshotCountExceeded Code = "ShareSnapshotCountExceeded"
ShareSnapshotInProgress Code = "ShareSnapshotInProgress"
ShareSnapshotOperationNotSupported Code = "ShareSnapshotOperationNotSupported"
SharingViolation Code = "SharingViolation"
UnsupportedHTTPVerb Code = "UnsupportedHttpVerb"
UnsupportedHeader Code = "UnsupportedHeader"
UnsupportedQueryParameter Code = "UnsupportedQueryParameter"
UnsupportedXMLNode Code = "UnsupportedXmlNode"
)
12 changes: 10 additions & 2 deletions sdk/storage/azfile/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ module github.com/Azure/azure-sdk-for-go/sdk/storage/azfile

go 1.18

require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0
require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1
github.com/stretchr/testify v1.7.0
)

require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/dnaeon/go-vcr v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
13 changes: 13 additions & 0 deletions sdk/storage/azfile/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,23 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0/go.mod h1:tZoQYdDZNOiIjdSn0d
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1 h1:Oj853U9kG+RLTCQXpjvOnrv0WaZHxgmZz1TlLywgOPY=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c=
github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
30 changes: 30 additions & 0 deletions sdk/storage/azfile/internal/base/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
package base

import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated"
)

type Client[T any] struct {
Expand All @@ -22,3 +24,31 @@ func InnerClient[T any](client *Client[T]) *T {
func SharedKey[T any](client *Client[T]) *exported.SharedKeyCredential {
return client.sharedKey
}

func NewServiceClient(serviceURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.ServiceClient] {
return &Client[generated.ServiceClient]{
inner: generated.NewServiceClient(serviceURL, pipeline),
sharedKey: sharedKey,
}
}

func NewShareClient(shareURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.ShareClient] {
return &Client[generated.ShareClient]{
inner: generated.NewShareClient(shareURL, pipeline),
sharedKey: sharedKey,
}
}

func NewDirectoryClient(directoryURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.DirectoryClient] {
return &Client[generated.DirectoryClient]{
inner: generated.NewDirectoryClient(directoryURL, pipeline),
sharedKey: sharedKey,
}
}

func NewFileClient(fileURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.FileClient] {
return &Client[generated.FileClient]{
inner: generated.NewFileClient(fileURL, pipeline),
sharedKey: sharedKey,
}
}
Loading