# Event Notifications ## List Event Notification Rules `r2.buckets.event_notifications.list(strbucket_name, EventNotificationListParams**kwargs) -> EventNotificationListResponse` **get** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration` List all event notification rules for a bucket. ### Parameters - `account_id: str` Account ID. - `bucket_name: str` Name of the bucket. - `jurisdiction: Optional[Literal["default", "eu", "fedramp"]]` Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `class EventNotificationListResponse: …` - `bucket_name: Optional[str]` Name of the bucket. - `queues: Optional[List[Queue]]` List of queues associated with the bucket. - `queue_id: Optional[str]` Queue ID. - `queue_name: Optional[str]` Name of the queue. - `rules: Optional[List[QueueRule]]` - `actions: List[Literal["PutObject", "CopyObject", "DeleteObject", 2 more]]` Array of R2 object actions that will trigger notifications. - `"PutObject"` - `"CopyObject"` - `"DeleteObject"` - `"CompleteMultipartUpload"` - `"LifecycleDeletion"` - `created_at: Optional[str]` Timestamp when the rule was created. - `description: Optional[str]` A description that can be used to identify the event notification rule after creation. - `prefix: Optional[str]` Notifications will be sent only for objects with this prefix. - `rule_id: Optional[str]` Rule ID. - `suffix: Optional[str]` Notifications will be sent only for objects with this suffix. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) event_notifications = client.r2.buckets.event_notifications.list( bucket_name="example-bucket", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(event_notifications.bucket_name) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "bucketName": "bucketName", "queues": [ { "queueId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "queueName": "first-queue", "rules": [ { "actions": [ "PutObject", "CopyObject" ], "createdAt": "2024-09-19T21:54:48.405Z", "description": "Notifications from source bucket to queue", "prefix": "img/", "ruleId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "suffix": ".jpeg" } ] } ] }, "success": true } ``` ## Get Event Notification Rule `r2.buckets.event_notifications.get(strqueue_id, EventNotificationGetParams**kwargs) -> EventNotificationGetResponse` **get** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}` Get a single event notification rule. ### Parameters - `account_id: str` Account ID. - `bucket_name: str` Name of the bucket. - `queue_id: str` Queue ID. - `jurisdiction: Optional[Literal["default", "eu", "fedramp"]]` The bucket jurisdiction. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `class EventNotificationGetResponse: …` - `queue_id: Optional[str]` Queue ID. - `queue_name: Optional[str]` Name of the queue. - `rules: Optional[List[Rule]]` - `actions: List[Literal["PutObject", "CopyObject", "DeleteObject", 2 more]]` Array of R2 object actions that will trigger notifications. - `"PutObject"` - `"CopyObject"` - `"DeleteObject"` - `"CompleteMultipartUpload"` - `"LifecycleDeletion"` - `created_at: Optional[str]` Timestamp when the rule was created. - `description: Optional[str]` A description that can be used to identify the event notification rule after creation. - `prefix: Optional[str]` Notifications will be sent only for objects with this prefix. - `rule_id: Optional[str]` Rule ID. - `suffix: Optional[str]` Notifications will be sent only for objects with this suffix. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) event_notification = client.r2.buckets.event_notifications.get( queue_id="queue_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", bucket_name="example-bucket", ) print(event_notification.queue_id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "queueId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "queueName": "first-queue", "rules": [ { "actions": [ "PutObject", "CopyObject" ], "createdAt": "2024-09-19T21:54:48.405Z", "description": "Notifications from source bucket to queue", "prefix": "img/", "ruleId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "suffix": ".jpeg" } ] }, "success": true } ``` ## Create Event Notification Rule `r2.buckets.event_notifications.update(strqueue_id, EventNotificationUpdateParams**kwargs) -> object` **put** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}` Create event notification rule. ### Parameters - `account_id: str` Account ID. - `bucket_name: str` Name of the bucket. - `queue_id: str` Queue ID. - `rules: Iterable[Rule]` Array of rules to drive notifications. - `actions: List[Literal["PutObject", "CopyObject", "DeleteObject", 2 more]]` Array of R2 object actions that will trigger notifications. - `"PutObject"` - `"CopyObject"` - `"DeleteObject"` - `"CompleteMultipartUpload"` - `"LifecycleDeletion"` - `description: Optional[str]` A description that can be used to identify the event notification rule after creation. - `prefix: Optional[str]` Notifications will be sent only for objects with this prefix. - `suffix: Optional[str]` Notifications will be sent only for objects with this suffix. - `jurisdiction: Optional[Literal["default", "eu", "fedramp"]]` Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) event_notification = client.r2.buckets.event_notifications.update( queue_id="queue_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", bucket_name="example-bucket", rules=[{ "actions": ["PutObject", "CopyObject"] }], ) print(event_notification) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Delete Event Notification Rules `r2.buckets.event_notifications.delete(strqueue_id, EventNotificationDeleteParams**kwargs) -> object` **delete** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}` Delete an event notification rule. **If no body is provided, all rules for specified queue will be deleted**. ### Parameters - `account_id: str` Account ID. - `bucket_name: str` Name of the bucket. - `queue_id: str` Queue ID. - `jurisdiction: Optional[Literal["default", "eu", "fedramp"]]` Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) event_notification = client.r2.buckets.event_notifications.delete( queue_id="queue_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", bucket_name="example-bucket", ) print(event_notification) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Domain Types ### Event Notification List Response - `class EventNotificationListResponse: …` - `bucket_name: Optional[str]` Name of the bucket. - `queues: Optional[List[Queue]]` List of queues associated with the bucket. - `queue_id: Optional[str]` Queue ID. - `queue_name: Optional[str]` Name of the queue. - `rules: Optional[List[QueueRule]]` - `actions: List[Literal["PutObject", "CopyObject", "DeleteObject", 2 more]]` Array of R2 object actions that will trigger notifications. - `"PutObject"` - `"CopyObject"` - `"DeleteObject"` - `"CompleteMultipartUpload"` - `"LifecycleDeletion"` - `created_at: Optional[str]` Timestamp when the rule was created. - `description: Optional[str]` A description that can be used to identify the event notification rule after creation. - `prefix: Optional[str]` Notifications will be sent only for objects with this prefix. - `rule_id: Optional[str]` Rule ID. - `suffix: Optional[str]` Notifications will be sent only for objects with this suffix. ### Event Notification Get Response - `class EventNotificationGetResponse: …` - `queue_id: Optional[str]` Queue ID. - `queue_name: Optional[str]` Name of the queue. - `rules: Optional[List[Rule]]` - `actions: List[Literal["PutObject", "CopyObject", "DeleteObject", 2 more]]` Array of R2 object actions that will trigger notifications. - `"PutObject"` - `"CopyObject"` - `"DeleteObject"` - `"CompleteMultipartUpload"` - `"LifecycleDeletion"` - `created_at: Optional[str]` Timestamp when the rule was created. - `description: Optional[str]` A description that can be used to identify the event notification rule after creation. - `prefix: Optional[str]` Notifications will be sent only for objects with this prefix. - `rule_id: Optional[str]` Rule ID. - `suffix: Optional[str]` Notifications will be sent only for objects with this suffix.