Skip to content

Examples#

Index > SSM > Examples

Auto-generated documentation for SSM type annotations stubs module mypy-boto3-ssm.

Client#

Implicit type annotations#

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

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

Client method usage example#

# SSMClient usage example

from boto3.session import Session


session = Session()

client = session.client("ssm")  # (1)
result = client.associate_ops_item_related_item()  # (2)
  1. client: SSMClient
  2. result: AssociateOpsItemRelatedItemResponseTypeDef

Paginator usage example#

# DescribeActivationsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("describe_activations")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: SSMClient
  2. paginator: DescribeActivationsPaginator
  3. item: DescribeActivationsResultTypeDef

Waiter usage example#

# CommandExecutedWaiter usage example

from boto3.session import Session


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

waiter = client.get_waiter("command_executed")  # (2)
waiter.wait(...)
  1. client: SSMClient
  2. waiter: CommandExecutedWaiter

Explicit type annotations#

With boto3-stubs-lite[ssm] or a standalone mypy_boto3_ssm package, you have to explicitly specify client: SSMClient 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#

# SSMClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_ssm.client import SSMClient
from mypy_boto3_ssm.type_defs import AssociateOpsItemRelatedItemResponseTypeDef
from mypy_boto3_ssm.type_defs import AssociateOpsItemRelatedItemRequestTypeDef


session = Session()

client: SSMClient = session.client("ssm")

kwargs: AssociateOpsItemRelatedItemRequestTypeDef = {...}
result: AssociateOpsItemRelatedItemResponseTypeDef = client.associate_ops_item_related_item(**kwargs)

Paginator usage example#

# DescribeActivationsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_ssm.client import SSMClient
from mypy_boto3_ssm.paginator import DescribeActivationsPaginator
from mypy_boto3_ssm.type_defs import DescribeActivationsResultTypeDef


session = Session()
client: SSMClient = session.client("ssm")

paginator: DescribeActivationsPaginator = client.get_paginator("describe_activations")
for item in paginator.paginate(...):
    item: DescribeActivationsResultTypeDef
    print(item)

Waiter usage example#

# CommandExecutedWaiter usage example with type annotations

from boto3.session import Session

from mypy_boto3_ssm.client import SSMClient
from mypy_boto3_ssm.waiter import CommandExecutedWaiter

session = Session()
client: SSMClient = session.client("ssm")

waiter: CommandExecutedWaiter = client.get_waiter("command_executed")
waiter.wait(...)