azure.eventgrid package¶
-
class
azure.eventgrid.
EventGridPublisherClient
(endpoint: str, credential: Union[AzureKeyCredential, AzureSasCredential], **kwargs: Any)[source]¶ EventGrid Python Publisher Client.
- Parameters
endpoint (str) – The topic endpoint to send the events to.
credential (AzureKeyCredential or AzureSasCredential) – The credential object used for authentication which implements SAS key authentication or SAS token authentication.
-
close
() → None[source]¶ Close the
EventGridPublisherClient
session.
-
send
(events: SendType, **kwargs: Any) → None[source]¶ Sends event data to topic hostname specified during client initialization. Multiple events can be published at once by seding a list of events. It is very inefficient to loop the send method for each event instead of just using a list and we highly recommend against it.
- Parameters
events (SendType) – A list of CloudEvent/EventGridEvent 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.
-
class
azure.eventgrid.
CloudEvent
(source: str, type: str, **kwargs: Any)[source]¶ 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. If data is of binary type, data_base64 can be used alternatively. Note that data and data_base64 cannot be present at the same time.
- Parameters
- Keyword Arguments
data – Optional. Event data specific to the event type. Only one of the data or data_base64 argument must be present. If data is of bytes type, it will be sent as data_base64 in the outgoing request.
time – Optional. The time (in UTC) the event was generated, in RFC3339 format.
dataschema – Optional. Identifies the schema that data adheres to.
datacontenttype – Optional. Content type of data value.
subject – Optional. This describes the subject of the event in the context of the event producer (identified by source).
specversion – Optional. The version of the CloudEvent spec. Defaults to “1.0”
id – Optional. An identifier for the event. The combination of id and source must be unique for each distinct event. If not provided, a random UUID will be generated and used.
data_base64 – Optional. Event data specific to the event type if the data is of bytes type. Only data of bytes type is accepted by data-base64 and only one of the data or data_base64 argument must be present.
- Variables
source (str) – 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.
data_base64 (bytes) – Event data specific to the event type if the data is of bytes type.
type (str) – 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).
specversion (str) – Optional. The version of the CloudEvent spec. Defaults to “1.0”
id (Optional[str]) – An identifier for the event. The combination of id and source must be unique for each distinct event. If not provided, a random UUID will be generated and used.
-
class
azure.eventgrid.
EventGridEvent
(subject: str, event_type: str, data: object, data_version: str, **kwargs: Any)[source]¶ 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
subject (str) – Required. A resource path relative to the topic path.
event_type (str) – Required. The type of the event that occurred.
data (object) – Required. Event data specific to the event type.
data_version (str) – Required. The schema version of the data object. If not provided, will be stamped with an empty value.
- Keyword Arguments
topic – Optional. The resource path of the event source. If not provided, Event Grid will stamp onto the event.
metadata_version – Optional. The schema version of the event metadata. If provided, must match Event Grid Schema exactly. If not provided, EventGrid will stamp onto event.
id – Optional. An identifier for the event. In not provided, a random UUID will be generated and used.
event_time – Optional.The time (in UTC) of the event. If not provided, it will be the time (in UTC) the event was generated.
- Variables
subject (str) – A resource path relative to the topic path.
event_type (str) – The type of the event that occurred.
data (object) – Event data specific to the event type.
data_version (str) – The schema version of the data object. If not provided, will be stamped with an empty value.
topic (str) – The resource path of the event source. If not provided, Event Grid will stamp onto the event.
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.
id (Optional[str]) – An identifier for the event. In not provided, a random UUID will be generated and used.
event_time (Optional[datetime]) – The time (in UTC) of the event. If not provided, it will be the time (in UTC) the event was generated.
-
as_dict
(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)¶ Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.
The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.
See the three examples in this file:
attribute_transformer
full_restapi_key_transformer
last_restapi_key_transformer
If you want XML serialization, you can pass the kwargs is_xml=True.
- Parameters
key_transformer (function) – A key transformer function.
- Returns
A dict JSON compatible object
- Return type
-
classmethod
deserialize
(data, content_type=None)¶ Parse a str using the RestAPI syntax and return a model.
-
classmethod
enable_additional_properties_sending
()¶
-
classmethod
from_dict
(data, key_extractors=None, content_type=None)¶ Parse a dict using given key extractor return a model.
By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)
-
classmethod
is_xml_model
()¶
-
serialize
(keep_readonly=False, **kwargs)¶ Return the JSON that would be sent to azure from this model.
This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).
If you want XML serialization, you can pass the kwargs is_xml=True.
-
class
azure.eventgrid.
SystemEventNames
[source]¶ This enum represents the names of the various event types for the system events published to Azure Event Grid. To check the list of recognizable system topics, visit https://docs.microsoft.com/azure/event-grid/system-topics.
-
ACSChatMemberAddedToThreadWithUserEventName
= 'Microsoft.Communication.ChatMemberAddedToThreadWithUser'¶
-
ACSChatMemberRemovedFromThreadWithUserEventName
= 'Microsoft.Communication.ChatMemberRemovedFromThreadWithUser'¶
-
ACSChatMessageDeletedEventName
= 'Microsoft.Communication.ChatMessageDeleted'¶
-
ACSChatMessageEditedEventName
= 'Microsoft.Communication.ChatMessageEdited'¶
-
ACSChatMessageReceivedEventName
= 'Microsoft.Communication.ChatMessageReceived'¶
-
ACSChatThreadCreatedWithUserEventName
= 'Microsoft.Communication.ChatThreadCreatedWithUser'¶
-
ACSChatThreadPropertiesUpdatedPerUserEventName
= 'Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser'¶
-
ACSChatThreadWithUserDeletedEventName
= 'Microsoft.Communication.ChatThreadWithUserDeleted'¶
-
ACSSMSDeliveryReportReceivedEventName
= 'Microsoft.Communication.SMSDeliveryReportReceived'¶
-
ACSSMSReceivedEventName
= 'Microsoft.Communication.SMSReceived'¶
-
AppConfigurationKeyValueDeletedEventName
= 'Microsoft.AppConfiguration.KeyValueDeleted'¶
-
AppConfigurationKeyValueModifiedEventName
= 'Microsoft.AppConfiguration.KeyValueModified'¶
-
ContainerRegistryChartDeletedEventName
= 'Microsoft.ContainerRegistry.ChartDeleted'¶
-
ContainerRegistryChartPushedEventName
= 'Microsoft.ContainerRegistry.ChartPushed'¶
-
ContainerRegistryImageDeletedEventName
= 'Microsoft.ContainerRegistry.ImageDeleted'¶
-
ContainerRegistryImagePushedEventName
= 'Microsoft.ContainerRegistry.ImagePushed'¶
-
EventGridSubscriptionDeletedEventName
= 'Microsoft.EventGrid.SubscriptionDeletedEvent'¶
-
EventGridSubscriptionValidationEventName
= 'Microsoft.EventGrid.SubscriptionValidationEvent'¶
-
EventHubCaptureFileCreatedEventName
= 'Microsoft.EventHub.CaptureFileCreated'¶
-
IoTHubDeviceConnectedEventName
= 'Microsoft.Devices.DeviceConnected'¶
-
IoTHubDeviceCreatedEventName
= 'Microsoft.Devices.DeviceCreated'¶
-
IoTHubDeviceDeletedEventName
= 'Microsoft.Devices.DeviceDeleted'¶
-
IoTHubDeviceDisconnectedEventName
= 'Microsoft.Devices.DeviceDisconnected'¶
-
IotHubDeviceTelemetryEventName
= 'Microsoft.Devices.DeviceTelemetry'¶
-
KeyVaultAccessPolicyChangedEventName
= 'Microsoft.KeyVault.VaultAccessPolicyChanged'¶
-
KeyVaultCertificateExpiredEventName
= 'Microsoft.KeyVault.CertificateExpired'¶
-
KeyVaultCertificateNearExpiryEventName
= 'Microsoft.KeyVault.CertificateNearExpiry'¶
-
KeyVaultCertificateNewVersionCreatedEventName
= 'Microsoft.KeyVault.CertificateNewVersionCreated'¶
-
KeyVaultKeyExpiredEventName
= 'Microsoft.KeyVault.KeyExpired'¶
-
KeyVaultKeyNearExpiryEventName
= 'Microsoft.KeyVault.KeyNearExpiry'¶
-
KeyVaultKeyNewVersionCreatedEventName
= 'Microsoft.KeyVault.KeyNewVersionCreated'¶
-
KeyVaultSecretExpiredEventName
= 'Microsoft.KeyVault.SecretExpired'¶
-
KeyVaultSecretNearExpiryEventName
= 'Microsoft.KeyVault.SecretNearExpiry'¶
-
KeyVaultSecretNewVersionCreatedEventName
= 'Microsoft.KeyVault.SecretNewVersionCreated'¶
-
MachineLearningServicesDatasetDriftDetectedEventName
= 'Microsoft.MachineLearningServices.DatasetDriftDetected'¶
-
MachineLearningServicesModelDeployedEventName
= 'Microsoft.MachineLearningServices.ModelDeployed'¶
-
MachineLearningServicesModelRegisteredEventName
= 'Microsoft.MachineLearningServices.ModelRegistered'¶
-
MachineLearningServicesRunCompletedEventName
= 'Microsoft.MachineLearningServices.RunCompleted'¶
-
MachineLearningServicesRunStatusChangedEventName
= 'Microsoft.MachineLearningServices.RunStatusChanged'¶
-
MapsGeofenceEnteredEventName
= 'Microsoft.Maps.GeofenceEntered'¶
-
MapsGeofenceExitedEventName
= 'Microsoft.Maps.GeofenceExited'¶
-
MapsGeofenceResultEventName
= 'Microsoft.Maps.GeofenceResult'¶
-
MediaJobCanceledEventName
= 'Microsoft.Media.JobCanceled'¶
-
MediaJobCancelingEventName
= 'Microsoft.Media.JobCanceling'¶
-
MediaJobErroredEventName
= 'Microsoft.Media.JobErrored'¶
-
MediaJobFinishedEventName
= 'Microsoft.Media.JobFinished'¶
-
MediaJobOutputCanceledEventName
= 'Microsoft.Media.JobOutputCanceled'¶
-
MediaJobOutputCancelingEventName
= 'Microsoft.Media.JobOutputCanceling'¶
-
MediaJobOutputErroredEventName
= 'Microsoft.Media.JobOutputErrored'¶
-
MediaJobOutputFinishedEventName
= 'Microsoft.Media.JobOutputFinished'¶
-
MediaJobOutputProcessingEventName
= 'Microsoft.Media.JobOutputProcessing'¶
-
MediaJobOutputProgressEventName
= 'Microsoft.Media.JobOutputProgress'¶
-
MediaJobOutputScheduledEventName
= 'Microsoft.Media.JobOutputScheduled'¶
-
MediaJobOutputStateChangeEventName
= 'Microsoft.Media.JobOutputStateChange'¶
-
MediaJobProcessingEventName
= 'Microsoft.Media.JobProcessing'¶
-
MediaJobScheduledEventName
= 'Microsoft.Media.JobScheduled'¶
-
MediaJobStateChangeEventName
= 'Microsoft.Media.JobStateChange'¶
-
MediaLiveEventConnectionRejectedEventName
= 'Microsoft.Media.LiveEventConnectionRejected'¶
-
MediaLiveEventEncoderConnectedEventName
= 'Microsoft.Media.LiveEventEncoderConnected'¶
-
MediaLiveEventEncoderDisconnectedEventName
= 'Microsoft.Media.LiveEventEncoderDisconnected'¶
-
MediaLiveEventIncomingDataChunkDroppedEventName
= 'Microsoft.Media.LiveEventIncomingDataChunkDropped'¶
-
MediaLiveEventIncomingStreamReceivedEventName
= 'Microsoft.Media.LiveEventIncomingStreamReceived'¶
-
MediaLiveEventIncomingStreamsOutOfSyncEventName
= 'Microsoft.Media.LiveEventIncomingStreamsOutOfSync'¶
-
MediaLiveEventIncomingVideoStreamsOutOfSyncEventName
= 'Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync'¶
-
MediaLiveEventIngestHeartbeatEventName
= 'Microsoft.Media.LiveEventIngestHeartbeat'¶
-
MediaLiveEventTrackDiscontinuityDetectedEventName
= 'Microsoft.Media.LiveEventTrackDiscontinuityDetected'¶
-
ResourceActionCancelEventName
= 'Microsoft.Resources.ResourceActionCancel'¶
-
ResourceActionFailureEventName
= 'Microsoft.Resources.ResourceActionFailure'¶
-
ResourceActionSuccessEventName
= 'Microsoft.Resources.ResourceActionSuccess'¶
-
ResourceDeleteCancelEventName
= 'Microsoft.Resources.ResourceDeleteCancel'¶
-
ResourceDeleteFailureEventName
= 'Microsoft.Resources.ResourceDeleteFailure'¶
-
ResourceDeleteSuccessEventName
= 'Microsoft.Resources.ResourceDeleteSuccess'¶
-
ResourceWriteCancelEventName
= 'Microsoft.Resources.ResourceWriteCancel'¶
-
ResourceWriteFailureEventName
= 'Microsoft.Resources.ResourceWriteFailure'¶
-
ResourceWriteSuccessEventName
= 'Microsoft.Resources.ResourceWriteSuccess'¶
-
ServiceBusActiveMessagesAvailableWithNoListenersEventName
= 'Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners'¶
-
ServiceBusDeadletterMessagesAvailableWithNoListenerEventName
= 'Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener'¶
-
StorageBlobCreatedEventName
= 'Microsoft.Storage.BlobCreated'¶
-
StorageBlobDeletedEventName
= 'Microsoft.Storage.BlobDeleted'¶
-
StorageBlobRenamedEventName
= 'Microsoft.Storage.BlobRenamed'¶
-
StorageDirectoryCreatedEventName
= 'Microsoft.Storage.DirectoryCreated'¶
-
StorageDirectoryDeletedEventName
= 'Microsoft.Storage.DirectoryDeleted'¶
-
StorageDirectoryRenamedEventName
= 'Microsoft.Storage.DirectoryRenamed'¶
-
StorageLifecyclePolicyCompletedEventName
= 'Microsoft.Storage.LifecyclePolicyCompleted'¶
-
WebAppServicePlanUpdatedEventName
= 'Microsoft.Web.AppServicePlanUpdated'¶
-
WebAppUpdatedEventName
= 'Microsoft.Web.AppUpdated'¶
-
WebBackupOperationCompletedEventName
= 'Microsoft.Web.BackupOperationCompleted'¶
-
WebBackupOperationFailedEventName
= 'Microsoft.Web.BackupOperationFailed'¶
-
WebBackupOperationStartedEventName
= 'Microsoft.Web.BackupOperationStarted'¶
-
WebRestoreOperationCompletedEventName
= 'Microsoft.Web.RestoreOperationCompleted'¶
-
WebRestoreOperationFailedEventName
= 'Microsoft.Web.RestoreOperationFailed'¶
-
WebRestoreOperationStartedEventName
= 'Microsoft.Web.RestoreOperationStarted'¶
-
WebSlotSwapCompletedEventName
= 'Microsoft.Web.SlotSwapCompleted'¶
-
WebSlotSwapFailedEventName
= 'Microsoft.Web.SlotSwapFailed'¶
-
WebSlotSwapStartedEventName
= 'Microsoft.Web.SlotSwapStarted'¶
-
WebSlotSwapWithPreviewCancelledEventName
= 'Microsoft.Web.SlotSwapWithPreviewCancelled'¶
-
WebSlotSwapWithPreviewStartedEventName
= 'Microsoft.Web.SlotSwapWithPreviewStarted'¶
-
-
azure.eventgrid.
generate_sas
(endpoint: str, shared_access_key: str, expiration_date_utc: datetime, **kwargs: Any) → str[source]¶ Helper method to generate shared access signature given hostname, key, and expiration date. :param str endpoint: 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.
- Keyword Arguments
api_version (str) – The API Version to include in the signature. If not provided, the default API version will be used.
- Return type