diff --git a/storage/2023-11-03/blob/accounts/get_service_properties.go b/storage/2023-11-03/blob/accounts/get_service_properties.go index 668b127..5c00898 100644 --- a/storage/2023-11-03/blob/accounts/get_service_properties.go +++ b/storage/2023-11-03/blob/accounts/get_service_properties.go @@ -39,10 +39,12 @@ func (c Client) GetServiceProperties(ctx context.Context, accountName string) (r if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/append_block.go b/storage/2023-11-03/blob/blobs/append_block.go index 26374e8..d5a424d 100644 --- a/storage/2023-11-03/blob/blobs/append_block.go +++ b/storage/2023-11-03/blob/blobs/append_block.go @@ -105,19 +105,21 @@ func (c Client) AppendBlock(ctx context.Context, containerName, blobName string, if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.BlobAppendOffset = resp.Header.Get("x-ms-blob-append-offset") - result.ContentMD5 = resp.Header.Get("Content-MD5") - result.ETag = resp.Header.Get("ETag") - result.LastModified = resp.Header.Get("Last-Modified") - - if v := resp.Header.Get("x-ms-blob-committed-block-count"); v != "" { - i, innerErr := strconv.Atoi(v) - if innerErr != nil { - err = fmt.Errorf("parsing `x-ms-blob-committed-block-count` header value %q: %+v", v, innerErr) - return + if err == nil { + if resp.Header != nil { + result.BlobAppendOffset = resp.Header.Get("x-ms-blob-append-offset") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ETag = resp.Header.Get("ETag") + result.LastModified = resp.Header.Get("Last-Modified") + + if v := resp.Header.Get("x-ms-blob-committed-block-count"); v != "" { + i, innerErr := strconv.Atoi(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-blob-committed-block-count` header value %q: %+v", v, innerErr) + return + } + result.BlobCommittedBlockCount = int64(i) } - result.BlobCommittedBlockCount = int64(i) } } } diff --git a/storage/2023-11-03/blob/blobs/copy.go b/storage/2023-11-03/blob/blobs/copy.go index 50360cf..2565c64 100644 --- a/storage/2023-11-03/blob/blobs/copy.go +++ b/storage/2023-11-03/blob/blobs/copy.go @@ -155,9 +155,11 @@ func (c Client) Copy(ctx context.Context, containerName, blobName string, input if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.CopyID = resp.Header.Get("x-ms-copy-id") - result.CopyStatus = resp.Header.Get("x-ms-copy-status") + if err == nil { + if resp.Header != nil { + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyStatus = resp.Header.Get("x-ms-copy-status") + } } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/get.go b/storage/2023-11-03/blob/blobs/get.go index 0e49f43..4c8a4b5 100644 --- a/storage/2023-11-03/blob/blobs/get.go +++ b/storage/2023-11-03/blob/blobs/get.go @@ -68,14 +68,16 @@ func (c Client) Get(ctx context.Context, containerName, blobName string, input G if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Body != nil { - defer resp.Body.Close() - respBody, err := io.ReadAll(resp.Body) - if err != nil { - return result, fmt.Errorf("could not parse response body") + if err == nil { + if resp.Body != nil { + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return result, fmt.Errorf("could not parse response body") + } + + result.Contents = &respBody } - - result.Contents = &respBody } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/get_block_list.go b/storage/2023-11-03/blob/blobs/get_block_list.go index 45a30a6..07277d1 100644 --- a/storage/2023-11-03/blob/blobs/get_block_list.go +++ b/storage/2023-11-03/blob/blobs/get_block_list.go @@ -71,26 +71,28 @@ func (c Client) GetBlockList(ctx context.Context, containerName, blobName string if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.ContentType = resp.Header.Get("Content-Type") - result.ETag = resp.Header.Get("ETag") - - if v := resp.Header.Get("x-ms-blob-content-length"); v != "" { - i, innerErr := strconv.Atoi(v) - if innerErr != nil { - err = fmt.Errorf("parsing `x-ms-blob-content-length` header value %q: %s", v, innerErr) - return + if err == nil { + if resp.Header != nil { + result.ContentType = resp.Header.Get("Content-Type") + result.ETag = resp.Header.Get("ETag") + + if v := resp.Header.Get("x-ms-blob-content-length"); v != "" { + i, innerErr := strconv.Atoi(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-blob-content-length` header value %q: %s", v, innerErr) + return + } + + i64 := int64(i) + result.BlobContentLength = &i64 } - - i64 := int64(i) - result.BlobContentLength = &i64 } - } - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/get_page_ranges.go b/storage/2023-11-03/blob/blobs/get_page_ranges.go index 5341365..cb91a0a 100644 --- a/storage/2023-11-03/blob/blobs/get_page_ranges.go +++ b/storage/2023-11-03/blob/blobs/get_page_ranges.go @@ -81,26 +81,28 @@ func (c Client) GetPageRanges(ctx context.Context, containerName, blobName strin if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.ContentType = resp.Header.Get("Content-Type") - result.ETag = resp.Header.Get("ETag") - - if v := resp.Header.Get("x-ms-blob-content-length"); v != "" { - i, innerErr := strconv.Atoi(v) - if innerErr != nil { - err = fmt.Errorf("parsing `x-ms-blob-content-length` header value %q: %+v", v, innerErr) - return + if err == nil { + if resp.Header != nil { + result.ContentType = resp.Header.Get("Content-Type") + result.ETag = resp.Header.Get("ETag") + + if v := resp.Header.Get("x-ms-blob-content-length"); v != "" { + i, innerErr := strconv.Atoi(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-blob-content-length` header value %q: %+v", v, innerErr) + return + } + + i64 := int64(i) + result.ContentLength = &i64 } - - i64 := int64(i) - result.ContentLength = &i64 } - } - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/lease_acquire.go b/storage/2023-11-03/blob/blobs/lease_acquire.go index bf81cb3..1c807c3 100644 --- a/storage/2023-11-03/blob/blobs/lease_acquire.go +++ b/storage/2023-11-03/blob/blobs/lease_acquire.go @@ -83,8 +83,10 @@ func (c Client) AcquireLease(ctx context.Context, containerName, blobName string if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { - result.LeaseID = resp.Header.Get("x-ms-lease-id") + if err == nil { + if resp.Response != nil && resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/lease_change.go b/storage/2023-11-03/blob/blobs/lease_change.go index 46ee080..d7f236d 100644 --- a/storage/2023-11-03/blob/blobs/lease_change.go +++ b/storage/2023-11-03/blob/blobs/lease_change.go @@ -70,8 +70,10 @@ func (c Client) ChangeLease(ctx context.Context, containerName, blobName string, if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { - result.LeaseID = resp.Header.Get("x-ms-lease-id") + if err == nil { + if resp.Response != nil && resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/properties_get.go b/storage/2023-11-03/blob/blobs/properties_get.go index 6ae254d..ba14343 100644 --- a/storage/2023-11-03/blob/blobs/properties_get.go +++ b/storage/2023-11-03/blob/blobs/properties_get.go @@ -200,68 +200,70 @@ func (c Client) GetProperties(ctx context.Context, containerName, blobName strin if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.AccessTier = AccessTier(resp.Header.Get("x-ms-access-tier")) - result.AccessTierChangeTime = resp.Header.Get("x-ms-access-tier-change-time") - result.ArchiveStatus = ArchiveStatus(resp.Header.Get("x-ms-archive-status")) - result.BlobCommittedBlockCount = resp.Header.Get("x-ms-blob-committed-block-count") - result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") - result.BlobType = BlobType(resp.Header.Get("x-ms-blob-type")) - result.CacheControl = resp.Header.Get("Cache-Control") - result.ContentDisposition = resp.Header.Get("Content-Disposition") - result.ContentEncoding = resp.Header.Get("Content-Encoding") - result.ContentLanguage = resp.Header.Get("Content-Language") - result.ContentMD5 = resp.Header.Get("Content-MD5") - result.ContentType = resp.Header.Get("Content-Type") - result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") - result.CopyDestinationSnapshot = resp.Header.Get("x-ms-copy-destination-snapshot") - result.CopyID = resp.Header.Get("x-ms-copy-id") - result.CopyProgress = resp.Header.Get("x-ms-copy-progress") - result.CopySource = resp.Header.Get("x-ms-copy-source") - result.CopyStatus = CopyStatus(resp.Header.Get("x-ms-copy-status")) - result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") - result.CreationTime = resp.Header.Get("x-ms-creation-time") - result.ETag = resp.Header.Get("Etag") - result.LastModified = resp.Header.Get("Last-Modified") - result.LeaseDuration = LeaseDuration(resp.Header.Get("x-ms-lease-duration")) - result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) - result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) - result.EncryptionScope = resp.Header.Get("x-ms-encryption-scope") - result.MetaData = metadata.ParseFromHeaders(resp.Header) - - if v := resp.Header.Get("x-ms-access-tier-inferred"); v != "" { - b, innerErr := strconv.ParseBool(v) - if innerErr != nil { - err = fmt.Errorf("parsing `x-ms-access-tier-inferred` header value %q: %s", v, innerErr) - return + if err == nil { + if resp.Header != nil { + result.AccessTier = AccessTier(resp.Header.Get("x-ms-access-tier")) + result.AccessTierChangeTime = resp.Header.Get("x-ms-access-tier-change-time") + result.ArchiveStatus = ArchiveStatus(resp.Header.Get("x-ms-archive-status")) + result.BlobCommittedBlockCount = resp.Header.Get("x-ms-blob-committed-block-count") + result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") + result.BlobType = BlobType(resp.Header.Get("x-ms-blob-type")) + result.CacheControl = resp.Header.Get("Cache-Control") + result.ContentDisposition = resp.Header.Get("Content-Disposition") + result.ContentEncoding = resp.Header.Get("Content-Encoding") + result.ContentLanguage = resp.Header.Get("Content-Language") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ContentType = resp.Header.Get("Content-Type") + result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") + result.CopyDestinationSnapshot = resp.Header.Get("x-ms-copy-destination-snapshot") + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyProgress = resp.Header.Get("x-ms-copy-progress") + result.CopySource = resp.Header.Get("x-ms-copy-source") + result.CopyStatus = CopyStatus(resp.Header.Get("x-ms-copy-status")) + result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") + result.CreationTime = resp.Header.Get("x-ms-creation-time") + result.ETag = resp.Header.Get("Etag") + result.LastModified = resp.Header.Get("Last-Modified") + result.LeaseDuration = LeaseDuration(resp.Header.Get("x-ms-lease-duration")) + result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) + result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) + result.EncryptionScope = resp.Header.Get("x-ms-encryption-scope") + result.MetaData = metadata.ParseFromHeaders(resp.Header) + + if v := resp.Header.Get("x-ms-access-tier-inferred"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-access-tier-inferred` header value %q: %s", v, innerErr) + return + } + result.AccessTierInferred = b } - result.AccessTierInferred = b - } - if v := resp.Header.Get("Content-Length"); v != "" { - i, innerErr := strconv.Atoi(v) - if innerErr != nil { - err = fmt.Errorf("parsing `Content-Length` header value %q: %s", v, innerErr) + if v := resp.Header.Get("Content-Length"); v != "" { + i, innerErr := strconv.Atoi(v) + if innerErr != nil { + err = fmt.Errorf("parsing `Content-Length` header value %q: %s", v, innerErr) + } + result.ContentLength = int64(i) } - result.ContentLength = int64(i) - } - if v := resp.Header.Get("x-ms-incremental-copy"); v != "" { - b, innerErr := strconv.ParseBool(v) - if innerErr != nil { - err = fmt.Errorf("parsing `x-ms-incremental-copy` header value %q: %s", v, innerErr) - return + if v := resp.Header.Get("x-ms-incremental-copy"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-incremental-copy` header value %q: %s", v, innerErr) + return + } + result.IncrementalCopy = b } - result.IncrementalCopy = b - } - if v := resp.Header.Get("x-ms-server-encrypted"); v != "" { - b, innerErr := strconv.ParseBool(v) - if innerErr != nil { - err = fmt.Errorf("parsing `x-ms-server-encrypted` header value %q: %s", v, innerErr) - return + if v := resp.Header.Get("x-ms-server-encrypted"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-server-encrypted` header value %q: %s", v, innerErr) + return + } + result.ServerEncrypted = b } - result.ServerEncrypted = b } } } diff --git a/storage/2023-11-03/blob/blobs/put_block_list.go b/storage/2023-11-03/blob/blobs/put_block_list.go index cf04af0..8ac5a83 100644 --- a/storage/2023-11-03/blob/blobs/put_block_list.go +++ b/storage/2023-11-03/blob/blobs/put_block_list.go @@ -89,10 +89,12 @@ func (c Client) PutBlockList(ctx context.Context, containerName, blobName string if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.ContentMD5 = resp.Header.Get("Content-MD5") - result.ETag = resp.Header.Get("ETag") - result.LastModified = resp.Header.Get("Last-Modified") + if err == nil { + if resp.Header != nil { + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ETag = resp.Header.Get("ETag") + result.LastModified = resp.Header.Get("Last-Modified") + } } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/put_block_url.go b/storage/2023-11-03/blob/blobs/put_block_url.go index 2b683d7..a9b5310 100644 --- a/storage/2023-11-03/blob/blobs/put_block_url.go +++ b/storage/2023-11-03/blob/blobs/put_block_url.go @@ -74,8 +74,10 @@ func (c Client) PutBlockFromURL(ctx context.Context, containerName, blobName str if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.ContentMD5 = resp.Header.Get("Content-MD5") + if err == nil { + if resp.Header != nil { + result.ContentMD5 = resp.Header.Get("Content-MD5") + } } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/put_page_update.go b/storage/2023-11-03/blob/blobs/put_page_update.go index 3294d46..acfc859 100644 --- a/storage/2023-11-03/blob/blobs/put_page_update.go +++ b/storage/2023-11-03/blob/blobs/put_page_update.go @@ -97,10 +97,12 @@ func (c Client) PutPageUpdate(ctx context.Context, containerName, blobName strin if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") - result.ContentMD5 = resp.Header.Get("Content-MD5") - result.LastModified = resp.Header.Get("Last-Modified") + if err == nil { + if resp.Header != nil { + result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.LastModified = resp.Header.Get("Last-Modified") + } } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/snapshot.go b/storage/2023-11-03/blob/blobs/snapshot.go index 18ddcd2..d925dc1 100644 --- a/storage/2023-11-03/blob/blobs/snapshot.go +++ b/storage/2023-11-03/blob/blobs/snapshot.go @@ -99,9 +99,11 @@ func (c Client) Snapshot(ctx context.Context, containerName, blobName string, in if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.ETag = resp.Header.Get("ETag") - result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") + if err == nil { + if resp.Header != nil { + result.ETag = resp.Header.Get("ETag") + result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") + } } } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/snapshot_get_properties.go b/storage/2023-11-03/blob/blobs/snapshot_get_properties.go index 59f3607..50a50a4 100644 --- a/storage/2023-11-03/blob/blobs/snapshot_get_properties.go +++ b/storage/2023-11-03/blob/blobs/snapshot_get_properties.go @@ -66,71 +66,73 @@ func (c Client) GetSnapshotProperties(ctx context.Context, containerName, blobNa if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.AccessTier = AccessTier(resp.Header.Get("x-ms-access-tier")) - result.AccessTierChangeTime = resp.Header.Get("x-ms-access-tier-change-time") - result.ArchiveStatus = ArchiveStatus(resp.Header.Get("x-ms-archive-status")) - result.BlobCommittedBlockCount = resp.Header.Get("x-ms-blob-committed-block-count") - result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") - result.BlobType = BlobType(resp.Header.Get("x-ms-blob-type")) - result.CacheControl = resp.Header.Get("Cache-Control") - result.ContentDisposition = resp.Header.Get("Content-Disposition") - result.ContentEncoding = resp.Header.Get("Content-Encoding") - result.ContentLanguage = resp.Header.Get("Content-Language") - result.ContentMD5 = resp.Header.Get("Content-MD5") - result.ContentType = resp.Header.Get("Content-Type") - result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") - result.CopyDestinationSnapshot = resp.Header.Get("x-ms-copy-destination-snapshot") - result.CopyID = resp.Header.Get("x-ms-copy-id") - result.CopyProgress = resp.Header.Get("x-ms-copy-progress") - result.CopySource = resp.Header.Get("x-ms-copy-source") - result.CopyStatus = CopyStatus(resp.Header.Get("x-ms-copy-status")) - result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") - result.CreationTime = resp.Header.Get("x-ms-creation-time") - result.ETag = resp.Header.Get("Etag") - result.LastModified = resp.Header.Get("Last-Modified") - result.LeaseDuration = LeaseDuration(resp.Header.Get("x-ms-lease-duration")) - result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) - result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) - result.MetaData = metadata.ParseFromHeaders(resp.Header) - - if v := resp.Header.Get("Content-Length"); v != "" { - i, innerErr := strconv.Atoi(v) - if innerErr != nil { - err = fmt.Errorf("parsing `Content-Length` header value %q: %+v", v, innerErr) + if err == nil { + if resp.Header != nil { + result.AccessTier = AccessTier(resp.Header.Get("x-ms-access-tier")) + result.AccessTierChangeTime = resp.Header.Get("x-ms-access-tier-change-time") + result.ArchiveStatus = ArchiveStatus(resp.Header.Get("x-ms-archive-status")) + result.BlobCommittedBlockCount = resp.Header.Get("x-ms-blob-committed-block-count") + result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") + result.BlobType = BlobType(resp.Header.Get("x-ms-blob-type")) + result.CacheControl = resp.Header.Get("Cache-Control") + result.ContentDisposition = resp.Header.Get("Content-Disposition") + result.ContentEncoding = resp.Header.Get("Content-Encoding") + result.ContentLanguage = resp.Header.Get("Content-Language") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ContentType = resp.Header.Get("Content-Type") + result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") + result.CopyDestinationSnapshot = resp.Header.Get("x-ms-copy-destination-snapshot") + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyProgress = resp.Header.Get("x-ms-copy-progress") + result.CopySource = resp.Header.Get("x-ms-copy-source") + result.CopyStatus = CopyStatus(resp.Header.Get("x-ms-copy-status")) + result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") + result.CreationTime = resp.Header.Get("x-ms-creation-time") + result.ETag = resp.Header.Get("Etag") + result.LastModified = resp.Header.Get("Last-Modified") + result.LeaseDuration = LeaseDuration(resp.Header.Get("x-ms-lease-duration")) + result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) + result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) + result.MetaData = metadata.ParseFromHeaders(resp.Header) + + if v := resp.Header.Get("Content-Length"); v != "" { + i, innerErr := strconv.Atoi(v) + if innerErr != nil { + err = fmt.Errorf("parsing `Content-Length` header value %q: %+v", v, innerErr) + } + + result.ContentLength = int64(i) } - result.ContentLength = int64(i) - } + if v := resp.Header.Get("x-ms-access-tier-inferred"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-access-tier-inferred` header value %q: %+v", v, innerErr) + return + } - if v := resp.Header.Get("x-ms-access-tier-inferred"); v != "" { - b, innerErr := strconv.ParseBool(v) - if innerErr != nil { - err = fmt.Errorf("parsing `x-ms-access-tier-inferred` header value %q: %+v", v, innerErr) - return + result.AccessTierInferred = b } - result.AccessTierInferred = b - } + if v := resp.Header.Get("x-ms-incremental-copy"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-incremental-copy` header value %q: %+v", v, innerErr) + return + } - if v := resp.Header.Get("x-ms-incremental-copy"); v != "" { - b, innerErr := strconv.ParseBool(v) - if innerErr != nil { - err = fmt.Errorf("parsing `x-ms-incremental-copy` header value %q: %+v", v, innerErr) - return + result.IncrementalCopy = b } - result.IncrementalCopy = b - } + if v := resp.Header.Get("x-ms-server-encrypted"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `\"x-ms-server-encrypted` header value %q: %+v", v, innerErr) + return + } - if v := resp.Header.Get("x-ms-server-encrypted"); v != "" { - b, innerErr := strconv.ParseBool(v) - if innerErr != nil { - err = fmt.Errorf("parsing `\"x-ms-server-encrypted` header value %q: %+v", v, innerErr) - return + result.ServerEncrypted = b } - - result.ServerEncrypted = b } } } diff --git a/storage/2023-11-03/blob/containers/get_properties.go b/storage/2023-11-03/blob/containers/get_properties.go index dab47b4..89d6e67 100644 --- a/storage/2023-11-03/blob/containers/get_properties.go +++ b/storage/2023-11-03/blob/containers/get_properties.go @@ -50,29 +50,31 @@ func (c Client) GetProperties(ctx context.Context, containerName string, input G if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.DefaultEncryptionScope = resp.Header.Get("x-ms-default-encryption-scope") - result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) - result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) - if result.LeaseStatus == Locked { - duration := LeaseDuration(resp.Header.Get("x-ms-lease-duration")) - result.LeaseDuration = &duration + if err == nil { + if resp.Header != nil { + result.DefaultEncryptionScope = resp.Header.Get("x-ms-default-encryption-scope") + result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) + result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) + if result.LeaseStatus == Locked { + duration := LeaseDuration(resp.Header.Get("x-ms-lease-duration")) + result.LeaseDuration = &duration + } + + // If this header is not returned in the response, the container is private to the account owner. + accessLevel := resp.Header.Get("x-ms-blob-public-access") + if accessLevel != "" { + result.AccessLevel = AccessLevel(accessLevel) + } else { + result.AccessLevel = Private + } + + // we can't necessarily use strconv.ParseBool here since this could be nil (only in some API versions) + result.EncryptionScopeOverrideDisabled = strings.EqualFold(resp.Header.Get("x-ms-deny-encryption-scope-override"), "true") + result.HasImmutabilityPolicy = strings.EqualFold(resp.Header.Get("x-ms-has-immutability-policy"), "true") + result.HasLegalHold = strings.EqualFold(resp.Header.Get("x-ms-has-legal-hold"), "true") + + result.MetaData = metadata.ParseFromHeaders(resp.Header) } - - // If this header is not returned in the response, the container is private to the account owner. - accessLevel := resp.Header.Get("x-ms-blob-public-access") - if accessLevel != "" { - result.AccessLevel = AccessLevel(accessLevel) - } else { - result.AccessLevel = Private - } - - // we can't necessarily use strconv.ParseBool here since this could be nil (only in some API versions) - result.EncryptionScopeOverrideDisabled = strings.EqualFold(resp.Header.Get("x-ms-deny-encryption-scope-override"), "true") - result.HasImmutabilityPolicy = strings.EqualFold(resp.Header.Get("x-ms-has-immutability-policy"), "true") - result.HasLegalHold = strings.EqualFold(resp.Header.Get("x-ms-has-legal-hold"), "true") - - result.MetaData = metadata.ParseFromHeaders(resp.Header) } } if err != nil { diff --git a/storage/2023-11-03/blob/containers/lease_acquire.go b/storage/2023-11-03/blob/containers/lease_acquire.go index 1a2fc9d..102e689 100644 --- a/storage/2023-11-03/blob/containers/lease_acquire.go +++ b/storage/2023-11-03/blob/containers/lease_acquire.go @@ -60,8 +60,10 @@ func (c Client) AcquireLease(ctx context.Context, containerName string, input Ac if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.LeaseID = resp.Header.Get("x-ms-lease-id") + if err == nil { + if resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } } } if err != nil { diff --git a/storage/2023-11-03/blob/containers/lease_break.go b/storage/2023-11-03/blob/containers/lease_break.go index db91393..356068e 100644 --- a/storage/2023-11-03/blob/containers/lease_break.go +++ b/storage/2023-11-03/blob/containers/lease_break.go @@ -67,10 +67,12 @@ func (c Client) BreakLease(ctx context.Context, containerName string, input Brea if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - if leaseTimeRaw := resp.Header.Get("x-ms-lease-time"); leaseTimeRaw != "" { - if leaseTime, err := strconv.Atoi(leaseTimeRaw); err == nil { - result.LeaseTime = leaseTime + if err == nil { + if resp.Header != nil { + if leaseTimeRaw := resp.Header.Get("x-ms-lease-time"); leaseTimeRaw != "" { + if leaseTime, err := strconv.Atoi(leaseTimeRaw); err == nil { + result.LeaseTime = leaseTime + } } } } diff --git a/storage/2023-11-03/blob/containers/lease_change.go b/storage/2023-11-03/blob/containers/lease_change.go index fe0ae9b..89d5e50 100644 --- a/storage/2023-11-03/blob/containers/lease_change.go +++ b/storage/2023-11-03/blob/containers/lease_change.go @@ -62,8 +62,10 @@ func (c Client) ChangeLease(ctx context.Context, containerName string, input Cha if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.LeaseID = resp.Header.Get("x-ms-lease-id") + if err == nil { + if resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } } } if err != nil { diff --git a/storage/2023-11-03/blob/containers/list_blobs.go b/storage/2023-11-03/blob/containers/list_blobs.go index 009b77e..c6d0546 100644 --- a/storage/2023-11-03/blob/containers/list_blobs.go +++ b/storage/2023-11-03/blob/containers/list_blobs.go @@ -117,10 +117,12 @@ func (c Client) ListBlobs(ctx context.Context, containerName string, input ListB if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/datalakestore/filesystems/properties_get.go b/storage/2023-11-03/datalakestore/filesystems/properties_get.go index eae1c95..5bd7f10 100644 --- a/storage/2023-11-03/datalakestore/filesystems/properties_get.go +++ b/storage/2023-11-03/datalakestore/filesystems/properties_get.go @@ -53,18 +53,20 @@ func (c Client) GetProperties(ctx context.Context, fileSystemName string) (resul if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.DefaultEncryptionScope = resp.Header.Get("x-ms-default-encryption-scope") + if err == nil { + if resp.Header != nil { + result.DefaultEncryptionScope = resp.Header.Get("x-ms-default-encryption-scope") - propertiesRaw := resp.Header.Get("x-ms-properties") - var properties *map[string]string - properties, err = parseProperties(propertiesRaw) - if err != nil { - return - } + propertiesRaw := resp.Header.Get("x-ms-properties") + var properties *map[string]string + properties, err = parseProperties(propertiesRaw) + if err != nil { + return + } - result.Properties = *properties - result.NamespaceEnabled = strings.EqualFold(resp.Header.Get("x-ms-namespace-enabled"), "true") + result.Properties = *properties + result.NamespaceEnabled = strings.EqualFold(resp.Header.Get("x-ms-namespace-enabled"), "true") + } } } if err != nil { diff --git a/storage/2023-11-03/datalakestore/paths/properties_get.go b/storage/2023-11-03/datalakestore/paths/properties_get.go index 9f620e8..c8835ee 100644 --- a/storage/2023-11-03/datalakestore/paths/properties_get.go +++ b/storage/2023-11-03/datalakestore/paths/properties_get.go @@ -65,21 +65,23 @@ func (c Client) GetProperties(ctx context.Context, fileSystemName string, path s if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.ResourceType = PathResource(resp.Header.Get("x-ms-resource-type")) - result.ETag = resp.Header.Get("ETag") - - if lastModifiedRaw := resp.Header.Get("Last-Modified"); lastModifiedRaw != "" { - lastModified, err := time.Parse(time.RFC1123, lastModifiedRaw) - if err != nil { - return GetPropertiesResponse{}, err + if err == nil { + if resp.Header != nil { + result.ResourceType = PathResource(resp.Header.Get("x-ms-resource-type")) + result.ETag = resp.Header.Get("ETag") + + if lastModifiedRaw := resp.Header.Get("Last-Modified"); lastModifiedRaw != "" { + lastModified, err := time.Parse(time.RFC1123, lastModifiedRaw) + if err != nil { + return GetPropertiesResponse{}, err + } + result.LastModified = lastModified } - result.LastModified = lastModified - } - result.Owner = resp.Header.Get("x-ms-owner") - result.Group = resp.Header.Get("x-ms-group") - result.ACL = resp.Header.Get("x-ms-acl") + result.Owner = resp.Header.Get("x-ms-owner") + result.Group = resp.Header.Get("x-ms-group") + result.ACL = resp.Header.Get("x-ms-acl") + } } } if err != nil { diff --git a/storage/2023-11-03/file/directories/get.go b/storage/2023-11-03/file/directories/get.go index b49444a..8d29b77 100644 --- a/storage/2023-11-03/file/directories/get.go +++ b/storage/2023-11-03/file/directories/get.go @@ -60,9 +60,11 @@ func (c Client) Get(ctx context.Context, shareName, path string) (result GetResp if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.DirectoryMetaDataEncrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") - result.MetaData = metadata.ParseFromHeaders(resp.Header) + if err == nil { + if resp.Header != nil { + result.DirectoryMetaDataEncrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } } } if err != nil { diff --git a/storage/2023-11-03/file/directories/metadata_get.go b/storage/2023-11-03/file/directories/metadata_get.go index aa6e0ac..5ebcae1 100644 --- a/storage/2023-11-03/file/directories/metadata_get.go +++ b/storage/2023-11-03/file/directories/metadata_get.go @@ -55,8 +55,10 @@ func (c Client) GetMetaData(ctx context.Context, shareName, path string) (result if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) + if err == nil { + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } } } if err != nil { diff --git a/storage/2023-11-03/file/files/copy.go b/storage/2023-11-03/file/files/copy.go index 2562443..dacfd26 100644 --- a/storage/2023-11-03/file/files/copy.go +++ b/storage/2023-11-03/file/files/copy.go @@ -89,9 +89,11 @@ func (c Client) Copy(ctx context.Context, shareName, path, fileName string, inpu if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.CopyID = resp.Header.Get("x-ms-copy-id") - result.CopySuccess = resp.Header.Get("x-ms-copy-status") + if err == nil { + if resp.Header != nil { + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopySuccess = resp.Header.Get("x-ms-copy-status") + } } } if err != nil { diff --git a/storage/2023-11-03/file/files/metadata_get.go b/storage/2023-11-03/file/files/metadata_get.go index ca88c3c..3df483e 100644 --- a/storage/2023-11-03/file/files/metadata_get.go +++ b/storage/2023-11-03/file/files/metadata_get.go @@ -59,8 +59,10 @@ func (c Client) GetMetaData(ctx context.Context, shareName, path, fileName strin if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) + if err == nil { + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } } } if err != nil { diff --git a/storage/2023-11-03/file/files/properties_get.go b/storage/2023-11-03/file/files/properties_get.go index fa5fbc3..488d205 100644 --- a/storage/2023-11-03/file/files/properties_get.go +++ b/storage/2023-11-03/file/files/properties_get.go @@ -74,32 +74,34 @@ func (c Client) GetProperties(ctx context.Context, shareName, path, fileName str if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.CacheControl = resp.Header.Get("Cache-Control") - result.ContentDisposition = resp.Header.Get("Content-Disposition") - result.ContentEncoding = resp.Header.Get("Content-Encoding") - result.ContentLanguage = resp.Header.Get("Content-Language") - result.ContentMD5 = resp.Header.Get("Content-MD5") - result.ContentType = resp.Header.Get("Content-Type") - result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") - result.CopyID = resp.Header.Get("x-ms-copy-id") - result.CopyProgress = resp.Header.Get("x-ms-copy-progress") - result.CopySource = resp.Header.Get("x-ms-copy-source") - result.CopyStatus = resp.Header.Get("x-ms-copy-status") - result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") - result.Encrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") - result.MetaData = metadata.ParseFromHeaders(resp.Header) + if err == nil { + if resp.Header != nil { + result.CacheControl = resp.Header.Get("Cache-Control") + result.ContentDisposition = resp.Header.Get("Content-Disposition") + result.ContentEncoding = resp.Header.Get("Content-Encoding") + result.ContentLanguage = resp.Header.Get("Content-Language") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ContentType = resp.Header.Get("Content-Type") + result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyProgress = resp.Header.Get("x-ms-copy-progress") + result.CopySource = resp.Header.Get("x-ms-copy-source") + result.CopyStatus = resp.Header.Get("x-ms-copy-status") + result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") + result.Encrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") + result.MetaData = metadata.ParseFromHeaders(resp.Header) - contentLengthRaw := resp.Header.Get("Content-Length") - if contentLengthRaw != "" { - var contentLength int - contentLength, err = strconv.Atoi(contentLengthRaw) - if err != nil { - err = fmt.Errorf("parsing `Content-Length` header value %q: %s", contentLengthRaw, err) - return + contentLengthRaw := resp.Header.Get("Content-Length") + if contentLengthRaw != "" { + var contentLength int + contentLength, err = strconv.Atoi(contentLengthRaw) + if err != nil { + err = fmt.Errorf("parsing `Content-Length` header value %q: %s", contentLengthRaw, err) + return + } + contentLengthI64 := int64(contentLength) + result.ContentLength = &contentLengthI64 } - contentLengthI64 := int64(contentLength) - result.ContentLength = &contentLengthI64 } } } diff --git a/storage/2023-11-03/file/files/range_get.go b/storage/2023-11-03/file/files/range_get.go index 7d2d4c5..3910739 100644 --- a/storage/2023-11-03/file/files/range_get.go +++ b/storage/2023-11-03/file/files/range_get.go @@ -87,16 +87,18 @@ func (c Client) GetByteRange(ctx context.Context, shareName, path, fileName stri if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - result.Contents = &[]byte{} - if resp.Body != nil { - respBody, err := io.ReadAll(resp.Body) - defer resp.Body.Close() - if err != nil { - return result, fmt.Errorf("could not parse response body") - } - - if respBody != nil { - result.Contents = pointer.To(respBody) + if err == nil { + result.Contents = &[]byte{} + if resp.Body != nil { + respBody, err := io.ReadAll(resp.Body) + defer resp.Body.Close() + if err != nil { + return result, fmt.Errorf("could not parse response body") + } + + if respBody != nil { + result.Contents = pointer.To(respBody) + } } } } diff --git a/storage/2023-11-03/file/files/ranges_list.go b/storage/2023-11-03/file/files/ranges_list.go index d6b1df4..91a3a25 100644 --- a/storage/2023-11-03/file/files/ranges_list.go +++ b/storage/2023-11-03/file/files/ranges_list.go @@ -68,10 +68,12 @@ func (c Client) ListRanges(ctx context.Context, shareName, path, fileName string if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/file/shares/acl_get.go b/storage/2023-11-03/file/shares/acl_get.go index 2c9c5ea..8231161 100644 --- a/storage/2023-11-03/file/shares/acl_get.go +++ b/storage/2023-11-03/file/shares/acl_get.go @@ -48,10 +48,12 @@ func (c Client) GetACL(ctx context.Context, shareName string) (result GetACLResu if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/file/shares/metadata_get.go b/storage/2023-11-03/file/shares/metadata_get.go index ae34b3d..c659656 100644 --- a/storage/2023-11-03/file/shares/metadata_get.go +++ b/storage/2023-11-03/file/shares/metadata_get.go @@ -47,8 +47,10 @@ func (c Client) GetMetaData(ctx context.Context, shareName string) (result GetMe if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) + if err == nil { + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } } } if err != nil { diff --git a/storage/2023-11-03/file/shares/properties_get.go b/storage/2023-11-03/file/shares/properties_get.go index d33b471..dfdf28c 100644 --- a/storage/2023-11-03/file/shares/properties_get.go +++ b/storage/2023-11-03/file/shares/properties_get.go @@ -53,29 +53,31 @@ func (c Client) GetProperties(ctx context.Context, shareName string) (result Get if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) + if err == nil { + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) - quotaRaw := resp.Header.Get("x-ms-share-quota") - if quotaRaw != "" { - quota, e := strconv.Atoi(quotaRaw) - if e != nil { - err = fmt.Errorf("error converting %q to an integer: %s", quotaRaw, err) - return + quotaRaw := resp.Header.Get("x-ms-share-quota") + if quotaRaw != "" { + quota, e := strconv.Atoi(quotaRaw) + if e != nil { + err = fmt.Errorf("error converting %q to an integer: %s", quotaRaw, err) + return + } + result.QuotaInGB = quota } - result.QuotaInGB = quota - } - protocol := SMB - if protocolRaw := resp.Header.Get("x-ms-enabled-protocols"); protocolRaw != "" { - protocol = ShareProtocol(protocolRaw) - } + protocol := SMB + if protocolRaw := resp.Header.Get("x-ms-enabled-protocols"); protocolRaw != "" { + protocol = ShareProtocol(protocolRaw) + } - if accessTierRaw := resp.Header.Get("x-ms-access-tier"); accessTierRaw != "" { - tier := AccessTier(accessTierRaw) - result.AccessTier = &tier + if accessTierRaw := resp.Header.Get("x-ms-access-tier"); accessTierRaw != "" { + tier := AccessTier(accessTierRaw) + result.AccessTier = &tier + } + result.EnabledProtocol = protocol } - result.EnabledProtocol = protocol } } if err != nil { diff --git a/storage/2023-11-03/file/shares/snapshot_create.go b/storage/2023-11-03/file/shares/snapshot_create.go index 6de6e43..d898232 100644 --- a/storage/2023-11-03/file/shares/snapshot_create.go +++ b/storage/2023-11-03/file/shares/snapshot_create.go @@ -67,8 +67,10 @@ func (c Client) CreateSnapshot(ctx context.Context, shareName string, input Crea if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") + if err == nil { + if resp.Header != nil { + result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") + } } } if err != nil { diff --git a/storage/2023-11-03/file/shares/snapshot_get.go b/storage/2023-11-03/file/shares/snapshot_get.go index cde1d2f..bd2408a 100644 --- a/storage/2023-11-03/file/shares/snapshot_get.go +++ b/storage/2023-11-03/file/shares/snapshot_get.go @@ -61,8 +61,10 @@ func (c Client) GetSnapshot(ctx context.Context, shareName string, input GetSnap if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) + if err == nil { + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } } } if err != nil { diff --git a/storage/2023-11-03/queue/messages/get.go b/storage/2023-11-03/queue/messages/get.go index 740af86..6d2dfaf 100644 --- a/storage/2023-11-03/queue/messages/get.go +++ b/storage/2023-11-03/queue/messages/get.go @@ -65,10 +65,12 @@ func (c Client) Get(ctx context.Context, queueName string, input GetInput) (resu if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/queue/messages/peek.go b/storage/2023-11-03/queue/messages/peek.go index dadc526..f417faf 100644 --- a/storage/2023-11-03/queue/messages/peek.go +++ b/storage/2023-11-03/queue/messages/peek.go @@ -55,10 +55,12 @@ func (c Client) Peek(ctx context.Context, queueName string, input PeekInput) (re if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/queue/messages/put.go b/storage/2023-11-03/queue/messages/put.go index 8cb247a..d8eebc3 100644 --- a/storage/2023-11-03/queue/messages/put.go +++ b/storage/2023-11-03/queue/messages/put.go @@ -77,10 +77,12 @@ func (c Client) Put(ctx context.Context, queueName string, input PutInput) (resu if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/queue/queues/metadata_get.go b/storage/2023-11-03/queue/queues/metadata_get.go index dc70d8e..a05f851 100644 --- a/storage/2023-11-03/queue/queues/metadata_get.go +++ b/storage/2023-11-03/queue/queues/metadata_get.go @@ -49,8 +49,10 @@ func (c Client) GetMetaData(ctx context.Context, queueName string) (result GetMe if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) + if err == nil { + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } } } if err != nil { diff --git a/storage/2023-11-03/queue/queues/properties_get.go b/storage/2023-11-03/queue/queues/properties_get.go index ec250a5..13ee273 100644 --- a/storage/2023-11-03/queue/queues/properties_get.go +++ b/storage/2023-11-03/queue/queues/properties_get.go @@ -38,10 +38,12 @@ func (c Client) GetServiceProperties(ctx context.Context) (result GetStorageServ if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/table/entities/get.go b/storage/2023-11-03/table/entities/get.go index cb92d8b..1827034 100644 --- a/storage/2023-11-03/table/entities/get.go +++ b/storage/2023-11-03/table/entities/get.go @@ -59,10 +59,12 @@ func (c Client) Get(ctx context.Context, tableName string, input GetEntityInput) if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result.Entity) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result.Entity) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/table/entities/query.go b/storage/2023-11-03/table/entities/query.go index 3e3d75a..dd13b2a 100644 --- a/storage/2023-11-03/table/entities/query.go +++ b/storage/2023-11-03/table/entities/query.go @@ -87,10 +87,12 @@ func (c Client) Query(ctx context.Context, tableName string, input QueryEntities if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/table/tables/acl_get.go b/storage/2023-11-03/table/tables/acl_get.go index dc34659..dc3e0e6 100644 --- a/storage/2023-11-03/table/tables/acl_get.go +++ b/storage/2023-11-03/table/tables/acl_get.go @@ -44,10 +44,12 @@ func (c Client) GetACL(ctx context.Context, tableName string) (result GetACLResp if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil { diff --git a/storage/2023-11-03/table/tables/query.go b/storage/2023-11-03/table/tables/query.go index 92134e9..5a7dfa9 100644 --- a/storage/2023-11-03/table/tables/query.go +++ b/storage/2023-11-03/table/tables/query.go @@ -45,10 +45,12 @@ func (c Client) Query(ctx context.Context, input QueryInput) (result GetResponse if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - err = resp.Unmarshal(&result) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + if err == nil { + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } } } if err != nil {