Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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: 5 additions & 1 deletion sdk/azcore/runtime/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ func JoinPaths(root string, paths ...string) string {
}

if qps != "" {
p = p + "?" + qps
if strings.Contains(p, "?") {
p = p + "&" + qps
} else {
p = p + "?" + qps
}
}

if strings.HasSuffix(root, "/") && strings.HasPrefix(p, "/") {
Expand Down
55 changes: 9 additions & 46 deletions sdk/storage/azblob/appendblob/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptio
audience := base.GetAudience((*base.ClientOptions)(options))
conOptions := shared.GetClientOptions(options)
authPolicy := shared.NewStorageChallengePolicy(cred, audience, conOptions.InsecureAllowCredentialWithHTTP)
plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}}
plOpts := runtime.PipelineOptions{PerCall: []policy.Policy{&shared.RangePolicy{}}, PerRetry: []policy.Policy{authPolicy}}

azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions)
if err != nil {
Expand All @@ -52,7 +52,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(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions)
azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{PerCall: []policy.Policy{&shared.RangePolicy{}}}, &conOptions.ClientOptions)
if err != nil {
return nil, err
}
Expand All @@ -67,7 +67,7 @@ func NewClientWithNoCredential(blobURL string, options *ClientOptions) (*Client,
func NewClientWithSharedKeyCredential(blobURL string, cred *blob.SharedKeyCredential, options *ClientOptions) (*Client, error) {
authPolicy := exported.NewSharedKeyCredPolicy(cred)
conOptions := shared.GetClientOptions(options)
plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}}
plOpts := runtime.PipelineOptions{PerCall: []policy.Policy{&shared.RangePolicy{}}, PerRetry: []policy.Policy{authPolicy}}

