Skip to content

Commit 391ddec

Browse files
author
SDKAuto
committed
CodeGen from PR 31387 in Azure/azure-rest-api-specs
Merge 02bb3966d5d68dd08e4bd2fff041348052c31500 into 4a34315010d7416991838424bcbbfe0d4f8cea8a
1 parent a910ff3 commit 391ddec

40 files changed

+498
-1473
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "26af8eff710ea634da1b33fed369967d1c39b689",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/communication/Communication.Messages",
5+
"@azure-tools/typespec-python": "0.36.1"
6+
}

sdk/communication/azure-communication-messages/azure/communication/messages/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
55
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._client import NotificationMessagesClient
10-
from ._client import MessageTemplateClient
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import NotificationMessagesClient # type: ignore
16+
from ._client import MessageTemplateClient # type: ignore
1117
from ._version import VERSION
1218

1319
__version__ = VERSION
1420

1521
try:
1622
from ._patch import __all__ as _patch_all
17-
from ._patch import * # pylint: disable=unused-wildcard-import
23+
from ._patch import *
1824
except ImportError:
1925
_patch_all = []
2026
from ._patch import patch_sdk as _patch_sdk
@@ -23,6 +29,6 @@
2329
"NotificationMessagesClient",
2430
"MessageTemplateClient",
2531
]
26-
__all__.extend([p for p in _patch_all if p not in __all__])
32+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2733

2834
_patch_sdk()

sdk/communication/azure-communication-messages/azure/communication/messages/_api_versions.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

sdk/communication/azure-communication-messages/azure/communication/messages/_client.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020
from ._serialization import Deserializer, Serializer
2121

2222
if TYPE_CHECKING:
23-
# pylint: disable=unused-import,ungrouped-imports
2423
from azure.core.credentials import TokenCredential
2524

2625

27-
class NotificationMessagesClient(
28-
NotificationMessagesClientOperationsMixin
29-
): # pylint: disable=client-accepts-api-version-keyword
26+
class NotificationMessagesClient(NotificationMessagesClientOperationsMixin):
3027
"""NotificationMessagesClient.
3128
3229
:param endpoint: The communication resource, for example
@@ -104,7 +101,7 @@ def __exit__(self, *exc_details: Any) -> None:
104101
self._client.__exit__(*exc_details)
105102

106103

107-
class MessageTemplateClient(MessageTemplateClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
104+
class MessageTemplateClient(MessageTemplateClientOperationsMixin):
108105
"""MessageTemplateClient.
109106
110107
:param endpoint: The communication resource, for example

sdk/communication/azure-communication-messages/azure/communication/messages/_configuration.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
from ._version import VERSION
1515

1616
if TYPE_CHECKING:
17-
# pylint: disable=unused-import,ungrouped-imports
1817
from azure.core.credentials import TokenCredential
1918

2019

21-
class NotificationMessagesClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
20+
class NotificationMessagesClientConfiguration: # pylint: disable=too-many-instance-attributes
2221
"""Configuration for NotificationMessagesClient.
2322
2423
Note that all parameters used to create this instance are saved as instance
@@ -73,7 +72,7 @@ def _configure(self, **kwargs: Any) -> None:
7372
self.authentication_policy = self._infer_policy(**kwargs)
7473

7574

76-
class MessageTemplateClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
75+
class MessageTemplateClientConfiguration: # pylint: disable=too-many-instance-attributes
7776
"""Configuration for MessageTemplateClient.
7877
7978
Note that all parameters used to create this instance are saved as instance

sdk/communication/azure-communication-messages/azure/communication/messages/_model_base.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
# pylint: disable=too-many-lines
12
# coding=utf-8
23
# --------------------------------------------------------------------------
34
# Copyright (c) Microsoft Corporation. All rights reserved.
45
# Licensed under the MIT License. See License.txt in the project root for
56
# license information.
67
# --------------------------------------------------------------------------
7-
# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines
8+
# pylint: disable=protected-access, broad-except
89

910
import copy
1011
import calendar
@@ -573,7 +574,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
573574
def copy(self) -> "Model":
574575
return Model(self.__dict__)
575576

576-
def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument
577+
def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self:
577578
if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated:
578579
# we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping',
579580
# 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object'
@@ -584,8 +585,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
584585
annotations = {
585586
k: v
586587
for mro_class in mros
587-
if hasattr(mro_class, "__annotations__") # pylint: disable=no-member
588-
for k, v in mro_class.__annotations__.items() # pylint: disable=no-member
588+
if hasattr(mro_class, "__annotations__")
589+
for k, v in mro_class.__annotations__.items()
589590
}
590591
for attr, rf in attr_to_rest_field.items():
591592
rf._module = cls.__module__
@@ -600,8 +601,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
600601

601602
def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None:
602603
for base in cls.__bases__:
603-
if hasattr(base, "__mapping__"): # pylint: disable=no-member
604-
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member
604+
if hasattr(base, "__mapping__"):
605+
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore
605606

