Skip to content

Commit

Permalink
[Queues] Generated Queues using newest autorest version (#16148)
Browse files Browse the repository at this point in the history
* generated and removed StorageErrorException

* fixed all failing tests

* fixed failing test

* fixed failing test

* removed import
  • Loading branch information
tasherif-msft authored Jan 18, 2021
1 parent c47cdc3 commit 1ca37b4
Show file tree
Hide file tree
Showing 39 changed files with 3,153 additions and 2,894 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


def deserialize_metadata(response, obj, headers):
raw_metadata = {k: v for k, v in response.headers.items() if k.startswith("x-ms-meta-")}
raw_metadata = {k: v for k, v in response.http_response.headers.items() if k.startswith("x-ms-meta-")}
return {k[10:]: v for k, v in raw_metadata.items()}


Expand All @@ -26,6 +26,7 @@ def deserialize_queue_properties(response, obj, headers):


def deserialize_queue_creation(response, obj, headers):
response = response.http_response
if response.status_code == 204:
error_code = StorageErrorCode.queue_already_exists
error = ResourceExistsError(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._azure_queue_storage import AzureQueueStorage
__all__ = ['AzureQueueStorage']

from .version import VERSION

__version__ = VERSION

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import TYPE_CHECKING

from azure.core import PipelineClient
from msrest import Serializer, Deserializer
from msrest import Deserializer, Serializer

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from ._configuration import AzureQueueStorageConfiguration
from azure.core.exceptions import map_error
from .operations import ServiceOperations
from .operations import QueueOperations
from .operations import MessagesOperations
Expand All @@ -22,32 +24,33 @@


class AzureQueueStorage(object):
"""AzureQueueStorage
"""AzureQueueStorage.
:ivar service: Service operations
:ivar service: ServiceOperations operations
:vartype service: azure.storage.queue.operations.ServiceOperations
:ivar queue: Queue operations
:ivar queue: QueueOperations operations
:vartype queue: azure.storage.queue.operations.QueueOperations
:ivar messages: Messages operations
:ivar messages: MessagesOperations operations
:vartype messages: azure.storage.queue.operations.MessagesOperations
:ivar message_id: MessageId operations
:ivar message_id: MessageIdOperations operations
:vartype message_id: azure.storage.queue.operations.MessageIdOperations
:param url: The URL of the service account, queue or message that is the
targe of the desired operation.
:param url: The URL of the service account, queue or message that is the targe of the desired operation.
:type url: str
"""

def __init__(self, url, **kwargs):

def __init__(
self,
url, # type: str
**kwargs # type: Any
):
# type: (...) -> None
base_url = '{url}'
self._config = AzureQueueStorageConfiguration(url, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = '2018-03-28'
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)

self.service = ServiceOperations(
Expand All @@ -60,9 +63,14 @@ def __init__(self, url, **kwargs):
self._client, self._config, self._serialize, self._deserialize)

def close(self):
# type: () -> None
self._client.close()

def __enter__(self):
# type: () -> AzureQueueStorage
self._client.__enter__()
return self

def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -1,52 +1,58 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from .version import VERSION
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

VERSION = "unknown"

class AzureQueueStorageConfiguration(Configuration):
"""Configuration for AzureQueueStorage
"""Configuration for AzureQueueStorage.
Note that all parameters used to create this instance are saved as instance
attributes.
:param url: The URL of the service account, queue or message that is the
targe of the desired operation.
:param url: The URL of the service account, queue or message that is the targe of the desired operation.
:type url: str
:ivar version: Specifies the version of the operation to use for this
request.
:type version: str
"""

def __init__(self, url, **kwargs):

def __init__(
self,
url, # type: str
**kwargs # type: Any
):
# type: (...) -> None
if url is None:
raise ValueError("Parameter 'url' must not be None.")

super(AzureQueueStorageConfiguration, self).__init__(**kwargs)
self._configure(**kwargs)

self.user_agent_policy.add_user_agent('azsdk-python-azurequeuestorage/{}'.format(VERSION))
self.generate_client_request_id = True

self.url = url
self.version = "2018-03-28"
kwargs.setdefault('sdk_moniker', 'azurequeuestorage/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(self, **kwargs):
def _configure(
self,
**kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._azure_queue_storage_async import AzureQueueStorage
from ._azure_queue_storage import AzureQueueStorage
__all__ = ['AzureQueueStorage']
Original file line number Diff line number Diff line change
@@ -1,54 +1,51 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any

from azure.core import AsyncPipelineClient
from msrest import Serializer, Deserializer
from msrest import Deserializer, Serializer

from ._configuration_async import AzureQueueStorageConfiguration
from azure.core.exceptions import map_error
from .operations_async import ServiceOperations
from .operations_async import QueueOperations
from .operations_async import MessagesOperations
from .operations_async import MessageIdOperations
from ._configuration import AzureQueueStorageConfiguration
from .operations import ServiceOperations
from .operations import QueueOperations
from .operations import MessagesOperations
from .operations import MessageIdOperations
from .. import models


class AzureQueueStorage(object):
"""AzureQueueStorage
:ivar service: Service operations
:vartype service: azure.storage.queue.aio.operations_async.ServiceOperations
:ivar queue: Queue operations
:vartype queue: azure.storage.queue.aio.operations_async.QueueOperations
:ivar messages: Messages operations
:vartype messages: azure.storage.queue.aio.operations_async.MessagesOperations
:ivar message_id: MessageId operations
:vartype message_id: azure.storage.queue.aio.operations_async.MessageIdOperations
"""AzureQueueStorage.
:param url: The URL of the service account, queue or message that is the
targe of the desired operation.
:ivar service: ServiceOperations operations
:vartype service: azure.storage.queue.aio.operations.ServiceOperations
:ivar queue: QueueOperations operations
:vartype queue: azure.storage.queue.aio.operations.QueueOperations
:ivar messages: MessagesOperations operations
:vartype messages: azure.storage.queue.aio.operations.MessagesOperations
:ivar message_id: MessageIdOperations operations
:vartype message_id: azure.storage.queue.aio.operations.MessageIdOperations
:param url: The URL of the service account, queue or message that is the targe of the desired operation.
:type url: str
"""

def __init__(
self, url, **kwargs):

self,
url: str,
**kwargs: Any
) -> None:
base_url = '{url}'
self._config = AzureQueueStorageConfiguration(url, **kwargs)
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = '2018-03-28'
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)

self.service = ServiceOperations(
Expand All @@ -60,10 +57,12 @@ def __init__(
self.message_id = MessageIdOperations(
self._client, self._config, self._serialize, self._deserialize)

async def close(self):
async def close(self) -> None:
await self._client.close()
async def __aenter__(self):

async def __aenter__(self) -> "AzureQueueStorage":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details):

async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from ..version import VERSION

VERSION = "unknown"

class AzureQueueStorageConfiguration(Configuration):
"""Configuration for AzureQueueStorage
"""Configuration for AzureQueueStorage.
Note that all parameters used to create this instance are saved as instance
attributes.
:param url: The URL of the service account, queue or message that is the
targe of the desired operation.
:param url: The URL of the service account, queue or message that is the targe of the desired operation.
:type url: str
:ivar version: Specifies the version of the operation to use for this
request.
:type version: str
"""

def __init__(self, url, **kwargs):

def __init__(
self,
url: str,
**kwargs: Any
) -> None:
if url is None:
raise ValueError("Parameter 'url' must not be None.")

super(AzureQueueStorageConfiguration, self).__init__(**kwargs)
self._configure(**kwargs)

self.user_agent_policy.add_user_agent('azsdk-python-azurequeuestorage/{}'.format(VERSION))
self.generate_client_request_id = True
self.accept_language = None

self.url = url
self.version = "2018-03-28"
kwargs.setdefault('sdk_moniker', 'azurequeuestorage/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(self, **kwargs):
def _configure(
self,
**kwargs: Any
) -> None:
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
Loading

0 comments on commit 1ca37b4

Please sign in to comment.