azClient, err := azcore.NewClient(exported.ModuleName, exported.ModuleVersion, plOpts, &conOptions.ClientOptions)
if err != nil {
Expand Down Expand Up @@ -152,10 +152,7 @@ func (ab *Client) WithVersionID(versionID string) (*Client, error) {
// Create creates a 0-size append blob. Call AppendBlock to append data to an append blob.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-blob.
func (ab *Client) Create(ctx context.Context, o *CreateOptions) (CreateResponse, error) {
opts, httpHeaders, leaseAccessConditions, cpkInfo, cpkScopeInfo, modifiedAccessConditions := o.format()
resp, err := ab.generated().Create(ctx, 0, opts, httpHeaders, leaseAccessConditions, cpkInfo,
cpkScopeInfo, modifiedAccessConditions)
return resp, err
return ab.generated().Create(ctx, o.format())
}

// AppendBlock writes a stream to a new block of data to the end of the existing append blob.
Expand All @@ -168,63 +165,29 @@ func (ab *Client) AppendBlock(ctx context.Context, body io.ReadSeekCloser, o *Ap
return AppendBlockResponse{}, nil
}

appendOptions, appendPositionAccessConditions, cpkInfo, cpkScope, modifiedAccessConditions, leaseAccessConditions := o.format()
options := o.format()

if o != nil && o.TransactionalValidation != nil {
body, err = o.TransactionalValidation.Apply(body, appendOptions)
body, err = o.TransactionalValidation.Apply(body, options)
if err != nil {
return AppendBlockResponse{}, nil
}
}

resp, err := ab.generated().AppendBlock(ctx,
count,
body,
appendOptions,
leaseAccessConditions,
appendPositionAccessConditions,
cpkInfo,
cpkScope,
modifiedAccessConditions)

return resp, err
return ab.generated().AppendBlock(ctx, body, count, options)
}

// AppendBlockFromURL copies a new block of data from source URL to the end of the existing append blob.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/append-block-from-url.
func (ab *Client) AppendBlockFromURL(ctx context.Context, source string, o *AppendBlockFromURLOptions) (AppendBlockFromURLResponse, error) {
appendBlockFromURLOptions,
cpkInfo,
cpkScopeInfo,
leaseAccessConditions,
appendPositionAccessConditions,
modifiedAccessConditions,
sourceModifiedAccessConditions := o.format()

// content length should be 0 on * from URL. always. It's a 400 if it isn't.
resp, err := ab.generated().AppendBlockFromURL(ctx,
source,
0,
appendBlockFromURLOptions,
cpkInfo,
cpkScopeInfo,
leaseAccessConditions,
appendPositionAccessConditions,
modifiedAccessConditions,
sourceModifiedAccessConditions)
return resp, err
return ab.generated().AppendBlockFromURL(ctx, source, 0, o.format())
}

// Seal - The purpose of Append Blob Seal is to allow users and applications to seal append blobs, marking them as read only.
// https://docs.microsoft.com/en-us/rest/api/storageservices/append-blob-seal
func (ab *Client) Seal(ctx context.Context, o *SealOptions) (SealResponse, error) {
leaseAccessConditions, modifiedAccessConditions, positionAccessConditions := o.format()
resp, err := ab.generated().Seal(ctx,
nil,
leaseAccessConditions,
modifiedAccessConditions,
positionAccessConditions)
return resp, err
return ab.generated().Seal(ctx, o.format())
}

// Delete marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection.
Expand Down
20 changes: 10 additions & 10 deletions sdk/storage/azblob/appendblob/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2166,7 +2166,7 @@ func (s *AppendBlobUnrecordedTestsSuite) TestCreateAppendBlobWithTags() {
createResp, err := abClient.Create(context.Background(), &createAppendBlobOptions)
_require.NoError(err)
_require.NotNil(createResp.VersionID)
time.Sleep(10 * time.Second)
testcommon.Sleep(10 * time.Second)

_, err = abClient.GetProperties(context.Background(), nil)
_require.NoError(err)
Expand Down Expand Up @@ -2820,7 +2820,7 @@ func (s *AppendBlobRecordedTestsSuite) TestUndeleteAppendBlobVersion() {
}

// adding wait after delete
time.Sleep(time.Second * 10)
testcommon.Sleep(time.Second * 10)

listPager = containerClient.NewListBlobsFlatPager(&container.ListBlobsFlatOptions{
Include: container.ListBlobsInclude{Versions: true},
Expand All @@ -2831,7 +2831,7 @@ func (s *AppendBlobRecordedTestsSuite) TestUndeleteAppendBlobVersion() {
_require.NoError(err)

// adding wait after undelete
time.Sleep(time.Second * 10)
testcommon.Sleep(time.Second * 10)

listPager = containerClient.NewListBlobsFlatPager(&container.ListBlobsFlatOptions{
Include: container.ListBlobsInclude{Versions: true},
Expand Down Expand Up @@ -2877,7 +2877,7 @@ func (s *AppendBlobRecordedTestsSuite) TestUndeleteAppendBlobSnapshot() {
}

// adding wait after delete
time.Sleep(time.Second * 10)
testcommon.Sleep(time.Second * 10)

listPager = containerClient.NewListBlobsFlatPager(&container.ListBlobsFlatOptions{
Include: container.ListBlobsInclude{Snapshots: true},
Expand All @@ -2888,7 +2888,7 @@ func (s *AppendBlobRecordedTestsSuite) TestUndeleteAppendBlobSnapshot() {
_require.NoError(err)

// adding wait after undelete
time.Sleep(time.Second * 10)
testcommon.Sleep(time.Second * 10)

listPager = containerClient.NewListBlobsFlatPager(&container.ListBlobsFlatOptions{
Include: container.ListBlobsInclude{Snapshots: true},
Expand Down Expand Up @@ -2951,7 +2951,7 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendBlobSetExpiryRelativeToNow() {
_require.NoError(err)
_require.NotNil(resp.ExpiresOn)

time.Sleep(time.Second * 10)
testcommon.Sleep(time.Second * 10)

_, err = abClient.GetProperties(context.Background(), nil)
testcommon.ValidateBlobErrorCode(_require, err, bloberror.BlobNotFound)
Expand Down Expand Up @@ -2984,7 +2984,7 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendBlobSetExpiryRelativeToCreation
_require.NoError(err)
_require.NotNil(resp.ExpiresOn)

time.Sleep(time.Second * 10)
testcommon.Sleep(time.Second * 10)

_, err = abClient.GetProperties(context.Background(), nil)
testcommon.ValidateBlobErrorCode(_require, err, bloberror.BlobNotFound)
Expand Down Expand Up @@ -3019,7 +3019,7 @@ func (s *AppendBlobUnrecordedTestsSuite) TestAppendBlobSetExpiryToAbsolute() {
_require.NotNil(resp.ExpiresOn)
_require.Equal(expiryTimeAbsolute.UTC().Format(http.TimeFormat), resp.ExpiresOn.UTC().Format(http.TimeFormat))

time.Sleep(time.Second * 10)
testcommon.Sleep(time.Second * 10)

_, err = abClient.GetProperties(context.Background(), nil)
testcommon.ValidateBlobErrorCode(_require, err, bloberror.BlobNotFound)
Expand Down Expand Up @@ -3541,7 +3541,7 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendBlobSetBlobTags() {

_, err = abClient.SetTags(context.Background(), tagsMap, nil)
_require.NoError(err)
time.Sleep(10 * time.Second)
testcommon.Sleep(10 * time.Second)

blobGetTagsResponse, err := abClient.GetTags(context.Background(), nil)
_require.NoError(err)
Expand Down Expand Up @@ -3579,7 +3579,7 @@ func (s *AppendBlobUnrecordedTestsSuite) TestSetBlobTagsWithLeaseId() {

_, err = abClient.SetTags(ctx, testcommon.BasicBlobTagsMap, nil)
_require.Error(err)
time.Sleep(10 * time.Second)
testcommon.Sleep(10 * time.Second)

// add lease conditions
_, err = abClient.SetTags(ctx, testcommon.BasicBlobTagsMap, &blob.SetTagsOptions{AccessConditions: &blob.AccessConditions{
Expand Down
Loading