From 42fa731866c452a62bf633975e35c0bed5fe9ab6 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Mon, 10 Jan 2022 08:39:34 -0800 Subject: [PATCH 1/2] Update azblob with the latest azcore This tactially resolves the small number of breaking changes in azcore. --- sdk/storage/azblob/CHANGELOG.md | 3 +- sdk/storage/azblob/go.mod | 4 +- sdk/storage/azblob/go.sum | 8 +- sdk/storage/azblob/zc_blob_lease_client.go | 1 + sdk/storage/azblob/zc_block_blob_client.go | 3 +- .../azblob/zc_container_lease_client.go | 1 + sdk/storage/azblob/zc_page_blob_client.go | 5 +- sdk/storage/azblob/zc_storage_error.go | 38 +- sdk/storage/azblob/zt_blob_client_test.go | 9 +- sdk/storage/azblob/zt_service_client_test.go | 2 +- sdk/storage/azblob/zt_test.go | 13 +- .../azblob/zz_generated_appendblob_client.go | 66 +--- .../azblob/zz_generated_blob_client.go | 370 ++---------------- .../azblob/zz_generated_blockblob_client.go | 81 +--- sdk/storage/azblob/zz_generated_connection.go | 4 +- sdk/storage/azblob/zz_generated_constants.go | 2 +- .../azblob/zz_generated_container_client.go | 226 +---------- .../azblob/zz_generated_directory_client.go | 81 +--- sdk/storage/azblob/zz_generated_models.go | 11 - .../azblob/zz_generated_pageblob_client.go | 141 +------ sdk/storage/azblob/zz_generated_pagers.go | 11 +- .../azblob/zz_generated_service_client.go | 125 +----- 22 files changed, 154 insertions(+), 1051 deletions(-) diff --git a/sdk/storage/azblob/CHANGELOG.md b/sdk/storage/azblob/CHANGELOG.md index 7069dfa0ded7..0350465e8e7d 100644 --- a/sdk/storage/azblob/CHANGELOG.md +++ b/sdk/storage/azblob/CHANGELOG.md @@ -1,10 +1,11 @@ # Release History -## 0.2.1 (Unreleased) +## 0.3.0 (Unreleased) ### Features Added ### Breaking Changes +* Updated to latest `azcore`. Public surface area is unchanged. ### Bugs Fixed diff --git a/sdk/storage/azblob/go.mod b/sdk/storage/azblob/go.mod index d09ac398018e..ecdd614d6545 100644 --- a/sdk/storage/azblob/go.mod +++ b/sdk/storage/azblob/go.mod @@ -3,8 +3,8 @@ module github.com/Azure/azure-sdk-for-go/sdk/storage/azblob go 1.16 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 - github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 + github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 github.com/davecgh/go-spew v1.1.1 // indirect github.com/dnaeon/go-vcr v1.2.0 // indirect github.com/stretchr/testify v1.7.0 diff --git a/sdk/storage/azblob/go.sum b/sdk/storage/azblob/go.sum index 73a1581eb220..a1431da8ba3b 100644 --- a/sdk/storage/azblob/go.sum +++ b/sdk/storage/azblob/go.sum @@ -1,7 +1,7 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 h1:8wVJL0HUP5yDFXvotdewORTw7Yu88JbreWN/mobSvsQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 h1:E+m3SkZCN0Bf5q7YdTs5lSm2CYY3CK4spn5OmUIiQtk= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/sdk/storage/azblob/zc_blob_lease_client.go b/sdk/storage/azblob/zc_blob_lease_client.go index 4b07d4aadc99..c9ac3ae45ceb 100644 --- a/sdk/storage/azblob/zc_blob_lease_client.go +++ b/sdk/storage/azblob/zc_blob_lease_client.go @@ -6,6 +6,7 @@ package azblob import ( "context" "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/uuid" ) diff --git a/sdk/storage/azblob/zc_block_blob_client.go b/sdk/storage/azblob/zc_block_blob_client.go index 8bcdb964ab0f..2160e51c6653 100644 --- a/sdk/storage/azblob/zc_block_blob_client.go +++ b/sdk/storage/azblob/zc_block_blob_client.go @@ -5,10 +5,11 @@ package azblob import ( "context" + "io" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "io" ) const ( diff --git a/sdk/storage/azblob/zc_container_lease_client.go b/sdk/storage/azblob/zc_container_lease_client.go index db66b004d17f..716d5e84c978 100644 --- a/sdk/storage/azblob/zc_container_lease_client.go +++ b/sdk/storage/azblob/zc_container_lease_client.go @@ -6,6 +6,7 @@ package azblob import ( "context" "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/uuid" ) diff --git a/sdk/storage/azblob/zc_page_blob_client.go b/sdk/storage/azblob/zc_page_blob_client.go index 4ff0ea9618ba..db79f887f58c 100644 --- a/sdk/storage/azblob/zc_page_blob_client.go +++ b/sdk/storage/azblob/zc_page_blob_client.go @@ -5,10 +5,11 @@ package azblob import ( "context" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "io" "net/url" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) const ( diff --git a/sdk/storage/azblob/zc_storage_error.go b/sdk/storage/azblob/zc_storage_error.go index 329f680ed3c0..f49a0944dff8 100644 --- a/sdk/storage/azblob/zc_storage_error.go +++ b/sdk/storage/azblob/zc_storage_error.go @@ -12,7 +12,9 @@ import ( "sort" "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) // InternalError is an internal error type that all errors get wrapped in. @@ -50,7 +52,6 @@ func (e *InternalError) As(target interface{}) bool { // TL;DR: This implements xml.Unmarshaler, and when the original StorageError is substituted, this unmarshaler kicks in. // This handles the description and details. defunkifyStorageError handles the response, cause, and service code. type StorageError struct { - raw string response *http.Response description string @@ -59,8 +60,9 @@ type StorageError struct { } func handleError(err error) error { - if err, ok := err.(ResponseError); ok { - return &InternalError{defunkifyStorageError(err)} + var respErr *azcore.ResponseError + if errors.As(err, &respErr) { + return &InternalError{defunkifyStorageError(respErr)} } if err != nil { @@ -71,22 +73,32 @@ func handleError(err error) error { } // defunkifyStorageError is a function that takes the "funky" ResponseError and reduces it to a storageError. -func defunkifyStorageError(responseError ResponseError) error { - if err, ok := responseError.Unwrap().(*StorageError); ok { - // errors.Unwrap(responseError.Unwrap()) +func defunkifyStorageError(responseError *azcore.ResponseError) error { + var storageError StorageError + body, err := runtime.Payload(responseError.RawResponse) + if err != nil { + goto Default + } + if len(body) > 0 { + if err := xml.Unmarshal(body, &storageError); err != nil { + goto Default + } + } - err.response = responseError.RawResponse() + // errors.Unwrap(responseError.Unwrap()) - err.ErrorCode = StorageErrorCode(responseError.RawResponse().Header.Get("x-ms-error-code")) + storageError.response = responseError.RawResponse - if code, ok := err.details["Code"]; ok { - err.ErrorCode = StorageErrorCode(code) - delete(err.details, "Code") - } + storageError.ErrorCode = StorageErrorCode(responseError.RawResponse.Header.Get("x-ms-error-code")) - return err + if code, ok := storageError.details["Code"]; ok { + storageError.ErrorCode = StorageErrorCode(code) + delete(storageError.details, "Code") } + return &storageError + +Default: return &InternalError{ cause: responseError, } diff --git a/sdk/storage/azblob/zt_blob_client_test.go b/sdk/storage/azblob/zt_blob_client_test.go index 6f38783193d0..945a4209f905 100644 --- a/sdk/storage/azblob/zt_blob_client_test.go +++ b/sdk/storage/azblob/zt_blob_client_test.go @@ -7,15 +7,16 @@ import ( "bytes" "crypto/md5" "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal" - "github.com/stretchr/testify/assert" "io" "io/ioutil" "net/url" "strconv" "strings" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal" + "github.com/stretchr/testify/assert" ) //nolint @@ -2099,7 +2100,7 @@ func validateBlobDeleted(_assert *assert.Assertions, bbClient BlobClient) { _assert.NotNil(err) var storageError *StorageError - _assert.Equal(errors.As(err, &storageError), true) + _assert.Equal(true, errors.As(err, &storageError)) _assert.Equal(storageError.ErrorCode, StorageErrorCodeBlobNotFound) } diff --git a/sdk/storage/azblob/zt_service_client_test.go b/sdk/storage/azblob/zt_service_client_test.go index 7bbd51693e12..f11f208b9307 100644 --- a/sdk/storage/azblob/zt_service_client_test.go +++ b/sdk/storage/azblob/zt_service_client_test.go @@ -5,10 +5,10 @@ package azblob import ( "context" + "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/stretchr/testify/assert" - "time" ) func (s *azblobTestSuite) TestGetAccountInfo() { diff --git a/sdk/storage/azblob/zt_test.go b/sdk/storage/azblob/zt_test.go index 37d42311017e..23d19e63a05e 100644 --- a/sdk/storage/azblob/zt_test.go +++ b/sdk/storage/azblob/zt_test.go @@ -10,11 +10,6 @@ import ( "encoding/binary" "errors" "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - testframework "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/suite" "io" "io/ioutil" "log" @@ -26,7 +21,12 @@ import ( "testing" "time" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + testframework "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" ) type azblobTestSuite struct { @@ -533,7 +533,8 @@ func blockIDIntToBase64(blockID int) string { func validateStorageError(_assert *assert.Assertions, err error, code StorageErrorCode) { _assert.NotNil(err) var storageError *StorageError - _assert.Equal(errors.As(err, &storageError), true) + // TOOD: this should really be require.Equal so that if it fails we don't try the next line which will panic + _assert.Equal(true, errors.As(err, &storageError)) _assert.Equal(storageError.ErrorCode, code) } diff --git a/sdk/storage/azblob/zz_generated_appendblob_client.go b/sdk/storage/azblob/zz_generated_appendblob_client.go index 1022998bde77..6a2b7ace5984 100644 --- a/sdk/storage/azblob/zz_generated_appendblob_client.go +++ b/sdk/storage/azblob/zz_generated_appendblob_client.go @@ -11,13 +11,13 @@ package azblob import ( "context" "encoding/base64" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "io" "net/http" "strconv" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) type appendBlobClient struct { @@ -38,7 +38,7 @@ func (client *appendBlobClient) AppendBlock(ctx context.Context, contentLength i return AppendBlobAppendBlockResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return AppendBlobAppendBlockResponse{}, client.appendBlockHandleError(resp) + return AppendBlobAppendBlockResponse{}, runtime.NewResponseError(resp) } return client.appendBlockHandleResponse(resp) } @@ -176,19 +176,6 @@ func (client *appendBlobClient) appendBlockHandleResponse(resp *http.Response) ( return result, nil } -// appendBlockHandleError handles the AppendBlock error response. -func (client *appendBlobClient) appendBlockHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // AppendBlockFromURL - The Append Block operation commits a new block of data to the end of an existing append blob where the contents are read from a // source url. The Append Block operation is permitted only if the blob was // created with x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. @@ -203,7 +190,7 @@ func (client *appendBlobClient) AppendBlockFromURL(ctx context.Context, sourceUR return AppendBlobAppendBlockFromURLResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return AppendBlobAppendBlockFromURLResponse{}, client.appendBlockFromURLHandleError(resp) + return AppendBlobAppendBlockFromURLResponse{}, runtime.NewResponseError(resp) } return client.appendBlockFromURLHandleResponse(resp) } @@ -357,19 +344,6 @@ func (client *appendBlobClient) appendBlockFromURLHandleResponse(resp *http.Resp return result, nil } -// appendBlockFromURLHandleError handles the AppendBlockFromURL error response. -func (client *appendBlobClient) appendBlockFromURLHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Create - The Create Append Blob operation creates a new append blob. // If the operation fails it returns the *StorageError error type. func (client *appendBlobClient) Create(ctx context.Context, contentLength int64, appendBlobCreateOptions *AppendBlobCreateOptions, blobHTTPHeaders *BlobHTTPHeaders, leaseAccessConditions *LeaseAccessConditions, cpkInfo *CpkInfo, cpkScopeInfo *CpkScopeInfo, modifiedAccessConditions *ModifiedAccessConditions) (AppendBlobCreateResponse, error) { @@ -382,7 +356,7 @@ func (client *appendBlobClient) Create(ctx context.Context, contentLength int64, return AppendBlobCreateResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return AppendBlobCreateResponse{}, client.createHandleError(resp) + return AppendBlobCreateResponse{}, runtime.NewResponseError(resp) } return client.createHandleResponse(resp) } @@ -519,19 +493,6 @@ func (client *appendBlobClient) createHandleResponse(resp *http.Response) (Appen return result, nil } -// createHandleError handles the Create error response. -func (client *appendBlobClient) createHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Seal - The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 version or later. // If the operation fails it returns the *StorageError error type. func (client *appendBlobClient) Seal(ctx context.Context, appendBlobSealOptions *AppendBlobSealOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, appendPositionAccessConditions *AppendPositionAccessConditions) (AppendBlobSealResponse, error) { @@ -544,7 +505,7 @@ func (client *appendBlobClient) Seal(ctx context.Context, appendBlobSealOptions return AppendBlobSealResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return AppendBlobSealResponse{}, client.sealHandleError(resp) + return AppendBlobSealResponse{}, runtime.NewResponseError(resp) } return client.sealHandleResponse(resp) } @@ -625,16 +586,3 @@ func (client *appendBlobClient) sealHandleResponse(resp *http.Response) (AppendB } return result, nil } - -// sealHandleError handles the Seal error response. -func (client *appendBlobClient) sealHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/storage/azblob/zz_generated_blob_client.go b/sdk/storage/azblob/zz_generated_blob_client.go index f5e3aa4539c9..05a273cb25ae 100644 --- a/sdk/storage/azblob/zz_generated_blob_client.go +++ b/sdk/storage/azblob/zz_generated_blob_client.go @@ -11,13 +11,13 @@ package azblob import ( "context" "encoding/base64" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "strconv" "strings" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) type blobClient struct { @@ -38,7 +38,7 @@ func (client *blobClient) AbortCopyFromURL(ctx context.Context, copyID string, b return BlobAbortCopyFromURLResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return BlobAbortCopyFromURLResponse{}, client.abortCopyFromURLHandleError(resp) + return BlobAbortCopyFromURLResponse{}, runtime.NewResponseError(resp) } return client.abortCopyFromURLHandleResponse(resp) } @@ -90,19 +90,6 @@ func (client *blobClient) abortCopyFromURLHandleResponse(resp *http.Response) (B return result, nil } -// abortCopyFromURLHandleError handles the AbortCopyFromURL error response. -func (client *blobClient) abortCopyFromURLHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // AcquireLease - [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations // If the operation fails it returns the *StorageError error type. func (client *blobClient) AcquireLease(ctx context.Context, blobAcquireLeaseOptions *BlobAcquireLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (BlobAcquireLeaseResponse, error) { @@ -115,7 +102,7 @@ func (client *blobClient) AcquireLease(ctx context.Context, blobAcquireLeaseOpti return BlobAcquireLeaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return BlobAcquireLeaseResponse{}, client.acquireLeaseHandleError(resp) + return BlobAcquireLeaseResponse{}, runtime.NewResponseError(resp) } return client.acquireLeaseHandleResponse(resp) } @@ -197,19 +184,6 @@ func (client *blobClient) acquireLeaseHandleResponse(resp *http.Response) (BlobA return result, nil } -// acquireLeaseHandleError handles the AcquireLease error response. -func (client *blobClient) acquireLeaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // BreakLease - [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations // If the operation fails it returns the *StorageError error type. func (client *blobClient) BreakLease(ctx context.Context, blobBreakLeaseOptions *BlobBreakLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (BlobBreakLeaseResponse, error) { @@ -222,7 +196,7 @@ func (client *blobClient) BreakLease(ctx context.Context, blobBreakLeaseOptions return BlobBreakLeaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return BlobBreakLeaseResponse{}, client.breakLeaseHandleError(resp) + return BlobBreakLeaseResponse{}, runtime.NewResponseError(resp) } return client.breakLeaseHandleResponse(resp) } @@ -306,19 +280,6 @@ func (client *blobClient) breakLeaseHandleResponse(resp *http.Response) (BlobBre return result, nil } -// breakLeaseHandleError handles the BreakLease error response. -func (client *blobClient) breakLeaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // ChangeLease - [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations // If the operation fails it returns the *StorageError error type. func (client *blobClient) ChangeLease(ctx context.Context, leaseID string, proposedLeaseID string, blobChangeLeaseOptions *BlobChangeLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (BlobChangeLeaseResponse, error) { @@ -331,7 +292,7 @@ func (client *blobClient) ChangeLease(ctx context.Context, leaseID string, propo return BlobChangeLeaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobChangeLeaseResponse{}, client.changeLeaseHandleError(resp) + return BlobChangeLeaseResponse{}, runtime.NewResponseError(resp) } return client.changeLeaseHandleResponse(resp) } @@ -409,19 +370,6 @@ func (client *blobClient) changeLeaseHandleResponse(resp *http.Response) (BlobCh return result, nil } -// changeLeaseHandleError handles the ChangeLease error response. -func (client *blobClient) changeLeaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // CopyFromURL - The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response until the copy is complete. // If the operation fails it returns the *StorageError error type. func (client *blobClient) CopyFromURL(ctx context.Context, copySource string, blobCopyFromURLOptions *BlobCopyFromURLOptions, sourceModifiedAccessConditions *SourceModifiedAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, leaseAccessConditions *LeaseAccessConditions) (BlobCopyFromURLResponse, error) { @@ -434,7 +382,7 @@ func (client *blobClient) CopyFromURL(ctx context.Context, copySource string, bl return BlobCopyFromURLResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return BlobCopyFromURLResponse{}, client.copyFromURLHandleError(resp) + return BlobCopyFromURLResponse{}, runtime.NewResponseError(resp) } return client.copyFromURLHandleResponse(resp) } @@ -559,19 +507,6 @@ func (client *blobClient) copyFromURLHandleResponse(resp *http.Response) (BlobCo return result, nil } -// copyFromURLHandleError handles the CopyFromURL error response. -func (client *blobClient) copyFromURLHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // CreateSnapshot - The Create Snapshot operation creates a read-only snapshot of a blob // If the operation fails it returns the *StorageError error type. func (client *blobClient) CreateSnapshot(ctx context.Context, blobCreateSnapshotOptions *BlobCreateSnapshotOptions, cpkInfo *CpkInfo, cpkScopeInfo *CpkScopeInfo, modifiedAccessConditions *ModifiedAccessConditions, leaseAccessConditions *LeaseAccessConditions) (BlobCreateSnapshotResponse, error) { @@ -584,7 +519,7 @@ func (client *blobClient) CreateSnapshot(ctx context.Context, blobCreateSnapshot return BlobCreateSnapshotResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return BlobCreateSnapshotResponse{}, client.createSnapshotHandleError(resp) + return BlobCreateSnapshotResponse{}, runtime.NewResponseError(resp) } return client.createSnapshotHandleResponse(resp) } @@ -689,19 +624,6 @@ func (client *blobClient) createSnapshotHandleResponse(resp *http.Response) (Blo return result, nil } -// createSnapshotHandleError handles the CreateSnapshot error response. -func (client *blobClient) createSnapshotHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Delete - If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed from the storage account. If // the storage account's soft delete feature is enabled, // then, when a blob is deleted, it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or snapshot @@ -724,7 +646,7 @@ func (client *blobClient) Delete(ctx context.Context, blobDeleteOptions *BlobDel return BlobDeleteResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return BlobDeleteResponse{}, client.deleteHandleError(resp) + return BlobDeleteResponse{}, runtime.NewResponseError(resp) } return client.deleteHandleResponse(resp) } @@ -797,19 +719,6 @@ func (client *blobClient) deleteHandleResponse(resp *http.Response) (BlobDeleteR return result, nil } -// deleteHandleError handles the Delete error response. -func (client *blobClient) deleteHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Download - The Download operation reads or downloads a blob from the system, including its metadata and properties. You can also call Download to read // a snapshot. // If the operation fails it returns the *StorageError error type. @@ -823,7 +732,7 @@ func (client *blobClient) Download(ctx context.Context, blobDownloadOptions *Blo return BlobDownloadResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusPartialContent) { - return BlobDownloadResponse{}, client.downloadHandleError(resp) + return BlobDownloadResponse{}, runtime.NewResponseError(resp) } return client.downloadHandleResponse(resp) } @@ -845,7 +754,7 @@ func (client *blobClient) downloadCreateRequest(ctx context.Context, blobDownloa reqQP.Set("timeout", strconv.FormatInt(int64(*blobDownloadOptions.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.SkipBodyDownload() + runtime.SkipBodyDownload(req) if blobDownloadOptions != nil && blobDownloadOptions.Range != nil { req.Raw().Header.Set("x-ms-range", *blobDownloadOptions.Range) } @@ -1076,19 +985,6 @@ func (client *blobClient) downloadHandleResponse(resp *http.Response) (BlobDownl return result, nil } -// downloadHandleError handles the Download error response. -func (client *blobClient) downloadHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetAccessControl - Get the owner, group, permissions, or access control list for a blob. // If the operation fails it returns the *DataLakeStorageError error type. func (client *blobClient) GetAccessControl(ctx context.Context, blobGetAccessControlOptions *BlobGetAccessControlOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (BlobGetAccessControlResponse, error) { @@ -1101,7 +997,7 @@ func (client *blobClient) GetAccessControl(ctx context.Context, blobGetAccessCon return BlobGetAccessControlResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobGetAccessControlResponse{}, client.getAccessControlHandleError(resp) + return BlobGetAccessControlResponse{}, runtime.NewResponseError(resp) } return client.getAccessControlHandleResponse(resp) } @@ -1185,19 +1081,6 @@ func (client *blobClient) getAccessControlHandleResponse(resp *http.Response) (B return result, nil } -// getAccessControlHandleError handles the GetAccessControl error response. -func (client *blobClient) getAccessControlHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := DataLakeStorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetAccountInfo - Returns the sku name and account kind // If the operation fails it returns the *StorageError error type. func (client *blobClient) GetAccountInfo(ctx context.Context, options *BlobGetAccountInfoOptions) (BlobGetAccountInfoResponse, error) { @@ -1210,7 +1093,7 @@ func (client *blobClient) GetAccountInfo(ctx context.Context, options *BlobGetAc return BlobGetAccountInfoResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobGetAccountInfoResponse{}, client.getAccountInfoHandleError(resp) + return BlobGetAccountInfoResponse{}, runtime.NewResponseError(resp) } return client.getAccountInfoHandleResponse(resp) } @@ -1258,19 +1141,6 @@ func (client *blobClient) getAccountInfoHandleResponse(resp *http.Response) (Blo return result, nil } -// getAccountInfoHandleError handles the GetAccountInfo error response. -func (client *blobClient) getAccountInfoHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetProperties - The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties for the blob. It does // not return the content of the blob. // If the operation fails it returns the *StorageError error type. @@ -1284,7 +1154,7 @@ func (client *blobClient) GetProperties(ctx context.Context, blobGetPropertiesOp return BlobGetPropertiesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobGetPropertiesResponse{}, client.getPropertiesHandleError(resp) + return BlobGetPropertiesResponse{}, runtime.NewResponseError(resp) } return client.getPropertiesHandleResponse(resp) } @@ -1557,19 +1427,6 @@ func (client *blobClient) getPropertiesHandleResponse(resp *http.Response) (Blob return result, nil } -// getPropertiesHandleError handles the GetProperties error response. -func (client *blobClient) getPropertiesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetTags - The Get Tags operation enables users to get the tags associated with a blob. // If the operation fails it returns the *StorageError error type. func (client *blobClient) GetTags(ctx context.Context, blobGetTagsOptions *BlobGetTagsOptions, modifiedAccessConditions *ModifiedAccessConditions) (BlobGetTagsResponse, error) { @@ -1582,7 +1439,7 @@ func (client *blobClient) GetTags(ctx context.Context, blobGetTagsOptions *BlobG return BlobGetTagsResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobGetTagsResponse{}, client.getTagsHandleError(resp) + return BlobGetTagsResponse{}, runtime.NewResponseError(resp) } return client.getTagsHandleResponse(resp) } @@ -1641,19 +1498,6 @@ func (client *blobClient) getTagsHandleResponse(resp *http.Response) (BlobGetTag return result, nil } -// getTagsHandleError handles the GetTags error response. -func (client *blobClient) getTagsHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Query - The Query operation enables users to select/project on blob data by providing simple query expressions. // If the operation fails it returns the *StorageError error type. func (client *blobClient) Query(ctx context.Context, blobQueryOptions *BlobQueryOptions, leaseAccessConditions *LeaseAccessConditions, cpkInfo *CpkInfo, modifiedAccessConditions *ModifiedAccessConditions) (BlobQueryResponse, error) { @@ -1666,7 +1510,7 @@ func (client *blobClient) Query(ctx context.Context, blobQueryOptions *BlobQuery return BlobQueryResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusPartialContent) { - return BlobQueryResponse{}, client.queryHandleError(resp) + return BlobQueryResponse{}, runtime.NewResponseError(resp) } return client.queryHandleResponse(resp) } @@ -1686,7 +1530,7 @@ func (client *blobClient) queryCreateRequest(ctx context.Context, blobQueryOptio reqQP.Set("timeout", strconv.FormatInt(int64(*blobQueryOptions.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.SkipBodyDownload() + runtime.SkipBodyDownload(req) if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header.Set("x-ms-lease-id", *leaseAccessConditions.LeaseID) } @@ -1876,19 +1720,6 @@ func (client *blobClient) queryHandleResponse(resp *http.Response) (BlobQueryRes return result, nil } -// queryHandleError handles the Query error response. -func (client *blobClient) queryHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // ReleaseLease - [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations // If the operation fails it returns the *StorageError error type. func (client *blobClient) ReleaseLease(ctx context.Context, leaseID string, blobReleaseLeaseOptions *BlobReleaseLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (BlobReleaseLeaseResponse, error) { @@ -1901,7 +1732,7 @@ func (client *blobClient) ReleaseLease(ctx context.Context, leaseID string, blob return BlobReleaseLeaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobReleaseLeaseResponse{}, client.releaseLeaseHandleError(resp) + return BlobReleaseLeaseResponse{}, runtime.NewResponseError(resp) } return client.releaseLeaseHandleResponse(resp) } @@ -1975,19 +1806,6 @@ func (client *blobClient) releaseLeaseHandleResponse(resp *http.Response) (BlobR return result, nil } -// releaseLeaseHandleError handles the ReleaseLease error response. -func (client *blobClient) releaseLeaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Rename - Rename a blob/file. By default, the destination is overwritten and if the destination already exists and has a lease the lease is broken. This // operation supports conditional HTTP requests. For more // information, see Specifying Conditional Headers for Blob Service Operations [https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations]. @@ -2004,7 +1822,7 @@ func (client *blobClient) Rename(ctx context.Context, renameSource string, blobR return BlobRenameResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return BlobRenameResponse{}, client.renameHandleError(resp) + return BlobRenameResponse{}, runtime.NewResponseError(resp) } return client.renameHandleResponse(resp) } @@ -2125,19 +1943,6 @@ func (client *blobClient) renameHandleResponse(resp *http.Response) (BlobRenameR return result, nil } -// renameHandleError handles the Rename error response. -func (client *blobClient) renameHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := DataLakeStorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // RenewLease - [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations // If the operation fails it returns the *StorageError error type. func (client *blobClient) RenewLease(ctx context.Context, leaseID string, blobRenewLeaseOptions *BlobRenewLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (BlobRenewLeaseResponse, error) { @@ -2150,7 +1955,7 @@ func (client *blobClient) RenewLease(ctx context.Context, leaseID string, blobRe return BlobRenewLeaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobRenewLeaseResponse{}, client.renewLeaseHandleError(resp) + return BlobRenewLeaseResponse{}, runtime.NewResponseError(resp) } return client.renewLeaseHandleResponse(resp) } @@ -2227,19 +2032,6 @@ func (client *blobClient) renewLeaseHandleResponse(resp *http.Response) (BlobRen return result, nil } -// renewLeaseHandleError handles the RenewLease error response. -func (client *blobClient) renewLeaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetAccessControl - Set the owner, group, permissions, or access control list for a blob. // If the operation fails it returns the *DataLakeStorageError error type. func (client *blobClient) SetAccessControl(ctx context.Context, blobSetAccessControlOptions *BlobSetAccessControlOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (BlobSetAccessControlResponse, error) { @@ -2252,7 +2044,7 @@ func (client *blobClient) SetAccessControl(ctx context.Context, blobSetAccessCon return BlobSetAccessControlResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobSetAccessControlResponse{}, client.setAccessControlHandleError(resp) + return BlobSetAccessControlResponse{}, runtime.NewResponseError(resp) } return client.setAccessControlHandleResponse(resp) } @@ -2333,19 +2125,6 @@ func (client *blobClient) setAccessControlHandleResponse(resp *http.Response) (B return result, nil } -// setAccessControlHandleError handles the SetAccessControl error response. -func (client *blobClient) setAccessControlHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := DataLakeStorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetExpiry - Sets the time a blob will expire and be deleted. // If the operation fails it returns the *StorageError error type. func (client *blobClient) SetExpiry(ctx context.Context, expiryOptions BlobExpiryOptions, options *BlobSetExpiryOptions) (BlobSetExpiryResponse, error) { @@ -2358,7 +2137,7 @@ func (client *blobClient) SetExpiry(ctx context.Context, expiryOptions BlobExpir return BlobSetExpiryResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobSetExpiryResponse{}, client.setExpiryHandleError(resp) + return BlobSetExpiryResponse{}, runtime.NewResponseError(resp) } return client.setExpiryHandleResponse(resp) } @@ -2419,19 +2198,6 @@ func (client *blobClient) setExpiryHandleResponse(resp *http.Response) (BlobSetE return result, nil } -// setExpiryHandleError handles the SetExpiry error response. -func (client *blobClient) setExpiryHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetHTTPHeaders - The Set HTTP Headers operation sets system properties on the blob // If the operation fails it returns the *StorageError error type. func (client *blobClient) SetHTTPHeaders(ctx context.Context, blobSetHTTPHeadersOptions *BlobSetHTTPHeadersOptions, blobHTTPHeaders *BlobHTTPHeaders, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (BlobSetHTTPHeadersResponse, error) { @@ -2444,7 +2210,7 @@ func (client *blobClient) SetHTTPHeaders(ctx context.Context, blobSetHTTPHeaders return BlobSetHTTPHeadersResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobSetHTTPHeadersResponse{}, client.setHTTPHeadersHandleError(resp) + return BlobSetHTTPHeadersResponse{}, runtime.NewResponseError(resp) } return client.setHTTPHeadersHandleResponse(resp) } @@ -2544,19 +2310,6 @@ func (client *blobClient) setHTTPHeadersHandleResponse(resp *http.Response) (Blo return result, nil } -// setHTTPHeadersHandleError handles the SetHTTPHeaders error response. -func (client *blobClient) setHTTPHeadersHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetMetadata - The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs // If the operation fails it returns the *StorageError error type. func (client *blobClient) SetMetadata(ctx context.Context, blobSetMetadataOptions *BlobSetMetadataOptions, leaseAccessConditions *LeaseAccessConditions, cpkInfo *CpkInfo, cpkScopeInfo *CpkScopeInfo, modifiedAccessConditions *ModifiedAccessConditions) (BlobSetMetadataResponse, error) { @@ -2569,7 +2322,7 @@ func (client *blobClient) SetMetadata(ctx context.Context, blobSetMetadataOption return BlobSetMetadataResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobSetMetadataResponse{}, client.setMetadataHandleError(resp) + return BlobSetMetadataResponse{}, runtime.NewResponseError(resp) } return client.setMetadataHandleResponse(resp) } @@ -2677,19 +2430,6 @@ func (client *blobClient) setMetadataHandleResponse(resp *http.Response) (BlobSe return result, nil } -// setMetadataHandleError handles the SetMetadata error response. -func (client *blobClient) setMetadataHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetTags - The Set Tags operation enables users to set tags on a blob. // If the operation fails it returns the *StorageError error type. func (client *blobClient) SetTags(ctx context.Context, blobSetTagsOptions *BlobSetTagsOptions, modifiedAccessConditions *ModifiedAccessConditions) (BlobSetTagsResponse, error) { @@ -2702,7 +2442,7 @@ func (client *blobClient) SetTags(ctx context.Context, blobSetTagsOptions *BlobS return BlobSetTagsResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return BlobSetTagsResponse{}, client.setTagsHandleError(resp) + return BlobSetTagsResponse{}, runtime.NewResponseError(resp) } return client.setTagsHandleResponse(resp) } @@ -2764,19 +2504,6 @@ func (client *blobClient) setTagsHandleResponse(resp *http.Response) (BlobSetTag return result, nil } -// setTagsHandleError handles the SetTags error response. -func (client *blobClient) setTagsHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetTier - The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in // a blob storage account (locally redundant storage only). A // premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. @@ -2792,7 +2519,7 @@ func (client *blobClient) SetTier(ctx context.Context, tier AccessTier, blobSetT return BlobSetTierResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return BlobSetTierResponse{}, client.setTierHandleError(resp) + return BlobSetTierResponse{}, runtime.NewResponseError(resp) } return client.setTierHandleResponse(resp) } @@ -2848,19 +2575,6 @@ func (client *blobClient) setTierHandleResponse(resp *http.Response) (BlobSetTie return result, nil } -// setTierHandleError handles the SetTier error response. -func (client *blobClient) setTierHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // StartCopyFromURL - The Start Copy From URL operation copies a blob or an internet resource to a new blob. // If the operation fails it returns the *StorageError error type. func (client *blobClient) StartCopyFromURL(ctx context.Context, copySource string, blobStartCopyFromURLOptions *BlobStartCopyFromURLOptions, sourceModifiedAccessConditions *SourceModifiedAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, leaseAccessConditions *LeaseAccessConditions) (BlobStartCopyFromURLResponse, error) { @@ -2873,7 +2587,7 @@ func (client *blobClient) StartCopyFromURL(ctx context.Context, copySource strin return BlobStartCopyFromURLResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return BlobStartCopyFromURLResponse{}, client.startCopyFromURLHandleError(resp) + return BlobStartCopyFromURLResponse{}, runtime.NewResponseError(resp) } return client.startCopyFromURLHandleResponse(resp) } @@ -2989,19 +2703,6 @@ func (client *blobClient) startCopyFromURLHandleResponse(resp *http.Response) (B return result, nil } -// startCopyFromURLHandleError handles the StartCopyFromURL error response. -func (client *blobClient) startCopyFromURLHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Undelete - Undelete a blob that was previously soft deleted // If the operation fails it returns the *StorageError error type. func (client *blobClient) Undelete(ctx context.Context, options *BlobUndeleteOptions) (BlobUndeleteResponse, error) { @@ -3014,7 +2715,7 @@ func (client *blobClient) Undelete(ctx context.Context, options *BlobUndeleteOpt return BlobUndeleteResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobUndeleteResponse{}, client.undeleteHandleError(resp) + return BlobUndeleteResponse{}, runtime.NewResponseError(resp) } return client.undeleteHandleResponse(resp) } @@ -3060,16 +2761,3 @@ func (client *blobClient) undeleteHandleResponse(resp *http.Response) (BlobUndel } return result, nil } - -// undeleteHandleError handles the Undelete error response. -func (client *blobClient) undeleteHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/storage/azblob/zz_generated_blockblob_client.go b/sdk/storage/azblob/zz_generated_blockblob_client.go index 07619ac3a12b..c1d93782a261 100644 --- a/sdk/storage/azblob/zz_generated_blockblob_client.go +++ b/sdk/storage/azblob/zz_generated_blockblob_client.go @@ -11,13 +11,13 @@ package azblob import ( "context" "encoding/base64" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "io" "net/http" "strconv" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) type blockBlobClient struct { @@ -42,7 +42,7 @@ func (client *blockBlobClient) CommitBlockList(ctx context.Context, blocks Block return BlockBlobCommitBlockListResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return BlockBlobCommitBlockListResponse{}, client.commitBlockListHandleError(resp) + return BlockBlobCommitBlockListResponse{}, runtime.NewResponseError(resp) } return client.commitBlockListHandleResponse(resp) } @@ -194,19 +194,6 @@ func (client *blockBlobClient) commitBlockListHandleResponse(resp *http.Response return result, nil } -// commitBlockListHandleError handles the CommitBlockList error response. -func (client *blockBlobClient) commitBlockListHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetBlockList - The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob // If the operation fails it returns the *StorageError error type. func (client *blockBlobClient) GetBlockList(ctx context.Context, listType BlockListType, blockBlobGetBlockListOptions *BlockBlobGetBlockListOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (BlockBlobGetBlockListResponse, error) { @@ -219,7 +206,7 @@ func (client *blockBlobClient) GetBlockList(ctx context.Context, listType BlockL return BlockBlobGetBlockListResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlockBlobGetBlockListResponse{}, client.getBlockListHandleError(resp) + return BlockBlobGetBlockListResponse{}, runtime.NewResponseError(resp) } return client.getBlockListHandleResponse(resp) } @@ -299,19 +286,6 @@ func (client *blockBlobClient) getBlockListHandleResponse(resp *http.Response) ( return result, nil } -// getBlockListHandleError handles the GetBlockList error response. -func (client *blockBlobClient) getBlockListHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // StageBlock - The Stage Block operation creates a new block to be committed as part of a blob // If the operation fails it returns the *StorageError error type. func (client *blockBlobClient) StageBlock(ctx context.Context, blockID string, contentLength int64, body io.ReadSeekCloser, blockBlobStageBlockOptions *BlockBlobStageBlockOptions, leaseAccessConditions *LeaseAccessConditions, cpkInfo *CpkInfo, cpkScopeInfo *CpkScopeInfo) (BlockBlobStageBlockResponse, error) { @@ -324,7 +298,7 @@ func (client *blockBlobClient) StageBlock(ctx context.Context, blockID string, c return BlockBlobStageBlockResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return BlockBlobStageBlockResponse{}, client.stageBlockHandleError(resp) + return BlockBlobStageBlockResponse{}, runtime.NewResponseError(resp) } return client.stageBlockHandleResponse(resp) } @@ -421,19 +395,6 @@ func (client *blockBlobClient) stageBlockHandleResponse(resp *http.Response) (Bl return result, nil } -// stageBlockHandleError handles the StageBlock error response. -func (client *blockBlobClient) stageBlockHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // StageBlockFromURL - The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from a URL. // If the operation fails it returns the *StorageError error type. func (client *blockBlobClient) StageBlockFromURL(ctx context.Context, blockID string, contentLength int64, sourceURL string, blockBlobStageBlockFromURLOptions *BlockBlobStageBlockFromURLOptions, cpkInfo *CpkInfo, cpkScopeInfo *CpkScopeInfo, leaseAccessConditions *LeaseAccessConditions, sourceModifiedAccessConditions *SourceModifiedAccessConditions) (BlockBlobStageBlockFromURLResponse, error) { @@ -446,7 +407,7 @@ func (client *blockBlobClient) StageBlockFromURL(ctx context.Context, blockID st return BlockBlobStageBlockFromURLResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return BlockBlobStageBlockFromURLResponse{}, client.stageBlockFromURLHandleError(resp) + return BlockBlobStageBlockFromURLResponse{}, runtime.NewResponseError(resp) } return client.stageBlockFromURLHandleResponse(resp) } @@ -559,19 +520,6 @@ func (client *blockBlobClient) stageBlockFromURLHandleResponse(resp *http.Respon return result, nil } -// stageBlockFromURLHandleError handles the StageBlockFromURL error response. -func (client *blockBlobClient) stageBlockFromURLHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Upload - The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob overwrites any existing metadata // on the blob. Partial updates are not supported with Put // Blob; the content of the existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a block blob, use @@ -587,7 +535,7 @@ func (client *blockBlobClient) Upload(ctx context.Context, contentLength int64, return BlockBlobUploadResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return BlockBlobUploadResponse{}, client.uploadHandleError(resp) + return BlockBlobUploadResponse{}, runtime.NewResponseError(resp) } return client.uploadHandleResponse(resp) } @@ -729,16 +677,3 @@ func (client *blockBlobClient) uploadHandleResponse(resp *http.Response) (BlockB } return result, nil } - -// uploadHandleError handles the Upload error response. -func (client *blockBlobClient) uploadHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/storage/azblob/zz_generated_connection.go b/sdk/storage/azblob/zz_generated_connection.go index 2335bf2c9c74..aa11dd8d7c78 100644 --- a/sdk/storage/azblob/zz_generated_connection.go +++ b/sdk/storage/azblob/zz_generated_connection.go @@ -49,7 +49,9 @@ func newConnection(endpoint string, authPolicy policy.Policy, options *azcore.Cl if authPolicy != nil { perRetryPolicies = append(perRetryPolicies, authPolicy) } - return &connection{u: endpoint, p: runtime.NewPipeline(module, version, nil, perRetryPolicies, &cp)} + return &connection{u: endpoint, p: runtime.NewPipeline(module, version, runtime.PipelineOptions{ + PerRetry: perRetryPolicies, + }, &cp)} } // Endpoint returns the connection's endpoint. diff --git a/sdk/storage/azblob/zz_generated_constants.go b/sdk/storage/azblob/zz_generated_constants.go index fec9b1790480..e8bacdcc71c0 100644 --- a/sdk/storage/azblob/zz_generated_constants.go +++ b/sdk/storage/azblob/zz_generated_constants.go @@ -10,7 +10,7 @@ package azblob const ( module = "azblob" - version = "v0.2.1" + version = "v0.3.0" ) type AccessTier string diff --git a/sdk/storage/azblob/zz_generated_container_client.go b/sdk/storage/azblob/zz_generated_container_client.go index 3458ae3d417d..81295fe7d61e 100644 --- a/sdk/storage/azblob/zz_generated_container_client.go +++ b/sdk/storage/azblob/zz_generated_container_client.go @@ -12,12 +12,13 @@ import ( "context" "encoding/xml" "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "strconv" "strings" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) type containerClient struct { @@ -36,7 +37,7 @@ func (client *containerClient) AcquireLease(ctx context.Context, containerAcquir return ContainerAcquireLeaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ContainerAcquireLeaseResponse{}, client.acquireLeaseHandleError(resp) + return ContainerAcquireLeaseResponse{}, runtime.NewResponseError(resp) } return client.acquireLeaseHandleResponse(resp) } @@ -110,19 +111,6 @@ func (client *containerClient) acquireLeaseHandleResponse(resp *http.Response) ( return result, nil } -// acquireLeaseHandleError handles the AcquireLease error response. -func (client *containerClient) acquireLeaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // BreakLease - [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite // If the operation fails it returns the *StorageError error type. func (client *containerClient) BreakLease(ctx context.Context, containerBreakLeaseOptions *ContainerBreakLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (ContainerBreakLeaseResponse, error) { @@ -135,7 +123,7 @@ func (client *containerClient) BreakLease(ctx context.Context, containerBreakLea return ContainerBreakLeaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ContainerBreakLeaseResponse{}, client.breakLeaseHandleError(resp) + return ContainerBreakLeaseResponse{}, runtime.NewResponseError(resp) } return client.breakLeaseHandleResponse(resp) } @@ -211,19 +199,6 @@ func (client *containerClient) breakLeaseHandleResponse(resp *http.Response) (Co return result, nil } -// breakLeaseHandleError handles the BreakLease error response. -func (client *containerClient) breakLeaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // ChangeLease - [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite // If the operation fails it returns the *StorageError error type. func (client *containerClient) ChangeLease(ctx context.Context, leaseID string, proposedLeaseID string, containerChangeLeaseOptions *ContainerChangeLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (ContainerChangeLeaseResponse, error) { @@ -236,7 +211,7 @@ func (client *containerClient) ChangeLease(ctx context.Context, leaseID string, return ContainerChangeLeaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ContainerChangeLeaseResponse{}, client.changeLeaseHandleError(resp) + return ContainerChangeLeaseResponse{}, runtime.NewResponseError(resp) } return client.changeLeaseHandleResponse(resp) } @@ -306,19 +281,6 @@ func (client *containerClient) changeLeaseHandleResponse(resp *http.Response) (C return result, nil } -// changeLeaseHandleError handles the ChangeLease error response. -func (client *containerClient) changeLeaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Create - creates a new container under the specified account. If the container with the same name already exists, the operation fails // If the operation fails it returns the *StorageError error type. func (client *containerClient) Create(ctx context.Context, containerCreateOptions *ContainerCreateOptions, containerCpkScopeInfo *ContainerCpkScopeInfo) (ContainerCreateResponse, error) { @@ -331,7 +293,7 @@ func (client *containerClient) Create(ctx context.Context, containerCreateOption return ContainerCreateResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ContainerCreateResponse{}, client.createHandleError(resp) + return ContainerCreateResponse{}, runtime.NewResponseError(resp) } return client.createHandleResponse(resp) } @@ -402,19 +364,6 @@ func (client *containerClient) createHandleResponse(resp *http.Response) (Contai return result, nil } -// createHandleError handles the Create error response. -func (client *containerClient) createHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Delete - operation marks the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection // If the operation fails it returns the *StorageError error type. func (client *containerClient) Delete(ctx context.Context, containerDeleteOptions *ContainerDeleteOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (ContainerDeleteResponse, error) { @@ -427,7 +376,7 @@ func (client *containerClient) Delete(ctx context.Context, containerDeleteOption return ContainerDeleteResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ContainerDeleteResponse{}, client.deleteHandleError(resp) + return ContainerDeleteResponse{}, runtime.NewResponseError(resp) } return client.deleteHandleResponse(resp) } @@ -483,19 +432,6 @@ func (client *containerClient) deleteHandleResponse(resp *http.Response) (Contai return result, nil } -// deleteHandleError handles the Delete error response. -func (client *containerClient) deleteHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetAccessPolicy - gets the permissions for the specified container. The permissions indicate whether container data may be accessed publicly. // If the operation fails it returns the *StorageError error type. func (client *containerClient) GetAccessPolicy(ctx context.Context, containerGetAccessPolicyOptions *ContainerGetAccessPolicyOptions, leaseAccessConditions *LeaseAccessConditions) (ContainerGetAccessPolicyResponse, error) { @@ -508,7 +444,7 @@ func (client *containerClient) GetAccessPolicy(ctx context.Context, containerGet return ContainerGetAccessPolicyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ContainerGetAccessPolicyResponse{}, client.getAccessPolicyHandleError(resp) + return ContainerGetAccessPolicyResponse{}, runtime.NewResponseError(resp) } return client.getAccessPolicyHandleResponse(resp) } @@ -575,19 +511,6 @@ func (client *containerClient) getAccessPolicyHandleResponse(resp *http.Response return result, nil } -// getAccessPolicyHandleError handles the GetAccessPolicy error response. -func (client *containerClient) getAccessPolicyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetAccountInfo - Returns the sku name and account kind // If the operation fails it returns the *StorageError error type. func (client *containerClient) GetAccountInfo(ctx context.Context, options *ContainerGetAccountInfoOptions) (ContainerGetAccountInfoResponse, error) { @@ -600,7 +523,7 @@ func (client *containerClient) GetAccountInfo(ctx context.Context, options *Cont return ContainerGetAccountInfoResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ContainerGetAccountInfoResponse{}, client.getAccountInfoHandleError(resp) + return ContainerGetAccountInfoResponse{}, runtime.NewResponseError(resp) } return client.getAccountInfoHandleResponse(resp) } @@ -648,19 +571,6 @@ func (client *containerClient) getAccountInfoHandleResponse(resp *http.Response) return result, nil } -// getAccountInfoHandleError handles the GetAccountInfo error response. -func (client *containerClient) getAccountInfoHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetProperties - returns all user-defined metadata and system properties for the specified container. The data returned does not include the container's // list of blobs // If the operation fails it returns the *StorageError error type. @@ -674,7 +584,7 @@ func (client *containerClient) GetProperties(ctx context.Context, containerGetPr return ContainerGetPropertiesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ContainerGetPropertiesResponse{}, client.getPropertiesHandleError(resp) + return ContainerGetPropertiesResponse{}, runtime.NewResponseError(resp) } return client.getPropertiesHandleResponse(resp) } @@ -778,19 +688,6 @@ func (client *containerClient) getPropertiesHandleResponse(resp *http.Response) return result, nil } -// getPropertiesHandleError handles the GetProperties error response. -func (client *containerClient) getPropertiesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // ListBlobFlatSegment - [Update] The List Blobs operation returns a list of the blobs under the specified container // If the operation fails it returns the *StorageError error type. func (client *containerClient) ListBlobFlatSegment(options *ContainerListBlobFlatSegmentOptions) *ContainerListBlobFlatSegmentPager { @@ -866,19 +763,6 @@ func (client *containerClient) listBlobFlatSegmentHandleResponse(resp *http.Resp return result, nil } -// listBlobFlatSegmentHandleError handles the ListBlobFlatSegment error response. -func (client *containerClient) listBlobFlatSegmentHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // ListBlobHierarchySegment - [Update] The List Blobs operation returns a list of the blobs under the specified container // If the operation fails it returns the *StorageError error type. func (client *containerClient) ListBlobHierarchySegment(delimiter string, options *ContainerListBlobHierarchySegmentOptions) *ContainerListBlobHierarchySegmentPager { @@ -955,19 +839,6 @@ func (client *containerClient) listBlobHierarchySegmentHandleResponse(resp *http return result, nil } -// listBlobHierarchySegmentHandleError handles the ListBlobHierarchySegment error response. -func (client *containerClient) listBlobHierarchySegmentHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // ReleaseLease - [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite // If the operation fails it returns the *StorageError error type. func (client *containerClient) ReleaseLease(ctx context.Context, leaseID string, containerReleaseLeaseOptions *ContainerReleaseLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (ContainerReleaseLeaseResponse, error) { @@ -980,7 +851,7 @@ func (client *containerClient) ReleaseLease(ctx context.Context, leaseID string, return ContainerReleaseLeaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ContainerReleaseLeaseResponse{}, client.releaseLeaseHandleError(resp) + return ContainerReleaseLeaseResponse{}, runtime.NewResponseError(resp) } return client.releaseLeaseHandleResponse(resp) } @@ -1046,19 +917,6 @@ func (client *containerClient) releaseLeaseHandleResponse(resp *http.Response) ( return result, nil } -// releaseLeaseHandleError handles the ReleaseLease error response. -func (client *containerClient) releaseLeaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // RenewLease - [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite // If the operation fails it returns the *StorageError error type. func (client *containerClient) RenewLease(ctx context.Context, leaseID string, containerRenewLeaseOptions *ContainerRenewLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (ContainerRenewLeaseResponse, error) { @@ -1071,7 +929,7 @@ func (client *containerClient) RenewLease(ctx context.Context, leaseID string, c return ContainerRenewLeaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ContainerRenewLeaseResponse{}, client.renewLeaseHandleError(resp) + return ContainerRenewLeaseResponse{}, runtime.NewResponseError(resp) } return client.renewLeaseHandleResponse(resp) } @@ -1140,19 +998,6 @@ func (client *containerClient) renewLeaseHandleResponse(resp *http.Response) (Co return result, nil } -// renewLeaseHandleError handles the RenewLease error response. -func (client *containerClient) renewLeaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Restore - Restores a previously-deleted container. // If the operation fails it returns the *StorageError error type. func (client *containerClient) Restore(ctx context.Context, options *ContainerRestoreOptions) (ContainerRestoreResponse, error) { @@ -1165,7 +1010,7 @@ func (client *containerClient) Restore(ctx context.Context, options *ContainerRe return ContainerRestoreResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ContainerRestoreResponse{}, client.restoreHandleError(resp) + return ContainerRestoreResponse{}, runtime.NewResponseError(resp) } return client.restoreHandleResponse(resp) } @@ -1219,19 +1064,6 @@ func (client *containerClient) restoreHandleResponse(resp *http.Response) (Conta return result, nil } -// restoreHandleError handles the Restore error response. -func (client *containerClient) restoreHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetAccessPolicy - sets the permissions for the specified container. The permissions indicate whether blobs in a container may be accessed publicly. // If the operation fails it returns the *StorageError error type. func (client *containerClient) SetAccessPolicy(ctx context.Context, containerSetAccessPolicyOptions *ContainerSetAccessPolicyOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (ContainerSetAccessPolicyResponse, error) { @@ -1244,7 +1076,7 @@ func (client *containerClient) SetAccessPolicy(ctx context.Context, containerSet return ContainerSetAccessPolicyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ContainerSetAccessPolicyResponse{}, client.setAccessPolicyHandleError(resp) + return ContainerSetAccessPolicyResponse{}, runtime.NewResponseError(resp) } return client.setAccessPolicyHandleResponse(resp) } @@ -1321,19 +1153,6 @@ func (client *containerClient) setAccessPolicyHandleResponse(resp *http.Response return result, nil } -// setAccessPolicyHandleError handles the SetAccessPolicy error response. -func (client *containerClient) setAccessPolicyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetMetadata - operation sets one or more user-defined name-value pairs for the specified container. // If the operation fails it returns the *StorageError error type. func (client *containerClient) SetMetadata(ctx context.Context, containerSetMetadataOptions *ContainerSetMetadataOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (ContainerSetMetadataResponse, error) { @@ -1346,7 +1165,7 @@ func (client *containerClient) SetMetadata(ctx context.Context, containerSetMeta return ContainerSetMetadataResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ContainerSetMetadataResponse{}, client.setMetadataHandleError(resp) + return ContainerSetMetadataResponse{}, runtime.NewResponseError(resp) } return client.setMetadataHandleResponse(resp) } @@ -1414,16 +1233,3 @@ func (client *containerClient) setMetadataHandleResponse(resp *http.Response) (C } return result, nil } - -// setMetadataHandleError handles the SetMetadata error response. -func (client *containerClient) setMetadataHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/storage/azblob/zz_generated_directory_client.go b/sdk/storage/azblob/zz_generated_directory_client.go index a8f435552542..c3ce389d81ba 100644 --- a/sdk/storage/azblob/zz_generated_directory_client.go +++ b/sdk/storage/azblob/zz_generated_directory_client.go @@ -10,12 +10,12 @@ package azblob import ( "context" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "strconv" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) type directoryClient struct { @@ -39,7 +39,7 @@ func (client *directoryClient) Create(ctx context.Context, directoryCreateOption return DirectoryCreateResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return DirectoryCreateResponse{}, client.createHandleError(resp) + return DirectoryCreateResponse{}, runtime.NewResponseError(resp) } return client.createHandleResponse(resp) } @@ -142,19 +142,6 @@ func (client *directoryClient) createHandleResponse(resp *http.Response) (Direct return result, nil } -// createHandleError handles the Create error response. -func (client *directoryClient) createHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := DataLakeStorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Delete - Deletes the directory // If the operation fails it returns the *DataLakeStorageError error type. func (client *directoryClient) Delete(ctx context.Context, recursiveDirectoryDelete bool, directoryDeleteOptions *DirectoryDeleteOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (DirectoryDeleteResponse, error) { @@ -167,7 +154,7 @@ func (client *directoryClient) Delete(ctx context.Context, recursiveDirectoryDel return DirectoryDeleteResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryDeleteResponse{}, client.deleteHandleError(resp) + return DirectoryDeleteResponse{}, runtime.NewResponseError(resp) } return client.deleteHandleResponse(resp) } @@ -235,19 +222,6 @@ func (client *directoryClient) deleteHandleResponse(resp *http.Response) (Direct return result, nil } -// deleteHandleError handles the Delete error response. -func (client *directoryClient) deleteHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := DataLakeStorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetAccessControl - Get the owner, group, permissions, or access control list for a directory. // If the operation fails it returns the *DataLakeStorageError error type. func (client *directoryClient) GetAccessControl(ctx context.Context, directoryGetAccessControlOptions *DirectoryGetAccessControlOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (DirectoryGetAccessControlResponse, error) { @@ -260,7 +234,7 @@ func (client *directoryClient) GetAccessControl(ctx context.Context, directoryGe return DirectoryGetAccessControlResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryGetAccessControlResponse{}, client.getAccessControlHandleError(resp) + return DirectoryGetAccessControlResponse{}, runtime.NewResponseError(resp) } return client.getAccessControlHandleResponse(resp) } @@ -344,19 +318,6 @@ func (client *directoryClient) getAccessControlHandleResponse(resp *http.Respons return result, nil } -// getAccessControlHandleError handles the GetAccessControl error response. -func (client *directoryClient) getAccessControlHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := DataLakeStorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Rename - Rename a directory. By default, the destination is overwritten and if the destination already exists and has a lease the lease is broken. This // operation supports conditional HTTP requests. For more // information, see Specifying Conditional Headers for Blob Service Operations [https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations]. @@ -373,7 +334,7 @@ func (client *directoryClient) Rename(ctx context.Context, renameSource string, return DirectoryRenameResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return DirectoryRenameResponse{}, client.renameHandleError(resp) + return DirectoryRenameResponse{}, runtime.NewResponseError(resp) } return client.renameHandleResponse(resp) } @@ -500,19 +461,6 @@ func (client *directoryClient) renameHandleResponse(resp *http.Response) (Direct return result, nil } -// renameHandleError handles the Rename error response. -func (client *directoryClient) renameHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := DataLakeStorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetAccessControl - Set the owner, group, permissions, or access control list for a directory. // If the operation fails it returns the *DataLakeStorageError error type. func (client *directoryClient) SetAccessControl(ctx context.Context, directorySetAccessControlOptions *DirectorySetAccessControlOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (DirectorySetAccessControlResponse, error) { @@ -525,7 +473,7 @@ func (client *directoryClient) SetAccessControl(ctx context.Context, directorySe return DirectorySetAccessControlResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectorySetAccessControlResponse{}, client.setAccessControlHandleError(resp) + return DirectorySetAccessControlResponse{}, runtime.NewResponseError(resp) } return client.setAccessControlHandleResponse(resp) } @@ -605,16 +553,3 @@ func (client *directoryClient) setAccessControlHandleResponse(resp *http.Respons } return result, nil } - -// setAccessControlHandleError handles the SetAccessControl error response. -func (client *directoryClient) setAccessControlHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := DataLakeStorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/storage/azblob/zz_generated_models.go b/sdk/storage/azblob/zz_generated_models.go index b42a18762daa..2366bbb35214 100644 --- a/sdk/storage/azblob/zz_generated_models.go +++ b/sdk/storage/azblob/zz_generated_models.go @@ -1204,12 +1204,6 @@ type DataLakeStorageError struct { DataLakeStorageErrorDetails *DataLakeStorageErrorAutoGenerated `xml:"error"` } -// Error implements the error interface for type DataLakeStorageError. -// The contents of the error text are not contractual and subject to change. -func (e DataLakeStorageError) Error() string { - return e.raw -} - // DataLakeStorageErrorAutoGenerated - The service error response object. type DataLakeStorageErrorAutoGenerated struct { // The service error code. @@ -1910,11 +1904,6 @@ type StaticWebsite struct { // Message *string `xml:"Message"` //} // -//// Error implements the error interface for type StorageError. -//// The contents of the error text are not contractual and subject to change. -//func (e StorageError) Error() string { -// return e.raw -//} // StorageServiceProperties - Storage Service Properties. type StorageServiceProperties struct { diff --git a/sdk/storage/azblob/zz_generated_pageblob_client.go b/sdk/storage/azblob/zz_generated_pageblob_client.go index 70546afaaa56..651403bcb982 100644 --- a/sdk/storage/azblob/zz_generated_pageblob_client.go +++ b/sdk/storage/azblob/zz_generated_pageblob_client.go @@ -11,13 +11,13 @@ package azblob import ( "context" "encoding/base64" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "io" "net/http" "strconv" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) type pageBlobClient struct { @@ -36,7 +36,7 @@ func (client *pageBlobClient) ClearPages(ctx context.Context, contentLength int6 return PageBlobClearPagesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return PageBlobClearPagesResponse{}, client.clearPagesHandleError(resp) + return PageBlobClearPagesResponse{}, runtime.NewResponseError(resp) } return client.clearPagesHandleResponse(resp) } @@ -158,19 +158,6 @@ func (client *pageBlobClient) clearPagesHandleResponse(resp *http.Response) (Pag return result, nil } -// clearPagesHandleError handles the ClearPages error response. -func (client *pageBlobClient) clearPagesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // CopyIncremental - The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot is copied such that // only the differential changes between the previously copied // snapshot are transferred to the destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as usual. @@ -187,7 +174,7 @@ func (client *pageBlobClient) CopyIncremental(ctx context.Context, copySource st return PageBlobCopyIncrementalResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return PageBlobCopyIncrementalResponse{}, client.copyIncrementalHandleError(resp) + return PageBlobCopyIncrementalResponse{}, runtime.NewResponseError(resp) } return client.copyIncrementalHandleResponse(resp) } @@ -266,19 +253,6 @@ func (client *pageBlobClient) copyIncrementalHandleResponse(resp *http.Response) return result, nil } -// copyIncrementalHandleError handles the CopyIncremental error response. -func (client *pageBlobClient) copyIncrementalHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Create - The Create operation creates a new page blob. // If the operation fails it returns the *StorageError error type. func (client *pageBlobClient) Create(ctx context.Context, contentLength int64, blobContentLength int64, pageBlobCreateOptions *PageBlobCreateOptions, blobHTTPHeaders *BlobHTTPHeaders, leaseAccessConditions *LeaseAccessConditions, cpkInfo *CpkInfo, cpkScopeInfo *CpkScopeInfo, modifiedAccessConditions *ModifiedAccessConditions) (PageBlobCreateResponse, error) { @@ -291,7 +265,7 @@ func (client *pageBlobClient) Create(ctx context.Context, contentLength int64, b return PageBlobCreateResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return PageBlobCreateResponse{}, client.createHandleError(resp) + return PageBlobCreateResponse{}, runtime.NewResponseError(resp) } return client.createHandleResponse(resp) } @@ -435,19 +409,6 @@ func (client *pageBlobClient) createHandleResponse(resp *http.Response) (PageBlo return result, nil } -// createHandleError handles the Create error response. -func (client *pageBlobClient) createHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetPageRanges - The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot of a page blob // If the operation fails it returns the *StorageError error type. func (client *pageBlobClient) GetPageRanges(ctx context.Context, pageBlobGetPageRangesOptions *PageBlobGetPageRangesOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (PageBlobGetPageRangesResponse, error) { @@ -460,7 +421,7 @@ func (client *pageBlobClient) GetPageRanges(ctx context.Context, pageBlobGetPage return PageBlobGetPageRangesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return PageBlobGetPageRangesResponse{}, client.getPageRangesHandleError(resp) + return PageBlobGetPageRangesResponse{}, runtime.NewResponseError(resp) } return client.getPageRangesHandleResponse(resp) } @@ -551,19 +512,6 @@ func (client *pageBlobClient) getPageRangesHandleResponse(resp *http.Response) ( return result, nil } -// getPageRangesHandleError handles the GetPageRanges error response. -func (client *pageBlobClient) getPageRangesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetPageRangesDiff - The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were changed between target blob and // previous snapshot. // If the operation fails it returns the *StorageError error type. @@ -577,7 +525,7 @@ func (client *pageBlobClient) GetPageRangesDiff(ctx context.Context, pageBlobGet return PageBlobGetPageRangesDiffResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return PageBlobGetPageRangesDiffResponse{}, client.getPageRangesDiffHandleError(resp) + return PageBlobGetPageRangesDiffResponse{}, runtime.NewResponseError(resp) } return client.getPageRangesDiffHandleResponse(resp) } @@ -674,19 +622,6 @@ func (client *pageBlobClient) getPageRangesDiffHandleResponse(resp *http.Respons return result, nil } -// getPageRangesDiffHandleError handles the GetPageRangesDiff error response. -func (client *pageBlobClient) getPageRangesDiffHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Resize - Resize the Blob // If the operation fails it returns the *StorageError error type. func (client *pageBlobClient) Resize(ctx context.Context, blobContentLength int64, pageBlobResizeOptions *PageBlobResizeOptions, leaseAccessConditions *LeaseAccessConditions, cpkInfo *CpkInfo, cpkScopeInfo *CpkScopeInfo, modifiedAccessConditions *ModifiedAccessConditions) (PageBlobResizeResponse, error) { @@ -699,7 +634,7 @@ func (client *pageBlobClient) Resize(ctx context.Context, blobContentLength int6 return PageBlobResizeResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return PageBlobResizeResponse{}, client.resizeHandleError(resp) + return PageBlobResizeResponse{}, runtime.NewResponseError(resp) } return client.resizeHandleResponse(resp) } @@ -794,19 +729,6 @@ func (client *pageBlobClient) resizeHandleResponse(resp *http.Response) (PageBlo return result, nil } -// resizeHandleError handles the Resize error response. -func (client *pageBlobClient) resizeHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // UpdateSequenceNumber - Update the sequence number of the blob // If the operation fails it returns the *StorageError error type. func (client *pageBlobClient) UpdateSequenceNumber(ctx context.Context, sequenceNumberAction SequenceNumberActionType, pageBlobUpdateSequenceNumberOptions *PageBlobUpdateSequenceNumberOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (PageBlobUpdateSequenceNumberResponse, error) { @@ -819,7 +741,7 @@ func (client *pageBlobClient) UpdateSequenceNumber(ctx context.Context, sequence return PageBlobUpdateSequenceNumberResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return PageBlobUpdateSequenceNumberResponse{}, client.updateSequenceNumberHandleError(resp) + return PageBlobUpdateSequenceNumberResponse{}, runtime.NewResponseError(resp) } return client.updateSequenceNumberHandleResponse(resp) } @@ -905,19 +827,6 @@ func (client *pageBlobClient) updateSequenceNumberHandleResponse(resp *http.Resp return result, nil } -// updateSequenceNumberHandleError handles the UpdateSequenceNumber error response. -func (client *pageBlobClient) updateSequenceNumberHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // UploadPages - The Upload Pages operation writes a range of pages to a page blob // If the operation fails it returns the *StorageError error type. func (client *pageBlobClient) UploadPages(ctx context.Context, contentLength int64, body io.ReadSeekCloser, pageBlobUploadPagesOptions *PageBlobUploadPagesOptions, leaseAccessConditions *LeaseAccessConditions, cpkInfo *CpkInfo, cpkScopeInfo *CpkScopeInfo, sequenceNumberAccessConditions *SequenceNumberAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (PageBlobUploadPagesResponse, error) { @@ -930,7 +839,7 @@ func (client *pageBlobClient) UploadPages(ctx context.Context, contentLength int return PageBlobUploadPagesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return PageBlobUploadPagesResponse{}, client.uploadPagesHandleError(resp) + return PageBlobUploadPagesResponse{}, runtime.NewResponseError(resp) } return client.uploadPagesHandleResponse(resp) } @@ -1071,19 +980,6 @@ func (client *pageBlobClient) uploadPagesHandleResponse(resp *http.Response) (Pa return result, nil } -// uploadPagesHandleError handles the UploadPages error response. -func (client *pageBlobClient) uploadPagesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // UploadPagesFromURL - The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL // If the operation fails it returns the *StorageError error type. func (client *pageBlobClient) UploadPagesFromURL(ctx context.Context, sourceURL string, sourceRange string, contentLength int64, rangeParam string, pageBlobUploadPagesFromURLOptions *PageBlobUploadPagesFromURLOptions, cpkInfo *CpkInfo, cpkScopeInfo *CpkScopeInfo, leaseAccessConditions *LeaseAccessConditions, sequenceNumberAccessConditions *SequenceNumberAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, sourceModifiedAccessConditions *SourceModifiedAccessConditions) (PageBlobUploadPagesFromURLResponse, error) { @@ -1096,7 +992,7 @@ func (client *pageBlobClient) UploadPagesFromURL(ctx context.Context, sourceURL return PageBlobUploadPagesFromURLResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return PageBlobUploadPagesFromURLResponse{}, client.uploadPagesFromURLHandleError(resp) + return PageBlobUploadPagesFromURLResponse{}, runtime.NewResponseError(resp) } return client.uploadPagesFromURLHandleResponse(resp) } @@ -1245,16 +1141,3 @@ func (client *pageBlobClient) uploadPagesFromURLHandleResponse(resp *http.Respon } return result, nil } - -// uploadPagesFromURLHandleError handles the UploadPagesFromURL error response. -func (client *pageBlobClient) uploadPagesFromURLHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/storage/azblob/zz_generated_pagers.go b/sdk/storage/azblob/zz_generated_pagers.go index fab312cb80c5..d3ad53c2107e 100644 --- a/sdk/storage/azblob/zz_generated_pagers.go +++ b/sdk/storage/azblob/zz_generated_pagers.go @@ -10,10 +10,11 @@ package azblob import ( "context" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "reflect" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) // ContainerListBlobFlatSegmentPager provides operations for iterating over paged responses. @@ -53,7 +54,7 @@ func (p *ContainerListBlobFlatSegmentPager) NextPage(ctx context.Context) bool { return false } if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = p.client.listBlobFlatSegmentHandleError(resp) + p.err = runtime.NewResponseError(resp) return false } result, err := p.client.listBlobFlatSegmentHandleResponse(resp) @@ -107,7 +108,7 @@ func (p *ContainerListBlobHierarchySegmentPager) NextPage(ctx context.Context) b return false } if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = p.client.listBlobHierarchySegmentHandleError(resp) + p.err = runtime.NewResponseError(resp) return false } result, err := p.client.listBlobHierarchySegmentHandleResponse(resp) @@ -161,7 +162,7 @@ func (p *ServiceListContainersSegmentPager) NextPage(ctx context.Context) bool { return false } if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = p.client.listContainersSegmentHandleError(resp) + p.err = runtime.NewResponseError(resp) return false } result, err := p.client.listContainersSegmentHandleResponse(resp) diff --git a/sdk/storage/azblob/zz_generated_service_client.go b/sdk/storage/azblob/zz_generated_service_client.go index 738956899100..d4fa7768a10a 100644 --- a/sdk/storage/azblob/zz_generated_service_client.go +++ b/sdk/storage/azblob/zz_generated_service_client.go @@ -11,13 +11,14 @@ package azblob import ( "context" "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "io" "net/http" "strconv" "strings" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) type serviceClient struct { @@ -38,7 +39,7 @@ func (client *serviceClient) FilterBlobs(ctx context.Context, options *ServiceFi return ServiceFilterBlobsResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceFilterBlobsResponse{}, client.filterBlobsHandleError(resp) + return ServiceFilterBlobsResponse{}, runtime.NewResponseError(resp) } return client.filterBlobsHandleResponse(resp) } @@ -97,19 +98,6 @@ func (client *serviceClient) filterBlobsHandleResponse(resp *http.Response) (Ser return result, nil } -// filterBlobsHandleError handles the FilterBlobs error response. -func (client *serviceClient) filterBlobsHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetAccountInfo - Returns the sku name and account kind // If the operation fails it returns the *StorageError error type. func (client *serviceClient) GetAccountInfo(ctx context.Context, options *ServiceGetAccountInfoOptions) (ServiceGetAccountInfoResponse, error) { @@ -122,7 +110,7 @@ func (client *serviceClient) GetAccountInfo(ctx context.Context, options *Servic return ServiceGetAccountInfoResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceGetAccountInfoResponse{}, client.getAccountInfoHandleError(resp) + return ServiceGetAccountInfoResponse{}, runtime.NewResponseError(resp) } return client.getAccountInfoHandleResponse(resp) } @@ -177,19 +165,6 @@ func (client *serviceClient) getAccountInfoHandleResponse(resp *http.Response) ( return result, nil } -// getAccountInfoHandleError handles the GetAccountInfo error response. -func (client *serviceClient) getAccountInfoHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetProperties - gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) // rules. // If the operation fails it returns the *StorageError error type. @@ -203,7 +178,7 @@ func (client *serviceClient) GetProperties(ctx context.Context, options *Service return ServiceGetPropertiesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceGetPropertiesResponse{}, client.getPropertiesHandleError(resp) + return ServiceGetPropertiesResponse{}, runtime.NewResponseError(resp) } return client.getPropertiesHandleResponse(resp) } @@ -247,19 +222,6 @@ func (client *serviceClient) getPropertiesHandleResponse(resp *http.Response) (S return result, nil } -// getPropertiesHandleError handles the GetProperties error response. -func (client *serviceClient) getPropertiesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetStatistics - Retrieves statistics related to replication for the Blob service. It is only available on the secondary location endpoint when read-access // geo-redundant replication is enabled for the storage account. // If the operation fails it returns the *StorageError error type. @@ -273,7 +235,7 @@ func (client *serviceClient) GetStatistics(ctx context.Context, options *Service return ServiceGetStatisticsResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceGetStatisticsResponse{}, client.getStatisticsHandleError(resp) + return ServiceGetStatisticsResponse{}, runtime.NewResponseError(resp) } return client.getStatisticsHandleResponse(resp) } @@ -324,19 +286,6 @@ func (client *serviceClient) getStatisticsHandleResponse(resp *http.Response) (S return result, nil } -// getStatisticsHandleError handles the GetStatistics error response. -func (client *serviceClient) getStatisticsHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetUserDelegationKey - Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token authentication. // If the operation fails it returns the *StorageError error type. func (client *serviceClient) GetUserDelegationKey(ctx context.Context, keyInfo KeyInfo, options *ServiceGetUserDelegationKeyOptions) (ServiceGetUserDelegationKeyResponse, error) { @@ -349,7 +298,7 @@ func (client *serviceClient) GetUserDelegationKey(ctx context.Context, keyInfo K return ServiceGetUserDelegationKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceGetUserDelegationKeyResponse{}, client.getUserDelegationKeyHandleError(resp) + return ServiceGetUserDelegationKeyResponse{}, runtime.NewResponseError(resp) } return client.getUserDelegationKeyHandleResponse(resp) } @@ -400,19 +349,6 @@ func (client *serviceClient) getUserDelegationKeyHandleResponse(resp *http.Respo return result, nil } -// getUserDelegationKeyHandleError handles the GetUserDelegationKey error response. -func (client *serviceClient) getUserDelegationKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // ListContainersSegment - The List Containers Segment operation returns a list of the containers under the specified account // If the operation fails it returns the *StorageError error type. func (client *serviceClient) ListContainersSegment(options *ServiceListContainersSegmentOptions) *ServiceListContainersSegmentPager { @@ -477,19 +413,6 @@ func (client *serviceClient) listContainersSegmentHandleResponse(resp *http.Resp return result, nil } -// listContainersSegmentHandleError handles the ListContainersSegment error response. -func (client *serviceClient) listContainersSegmentHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetProperties - Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and CORS (Cross-Origin Resource // Sharing) rules // If the operation fails it returns the *StorageError error type. @@ -503,7 +426,7 @@ func (client *serviceClient) SetProperties(ctx context.Context, storageServicePr return ServiceSetPropertiesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ServiceSetPropertiesResponse{}, client.setPropertiesHandleError(resp) + return ServiceSetPropertiesResponse{}, runtime.NewResponseError(resp) } return client.setPropertiesHandleResponse(resp) } @@ -544,19 +467,6 @@ func (client *serviceClient) setPropertiesHandleResponse(resp *http.Response) (S return result, nil } -// setPropertiesHandleError handles the SetProperties error response. -func (client *serviceClient) setPropertiesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SubmitBatch - The Batch operation allows multiple API calls to be embedded into a single HTTP request. // If the operation fails it returns the *StorageError error type. func (client *serviceClient) SubmitBatch(ctx context.Context, contentLength int64, multipartContentType string, body io.ReadSeekCloser, options *ServiceSubmitBatchOptions) (ServiceSubmitBatchResponse, error) { @@ -569,7 +479,7 @@ func (client *serviceClient) SubmitBatch(ctx context.Context, contentLength int6 return ServiceSubmitBatchResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceSubmitBatchResponse{}, client.submitBatchHandleError(resp) + return ServiceSubmitBatchResponse{}, runtime.NewResponseError(resp) } return client.submitBatchHandleResponse(resp) } @@ -586,7 +496,7 @@ func (client *serviceClient) submitBatchCreateRequest(ctx context.Context, conte reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.SkipBodyDownload() + runtime.SkipBodyDownload(req) req.Raw().Header.Set("Content-Length", strconv.FormatInt(contentLength, 10)) req.Raw().Header.Set("Content-Type", multipartContentType) req.Raw().Header.Set("x-ms-version", "2019-12-12") @@ -611,16 +521,3 @@ func (client *serviceClient) submitBatchHandleResponse(resp *http.Response) (Ser } return result, nil } - -// submitBatchHandleError handles the SubmitBatch error response. -func (client *serviceClient) submitBatchHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := StorageError{raw: string(body)} - if err := runtime.UnmarshalAsXML(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} From 7a5d045f5221395c49e71c15e3d4ef589986e8be Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Tue, 11 Jan 2022 13:59:56 -0800 Subject: [PATCH 2/2] clean-up --- sdk/storage/azblob/zc_storage_error.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sdk/storage/azblob/zc_storage_error.go b/sdk/storage/azblob/zc_storage_error.go index f49a0944dff8..db6e1160ba19 100644 --- a/sdk/storage/azblob/zc_storage_error.go +++ b/sdk/storage/azblob/zc_storage_error.go @@ -62,7 +62,7 @@ type StorageError struct { func handleError(err error) error { var respErr *azcore.ResponseError if errors.As(err, &respErr) { - return &InternalError{defunkifyStorageError(respErr)} + return &InternalError{responseErrorToStorageError(respErr)} } if err != nil { @@ -72,8 +72,8 @@ func handleError(err error) error { return nil } -// defunkifyStorageError is a function that takes the "funky" ResponseError and reduces it to a storageError. -func defunkifyStorageError(responseError *azcore.ResponseError) error { +// converts an *azcore.ResponseError to a *StorageError, or if that fails, a *InternalError +func responseErrorToStorageError(responseError *azcore.ResponseError) error { var storageError StorageError body, err := runtime.Payload(responseError.RawResponse) if err != nil { @@ -85,8 +85,6 @@ func defunkifyStorageError(responseError *azcore.ResponseError) error { } } - // errors.Unwrap(responseError.Unwrap()) - storageError.response = responseError.RawResponse storageError.ErrorCode = StorageErrorCode(responseError.RawResponse.Header.Get("x-ms-error-code"))