Skip to content

Examples#

Index > CognitoIdentityProvider > Examples

Auto-generated documentation for CognitoIdentityProvider type annotations stubs module types-boto3-cognito-idp.

Client#

Implicit type annotations#

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

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

# CognitoIdentityProviderClient usage example

from boto3.session import Session


session = Session()

client = session.client("cognito-idp")  # (1)
result = client.admin_add_user_to_group()  # (2)
  1. client: CognitoIdentityProviderClient
  2. result: EmptyResponseMetadataTypeDef
# AdminListGroupsForUserPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("cognito-idp")  # (1)

paginator = client.get_paginator("admin_list_groups_for_user")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: CognitoIdentityProviderClient
  2. paginator: AdminListGroupsForUserPaginator
  3. item: AdminListGroupsForUserResponseTypeDef

Explicit type annotations#

With types-boto3-lite[cognito-idp] or a standalone types_boto3_cognito_idp package, you have to explicitly specify client: CognitoIdentityProviderClient 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.

# CognitoIdentityProviderClient usage example with type annotations

from boto3.session import Session

from types_boto3_cognito_idp.client import CognitoIdentityProviderClient
from types_boto3_cognito_idp.type_defs import EmptyResponseMetadataTypeDef
from types_boto3_cognito_idp.type_defs import AdminAddUserToGroupRequestRequestTypeDef


session = Session()

client: CognitoIdentityProviderClient = session.client("cognito-idp")

kwargs: AdminAddUserToGroupRequestRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.admin_add_user_to_group(**kwargs)
# AdminListGroupsForUserPaginator usage example with type annotations

from boto3.session import Session

from types_boto3_cognito_idp.client import CognitoIdentityProviderClient
from types_boto3_cognito_idp.paginator import AdminListGroupsForUserPaginator
from types_boto3_cognito_idp.type_defs import AdminListGroupsForUserResponseTypeDef


session = Session()
client: CognitoIdentityProviderClient = session.client("cognito-idp")

paginator: AdminListGroupsForUserPaginator = client.get_paginator("admin_list_groups_for_user")
for item in paginator.paginate(...):
    item: AdminListGroupsForUserResponseTypeDef
    print(item)