Skip to content

Examples#

Index > CloudWatchNetworkMonitor > Examples

Auto-generated documentation for CloudWatchNetworkMonitor type annotations stubs module types-boto3-networkmonitor.

Client#

Implicit type annotations#

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

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

Client method usage example#

# CloudWatchNetworkMonitorClient usage example

from boto3.session import Session


session = Session()

client = session.client("networkmonitor")  # (1)
result = client.create_monitor()  # (2)
  1. client: CloudWatchNetworkMonitorClient
  2. result: CreateMonitorOutputTypeDef

Paginator usage example#

# ListMonitorsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("list_monitors")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: CloudWatchNetworkMonitorClient
  2. paginator: ListMonitorsPaginator
  3. item: ListMonitorsOutputTypeDef

Explicit type annotations#

With types-boto3-lite[networkmonitor] or a standalone types_boto3_networkmonitor package, you have to explicitly specify client: CloudWatchNetworkMonitorClient 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.

Client method usage example#

# CloudWatchNetworkMonitorClient usage example with type annotations

from boto3.session import Session

from types_boto3_networkmonitor.client import CloudWatchNetworkMonitorClient
from types_boto3_networkmonitor.type_defs import CreateMonitorOutputTypeDef
from types_boto3_networkmonitor.type_defs import CreateMonitorInputTypeDef


session = Session()

client: CloudWatchNetworkMonitorClient = session.client("networkmonitor")

kwargs: CreateMonitorInputTypeDef = {...}
result: CreateMonitorOutputTypeDef = client.create_monitor(**kwargs)

Paginator usage example#

# ListMonitorsPaginator usage example with type annotations

from boto3.session import Session

from types_boto3_networkmonitor.client import CloudWatchNetworkMonitorClient
from types_boto3_networkmonitor.paginator import ListMonitorsPaginator
from types_boto3_networkmonitor.type_defs import ListMonitorsOutputTypeDef


session = Session()
client: CloudWatchNetworkMonitorClient = session.client("networkmonitor")

paginator: ListMonitorsPaginator = client.get_paginator("list_monitors")
for item in paginator.paginate(...):
    item: ListMonitorsOutputTypeDef
    print(item)