Skip to content

Examples#

Index > CloudHSMV2 > Examples

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

Client#

Implicit type annotations#

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

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

# CloudHSMV2Client usage example

from aioboto3.session import Session


session = Session()

async with session.client("cloudhsmv2") as client:  # (1)
    result = await client.copy_backup_to_region()  # (2)
  1. client: CloudHSMV2Client
  2. result: CopyBackupToRegionResponseTypeDef
# DescribeBackupsPaginator usage example

from aioboto3.session import Session


session = Session()

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

Explicit type annotations#

With types-aioboto3-lite[cloudhsmv2] or a standalone types_aiobotocore_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.

# CloudHSMV2Client usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_cloudhsmv2.client import CloudHSMV2Client
from types_aiobotocore_cloudhsmv2.type_defs import CopyBackupToRegionResponseTypeDef
from types_aiobotocore_cloudhsmv2.type_defs import CopyBackupToRegionRequestRequestTypeDef


session = Session()

client: CloudHSMV2Client
async with session.client("cloudhsmv2") as client:  # (1)
    kwargs: CopyBackupToRegionRequestRequestTypeDef = {...}  # (2)
    result: CopyBackupToRegionResponseTypeDef = await client.copy_backup_to_region(**kwargs)  # (3)
  1. client: CloudHSMV2Client
  2. kwargs: CopyBackupToRegionRequestRequestTypeDef
  3. result: CopyBackupToRegionResponseTypeDef
# DescribeBackupsPaginator usage example with type annotations

from aioboto3.session import Session

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


session = Session()

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