606607
@classmethod
607608
def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]:
@@ -612,7 +613,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField
612613

613614
@classmethod
614615
def _deserialize(cls, data, exist_discriminators):
615-
if not hasattr(cls, "__mapping__"): # pylint: disable=no-member
616+
if not hasattr(cls, "__mapping__"):
616617
return cls(data)
617618
discriminator = cls._get_discriminator(exist_discriminators)
618619
if discriminator is None:
@@ -632,11 +633,11 @@ def _deserialize(cls, data, exist_discriminators):
632633
discriminator_value = data.find(xml_name).text # pyright: ignore
633634
else:
634635
discriminator_value = data.get(discriminator._rest_name)
635-
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member
636+
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore
636637
return mapped_cls._deserialize(data, exist_discriminators)
637638

638639
def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]:
639-
"""Return a dict that can be JSONify using json.dump.
640+
"""Return a dict that can be turned into json using json.dump.
640641
641642
:keyword bool exclude_readonly: Whether to remove the readonly properties.
642643
:returns: A dict JSON compatible object
@@ -733,7 +734,7 @@ def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.An
733734
)
734735

735736

736-
def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915, R0912
737+
def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches
737738
annotation: typing.Any,
738739
module: typing.Optional[str],
739740
rf: typing.Optional["_RestField"] = None,

sdk/communication/azure-communication-messages/azure/communication/messages/_operations/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@
55
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._operations import NotificationMessagesClientOperationsMixin
10-
from ._operations import MessageTemplateClientOperationsMixin
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._operations import NotificationMessagesClientOperationsMixin # type: ignore
16+
from ._operations import MessageTemplateClientOperationsMixin # type: ignore
1117

1218
from ._patch import __all__ as _patch_all
13-
from ._patch import * # pylint: disable=unused-wildcard-import
19+
from ._patch import *
1420
from ._patch import patch_sdk as _patch_sdk
1521

1622
__all__ = [
1723
"NotificationMessagesClientOperationsMixin",
1824
"MessageTemplateClientOperationsMixin",
1925
]
20-
__all__.extend([p for p in _patch_all if p not in __all__])
26+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2127
_patch_sdk()

sdk/communication/azure-communication-messages/azure/communication/messages/_operations/_operations.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# pylint: disable=too-many-lines,too-many-statements
21
# coding=utf-8
32
# --------------------------------------------------------------------------
43
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10,7 +9,7 @@
109
from io import IOBase
1110
import json
1211
import sys
13-
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, Type, TypeVar, Union, overload
12+
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, overload
1413
import urllib.parse
1514
import uuid
1615

