Skip to content

Examples#

Index > CloudHSMV2 > Examples

Auto-generated documentation for CloudHSMV2 type annotations stubs module types-boto3-cloudhsmv2.

Client#

Implicit type annotations#

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

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

Client method usage example#

# CloudHSMV2Client usage example

from boto3.session import Session


session = Session()

client = session.client("cloudhsmv2")  # (1)
result = client.copy_backup_to_region()  # (2)
  1. client: CloudHSMV2Client
  2. result: CopyBackupToRegionResponseTypeDef

Paginator usage example#

# DescribeBackupsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("describe_backups")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: CloudHSMV2Client
  2. paginator: DescribeBackupsPaginator
  3. item: DescribeBackupsResponseTypeDef

Explicit type annotations#

With types-boto3-lite[cloudhsmv2] or a standalone types_boto3_cloudhsmv2 package, you have to explicitly specify client: CloudHSMV2Client 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#

# CloudHSMV2Client usage example with type annotations

from boto3.session import Session

from types_boto3_cloudhsmv2.client import CloudHSMV2Client
from types_boto3_cloudhsmv2.type_defs import CopyBackupToRegionResponseTypeDef
from types_boto3_cloudhsmv2.type_defs import CopyBackupToRegionRequestTypeDef


session = Session()

client: CloudHSMV2Client = session.client("cloudhsmv2")

kwargs: CopyBackupToRegionRequestTypeDef = {...}
result: CopyBackupToRegionResponseTypeDef = client.copy_backup_to_region(**kwargs)

Paginator usage example#

# DescribeBackupsPaginator usage example with type annotations

from boto3.session import Session

from types_boto3_cloudhsmv2.client import CloudHSMV2Client
from types_boto3_cloudhsmv2.paginator import DescribeBackupsPaginator
from types_boto3_cloudhsmv2.type_defs import DescribeBackupsResponseTypeDef


session = Session()
client: CloudHSMV2Client = session.client("cloudhsmv2")

paginator: DescribeBackupsPaginator = client.get_paginator("describe_backups")
for item in paginator.paginate(...):
    item: DescribeBackupsResponseTypeDef
    print(item)