Skip to content
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
10 changes: 9 additions & 1 deletion monitoring/v3/src/main/java/AlertSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ private List<AlertPolicy> getAlertPolicies(String projectId) {
return alertPolicies;
}

// [START monitoring_alert_list_channels]
private List<NotificationChannel> getNotificationChannels(String projectId) {
List<NotificationChannel> notificationChannels = Lists.newArrayList();
ListNotificationChannelsPagedResponse listNotificationChannelsResponse =
Expand All @@ -258,6 +259,7 @@ private List<NotificationChannel> getNotificationChannels(String projectId) {
}
return notificationChannels;
}
// [END monitoring_alert_list_channels]

private void writePoliciesBackupFile(String projectId,
String filePath,
Expand Down Expand Up @@ -334,6 +336,7 @@ private List<AlertPolicy> reviseRestoredPolicies(AlertPolicy[] policies,
return newPolicies;
}

// [START monitoring_alert_create_policy]
private void restoreRevisedPolicies(String projectId,
boolean isSameProject,
List<AlertPolicy> policies) {
Expand All @@ -351,6 +354,7 @@ private void restoreRevisedPolicies(String projectId,
outputStream.println(String.format("Restored %s", policy.getName()));
}
}
// [END monitoring_alert_create_policy]

private List<NotificationChannel> readNotificationChannelsJson(JsonObject backupContent) {
if (backupContent.has("notification_channels")) {
Expand All @@ -361,6 +365,8 @@ private List<NotificationChannel> readNotificationChannelsJson(JsonObject backup
return Lists.newArrayList();
}

// [START monitoring_alert_create_channel]
// [START monitoring_alert_update_channel]
private Map<String, String> restoreNotificationChannels(String projectId,
List<NotificationChannel> channels,
boolean isSameProject) {
Expand Down Expand Up @@ -392,7 +398,9 @@ private Map<String, String> 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);
Expand Down