Skip to content

Commit e26953f

Browse files
SDKAutoAshraf HamadlmazuelJoshLove-msftahamad-MS
committed
CodeGen from PR 23204 in Azure/azure-rest-api-specs
EventGridv2 TypeSpec Api Preview (Azure#23204) * start typespec * adding eventgrid typespec for api w/ TODOs * update eventgrid typespec with latest eventgrid v2 operations * don't require content-type if there is no body * Update specification/eventgrid/typespec/main.tsp Co-authored-by: JoshLove-msft <[email protected]> * Update specification/eventgrid/typespec/main.tsp Co-authored-by: JoshLove-msft <[email protected]> * changing naming of cloudevent and added in data_base64 * openapi.json * Update specification/eventgrid/typespec/main.tsp Co-authored-by: Libba Lawrence <[email protected]> * Update specification/eventgrid/typespec/main.tsp Co-authored-by: Libba Lawrence <[email protected]> * Update specification/eventgrid/typespec/main.tsp Co-authored-by: Libba Lawrence <[email protected]> * lockTokens format, updated json, optional? params * address code review comments * name_change * add @internal for python * Update specification/eventgrid/Azure.Messaging.EventGrid/main.tsp Co-authored-by: JoshLove-msft <[email protected]> * move @internal to client.tsp (Azure#23538) * rename (Azure#23565) * [EventGrid Typespec] breaking changes with april release of typespec (Azure#23539) * breaking changes with april release of typespec * unknown type * [EG Typespec] Update Release behavior (Azure#23699) * update behavior * just behavior * Add tspconfig and remove AAD auth (Azure#23717) * add tspconfig * add namespace * remove oauth * [EG TypeSpec] Archboard Comments (Azure#23696) * refactoring off of apiview * keep as int * no duration * aligning ack and release * remove behavioral change * ack to release * initial naming changes * Update ReleaseResult doc Co-authored-by: JoshLove-msft <[email protected]> * Update AckResult doc Co-authored-by: JoshLove-msft <[email protected]> * versioning twice-- remove one instance --------- Co-authored-by: JoshLove-msft <[email protected]> * Address couple of stewardship team feedback. These include: 1. Rename CloudEventEvent to simply CloudEvent, 2. Add more description to the operations including the possible erorr codes, 3. Add PublishResult with empty Json object as successful response for the Publish operation, 4. Others. * Add support for missing Reject operation + adding deliveryAttemptCount to BrokerProperties + Adding query parameter for release operation for deliveryDelayInSeconds * Update failedTokens/SuccessfulTokens Description to address code review comments * Update to match service behavior (Azure#23754) * Update to match service behavior * remove locktoken * [EGv2] Editing unused variables (Azure#23917) * event delivery delay not in preview * remove from url comment * [EGv2] Version dependency on Azure.Core (Azure#23936) * verioning fix * spacing mishap? * [EventGrid] Deliveryattempt change (Azure#23960) * deliveryCount 5/1 * small typo * [EventGrid] Remove internal (Azure#23995) * remove internal * remove client.tsp * remove waitWaitTime (Azure#24078) * move location of json file (Azure#24076) * [Egv2] Encode param (Azure#24080) * encode * remove num default on duration --------- Co-authored-by: Laurent Mazuel <[email protected]> * [EGv2] Fix pipeline (Azure#24098) * regen off new commit for encode * reference preview tag * ignore word * update readme to have both apis * update with next autorest * change format to int32 --------- Co-authored-by: Ashraf Hamad <[email protected]> Co-authored-by: Laurent Mazuel <[email protected]> Co-authored-by: JoshLove-msft <[email protected]> Co-authored-by: Ashraf Hamad <[email protected]>
1 parent d99416c commit e26953f

File tree

78 files changed

+5935
-1234
lines changed

Some content is hidden

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

78 files changed

+5935
-1234
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
recursive-include tests *.py *.yaml
2-
recursive-include samples *.py
31
include *.md
42
include LICENSE
5-
include azure/__init__.py
63
include azure/eventgrid/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
6+
include azure/__init__.py
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"commit": "f6f647a40fbbc43dd6e65c4436448129ab7e1fdd",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/eventgrid/Azure.Messaging.EventGrid",
5+
"@azure-tools/typespec-python": {
6+
"version": "0.8.6",
7+
"resolved": "https://registry.npmjs.org/@azure-tools/typespec-python/-/typespec-python-0.8.6.tgz",
8+
"dependencies": {
9+
"@autorest/python": {
10+
"version": "6.4.15",
11+
"resolved": "https://registry.npmjs.org/@autorest/python/-/python-6.4.15.tgz"
12+
}
13+
}
14+
}
15+
}
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: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
57
# --------------------------------------------------------------------------
68

7-
from ._publisher_client import EventGridPublisherClient
8-
from ._event_mappings import SystemEventNames
9-
from ._helpers import generate_sas
10-
from ._models import EventGridEvent
9+
from ._client import EventGridClient
1110
from ._version import VERSION
1211

