Skip to content

Commit 47082af

Browse files
tasherif-msftjhendrixMSFTealsurrichardpark-msftazure-sdk
authored
[Datalake] Client Constructors (#21034)
* Enable gocritic during linting (#20715) Enabled gocritic's evalOrder to catch dependencies on undefined behavior on return statements. Updated to latest version of golangci-lint. Fixed issue in azblob flagged by latest linter. * Cosmos DB: Enable merge support (#20716) * Adding header and value * Wiring and tests * format * Fixing value * change log * [azservicebus, azeventhubs] Stress test and logging improvement (#20710) Logging improvements: * Updating the logging to print more tracing information (per-link) in prep for the bigger release coming up. * Trimming out some of the verbose logging, seeing if I can get it a bit more reasonable. Stress tests: * Add a timestamp to the log name we generate and also default to append, not overwrite. * Use 0.5 cores, 0.5GB as our baseline. Some pods use more and I'll tune them more later. * update proxy version (#20712) Co-authored-by: Scott Beddall <[email protected]> * Return an error when you try to send a message that's too large. (#20721) This now works just like the message batch - you'll get an ErrMessageTooLarge if you attempt to send a message that's too large for the link's configured size. NOTE: there's a patch to `internal/go-amqp/Sender.go` to match what's in go-amqp's main so it returns a programmatically useful error when the message is too large. Fixes #20647 * Changes in test that is failing in pipeline (#20693) * [azservicebus, azeventhubs] Treat 'entity full' as a fatal error (#20722) When the remote entity is full we get a resource-limit-exceeded condition. This isn't something we should keep retrying on and it's best to just abort and let the user know immediately, rather than hoping it might eventually clear out. This affected both Event Hubs and Service Bus. Fixes #20647 * [azservicebus/azeventhubs] Redirect stderr and stdout to tee (#20726) * Update changelog with latest features (#20730) * Update changelog with latest features Prepare for upcoming release. * bump minor version * pass along the artifact name so we can override it later (#20732) Co-authored-by: scbedd <[email protected]> * [azeventhubs] Fixing checkpoint store race condition (#20727) The checkpoint store wasn't guarding against multiple owners claiming for the first time - fixing this by using IfNoneMatch Fixes #20717 * Fix azidentity troubleshooting guide link (#20736) * [Release] sdk/resourcemanager/paloaltonetworksngfw/armpanngfw/0.1.0 (#20437) * [Release] sdk/resourcemanager/paloaltonetworksngfw/armpanngfw/0.1.0 generation from spec commit: 85fb4ac6f8bfefd179e6c2632976a154b5c9ff04 * client factory * fix * fix * update * add sdk/resourcemanager/postgresql/armpostgresql live test (#20685) * add sdk/resourcemanager/postgresql/armpostgresql live test * update assets.json * set subscriptionId default value * format * add sdk/resourcemanager/eventhub/armeventhub live test (#20686) * add sdk/resourcemanager/eventhub/armeventhub live test * update assets * add sdk/resourcemanager/compute/armcompute live test (#20048) * add sdk/resourcemanager/compute/armcompute live test * skus filter * fix subscriptionId default value * fix * gofmt * update recording * sdk/resourcemanager/network/armnetwork live test (#20331) * sdk/resourcemanager/network/armnetwork live test * update subscriptionId default value * update recording * add sdk/resourcemanager/cosmos/armcosmos live test (#20705) * add sdk/resourcemanager/cosmos/armcosmos live test * update assets.json * update assets.json * update assets.json * update assets.json * Increment package version after release of azcore (#20740) * [azeventhubs] Improperly resetting etag in the checkpoint store (#20737) We shouldn't be resetting the etag to nil - it's what we use to enforce a "single winner" when doing ownership claims. The bug here was two-fold: I had bad logic in my previous claim ownership, which I fixed in a previous PR, but we need to reflect that same constraint properly in our in-memory checkpoint store for these tests. * Eng workflows sync and branch cleanup additions (#20743) Co-authored-by: James Suplizio <[email protected]> * [azeventhubs] Latest start position can also be inclusive (ie, get the latest message) (#20744) * Update GitHubEventProcessor version and remove pull_request_review procesing (#20751) Co-authored-by: James Suplizio <[email protected]> * Rename DisableAuthorityValidationAndInstanceDiscovery (#20746) * fix (#20707) * AzFile (#20739) * azfile: Fixing connection string parsing logic (#20798) * Fixing connection string parse logic * Update README * [azadmin] fix flaky test (#20758) * fix flaky test * charles suggestion * Prepare azidentity v1.3.0 for release (#20756) * Fix broken podman link (#20801) Co-authored-by: Wes Haggard <[email protected]> * [azquery] update doc comments (#20755) * update doc comments * update statistics and visualization generation * prep-for-release * Fixed contribution section (#20752) Co-authored-by: Bob Tabor <[email protected]> * [azeventhubs,azservicebus] Some API cleanup, renames (#20754) * Adding options to UpdateCheckpoint(), just for future potential expansion * Make Offset an int64, not a *int64 (it's not optional, it'll always come back with ReceivedEvents) * Adding more logging into the checkpoint store. * Point all imports at the production go-amqp * Add supporting features to enable distributed tracing (#20301) (#20708) * Add supporting features to enable distributed tracing This includes new internal pipeline policies and other supporting types. See the changelog for a full description. Added some missing doc comments. * fix linter issue * add net.peer.name trace attribute sequence custom HTTP header policy before logging policy. sequence logging policy after HTTP trace policy. keep body download policy at the end. * add span for iterating over pages * Restore ARM CAE support for azcore beta (#20657) This reverts commit 9020972. * Upgrade to stable azcore (#20808) * Increment package version after release of data/azcosmos (#20807) * Updating changelog (#20810) * Add fake package to azcore (#20711) * Add fake package to azcore This is the supporting infrastructure for the generated SDK fakes. * fix doc comment * Updating CHANGELOG.md (#20809) * changelog (#20811) * Increment package version after release of storage/azfile (#20813) * Update changelog (azblob) (#20815) * Updating CHANGELOG.md * Update the changelog with correct version * [azquery] migration guide (#20742) * migration guide * Charles feedback * Richard feedback --------- Co-authored-by: Charles Lowell <[email protected]> * Increment package version after release of monitor/azquery (#20820) * [keyvault] prep for release (#20819) * prep for release * perf tests * update date * added sas support * small fix * query params fix * fix * added some tests * added more tests * resolved some comments * added encoding * added constructors * cleanup * cleanup * gmt * added all necessary builders * merge branch * removed path client --------- Co-authored-by: Joel Hendrix <[email protected]> Co-authored-by: Matias Quaranta <[email protected]> Co-authored-by: Richard Park <[email protected]> Co-authored-by: Azure SDK Bot <[email protected]> Co-authored-by: Scott Beddall <[email protected]> Co-authored-by: siminsavani-msft <[email protected]> Co-authored-by: scbedd <[email protected]> Co-authored-by: Charles Lowell <[email protected]> Co-authored-by: Peng Jiahui <[email protected]> Co-authored-by: James Suplizio <[email protected]> Co-authored-by: Sourav Gupta <[email protected]> Co-authored-by: gracewilcox <[email protected]> Co-authored-by: Wes Haggard <[email protected]> Co-authored-by: Bob Tabor <[email protected]> Co-authored-by: Bob Tabor <[email protected]>
1 parent c09de0b commit 47082af

File tree

21 files changed

+1058
-589
lines changed

21 files changed

+1058
-589
lines changed

sdk/storage/azdatalake/common.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@
77
package azdatalake
88

99
import (
10-
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
1110
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/generated"
1211
)
1312

14-
// ClientOptions contains the optional parameters when creating a Client.
15-
type ClientOptions struct {
16-
azcore.ClientOptions
17-
}
18-
1913
// AccessConditions identifies container-specific access conditions which you optionally set.
2014
type AccessConditions struct {
2115
ModifiedAccessConditions *ModifiedAccessConditions

sdk/storage/azdatalake/directory/client.go

Lines changed: 139 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,123 @@ package directory
99
import (
1010
"context"
1111
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
12-
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake"
13-
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/path"
12+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
13+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
14+
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
15+
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/base"
16+
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/exported"
17+
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/generated"
18+
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/shared"
19+
"strings"
1420
)
1521

16-
// Client represents a URL to the Azure Datalake Storage service allowing you to manipulate datalake directories.
17-
type Client struct {
18-
path.Client
19-
}
22+
// ClientOptions contains the optional parameters when creating a Client.
23+
type ClientOptions base.ClientOptions
2024

21-
// NewClient creates an instance of Client with the specified values.
22-
// - serviceURL - the URL of the storage account e.g. https://<account>.dfs.core.windows.net/
23-
// - cred - an Azure AD credential, typically obtained via the azidentity module
24-
// - options - client options; pass nil to accept the default values
25-
func NewClient(serviceURL string, cred azcore.TokenCredential, options *azdatalake.ClientOptions) (*Client, error) {
26-
return nil, nil
27-
}
25+
// Client represents a URL to the Azure Datalake Storage service.
26+
type Client base.CompositeClient[generated.PathClient, generated.PathClient, blob.Client]
27+
28+
//TODO: NewClient()
2829

2930
// NewClientWithNoCredential creates an instance of Client with the specified values.
3031
// This is used to anonymously access a storage account or with a shared access signature (SAS) token.
3132
// - serviceURL - the URL of the storage account e.g. https://<account>.dfs.core.windows.net/?<sas token>
3233
// - options - client options; pass nil to accept the default values
33-
func NewClientWithNoCredential(serviceURL string, options *azdatalake.ClientOptions) (*Client, error) {
34-
return nil, nil
34+
func NewClientWithNoCredential(directoryURL string, options *ClientOptions) (*Client, error) {
35+
blobURL := strings.Replace(directoryURL, ".dfs.", ".blob.", 1)
36+
directoryURL = strings.Replace(directoryURL, ".blob.", ".dfs.", 1)
37+
38+
conOptions := shared.GetClientOptions(options)
39+
plOpts := runtime.PipelineOptions{}
40+
base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts)
41+
42+
azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions)
43+
if err != nil {
44+
return nil, err
45+
}
46+
47+
blobClientOpts := blob.ClientOptions{
48+
ClientOptions: options.ClientOptions,
49+
}
50+
blobClient, _ := blob.NewClientWithNoCredential(blobURL, &blobClientOpts)
51+
dirClient := base.NewPathClient(directoryURL, blobURL, blobClient, azClient, nil, (*base.ClientOptions)(conOptions))
52+
53+
return (*Client)(dirClient), nil
3554
}
3655

3756
// NewClientWithSharedKeyCredential creates an instance of Client with the specified values.
3857
// - serviceURL - the URL of the storage account e.g. https://<account>.dfs.core.windows.net/
3958
// - cred - a SharedKeyCredential created with the matching storage account and access key
4059
// - options - client options; pass nil to accept the default values
41-
func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredential, options *azdatalake.ClientOptions) (*Client, error) {
42-
return nil, nil
60+
func NewClientWithSharedKeyCredential(directoryURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error) {
61+
blobURL := strings.Replace(directoryURL, ".dfs.", ".blob.", 1)
62+
directoryURL = strings.Replace(directoryURL, ".blob.", ".dfs.", 1)
63+
64+
authPolicy := exported.NewSharedKeyCredPolicy(cred)
65+
conOptions := shared.GetClientOptions(options)
66+
plOpts := runtime.PipelineOptions{
67+
PerRetry: []policy.Policy{authPolicy},
68+
}
69+
base.SetPipelineOptions((*base.ClientOptions)(conOptions), &plOpts)
70+
71+
azClient, err := azcore.NewClient(shared.DirectoryClient, exported.ModuleVersion, plOpts, &conOptions.ClientOptions)
72+
if err != nil {
73+
return nil, err
74+
}
75+
76+
blobClientOpts := blob.ClientOptions{
77+
ClientOptions: options.ClientOptions,
78+
}
79+
blobSharedKeyCredential, _ := blob.NewSharedKeyCredential(cred.AccountName(), cred.AccountKey())
80+
blobClient, _ := blob.NewClientWithSharedKeyCredential(blobURL, blobSharedKeyCredential, &blobClientOpts)
81+
dirClient := base.NewPathClient(directoryURL, blobURL, blobClient, azClient, nil, (*base.ClientOptions)(conOptions))
82+
83+
return (*Client)(dirClient), nil
4384
}
4485

4586
// NewClientFromConnectionString creates an instance of Client with the specified values.
4687
// - connectionString - a connection string for the desired storage account
4788
// - options - client options; pass nil to accept the default values
48-
func NewClientFromConnectionString(connectionString string, options *azdatalake.ClientOptions) (*Client, error) {
49-
return nil, nil
89+
func NewClientFromConnectionString(connectionString string, options *ClientOptions) (*Client, error) {
90+
parsed, err := shared.ParseConnectionString(connectionString)
91+
if err != nil {
92+
return nil, err
93+
}
94+
95+
if parsed.AccountKey != "" && parsed.AccountName != "" {
96+
credential, err := exported.NewSharedKeyCredential(parsed.AccountName, parsed.AccountKey)
97+
if err != nil {
98+
return nil, err
99+
}
100+
return NewClientWithSharedKeyCredential(parsed.ServiceURL, credential, options)
101+
}
102+
103+
return NewClientWithNoCredential(parsed.ServiceURL, options)
104+
}
105+
106+
func (d *Client) generatedFSClientWithDFS() *generated.PathClient {
107+
//base.SharedKeyComposite((*base.CompositeClient[generated.BlobClient, generated.BlockBlobClient])(bb))
108+
dirClientWithDFS, _, _ := base.InnerClients((*base.CompositeClient[generated.PathClient, generated.PathClient, blob.Client])(d))
109+
return dirClientWithDFS
110+
}
111+
112+
func (d *Client) generatedFSClientWithBlob() *generated.PathClient {
113+
_, dirClientWithBlob, _ := base.InnerClients((*base.CompositeClient[generated.PathClient, generated.PathClient, blob.Client])(d))
114+
return dirClientWithBlob
115+
}
116+
117+
func (d *Client) blobClient() *blob.Client {
118+
_, _, blobClient := base.InnerClients((*base.CompositeClient[generated.PathClient, generated.PathClient, blob.Client])(d))
119+
return blobClient
120+
}
121+
122+
func (d *Client) sharedKey() *exported.SharedKeyCredential {
123+
return base.SharedKeyComposite((*base.CompositeClient[generated.PathClient, generated.PathClient, blob.Client])(d))
124+
}
125+
126+
// URL returns the URL endpoint used by the Client object.
127+
func (d *Client) URL() string {
128+
return "s.generated().Endpoint()"
50129
}
51130

52131
// Create creates a new directory (dfs1).
@@ -70,3 +149,44 @@ func (d *Client) GetProperties(ctx context.Context, options *GetPropertiesOption
70149
func (d *Client) Rename(ctx context.Context, newName string, options *RenameOptions) (RenameResponse, error) {
71150
return RenameResponse{}, nil
72151
}
152+
153+
// SetAccessControl sets the owner, owning group, and permissions for a file or directory (dfs1).
154+
func (d *Client) SetAccessControl(ctx context.Context, options *SetAccessControlOptions) (SetAccessControlResponse, error) {
155+
return SetAccessControlResponse{}, nil
156+
}
157+
158+
// SetAccessControlRecursive sets the owner, owning group, and permissions for a file or directory (dfs1).
159+
func (d *Client) SetAccessControlRecursive(ctx context.Context, options *SetAccessControlRecursiveOptions) (SetAccessControlRecursiveResponse, error) {
160+
// TODO explicitly pass SetAccessControlRecursiveMode
161+
return SetAccessControlRecursiveResponse{}, nil
162+
}
163+
164+
// UpdateAccessControlRecursive updates the owner, owning group, and permissions for a file or directory (dfs1).
165+
func (d *Client) UpdateAccessControlRecursive(ctx context.Context, options *UpdateAccessControlRecursiveOptions) (UpdateAccessControlRecursiveResponse, error) {
166+
// TODO explicitly pass SetAccessControlRecursiveMode
167+
return SetAccessControlRecursiveResponse{}, nil
168+
}
169+
170+
// GetAccessControl gets the owner, owning group, and permissions for a file or directory (dfs1).
171+
func (d *Client) GetAccessControl(ctx context.Context, options *GetAccessControlOptions) (GetAccessControlResponse, error) {
172+
return GetAccessControlResponse{}, nil
173+
}
174+
175+
// RemoveAccessControlRecursive removes the owner, owning group, and permissions for a file or directory (dfs1).
176+
func (d *Client) RemoveAccessControlRecursive(ctx context.Context, options *RemoveAccessControlRecursiveOptions) (RemoveAccessControlRecursiveResponse, error) {
177+
// TODO explicitly pass SetAccessControlRecursiveMode
178+
return SetAccessControlRecursiveResponse{}, nil
179+
}
180+
181+
// SetMetadata sets the metadata for a file or directory (blob3).
182+
func (d *Client) SetMetadata(ctx context.Context, options *SetMetadataOptions) (SetMetadataResponse, error) {
183+
// TODO: call directly into blob
184+
return SetMetadataResponse{}, nil
185+
}
186+
187+
// SetHTTPHeaders sets the HTTP headers for a file or directory (blob3).
188+
func (d *Client) SetHTTPHeaders(ctx context.Context, httpHeaders HTTPHeaders, options *SetHTTPHeadersOptions) (SetHTTPHeadersResponse, error) {
189+
// TODO: call formatBlobHTTPHeaders() since we want to add the blob prefix to our options before calling into blob
190+
// TODO: call into blob
191+
return SetHTTPHeadersResponse{}, nil
192+
}

sdk/storage/azdatalake/directory/constants.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,37 @@
77
package directory
88

99
import (
10-
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/path"
10+
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
11+
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/generated"
1112
)
1213

13-
// RenameMode defines the rename mode for RenameDirectory
14-
type RenameMode = path.RenameMode
14+
type ResourceType = generated.PathResourceType
1515

16+
// TODO: consider the possibility of not exposing this and just pass it under the hood
1617
const (
17-
RenameModeLegacy RenameMode = path.RenameModeLegacy
18-
RenameModePosix RenameMode = path.RenameModePosix
18+
ResourceTypeFile ResourceType = generated.PathResourceTypeFile
19+
ResourceTypeDirectory ResourceType = generated.PathResourceTypeDirectory
1920
)
2021

21-
// SetAccessControlRecursiveMode defines the set access control recursive mode for SetAccessControlRecursive
22-
type SetAccessControlRecursiveMode = path.SetAccessControlRecursiveMode
22+
type RenameMode = generated.PathRenameMode
2323

24+
// TODO: consider the possibility of not exposing this and just pass it under the hood
2425
const (
25-
SetAccessControlRecursiveModeSet SetAccessControlRecursiveMode = path.SetAccessControlRecursiveModeSet
26-
SetAccessControlRecursiveModeModify SetAccessControlRecursiveMode = path.SetAccessControlRecursiveModeModify
27-
SetAccessControlRecursiveModeRemove SetAccessControlRecursiveMode = path.SetAccessControlRecursiveModeRemove
26+
RenameModeLegacy RenameMode = generated.PathRenameModeLegacy
27+
RenameModePosix RenameMode = generated.PathRenameModePosix
2828
)
2929

30-
type EncryptionAlgorithmType = path.EncryptionAlgorithmType
30+
type SetAccessControlRecursiveMode = generated.PathSetAccessControlRecursiveMode
3131

3232
const (
33-
EncryptionAlgorithmTypeNone EncryptionAlgorithmType = path.EncryptionAlgorithmTypeNone
34-
EncryptionAlgorithmTypeAES256 EncryptionAlgorithmType = path.EncryptionAlgorithmTypeAES256
33+
SetAccessControlRecursiveModeSet SetAccessControlRecursiveMode = generated.PathSetAccessControlRecursiveModeSet
34+
SetAccessControlRecursiveModeModify SetAccessControlRecursiveMode = generated.PathSetAccessControlRecursiveModeModify
35+
SetAccessControlRecursiveModeRemove SetAccessControlRecursiveMode = generated.PathSetAccessControlRecursiveModeRemove
36+
)
37+
38+
type EncryptionAlgorithmType = blob.EncryptionAlgorithmType
39+
40+
const (
41+
EncryptionAlgorithmTypeNone EncryptionAlgorithmType = blob.EncryptionAlgorithmTypeNone
42+
EncryptionAlgorithmTypeAES256 EncryptionAlgorithmType = blob.EncryptionAlgorithmTypeAES256
3543
)

0 commit comments

Comments
 (0)