diff --git a/sdk/storage/azblob/appendblob/client.go b/sdk/storage/azblob/appendblob/client.go index ef8e2e85a068..a62abfdc0c21 100644 --- a/sdk/storage/azblob/appendblob/client.go +++ b/sdk/storage/azblob/appendblob/client.go @@ -40,7 +40,7 @@ func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptio conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.AppendBlobClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -55,7 +55,7 @@ func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptio func NewClientWithNoCredential(blobURL string, options *ClientOptions) (*Client, error) { conOptions := shared.GetClientOptions(options) - azClient, err := azcore.NewClient(shared.AppendBlobClient, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -72,7 +72,7 @@ func NewClientWithSharedKeyCredential(blobURL string, cred *blob.SharedKeyCreden conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.AppendBlobClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } diff --git a/sdk/storage/azblob/blob/client.go b/sdk/storage/azblob/blob/client.go index 23955a828f72..5b3cf5544550 100644 --- a/sdk/storage/azblob/blob/client.go +++ b/sdk/storage/azblob/blob/client.go @@ -41,7 +41,7 @@ func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptio conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.BlobClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -55,7 +55,7 @@ func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptio func NewClientWithNoCredential(blobURL string, options *ClientOptions) (*Client, error) { conOptions := shared.GetClientOptions(options) - azClient, err := azcore.NewClient(shared.BlobClient, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -71,7 +71,7 @@ func NewClientWithSharedKeyCredential(blobURL string, cred *SharedKeyCredential, conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.BlobClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } diff --git a/sdk/storage/azblob/blockblob/client.go b/sdk/storage/azblob/blockblob/client.go index b69c4d490d6d..1e8da9e32546 100644 --- a/sdk/storage/azblob/blockblob/client.go +++ b/sdk/storage/azblob/blockblob/client.go @@ -50,7 +50,7 @@ func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptio conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.BlockBlobClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -64,7 +64,7 @@ func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptio func NewClientWithNoCredential(blobURL string, options *ClientOptions) (*Client, error) { conOptions := shared.GetClientOptions(options) - azClient, err := azcore.NewClient(shared.BlockBlobClient, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -81,7 +81,7 @@ func NewClientWithSharedKeyCredential(blobURL string, cred *blob.SharedKeyCreden conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.BlockBlobClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } diff --git a/sdk/storage/azblob/container/client.go b/sdk/storage/azblob/container/client.go index 0086a81920dd..b23798cb1f66 100644 --- a/sdk/storage/azblob/container/client.go +++ b/sdk/storage/azblob/container/client.go @@ -47,7 +47,7 @@ func NewClient(containerURL string, cred azcore.TokenCredential, options *Client conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.ContainerClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -61,7 +61,7 @@ func NewClient(containerURL string, cred azcore.TokenCredential, options *Client func NewClientWithNoCredential(containerURL string, options *ClientOptions) (*Client, error) { conOptions := shared.GetClientOptions(options) - azClient, err := azcore.NewClient(shared.ContainerClient, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -77,7 +77,7 @@ func NewClientWithSharedKeyCredential(containerURL string, cred *SharedKeyCreden conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.ContainerClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -138,7 +138,7 @@ func (c *Client) URL() string { func (c *Client) NewBlobClient(blobName string) *blob.Client { blobName = url.PathEscape(blobName) blobURL := runtime.JoinPaths(c.URL(), blobName) - return (*blob.Client)(base.NewBlobClient(blobURL, c.generated().InternalClient().WithClientName(shared.BlobClient), c.credential(), c.getClientOptions())) + return (*blob.Client)(base.NewBlobClient(blobURL, c.generated().InternalClient().WithClientName(exported.ModuleName), c.credential(), c.getClientOptions())) } // NewAppendBlobClient creates a new appendblob.Client object by concatenating blobName to the end of @@ -147,7 +147,7 @@ func (c *Client) NewBlobClient(blobName string) *blob.Client { func (c *Client) NewAppendBlobClient(blobName string) *appendblob.Client { blobName = url.PathEscape(blobName) blobURL := runtime.JoinPaths(c.URL(), blobName) - return (*appendblob.Client)(base.NewAppendBlobClient(blobURL, c.generated().InternalClient().WithClientName(shared.AppendBlobClient), c.sharedKey())) + return (*appendblob.Client)(base.NewAppendBlobClient(blobURL, c.generated().InternalClient().WithClientName(exported.ModuleName), c.sharedKey())) } // NewBlockBlobClient creates a new blockblob.Client object by concatenating blobName to the end of @@ -156,7 +156,7 @@ func (c *Client) NewAppendBlobClient(blobName string) *appendblob.Client { func (c *Client) NewBlockBlobClient(blobName string) *blockblob.Client { blobName = url.PathEscape(blobName) blobURL := runtime.JoinPaths(c.URL(), blobName) - return (*blockblob.Client)(base.NewBlockBlobClient(blobURL, c.generated().InternalClient().WithClientName(shared.BlockBlobClient), c.sharedKey())) + return (*blockblob.Client)(base.NewBlockBlobClient(blobURL, c.generated().InternalClient().WithClientName(exported.ModuleName), c.sharedKey())) } // NewPageBlobClient creates a new pageblob.Client object by concatenating blobName to the end of @@ -165,7 +165,7 @@ func (c *Client) NewBlockBlobClient(blobName string) *blockblob.Client { func (c *Client) NewPageBlobClient(blobName string) *pageblob.Client { blobName = url.PathEscape(blobName) blobURL := runtime.JoinPaths(c.URL(), blobName) - return (*pageblob.Client)(base.NewPageBlobClient(blobURL, c.generated().InternalClient().WithClientName(shared.PageBlobClient), c.sharedKey())) + return (*pageblob.Client)(base.NewPageBlobClient(blobURL, c.generated().InternalClient().WithClientName(exported.ModuleName), c.sharedKey())) } // Create creates a new container within a storage account. If a container with the same name already exists, the operation fails. diff --git a/sdk/storage/azblob/internal/exported/version.go b/sdk/storage/azblob/internal/exported/version.go index b8b34739239f..7129ef760873 100644 --- a/sdk/storage/azblob/internal/exported/version.go +++ b/sdk/storage/azblob/internal/exported/version.go @@ -7,6 +7,6 @@ package exported const ( - ModuleName = "azblob" + ModuleName = "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" ModuleVersion = "v1.3.0-beta.2" ) diff --git a/sdk/storage/azblob/internal/shared/shared.go b/sdk/storage/azblob/internal/shared/shared.go index c131facf7b7f..c7922076f3cf 100644 --- a/sdk/storage/azblob/internal/shared/shared.go +++ b/sdk/storage/azblob/internal/shared/shared.go @@ -44,15 +44,6 @@ const ( const crc64Polynomial uint64 = 0x9A6C9329AC4BC9B5 -const ( - AppendBlobClient = "azblob/appendblob.Client" - BlobClient = "azblob/blob.Client" - BlockBlobClient = "azblob/blockblob.Client" - ContainerClient = "azblob/container.Client" - PageBlobClient = "azblob/pageblob.Client" - ServiceClient = "azblob/service.Client" -) - var CRC64Table = crc64.MakeTable(crc64Polynomial) // CopyOptions returns a zero-value T if opts is nil. diff --git a/sdk/storage/azblob/pageblob/client.go b/sdk/storage/azblob/pageblob/client.go index 1d62487c9104..ca196f2c8b4c 100644 --- a/sdk/storage/azblob/pageblob/client.go +++ b/sdk/storage/azblob/pageblob/client.go @@ -41,7 +41,7 @@ func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptio conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.PageBlobClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -55,7 +55,7 @@ func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptio func NewClientWithNoCredential(blobURL string, options *ClientOptions) (*Client, error) { conOptions := shared.GetClientOptions(options) - azClient, err := azcore.NewClient(shared.PageBlobClient, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -71,7 +71,7 @@ func NewClientWithSharedKeyCredential(blobURL string, cred *blob.SharedKeyCreden conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.PageBlobClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } diff --git a/sdk/storage/azblob/service/client.go b/sdk/storage/azblob/service/client.go index bcd10a4be864..ccf4159c240f 100644 --- a/sdk/storage/azblob/service/client.go +++ b/sdk/storage/azblob/service/client.go @@ -45,7 +45,7 @@ func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOp conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -59,7 +59,7 @@ func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOp func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Client, error) { conOptions := shared.GetClientOptions(options) - azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -75,7 +75,7 @@ func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredenti conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} - azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -150,7 +150,7 @@ func (s *Client) URL() string { // this Client's URL. The new container.Client uses the same request policy pipeline as the Client. func (s *Client) NewContainerClient(containerName string) *container.Client { containerURL := runtime.JoinPaths(s.generated().Endpoint(), containerName) - return (*container.Client)(base.NewContainerClient(containerURL, s.generated().InternalClient().WithClientName(shared.ContainerClient), s.credential(), s.getClientOptions())) + return (*container.Client)(base.NewContainerClient(containerURL, s.generated().InternalClient().WithClientName(exported.ModuleName), s.credential(), s.getClientOptions())) } // CreateContainer is a lifecycle method to creates a new container under the specified account. diff --git a/sdk/storage/azblob/service/client_test.go b/sdk/storage/azblob/service/client_test.go index bac044016dbf..f99716b4b30f 100644 --- a/sdk/storage/azblob/service/client_test.go +++ b/sdk/storage/azblob/service/client_test.go @@ -9,7 +9,9 @@ package service_test import ( "context" "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "io" + "net/http" "os" "strings" "testing" @@ -314,6 +316,41 @@ func (s *ServiceRecordedTestsSuite) TestSetPropertiesSetCORSMultiple() { _require.NoError(err) } +type userAgentTest struct{} + +func (u userAgentTest) Do(req *policy.Request) (*http.Response, error) { + const userAgentHeader = "User-Agent" + + currentUserAgentHeader := req.Raw().Header.Get(userAgentHeader) + if !strings.HasPrefix(currentUserAgentHeader, "azsdk-go-azblob/"+exported.ModuleVersion) { + return nil, fmt.Errorf(currentUserAgentHeader + " user agent doesn't match expected agent: azsdk-go-azdatalake/v1.2.0 (go1.19.3; Windows_NT)") + } + + return &http.Response{ + Request: req.Raw(), + Status: "Created", + StatusCode: http.StatusOK, + Header: http.Header{}, + Body: http.NoBody, + }, nil +} + +func newTelemetryTestPolicy() policy.Policy { + return &userAgentTest{} +} + +func TestUserAgentForAzBlob(t *testing.T) { + client, err := service.NewClientWithNoCredential("https://fake/blob/testpath", &service.ClientOptions{ + ClientOptions: policy.ClientOptions{ + PerCallPolicies: []policy.Policy{newTelemetryTestPolicy()}, + }, + }) + require.NoError(t, err) + _, err = client.GetProperties(context.Background(), nil) + require.NoError(t, err) + require.NotNil(t, client) +} + func (s *ServiceUnrecordedTestsSuite) TestListContainersBasicUsingConnectionString() { _require := require.New(s.T()) testName := s.T().Name() diff --git a/sdk/storage/azdatalake/directory/client.go b/sdk/storage/azdatalake/directory/client.go index 483a3608bff5..2d9dfe6dfa9d 100644 --- a/sdk/storage/azdatalake/directory/client.go +++ b/sdk/storage/azdatalake/directory/client.go @@ -49,7 +49,7 @@ func NewClient(directoryURL string, cred azcore.TokenCredential, options *Client } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -82,7 +82,7 @@ func NewClientWithNoCredential(directoryURL string, options *ClientOptions) (*Cl plOpts := runtime.PipelineOptions{} base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -119,7 +119,7 @@ func NewClientWithSharedKeyCredential(directoryURL string, cred *SharedKeyCreden } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -225,7 +225,7 @@ func (d *Client) NewFileClient(fileName string) (*file.Client, error) { if err != nil { return nil, exported.ConvertToDFSError(err) } - return (*file.Client)(base.NewPathClient(fileURL, newBlobURL, newBlobClient, d.generatedDirClientWithDFS().InternalClient().WithClientName(shared.FileClient), d.sharedKey(), d.identityCredential(), d.getClientOptions())), nil + return (*file.Client)(base.NewPathClient(fileURL, newBlobURL, newBlobClient, d.generatedDirClientWithDFS().InternalClient().WithClientName(exported.ModuleName), d.sharedKey(), d.identityCredential(), d.getClientOptions())), nil } // NewSubdirectoryClient creates a new directory.Client object by concatenating subdirectoryName to the end of this Client's URL. @@ -248,7 +248,7 @@ func (d *Client) NewSubdirectoryClient(subdirectoryName string) (*Client, error) if err != nil { return nil, exported.ConvertToDFSError(err) } - return (*Client)(base.NewPathClient(subDirectoryURL, newBlobURL, newBlobClient, d.generatedDirClientWithDFS().InternalClient().WithClientName(shared.DirectoryClient), d.sharedKey(), d.identityCredential(), d.getClientOptions())), nil + return (*Client)(base.NewPathClient(subDirectoryURL, newBlobURL, newBlobClient, d.generatedDirClientWithDFS().InternalClient().WithClientName(exported.ModuleName), d.sharedKey(), d.identityCredential(), d.getClientOptions())), nil } // Create creates a new directory. @@ -332,7 +332,7 @@ func (d *Client) Rename(ctx context.Context, destinationPath string, options *Re if err != nil { return RenameResponse{}, exported.ConvertToDFSError(err) } - newDirClient := (*Client)(base.NewPathClient(newPathURL, newBlobURL, newBlobClient, d.generatedDirClientWithDFS().InternalClient().WithClientName(shared.DirectoryClient), d.sharedKey(), d.identityCredential(), d.getClientOptions())) + newDirClient := (*Client)(base.NewPathClient(newPathURL, newBlobURL, newBlobClient, d.generatedDirClientWithDFS().InternalClient().WithClientName(exported.ModuleName), d.sharedKey(), d.identityCredential(), d.getClientOptions())) resp, err := newDirClient.generatedDirClientWithDFS().Create(ctx, createOpts, nil, lac, mac, smac, cpkOpts) //return RenameResponse{ // Response: resp, diff --git a/sdk/storage/azdatalake/file/client.go b/sdk/storage/azdatalake/file/client.go index be8c5a3ec84f..75dbd8fccbfb 100644 --- a/sdk/storage/azdatalake/file/client.go +++ b/sdk/storage/azdatalake/file/client.go @@ -55,7 +55,7 @@ func NewClient(fileURL string, cred azcore.TokenCredential, options *ClientOptio } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.FileClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -88,7 +88,7 @@ func NewClientWithNoCredential(fileURL string, options *ClientOptions) (*Client, plOpts := runtime.PipelineOptions{} base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.FileClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -124,7 +124,7 @@ func NewClientWithSharedKeyCredential(fileURL string, cred *SharedKeyCredential, } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.FileClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -292,7 +292,7 @@ func (f *Client) Rename(ctx context.Context, destinationPath string, options *Re if err != nil { return RenameResponse{}, exported.ConvertToDFSError(err) } - newFileClient := (*Client)(base.NewPathClient(newPathURL, newBlobURL, newBlobClient, f.generatedFileClientWithDFS().InternalClient().WithClientName(shared.FileClient), f.sharedKey(), f.identityCredential(), f.getClientOptions())) + newFileClient := (*Client)(base.NewPathClient(newPathURL, newBlobURL, newBlobClient, f.generatedFileClientWithDFS().InternalClient().WithClientName(exported.ModuleName), f.sharedKey(), f.identityCredential(), f.getClientOptions())) resp, err := newFileClient.generatedFileClientWithDFS().Create(ctx, createOpts, nil, lac, mac, smac, cpkOpts) //return RenameResponse{ diff --git a/sdk/storage/azdatalake/file/client_test.go b/sdk/storage/azdatalake/file/client_test.go index cf738b6587f2..df39e72cfe3a 100644 --- a/sdk/storage/azdatalake/file/client_test.go +++ b/sdk/storage/azdatalake/file/client_test.go @@ -11,6 +11,9 @@ import ( "context" "crypto/md5" "encoding/binary" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/exported" "github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/service" "hash/crc64" "io" @@ -18,6 +21,7 @@ import ( "net/http" "os" "strconv" + "strings" "testing" "time" @@ -82,12 +86,46 @@ type UnrecordedTestSuite struct { suite.Suite } -//func validateFileDeleted(_require *require.Assertions, fileClient *file.Client) { -// _, err := fileClient.GetAccessControl(context.Background(), nil) -// _require.Error(err) +// func validateFileDeleted(_require *require.Assertions, fileClient *file.Client) { +// _, err := fileClient.GetAccessControl(context.Background(), nil) +// _require.Error(err) // -// testcommon.ValidateErrorCode(_require, err, datalakeerror.PathNotFound) -//} +// testcommon.ValidateErrorCode(_require, err, datalakeerror.PathNotFound) +// } +type userAgentTest struct{} + +func (u userAgentTest) Do(req *policy.Request) (*http.Response, error) { + const userAgentHeader = "User-Agent" + + currentUserAgentHeader := req.Raw().Header.Get(userAgentHeader) + if !strings.HasPrefix(currentUserAgentHeader, "azsdk-go-azdatalake/"+exported.ModuleVersion) { + return nil, fmt.Errorf(currentUserAgentHeader + " user agent doesn't match expected agent: azsdk-go-azdatalake/vx.xx.xx") + } + + return &http.Response{ + Request: req.Raw(), + Status: "Created", + StatusCode: http.StatusCreated, + Header: http.Header{}, + Body: http.NoBody, + }, nil +} + +func newTelemetryTestPolicy() policy.Policy { + return &userAgentTest{} +} + +func TestUserAgentForAzDatalake(t *testing.T) { + client, err := file.NewClientWithNoCredential("https://fake/blob/testpath", &file.ClientOptions{ + ClientOptions: policy.ClientOptions{ + PerCallPolicies: []policy.Policy{newTelemetryTestPolicy()}, + }, + }) + require.NoError(t, err) + _, err = client.Create(context.Background(), nil) + require.NoError(t, err) + require.NotNil(t, client) +} func (s *UnrecordedTestSuite) TestCreateFileAndDeleteWithConnectionString() { diff --git a/sdk/storage/azdatalake/filesystem/client.go b/sdk/storage/azdatalake/filesystem/client.go index d25f09130fe3..b69f14ba29eb 100644 --- a/sdk/storage/azdatalake/filesystem/client.go +++ b/sdk/storage/azdatalake/filesystem/client.go @@ -47,7 +47,7 @@ func NewClient(filesystemURL string, cred azcore.TokenCredential, options *Clien } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.FileSystemClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -79,7 +79,7 @@ func NewClientWithNoCredential(filesystemURL string, options *ClientOptions) (*C plOpts := runtime.PipelineOptions{} base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.FileSystemClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -114,7 +114,7 @@ func NewClientWithSharedKeyCredential(filesystemURL string, cred *SharedKeyCrede } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.FileSystemClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -204,7 +204,7 @@ func (fs *Client) NewDirectoryClient(directoryPath string) *directory.Client { directoryPath = strings.ReplaceAll(directoryPath, "\\", "/") dirURL := runtime.JoinPaths(fs.generatedFSClientWithDFS().Endpoint(), directoryPath) blobURL, dirURL := shared.GetURLs(dirURL) - return (*directory.Client)(base.NewPathClient(dirURL, blobURL, fs.containerClient().NewBlockBlobClient(directoryPath), fs.generatedFSClientWithDFS().InternalClient().WithClientName(shared.DirectoryClient), fs.sharedKey(), fs.identityCredential(), fs.getClientOptions())) + return (*directory.Client)(base.NewPathClient(dirURL, blobURL, fs.containerClient().NewBlockBlobClient(directoryPath), fs.generatedFSClientWithDFS().InternalClient().WithClientName(exported.ModuleName), fs.sharedKey(), fs.identityCredential(), fs.getClientOptions())) } // NewFileClient creates a new file.Client object by concatenating file path to the end of this Client's URL. @@ -213,7 +213,7 @@ func (fs *Client) NewFileClient(filePath string) *file.Client { filePath = strings.ReplaceAll(filePath, "\\", "/") fileURL := runtime.JoinPaths(fs.generatedFSClientWithDFS().Endpoint(), filePath) blobURL, fileURL := shared.GetURLs(fileURL) - return (*file.Client)(base.NewPathClient(fileURL, blobURL, fs.containerClient().NewBlockBlobClient(filePath), fs.generatedFSClientWithDFS().InternalClient().WithClientName(shared.FileClient), fs.sharedKey(), fs.identityCredential(), fs.getClientOptions())) + return (*file.Client)(base.NewPathClient(fileURL, blobURL, fs.containerClient().NewBlockBlobClient(filePath), fs.generatedFSClientWithDFS().InternalClient().WithClientName(exported.ModuleName), fs.sharedKey(), fs.identityCredential(), fs.getClientOptions())) } // Create creates a new filesystem under the specified account. diff --git a/sdk/storage/azdatalake/internal/exported/version.go b/sdk/storage/azdatalake/internal/exported/version.go index 32327f6a66be..0cd579fed1d7 100644 --- a/sdk/storage/azdatalake/internal/exported/version.go +++ b/sdk/storage/azdatalake/internal/exported/version.go @@ -7,6 +7,6 @@ package exported const ( - ModuleName = "azdatalake" + ModuleName = "github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake" ModuleVersion = "v1.1.0-beta.2" ) diff --git a/sdk/storage/azdatalake/internal/shared/shared.go b/sdk/storage/azdatalake/internal/shared/shared.go index f6ae4ea2fe66..d26008a79adb 100644 --- a/sdk/storage/azdatalake/internal/shared/shared.go +++ b/sdk/storage/azdatalake/internal/shared/shared.go @@ -24,13 +24,6 @@ const ( TokenScope = "https://storage.azure.com/.default" ) -const ( - ServiceClient = "azdatalake/service.Client" - FileSystemClient = "azdatalake/filesystem.Client" - DirectoryClient = "azdatalake/directory.Client" - FileClient = "azdatalake/file.Client" -) - const ( HeaderAuthorization = "Authorization" HeaderXmsDate = "x-ms-date" diff --git a/sdk/storage/azdatalake/service/client.go b/sdk/storage/azdatalake/service/client.go index c641ad0b3324..327871cb4f56 100644 --- a/sdk/storage/azdatalake/service/client.go +++ b/sdk/storage/azdatalake/service/client.go @@ -46,7 +46,7 @@ func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOp } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -77,7 +77,7 @@ func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Clie plOpts := runtime.PipelineOptions{} base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -112,7 +112,7 @@ func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredenti } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -167,7 +167,7 @@ func (s *Client) getClientOptions() *base.ClientOptions { func (s *Client) NewFileSystemClient(filesystemName string) *filesystem.Client { filesystemURL := runtime.JoinPaths(s.generatedServiceClientWithDFS().Endpoint(), filesystemName) containerURL, filesystemURL := shared.GetURLs(filesystemURL) - return (*filesystem.Client)(base.NewFileSystemClient(filesystemURL, containerURL, s.serviceClient().NewContainerClient(filesystemName), s.generatedServiceClientWithDFS().InternalClient().WithClientName(shared.FileSystemClient), s.sharedKey(), s.identityCredential(), s.getClientOptions())) + return (*filesystem.Client)(base.NewFileSystemClient(filesystemURL, containerURL, s.serviceClient().NewContainerClient(filesystemName), s.generatedServiceClientWithDFS().InternalClient().WithClientName(exported.ModuleName), s.sharedKey(), s.identityCredential(), s.getClientOptions())) } // GetUserDelegationCredential obtains a UserDelegationKey object using the base ServiceURL object. diff --git a/sdk/storage/azfile/directory/client.go b/sdk/storage/azfile/directory/client.go index dc90bf7d8fd6..40d3d44ad978 100644 --- a/sdk/storage/azfile/directory/client.go +++ b/sdk/storage/azfile/directory/client.go @@ -44,7 +44,7 @@ func NewClient(directoryURL string, cred azcore.TokenCredential, options *Client } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -61,7 +61,7 @@ func NewClientWithNoCredential(directoryURL string, options *ClientOptions) (*Cl plOpts := runtime.PipelineOptions{} base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -81,7 +81,7 @@ func NewClientWithSharedKeyCredential(directoryURL string, cred *SharedKeyCreden } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -144,7 +144,7 @@ func (d *Client) NewSubdirectoryClient(subDirectoryName string) *Client { func (d *Client) NewFileClient(fileName string) *file.Client { fileName = url.PathEscape(fileName) fileURL := runtime.JoinPaths(d.URL(), fileName) - return (*file.Client)(base.NewFileClient(fileURL, d.generated().InternalClient().WithClientName(shared.FileClient), d.sharedKey(), d.getClientOptions())) + return (*file.Client)(base.NewFileClient(fileURL, d.generated().InternalClient().WithClientName(exported.ModuleName), d.sharedKey(), d.getClientOptions())) } // Create operation creates a new directory under the specified share or parent directory. diff --git a/sdk/storage/azfile/file/client.go b/sdk/storage/azfile/file/client.go index fc712327fc73..d6a560e99a59 100644 --- a/sdk/storage/azfile/file/client.go +++ b/sdk/storage/azfile/file/client.go @@ -49,7 +49,7 @@ func NewClient(fileURL string, cred azcore.TokenCredential, options *ClientOptio } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.FileClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -68,7 +68,7 @@ func NewClientWithNoCredential(fileURL string, options *ClientOptions) (*Client, plOpts := runtime.PipelineOptions{} base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.FileClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -90,7 +90,7 @@ func NewClientWithSharedKeyCredential(fileURL string, cred *SharedKeyCredential, } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.FileClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } diff --git a/sdk/storage/azfile/internal/exported/version.go b/sdk/storage/azfile/internal/exported/version.go index bc0ddccee738..ce0369e2e97b 100644 --- a/sdk/storage/azfile/internal/exported/version.go +++ b/sdk/storage/azfile/internal/exported/version.go @@ -7,6 +7,6 @@ package exported const ( - ModuleName = "azfile" + ModuleName = "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile" ModuleVersion = "v1.2.0-beta.2" ) diff --git a/sdk/storage/azfile/internal/shared/shared.go b/sdk/storage/azfile/internal/shared/shared.go index 4b8140f68556..0b819c28ea5a 100644 --- a/sdk/storage/azfile/internal/shared/shared.go +++ b/sdk/storage/azfile/internal/shared/shared.go @@ -62,13 +62,6 @@ const ( FileAttributesDirectory = "Directory" ) -const ( - ServiceClient = "azfile/service.Client" - ShareClient = "azfile/share.Client" - DirectoryClient = "azfile/directory.Client" - FileClient = "azfile/file.Client" -) - func GetClientOptions[T any](o *T) *T { if o == nil { return new(T) diff --git a/sdk/storage/azfile/service/client.go b/sdk/storage/azfile/service/client.go index 1fd1f819313e..a122774f1cce 100644 --- a/sdk/storage/azfile/service/client.go +++ b/sdk/storage/azfile/service/client.go @@ -46,7 +46,7 @@ func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOp } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -63,7 +63,7 @@ func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Clie plOpts := runtime.PipelineOptions{} base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -83,7 +83,7 @@ func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredenti } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.ServiceClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -132,7 +132,7 @@ func (s *Client) URL() string { // The new share.Client uses the same request policy pipeline as the Client. func (s *Client) NewShareClient(shareName string) *share.Client { shareURL := runtime.JoinPaths(s.generated().Endpoint(), shareName) - return (*share.Client)(base.NewShareClient(shareURL, s.generated().InternalClient().WithClientName(shared.ShareClient), s.sharedKey(), s.getClientOptions())) + return (*share.Client)(base.NewShareClient(shareURL, s.generated().InternalClient().WithClientName(exported.ModuleName), s.sharedKey(), s.getClientOptions())) } // CreateShare is a lifecycle method to creates a new share under the specified account. diff --git a/sdk/storage/azfile/service/client_test.go b/sdk/storage/azfile/service/client_test.go index 61061fcbb121..da7b4ae7c334 100644 --- a/sdk/storage/azfile/service/client_test.go +++ b/sdk/storage/azfile/service/client_test.go @@ -9,16 +9,20 @@ package service_test import ( "context" "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/fileerror" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/testcommon" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/sas" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/service" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/share" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "net/http" "strconv" + "strings" "testing" "time" ) @@ -181,6 +185,42 @@ func (s *ServiceRecordedTestsSuite) TestAccountHourMetrics() { _require.NoError(err) } +type userAgentTest struct{} + +func (u userAgentTest) Do(req *policy.Request) (*http.Response, error) { + const userAgentHeader = "User-Agent" + + currentUserAgentHeader := req.Raw().Header.Get(userAgentHeader) + if !strings.HasPrefix(currentUserAgentHeader, "azsdk-go-azfile/"+exported.ModuleVersion) { + return nil, fmt.Errorf(currentUserAgentHeader + " user agent doesn't match expected agent: azsdk-go-azfile/vx.xx.x") + } + + return &http.Response{ + Request: req.Raw(), + Status: "Created", + StatusCode: http.StatusOK, + Header: http.Header{}, + Body: http.NoBody, + }, nil +} + +func newTelemetryTestPolicy() policy.Policy { + return &userAgentTest{} +} + +func TestUserAgentForAzFile(t *testing.T) { + client, err := service.NewClientWithNoCredential("https://fake/blob/testpath", &service.ClientOptions{ + ClientOptions: policy.ClientOptions{ + PerCallPolicies: []policy.Policy{newTelemetryTestPolicy()}, + }, + }) + require.NoError(t, err) + + _, err = client.GetProperties(context.Background(), nil) + require.NoError(t, err) + require.NotNil(t, client) +} + func (s *ServiceRecordedTestsSuite) TestAccountListSharesNonDefault() { _require := require.New(s.T()) testName := s.T().Name() diff --git a/sdk/storage/azfile/share/client.go b/sdk/storage/azfile/share/client.go index db30b3f48c16..01e4ca2543d7 100644 --- a/sdk/storage/azfile/share/client.go +++ b/sdk/storage/azfile/share/client.go @@ -45,7 +45,7 @@ func NewClient(shareURL string, cred azcore.TokenCredential, options *ClientOpti } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.ShareClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -62,7 +62,7 @@ func NewClientWithNoCredential(shareURL string, options *ClientOptions) (*Client plOpts := runtime.PipelineOptions{} base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.ShareClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -82,7 +82,7 @@ func NewClientWithSharedKeyCredential(shareURL string, cred *SharedKeyCredential } base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts) - azClient, err := azcore.NewClient(shared.ShareClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) + azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions) if err != nil { return nil, err } @@ -134,14 +134,14 @@ func (s *Client) URL() string { func (s *Client) NewDirectoryClient(directoryName string) *directory.Client { directoryName = url.PathEscape(strings.TrimRight(directoryName, "/")) directoryURL := runtime.JoinPaths(s.URL(), directoryName) - return (*directory.Client)(base.NewDirectoryClient(directoryURL, s.generated().InternalClient().WithClientName(shared.DirectoryClient), s.sharedKey(), s.getClientOptions())) + return (*directory.Client)(base.NewDirectoryClient(directoryURL, s.generated().InternalClient().WithClientName(exported.ModuleName), s.sharedKey(), s.getClientOptions())) } // NewRootDirectoryClient creates a new directory.Client object for the root of the share using the Client's URL. // The new directory.Client uses the same request policy pipeline as the Client. func (s *Client) NewRootDirectoryClient() *directory.Client { rootDirURL := s.URL() - return (*directory.Client)(base.NewDirectoryClient(rootDirURL, s.generated().InternalClient().WithClientName(shared.DirectoryClient), s.sharedKey(), s.getClientOptions())) + return (*directory.Client)(base.NewDirectoryClient(rootDirURL, s.generated().InternalClient().WithClientName(exported.ModuleName), s.sharedKey(), s.getClientOptions())) } // WithSnapshot creates a new Client object identical to the source but with the specified share snapshot timestamp.