Skip to content

Examples#

Index > PrometheusService > Examples

Auto-generated documentation for PrometheusService type annotations stubs module mypy-boto3-amp.

Client#

Implicit type annotations#

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

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

# PrometheusServiceClient usage example

from boto3.session import Session


session = Session()

client = session.client("amp")  # (1)
result = client.create_alert_manager_definition()  # (2)
  1. client: PrometheusServiceClient
  2. result: CreateAlertManagerDefinitionResponseTypeDef
# ListRuleGroupsNamespacesPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("list_rule_groups_namespaces")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: PrometheusServiceClient
  2. paginator: ListRuleGroupsNamespacesPaginator
  3. item: ListRuleGroupsNamespacesResponseTypeDef
# ScraperActiveWaiter usage example

from boto3.session import Session


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

waiter = client.get_waiter("scraper_active")  # (2)
waiter.wait()
  1. client: PrometheusServiceClient
  2. waiter: ScraperActiveWaiter

Explicit type annotations#

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

# PrometheusServiceClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_amp.client import PrometheusServiceClient
from mypy_boto3_amp.type_defs import CreateAlertManagerDefinitionResponseTypeDef
from mypy_boto3_amp.type_defs import CreateAlertManagerDefinitionRequestRequestTypeDef


session = Session()

client: PrometheusServiceClient = session.client("amp")

kwargs: CreateAlertManagerDefinitionRequestRequestTypeDef = {...}
result: CreateAlertManagerDefinitionResponseTypeDef = client.create_alert_manager_definition(**kwargs)
# ListRuleGroupsNamespacesPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_amp.client import PrometheusServiceClient
from mypy_boto3_amp.paginator import ListRuleGroupsNamespacesPaginator
from mypy_boto3_amp.type_defs import ListRuleGroupsNamespacesResponseTypeDef


session = Session()
client: PrometheusServiceClient = session.client("amp")

paginator: ListRuleGroupsNamespacesPaginator = client.get_paginator("list_rule_groups_namespaces")
for item in paginator.paginate(...):
    item: ListRuleGroupsNamespacesResponseTypeDef
    print(item)
# ScraperActiveWaiter usage example with type annotations

from boto3.session import Session

from mypy_boto3_amp.client import PrometheusServiceClient
from mypy_boto3_amp.waiter import ScraperActiveWaiter

session = Session()
client: PrometheusServiceClient = session.client("amp")

waiter: ScraperActiveWaiter = client.get_waiter("scraper_active")
waiter.wait()