Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more doc tags to alerts sample. #1483

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions monitoring/api/v3/alerts-client/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
import tabulate


# [START monitoring_alert_list_policies]
def list_alert_policies(project_name):
client = monitoring_v3.AlertPolicyServiceClient()
policies = client.list_alert_policies(project_name)
print(tabulate.tabulate(
[(policy.name, policy.display_name) for policy in policies],
('name', 'display_name')))
# [END monitoring_alert_list_policies]


# [START monitoring_alert_list_channels]
Expand Down Expand Up @@ -113,6 +115,9 @@ def default(self, obj):


# [START monitoring_alert_restore_policies]
# [START monitoring_alert_create_policy]
# [START monitoring_alert_create_channel]
# [START monitoring_alert_update_channel]
def restore(project_name):
print('Loading alert policies and notification channels from backup.json.')
record = json.load(open('backup.json', 'rt'))
Expand Down Expand Up @@ -193,6 +198,9 @@ def restore(project_name):
policy = alert_client.create_alert_policy(project_name, policy)
print('Updated', policy.name)
# [END monitoring_alert_restore_policies]
# [END monitoring_alert_create_policy]
# [END monitoring_alert_create_channel]
# [END monitoring_alert_update_channel]


class MissingProjectIdError(Exception):
Expand Down