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.
Client method usage example#
# PrometheusServiceClient usage example
from boto3.session import Session
session = Session()
client = session.client("amp") # (1)
result = client.create_alert_manager_definition() # (2)
- client: PrometheusServiceClient
- result: CreateAlertManagerDefinitionResponseTypeDef
Paginator usage example#
# 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)
- client: PrometheusServiceClient
- paginator: ListRuleGroupsNamespacesPaginator
- item: ListRuleGroupsNamespacesResponseTypeDef
Waiter usage example#
# ScraperActiveWaiter usage example
from boto3.session import Session
session = Session()
client = session.client("amp") # (1)
waiter = client.get_waiter("scraper_active") # (2)
waiter.wait(...)
- client: PrometheusServiceClient
- 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.
Client method usage example#
# 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 CreateAlertManagerDefinitionRequestTypeDef
session = Session()
client: PrometheusServiceClient = session.client("amp")
kwargs: CreateAlertManagerDefinitionRequestTypeDef = {...}
result: CreateAlertManagerDefinitionResponseTypeDef = client.create_alert_manager_definition(**kwargs)
Paginator usage example#
# 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)
Waiter usage example#
# 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(...)