Skip to content

Commit 7ddd0e5

Browse files
committed
[EG] regenerate to fix gen code bug (#35327)
* regenerate to fix gen code bug * update serialization code * update * pylint * update faulty tests * use _patch * use _patch * add test type * fix test + add version
1 parent 2950192 commit 7ddd0e5

File tree

79 files changed

+1654
-2301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1654
-2301
lines changed

sdk/eventgrid/azure-eventgrid/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Release History
22

3+
## 4.20.1b1 (2024-04-24)
4+
5+
This is a Beta of the EventGridClient
6+
7+
### Bug Fixes
8+
9+
- Fixed serialization issues with CloudEvent and CNCF Cloud Event
10+
311
## 4.20.0b1 (2024-04-11)
412

513
### Features Added
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

sdk/eventgrid/azure-eventgrid/azure/eventgrid/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
except ImportError:
1818
_patch_all = []
1919
from ._patch import patch_sdk as _patch_sdk
20+
2021
__all__ = [
21-
'EventGridClient',
22+
"EventGridClient",
2223
]
2324
__all__.extend([p for p in _patch_all if p not in __all__])
2425

sdk/eventgrid/azure-eventgrid/azure/eventgrid/_client.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
# pylint: disable=unused-import,ungrouped-imports
2323
from azure.core.credentials import TokenCredential
2424

25+
2526
class EventGridClient(EventGridClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
2627
"""Azure Messaging EventGrid Client.
2728
2829
:param endpoint: The host name of the namespace, e.g.
2930
namespaceName1.westus-1.eventgrid.azure.net. Required.
3031
:type endpoint: str
31-
:param credential: Credential needed for the client to connect to Azure. Is either a
32+
:param credential: Credential used to authenticate requests to the service. Is either a
3233
AzureKeyCredential type or a TokenCredential type. Required.
3334
:type credential: ~azure.core.credentials.AzureKeyCredential or
3435
~azure.core.credentials.TokenCredential
@@ -38,30 +39,33 @@ class EventGridClient(EventGridClientOperationsMixin): # pylint: disable=client
3839
:paramtype api_version: str
3940
"""
4041

41-
def __init__(
42-
self,
43-
endpoint: str,
44-
credential: Union[AzureKeyCredential, "TokenCredential"],
45-
**kwargs: Any
46-
) -> None:
47-
_endpoint = '{endpoint}'
42+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
43+
_endpoint = "{endpoint}"
4844
self._config = EventGridClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
49-
_policies = kwargs.pop('policies', None)
45+
_policies = kwargs.pop("policies", None)
5046
if _policies is None:
51-
_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]
47+
_policies = [
48+
policies.RequestIdPolicy(**kwargs),
49+
self._config.headers_policy,
50+
self._config.user_agent_policy,
51+
self._config.proxy_policy,
52+
policies.ContentDecodePolicy(**kwargs),
53+
self._config.redirect_policy,
54+
self._config.retry_policy,
55+
self._config.authentication_policy,
56+
self._config.custom_hook_policy,
57+
self._config.logging_policy,
58+
policies.DistributedTracingPolicy(**kwargs),
59+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
60+
self._config.http_logging_policy,
61+
]
5262
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
5363

54-
5564
self._serialize = Serializer()
5665
self._deserialize = Deserializer()
5766
self._serialize.client_side_validation = False
5867

59-
60-
def send_request(
61-
self,
62-
request: HttpRequest, *, stream: bool = False,
63-
**kwargs: Any
64-
) -> HttpResponse:
68+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
6569
"""Runs the network request through the client's chained policies.
6670
6771
>>> from azure.core.rest import HttpRequest
@@ -81,7 +85,7 @@ def send_request(
8185

8286
request_copy = deepcopy(request)
8387
path_format_arguments = {
84-
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
88+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
8589
}
8690

8791
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)

sdk/eventgrid/azure-eventgrid/azure/eventgrid/_configuration.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from azure.core.credentials import TokenCredential
1919

2020

21-
class EventGridClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
21+
class EventGridClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
2222
"""Configuration for EventGridClient.
2323
2424
Note that all parameters used to create this instance are saved as instance
@@ -27,7 +27,7 @@ class EventGridClientConfiguration: # pylint: disable=too-many-instance-attri
2727
:param endpoint: The host name of the namespace, e.g.
2828
namespaceName1.westus-1.eventgrid.azure.net. Required.
2929
:type endpoint: str
30-
:param credential: Credential needed for the client to connect to Azure. Is either a
30+
:param credential: Credential used to authenticate requests to the service. Is either a
3131
AzureKeyCredential type or a TokenCredential type. Required.
3232
:type credential: ~azure.core.credentials.AzureKeyCredential or
3333
~azure.core.credentials.TokenCredential
@@ -37,13 +37,8 @@ class EventGridClientConfiguration: # pylint: disable=too-many-instance-attri
3737
:paramtype api_version: str
3838
"""
3939

40-
def __init__(
41-
self,
42-
endpoint: str,
43-
credential: Union[AzureKeyCredential, "TokenCredential"],
44-
**kwargs: Any
45-
) -> None:
46-
api_version: str = kwargs.pop('api_version', "2023-10-01-preview")
40+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
41+
api_version: str = kwargs.pop("api_version", "2023-10-01-preview")
4742

4843
if endpoint is None:
4944
raise ValueError("Parameter 'endpoint' must not be None.")
@@ -53,30 +48,29 @@ def __init__(
5348
self.endpoint = endpoint
5449
self.credential = credential
5550
self.api_version = api_version
56-
self.credential_scopes = kwargs.pop('credential_scopes', ['https://eventgrid.azure.net/.default'])
57-
kwargs.setdefault('sdk_moniker', 'eventgrid/{}'.format(VERSION))
51+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://eventgrid.azure.net/.default"])
52+
kwargs.setdefault("sdk_moniker", "eventgrid/{}".format(VERSION))
5853
self.polling_interval = kwargs.get("polling_interval", 30)
5954
self._configure(**kwargs)
6055

6156
def _infer_policy(self, **kwargs):
6257
if isinstance(self.credential, AzureKeyCredential):
63-
return policies.AzureKeyCredentialPolicy(self.credential, "Authorization", prefix="SharedAccessKey", **kwargs)
64-
if hasattr(self.credential, 'get_token'):
58+
return policies.AzureKeyCredentialPolicy(
59+
self.credential, "Authorization", prefix="SharedAccessKey", **kwargs
60+
)
61+
if hasattr(self.credential, "get_token"):
6562
return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
6663
raise TypeError(f"Unsupported credential: {self.credential}")
6764

68-
def _configure(
69-
self,
70-
**kwargs: Any
71-
) -> None:
72-
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
73-
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
74-
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
75-
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
76-
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
77-
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
78-
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
79-
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
80-
self.authentication_policy = kwargs.get('authentication_policy')
65+
def _configure(self, **kwargs: Any) -> None:
66+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
67+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
68+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
69+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
70+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
71+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
72+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
73+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
74+
self.authentication_policy = kwargs.get("authentication_policy")
8175
if self.credential and not self.authentication_policy:
8276
self.authentication_policy = self._infer_policy(**kwargs)

0 commit comments

Comments
 (0)