@@ -38,7 +37,7 @@
3837
if sys.version_info >= (3, 9):
3938
from collections.abc import MutableMapping
4039
else:
41-
from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports
40+
from typing import MutableMapping # type: ignore
4241
JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object
4342
T = TypeVar("T")
4443
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@@ -190,7 +189,7 @@ def send(
190189
:rtype: ~azure.communication.messages.models.SendMessageResult
191190
:raises ~azure.core.exceptions.HttpResponseError:
192191
"""
193-
error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object
192+
error_map: MutableMapping = {
194193
401: ClientAuthenticationError,
195194
404: ResourceNotFoundError,
196195
409: ResourceExistsError,
@@ -267,7 +266,7 @@ def download_media(self, id: str, **kwargs: Any) -> Iterator[bytes]:
267266
:rtype: Iterator[bytes]
268267
:raises ~azure.core.exceptions.HttpResponseError:
269268
"""
270-
error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object
269+
error_map: MutableMapping = {
271270
401: ClientAuthenticationError,
272271
404: ResourceNotFoundError,
273272
409: ResourceExistsError,
@@ -339,7 +338,7 @@ def list_templates(self, channel_id: str, **kwargs: Any) -> Iterable["_models.Me
339338
maxpagesize = kwargs.pop("maxpagesize", None)
340339
cls: ClsType[List[_models.MessageTemplateItem]] = kwargs.pop("cls", None)
341340

342-
error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object
341+
error_map: MutableMapping = {
343342
401: ClientAuthenticationError,
344343
404: ResourceNotFoundError,
345344
409: ResourceExistsError,

sdk/communication/azure-communication-messages/azure/communication/messages/_patch.py

Lines changed: 2 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -6,132 +6,9 @@
66
77
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
88
"""
9-
from typing import List, Any, Union
10-
from urllib.parse import urlparse
11-
from azure.core.credentials import TokenCredential, AzureKeyCredential
12-
from ._shared.utils import parse_connection_str
13-
from ._client import (
14-
NotificationMessagesClient as NotificationMessagesClientGenerated,
15-
MessageTemplateClient as MessageTemplateClientGenerated,
16-
)
17-
from ._shared.auth_policy_utils import get_authentication_policy
18-
from ._api_versions import DEFAULT_VERSION
9+
from typing import List
1910

20-
21-
class NotificationMessagesClient(NotificationMessagesClientGenerated):
22-
"""A client to interact with the AzureCommunicationService Messaging service.
23-
24-
This client provides operations to create and update jobs, policies and workers.
25-
26-
:param str endpoint:
27-
The endpoint of the Azure Communication resource.
28-
:param Union[TokenCredential, AsyncTokenCredential] credential:
29-
The credentials with which to authenticate
30-
31-
:keyword api_version: Azure Communication Messaging API version.
32-
Default value is "2023-11-01".
33-
Note that overriding this default value may result in unsupported behavior.
34-
"""
35-
36-
def __init__(self, endpoint: str, credential: Union[TokenCredential, AzureKeyCredential], **kwargs: Any) -> None:
37-
if not credential:
38-
raise ValueError("credential can not be None")
39-
40-
try:
41-
if not endpoint.lower().startswith("http"):
42-
endpoint = "https://" + endpoint
43-
except AttributeError:
44-
raise ValueError("Host URL must be a string") # pylint:disable=raise-missing-from
45-
46-
parsed_url = urlparse(endpoint.rstrip("/"))
47-
if not parsed_url.netloc:
48-
raise ValueError("Invalid URL: {}".format(endpoint))
49-
50-
self._endpoint = endpoint
51-
self._api_version = kwargs.pop("api_version", DEFAULT_VERSION)
52-
self._authentication_policy = get_authentication_policy(endpoint, credential)
53-
self._credential = credential
54-
super().__init__(
55-
self._endpoint,
56-
self._credential,
57-
authentication_policy=self._authentication_policy,
58-
api_version=self._api_version,
59-
**kwargs
60-
)
61-
62-
@classmethod
63-
def from_connection_string(cls, conn_str: str, **kwargs: Any) -> "NotificationMessagesClient":
64-
"""Create NotificationMessagesClient from a Connection String.
65-
66-
:param conn_str: Azure communication service connection string. Required.
67-
:type conn_str: str
68-
:return: instance of NotificationMessagesClient
69-
:rtype:
70-
~azure.communication.messages.NotificationMessagesClient
71-
"""
72-
endpoint, access_key = parse_connection_str(conn_str)
73-
return cls(endpoint, AzureKeyCredential(access_key), **kwargs)
74-
75-
76-
class MessageTemplateClient(MessageTemplateClientGenerated):
77-
"""A client to interact with the AzureCommunicationService Messaging service.
78-
79-
This client provides Advanced Messaging.
80-
81-
:param str endpoint:
82-
The endpoint of the Azure Communication resource.
83-
:param Union[TokenCredential, AsyncTokenCredential] credential:
84-
The credentials with which to authenticate
85-
86-
:keyword api_version: Azure Communication Messages API version. Default value is "2024-02-01".
87-
Note that overriding this default value may result in unsupported behavior.
88-
:paramtype api_version: str
89-
"""
90-
91-
def __init__(self, endpoint: str, credential: Union[TokenCredential, AzureKeyCredential], **kwargs: Any) -> "None":
92-
if not credential:
93-
raise ValueError("credential can not be None")
94-
95-
try:
96-
if not endpoint.lower().startswith("http"):
97-
endpoint = "https://" + endpoint
98-
except AttributeError:
99-
raise ValueError("Host URL must be a string") # pylint: disable=raise-missing-from
100-
101-
parsed_url = urlparse(endpoint.rstrip("/"))
102-
if not parsed_url.netloc:
103-
raise ValueError("Invalid URL: {}".format(endpoint))
104-
105-
self._endpoint = endpoint
106-
self._api_version = kwargs.pop("api_version", DEFAULT_VERSION)
107-
self._authentication_policy = get_authentication_policy(endpoint, credential)
108-
self._credential = credential
109-
super().__init__(
110-
self._endpoint,
111-
self._credential,
112-
authentication_policy=self._authentication_policy,
113-
api_version=self._api_version,
114-
**kwargs
115-
)
116-
117-
@classmethod
118-
def from_connection_string(cls, conn_str: str, **kwargs: Any) -> "MessageTemplateClient":
119-
"""Create MessageTemplateClient from a Connection String.
120-
121-
:param conn_str: Azure communication service connection string. Required.
122-
:type conn_str: str
123-
:return: instance of MessageTemplateClient
124-
:rtype:
125-
~azure.communication.messages.MessageTemplateClient
126-
"""
127-
endpoint, access_key = parse_connection_str(conn_str)
128-
return cls(endpoint, AzureKeyCredential(access_key), **kwargs)
129-
130-
131-
__all__: List[str] = [
132-
"NotificationMessagesClient",
133-
"MessageTemplateClient",
134-
] # Add all objects you want publicly available to users at this package level
11+
__all__: List[str] = [] # Add all objects you want publicly available to users at this package level
13512

13613

13714
def patch_sdk():

0 commit comments

Comments
 (0)