Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ServiceBus] remove msrest #29324

Merged
19 commits merged into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sdk/servicebus/azure-servicebus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@

### Breaking Changes

- Operations on the sync and async `ServiceBusAdministrationClient` will now raise `azure.core.exceptions.HttpResponseError` everywhere `msrest.exceptions.ValidationErrors` were raised.
swathipil marked this conversation as resolved.
Show resolved Hide resolved

### Bugs Fixed

### Other Changes

- Updated minimum `azure-core` version to 1.24.0.
- Removed `msrest` dependency.
- Removed `azure-common` dependency.

## 7.8.3 (2023-03-09)

### Bugs Fixed
Expand Down
2 changes: 1 addition & 1 deletion sdk/servicebus/azure-servicebus/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/servicebus/azure-servicebus",
"Tag": "python/servicebus/azure-servicebus_361137d481"
"Tag": "python/servicebus/azure-servicebus_fe5bc0050b"
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
cast
)
from contextlib import contextmanager
from msrest.serialization import TZ_UTC
from azure.core.serialization import TZ_UTC
swathipil marked this conversation as resolved.
Show resolved Hide resolved

try:
from urlparse import urlparse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
ServiceBusSharedKeyCredential,
ServiceBusSASTokenCredential,
)
from ...management._generated.aio._configuration_async import (
from ...management._generated.aio._configuration import (
ServiceBusManagementClientConfiguration,
)
from ...management._generated.aio._service_bus_management_client_async import (
from ...management._generated.aio._client import (
ServiceBusManagementClient as ServiceBusManagementClientImpl,
)
from ...management import _constants as constants
Expand Down Expand Up @@ -119,10 +119,12 @@ def __init__(
self._api_version = api_version
self._credential = credential
self._endpoint = "https://" + fully_qualified_namespace
self._config = ServiceBusManagementClientConfiguration(self._endpoint, **kwargs)
self._config = ServiceBusManagementClientConfiguration(
self._endpoint, credential=self._credential, api_version=api_version, **kwargs
)
self._pipeline = self._build_pipeline()
self._impl = ServiceBusManagementClientImpl(
endpoint=fully_qualified_namespace, pipeline=self._pipeline
endpoint=fully_qualified_namespace, credential=self._credential, pipeline=self._pipeline
)

async def __aenter__(self) -> "ServiceBusAdministrationClient":
Expand Down Expand Up @@ -170,7 +172,7 @@ async def _get_entity_element(
element = cast(
ElementTree,
await self._impl.entity.get(
entity_name, enrich=enrich, api_version=self._api_version, **kwargs
entity_name, enrich=enrich, **kwargs
),
)
return element
Expand All @@ -191,7 +193,6 @@ async def _get_subscription_element(
topic_name,
subscription_name,
enrich=enrich,
api_version=self._api_version,
**kwargs
),
)
Expand All @@ -212,7 +213,6 @@ async def _get_rule_element(
subscription_name,
rule_name,
enrich=False,
api_version=self._api_version,
**kwargs
),
)
Expand Down Expand Up @@ -441,7 +441,6 @@ async def create_queue( # pylint: disable=too-many-locals
await self._impl.entity.put(
queue_name, # type: ignore
request_body,
api_version=self._api_version,
**kwargs
),
)
Expand Down Expand Up @@ -484,7 +483,6 @@ async def update_queue(
await self._impl.entity.put(
queue.name, # type: ignore
request_body,
api_version=self._api_version,
if_match="*",
**kwargs
)
Expand All @@ -502,7 +500,7 @@ async def delete_queue(self, queue_name: str, **kwargs: Any) -> None:
raise ValueError("queue_name must not be None or empty")
with _handle_response_error():
await self._impl.entity.delete(
queue_name, api_version=self._api_version, **kwargs
queue_name, **kwargs
)

def list_queues(self, **kwargs: Any) -> AsyncItemPaged[QueueProperties]:
Expand All @@ -524,7 +522,6 @@ def entry_to_qd(entry):
get_next = functools.partial(
get_next_template,
functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_QUEUES),
api_version=self._api_version,
kashifkhan marked this conversation as resolved.
Show resolved Hide resolved
**kwargs
)
return AsyncItemPaged(get_next, extract_data)
Expand All @@ -550,7 +547,6 @@ def entry_to_qr(entry):
get_next = functools.partial(
get_next_template,
functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_QUEUES),
api_version=self._api_version,
**kwargs
)
return AsyncItemPaged(get_next, extract_data)
Expand Down Expand Up @@ -696,7 +692,6 @@ async def create_topic(
await self._impl.entity.put(
topic_name, # type: ignore
request_body,
api_version=self._api_version,
**kwargs
),
)
Expand Down Expand Up @@ -737,7 +732,6 @@ async def update_topic(
await self._impl.entity.put(
topic.name, # type: ignore
request_body,
api_version=self._api_version,
if_match="*",
**kwargs
)
Expand All @@ -751,7 +745,7 @@ async def delete_topic(self, topic_name: str, **kwargs: Any) -> None:
_validate_entity_name_type(topic_name)

await self._impl.entity.delete(
topic_name, api_version=self._api_version, **kwargs
topic_name, **kwargs
)

def list_topics(self, **kwargs: Any) -> AsyncItemPaged[TopicProperties]:
Expand All @@ -773,7 +767,6 @@ def entry_to_topic(entry):
get_next = functools.partial(
get_next_template,
functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_TOPICS),
api_version=self._api_version,
**kwargs
)
return AsyncItemPaged(get_next, extract_data)
Expand All @@ -799,7 +792,6 @@ def entry_to_topic(entry):
get_next = functools.partial(
get_next_template,
functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_TOPICS),
api_version=self._api_version,
**kwargs
)
return AsyncItemPaged(get_next, extract_data)
Expand Down Expand Up @@ -960,7 +952,6 @@ async def create_subscription(
topic_name,
subscription_name, # type: ignore
request_body,
api_version=self._api_version,
**kwargs
),
)
Expand Down Expand Up @@ -1013,7 +1004,6 @@ async def update_subscription(
topic_name,
subscription.name,
request_body,
api_version=self._api_version,
if_match="*",
**kwargs
)
Expand All @@ -1031,7 +1021,7 @@ async def delete_subscription(
_validate_topic_and_subscription_types(topic_name, subscription_name)

await self._impl.subscription.delete(
topic_name, subscription_name, api_version=self._api_version, **kwargs
topic_name, subscription_name, **kwargs
)

def list_subscriptions(
Expand All @@ -1057,7 +1047,6 @@ def entry_to_subscription(entry):
get_next = functools.partial(
get_next_template,
functools.partial(self._impl.list_subscriptions, topic_name),
api_version=self._api_version,
**kwargs
)
return AsyncItemPaged(get_next, extract_data)
Expand Down Expand Up @@ -1085,7 +1074,6 @@ def entry_to_subscription(entry):
get_next = functools.partial(
get_next_template,
functools.partial(self._impl.list_subscriptions, topic_name),
api_version=self._api_version,
**kwargs
)
return AsyncItemPaged(get_next, extract_data)
Expand Down Expand Up @@ -1170,7 +1158,6 @@ async def create_rule(
subscription_name, # type: ignore
rule_name,
request_body,
api_version=self._api_version,
**kwargs
)
entry = RuleDescriptionEntry.deserialize(entry_ele)
Expand Down Expand Up @@ -1223,7 +1210,6 @@ async def update_rule(
subscription_name,
rule.name,
request_body,
api_version=self._api_version,
if_match="*",
**kwargs
)
Expand All @@ -1247,7 +1233,6 @@ async def delete_rule(
topic_name,
subscription_name,
rule_name,
api_version=self._api_version,
**kwargs
)

Expand Down Expand Up @@ -1281,7 +1266,6 @@ def entry_to_rule(ele, entry):
get_next = functools.partial(
get_next_template,
functools.partial(self._impl.list_rules, topic_name, subscription_name),
api_version=self._api_version,
**kwargs
)
return AsyncItemPaged(get_next, extract_data)
Expand All @@ -1291,9 +1275,7 @@ async def get_namespace_properties(self, **kwargs: Any) -> NamespaceProperties:

:rtype: ~azure.servicebus.management.NamespaceProperties
"""
entry_el = await self._impl.namespace.get(
api_version=self._api_version, **kwargs
)
entry_el = await self._impl.namespace.get(**kwargs)
namespace_entry = NamespacePropertiesEntry.deserialize(entry_el)
return NamespaceProperties._from_internal_entity(
namespace_entry.title, namespace_entry.content.namespace_properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import urllib.parse as urlparse

from ...management import _constants as constants
from ...management._api_version import DEFAULT_VERSION
from ...management._handle_response_error import _handle_response_error

# This module defines functions get_next_template and extract_data_template.
Expand Down Expand Up @@ -127,17 +126,15 @@ async def get_next_template(
XML ElementTree to call a partial function created from `extrat_data_template`.

"""
api_version = kwargs.pop("api_version", DEFAULT_VERSION)
if args[0]: # It's next link. It's None for the first page.
queries = urlparse.parse_qs(urlparse.urlparse(args[0]).query)
start_index = int(queries[constants.LIST_OP_SKIP][0])
max_page_size = int(queries[constants.LIST_OP_TOP][0])
api_version = queries[constants.API_VERSION_PARAM_NAME][0]
with _handle_response_error():
feed_element = cast(
ElementTree,
await list_func(
skip=start_index, top=max_page_size, api_version=api_version, **kwargs
skip=start_index, top=max_page_size, **kwargs
),
)
return feed_element
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import warnings
from typing import Optional, Any, Tuple, cast, Mapping, Union, Dict, List

from msrest.serialization import TZ_UTC
from azure.core.serialization import TZ_UTC
import uamqp

from ._constants import AMQP_MESSAGE_BODY_TYPE_MAP, AmqpMessageBodyType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._service_bus_management_client import ServiceBusManagementClient
from ._version import VERSION

__version__ = VERSION
__all__ = ['ServiceBusManagementClient']
from ._client import ServiceBusManagementClient

try:
from ._patch import patch_sdk
patch_sdk()
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
except ImportError:
pass
_patch_all = []
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"ServiceBusManagementClient",
]
__all__.extend([p for p in _patch_all if p not in __all__])

_patch_sdk()
Loading