Skip to content

Examples#

Index > AgentsforBedrock > Examples

Auto-generated documentation for AgentsforBedrock type annotations stubs module mypy-boto3-bedrock-agent.

Client#

Implicit type annotations#

Can be used with boto3-stubs[bedrock-agent] package installed.

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

# AgentsforBedrockClient usage example

from boto3.session import Session


session = Session()

client = session.client("bedrock-agent")  # (1)
result = client.associate_agent_knowledge_base()  # (2)
  1. client: AgentsforBedrockClient
  2. result: AssociateAgentKnowledgeBaseResponseTypeDef
# ListAgentActionGroupsPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("bedrock-agent")  # (1)

paginator = client.get_paginator("list_agent_action_groups")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: AgentsforBedrockClient
  2. paginator: ListAgentActionGroupsPaginator
  3. item: ListAgentActionGroupsResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[bedrock-agent] or a standalone mypy_boto3_bedrock_agent package, you have to explicitly specify client: AgentsforBedrockClient 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.

# AgentsforBedrockClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_bedrock_agent.client import AgentsforBedrockClient
from mypy_boto3_bedrock_agent.type_defs import AssociateAgentKnowledgeBaseResponseTypeDef
from mypy_boto3_bedrock_agent.type_defs import AssociateAgentKnowledgeBaseRequestRequestTypeDef


session = Session()

client: AgentsforBedrockClient = session.client("bedrock-agent")

kwargs: AssociateAgentKnowledgeBaseRequestRequestTypeDef = {...}
result: AssociateAgentKnowledgeBaseResponseTypeDef = client.associate_agent_knowledge_base(**kwargs)
# ListAgentActionGroupsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_bedrock_agent.client import AgentsforBedrockClient
from mypy_boto3_bedrock_agent.paginator import ListAgentActionGroupsPaginator
from mypy_boto3_bedrock_agent.type_defs import ListAgentActionGroupsResponseTypeDef


session = Session()
client: AgentsforBedrockClient = session.client("bedrock-agent")

paginator: ListAgentActionGroupsPaginator = client.get_paginator("list_agent_action_groups")
for item in paginator.paginate(...):
    item: ListAgentActionGroupsResponseTypeDef
    print(item)