-
Notifications
You must be signed in to change notification settings - Fork 3k
Event grid track 2 #12768
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 #12768
Changes from 20 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
1d79110
genereated python client for event grid
t-swpill aad10b4
updated readme to use track2 generator
t-swpill ce1fa52
added sas key auth sample
t-swpill 05d0e43
added consume sample, not final
t-swpill 91d9e76
removing old eg
t-swpill b9f8611
added track 2 changes needed for api view
t-swpill abf9d75
add consumer operations
t-swpill e3bfc78
cleanup client versions for api view
t-swpill ea0a6fd
remove _initialize_mapping() in BaseEventType class in models
t-swpill 529c6ed
track 2 design manual changes
t-swpill 55b2df5
added publisher wrapper in azure/eventgrid for demo
t-swpill 2dc4f31
modified naming for publish sample for demo
t-swpill 18edaa2
final sample fix for demo
t-swpill 7581cb7
added response to publish_events(), still need to fix
t-swpill 6d8ce6d
added decoder for apiview
t-swpill 3f16127
renamed consumer, added Deserialized/CustomEvent
t-swpill 7446b60
final for Board Review
t-swpill c135026
testing changes
t-swpill 3e45087
added EventGridSharedAccessSignatureCredential,Policy and modified sa…
t-swpill debf2c8
added eg_client test
t-swpill de0ea80
moving generated code out from event_grid_publisher_client nested folder
t-swpill 9f204fd
added consumption function samples
t-swpill d04ddd2
removed eg required package and removed service bus dependency in con…
t-swpill a0bb333
removed unnecessary functions
t-swpill 7141cf2
changed consumer deserialize_event() to take,return single event of o…
t-swpill 325a3ca
added publish tests
t-swpill 7869363
fixed PR, added CustomEvent, added tests/samples
t-swpill 697beb7
updated swagger, removed unnecessary imports
t-swpill 713c97c
removed unnecessary reqs in dev_requirements
t-swpill 00fdf25
changed async publisher import path, added type hints
t-swpill c17340d
modified typehints for publishers, based on apiview
t-swpill d300ccf
added newlines
t-swpill b0ca487
added shared_reqs file
t-swpill 15dad6e
moved shared_requirement
t-swpill ca47c0f
fixed non live test
t-swpill 8971c9f
Merge branch 'master' into event-grid-track-2
t-swpill ed266ee
added changelog, test fix
t-swpill 9c9171d
Merge branch 'event-grid-track-2' of https://github.com/t-swpill/azur…
t-swpill 9b87f0c
changed topic preparer
t-swpill 23dc910
added samples to exclude to setup.py
t-swpill 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,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. | ||
# | ||
# 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. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
t-swpill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# -------------------------------------------------------------------------- | ||
|
||
from .event_grid_client import EventGridClient | ||
from ._publisher_client import EventGridPublisherClient | ||
from ._consumer import EventGridConsumer | ||
from ._helpers import generate_shared_access_signature | ||
from ._models import CloudEvent, CustomEvent, EventGridEvent, DeserializedEvent | ||
from .shared_access_signature_credential import EventGridSharedAccessSignatureCredential | ||
t-swpill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from .version import VERSION | ||
|
||
__all__ = ['EventGridClient'] | ||
|
||
__version__ = VERSION | ||
|
||
__all__ = ['EventGridPublisherClient', 'EventGridConsumer', 'CloudEvent', 'CustomEvent', 'DeserializedEvent', 'EventGridEvent', '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 = '~()*!.\'' |
48 changes: 48 additions & 0 deletions
48
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,48 @@ | ||
# 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 azure.servicebus import ReceivedMessage | ||
t-swpill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from msrest import Deserializer, Serializer | ||
import json | ||
|
||
if TYPE_CHECKING: | ||
# pylint: disable=unused-import,ungrouped-imports | ||
from typing import Any | ||
|
||
from ._models import DeserializedEvent | ||
from ._helpers import generate_shared_access_signature | ||
from . import _constants as constants | ||
|
||
class EventGridConsumer: | ||
t-swpill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
A consumer responsible for deserializing event handler messages into a list of event type objects | ||
specified in the EventGridEvents/CloudEvents. | ||
""" | ||
|
||
def __init__(self, **kwargs): | ||
t-swpill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# type: (Any) -> None | ||
pass | ||
|
||
def deserialize_events(self, events, **kwargs): | ||
# type: (azure.eventhub.EventData, azure.functions.EventGridEvent, azure.servicebus.message.ReceivedMessage, azure.functions.HttpRequest, azure.storage.queue.QueueMessage) -> List[models.DeserializedEvent] | ||
t-swpill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""A message of a list of events in CloudEvent/EventGridEvent format from an event handler will be parsed and returned as a list of | ||
EventContainer objects. | ||
:param events: The event handler message to be deserialized. | ||
:type events: azure.eventhub.EventData or azure.functions.EventGridEvent or azure.servicebus.Message or azure.functions.HttpRequest or azure.storage.queue.QueueMessage | ||
:rtype: List[models.DeserializedEvent] | ||
|
||
:raise: :class:`ValueError`, when events are not of CloudEvent or EventGridEvent format. | ||
""" | ||
if isinstance(events, ReceivedMessage): | ||
t-swpill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dict_event = json.loads(str(events)) | ||
return [DeserializedEvent(dict_event)] | ||
|
||
return None |
5 changes: 5 additions & 0 deletions
5
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,5 @@ | ||
# coding=utf-8 | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ |
16 changes: 16 additions & 0 deletions
16
...ntgrid/azure-eventgrid/azure/eventgrid/_generated/event_grid_publisher_client/__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
.../azure-eventgrid/azure/eventgrid/_generated/event_grid_publisher_client/_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
...id/azure/eventgrid/_generated/event_grid_publisher_client/_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
...id/azure-eventgrid/azure/eventgrid/_generated/event_grid_publisher_client/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
...ntgrid/azure/eventgrid/_generated/event_grid_publisher_client/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
...ventgrid/_generated/event_grid_publisher_client/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
...d/azure/eventgrid/_generated/event_grid_publisher_client/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.