diff --git a/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs3_consume_system_events.py b/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs3_consume_system_events.py index 5f46ea50bcd2..f07298151ddc 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs3_consume_system_events.py +++ b/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs3_consume_system_events.py @@ -11,7 +11,7 @@ consumer = EventGridConsumer() # returns List[DeserializedEvent] -deserialized_events = consumer.deserialize_events(service_bus_received_message) +deserialized_events = consumer.decode_eventgrid_event(service_bus_received_message) # EventGridEvent schema, Storage.BlobCreated event for event in deserialized_events: diff --git a/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs4_consume_custom_events.py b/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs4_consume_custom_events.py index ea5799322088..fd4666b0ba4f 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs4_consume_custom_events.py +++ b/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs4_consume_custom_events.py @@ -11,7 +11,7 @@ consumer = EventGridConsumer() # returns List[DeserializedEvent] -deserialized_events = consumer.deserialize_events(service_bus_received_message) +deserialized_events = consumer.decode_eventgrid_event(service_bus_received_message) # EventGridEvent schema, with custom event type for event in deserialized_events: diff --git a/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs6_consume_events_using_cloud_events_1.0_schema.py b/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs6_consume_events_using_cloud_events_1.0_schema.py index 278efccdea7d..6d871bbb10ac 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs6_consume_events_using_cloud_events_1.0_schema.py +++ b/sdk/eventgrid/azure-eventgrid/samples/champion_scenarios/cs6_consume_events_using_cloud_events_1.0_schema.py @@ -11,7 +11,7 @@ consumer = EventGridConsumer() # returns List[DeserializedEvent] -deserialized_events = consumer.deserialize_events(service_bus_received_message) +deserialized_events = consumer.decode_eventgrid_event(service_bus_received_message) # CloudEvent schema for event in deserialized_events: diff --git a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_custom_data_sample.py b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_custom_data_sample.py index 3f5f7f8da283..94fc68b80a89 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_custom_data_sample.py +++ b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_custom_data_sample.py @@ -22,9 +22,9 @@ cloud_custom_bytes = bytes(cloud_custom_string, "utf-8") client = EventGridConsumer() -deserialized_dict_event = client.deserialize_event(cloud_custom_dict) -deserialized_str_event = client.deserialize_event(cloud_custom_string) -deserialized_bytes_event = client.deserialize_event(cloud_custom_bytes) +deserialized_dict_event = client.decode_cloud_event(cloud_custom_dict) +deserialized_str_event = client.decode_cloud_event(cloud_custom_string) +deserialized_bytes_event = client.decode_cloud_event(cloud_custom_bytes) print(deserialized_bytes_event.model == deserialized_str_event.model) print(deserialized_bytes_event.model == deserialized_dict_event.model) \ No newline at end of file diff --git a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_eg_storage_blob_created_data_sample.py b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_eg_storage_blob_created_data_sample.py index 894a471a354c..3ce2ebeecf02 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_eg_storage_blob_created_data_sample.py +++ b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_eg_storage_blob_created_data_sample.py @@ -36,9 +36,9 @@ eg_storage_bytes = bytes(eg_storage_string, "utf-8") client = EventGridConsumer() -deserialized_dict_event = client.deserialize_event(eg_storage_dict) -deserialized_str_event = client.deserialize_event(eg_storage_string) -deserialized_bytes_event = client.deserialize_event(eg_storage_bytes) +deserialized_dict_event = client.decode_eventgrid_event(eg_storage_dict) +deserialized_str_event = client.decode_eventgrid_event(eg_storage_string) +deserialized_bytes_event = client.decode_eventgrid_event(eg_storage_bytes) print(deserialized_bytes_event.model == deserialized_str_event.model) print(deserialized_bytes_event.model == deserialized_dict_event.model) diff --git a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_eventhub.py b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_eventhub.py index fd820ea90d87..4ea4fb633644 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_eventhub.py +++ b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_eventhub.py @@ -20,7 +20,7 @@ def on_event(partition_context, event): dict_event = event.body_as_json()[0] - deserialized_event = eg_consumer.deserialize_event(dict_event) + deserialized_event = eg_consumer.decode_eventgrid_event(dict_event) if deserialized_event.model.__class__ == CloudEvent: dict_event = deserialized_event.to_json() print("event.type: {}\n".format(dict_event["type"])) diff --git a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_service_bus_queue.py b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_service_bus_queue.py index 26b627179ea4..92a324185483 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_service_bus_queue.py +++ b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_service_bus_queue.py @@ -28,13 +28,14 @@ print("number of messages: {}".format(len(msgs))) for msg in msgs: # receive single dict message - deserialized_event = consumer.deserialize_event(str(msg)) - if deserialized_event.model.__class__ == CloudEvent: + if 'specversion' in msg: + deserialized_event = consumer.decode_cloud_event(str(msg)) dict_event = deserialized_event.to_json() print("event.to_json(): {}\n".format(dict_event)) print("model: {}\n".format(deserialized_event.model)) print("model.data: {}\n".format(deserialized_event.model.data)) else: + deserialized_event = consumer.decode_eventgrid_event(str(msg)) dict_event = deserialized_event.to_json() print("event.to_json(): {}\n".format(dict_event)) print("model: {}\n".format(deserialized_event.model)) diff --git a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_storage_queue.py b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_storage_queue.py index db341bd55572..5ee6b808a3f7 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_storage_queue.py +++ b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/e2e_samples/consume_cloud_events_from_storage_queue.py @@ -23,14 +23,15 @@ msgs = queue_client.receive_messages() for msg in msgs: # receive single dict message - deserialized_event = consumer.deserialize_event(b64decode(msg.content)) - if deserialized_event.model.__class__ == CloudEvent: + if 'specversion' in msg: + deserialized_event = consumer.decode_cloud_event(b64decode(msg.content)) dict_event = deserialized_event.to_json() print("event.type: {}\n".format(dict_event["type"])) print("event.to_json(): {}\n".format(dict_event)) print("model: {}\n".format(deserialized_event.model)) print("model.data: {}\n".format(deserialized_event.model.data)) else: + deserialized_event = consumer.decode_eventgrid_event(b64decode(msg.content)) dict_event = deserialized_event.to_json() print("event.to_json(): {}\n".format(dict_event)) print("model: {}\n".format(deserialized_event.model))