Skip to content

Commit

Permalink
[Blob][Datalake] Generated Blob & Datalake using newest autorest vers…
Browse files Browse the repository at this point in the history
…ion (Azure#15393)

* Generated using newest autorest version

* readded version

* readded StorageErrorException

* added more missing imports for storageErrorException

* added more missing imports for storageErrorException

* use http_response

* eradicated StorageErrorException

* added http_response to deserialize

* added http_response location mode

* added body to params since it got repositioned

* made more changes

* added extra check

* fixed sync test for retention policy

* fixed async rentention policy test

* fixed ci for blobs

* generated for datalake using new gen

* api versioning fix

* removed storage error excep

* fixed append data bug

* fixed all failing tests for datalake

* fixed all failing tests for datalake

* linter

* fixed linter

* fixed linter

* removed cls in datalake list paths

* removed the cls method from deserialize

* added version id
  • Loading branch information
tasherif-msft authored and rakshith91 committed Jan 8, 2021
1 parent 9e72fde commit 79b4d5a
Show file tree
Hide file tree
Showing 108 changed files with 23,551 additions and 22,709 deletions.
73 changes: 37 additions & 36 deletions sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import six
from azure.core.tracing.decorator import distributed_trace
from azure.core.exceptions import ResourceNotFoundError
from azure.core.exceptions import ResourceNotFoundError, HttpResponseError

from ._shared import encode_base64
from ._shared.base_client import StorageAccountHostsMixin, parse_connection_str, parse_query
Expand All @@ -28,14 +28,13 @@
add_metadata_headers, get_length, read_length,
validate_and_format_range_headers)
from ._shared.response_handlers import return_response_headers, process_storage_error, return_headers_and_deserialized
from ._generated import AzureBlobStorage, VERSION
from ._generated import AzureBlobStorage
from ._generated.models import ( # pylint: disable=unused-import
DeleteSnapshotsOptionType,
BlobHTTPHeaders,
BlockLookupList,
AppendPositionAccessConditions,
SequenceNumberAccessConditions,
StorageErrorException,
QueryRequest,
CpkInfo)
from ._serialize import (
Expand Down Expand Up @@ -165,7 +164,8 @@ def __init__(
self._query_str, credential = self._format_query_string(sas_token, credential, snapshot=self.snapshot)
super(BlobClient, self).__init__(parsed_url, service='blob', credential=credential, **kwargs)
self._client = AzureBlobStorage(self.url, pipeline=self._pipeline)
self._client._config.version = get_api_version(kwargs, VERSION) # pylint: disable=protected-access
default_api_version = self._client._config.version # pylint: disable=protected-access
self._client._config.version = get_api_version(kwargs, default_api_version) # pylint: disable=protected-access

def _format_url(self, hostname):
container_name = self.container_name
Expand Down Expand Up @@ -316,7 +316,7 @@ def get_account_information(self, **kwargs):
"""
try:
return self._client.blob.get_account_info(cls=return_response_headers, **kwargs) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _upload_blob_options( # pylint:disable=too-many-statements
Expand Down Expand Up @@ -543,7 +543,7 @@ def upload_blob_from_url(self, source_url, **kwargs):
**kwargs)
try:
return self._client.block_blob.put_blob_from_url(**options)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

@distributed_trace
Expand Down Expand Up @@ -940,7 +940,7 @@ def query_blob(self, query_expression, **kwargs):
options, delimiter = self._quick_query_options(query_expression, **kwargs)
try:
headers, raw_response_body = self._client.blob.query(**options)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)
return BlobQueryReader(
name=self.blob_name,
Expand Down Expand Up @@ -975,6 +975,7 @@ def _delete_blob_options(self, delete_snapshots=False, **kwargs):
options = self._generic_delete_blob_options(delete_snapshots, **kwargs)
options['snapshot'] = self.snapshot
options['version_id'] = kwargs.pop('version_id', None)
options['blob_delete_type'] = kwargs.pop('blob_delete_type', None)
return options

@distributed_trace
Expand Down Expand Up @@ -1048,7 +1049,7 @@ def delete_blob(self, delete_snapshots=False, **kwargs):
options = self._delete_blob_options(delete_snapshots=delete_snapshots, **kwargs)
try:
self._client.blob.delete(**options)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

@distributed_trace
Expand All @@ -1074,7 +1075,7 @@ def undelete_blob(self, **kwargs):
"""
try:
self._client.blob.undelete(timeout=kwargs.pop('timeout', None), **kwargs)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

@distributed_trace()
Expand All @@ -1096,7 +1097,7 @@ def exists(self, **kwargs):
snapshot=self.snapshot,
**kwargs)
return True
except StorageErrorException as error:
except HttpResponseError as error:
try:
process_storage_error(error)
except ResourceNotFoundError:
Expand Down Expand Up @@ -1181,7 +1182,7 @@ def get_blob_properties(self, **kwargs):
cls=kwargs.pop('cls', None) or deserialize_blob_properties,
cpk_info=cpk_info,
**kwargs)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)
blob_props.name = self.blob_name
if isinstance(blob_props, BlobProperties):
Expand Down Expand Up @@ -1257,7 +1258,7 @@ def set_http_headers(self, content_settings=None, **kwargs):
options = self._set_http_headers_options(content_settings=content_settings, **kwargs)
try:
return self._client.blob.set_http_headers(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _set_blob_metadata_options(self, metadata=None, **kwargs):
Expand Down Expand Up @@ -1343,7 +1344,7 @@ def set_blob_metadata(self, metadata=None, **kwargs):
options = self._set_blob_metadata_options(metadata=metadata, **kwargs)
try:
return self._client.blob.set_metadata(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _create_page_blob_options( # type: ignore
Expand Down Expand Up @@ -1490,7 +1491,7 @@ def create_page_blob( # type: ignore
**kwargs)
try:
return self._client.page_blob.create(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _create_append_blob_options(self, content_settings=None, metadata=None, **kwargs):
Expand Down Expand Up @@ -1602,7 +1603,7 @@ def create_append_blob(self, content_settings=None, metadata=None, **kwargs):
**kwargs)
try:
return self._client.append_blob.create(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _create_snapshot_options(self, metadata=None, **kwargs):
Expand Down Expand Up @@ -1703,7 +1704,7 @@ def create_snapshot(self, metadata=None, **kwargs):
options = self._create_snapshot_options(metadata=metadata, **kwargs)
try:
return self._client.blob.create_snapshot(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _start_copy_from_url_options(self, source_url, metadata=None, incremental_copy=False, **kwargs):
Expand Down Expand Up @@ -1899,7 +1900,7 @@ def start_copy_from_url(self, source_url, metadata=None, incremental_copy=False,
if incremental_copy:
return self._client.page_blob.copy_incremental(**options)
return self._client.blob.start_copy_from_url(**options)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _abort_copy_options(self, copy_id, **kwargs):
Expand Down Expand Up @@ -1945,7 +1946,7 @@ def abort_copy(self, copy_id, **kwargs):
options = self._abort_copy_options(copy_id, **kwargs)
try:
self._client.blob.abort_copy_from_url(**options)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

@distributed_trace
Expand Down Expand Up @@ -2057,7 +2058,7 @@ def set_standard_blob_tier(self, standard_blob_tier, **kwargs):
modified_access_conditions=mod_conditions,
lease_access_conditions=access_conditions,
**kwargs)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _stage_block_options(
Expand Down Expand Up @@ -2160,7 +2161,7 @@ def stage_block(
**kwargs)
try:
return self._client.block_blob.stage_block(**options)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _stage_block_from_url_options(
Expand Down Expand Up @@ -2260,7 +2261,7 @@ def stage_block_from_url(
**kwargs)
try:
return self._client.block_blob.stage_block_from_url(**options)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _get_block_list_result(self, blocks):
Expand Down Expand Up @@ -2307,7 +2308,7 @@ def get_block_list(self, block_list_type="committed", **kwargs):
lease_access_conditions=access_conditions,
modified_access_conditions=mod_conditions,
**kwargs)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)
return self._get_block_list_result(blocks)

Expand Down Expand Up @@ -2466,7 +2467,7 @@ def commit_block_list( # type: ignore
**kwargs)
try:
return self._client.block_blob.commit_block_list(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

@distributed_trace
Expand Down Expand Up @@ -2506,7 +2507,7 @@ def set_premium_page_blob_tier(self, premium_page_blob_tier, **kwargs):
lease_access_conditions=access_conditions,
modified_access_conditions=mod_conditions,
**kwargs)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _set_blob_tags_options(self, tags=None, **kwargs):
Expand Down Expand Up @@ -2565,7 +2566,7 @@ def set_blob_tags(self, tags=None, **kwargs):
options = self._set_blob_tags_options(tags=tags, **kwargs)
try:
return self._client.blob.set_tags(**options)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _get_blob_tags_options(self, **kwargs):
Expand Down Expand Up @@ -2609,7 +2610,7 @@ def get_blob_tags(self, **kwargs):
try:
_, tags = self._client.blob.get_tags(**options)
return parse_tags(tags) # pylint: disable=protected-access
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _get_page_ranges_options( # type: ignore
Expand Down Expand Up @@ -2718,7 +2719,7 @@ def get_page_ranges( # type: ignore
ranges = self._client.page_blob.get_page_ranges_diff(**options)
else:
ranges = self._client.page_blob.get_page_ranges(**options)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)
return get_page_ranges_result(ranges)

Expand Down Expand Up @@ -2791,7 +2792,7 @@ def get_page_range_diff_for_managed_disk(
**kwargs)
try:
ranges = self._client.page_blob.get_page_ranges_diff(**options)
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)
return get_page_ranges_result(ranges)

Expand Down Expand Up @@ -2859,7 +2860,7 @@ def set_sequence_number(self, sequence_number_action, sequence_number=None, **kw
sequence_number_action, sequence_number=sequence_number, **kwargs)
try:
return self._client.page_blob.update_sequence_number(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _resize_blob_options(self, size, **kwargs):
Expand Down Expand Up @@ -2936,7 +2937,7 @@ def resize_blob(self, size, **kwargs):
options = self._resize_blob_options(size, **kwargs)
try:
return self._client.page_blob.resize(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _upload_page_options( # type: ignore
Expand Down Expand Up @@ -3081,7 +3082,7 @@ def upload_page( # type: ignore
**kwargs)
try:
return self._client.page_blob.upload_pages(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _upload_pages_from_url_options( # type: ignore
Expand Down Expand Up @@ -3251,7 +3252,7 @@ def upload_pages_from_url(self, source_url, # type: str
)
try:
return self._client.page_blob.upload_pages_from_url(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _clear_page_options(self, offset, length, **kwargs):
Expand Down Expand Up @@ -3356,7 +3357,7 @@ def clear_page(self, offset, length, **kwargs):
options = self._clear_page_options(offset, length, **kwargs)
try:
return self._client.page_blob.clear_pages(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _append_block_options( # type: ignore
Expand Down Expand Up @@ -3500,7 +3501,7 @@ def append_block( # type: ignore
)
try:
return self._client.append_blob.append_block(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _append_block_from_url_options( # type: ignore
Expand Down Expand Up @@ -3661,7 +3662,7 @@ def append_block_from_url(self, copy_source_url, # type: str
)
try:
return self._client.append_blob.append_block_from_url(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)

def _seal_append_blob_options(self, **kwargs):
Expand Down Expand Up @@ -3729,5 +3730,5 @@ def seal_append_blob(self, **kwargs):
options = self._seal_append_blob_options(**kwargs)
try:
return self._client.append_blob.seal(**options) # type: ignore
except StorageErrorException as error:
except HttpResponseError as error:
process_storage_error(error)
Loading

0 comments on commit 79b4d5a

Please sign in to comment.