Skip to content

Examples#

Index > DirectConnect > Examples

Auto-generated documentation for DirectConnect type annotations stubs module types-boto3-directconnect.

Client#

Implicit type annotations#

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

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

# DirectConnectClient usage example

from boto3.session import Session


session = Session()

client = session.client("directconnect")  # (1)
result = client.accept_direct_connect_gateway_association_proposal()  # (2)
  1. client: DirectConnectClient
  2. result: AcceptDirectConnectGatewayAssociationProposalResultTypeDef
# DescribeDirectConnectGatewayAssociationsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("describe_direct_connect_gateway_associations")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: DirectConnectClient
  2. paginator: DescribeDirectConnectGatewayAssociationsPaginator
  3. item: DescribeDirectConnectGatewayAssociationsResultTypeDef

Explicit type annotations#

With types-boto3-lite[directconnect] or a standalone types_boto3_directconnect package, you have to explicitly specify client: DirectConnectClient 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.

# DirectConnectClient usage example with type annotations

from boto3.session import Session

from types_boto3_directconnect.client import DirectConnectClient
from types_boto3_directconnect.type_defs import AcceptDirectConnectGatewayAssociationProposalResultTypeDef
from types_boto3_directconnect.type_defs import AcceptDirectConnectGatewayAssociationProposalRequestRequestTypeDef


session = Session()

client: DirectConnectClient = session.client("directconnect")

kwargs: AcceptDirectConnectGatewayAssociationProposalRequestRequestTypeDef = {...}
result: AcceptDirectConnectGatewayAssociationProposalResultTypeDef = client.accept_direct_connect_gateway_association_proposal(**kwargs)
# DescribeDirectConnectGatewayAssociationsPaginator usage example with type annotations

from boto3.session import Session

from types_boto3_directconnect.client import DirectConnectClient
from types_boto3_directconnect.paginator import DescribeDirectConnectGatewayAssociationsPaginator
from types_boto3_directconnect.type_defs import DescribeDirectConnectGatewayAssociationsResultTypeDef


session = Session()
client: DirectConnectClient = session.client("directconnect")

paginator: DescribeDirectConnectGatewayAssociationsPaginator = client.get_paginator("describe_direct_connect_gateway_associations")
for item in paginator.paginate(...):
    item: DescribeDirectConnectGatewayAssociationsResultTypeDef
    print(item)