Skip to content

Commit

Permalink
CodeGen from PR 29483 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge a99b0d5c4abdfcf04c4a4733d73058bdd01e6724 into 2b6c728b10f0d8eca8bad4e7f009e38334ea7f1c
  • Loading branch information
SDKAuto committed Jun 26, 2024
1 parent 89014fa commit 7859813
Show file tree
Hide file tree
Showing 173 changed files with 43,602 additions and 54,478 deletions.
7 changes: 7 additions & 0 deletions sdk/communication/azure-communication-messages/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"commit": "228acac22c34fa19cd629ba2df005822ab8ba959",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"typespec_src": "specification/communication/Communication.Messages",
"@azure-tools/typespec-python": "0.24.3",
"@autorest/python": "6.14.3"
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk

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

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from copy import deepcopy
from typing import Any, TYPE_CHECKING, Union
from typing_extensions import Self

from azure.core import PipelineClient
from azure.core.credentials import AzureKeyCredential
Expand All @@ -22,13 +23,16 @@
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential

class NotificationMessagesClient(NotificationMessagesClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword

class NotificationMessagesClient(
NotificationMessagesClientOperationsMixin
): # pylint: disable=client-accepts-api-version-keyword
"""NotificationMessagesClient.
:param endpoint: The communication resource, for example
https://my-resource.communication.azure.com. Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Is either a
:param credential: Credential used to authenticate requests to the service. Is either a
TokenCredential type or a AzureKeyCredential type. Required.
:type credential: ~azure.core.credentials.TokenCredential or
~azure.core.credentials.AzureKeyCredential
Expand All @@ -37,38 +41,33 @@ class NotificationMessagesClient(NotificationMessagesClientOperationsMixin): #
:paramtype api_version: str
"""

def __init__(
self,
endpoint: str,
credential: Union["TokenCredential", AzureKeyCredential],
**kwargs: Any
) -> None:
_endpoint = '{endpoint}'
def __init__(self, endpoint: str, credential: Union["TokenCredential", AzureKeyCredential], **kwargs: Any) -> None:
_endpoint = "{endpoint}"
self._config = NotificationMessagesClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
_policies = kwargs.pop('policies', None)
_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [policies.RequestIdPolicy(**kwargs),self._config.headers_policy,
self._config.user_agent_policy,self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy]
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)


self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False


