Examples
Index > CloudFront > Examples
Auto-generated documentation for CloudFront type annotations stubs module mypy-boto3-cloudfront.
Client
Implicit type annotations
Can be used with boto3-stubs[cloudfront]
package installed.
Write your CloudFront
code as usual,
type checking and code completion should work out of the box.
Client usage example
from boto3.session import Session
session = Session()
client = session.client("cloudfront") # (1)
result = client.associate_alias() # (2)
- client: CloudFrontClient
- result: EmptyResponseMetadataTypeDef
Waiter usage example
from boto3.session import Session
session = Session()
client = session.client("cloudfront") # (1)
waiter = client.get_waiter("distribution_deployed") # (2)
waiter.wait()
- client: CloudFrontClient
- waiter: DistributionDeployedWaiter
Explicit type annotations
With boto3-stubs-lite[cloudfront]
or a standalone mypy_boto3_cloudfront
package, you have to explicitly specify client: CloudFrontClient
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 boto3.session import Session
from mypy_boto3_cloudfront.client import CloudFrontClient
from mypy_boto3_cloudfront.type_defs import EmptyResponseMetadataTypeDef
from mypy_boto3_cloudfront.type_defs import AssociateAliasRequestRequestTypeDef
session = Session()
client: CloudFrontClient = session.client("cloudfront")
kwargs: AssociateAliasRequestRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.associate_alias(**kwargs)
Paginator usage example
from boto3.session import Session
from mypy_boto3_cloudfront.client import CloudFrontClient
from mypy_boto3_cloudfront.paginator import ListCloudFrontOriginAccessIdentitiesPaginator
from mypy_boto3_cloudfront.type_defs import ListCloudFrontOriginAccessIdentitiesResultTypeDef
session = Session()
client: CloudFrontClient = session.client("cloudfront")
paginator: ListCloudFrontOriginAccessIdentitiesPaginator = client.get_paginator("list_cloud_front_origin_access_identities")
for item in paginator.paginate(...):
item: ListCloudFrontOriginAccessIdentitiesResultTypeDef
print(item)
Waiter usage example
from boto3.session import Session
from mypy_boto3_cloudfront.client import CloudFrontClient
from mypy_boto3_cloudfront.waiter import DistributionDeployedWaiter
session = Session()
client: CloudFrontClient = session.client("cloudfront")
waiter: DistributionDeployedWaiter = client.get_waiter("distribution_deployed")
waiter.wait()