Skip to content

Examples#

Index > EventBridge > Examples

Auto-generated documentation for EventBridge type annotations stubs module types-boto3-events.

Client#

Implicit type annotations#

Can be used with types-boto3[events] package installed.

Write your EventBridge code as usual, type checking and code completion should work out of the box.

# EventBridgeClient usage example

from boto3.session import Session


session = Session()

client = session.client("events")  # (1)
result = client.activate_event_source()  # (2)
  1. client: EventBridgeClient
  2. result: EmptyResponseMetadataTypeDef
# ListRuleNamesByTargetPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("events")  # (1)

paginator = client.get_paginator("list_rule_names_by_target")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: EventBridgeClient
  2. paginator: ListRuleNamesByTargetPaginator
  3. item: ListRuleNamesByTargetResponseTypeDef

Explicit type annotations#

With types-boto3-lite[events] or a standalone types_boto3_events package, you have to explicitly specify client: EventBridgeClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# EventBridgeClient usage example with type annotations

from boto3.session import Session

from types_boto3_events.client import EventBridgeClient
from types_boto3_events.type_defs import EmptyResponseMetadataTypeDef
from types_boto3_events.type_defs import ActivateEventSourceRequestRequestTypeDef


session = Session()

client: EventBridgeClient = session.client("events")

kwargs: ActivateEventSourceRequestRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.activate_event_source(**kwargs)
# ListRuleNamesByTargetPaginator usage example with type annotations

from boto3.session import Session

from types_boto3_events.client import EventBridgeClient
from types_boto3_events.paginator import ListRuleNamesByTargetPaginator
from types_boto3_events.type_defs import ListRuleNamesByTargetResponseTypeDef


session = Session()
client: EventBridgeClient = session.client("events")

paginator: ListRuleNamesByTargetPaginator = client.get_paginator("list_rule_names_by_target")
for item in paginator.paginate(...):
    item: ListRuleNamesByTargetResponseTypeDef
    print(item)