Skip to content

Examples#

Index > CloudFront > Examples

Auto-generated documentation for CloudFront type annotations stubs module types-boto3-cloudfront.

Client#

Implicit type annotations#

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

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

# CloudFrontClient usage example

from boto3.session import Session


session = Session()

client = session.client("cloudfront")  # (1)
result = client.associate_alias()  # (2)
  1. client: CloudFrontClient
  2. result: EmptyResponseMetadataTypeDef
# ListCloudFrontOriginAccessIdentitiesPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("list_cloud_front_origin_access_identities")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: CloudFrontClient
  2. paginator: ListCloudFrontOriginAccessIdentitiesPaginator
  3. item: ListCloudFrontOriginAccessIdentitiesResultTypeDef
# DistributionDeployedWaiter usage example

from boto3.session import Session


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

waiter = client.get_waiter("distribution_deployed")  # (2)
waiter.wait()
  1. client: CloudFrontClient
  2. waiter: DistributionDeployedWaiter

Explicit type annotations#

With types-boto3-lite[cloudfront] or a standalone types_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.

# CloudFrontClient usage example with type annotations

from boto3.session import Session

from types_boto3_cloudfront.client import CloudFrontClient
from types_boto3_cloudfront.type_defs import EmptyResponseMetadataTypeDef
from types_boto3_cloudfront.type_defs import AssociateAliasRequestRequestTypeDef


session = Session()

client: CloudFrontClient = session.client("cloudfront")

kwargs: AssociateAliasRequestRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.associate_alias(**kwargs)
# ListCloudFrontOriginAccessIdentitiesPaginator usage example with type annotations

from boto3.session import Session

from types_boto3_cloudfront.client import CloudFrontClient
from types_boto3_cloudfront.paginator import ListCloudFrontOriginAccessIdentitiesPaginator
from types_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)
# DistributionDeployedWaiter usage example with type annotations

from boto3.session import Session

from types_boto3_cloudfront.client import CloudFrontClient
from types_boto3_cloudfront.waiter import DistributionDeployedWaiter

session = Session()
client: CloudFrontClient = session.client("cloudfront")

waiter: DistributionDeployedWaiter = client.get_waiter("distribution_deployed")
waiter.wait()