Skip to content

Examples#

Index > ElasticsearchService > Examples

Auto-generated documentation for ElasticsearchService type annotations stubs module mypy-boto3-es.

Client#

Implicit type annotations#

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

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

Client method usage example#

# ElasticsearchServiceClient usage example

from boto3.session import Session


session = Session()

client = session.client("es")  # (1)
result = client.accept_inbound_cross_cluster_search_connection()  # (2)
  1. client: ElasticsearchServiceClient
  2. result: AcceptInboundCrossClusterSearchConnectionResponseTypeDef

Paginator usage example#

# DescribeReservedElasticsearchInstanceOfferingsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("describe_reserved_elasticsearch_instance_offerings")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: ElasticsearchServiceClient
  2. paginator: DescribeReservedElasticsearchInstanceOfferingsPaginator
  3. item: DescribeReservedElasticsearchInstanceOfferingsResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[es] or a standalone mypy_boto3_es package, you have to explicitly specify client: ElasticsearchServiceClient 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#

# ElasticsearchServiceClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_es.client import ElasticsearchServiceClient
from mypy_boto3_es.type_defs import AcceptInboundCrossClusterSearchConnectionResponseTypeDef
from mypy_boto3_es.type_defs import AcceptInboundCrossClusterSearchConnectionRequestTypeDef


session = Session()

client: ElasticsearchServiceClient = session.client("es")

kwargs: AcceptInboundCrossClusterSearchConnectionRequestTypeDef = {...}
result: AcceptInboundCrossClusterSearchConnectionResponseTypeDef = client.accept_inbound_cross_cluster_search_connection(**kwargs)

Paginator usage example#

# DescribeReservedElasticsearchInstanceOfferingsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_es.client import ElasticsearchServiceClient
from mypy_boto3_es.paginator import DescribeReservedElasticsearchInstanceOfferingsPaginator
from mypy_boto3_es.type_defs import DescribeReservedElasticsearchInstanceOfferingsResponseTypeDef


session = Session()
client: ElasticsearchServiceClient = session.client("es")

paginator: DescribeReservedElasticsearchInstanceOfferingsPaginator = client.get_paginator("describe_reserved_elasticsearch_instance_offerings")
for item in paginator.paginate(...):
    item: DescribeReservedElasticsearchInstanceOfferingsResponseTypeDef
    print(item)