def send_request(
self,
request: HttpRequest, *, stream: bool = False,
**kwargs: Any
) -> HttpResponse:
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
Expand All @@ -88,7 +87,7 @@ def send_request(

request_copy = deepcopy(request)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
Expand All @@ -97,19 +96,21 @@ def send_request(
def close(self) -> None:
self._client.close()

def __enter__(self) -> "NotificationMessagesClient":
def __enter__(self) -> Self:
self._client.__enter__()
return self

def __exit__(self, *exc_details: Any) -> None:
self._client.__exit__(*exc_details)


class MessageTemplateClient(MessageTemplateClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
"""MessageTemplateClient.
:param endpoint: The communication resource, for example
https://my-resource.communication.azure.com. Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Is either a
:param credential: Credential used to authenticate requests to the service. Is either a
TokenCredential type or a AzureKeyCredential type. Required.
:type credential: ~azure.core.credentials.TokenCredential or
~azure.core.credentials.AzureKeyCredential
Expand All @@ -118,35 +119,33 @@ class MessageTemplateClient(MessageTemplateClientOperationsMixin): # pylint: di
:paramtype api_version: str
"""

def __init__(
self,
endpoint: str,
credential: Union["TokenCredential", AzureKeyCredential],
**kwargs: Any
) -> None:
_endpoint = '{endpoint}'
def __init__(self, endpoint: str, credential: Union["TokenCredential", AzureKeyCredential], **kwargs: Any) -> None:
_endpoint = "{endpoint}"
self._config = MessageTemplateClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
_policies = kwargs.pop('policies', None)
_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [policies.RequestIdPolicy(**kwargs),self._config.headers_policy,self._config.user_agent_policy,
self._config.proxy_policy,policies.ContentDecodePolicy(**kwargs),self._config.redirect_policy,
self._config.retry_policy,self._config.authentication_policy,self._config.custom_hook_policy,
self._config.logging_policy,policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy]
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)


self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False


def send_request(
self,
request: HttpRequest, *, stream: bool = False,
**kwargs: Any
) -> HttpResponse:
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
Expand All @@ -166,7 +165,7 @@ def send_request(

request_copy = deepcopy(request)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
Expand All @@ -175,7 +174,7 @@ def send_request(
def close(self) -> None:
self._client.close()

def __enter__(self) -> "MessageTemplateClient":
def __enter__(self) -> Self:
self._client.__enter__()
return self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from azure.core.credentials import TokenCredential


class NotificationMessagesClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
class NotificationMessagesClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
"""Configuration for NotificationMessagesClient.
Note that all parameters used to create this instance are saved as instance
Expand All @@ -27,7 +27,7 @@ class NotificationMessagesClientConfiguration: # pylint: disable=too-many-ins
:param endpoint: The communication resource, for example
https://my-resource.communication.azure.com. Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Is either a
:param credential: Credential used to authenticate requests to the service. Is either a
TokenCredential type or a AzureKeyCredential type. Required.
:type credential: ~azure.core.credentials.TokenCredential or
~azure.core.credentials.AzureKeyCredential
Expand All @@ -36,13 +36,8 @@ class NotificationMessagesClientConfiguration: # pylint: disable=too-many-ins
:paramtype api_version: str
"""

def __init__(
self,
endpoint: str,
credential: Union["TokenCredential", AzureKeyCredential],
**kwargs: Any
) -> None:
api_version: str = kwargs.pop('api_version', "2024-02-01")
def __init__(self, endpoint: str, credential: Union["TokenCredential", AzureKeyCredential], **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2024-02-01")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand All @@ -52,34 +47,33 @@ def __init__(
self.endpoint = endpoint
self.credential = credential
self.api_version = api_version
self.credential_scopes = kwargs.pop('credential_scopes', ['https://communication.azure.com/.default'])
kwargs.setdefault('sdk_moniker', 'communication-messages/{}'.format(VERSION))
self.credential_scopes = kwargs.pop("credential_scopes", ["https://communication.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "communication-messages/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

def _infer_policy(self, **kwargs):
if hasattr(self.credential, 'get_token'):
if hasattr(self.credential, "get_token"):
return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
if isinstance(self.credential, AzureKeyCredential):
return policies.AzureKeyCredentialPolicy(self.credential, "Authorization", **kwargs)
raise TypeError(f"Unsupported credential: {self.credential}")

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.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = self._infer_policy(**kwargs)
class MessageTemplateClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long


class MessageTemplateClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
"""Configuration for MessageTemplateClient.
Note that all parameters used to create this instance are saved as instance
Expand All @@ -88,7 +82,7 @@ class MessageTemplateClientConfiguration: # pylint: disable=too-many-instance
:param endpoint: The communication resource, for example
https://my-resource.communication.azure.com. Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Is either a
:param credential: Credential used to authenticate requests to the service. Is either a
TokenCredential type or a AzureKeyCredential type. Required.
:type credential: ~azure.core.credentials.TokenCredential or
~azure.core.credentials.AzureKeyCredential
Expand All @@ -97,13 +91,8 @@ class MessageTemplateClientConfiguration: # pylint: disable=too-many-instance
:paramtype api_version: str
"""

def __init__(
self,
endpoint: str,
credential: Union["TokenCredential", AzureKeyCredential],
**kwargs: Any
) -> None:
api_version: str = kwargs.pop('api_version', "2024-02-01")
def __init__(self, endpoint: str, credential: Union["TokenCredential", AzureKeyCredential], **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2024-02-01")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand All @@ -113,30 +102,27 @@ def __init__(
self.endpoint = endpoint
self.credential = credential
self.api_version = api_version
self.credential_scopes = kwargs.pop('credential_scopes', ['https://communication.azure.com/.default'])
kwargs.setdefault('sdk_moniker', 'communication-messages/{}'.format(VERSION))
self.credential_scopes = kwargs.pop("credential_scopes", ["https://communication.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "communication-messages/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

def _infer_policy(self, **kwargs):
if hasattr(self.credential, 'get_token'):
if hasattr(self.credential, "get_token"):
return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
if isinstance(self.credential, AzureKeyCredential):
return policies.AzureKeyCredentialPolicy(self.credential, "Authorization", **kwargs)
raise TypeError(f"Unsupported credential: {self.credential}")

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.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = self._infer_policy(**kwargs)
Loading

0 comments on commit 7859813

Please sign in to comment.