azure.eventgrid.aio package¶
- class azure.eventgrid.aio.EventGridConsumerClient(endpoint: str, credential: AzureKeyCredential | AsyncTokenCredential, *, namespace_topic: str, subscription: str, api_version: str | None = None, **kwargs: Any)[source]¶
EventGridConsumerClient.
Consumes and manages events from a namespace topic and event subscription specified during the client initialization.
- Parameters:
endpoint (str) – The endpoint of the Event Grid tier (basic or namespace), e.g. namespaceName1.westus-1.eventgrid.azure.net. Required.
credential (AzureKeyCredential or AsyncTokenCredential) – Credential used to authenticate requests to the service. Is either a AzureKeyCredential type or a AsyncTokenCredential type. Required.
- Keyword Arguments:
namespace_topic (str) – The name of the topic to consume events from. Required.
subscription (str) – The name of the subscription to consume events from. Required.
api_version (str) – The API version to use for this operation. Default value is “2024-06-01”. Note that overriding this default value may result in unsupported behavior.
- async acknowledge(*, lock_tokens: List[str], **kwargs: Any) AcknowledgeResult ¶
Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens, along with other failed lock tokens with their corresponding error information. Successfully acknowledged events will no longer be available to be received by any consumer.
- Keyword Arguments:
lock_tokens (List[str]) – Array of lock tokens of Cloud Events. Required.
- Returns:
AcknowledgeResult. The AcknowledgeResult is compatible with MutableMapping
- Return type:
- Raises:
- async receive(*, max_events: int | None = None, max_wait_time: int | None = None, **kwargs: Any) List[ReceiveDetails] ¶
Receive Batch of Cloud Events from the Event Subscription.
- Keyword Arguments:
max_events (int) – Max Events count to be received. Minimum value is 1, while maximum value is 100 events. The default is None, meaning it will receive one event if available.
max_wait_time (int) – Max wait time value for receive operation in Seconds. It is the time in seconds that the server approximately waits for the availability of an event and responds to the request. If an event is available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120 seconds. The default value is None, meaning it will wait for 60 seconds.
- Returns:
ReceiveDetails list of received events and their broker properties.
- Return type:
- Raises:
- async reject(*, lock_tokens: List[str], **kwargs: Any) RejectResult ¶
Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along with other failed lock tokens with their corresponding error information. Successfully rejected events will be dead-lettered and can no longer be received by a consumer.
- Keyword Arguments:
lock_tokens (List[str]) – Array of lock tokens of Cloud Events. Required.
- Returns:
RejectResult. The RejectResult is compatible with MutableMapping
- Return type:
- Raises:
- async release(*, lock_tokens: List[str], release_delay: int | ReleaseDelay | None = None, **kwargs: Any) ReleaseResult ¶
Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along with other failed lock tokens with their corresponding error information. Successfully released events can be received by consumers.
- Keyword Arguments:
lock_tokens (List[str]) – Array of lock tokens of Cloud Events. Required.
release_delay (int or ReleaseDelay) – Release cloud events with the specified delay in seconds. Known values are: 0, 10, 60, 600, and 3600. Default value is None, indicating no delay.
- Returns:
ReleaseResult. The ReleaseResult is compatible with MutableMapping
- Return type:
- Raises:
- async renew_locks(*, lock_tokens: List[str], **kwargs: Any) RenewLocksResult ¶
Renew lock for batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully renewed lockTokens, along with other failed lockTokens with their corresponding error information.
- Keyword Arguments:
lock_tokens (List[str]) – Array of lock tokens of Cloud Events. Required.
- Returns:
RenewLocksResult. The RenewLocksResult is compatible with MutableMapping
- Return type:
- Raises:
- send_request(request: HttpRequest, *, stream: bool = False, **kwargs: Any) Awaitable[AsyncHttpResponse] [source]¶
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 = await client.send_request(request) <AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
- Parameters:
request (HttpRequest) – The network request you want to make. Required.
- Keyword Arguments:
stream (bool) – Whether the response payload will be streamed. Defaults to False.
- Returns:
The response of your network call. Does not do error handling on your response.
- Return type:
- class azure.eventgrid.aio.EventGridPublisherClient(endpoint: str, credential: AzureKeyCredential | AzureSasCredential | AsyncTokenCredential, *, namespace_topic: str | None = None, api_version: str | None = None, **kwargs: Any)[source]¶
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.
- Parameters:
endpoint (str) – The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net. Required.
credential (AzureKeyCredential or AsyncTokenCredential) – Credential used to authenticate requests to the service. Is either a AzureKeyCredential type or a AsyncTokenCredential type. Required.
- Keyword Arguments:
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.
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.
- async 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 ¶
Send events to the Event Grid Service.
- Parameters:
events (CloudEvent or List[CloudEvent] or Dict[str, Any] or List[Dict[str, Any]] or CNCFCloudEvent or List[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 Arguments:
- Returns:
None
- Return type:
None
- send_request(request: HttpRequest, *, stream: bool = False, **kwargs: Any) Awaitable[AsyncHttpResponse] [source]¶
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 = await client.send_request(request) <AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
- Parameters:
request (HttpRequest) – The network request you want to make. Required.
- Keyword Arguments:
stream (bool) – Whether the response payload will be streamed. Defaults to False.
- Returns:
The response of your network call. Does not do error handling on your response.
- Return type: