Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/eventgrid/azure-eventgrid/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- `EventGridConsumer` is now renamed to `EventGridDeserializer`.
- `decode_cloud_event` is renamed to `deserialize_cloud_events`.
- `decode_eventgrid_event` is renamed to `deserialize_eventgrid_events`.
- The system events now exist in the `azure.eventgrid.systemevents` namespace instead of `azure.eventgrid.models` namespace.
- The `send` method in the `EventGridPubliserClient` is now replaced by the `send_events`.
- `topic_hostname` is renamed to `endpoint` in the `EventGridPublisherClient`.

**Bug Fixes**
Expand Down
4 changes: 2 additions & 2 deletions sdk/eventgrid/azure-eventgrid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ event = EventGridEvent(
credential = AzureKeyCredential(key)
client = EventGridPublisherClient(endpoint, credential)

client.send(event)
client.send_events(event)
```

### Send a Cloud Event
Expand All @@ -120,7 +120,7 @@ event = CloudEvent(
credential = AzureKeyCredential(key)
client = EventGridPublisherClient(endpoint, credential)

client.send(event)
client.send_events(event)
```

### Consume an Event Grid Event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _policies(credential, **kwargs):
return policies

@distributed_trace
def send(self, events, **kwargs):
def send_events(self, events, **kwargs):
# type: (SendType, Any) -> None
"""Sends event data to topic hostname specified during client initialization.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _policies(
return policies

@distributed_trace_async
async def send(
async def send_events(
self,
events: SendType,
**kwargs: Any) -> None:
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventgrid/azure-eventgrid/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The `publish_events` API is replaced with `send` in v2.0. Additionally, `send` A

| In v1.3 | Equivalent in v2.0 | Sample |
|---|---|---|
|`EventGridClient(credentials).publish_events(topic_hostname, events)`|`EventGridPublisherClient(endpoint, credential).send(events)`|[Sample for client construction](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs5_publish_events_using_cloud_events_1.0_schema.py)|
|`EventGridClient(credentials).publish_events(topic_hostname, events)`|`EventGridPublisherClient(endpoint, credential).send_events(events)`|[Sample for client construction](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs5_publish_events_using_cloud_events_1.0_schema.py)|

### Consuming Events

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
credential = AzureKeyCredential(topic_key)
client = EventGridPublisherClient(endpoint, credential)

client.send([
client.send_events([
EventGridEvent(
event_type="Contoso.Items.ItemReceived",
data={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
credential = AzureSasCredential(signature)
client = EventGridPublisherClient(endpoint, credential)

client.send([
client.send_events([
EventGridEvent(
event_type="Contoso.Items.ItemReceived",
data={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
credential = AzureKeyCredential(domain_key)
client = EventGridPublisherClient(domain_hostname, credential)

client.send([
client.send_events([
EventGridEvent(
topic="MyCustomDomainTopic1",
event_type="Contoso.Items.ItemReceived",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
credential = AzureKeyCredential(topic_key)
client = EventGridPublisherClient(endpoint, credential)

client.send([
client.send_events([
CloudEvent(
type="Contoso.Items.ItemReceived",
source="/contoso/items",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""
import json
from azure.eventgrid import EventGridDeserializer, EventGridEvent
from azure.eventgrid.models import StorageBlobCreatedEventData
from azure.eventgrid.systemevents import StorageBlobCreatedEventData

# all types of EventGridEvents below produce same DeserializedEvent
eg_storage_dict = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def publish_event():
event_list.append(event)

# publish list of events
client.send(event_list)
client.send_events(event_list)
print("Batch of size {} published".format(len(event_list)))
time.sleep(randint(1, 5))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def publish_event():
event_list.append(event)

# publish list of events
client.send(event_list)
client.send_events(event_list)
print("Batch of size {} published".format(len(event_list)))
time.sleep(randint(1, 5))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def publish_event():
event_list.append(event)

# publish list of events
client.send(event_list)
client.send_events(event_list)
print("Batch of size {} published".format(len(event_list)))
time.sleep(randint(1, 5))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def publish_event():
event_list.append(event)

# publish list of events
client.send(event_list)
client.send_events(event_list)
print("Batch of size {} published".format(len(event_list)))
time.sleep(randint(1, 5))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def publish_event():
event_list.append(event)

# publish list of events
client.send(event_list)
client.send_events(event_list)
print("Batch of size {} published".format(len(event_list)))
time.sleep(randint(1, 5))

Expand Down
2 changes: 1 addition & 1 deletion sdk/eventgrid/azure-eventgrid/tests/test_eg_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from devtools_testutils import AzureMgmtTestCase
from msrest.serialization import UTC
from azure.eventgrid import EventGridDeserializer, CloudEvent, EventGridEvent
from azure.eventgrid.models import StorageBlobCreatedEventData
from azure.eventgrid.systemevents import StorageBlobCreatedEventData
from _mocks import (
cloud_storage_dict,
cloud_storage_string,
Expand Down
28 changes: 14 additions & 14 deletions sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_send_event_grid_event_data_dict(self, resource_group, eventgrid_topic,
event_type="Sample.EventGrid.Event",
data_version="2.0"
)
client.send(eg_event)
client.send_events(eg_event)

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='eventgridtest')
Expand All @@ -55,7 +55,7 @@ def test_send_event_grid_event_data_as_list(self, resource_group, eventgrid_topi
event_type="Sample.EventGrid.Event",
data_version="2.0"
)
client.send([eg_event1, eg_event2])
client.send_events([eg_event1, eg_event2])

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='eventgridtest')
Expand All @@ -68,7 +68,7 @@ def test_send_event_grid_event_data_str(self, resource_group, eventgrid_topic, e
event_type="Sample.EventGrid.Event",
data_version="2.0"
)
client.send(eg_event)
client.send_events(eg_event)

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='eventgridtest')
Expand All @@ -82,7 +82,7 @@ def test_send_event_grid_event_data_bytes(self, resource_group, eventgrid_topic,
data_version="2.0"
)
with pytest.raises(TypeError, match="Data in EventGridEvent cannot be bytes*"):
client.send(eg_event)
client.send_events(eg_event)

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='eventgridtest')
Expand All @@ -96,7 +96,7 @@ def test_send_event_grid_event_dict_data_bytes(self, resource_group, eventgrid_t
"data_version":"2.0"
}
with pytest.raises(TypeError, match="Data in EventGridEvent cannot be bytes*"):
client.send(eg_event)
client.send_events(eg_event)

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest')
Expand All @@ -108,7 +108,7 @@ def test_send_cloud_event_data_dict(self, resource_group, eventgrid_topic, event
data = {"sample": "cloudevent"},
type="Sample.Cloud.Event"
)
client.send(cloud_event)
client.send_events(cloud_event)

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest')
Expand All @@ -120,7 +120,7 @@ def test_send_cloud_event_data_str(self, resource_group, eventgrid_topic, eventg
data = "cloudevent",
type="Sample.Cloud.Event"
)
client.send(cloud_event)
client.send_events(cloud_event)

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest')
Expand All @@ -132,7 +132,7 @@ def test_send_cloud_event_data_bytes(self, resource_group, eventgrid_topic, even
data = b"cloudevent",
type="Sample.Cloud.Event"
)
client.send(cloud_event)
client.send_events(cloud_event)

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest')
Expand All @@ -144,7 +144,7 @@ def test_send_cloud_event_data_as_list(self, resource_group, eventgrid_topic, ev
data = "cloudevent",
type="Sample.Cloud.Event"
)
client.send([cloud_event])
client.send_events([cloud_event])

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='cloudeventgridtest')
Expand All @@ -160,7 +160,7 @@ def test_send_cloud_event_data_with_extensions(self, resource_group, eventgrid_t
'extension':'hello'
}
)
client.send([cloud_event])
client.send_events([cloud_event])
internal = cloud_event._to_generated().serialize()
assert 'reason_code' in internal
assert 'extension' in internal
Expand All @@ -178,7 +178,7 @@ def test_send_cloud_event_dict(self, resource_group, eventgrid_topic, eventgrid_
"data": "cloudevent",
"type": "Sample.Cloud.Event"
}
client.send(cloud_event1)
client.send_events(cloud_event1)

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='eventgridtest')
Expand All @@ -193,7 +193,7 @@ def test_send_signature_credential(self, resource_group, eventgrid_topic, eventg
event_type="Sample.EventGrid.Event",
data_version="2.0"
)
client.send(eg_event)
client.send_events(eg_event)

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='customeventgridtest')
Expand All @@ -210,7 +210,7 @@ def test_send_custom_schema_event(self, resource_group, eventgrid_topic, eventgr
"customData": "sample data"
}
)
client.send(custom_event)
client.send_events(custom_event)

@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='customeventgridtest')
Expand All @@ -237,7 +237,7 @@ def test_send_custom_schema_event_as_list(self, resource_group, eventgrid_topic,
"customData": "sample data 2"
}
)
client.send([custom_event1, custom_event2])
client.send_events([custom_event1, custom_event2])

def test_send_throws_with_bad_credential(self):
bad_credential = "I am a bad credential"
Expand Down
Loading