EventGridPublisherClient Class

EventGridPublisherClient.

Sends events to a basic topic, basic domain, or a namespace topic specified during the client initialization.

A single instance or a list of dictionaries, CloudEvents or EventGridEvents are accepted. If a list is provided, the list must contain only one type of event. If dictionaries are provided and sending to a namespace topic, the dictionary must follow the CloudEvent schema.

Constructor

EventGridPublisherClient(endpoint: str, credential: AzureKeyCredential | AzureSasCredential | TokenCredential, *, namespace_topic: str | None = None, api_version: str | None = None, **kwargs: Any)

Parameters

Name Description
endpoint
Required
str

The endpoint of the Event Grid tier (basic or namespace), e.g. namespaceName1.westus-1.eventgrid.azure.net. Required.

credential
Required

Credential used to authenticate requests to the service. Is either a AzureKeyCredential type or a TokenCredential type. Required.

Keyword-Only Parameters

Name Description
namespace_topic
str or None

The name of the topic to publish events to. Required for Event Grid Namespaces. Default value is None, which is used for Event Grid Basic.

Default value: None
api_version
str

The API version to use for this operation. Default value for Event Grid Namespace is "2024-06-01", default value for Event Grid Basic is "2018-01-01". Note that overriding this default value may result in unsupported behavior.

Default value: None

Methods

close
send

Send events to the Event Grid Service.

send_request

Runs the network request through the client's chained policies.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

close

close() -> None

send

Send events to the Event Grid Service.

send(events: CloudEvent | List[CloudEvent] | Dict[str, Any] | List[Dict[str, Any]] | CNCFCloudEvent | List[CNCFCloudEvent] | EventGridEvent | List[EventGridEvent], *, channel_name: str | None = None, content_type: str | None = None, **kwargs: Any) -> None

Parameters

Name Description
events
Required
<xref:CloudEvent> or List[<xref:CloudEvent>] or Dict[str, Any] or List[Dict[str, Any]] or <xref:CNCFCloudEvent> or List[<xref:CNCFCloudEvent>] or EventGridEvent or List[EventGridEvent]

The event(s) to send. If sending to an Event Grid Namespace, the dict, list of dicts, or event(s) should be in the format of a CloudEvent.

Keyword-Only Parameters

Name Description
channel_name
str or None

The name of the channel to send the event to. Event Grid Basic Resource only.

Default value: None
content_type
str

The content type of the event. If not specified, the default value is "application/cloudevents+json; charset=utf-8".

Default value: None

Returns

Type Description

None

send_request

Runs the network request through the client's chained policies.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

send_request(request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse

Parameters

Name Description
request
Required

The network request you want to make. Required.

Keyword-Only Parameters

Name Description
stream

Whether the response payload will be streamed. Defaults to False.

Default value: False

Returns

Type Description

The response of your network call. Does not do error handling on your response.