Skip to content

Examples#

Index > OpenSearchService > Examples

Auto-generated documentation for OpenSearchService type annotations stubs module mypy-boto3-opensearch.

Client#

Implicit type annotations#

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

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

# OpenSearchServiceClient usage example

from boto3.session import Session


session = Session()

client = session.client("opensearch")  # (1)
result = client.accept_inbound_connection()  # (2)
  1. client: OpenSearchServiceClient
  2. result: AcceptInboundConnectionResponseTypeDef
# ListApplicationsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("list_applications")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: OpenSearchServiceClient
  2. paginator: ListApplicationsPaginator
  3. item: ListApplicationsResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[opensearch] or a standalone mypy_boto3_opensearch package, you have to explicitly specify client: OpenSearchServiceClient 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.

# OpenSearchServiceClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_opensearch.client import OpenSearchServiceClient
from mypy_boto3_opensearch.type_defs import AcceptInboundConnectionResponseTypeDef
from mypy_boto3_opensearch.type_defs import AcceptInboundConnectionRequestRequestTypeDef


session = Session()

client: OpenSearchServiceClient = session.client("opensearch")

kwargs: AcceptInboundConnectionRequestRequestTypeDef = {...}
result: AcceptInboundConnectionResponseTypeDef = client.accept_inbound_connection(**kwargs)
# ListApplicationsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_opensearch.client import OpenSearchServiceClient
from mypy_boto3_opensearch.paginator import ListApplicationsPaginator
from mypy_boto3_opensearch.type_defs import ListApplicationsResponseTypeDef


session = Session()
client: OpenSearchServiceClient = session.client("opensearch")

paginator: ListApplicationsPaginator = client.get_paginator("list_applications")
for item in paginator.paginate(...):
    item: ListApplicationsResponseTypeDef
    print(item)