12+
__version__ = VERSION
13+
14+
try:
15+
from ._patch import __all__ as _patch_all
16+
from ._patch import * # pylint: disable=unused-wildcard-import
17+
except ImportError:
18+
_patch_all = []
19+
from ._patch import patch_sdk as _patch_sdk
20+
1321
__all__ = [
14-
"EventGridPublisherClient",
15-
"EventGridEvent",
16-
"generate_sas",
17-
"SystemEventNames",
22+
"EventGridClient",
1823
]
19-
__version__ = VERSION
24+
__all__.extend([p for p in _patch_all if p not in __all__])
25+
26+
_patch_sdk()
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from copy import deepcopy
10+
from typing import Any
11+
12+
from azure.core import PipelineClient
13+
from azure.core.credentials import AzureKeyCredential
14+
from azure.core.rest import HttpRequest, HttpResponse
15+
16+
from ._configuration import EventGridClientConfiguration
17+
from ._operations import EventGridClientOperationsMixin
18+
from ._serialization import Deserializer, Serializer
19+
20+
21+
class EventGridClient(EventGridClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
22+
"""Azure Messaging EventGrid Client.
23+
24+
:param endpoint: The host name of the namespace, e.g.
25+
namespaceName1.westus-1.eventgrid.azure.net. Required.
26+
:type endpoint: str
27+
:param credential: Credential needed for the client to connect to Azure. Required.
28+
:type credential: ~azure.core.credentials.AzureKeyCredential
29+
:keyword api_version: The API version to use for this operation. Default value is
30+
"2023-06-01-preview". Note that overriding this default value may result in unsupported
31+
behavior.
32+
:paramtype api_version: str
33+
"""
34+
35+
def __init__(self, endpoint: str, credential: AzureKeyCredential, **kwargs: Any) -> None:
36+
_endpoint = "{endpoint}"
37+
self._config = EventGridClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
38+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
39+
40+
self._serialize = Serializer()
41+
self._deserialize = Deserializer()
42+
self._serialize.client_side_validation = False
43+
44+
def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
45+
"""Runs the network request through the client's chained policies.
46+
47+
>>> from azure.core.rest import HttpRequest
48+
>>> request = HttpRequest("GET", "https://www.example.org/")
49+
<HttpRequest [GET], url: 'https://www.example.org/'>
50+
>>> response = client.send_request(request)
51+
<HttpResponse: 200 OK>
52+
53+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
54+
55+
:param request: The network request you want to make. Required.
56+
:type request: ~azure.core.rest.HttpRequest
57+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
58+
:return: The response of your network call. Does not do error handling on your response.
59+
:rtype: ~azure.core.rest.HttpResponse
60+
"""
61+
62+
request_copy = deepcopy(request)
63+
path_format_arguments = {
64+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
65+
}
66+
67+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
68+
return self._client.send_request(request_copy, **kwargs)
69+
70+
def close(self) -> None:
71+
self._client.close()
72+
73+
def __enter__(self) -> "EventGridClient":
74+
self._client.__enter__()
75+
return self
76+
77+
def __exit__(self, *exc_details: Any) -> None:
78+
self._client.__exit__(*exc_details)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import Any
10+
11+
from azure.core.configuration import Configuration
12+
from azure.core.credentials import AzureKeyCredential
13+
from azure.core.pipeline import policies
14+
15+
from ._version import VERSION
16+
17+
18+
class EventGridClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
19+
"""Configuration for EventGridClient.
20+
21+
Note that all parameters used to create this instance are saved as instance
22+
attributes.
23+
24+
:param endpoint: The host name of the namespace, e.g.
25+
namespaceName1.westus-1.eventgrid.azure.net. Required.
26+
:type endpoint: str
27+
:param credential: Credential needed for the client to connect to Azure. Required.
28+
:type credential: ~azure.core.credentials.AzureKeyCredential
29+
:keyword api_version: The API version to use for this operation. Default value is
30+
"2023-06-01-preview". Note that overriding this default value may result in unsupported
31+
behavior.
32+
:paramtype api_version: str
33+
"""
34+
35+
def __init__(self, endpoint: str, credential: AzureKeyCredential, **kwargs: Any) -> None:
36+
super(EventGridClientConfiguration, self).__init__(**kwargs)
37+
api_version: str = kwargs.pop("api_version", "2023-06-01-preview")
38+
39+
if endpoint is None:
40+
raise ValueError("Parameter 'endpoint' must not be None.")
41+
if credential is None:
42+
raise ValueError("Parameter 'credential' must not be None.")
43+
44+
self.endpoint = endpoint
45+
self.credential = credential
46+
self.api_version = api_version
47+
kwargs.setdefault("sdk_moniker", "eventgrid/{}".format(VERSION))
48+
self._configure(**kwargs)
49+
50+
def _configure(self, **kwargs: Any) -> None:
51+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
52+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
53+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
54+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
55+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
56+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
57+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
58+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
59+
self.authentication_policy = kwargs.get("authentication_policy")
60+
if self.credential and not self.authentication_policy:
61+
self.authentication_policy = policies.AzureKeyCredentialPolicy(self.credential, "SharedAccessKey", **kwargs)

0 commit comments

Comments
 (0)