Skip to content

Examples#

Index > NetworkFirewall > Examples

Auto-generated documentation for NetworkFirewall type annotations stubs module mypy-boto3-network-firewall.

Client#

Implicit type annotations#

Can be used with boto3-stubs[network-firewall] package installed.

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

Client method usage example#

# NetworkFirewallClient usage example

from boto3.session import Session


session = Session()

client = session.client("network-firewall")  # (1)
result = client.associate_firewall_policy()  # (2)
  1. client: NetworkFirewallClient
  2. result: AssociateFirewallPolicyResponseTypeDef

Paginator usage example#

# GetAnalysisReportResultsPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("network-firewall")  # (1)

paginator = client.get_paginator("get_analysis_report_results")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: NetworkFirewallClient
  2. paginator: GetAnalysisReportResultsPaginator
  3. item: GetAnalysisReportResultsResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[network-firewall] or a standalone mypy_boto3_network_firewall package, you have to explicitly specify client: NetworkFirewallClient 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 method usage example#

# NetworkFirewallClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_network_firewall.client import NetworkFirewallClient
from mypy_boto3_network_firewall.type_defs import AssociateFirewallPolicyResponseTypeDef
from mypy_boto3_network_firewall.type_defs import AssociateFirewallPolicyRequestTypeDef


session = Session()

client: NetworkFirewallClient = session.client("network-firewall")

kwargs: AssociateFirewallPolicyRequestTypeDef = {...}
result: AssociateFirewallPolicyResponseTypeDef = client.associate_firewall_policy(**kwargs)

Paginator usage example#

# GetAnalysisReportResultsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_network_firewall.client import NetworkFirewallClient
from mypy_boto3_network_firewall.paginator import GetAnalysisReportResultsPaginator
from mypy_boto3_network_firewall.type_defs import GetAnalysisReportResultsResponseTypeDef


session = Session()
client: NetworkFirewallClient = session.client("network-firewall")

paginator: GetAnalysisReportResultsPaginator = client.get_paginator("get_analysis_report_results")
for item in paginator.paginate(...):
    item: GetAnalysisReportResultsResponseTypeDef
    print(item)