Skip to content

Examples#

Index > PrometheusService > Examples

Auto-generated documentation for PrometheusService type annotations stubs module types-aiobotocore-amp.

Client#

Implicit type annotations#

Can be used with types-aiobotocore[amp] package installed.

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

Client method usage example#

# PrometheusServiceClient usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("amp") as client:  # (1)
    result = await client.create_alert_manager_definition()  # (2)
  1. client: PrometheusServiceClient
  2. result: CreateAlertManagerDefinitionResponseTypeDef

Paginator usage example#

# ListRuleGroupsNamespacesPaginator usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("amp") as client:  # (1)
    paginator = client.get_paginator("list_rule_groups_namespaces")  # (2)
    async for item in paginator.paginate(...):
        print(item)  # (3)
  1. client: PrometheusServiceClient
  2. paginator: ListRuleGroupsNamespacesPaginator
  3. item: ListRuleGroupsNamespacesResponseTypeDef

Waiter usage example#

# ScraperActiveWaiter usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("amp") as client:  # (1)
    waiter = client.get_waiter("scraper_active")  # (2)
    await waiter.wait(...)
  1. client: PrometheusServiceClient
  2. waiter: ScraperActiveWaiter

Explicit type annotations#

With types-aiobotocore-lite[amp] or a standalone types_aiobotocore_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.

Client method usage example#

# PrometheusServiceClient usage example with type annotations

from aiobotocore.session import get_session

from types_aiobotocore_amp.client import PrometheusServiceClient
from types_aiobotocore_amp.type_defs import CreateAlertManagerDefinitionResponseTypeDef
from types_aiobotocore_amp.type_defs import CreateAlertManagerDefinitionRequestTypeDef


session = get_session()

async with session.create_client("amp") as client:
    client: PrometheusServiceClient
    kwargs: CreateAlertManagerDefinitionRequestTypeDef = {...}
    result: CreateAlertManagerDefinitionResponseTypeDef = await client.create_alert_manager_definition(**kwargs)

Paginator usage example#

# ListRuleGroupsNamespacesPaginator usage example with type annotations

from aiobotocore.session import get_session

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


session = get_session()

async with session.create_client("amp") as client:
    client: PrometheusServiceClient
    paginator: ListRuleGroupsNamespacesPaginator = client.get_paginator("list_rule_groups_namespaces")
    async for item in paginator.paginate(...):
        item: ListRuleGroupsNamespacesResponseTypeDef
        print(item)

Waiter usage example#

# ScraperActiveWaiter usage example with type annotations

from aiobotocore.session import get_session

from types_aiobotocore_amp.client import PrometheusServiceClient
from types_aiobotocore_amp.waiter import ScraperActiveWaiter


session = get_session()

async with session.create_client("amp") as client:
    client: PrometheusServiceClient
    waiter: ScraperActiveWaiter = client.get_waiter("scraper_active")
    await waiter.wait(...)