-
Notifications
You must be signed in to change notification settings - Fork 3k
Event grid track 2 #13010
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
Merged
Merged
Event grid track 2 #13010
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ee0293b
Event grid track 2 (#12768)
t-swpill deae7a9
Packaging update of azure-eventgrid
AutorestCI ccb2f66
Fix Tests (#13024)
63513ef
Packaging update of azure-eventgrid
AutorestCI f0d6134
tests fix (#13026)
6e82f7d
Packaging update of azure-eventgrid
AutorestCI a308d85
Update sdk/eventgrid/azure-eventgrid/CHANGELOG.md
23afffe
Event grid v2 (#13051)
b007690
Update sdk/eventgrid/azure-eventgrid/CHANGELOG.md
710136e
Update sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py
e55cff8
Update sdk/eventgrid/azure-eventgrid/CHANGELOG.md
27f743c
Update sdk/eventgrid/azure-eventgrid/azure/eventgrid/_version.py
e05ce13
Event grid v2 (#13177)
6e6e278
Merge branch 'master' into event_grid_v2
4ac4182
Update sdk/eventgrid/azure-eventgrid/tests/_mocks.py
7da8906
Event grid v2 (#13201)
5075d57
Update sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py
b66e968
Update sdk/eventgrid/azure-eventgrid/azure/eventgrid/_models.py
9d6117f
Apply suggestions from code review
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
recursive-include tests *.py *.yaml | ||
recursive-include samples *.py | ||
include *.md | ||
include azure/__init__.py | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
## Microsoft Azure SDK for Python | ||
# Microsoft Azure SDK for Python | ||
|
||
This is the Microsoft Azure Event Grid Client Library. | ||
This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. | ||
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). | ||
|
||
This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7. | ||
|
||
For a more complete set of Azure libraries, see the | ||
[azure sdk python release](https://aka.ms/azsdk/python/all). | ||
# Usage | ||
|
||
## Usage | ||
|
||
For code examples, see [Event | ||
Grid](https://docs.microsoft.com/python/api/overview/azure/event-grid) | ||
For code examples, see [Event Grid](https://docs.microsoft.com/python/api/overview/azure/event-grid) | ||
on docs.microsoft.com. | ||
|
||
## Provide Feedback | ||
|
||
If you encounter any bugs or have suggestions, please file an issue in | ||
the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) | ||
# Provide Feedback | ||
|
||
If you encounter any bugs or have suggestions, please file an issue in the | ||
[Issues](https://github.com/Azure/azure-sdk-for-python/issues) | ||
section of the project. | ||
|
||
 | ||
|
||
 |
21 changes: 10 additions & 11 deletions
21
sdk/eventgrid/azure-eventgrid/azure/eventgrid/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------- | ||
|
||
from .event_grid_client import EventGridClient | ||
from .version import VERSION | ||
|
||
__all__ = ['EventGridClient'] | ||
from ._publisher_client import EventGridPublisherClient | ||
from ._consumer import EventGridConsumer | ||
from ._helpers import generate_shared_access_signature | ||
from ._models import CloudEvent, CustomEvent, EventGridEvent, DeserializedEvent, StorageBlobCreatedEventData | ||
from ._shared_access_signature_credential import EventGridSharedAccessSignatureCredential | ||
from ._version import VERSION | ||
|
||
__all__ = ['EventGridPublisherClient', 'EventGridConsumer', | ||
'CloudEvent', 'CustomEvent', 'DeserializedEvent', 'EventGridEvent', 'StorageBlobCreatedEventData' | ||
'generate_shared_access_signature', 'EventGridSharedAccessSignatureCredential'] | ||
__version__ = VERSION | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
EVENTGRID_KEY_HEADER = 'aeg-sas-key' | ||
EVENTGRID_TOKEN_HEADER = 'aeg-sas-token' | ||
DEFAULT_API_VERSION = "2018-01-01" | ||
SAFE_ENCODE = '~()*!.\'' |
50 changes: 50 additions & 0 deletions
50
sdk/eventgrid/azure-eventgrid/azure/eventgrid/_consumer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from typing import TYPE_CHECKING | ||
import json | ||
import six | ||
import logging | ||
|
||
from azure.core import PipelineClient | ||
from msrest import Deserializer, Serializer | ||
|
||
if TYPE_CHECKING: | ||
# pylint: disable=unused-import,ungrouped-imports | ||
from typing import Any | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
from ._models import DeserializedEvent | ||
|
||
class EventGridConsumer(object): | ||
""" | ||
A consumer responsible for deserializing event handler messages, to allow for access to strongly typed Event objects. | ||
""" | ||
|
||
def deserialize_event(self, event, **kwargs): | ||
KieranBrantnerMagee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# type: (Union[str, dict, bytes]) -> models.DeserializedEvent | ||
"""Single event following CloudEvent/EventGridEvent schema will be parsed and returned as DeserializedEvent. | ||
:param event: The event to be deserialized. | ||
:type event: Union[str, dict, bytes] | ||
:rtype: models.DeserializedEvent | ||
|
||
:raise: :class:`ValueError`, when events do not follow CloudEvent or EventGridEvent schema. | ||
""" | ||
encode = kwargs.pop('encoding', 'utf-8') | ||
try: | ||
if isinstance(event, six.binary_type): | ||
event = json.loads(event.decode(encode)) | ||
elif isinstance(event, six.string_types): | ||
event = json.loads(event) | ||
return DeserializedEvent(event) | ||
except Exception as err: | ||
_LOGGER.error('Error: cannot deserialize event. Event does not have a valid format. Event must be a string, dict, or bytes following the CloudEvent/EventGridEvent schema.') | ||
_LOGGER.error('Your event: {}'.format(event)) | ||
_LOGGER.error(err) | ||
raise ValueError('Error: cannot deserialize event. Event does not have a valid format. Event must be a string, dict, or bytes following the CloudEvent/EventGridEvent schema.') |
16 changes: 16 additions & 0 deletions
16
sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from ._event_grid_publisher_client import EventGridPublisherClient | ||
__all__ = ['EventGridPublisherClient'] | ||
|
||
try: | ||
from ._patch import patch_sdk | ||
patch_sdk() | ||
except ImportError: | ||
pass |
51 changes: 51 additions & 0 deletions
51
sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/_configuration.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from azure.core.configuration import Configuration | ||
from azure.core.pipeline import policies | ||
|
||
if TYPE_CHECKING: | ||
# pylint: disable=unused-import,ungrouped-imports | ||
from typing import Any | ||
|
||
VERSION = "unknown" | ||
|
||
class EventGridPublisherClientConfiguration(Configuration): | ||
"""Configuration for EventGridPublisherClient. | ||
|
||
Note that all parameters used to create this instance are saved as instance | ||
attributes. | ||
|
||
""" | ||
|
||
def __init__( | ||
self, | ||
**kwargs # type: Any | ||
): | ||
# type: (...) -> None | ||
super(EventGridPublisherClientConfiguration, self).__init__(**kwargs) | ||
|
||
self.api_version = "2018-01-01" | ||
kwargs.setdefault('sdk_moniker', 'eventgridpublisherclient/{}'.format(VERSION)) | ||
self._configure(**kwargs) | ||
|
||
def _configure( | ||
self, | ||
**kwargs # type: Any | ||
): | ||
# type: (...) -> 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.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**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.authentication_policy = kwargs.get('authentication_policy') |
54 changes: 54 additions & 0 deletions
54
sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/_event_grid_publisher_client.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from azure.core import PipelineClient | ||
from msrest import Deserializer, Serializer | ||
|
||
if TYPE_CHECKING: | ||
# pylint: disable=unused-import,ungrouped-imports | ||
from typing import Any | ||
|
||
from ._configuration import EventGridPublisherClientConfiguration | ||
from .operations import EventGridPublisherClientOperationsMixin | ||
from . import models | ||
|
||
|
||
class EventGridPublisherClient(EventGridPublisherClientOperationsMixin): | ||
"""EventGrid Python Publisher Client. | ||
|
||
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
**kwargs # type: Any | ||
): | ||
# type: (...) -> None | ||
base_url = 'https://{topicHostname}' | ||
self._config = EventGridPublisherClientConfiguration(**kwargs) | ||
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) | ||
|
||
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} | ||
self._serialize = Serializer(client_models) | ||
self._deserialize = Deserializer(client_models) | ||
|
||
|
||
def close(self): | ||
# type: () -> None | ||
self._client.close() | ||
|
||
def __enter__(self): | ||
# type: () -> EventGridPublisherClient | ||
self._client.__enter__() | ||
return self | ||
|
||
def __exit__(self, *exc_details): | ||
# type: (Any) -> None | ||
self._client.__exit__(*exc_details) |
10 changes: 10 additions & 0 deletions
10
sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from ._event_grid_publisher_client_async import EventGridPublisherClient | ||
__all__ = ['EventGridPublisherClient'] |
45 changes: 45 additions & 0 deletions
45
sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/_configuration_async.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from typing import Any | ||
|
||
from azure.core.configuration import Configuration | ||
from azure.core.pipeline import policies | ||
|
||
VERSION = "unknown" | ||
|
||
class EventGridPublisherClientConfiguration(Configuration): | ||
"""Configuration for EventGridPublisherClient. | ||
|
||
Note that all parameters used to create this instance are saved as instance | ||
attributes. | ||
|
||
""" | ||
|
||
def __init__( | ||
self, | ||
**kwargs: Any | ||
) -> None: | ||
super(EventGridPublisherClientConfiguration, self).__init__(**kwargs) | ||
|
||
self.api_version = "2018-01-01" | ||
kwargs.setdefault('sdk_moniker', 'eventgridpublisherclient/{}'.format(VERSION)) | ||
self._configure(**kwargs) | ||
|
||
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.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) | ||
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) | ||
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) | ||
self.authentication_policy = kwargs.get('authentication_policy') |
46 changes: 46 additions & 0 deletions
46
...grid/azure-eventgrid/azure/eventgrid/_generated/aio/_event_grid_publisher_client_async.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from typing import Any | ||
|
||
from azure.core import AsyncPipelineClient | ||
from msrest import Deserializer, Serializer | ||
|
||
from ._configuration_async import EventGridPublisherClientConfiguration | ||
from .operations_async import EventGridPublisherClientOperationsMixin | ||
from .. import models | ||
|
||
|
||
class EventGridPublisherClient(EventGridPublisherClientOperationsMixin): | ||
"""EventGrid Python Publisher Client. | ||
|
||
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
**kwargs: Any | ||
) -> None: | ||
base_url = 'https://{topicHostname}' | ||
self._config = EventGridPublisherClientConfiguration(**kwargs) | ||
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) | ||
|
||
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} | ||
self._serialize = Serializer(client_models) | ||
self._deserialize = Deserializer(client_models) | ||
|
||
|
||
async def close(self) -> None: | ||
await self._client.close() | ||
|
||
async def __aenter__(self) -> "EventGridPublisherClient": | ||
await self._client.__aenter__() | ||
return self | ||
|
||
async def __aexit__(self, *exc_details) -> None: | ||
await self._client.__aexit__(*exc_details) |
13 changes: 13 additions & 0 deletions
13
sdk/eventgrid/azure-eventgrid/azure/eventgrid/_generated/aio/operations_async/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from ._event_grid_publisher_client_operations_async import EventGridPublisherClientOperationsMixin | ||
|
||
__all__ = [ | ||
'EventGridPublisherClientOperationsMixin', | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.