From fb306e63cd9925887de2c1311769b45650e58b89 Mon Sep 17 00:00:00 2001 From: mtabasko <34554386+mtabasko@users.noreply.github.com> Date: Sun, 8 Apr 2018 21:08:07 -0400 Subject: [PATCH] Adds region tags to Java alerting sample Adds region tags to AlertSample.java, for extraction of doc samples without resorting to regexps. --- monitoring/v3/src/main/java/AlertSample.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/monitoring/v3/src/main/java/AlertSample.java b/monitoring/v3/src/main/java/AlertSample.java index 9a9323d2d38..d5bacbe98e7 100644 --- a/monitoring/v3/src/main/java/AlertSample.java +++ b/monitoring/v3/src/main/java/AlertSample.java @@ -249,6 +249,7 @@ private List getAlertPolicies(String projectId) { return alertPolicies; } + // [START monitoring_alert_list_channels] private List getNotificationChannels(String projectId) { List notificationChannels = Lists.newArrayList(); ListNotificationChannelsPagedResponse listNotificationChannelsResponse = @@ -258,6 +259,7 @@ private List getNotificationChannels(String projectId) { } return notificationChannels; } + // [END monitoring_alert_list_channels] private void writePoliciesBackupFile(String projectId, String filePath, @@ -334,6 +336,7 @@ private List reviseRestoredPolicies(AlertPolicy[] policies, return newPolicies; } + // [START monitoring_alert_create_policy] private void restoreRevisedPolicies(String projectId, boolean isSameProject, List policies) { @@ -351,6 +354,7 @@ private void restoreRevisedPolicies(String projectId, outputStream.println(String.format("Restored %s", policy.getName())); } } + // [END monitoring_alert_create_policy] private List readNotificationChannelsJson(JsonObject backupContent) { if (backupContent.has("notification_channels")) { @@ -361,6 +365,8 @@ private List readNotificationChannelsJson(JsonObject backup return Lists.newArrayList(); } + // [START monitoring_alert_create_channel] + // [START monitoring_alert_update_channel] private Map restoreNotificationChannels(String projectId, List channels, boolean isSameProject) { @@ -392,7 +398,9 @@ private Map restoreNotificationChannels(String projectId, } return newChannelNames; } - + // [END monitoring_alert_create_channel] + // [END monitoring_alert_update_channel] + private JsonObject getPolicyJsonContents(String filePath, BufferedReader content, Gson gson) { try { return gson.fromJson(content, JsonObject.class);