From 3cd4cbe43c970db18e08349e6504542f6ecf0e55 Mon Sep 17 00:00:00 2001 From: t-swpill <66144935+t-swpill@users.noreply.github.com> Date: Mon, 10 Aug 2020 18:05:38 -0400 Subject: [PATCH 01/20] Event grid track 2 (#12768) * genereated python client for event grid * updated readme to use track2 generator * added sas key auth sample * added consume sample, not final * removing old eg * added track 2 changes needed for api view * add consumer operations * cleanup client versions for api view * remove _initialize_mapping() in BaseEventType class in models * track 2 design manual changes * added publisher wrapper in azure/eventgrid for demo * modified naming for publish sample for demo * final sample fix for demo * added response to publish_events(), still need to fix * added decoder for apiview * renamed consumer, added Deserialized/CustomEvent * final for Board Review * testing changes * added EventGridSharedAccessSignatureCredential,Policy and modified samples * added eg_client test * moving generated code out from event_grid_publisher_client nested folder * added consumption function samples * removed eg required package and removed service bus dependency in consumer * removed unnecessary functions * changed consumer deserialize_event() to take,return single event of one type of (string, bytes string, dict). changed DeserializedEvent to have to_json() method, instead of extending DictMixin * added publish tests * fixed PR, added CustomEvent, added tests/samples * updated swagger, removed unnecessary imports * removed unnecessary reqs in dev_requirements * changed async publisher import path, added type hints * modified typehints for publishers, based on apiview * added newlines * added shared_reqs file * moved shared_requirement * fixed non live test * added changelog, test fix * changed topic preparer * added samples to exclude to setup.py --- sdk/eventgrid/azure-eventgrid/setup.py | 13 +------------ .../azure-eventgrid/tests/eventgrid_preparer.py | 1 - ...r_client_publish_event_grid_event_data_dict.yaml | 1 + 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/setup.py b/sdk/eventgrid/azure-eventgrid/setup.py index 9353b747230e1..0091677a59ce6 100644 --- a/sdk/eventgrid/azure-eventgrid/setup.py +++ b/sdk/eventgrid/azure-eventgrid/setup.py @@ -22,18 +22,6 @@ # azure v0.x is not compatible with this package # azure v0.x used to have a __version__ attribute (newer versions don't) -try: - import azure - try: - ver = azure.__version__ - raise Exception( - 'This package is incompatible with azure=={}. '.format(ver) + - 'Uninstall it with "pip uninstall azure".' - ) - except AttributeError: - pass -except ImportError: - pass # Version extraction inspired from 'requests' with open(os.path.join(package_folder_path, 'version.py') @@ -77,6 +65,7 @@ 'tests', 'samples', # Exclude packages that will be covered by PEP420 or nspkg + 'samples', 'azure', ]), install_requires=[ diff --git a/sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py b/sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py index d56af2bcebca2..ad6fefa5d0aa4 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py +++ b/sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py @@ -86,7 +86,6 @@ def remove_resource(self, name, **kwargs): if self.is_live: group = self._get_resource_group(**kwargs) self.client.topics.delete(group.name, name, polling=False) - def _get_resource_group(self, **kwargs): try: return kwargs.get(self.resource_group_parameter_name) diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_eg_publisher_client_publish_event_grid_event_data_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_eg_publisher_client_publish_event_grid_event_data_dict.yaml index 80389ad9f7e5e..cdfc16f790776 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_eg_publisher_client_publish_event_grid_event_data_dict.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_eg_publisher_client_publish_event_grid_event_data_dict.yaml @@ -1,3 +1,4 @@ + interactions: - request: body: '[{"id": "38eab883-eb07-4ae1-9ff4-12ebaf022113", "subject": "sample", "data": From 69ce1f1cc8c4024c4a57a5d752d3dfe0f3d667b4 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot Date: Mon, 10 Aug 2020 22:08:47 +0000 Subject: [PATCH 02/20] Packaging update of azure-eventgrid --- sdk/eventgrid/azure-eventgrid/setup.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/setup.py b/sdk/eventgrid/azure-eventgrid/setup.py index 0091677a59ce6..294e7b213eca0 100644 --- a/sdk/eventgrid/azure-eventgrid/setup.py +++ b/sdk/eventgrid/azure-eventgrid/setup.py @@ -22,6 +22,18 @@ # azure v0.x is not compatible with this package # azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass # Version extraction inspired from 'requests' with open(os.path.join(package_folder_path, 'version.py') @@ -49,7 +61,7 @@ author_email='azpysdkhelp@microsoft.com', url='https://github.com/Azure/azure-sdk-for-python', classifiers=[ - 'Development Status :: 4 - Beta', + 'Development Status :: 5 - Production/Stable', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', @@ -65,12 +77,12 @@ 'tests', 'samples', # Exclude packages that will be covered by PEP420 or nspkg - 'samples', 'azure', ]), install_requires=[ 'msrest>=0.5.0', - 'azure-core<2.0.0,>=1.7.0', + 'msrestazure>=0.4.32,<2.0.0', + 'azure-common~=1.1', ], extras_require={ ":python_version<'3.0'": ['azure-nspkg'], From da433c169ced9b4375896450f31d86cc3fe8fc52 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot Date: Tue, 11 Aug 2020 07:01:19 +0000 Subject: [PATCH 03/20] Packaging update of azure-eventgrid --- sdk/eventgrid/azure-eventgrid/MANIFEST.in | 1 - sdk/eventgrid/azure-eventgrid/setup.py | 1 - 2 files changed, 2 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/MANIFEST.in b/sdk/eventgrid/azure-eventgrid/MANIFEST.in index abba13db8db22..cad40fe06b5fe 100644 --- a/sdk/eventgrid/azure-eventgrid/MANIFEST.in +++ b/sdk/eventgrid/azure-eventgrid/MANIFEST.in @@ -1,5 +1,4 @@ recursive-include tests *.py *.yaml -recursive-include samples *.py include *.md include azure/__init__.py diff --git a/sdk/eventgrid/azure-eventgrid/setup.py b/sdk/eventgrid/azure-eventgrid/setup.py index 294e7b213eca0..9c3b4b10b03e9 100644 --- a/sdk/eventgrid/azure-eventgrid/setup.py +++ b/sdk/eventgrid/azure-eventgrid/setup.py @@ -75,7 +75,6 @@ zip_safe=False, packages=find_packages(exclude=[ 'tests', - 'samples', # Exclude packages that will be covered by PEP420 or nspkg 'azure', ]), From 88bd601809eb4c7000236a09cab1853b186dbf48 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 11 Aug 2020 12:36:53 -0700 Subject: [PATCH 04/20] tests fix (#13026) * other fixes * p2 compat --- sdk/eventgrid/azure-eventgrid/MANIFEST.in | 1 + sdk/eventgrid/azure-eventgrid/setup.py | 1 + 2 files changed, 2 insertions(+) diff --git a/sdk/eventgrid/azure-eventgrid/MANIFEST.in b/sdk/eventgrid/azure-eventgrid/MANIFEST.in index cad40fe06b5fe..abba13db8db22 100644 --- a/sdk/eventgrid/azure-eventgrid/MANIFEST.in +++ b/sdk/eventgrid/azure-eventgrid/MANIFEST.in @@ -1,4 +1,5 @@ recursive-include tests *.py *.yaml +recursive-include samples *.py include *.md include azure/__init__.py diff --git a/sdk/eventgrid/azure-eventgrid/setup.py b/sdk/eventgrid/azure-eventgrid/setup.py index 9c3b4b10b03e9..294e7b213eca0 100644 --- a/sdk/eventgrid/azure-eventgrid/setup.py +++ b/sdk/eventgrid/azure-eventgrid/setup.py @@ -75,6 +75,7 @@ zip_safe=False, packages=find_packages(exclude=[ 'tests', + 'samples', # Exclude packages that will be covered by PEP420 or nspkg 'azure', ]), From 5303288f2178b41f7cb771d18bfc707014b14078 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot Date: Tue, 11 Aug 2020 19:40:01 +0000 Subject: [PATCH 05/20] Packaging update of azure-eventgrid --- sdk/eventgrid/azure-eventgrid/MANIFEST.in | 1 - sdk/eventgrid/azure-eventgrid/setup.py | 1 - 2 files changed, 2 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/MANIFEST.in b/sdk/eventgrid/azure-eventgrid/MANIFEST.in index abba13db8db22..cad40fe06b5fe 100644 --- a/sdk/eventgrid/azure-eventgrid/MANIFEST.in +++ b/sdk/eventgrid/azure-eventgrid/MANIFEST.in @@ -1,5 +1,4 @@ recursive-include tests *.py *.yaml -recursive-include samples *.py include *.md include azure/__init__.py diff --git a/sdk/eventgrid/azure-eventgrid/setup.py b/sdk/eventgrid/azure-eventgrid/setup.py index 294e7b213eca0..9c3b4b10b03e9 100644 --- a/sdk/eventgrid/azure-eventgrid/setup.py +++ b/sdk/eventgrid/azure-eventgrid/setup.py @@ -75,7 +75,6 @@ zip_safe=False, packages=find_packages(exclude=[ 'tests', - 'samples', # Exclude packages that will be covered by PEP420 or nspkg 'azure', ]), From 04a61c42fb7e5246b2841152f6011c4c47e77946 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 11 Aug 2020 15:05:04 -0700 Subject: [PATCH 06/20] Event grid v2 (#13051) * other fixes * auto update --- sdk/eventgrid/azure-eventgrid/MANIFEST.in | 1 + sdk/eventgrid/azure-eventgrid/setup.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/MANIFEST.in b/sdk/eventgrid/azure-eventgrid/MANIFEST.in index cad40fe06b5fe..abba13db8db22 100644 --- a/sdk/eventgrid/azure-eventgrid/MANIFEST.in +++ b/sdk/eventgrid/azure-eventgrid/MANIFEST.in @@ -1,4 +1,5 @@ recursive-include tests *.py *.yaml +recursive-include samples *.py include *.md include azure/__init__.py diff --git a/sdk/eventgrid/azure-eventgrid/setup.py b/sdk/eventgrid/azure-eventgrid/setup.py index 9c3b4b10b03e9..9353b747230e1 100644 --- a/sdk/eventgrid/azure-eventgrid/setup.py +++ b/sdk/eventgrid/azure-eventgrid/setup.py @@ -61,7 +61,7 @@ author_email='azpysdkhelp@microsoft.com', url='https://github.com/Azure/azure-sdk-for-python', classifiers=[ - 'Development Status :: 5 - Production/Stable', + 'Development Status :: 4 - Beta', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', @@ -75,13 +75,13 @@ zip_safe=False, packages=find_packages(exclude=[ 'tests', + 'samples', # Exclude packages that will be covered by PEP420 or nspkg 'azure', ]), install_requires=[ 'msrest>=0.5.0', - 'msrestazure>=0.4.32,<2.0.0', - 'azure-common~=1.1', + 'azure-core<2.0.0,>=1.7.0', ], extras_require={ ":python_version<'3.0'": ['azure-nspkg'], From 7d35094467f9ef27e543e1244a86aa2b0340d218 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Mon, 17 Aug 2020 00:55:16 -0700 Subject: [PATCH 07/20] Send spec initial --- .../azure/eventgrid/_helpers.py | 8 ++ .../azure/eventgrid/_publisher_client.py | 26 ++++- .../eventgrid/aio/_publisher_client_async.py | 30 +++-- .../tests/test_eg_publisher_client.py | 107 +++++++++++++++--- 4 files changed, 143 insertions(+), 28 deletions(-) diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py index 020150fe897ea..2cbebfbefe522 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py @@ -70,3 +70,11 @@ def _get_authentication_policy(credential): if isinstance(credential, EventGridSharedAccessSignatureCredential): authentication_policy = EventGridSharedAccessSignatureCredentialPolicy(credential=credential, name=constants.EVENTGRID_TOKEN_HEADER) return authentication_policy + +def _is_cloud_event(event): + # type: dict -> bool + required = ('id', 'source', 'specversion', 'type') + try: + return all([_ in event for _ in required]) and event['specversion'] == "1.0" + except TypeError: + pass diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py index 9c90992c69e66..bdaf35a446b82 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py @@ -13,13 +13,23 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any + from typing import Any, Union, Dict, List + SendType = Union[ + CloudEvent, + EventGridEvent, + CustomEvent, + Dict, + List[CloudEvent], + List[EventGridEvent], + List[CustomEvent] + ] from ._models import CloudEvent, EventGridEvent, CustomEvent -from ._helpers import _get_topic_hostname_only_fqdn, _get_authentication_policy +from ._helpers import _get_topic_hostname_only_fqdn, _get_authentication_policy, _is_cloud_event from ._generated._event_grid_publisher_client import EventGridPublisherClient as EventGridPublisherClientImpl from . import _constants as constants + class EventGridPublisherClient(object): """EventGrid Python Publisher Client. @@ -36,9 +46,9 @@ def __init__(self, topic_hostname, credential, **kwargs): self._topic_hostname = topic_hostname auth_policy = _get_authentication_policy(credential) self._client = EventGridPublisherClientImpl(authentication_policy=auth_policy, **kwargs) - + def send(self, events, **kwargs): - # type: (Union[List[CloudEvent], List[EventGridEvent], List[CustomEvent]], Any) -> None + # type: (SendType, Any) -> None """Sends event data to topic hostname specified during client initialization. :param events: A list of CloudEvent/EventGridEvent/CustomEvent to be sent. @@ -46,10 +56,14 @@ def send(self, events, **kwargs): :rtype: None raise: :class:`ValueError`, when events do not follow specified SendType. """ + if not isinstance(events, list): + events = [events] - if all(isinstance(e, CloudEvent) for e in events): + if all(isinstance(e, CloudEvent) for e in events) or all(_is_cloud_event(e) for e in events): + kwargs.setdefault("content_type", "application/cloudevents-batch+json; charset=utf-8") self._client.publish_cloud_event_events(self._topic_hostname, events, **kwargs) - elif all(isinstance(e, EventGridEvent) for e in events): + elif all(isinstance(e, EventGridEvent) for e in events) or all(isinstance(e, dict) for e in events): + kwargs.setdefault("content_type", "application/json; charset=utf-8") self._client.publish_events(self._topic_hostname, events, **kwargs) elif all(isinstance(e, CustomEvent) for e in events): serialized_events = [dict(e) for e in events] diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py index 2bc93dd6981f2..29e328acfd529 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py @@ -12,12 +12,24 @@ from msrest import Deserializer, Serializer from .._models import CloudEvent, EventGridEvent -from .._helpers import _get_topic_hostname_only_fqdn, _get_authentication_policy +from .._helpers import _get_topic_hostname_only_fqdn, _get_authentication_policy, _is_cloud_event from azure.core.pipeline.policies import AzureKeyCredentialPolicy from azure.core.credentials import AzureKeyCredential from .._generated.aio import EventGridPublisherClient as EventGridPublisherClientAsync from .. import _constants as constants +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Union, Dict, List + SendType = Union[ + CloudEvent, + EventGridEvent, + CustomEvent, + Dict, + List[CloudEvent], + List[EventGridEvent], + List[CustomEvent] + ] class EventGridPublisherClient(object): """Asynchronous EventGrid Python Publisher Client. @@ -35,7 +47,7 @@ def __init__(self, topic_hostname, credential, **kwargs): async def send(self, events, **kwargs): - # type: (Union[List[CloudEvent], List[EventGridEvent], List[CustomEvent]], Any) -> None + # type: (SendType) -> None """Sends event data to topic hostname specified during client initialization. :param events: A list of CloudEvent/EventGridEvent/CustomEvent to be sent. @@ -43,14 +55,18 @@ async def send(self, events, **kwargs): :rtype: None raise: :class:`ValueError`, when events do not follow specified SendType. """ + if not isinstance(events, list): + events = [events] - if all(isinstance(e, CloudEvent) for e in events): - await self._client.publish_cloud_event_events(self._topic_hostname, events, **kwargs) - elif all(isinstance(e, EventGridEvent) for e in events): - await self._client.publish_events(self._topic_hostname, events, **kwargs) + if all(isinstance(e, CloudEvent) for e in events) or all(_is_cloud_event(e) for e in events): + kwargs.setdefault("content_type", "application/cloudevents-batch+json; charset=utf-8") + self._client.publish_cloud_event_events(self._topic_hostname, events, **kwargs) + elif all(isinstance(e, EventGridEvent) for e in events) or all(isinstance(e, dict) for e in events): + kwargs.setdefault("content_type", "application/json; charset=utf-8") + self._client.publish_events(self._topic_hostname, events, **kwargs) elif all(isinstance(e, CustomEvent) for e in events): serialized_events = [dict(e) for e in events] - await self._client.publish_custom_event_events(self._topic_hostname, serialized_events, **kwargs) + self._client.publish_custom_event_events(self._topic_hostname, serialized_events, **kwargs) else: raise ValueError("Event schema is not correct.") diff --git a/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py b/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py index 17924d3b06f53..dd7e7e8d75a94 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py +++ b/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py @@ -25,7 +25,7 @@ class EventGridPublisherClientTests(AzureMgmtTestCase): @pytest.mark.liveTest @CachedResourceGroupPreparer(name_prefix='eventgridtest') @CachedEventGridTopicPreparer(name_prefix='eventgridtest') - def test_eg_publisher_client_publish_event_grid_event_data_dict(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + def test_send_event_grid_event_data_dict(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) eg_event = EventGridEvent( @@ -34,12 +34,32 @@ def test_eg_publisher_client_publish_event_grid_event_data_dict(self, resource_g event_type="Sample.EventGrid.Event", data_version="2.0" ) - client.send([eg_event]) + client.send(eg_event) @pytest.mark.liveTest @CachedResourceGroupPreparer(name_prefix='eventgridtest') @CachedEventGridTopicPreparer(name_prefix='eventgridtest') - def test_eg_publisher_client_publish_event_grid_event_data_str(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + def test_send_event_grid_event_data_as_list(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + eg_event1 = EventGridEvent( + subject="sample", + data="eventgridevent", + event_type="Sample.EventGrid.Event", + data_version="2.0" + ) + eg_event2 = EventGridEvent( + subject="sample2", + data="eventgridevent2", + event_type="Sample.EventGrid.Event", + data_version="2.0" + ) + client.send([eg_event1, eg_event2]) + + @pytest.mark.liveTest + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='eventgridtest') + def test_send_event_grid_event_data_str(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) eg_event = EventGridEvent( @@ -48,12 +68,12 @@ def test_eg_publisher_client_publish_event_grid_event_data_str(self, resource_gr event_type="Sample.EventGrid.Event", data_version="2.0" ) - client.send([eg_event]) + client.send(eg_event) @pytest.mark.liveTest @CachedResourceGroupPreparer(name_prefix='eventgridtest') @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') - def test_eg_publisher_client_publish_cloud_event_data_dict(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + def test_send_cloud_event_data_dict(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) cloud_event = CloudEvent( @@ -61,25 +81,54 @@ def test_eg_publisher_client_publish_cloud_event_data_dict(self, resource_group, data = {"sample": "cloudevent"}, type="Sample.Cloud.Event" ) - client.send([cloud_event]) + client.send(cloud_event) + + # @pytest.mark.liveTest + # @CachedResourceGroupPreparer(name_prefix='eventgridtest') + # @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') + # def test_send_cloud_event_data_str(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + # akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + # client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + # cloud_event = CloudEvent( + # source = "http://samplesource.dev", + # data = "cloudevent", + # type="Sample.Cloud.Event" + # ) + # client.send(cloud_event) + @pytest.mark.liveTest @CachedResourceGroupPreparer(name_prefix='eventgridtest') - @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') - def test_eg_publisher_client_publish_cloud_event_data_str(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + @CachedEventGridTopicPreparer(name_prefix='eventgridtest') + def test_send_cloud_event_data_as_list(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) - cloud_event = CloudEvent( + cloud_event1 = CloudEvent( source = "http://samplesource.dev", data = "cloudevent", type="Sample.Cloud.Event" ) - client.send([cloud_event]) - + client.send([cloud_event1]) + @pytest.mark.liveTest @CachedResourceGroupPreparer(name_prefix='eventgridtest') @CachedEventGridTopicPreparer(name_prefix='eventgridtest') - def test_eg_publisher_client_publish_signature_credential(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + def test_send_cloud_event_dict(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + cloud_event1 = { + "id": "1234", + "source": "http://samplesource.dev", + "specversion": "1.0", + "data": "cloudevent", + "type": "Sample.Cloud.Event" + } + client.send(cloud_event1) + + @pytest.mark.liveTest + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='eventgridtest') + def test_send_signature_credential(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): expiration_date_utc = dt.datetime.now(UTC()) + timedelta(hours=1) signature = generate_shared_access_signature(eventgrid_topic_endpoint, eventgrid_topic_primary_key, expiration_date_utc) credential = EventGridSharedAccessSignatureCredential(signature) @@ -90,12 +139,12 @@ def test_eg_publisher_client_publish_signature_credential(self, resource_group, event_type="Sample.EventGrid.Event", data_version="2.0" ) - client.send([eg_event]) + client.send(eg_event) @pytest.mark.liveTest @CachedResourceGroupPreparer(name_prefix='eventgridtest') @CachedEventGridTopicPreparer(name_prefix='customeventgridtest') - def test_eg_publisher_client_publish_custom_schema_event(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + def test_send_custom_schema_event(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) custom_event = CustomEvent( @@ -108,4 +157,32 @@ def test_eg_publisher_client_publish_custom_schema_event(self, resource_group, e "customData": "sample data" } ) - client.send([custom_event]) \ No newline at end of file + client.send(custom_event) + + @pytest.mark.liveTest + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='customeventgridtest') + def test_send_custom_schema_event_as_list(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + custom_event1 = CustomEvent( + { + "customSubject": "sample", + "customEventType": "sample.event", + "customDataVersion": "2.0", + "customId": "1234", + "customEventTime": dt.datetime.now(UTC()).isoformat(), + "customData": "sample data" + } + ) + custom_event2 = CustomEvent( + { + "customSubject": "sample2", + "customEventType": "sample.event", + "customDataVersion": "2.0", + "customId": "12345", + "customEventTime": dt.datetime.now(UTC()).isoformat(), + "customData": "sample data 2" + } + ) + client.send([custom_event1, custom_event2]) \ No newline at end of file From 977e1402e31156d9381b63dd58230c50f72ad8d4 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 18 Aug 2020 19:55:23 -0700 Subject: [PATCH 08/20] recordings --- ...nt.test_send_cloud_event_data_as_list.yaml | 47 +++++++++++++++++++ ...lient.test_send_cloud_event_data_dict.yaml | 40 ++++++++++++++++ ...her_client.test_send_cloud_event_dict.yaml | 46 ++++++++++++++++++ ..._client.test_send_custom_schema_event.yaml | 40 ++++++++++++++++ ...test_send_custom_schema_event_as_list.yaml | 42 +++++++++++++++++ ...st_send_event_grid_event_data_as_list.yaml | 42 +++++++++++++++++ ....test_send_event_grid_event_data_dict.yaml | 40 ++++++++++++++++ ...t.test_send_event_grid_event_data_str.yaml | 40 ++++++++++++++++ ...client.test_send_signature_credential.yaml | 40 ++++++++++++++++ 9 files changed, 377 insertions(+) create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_as_list.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_dict.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_dict.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event_as_list.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_as_list.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_dict.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_str.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_signature_credential.yaml diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_as_list.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_as_list.yaml new file mode 100644 index 0000000000000..b686499659cc6 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_as_list.yaml @@ -0,0 +1,47 @@ +interactions: +- request: + body: '[{"id": "fe01f535-bfe8-4bfb-9732-5530cac95677", "source": "http://samplesource.dev", + "data": "cloudevent", "type": "Sample.Cloud.Event", "time": "2020-08-19T02:54:26.937747Z", + "specversion": "1.0"}]' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '198' + Content-Type: + - application/cloudevents-batch+json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - CNX1dEvFh9P+c93UazUJ0+FSB4v104amtip6jD/KQsY= + method: POST + uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: "{\r\n \"error\": {\r\n \"code\": \"BadRequest\",\r\n \"message\": + \"Unexpected property 'source' found in JSON. Report '2ce71012-6cad-4ba0-8fdb-b910b7f03670:1:8/19/2020 + 2:54:28 AM (UTC)' to our forums for assistance or raise a support ticket.\",\r\n + \ \"details\": [{\r\n \"code\": \"InputJsonInvalid\",\r\n + \ \"message\": \"Unexpected property 'source' found in JSON. Report + '2ce71012-6cad-4ba0-8fdb-b910b7f03670:1:8/19/2020 2:54:28 AM (UTC)' to our + forums for assistance or raise a support ticket.\"\r\n }]\r\n }\r\n}" + headers: + content-length: + - '527' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 19 Aug 2020 02:54:27 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 400 + message: Unexpected property 'source' found in JSON. Report '2ce71012-6cad-4ba0-8fdb-b910b7f03670:1:8/19/2020 + 2:54:28 AM (UTC)' to our forums for assistance or raise a support ticket. +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_dict.yaml new file mode 100644 index 0000000000000..6c11fb99a5a55 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_dict.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '[{"id": "b97b41af-2e19-4889-87a1-e289766ecf89", "source": "http://samplesource.dev", + "data": {"sample": "cloudevent"}, "type": "Sample.Cloud.Event", "time": "2020-08-19T02:54:40.927831Z", + "specversion": "1.0"}]' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '210' + Content-Type: + - application/cloudevents-batch+json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - 1H1Q60s9Apm1iLiSOyunHE0EF2NeA1muzLR2Q6VOSps= + method: POST + uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: + - '2018-01-01' + content-length: + - '0' + date: + - Wed, 19 Aug 2020 02:54:41 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_dict.yaml new file mode 100644 index 0000000000000..f4ada63d5a72f --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_dict.yaml @@ -0,0 +1,46 @@ +interactions: +- request: + body: '[{"id": "1234", "source": "http://samplesource.dev", "data": "cloudevent", + "type": "Sample.Cloud.Event", "specversion": "1.0"}]' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '127' + Content-Type: + - application/cloudevents-batch+json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - CNX1dEvFh9P+c93UazUJ0+FSB4v104amtip6jD/KQsY= + method: POST + uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: "{\r\n \"error\": {\r\n \"code\": \"BadRequest\",\r\n \"message\": + \"Unexpected property 'source' found in JSON. Report '5a0ead52-e8aa-4b1e-b34e-6c70f25010d7:3:8/19/2020 + 2:54:42 AM (UTC)' to our forums for assistance or raise a support ticket.\",\r\n + \ \"details\": [{\r\n \"code\": \"InputJsonInvalid\",\r\n + \ \"message\": \"Unexpected property 'source' found in JSON. Report + '5a0ead52-e8aa-4b1e-b34e-6c70f25010d7:3:8/19/2020 2:54:42 AM (UTC)' to our + forums for assistance or raise a support ticket.\"\r\n }]\r\n }\r\n}" + headers: + content-length: + - '527' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 19 Aug 2020 02:54:42 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 400 + message: Unexpected property 'source' found in JSON. Report '5a0ead52-e8aa-4b1e-b34e-6c70f25010d7:3:8/19/2020 + 2:54:42 AM (UTC)' to our forums for assistance or raise a support ticket. +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event.yaml new file mode 100644 index 0000000000000..d20008c84839f --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '[{"customSubject": "sample", "customEventType": "sample.event", "customDataVersion": + "2.0", "customId": "1234", "customEventTime": "2020-08-19T02:54:55.283370+00:00", + "customData": "sample data"}]' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '196' + Content-Type: + - application/json + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - bnShWuasxyRJT++S3CR8dxx+MBjyJ06zq9X/JxxNNKM= + method: POST + uri: https://customeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: + - '2018-01-01' + content-length: + - '0' + date: + - Wed, 19 Aug 2020 02:54:56 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event_as_list.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event_as_list.yaml new file mode 100644 index 0000000000000..98592a993b189 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event_as_list.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: '[{"customSubject": "sample", "customEventType": "sample.event", "customDataVersion": + "2.0", "customId": "1234", "customEventTime": "2020-08-19T02:54:55.786334+00:00", + "customData": "sample data"}, {"customSubject": "sample2", "customEventType": + "sample.event", "customDataVersion": "2.0", "customId": "12345", "customEventTime": + "2020-08-19T02:54:55.787335+00:00", "customData": "sample data 2"}]' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '396' + Content-Type: + - application/json + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - bnShWuasxyRJT++S3CR8dxx+MBjyJ06zq9X/JxxNNKM= + method: POST + uri: https://customeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: + - '2018-01-01' + content-length: + - '0' + date: + - Wed, 19 Aug 2020 02:54:57 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_as_list.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_as_list.yaml new file mode 100644 index 0000000000000..1dbdb480dc040 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_as_list.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: '[{"id": "f7813081-9a94-48b1-b92a-a812fa10512b", "subject": "sample", "data": + "eventgridevent", "eventType": "Sample.EventGrid.Event", "eventTime": "2020-08-19T02:54:56.159379Z", + "dataVersion": "2.0"}, {"id": "d73c89b5-639d-4900-aef9-d91df428a2c4", "subject": + "sample2", "data": "eventgridevent2", "eventType": "Sample.EventGrid.Event", + "eventTime": "2020-08-19T02:54:56.159379Z", "dataVersion": "2.0"}]' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '402' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - CNX1dEvFh9P+c93UazUJ0+FSB4v104amtip6jD/KQsY= + method: POST + uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: + - '2018-01-01' + content-length: + - '0' + date: + - Wed, 19 Aug 2020 02:54:56 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_dict.yaml new file mode 100644 index 0000000000000..900d7de9c87d9 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_dict.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '[{"id": "de0ca0b5-a8ab-48e4-8c50-d96545c5af76", "subject": "sample", "data": + {"sample": "eventgridevent"}, "eventType": "Sample.EventGrid.Event", "eventTime": + "2020-08-19T02:54:56.478324Z", "dataVersion": "2.0"}]' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '212' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - CNX1dEvFh9P+c93UazUJ0+FSB4v104amtip6jD/KQsY= + method: POST + uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: + - '2018-01-01' + content-length: + - '0' + date: + - Wed, 19 Aug 2020 02:54:57 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_str.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_str.yaml new file mode 100644 index 0000000000000..4ead5265b2970 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_str.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '[{"id": "9d3e0cd3-57a8-448c-85a5-4eedef1a2d8e", "subject": "sample", "data": + "eventgridevent", "eventType": "Sample.EventGrid.Event", "eventTime": "2020-08-19T02:54:56.786336Z", + "dataVersion": "2.0"}]' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '200' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - CNX1dEvFh9P+c93UazUJ0+FSB4v104amtip6jD/KQsY= + method: POST + uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: + - '2018-01-01' + content-length: + - '0' + date: + - Wed, 19 Aug 2020 02:54:57 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_signature_credential.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_signature_credential.yaml new file mode 100644 index 0000000000000..28c579a3336cf --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_signature_credential.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '[{"id": "b2997db2-24a8-42bc-b254-a3bb83217e3a", "subject": "sample", "data": + {"sample": "eventgridevent"}, "eventType": "Sample.EventGrid.Event", "eventTime": + "2020-08-19T02:54:57.067382Z", "dataVersion": "2.0"}]' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '212' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-token: + - r=https%3A%2F%2Feventgridtestj5ziptothnf.westus-1.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=2020-08-19%2003%3A54%3A57.065388%2B00%3A00&s=bDccCYZSzjz0%2BQ6nwsQ1ZDJdO%2BIJrbwqQRTG%2BGPaTrw%3D + method: POST + uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: + - '2018-01-01' + content-length: + - '0' + date: + - Wed, 19 Aug 2020 02:54:57 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 From 5fe65162cfe85e91b1b3130011dfdfdeb51be333 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 18 Aug 2020 20:37:28 -0700 Subject: [PATCH 09/20] tests fix --- ...nt.test_send_cloud_event_data_as_list.yaml | 29 +++++--------- ...lient.test_send_cloud_event_data_dict.yaml | 8 ++-- ...client.test_send_cloud_event_data_str.yaml | 40 +++++++++++++++++++ ...her_client.test_send_cloud_event_dict.yaml | 25 +++++------- ..._client.test_send_custom_schema_event.yaml | 6 +-- ...test_send_custom_schema_event_as_list.yaml | 10 +++-- ...st_send_event_grid_event_data_as_list.yaml | 14 +++---- ....test_send_event_grid_event_data_dict.yaml | 8 ++-- ...t.test_send_event_grid_event_data_str.yaml | 8 ++-- ...client.test_send_signature_credential.yaml | 8 ++-- .../tests/test_eg_publisher_client.py | 32 +++++++-------- 11 files changed, 108 insertions(+), 80 deletions(-) create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_str.yaml diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_as_list.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_as_list.yaml index b686499659cc6..0cd77a94c75e5 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_as_list.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_as_list.yaml @@ -1,7 +1,7 @@ interactions: - request: - body: '[{"id": "fe01f535-bfe8-4bfb-9732-5530cac95677", "source": "http://samplesource.dev", - "data": "cloudevent", "type": "Sample.Cloud.Event", "time": "2020-08-19T02:54:26.937747Z", + body: '[{"id": "3dc4b913-4bc2-41f8-be9b-bf1f67069806", "source": "http://samplesource.dev", + "data": "cloudevent", "type": "Sample.Cloud.Event", "time": "2020-08-19T03:36:41.947462Z", "specversion": "1.0"}]' headers: Accept: @@ -17,31 +17,24 @@ interactions: User-Agent: - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) aeg-sas-key: - - CNX1dEvFh9P+c93UazUJ0+FSB4v104amtip6jD/KQsY= + - dHUaOOg5xRj+D7iH/AC92GyHweLx9ugrDuMDg4e5Xvw= method: POST - uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 response: body: - string: "{\r\n \"error\": {\r\n \"code\": \"BadRequest\",\r\n \"message\": - \"Unexpected property 'source' found in JSON. Report '2ce71012-6cad-4ba0-8fdb-b910b7f03670:1:8/19/2020 - 2:54:28 AM (UTC)' to our forums for assistance or raise a support ticket.\",\r\n - \ \"details\": [{\r\n \"code\": \"InputJsonInvalid\",\r\n - \ \"message\": \"Unexpected property 'source' found in JSON. Report - '2ce71012-6cad-4ba0-8fdb-b910b7f03670:1:8/19/2020 2:54:28 AM (UTC)' to our - forums for assistance or raise a support ticket.\"\r\n }]\r\n }\r\n}" + string: '' headers: + api-supported-versions: + - '2018-01-01' content-length: - - '527' - content-type: - - application/json; charset=utf-8 + - '0' date: - - Wed, 19 Aug 2020 02:54:27 GMT + - Wed, 19 Aug 2020 03:36:43 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: - max-age=31536000; includeSubDomains status: - code: 400 - message: Unexpected property 'source' found in JSON. Report '2ce71012-6cad-4ba0-8fdb-b910b7f03670:1:8/19/2020 - 2:54:28 AM (UTC)' to our forums for assistance or raise a support ticket. + code: 200 + message: OK version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_dict.yaml index 6c11fb99a5a55..d0ffe1e0c37fa 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_dict.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_dict.yaml @@ -1,7 +1,7 @@ interactions: - request: - body: '[{"id": "b97b41af-2e19-4889-87a1-e289766ecf89", "source": "http://samplesource.dev", - "data": {"sample": "cloudevent"}, "type": "Sample.Cloud.Event", "time": "2020-08-19T02:54:40.927831Z", + body: '[{"id": "51c18497-2a25-45f1-b9ba-fdaf08c00263", "source": "http://samplesource.dev", + "data": {"sample": "cloudevent"}, "type": "Sample.Cloud.Event", "time": "2020-08-19T03:36:42.304479Z", "specversion": "1.0"}]' headers: Accept: @@ -17,7 +17,7 @@ interactions: User-Agent: - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) aeg-sas-key: - - 1H1Q60s9Apm1iLiSOyunHE0EF2NeA1muzLR2Q6VOSps= + - dHUaOOg5xRj+D7iH/AC92GyHweLx9ugrDuMDg4e5Xvw= method: POST uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 response: @@ -29,7 +29,7 @@ interactions: content-length: - '0' date: - - Wed, 19 Aug 2020 02:54:41 GMT + - Wed, 19 Aug 2020 03:36:43 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_str.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_str.yaml new file mode 100644 index 0000000000000..d5daebc0544c4 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_data_str.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '[{"id": "6a315e93-a59c-4eca-b2f2-6bf3b8f27984", "source": "http://samplesource.dev", + "data": "cloudevent", "type": "Sample.Cloud.Event", "time": "2020-08-19T03:36:42.629467Z", + "specversion": "1.0"}]' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '198' + Content-Type: + - application/cloudevents-batch+json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - dHUaOOg5xRj+D7iH/AC92GyHweLx9ugrDuMDg4e5Xvw= + method: POST + uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: + - '2018-01-01' + content-length: + - '0' + date: + - Wed, 19 Aug 2020 03:36:43 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_dict.yaml index f4ada63d5a72f..58267d8b955e4 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_dict.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_cloud_event_dict.yaml @@ -16,31 +16,24 @@ interactions: User-Agent: - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) aeg-sas-key: - - CNX1dEvFh9P+c93UazUJ0+FSB4v104amtip6jD/KQsY= + - dHUaOOg5xRj+D7iH/AC92GyHweLx9ugrDuMDg4e5Xvw= method: POST - uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 response: body: - string: "{\r\n \"error\": {\r\n \"code\": \"BadRequest\",\r\n \"message\": - \"Unexpected property 'source' found in JSON. Report '5a0ead52-e8aa-4b1e-b34e-6c70f25010d7:3:8/19/2020 - 2:54:42 AM (UTC)' to our forums for assistance or raise a support ticket.\",\r\n - \ \"details\": [{\r\n \"code\": \"InputJsonInvalid\",\r\n - \ \"message\": \"Unexpected property 'source' found in JSON. Report - '5a0ead52-e8aa-4b1e-b34e-6c70f25010d7:3:8/19/2020 2:54:42 AM (UTC)' to our - forums for assistance or raise a support ticket.\"\r\n }]\r\n }\r\n}" + string: '' headers: + api-supported-versions: + - '2018-01-01' content-length: - - '527' - content-type: - - application/json; charset=utf-8 + - '0' date: - - Wed, 19 Aug 2020 02:54:42 GMT + - Wed, 19 Aug 2020 03:36:44 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: - max-age=31536000; includeSubDomains status: - code: 400 - message: Unexpected property 'source' found in JSON. Report '5a0ead52-e8aa-4b1e-b34e-6c70f25010d7:3:8/19/2020 - 2:54:42 AM (UTC)' to our forums for assistance or raise a support ticket. + code: 200 + message: OK version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event.yaml index d20008c84839f..3c126ae700cff 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event.yaml @@ -1,7 +1,7 @@ interactions: - request: body: '[{"customSubject": "sample", "customEventType": "sample.event", "customDataVersion": - "2.0", "customId": "1234", "customEventTime": "2020-08-19T02:54:55.283370+00:00", + "2.0", "customId": "1234", "customEventTime": "2020-08-19T03:36:56.936961+00:00", "customData": "sample data"}]' headers: Accept: @@ -17,7 +17,7 @@ interactions: User-Agent: - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) aeg-sas-key: - - bnShWuasxyRJT++S3CR8dxx+MBjyJ06zq9X/JxxNNKM= + - uPQPJHQHsAhBxWOWtRXslz3sXf7TJ5lcqLZ6SC4QzJ4= method: POST uri: https://customeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 response: @@ -29,7 +29,7 @@ interactions: content-length: - '0' date: - - Wed, 19 Aug 2020 02:54:56 GMT + - Wed, 19 Aug 2020 03:36:57 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event_as_list.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event_as_list.yaml index 98592a993b189..6f84dc2cbe230 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event_as_list.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_custom_schema_event_as_list.yaml @@ -1,10 +1,10 @@ interactions: - request: body: '[{"customSubject": "sample", "customEventType": "sample.event", "customDataVersion": - "2.0", "customId": "1234", "customEventTime": "2020-08-19T02:54:55.786334+00:00", + "2.0", "customId": "1234", "customEventTime": "2020-08-19T03:36:57.422734+00:00", "customData": "sample data"}, {"customSubject": "sample2", "customEventType": "sample.event", "customDataVersion": "2.0", "customId": "12345", "customEventTime": - "2020-08-19T02:54:55.787335+00:00", "customData": "sample data 2"}]' + "2020-08-19T03:36:57.422734+00:00", "customData": "sample data 2"}]' headers: Accept: - '*/*' @@ -19,7 +19,7 @@ interactions: User-Agent: - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) aeg-sas-key: - - bnShWuasxyRJT++S3CR8dxx+MBjyJ06zq9X/JxxNNKM= + - uPQPJHQHsAhBxWOWtRXslz3sXf7TJ5lcqLZ6SC4QzJ4= method: POST uri: https://customeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 response: @@ -28,10 +28,12 @@ interactions: headers: api-supported-versions: - '2018-01-01' + connection: + - close content-length: - '0' date: - - Wed, 19 Aug 2020 02:54:57 GMT + - Wed, 19 Aug 2020 03:36:58 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_as_list.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_as_list.yaml index 1dbdb480dc040..d5cab7375376b 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_as_list.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_as_list.yaml @@ -1,10 +1,10 @@ interactions: - request: - body: '[{"id": "f7813081-9a94-48b1-b92a-a812fa10512b", "subject": "sample", "data": - "eventgridevent", "eventType": "Sample.EventGrid.Event", "eventTime": "2020-08-19T02:54:56.159379Z", - "dataVersion": "2.0"}, {"id": "d73c89b5-639d-4900-aef9-d91df428a2c4", "subject": + body: '[{"id": "576f3e27-5433-47b3-8b4e-e31ea6a1bdde", "subject": "sample", "data": + "eventgridevent", "eventType": "Sample.EventGrid.Event", "eventTime": "2020-08-19T03:37:11.07064Z", + "dataVersion": "2.0"}, {"id": "6c359c8d-b1fe-4458-96c5-eaffcd864573", "subject": "sample2", "data": "eventgridevent2", "eventType": "Sample.EventGrid.Event", - "eventTime": "2020-08-19T02:54:56.159379Z", "dataVersion": "2.0"}]' + "eventTime": "2020-08-19T03:37:11.071641Z", "dataVersion": "2.0"}]' headers: Accept: - '*/*' @@ -13,13 +13,13 @@ interactions: Connection: - keep-alive Content-Length: - - '402' + - '401' Content-Type: - application/json; charset=utf-8 User-Agent: - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) aeg-sas-key: - - CNX1dEvFh9P+c93UazUJ0+FSB4v104amtip6jD/KQsY= + - dS38eoc9IPjofR5npZ1QXrsb3Gz/Kdt99ZdK9SJ+99w= method: POST uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 response: @@ -31,7 +31,7 @@ interactions: content-length: - '0' date: - - Wed, 19 Aug 2020 02:54:56 GMT + - Wed, 19 Aug 2020 03:37:12 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_dict.yaml index 900d7de9c87d9..d20ed7f4c9c48 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_dict.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_dict.yaml @@ -1,8 +1,8 @@ interactions: - request: - body: '[{"id": "de0ca0b5-a8ab-48e4-8c50-d96545c5af76", "subject": "sample", "data": + body: '[{"id": "fbf293f1-d609-4fd8-8d3b-b0ed0e406795", "subject": "sample", "data": {"sample": "eventgridevent"}, "eventType": "Sample.EventGrid.Event", "eventTime": - "2020-08-19T02:54:56.478324Z", "dataVersion": "2.0"}]' + "2020-08-19T03:37:11.563581Z", "dataVersion": "2.0"}]' headers: Accept: - '*/*' @@ -17,7 +17,7 @@ interactions: User-Agent: - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) aeg-sas-key: - - CNX1dEvFh9P+c93UazUJ0+FSB4v104amtip6jD/KQsY= + - dS38eoc9IPjofR5npZ1QXrsb3Gz/Kdt99ZdK9SJ+99w= method: POST uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 response: @@ -29,7 +29,7 @@ interactions: content-length: - '0' date: - - Wed, 19 Aug 2020 02:54:57 GMT + - Wed, 19 Aug 2020 03:37:12 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_str.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_str.yaml index 4ead5265b2970..22679778a2fc7 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_str.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_event_grid_event_data_str.yaml @@ -1,7 +1,7 @@ interactions: - request: - body: '[{"id": "9d3e0cd3-57a8-448c-85a5-4eedef1a2d8e", "subject": "sample", "data": - "eventgridevent", "eventType": "Sample.EventGrid.Event", "eventTime": "2020-08-19T02:54:56.786336Z", + body: '[{"id": "10994707-90e7-431e-88f0-2abae07cc806", "subject": "sample", "data": + "eventgridevent", "eventType": "Sample.EventGrid.Event", "eventTime": "2020-08-19T03:37:11.893631Z", "dataVersion": "2.0"}]' headers: Accept: @@ -17,7 +17,7 @@ interactions: User-Agent: - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) aeg-sas-key: - - CNX1dEvFh9P+c93UazUJ0+FSB4v104amtip6jD/KQsY= + - dS38eoc9IPjofR5npZ1QXrsb3Gz/Kdt99ZdK9SJ+99w= method: POST uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 response: @@ -29,7 +29,7 @@ interactions: content-length: - '0' date: - - Wed, 19 Aug 2020 02:54:57 GMT + - Wed, 19 Aug 2020 03:37:12 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_signature_credential.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_signature_credential.yaml index 28c579a3336cf..35bc4e03ed5b4 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_signature_credential.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_send_signature_credential.yaml @@ -1,8 +1,8 @@ interactions: - request: - body: '[{"id": "b2997db2-24a8-42bc-b254-a3bb83217e3a", "subject": "sample", "data": + body: '[{"id": "18fe69c3-59bf-4e53-97e1-2e5310e4884f", "subject": "sample", "data": {"sample": "eventgridevent"}, "eventType": "Sample.EventGrid.Event", "eventTime": - "2020-08-19T02:54:57.067382Z", "dataVersion": "2.0"}]' + "2020-08-19T03:37:12.238633Z", "dataVersion": "2.0"}]' headers: Accept: - '*/*' @@ -17,7 +17,7 @@ interactions: User-Agent: - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) aeg-sas-token: - - r=https%3A%2F%2Feventgridtestj5ziptothnf.westus-1.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=2020-08-19%2003%3A54%3A57.065388%2B00%3A00&s=bDccCYZSzjz0%2BQ6nwsQ1ZDJdO%2BIJrbwqQRTG%2BGPaTrw%3D + - r=https%3A%2F%2Feventgridtestpm22oyo2kyl.westus-1.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=2020-08-19%2004%3A37%3A12.237630%2B00%3A00&s=NiA404pCphKDcLVP9%2FjN%2FY0%2BnejDRolHVkrEnfrXk6c%3D method: POST uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 response: @@ -29,7 +29,7 @@ interactions: content-length: - '0' date: - - Wed, 19 Aug 2020 02:54:57 GMT + - Wed, 19 Aug 2020 03:37:12 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: diff --git a/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py b/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py index dd7e7e8d75a94..287c5509e46b2 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py +++ b/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py @@ -83,36 +83,36 @@ def test_send_cloud_event_data_dict(self, resource_group, eventgrid_topic, event ) client.send(cloud_event) - # @pytest.mark.liveTest - # @CachedResourceGroupPreparer(name_prefix='eventgridtest') - # @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') - # def test_send_cloud_event_data_str(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): - # akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) - # client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) - # cloud_event = CloudEvent( - # source = "http://samplesource.dev", - # data = "cloudevent", - # type="Sample.Cloud.Event" - # ) - # client.send(cloud_event) + @pytest.mark.liveTest + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') + def test_send_cloud_event_data_str(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + cloud_event = CloudEvent( + source = "http://samplesource.dev", + data = "cloudevent", + type="Sample.Cloud.Event" + ) + client.send(cloud_event) @pytest.mark.liveTest @CachedResourceGroupPreparer(name_prefix='eventgridtest') - @CachedEventGridTopicPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') def test_send_cloud_event_data_as_list(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) - cloud_event1 = CloudEvent( + cloud_event = CloudEvent( source = "http://samplesource.dev", data = "cloudevent", type="Sample.Cloud.Event" ) - client.send([cloud_event1]) + client.send([cloud_event]) @pytest.mark.liveTest @CachedResourceGroupPreparer(name_prefix='eventgridtest') - @CachedEventGridTopicPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') def test_send_cloud_event_dict(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) From 7b014cc688874171a928c7bd4819f4af08ee60a0 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 19 Aug 2020 23:06:11 -0700 Subject: [PATCH 10/20] Update sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_eg_publisher_client_publish_event_grid_event_data_dict.yaml --- ...t_eg_publisher_client_publish_event_grid_event_data_dict.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_eg_publisher_client_publish_event_grid_event_data_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_eg_publisher_client_publish_event_grid_event_data_dict.yaml index cdfc16f790776..80389ad9f7e5e 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_eg_publisher_client_publish_event_grid_event_data_dict.yaml +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client.test_eg_publisher_client_publish_event_grid_event_data_dict.yaml @@ -1,4 +1,3 @@ - interactions: - request: body: '[{"id": "38eab883-eb07-4ae1-9ff4-12ebaf022113", "subject": "sample", "data": From 6d9d4e40e06ec0df413bbb7246b1b71a71fcf6b0 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 19 Aug 2020 23:07:11 -0700 Subject: [PATCH 11/20] Apply suggestions from code review --- sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py b/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py index 287c5509e46b2..3c4a45a021a8b 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py +++ b/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py @@ -185,4 +185,4 @@ def test_send_custom_schema_event_as_list(self, resource_group, eventgrid_topic, "customData": "sample data 2" } ) - client.send([custom_event1, custom_event2]) \ No newline at end of file + client.send([custom_event1, custom_event2]) From 231fd3560361c9ebb865b17172336f14e63c1192 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 19 Aug 2020 23:08:09 -0700 Subject: [PATCH 12/20] Update sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py --- .../azure-eventgrid/azure/eventgrid/_publisher_client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py index bdaf35a446b82..666cb15cd909e 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py @@ -46,7 +46,6 @@ def __init__(self, topic_hostname, credential, **kwargs): self._topic_hostname = topic_hostname auth_policy = _get_authentication_policy(credential) self._client = EventGridPublisherClientImpl(authentication_policy=auth_policy, **kwargs) - def send(self, events, **kwargs): # type: (SendType, Any) -> None """Sends event data to topic hostname specified during client initialization. From 783364f0e8b95d9f57fb8da704ae9712ff8683b5 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Thu, 20 Aug 2020 00:02:32 -0700 Subject: [PATCH 13/20] analyze --- .../azure/eventgrid/aio/_publisher_client_async.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py index 29e328acfd529..b569c0670c2ba 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any +from typing import Any, TYPE_CHECKING from azure.core import AsyncPipelineClient from msrest import Deserializer, Serializer From e191136ce0fd6b6106bde4630e17c4388f7c2bde Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Thu, 20 Aug 2020 16:35:42 -0700 Subject: [PATCH 14/20] Apply suggestions from code review Co-authored-by: KieranBrantnerMagee --- sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py | 2 +- sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py index 2cbebfbefe522..454fe543a5fb2 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_helpers.py @@ -77,4 +77,4 @@ def _is_cloud_event(event): try: return all([_ in event for _ in required]) and event['specversion'] == "1.0" except TypeError: - pass + return False diff --git a/sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py b/sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py index ad6fefa5d0aa4..d56af2bcebca2 100644 --- a/sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py +++ b/sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py @@ -86,6 +86,7 @@ def remove_resource(self, name, **kwargs): if self.is_live: group = self._get_resource_group(**kwargs) self.client.topics.delete(group.name, name, polling=False) + def _get_resource_group(self, **kwargs): try: return kwargs.get(self.resource_group_parameter_name) From 5a1bd5005a634b5e45e46fd060e9713ca83fc22e Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 26 Aug 2020 01:38:10 -0700 Subject: [PATCH 15/20] async tests --- .../azure/eventgrid/_publisher_client.py | 2 +- .../eventgrid/aio/_publisher_client_async.py | 13 +- ...nc.test_send_cloud_event_data_as_list.yaml | 30 +++ ...async.test_send_cloud_event_data_dict.yaml | 30 +++ ..._async.test_send_cloud_event_data_str.yaml | 30 +++ ...ient_async.test_send_cloud_event_dict.yaml | 29 +++ ...t_async.test_send_custom_schema_event.yaml | 30 +++ ...test_send_custom_schema_event_as_list.yaml | 32 +++ ...st_send_event_grid_event_data_as_list.yaml | 32 +++ ....test_send_event_grid_event_data_dict.yaml | 30 +++ ...c.test_send_event_grid_event_data_str.yaml | 30 +++ ..._async.test_send_signature_credential.yaml | 30 +++ .../tests/test_eg_publisher_client_async.py | 199 ++++++++++++++++++ 13 files changed, 510 insertions(+), 7 deletions(-) create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_as_list.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_dict.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_str.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_dict.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_custom_schema_event.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_custom_schema_event_as_list.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_as_list.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_dict.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_str.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_signature_credential.yaml create mode 100644 sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client_async.py diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py index 666cb15cd909e..1ecbc79f6be3b 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py @@ -53,7 +53,7 @@ def send(self, events, **kwargs): :param events: A list of CloudEvent/EventGridEvent/CustomEvent to be sent. :type events: Union[List[models.CloudEvent], List[models.EventGridEvent], List[models.CustomEvent]] :rtype: None - raise: :class:`ValueError`, when events do not follow specified SendType. + :raise: :class:`ValueError`, when events do not follow specified SendType. """ if not isinstance(events, list): events = [events] diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py index b569c0670c2ba..15e6363c61d6d 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py @@ -11,7 +11,7 @@ from azure.core import AsyncPipelineClient from msrest import Deserializer, Serializer -from .._models import CloudEvent, EventGridEvent +from .._models import CloudEvent, EventGridEvent, CustomEvent from .._helpers import _get_topic_hostname_only_fqdn, _get_authentication_policy, _is_cloud_event from azure.core.pipeline.policies import AzureKeyCredentialPolicy from azure.core.credentials import AzureKeyCredential @@ -42,7 +42,8 @@ class EventGridPublisherClient(object): def __init__(self, topic_hostname, credential, **kwargs): # type: (str, Union[AzureKeyCredential, EventGridSharedAccessSignatureCredential], Any) -> None auth_policy = _get_authentication_policy(credential) - self._client = EventGridPublisherClientAsync(authentication_policy=auth_policy) + self._client = EventGridPublisherClientAsync(authentication_policy=auth_policy, **kwargs) + topic_hostname = _get_topic_hostname_only_fqdn(topic_hostname) self._topic_hostname = topic_hostname @@ -53,20 +54,20 @@ async def send(self, events, **kwargs): :param events: A list of CloudEvent/EventGridEvent/CustomEvent to be sent. :type events: Union[List[models.CloudEvent], List[models.EventGridEvent], List[models.CustomEvent]] :rtype: None - raise: :class:`ValueError`, when events do not follow specified SendType. + :raise: :class:`ValueError`, when events do not follow specified SendType. """ if not isinstance(events, list): events = [events] if all(isinstance(e, CloudEvent) for e in events) or all(_is_cloud_event(e) for e in events): kwargs.setdefault("content_type", "application/cloudevents-batch+json; charset=utf-8") - self._client.publish_cloud_event_events(self._topic_hostname, events, **kwargs) + await self._client.publish_cloud_event_events(self._topic_hostname, events, **kwargs) elif all(isinstance(e, EventGridEvent) for e in events) or all(isinstance(e, dict) for e in events): kwargs.setdefault("content_type", "application/json; charset=utf-8") - self._client.publish_events(self._topic_hostname, events, **kwargs) + await self._client.publish_events(self._topic_hostname, events, **kwargs) elif all(isinstance(e, CustomEvent) for e in events): serialized_events = [dict(e) for e in events] - self._client.publish_custom_event_events(self._topic_hostname, serialized_events, **kwargs) + await self._client.publish_custom_event_events(self._topic_hostname, serialized_events, **kwargs) else: raise ValueError("Event schema is not correct.") diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_as_list.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_as_list.yaml new file mode 100644 index 0000000000000..b3c4782bd6746 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_as_list.yaml @@ -0,0 +1,30 @@ +interactions: +- request: + body: '[{"id": "a07023d9-c7ff-4f38-abe0-c3a8e555991b", "source": "http://samplesource.dev", + "data": "cloudevent", "type": "Sample.Cloud.Event", "time": "2020-08-26T08:36:53.957412Z", + "specversion": "1.0"}]' + headers: + Content-Length: + - '198' + Content-Type: + - application/cloudevents-batch+json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - lWdojve+oWWftlsc/y8gop1eyam9FXonHf0jmkPpA6Q= + method: POST + uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: '2018-01-01' + content-length: '0' + date: Wed, 26 Aug 2020 08:36:53 GMT + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://cloudeventgridtestgz6mhk.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_dict.yaml new file mode 100644 index 0000000000000..459913a84c1dc --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_dict.yaml @@ -0,0 +1,30 @@ +interactions: +- request: + body: '[{"id": "75b863c6-4344-47c5-a449-08ba3e68f912", "source": "http://samplesource.dev", + "data": {"sample": "cloudevent"}, "type": "Sample.Cloud.Event", "time": "2020-08-26T08:36:54.319455Z", + "specversion": "1.0"}]' + headers: + Content-Length: + - '210' + Content-Type: + - application/cloudevents-batch+json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - lWdojve+oWWftlsc/y8gop1eyam9FXonHf0jmkPpA6Q= + method: POST + uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: '2018-01-01' + content-length: '0' + date: Wed, 26 Aug 2020 08:36:54 GMT + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://cloudeventgridtestgz6mhk.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_str.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_str.yaml new file mode 100644 index 0000000000000..0e83ae4d66843 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_data_str.yaml @@ -0,0 +1,30 @@ +interactions: +- request: + body: '[{"id": "69cea73a-a033-4f12-ae17-0d2b21b4adbb", "source": "http://samplesource.dev", + "data": "cloudevent", "type": "Sample.Cloud.Event", "time": "2020-08-26T08:36:54.592725Z", + "specversion": "1.0"}]' + headers: + Content-Length: + - '198' + Content-Type: + - application/cloudevents-batch+json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - lWdojve+oWWftlsc/y8gop1eyam9FXonHf0jmkPpA6Q= + method: POST + uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: '2018-01-01' + content-length: '0' + date: Wed, 26 Aug 2020 08:36:53 GMT + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://cloudeventgridtestgz6mhk.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_dict.yaml new file mode 100644 index 0000000000000..3c78a559a94b0 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_cloud_event_dict.yaml @@ -0,0 +1,29 @@ +interactions: +- request: + body: '[{"id": "1234", "source": "http://samplesource.dev", "data": "cloudevent", + "type": "Sample.Cloud.Event", "specversion": "1.0"}]' + headers: + Content-Length: + - '127' + Content-Type: + - application/cloudevents-batch+json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - lWdojve+oWWftlsc/y8gop1eyam9FXonHf0jmkPpA6Q= + method: POST + uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: '2018-01-01' + content-length: '0' + date: Wed, 26 Aug 2020 08:36:54 GMT + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://cloudeventgridtestgz6mhk.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_custom_schema_event.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_custom_schema_event.yaml new file mode 100644 index 0000000000000..f62e83d46adf0 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_custom_schema_event.yaml @@ -0,0 +1,30 @@ +interactions: +- request: + body: '[{"customSubject": "sample", "customEventType": "sample.event", "customDataVersion": + "2.0", "customId": "1234", "customEventTime": "2020-08-26T08:37:08.332700+00:00", + "customData": "sample data"}]' + headers: + Content-Length: + - '196' + Content-Type: + - application/json + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - pWVPWql9F5Q5CqInHnpIWhyIWYW0gjMKy3N93kFcq8c= + method: POST + uri: https://customeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: '2018-01-01' + content-length: '0' + date: Wed, 26 Aug 2020 08:37:08 GMT + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://customeventgridtestj225p.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_custom_schema_event_as_list.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_custom_schema_event_as_list.yaml new file mode 100644 index 0000000000000..8a6bd49d86e99 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_custom_schema_event_as_list.yaml @@ -0,0 +1,32 @@ +interactions: +- request: + body: '[{"customSubject": "sample", "customEventType": "sample.event", "customDataVersion": + "2.0", "customId": "1234", "customEventTime": "2020-08-26T08:37:08.710695+00:00", + "customData": "sample data"}, {"customSubject": "sample2", "customEventType": + "sample.event", "customDataVersion": "2.0", "customId": "12345", "customEventTime": + "2020-08-26T08:37:08.710695+00:00", "customData": "sample data 2"}]' + headers: + Content-Length: + - '396' + Content-Type: + - application/json + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - pWVPWql9F5Q5CqInHnpIWhyIWYW0gjMKy3N93kFcq8c= + method: POST + uri: https://customeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: '2018-01-01' + content-length: '0' + date: Wed, 26 Aug 2020 08:37:08 GMT + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://customeventgridtestj225p.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_as_list.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_as_list.yaml new file mode 100644 index 0000000000000..ffab3ee0d911b --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_as_list.yaml @@ -0,0 +1,32 @@ +interactions: +- request: + body: '[{"id": "d8217ffd-6e75-44e7-adbb-ed9869aa275b", "subject": "sample", "data": + "eventgridevent", "eventType": "Sample.EventGrid.Event", "eventTime": "2020-08-26T08:37:22.429524Z", + "dataVersion": "2.0"}, {"id": "8238c6eb-dd48-4404-bdb1-cc3fd06ceabd", "subject": + "sample2", "data": "eventgridevent2", "eventType": "Sample.EventGrid.Event", + "eventTime": "2020-08-26T08:37:22.429524Z", "dataVersion": "2.0"}]' + headers: + Content-Length: + - '402' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - NpNkZLDV1WROE17wLypJk8VTz8hmAcByPv3tsCmhlys= + method: POST + uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: '2018-01-01' + content-length: '0' + date: Wed, 26 Aug 2020 08:37:21 GMT + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://eventgridtesty45wuyer4g4.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_dict.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_dict.yaml new file mode 100644 index 0000000000000..f20a2a16b4d85 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_dict.yaml @@ -0,0 +1,30 @@ +interactions: +- request: + body: '[{"id": "3654b7c2-6219-45a6-a6e6-001770982469", "subject": "sample", "data": + {"sample": "eventgridevent"}, "eventType": "Sample.EventGrid.Event", "eventTime": + "2020-08-26T08:37:22.81246Z", "dataVersion": "2.0"}]' + headers: + Content-Length: + - '211' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - NpNkZLDV1WROE17wLypJk8VTz8hmAcByPv3tsCmhlys= + method: POST + uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: '2018-01-01' + content-length: '0' + date: Wed, 26 Aug 2020 08:37:22 GMT + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://eventgridtesty45wuyer4g4.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_str.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_str.yaml new file mode 100644 index 0000000000000..74bde4b6c0e99 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_event_grid_event_data_str.yaml @@ -0,0 +1,30 @@ +interactions: +- request: + body: '[{"id": "5bd130e8-0001-488a-9cd6-807d6bb30270", "subject": "sample", "data": + "eventgridevent", "eventType": "Sample.EventGrid.Event", "eventTime": "2020-08-26T08:37:23.122484Z", + "dataVersion": "2.0"}]' + headers: + Content-Length: + - '200' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-key: + - NpNkZLDV1WROE17wLypJk8VTz8hmAcByPv3tsCmhlys= + method: POST + uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: '2018-01-01' + content-length: '0' + date: Wed, 26 Aug 2020 08:37:23 GMT + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://eventgridtesty45wuyer4g4.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_signature_credential.yaml b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_signature_credential.yaml new file mode 100644 index 0000000000000..28c6113cb3a98 --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/recordings/test_eg_publisher_client_async.test_send_signature_credential.yaml @@ -0,0 +1,30 @@ +interactions: +- request: + body: '[{"id": "711ffb3e-f134-45bd-b12c-b9d9463b2b95", "subject": "sample", "data": + {"sample": "eventgridevent"}, "eventType": "Sample.EventGrid.Event", "eventTime": + "2020-08-26T08:37:23.403459Z", "dataVersion": "2.0"}]' + headers: + Content-Length: + - '212' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - azsdk-python-eventgridpublisherclient/unknown Python/3.7.3 (Windows-10-10.0.18362-SP0) + aeg-sas-token: + - r=https%3A%2F%2Feventgridtesty45wuyer4g4.westus-1.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=2020-08-26%2009%3A37%3A23.402457%2B00%3A00&s=CCoSPjEt0vQovS3vOJXxswxV%2Frkxn9TCQPjtmE8xNeM%3D + method: POST + uri: https://eventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 + response: + body: + string: '' + headers: + api-supported-versions: '2018-01-01' + content-length: '0' + date: Wed, 26 Aug 2020 08:37:22 GMT + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://eventgridtesty45wuyer4g4.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 +version: 1 diff --git a/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client_async.py b/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client_async.py new file mode 100644 index 0000000000000..a93dc748dd4bc --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client_async.py @@ -0,0 +1,199 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import logging +import asyncio +import sys +import os +import pytest +from datetime import timedelta +from msrest.serialization import UTC +import datetime as dt + +from devtools_testutils import AzureMgmtTestCase, CachedResourceGroupPreparer + +from azure.core.credentials import AzureKeyCredential +from azure.eventgrid import CloudEvent, EventGridEvent, CustomEvent ,EventGridSharedAccessSignatureCredential, generate_shared_access_signature +from azure.eventgrid.aio import EventGridPublisherClient + +from eventgrid_preparer import ( + CachedEventGridTopicPreparer +) + +class EventGridPublisherClientTests(AzureMgmtTestCase): + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='eventgridtest') + @pytest.mark.asyncio + async def test_send_event_grid_event_data_dict(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + eg_event = EventGridEvent( + subject="sample", + data={"sample": "eventgridevent"}, + event_type="Sample.EventGrid.Event", + data_version="2.0" + ) + await client.send(eg_event) + + + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='eventgridtest') + @pytest.mark.asyncio + async def test_send_event_grid_event_data_as_list(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + eg_event1 = EventGridEvent( + subject="sample", + data="eventgridevent", + event_type="Sample.EventGrid.Event", + data_version="2.0" + ) + eg_event2 = EventGridEvent( + subject="sample2", + data="eventgridevent2", + event_type="Sample.EventGrid.Event", + data_version="2.0" + ) + await client.send([eg_event1, eg_event2]) + + + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='eventgridtest') + @pytest.mark.asyncio + async def test_send_event_grid_event_data_str(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + eg_event = EventGridEvent( + subject="sample", + data="eventgridevent", + event_type="Sample.EventGrid.Event", + data_version="2.0" + ) + await client.send(eg_event) + + + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') + @pytest.mark.asyncio + async def test_send_cloud_event_data_dict(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + cloud_event = CloudEvent( + source = "http://samplesource.dev", + data = {"sample": "cloudevent"}, + type="Sample.Cloud.Event" + ) + await client.send(cloud_event) + + + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') + @pytest.mark.asyncio + async def test_send_cloud_event_data_str(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + cloud_event = CloudEvent( + source = "http://samplesource.dev", + data = "cloudevent", + type="Sample.Cloud.Event" + ) + await client.send(cloud_event) + + + + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') + @pytest.mark.asyncio + async def test_send_cloud_event_data_as_list(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + cloud_event = CloudEvent( + source = "http://samplesource.dev", + data = "cloudevent", + type="Sample.Cloud.Event" + ) + await client.send([cloud_event]) + + + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest') + @pytest.mark.asyncio + async def test_send_cloud_event_dict(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + cloud_event1 = { + "id": "1234", + "source": "http://samplesource.dev", + "specversion": "1.0", + "data": "cloudevent", + "type": "Sample.Cloud.Event" + } + await client.send(cloud_event1) + + + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='eventgridtest') + @pytest.mark.asyncio + async def test_send_signature_credential(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + expiration_date_utc = dt.datetime.now(UTC()) + timedelta(hours=1) + signature = generate_shared_access_signature(eventgrid_topic_endpoint, eventgrid_topic_primary_key, expiration_date_utc) + credential = EventGridSharedAccessSignatureCredential(signature) + client = EventGridPublisherClient(eventgrid_topic_endpoint, credential) + eg_event = EventGridEvent( + subject="sample", + data={"sample": "eventgridevent"}, + event_type="Sample.EventGrid.Event", + data_version="2.0" + ) + await client.send(eg_event) + + + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='customeventgridtest') + @pytest.mark.asyncio + async def test_send_custom_schema_event(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + custom_event = CustomEvent( + { + "customSubject": "sample", + "customEventType": "sample.event", + "customDataVersion": "2.0", + "customId": "1234", + "customEventTime": dt.datetime.now(UTC()).isoformat(), + "customData": "sample data" + } + ) + await client.send(custom_event) + + + @CachedResourceGroupPreparer(name_prefix='eventgridtest') + @CachedEventGridTopicPreparer(name_prefix='customeventgridtest') + @pytest.mark.asyncio + async def test_send_custom_schema_event_as_list(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint): + akc_credential = AzureKeyCredential(eventgrid_topic_primary_key) + client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential) + custom_event1 = CustomEvent( + { + "customSubject": "sample", + "customEventType": "sample.event", + "customDataVersion": "2.0", + "customId": "1234", + "customEventTime": dt.datetime.now(UTC()).isoformat(), + "customData": "sample data" + } + ) + custom_event2 = CustomEvent( + { + "customSubject": "sample2", + "customEventType": "sample.event", + "customDataVersion": "2.0", + "customId": "12345", + "customEventTime": dt.datetime.now(UTC()).isoformat(), + "customData": "sample data 2" + } + ) + await client.send([custom_event1, custom_event2]) From 741feeae9b02c44bdb472a7626fe0ea909779f4d Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 26 Aug 2020 01:59:07 -0700 Subject: [PATCH 16/20] no async for py2 --- .../azure-eventgrid/tests/conftest.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 sdk/eventgrid/azure-eventgrid/tests/conftest.py diff --git a/sdk/eventgrid/azure-eventgrid/tests/conftest.py b/sdk/eventgrid/azure-eventgrid/tests/conftest.py new file mode 100644 index 0000000000000..2e685fe040ddb --- /dev/null +++ b/sdk/eventgrid/azure-eventgrid/tests/conftest.py @@ -0,0 +1,33 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- +import platform +import sys + + +# Ignore async tests for Python < 3.5 +collect_ignore_glob = [] +if sys.version_info < (3, 5): + collect_ignore_glob.append("*_async.py") From 5bc8c56f37fa52d0e669ed8037ca7821af206bd3 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 26 Aug 2020 14:04:04 -0700 Subject: [PATCH 17/20] comment --- .../azure-eventgrid/azure/eventgrid/_publisher_client.py | 1 + .../azure/eventgrid/aio/_publisher_client_async.py | 1 + 2 files changed, 2 insertions(+) diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py index 1ecbc79f6be3b..254c137a72d06 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py @@ -52,6 +52,7 @@ def send(self, events, **kwargs): :param events: A list of CloudEvent/EventGridEvent/CustomEvent to be sent. :type events: Union[List[models.CloudEvent], List[models.EventGridEvent], List[models.CustomEvent]] + :keyword str content_type: The type of content to be used to send the events. :rtype: None :raise: :class:`ValueError`, when events do not follow specified SendType. """ diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py index 15e6363c61d6d..884ed4ae5de00 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py @@ -53,6 +53,7 @@ async def send(self, events, **kwargs): :param events: A list of CloudEvent/EventGridEvent/CustomEvent to be sent. :type events: Union[List[models.CloudEvent], List[models.EventGridEvent], List[models.CustomEvent]] + :keyword str content_type: The type of content to be used to send the events. :rtype: None :raise: :class:`ValueError`, when events do not follow specified SendType. """ From de9a50ee0c3816ccbcc184ab69c5a0277ce1a1df Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Thu, 27 Aug 2020 09:49:21 -0700 Subject: [PATCH 18/20] Apply suggestions from code review Co-authored-by: KieranBrantnerMagee --- .../azure-eventgrid/azure/eventgrid/_publisher_client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py index 254c137a72d06..a0e5ff7e62c88 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_publisher_client.py @@ -21,7 +21,8 @@ Dict, List[CloudEvent], List[EventGridEvent], - List[CustomEvent] + List[CustomEvent], + List[Dict] ] from ._models import CloudEvent, EventGridEvent, CustomEvent @@ -53,6 +54,7 @@ def send(self, events, **kwargs): :param events: A list of CloudEvent/EventGridEvent/CustomEvent to be sent. :type events: Union[List[models.CloudEvent], List[models.EventGridEvent], List[models.CustomEvent]] :keyword str content_type: The type of content to be used to send the events. + Has default value "application/json; charset=utf-8" for EventGridEvents, with "cloudevents-batch+json" for CloudEvents :rtype: None :raise: :class:`ValueError`, when events do not follow specified SendType. """ From 081cf650aec6072a17d139920862d49db88aa2ec Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Thu, 27 Aug 2020 09:49:34 -0700 Subject: [PATCH 19/20] Apply suggestions from code review Co-authored-by: KieranBrantnerMagee --- .../azure/eventgrid/aio/_publisher_client_async.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py index 884ed4ae5de00..2a5692c303cea 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py @@ -28,7 +28,8 @@ Dict, List[CloudEvent], List[EventGridEvent], - List[CustomEvent] + List[CustomEvent], + List[Dict] ] class EventGridPublisherClient(object): From 3f88670c05b18aa218a1e053a071b2e7eb5b2846 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Thu, 27 Aug 2020 09:49:49 -0700 Subject: [PATCH 20/20] Apply suggestions from code review Co-authored-by: KieranBrantnerMagee --- .../azure/eventgrid/aio/_publisher_client_async.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py index 2a5692c303cea..f4b552b0882e7 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_publisher_client_async.py @@ -55,6 +55,7 @@ async def send(self, events, **kwargs): :param events: A list of CloudEvent/EventGridEvent/CustomEvent to be sent. :type events: Union[List[models.CloudEvent], List[models.EventGridEvent], List[models.CustomEvent]] :keyword str content_type: The type of content to be used to send the events. + Has default value "application/json; charset=utf-8" for EventGridEvents, with "cloudevents-batch+json" for CloudEvents :rtype: None :raise: :class:`ValueError`, when events do not follow specified SendType. """