Skip to content

Examples#

Index > CloudWatchRUM > Examples

Auto-generated documentation for CloudWatchRUM type annotations stubs module mypy-boto3-rum.

Client#

Implicit type annotations#

Can be used with boto3-stubs[rum] package installed.

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

# CloudWatchRUMClient usage example

from boto3.session import Session


session = Session()

client = session.client("rum")  # (1)
result = client.batch_create_rum_metric_definitions()  # (2)
  1. client: CloudWatchRUMClient
  2. result: BatchCreateRumMetricDefinitionsResponseTypeDef
# BatchGetRumMetricDefinitionsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("batch_get_rum_metric_definitions")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: CloudWatchRUMClient
  2. paginator: BatchGetRumMetricDefinitionsPaginator
  3. item: BatchGetRumMetricDefinitionsResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[rum] or a standalone mypy_boto3_rum package, you have to explicitly specify client: CloudWatchRUMClient 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.

# CloudWatchRUMClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_rum.client import CloudWatchRUMClient
from mypy_boto3_rum.type_defs import BatchCreateRumMetricDefinitionsResponseTypeDef
from mypy_boto3_rum.type_defs import BatchCreateRumMetricDefinitionsRequestRequestTypeDef


session = Session()

client: CloudWatchRUMClient = session.client("rum")

kwargs: BatchCreateRumMetricDefinitionsRequestRequestTypeDef = {...}
result: BatchCreateRumMetricDefinitionsResponseTypeDef = client.batch_create_rum_metric_definitions(**kwargs)
# BatchGetRumMetricDefinitionsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_rum.client import CloudWatchRUMClient
from mypy_boto3_rum.paginator import BatchGetRumMetricDefinitionsPaginator
from mypy_boto3_rum.type_defs import BatchGetRumMetricDefinitionsResponseTypeDef


session = Session()
client: CloudWatchRUMClient = session.client("rum")

paginator: BatchGetRumMetricDefinitionsPaginator = client.get_paginator("batch_get_rum_metric_definitions")
for item in paginator.paginate(...):
    item: BatchGetRumMetricDefinitionsResponseTypeDef
    print(item)