@@ -249,6 +249,7 @@ private List<AlertPolicy> getAlertPolicies(String projectId) {
249
249
return alertPolicies ;
250
250
}
251
251
252
+ // [START monitoring_alert_list_channels]
252
253
private List <NotificationChannel > getNotificationChannels (String projectId ) {
253
254
List <NotificationChannel > notificationChannels = Lists .newArrayList ();
254
255
ListNotificationChannelsPagedResponse listNotificationChannelsResponse =
@@ -258,6 +259,7 @@ private List<NotificationChannel> getNotificationChannels(String projectId) {
258
259
}
259
260
return notificationChannels ;
260
261
}
262
+ // [END monitoring_alert_list_channels]
261
263
262
264
private void writePoliciesBackupFile (String projectId ,
263
265
String filePath ,
@@ -334,6 +336,7 @@ private List<AlertPolicy> reviseRestoredPolicies(AlertPolicy[] policies,
334
336
return newPolicies ;
335
337
}
336
338
339
+ // [START monitoring_alert_create_policy]
337
340
private void restoreRevisedPolicies (String projectId ,
338
341
boolean isSameProject ,
339
342
List <AlertPolicy > policies ) {
@@ -351,6 +354,7 @@ private void restoreRevisedPolicies(String projectId,
351
354
outputStream .println (String .format ("Restored %s" , policy .getName ()));
352
355
}
353
356
}
357
+ // [END monitoring_alert_create_policy]
354
358
355
359
private List <NotificationChannel > readNotificationChannelsJson (JsonObject backupContent ) {
356
360
if (backupContent .has ("notification_channels" )) {
@@ -361,6 +365,8 @@ private List<NotificationChannel> readNotificationChannelsJson(JsonObject backup
361
365
return Lists .newArrayList ();
362
366
}
363
367
368
+ // [START monitoring_alert_create_channel]
369
+ // [START monitoring_alert_update_channel]
364
370
private Map <String , String > restoreNotificationChannels (String projectId ,
365
371
List <NotificationChannel > channels ,
366
372
boolean isSameProject ) {
@@ -392,7 +398,9 @@ private Map<String, String> restoreNotificationChannels(String projectId,
392
398
}
393
399
return newChannelNames ;
394
400
}
395
-
401
+ // [END monitoring_alert_create_channel]
402
+ // [END monitoring_alert_update_channel]
403
+
396
404
private JsonObject getPolicyJsonContents (String filePath , BufferedReader content , Gson gson ) {
397
405
try {
398
406
return gson .fromJson (content , JsonObject .class );
0 commit comments