azure.eventgrid package¶
Module contents¶
-
class
azure.eventgrid.
CloudEvent
(source: str, type: str, **kwargs: Any)[source]¶ Bases:
azure.eventgrid._models.EventMixin
Properties of an event published to an Event Grid topic using the CloudEvent 1.0 Schema.
All required parameters must be populated in order to send to Azure.
- Parameters
source (str) – Required. Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. If publishing to a domain topic, source must be the domain name.
data (object) – Event data specific to the event type.
type (str) – Required. Type of event related to the originating occurrence.
time (datetime) – The time (in UTC) the event was generated, in RFC3339 format.
dataschema (str) – Identifies the schema that data adheres to.
datacontenttype (str) – Content type of data value.
subject (str) – This describes the subject of the event in the context of the event producer (identified by source).
id (Optional[str]) – Optional. An identifier for the event. The combination of id and source must be unique for each distinct event.
-
class
azure.eventgrid.
CustomEvent
(*args: Any, **kwargs: Any)[source]¶ Bases:
azure.eventgrid._shared.mixins.DictMixin
The wrapper class for a CustomEvent, to be used when publishing events. :param dict args: dict
-
class
azure.eventgrid.
EventGridConsumer
[source]¶ Bases:
object
A consumer responsible for deserializing event handler messages, to allow for access to strongly typed Event objects.
-
decode_cloud_event
(cloud_event: Union[str, dict, bytes], **kwargs: Any) → CloudEvent[source]¶ Single event following CloudEvent schema will be parsed and returned as Deserialized Event. :param cloud_event: The event to be deserialized. :type cloud_event: Union[str, dict, bytes] :rtype: CloudEvent
- Raise
ValueError
, when events do not follow CloudEvent schema.
-
decode_eventgrid_event
(eventgrid_event: Union[str, dict, bytes], **kwargs: Any) → EventGridEvent[source]¶ Single event following EventGridEvent schema will be parsed and returned as Deserialized Event. :param eventgrid_event: The event to be deserialized. :type eventgrid_event: Union[str, dict, bytes] :rtype: EventGridEvent
- Raise
ValueError
, when events do not follow EventGridEvent schema.
-
-
class
azure.eventgrid.
EventGridEvent
(subject: str, event_type: str, **kwargs: Any)[source]¶ Bases:
azure.eventgrid._generated.models._models_py3.EventGridEvent
,azure.eventgrid._models.EventMixin
Properties of an event published to an Event Grid topic using the EventGrid Schema.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
- Parameters
topic (str) – The resource path of the event source. If not provided, Event Grid will stamp onto the event.
subject (str) – Required. A resource path relative to the topic path.
data (object) – Event data specific to the event type.
event_type (str) – Required. The type of the event that occurred.
data_version (str) – The schema version of the data object. If not provided, will be stamped with an empty value.
id (Optional[str]) – Optional. An identifier for the event. The combination of id and source must be unique for each distinct event.
event_time (Optional[datetime]) – Optional.The time (in UTC) of the event. If not provided, it will be the time (in UTC) the event was generated.
- Variables
metadata_version (str) – The schema version of the event metadata. If provided, must match Event Grid Schema exactly. If not provided, EventGrid will stamp onto event.
-
class
azure.eventgrid.
EventGridPublisherClient
(topic_hostname: str, credential: Union[AzureKeyCredential, EventGridSharedAccessSignatureCredential], **kwargs: Any)[source]¶ Bases:
object
EventGrid Python Publisher Client.
- Parameters
topic_hostname (str) – The topic endpoint to send the events to.
credential (AzureKeyCredential or EventGridSharedAccessSignatureCredential) – The credential object used for authentication which implements SAS key authentication or SAS token authentication.
-
send
(events: SendType, **kwargs: Any) → None[source]¶ Sends event data to topic hostname specified during client initialization.
- Parameters
events (SendType) – A list or an instance of CloudEvent/EventGridEvent/CustomEvent to be sent.
- Keyword Arguments
content_type (str) – 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
- Return type
- Raises
ValueError
, when events do not follow specified SendType.
Bases:
object
Creates an instance of an EventGridSharedAccessSignatureCredential for use with a service client. :param str signature: Signature to use in authentication.
Updates the key property value of the signature to be used in authentication.
- Parameters
signature (str) – Signature to use in authentication.
The value of the signature to be used in authentication.
- Return type
Helper method to generate shared access signature given hostname, key, and expiration date. :param str topic_hostname: The topic endpoint to send the events to.
Similar to <YOUR-TOPIC-NAME>.<YOUR-REGION-NAME>-1.eventgrid.azure.net
- Parameters
shared_access_key (str) – The shared access key to be used for generating the token
expiration_date_utc (datetime.datetime) – The expiration datetime in UTC for the signature.
api_version (str) – The API Version to include in the signature. If not provided, the default API version will be used.
- Return type