Examples
Index > CognitoIdentity > Examples
Auto-generated documentation for CognitoIdentity type annotations stubs module types-aiobotocore-cognito-identity.
Client
Implicit type annotations
Can be used with types-aioboto3[cognito-identity]
package installed.
Write your CognitoIdentity
code as usual,
type checking and code completion should work out of the box.
Client usage example
from aioboto3.session import Session
session = Session()
async with session.client("cognito-identity") as client: # (1)
result = await client.create_identity_pool() # (2)
- client: CognitoIdentityClient
- result: IdentityPoolTypeDef
Paginator usage example
from aioboto3.session import Session
session = Session()
async with session.client("cognito-identity") as client: # (1)
paginator = client.get_paginator("list_identity_pools") # (2)
async for item in paginator.paginate(...):
print(item) # (3)
- client: CognitoIdentityClient
- paginator: ListIdentityPoolsPaginator
- item: ListIdentityPoolsResponseTypeDef
Explicit type annotations
With types-aioboto3-lite[cognito-identity]
or a standalone types_aiobotocore_cognito_identity
package, you have to explicitly specify
client: CognitoIdentityClient
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 usage example
from aioboto3.session import Session
from types_aiobotocore_cognito_identity.client import CognitoIdentityClient
from types_aiobotocore_cognito_identity.type_defs import IdentityPoolTypeDef
from types_aiobotocore_cognito_identity.type_defs import CreateIdentityPoolInputRequestTypeDef
session = Session()
client: CognitoIdentityClient
async with session.client("cognito-identity") as client: # (1)
kwargs: CreateIdentityPoolInputRequestTypeDef = {...} # (2)
result: IdentityPoolTypeDef = await client.create_identity_pool(**kwargs) # (3)
- client: CognitoIdentityClient
- kwargs: CreateIdentityPoolInputRequestTypeDef
- result: IdentityPoolTypeDef
Paginator usage example
from aioboto3.session import Session
from types_aiobotocore_cognito_identity.client import CognitoIdentityClient
from types_aiobotocore_cognito_identity.paginator import ListIdentityPoolsPaginator
from types_aiobotocore_cognito_identity.type_defs import ListIdentityPoolsResponseTypeDef
session = Session()
client: CognitoIdentityClient
async with session.client("cognito-identity") as client: # (1)
paginator: ListIdentityPoolsPaginator = client.get_paginator("list_identity_pools") # (2)
async for item in paginator.paginate(...):
item: ListIdentityPoolsResponseTypeDef
print(item) # (3)
- client: CognitoIdentityClient
- paginator: ListIdentityPoolsPaginator
- item: ListIdentityPoolsResponseTypeDef