Skip to content

Commit dd06e57

Browse files
authored
docs: Update Security Command Center UpdateNotificationConfig sample, adding filter to mutable field. (#2879)
* Update sample for UpdateNotificationConfig filter update flag * fix syntax error * docs: Update sample for UpdateNotificationConfig filter update flag
1 parent f1fc918 commit dd06e57

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

securitycenter/src/main/java/com/google/cloud/examples/securitycenter/snippets/UpdateNotificationConfigSnippets.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
// [START scc_update_notification_config]
2020
import com.google.cloud.securitycenter.v1.NotificationConfig;
21+
import com.google.cloud.securitycenter.v1.NotificationConfig.StreamingConfig;
2122
import com.google.cloud.securitycenter.v1.SecurityCenterClient;
2223
import com.google.protobuf.FieldMask;
2324
import java.io.IOException;
@@ -48,9 +49,13 @@ public static NotificationConfig updateNotificationConfig(
4849
.setName(notificationConfigName)
4950
.setDescription("updated description")
5051
.setPubsubTopic(pubsubTopic)
52+
.setStreamingConfig(StreamingConfig.newBuilder().setFilter("state = \"ACTIVE\""))
5153
.build();
5254
FieldMask fieldMask =
53-
FieldMask.newBuilder().addPaths("description").addPaths("pubsub_topic").build();
55+
FieldMask.newBuilder()
56+
.addPaths("description")
57+
.addPaths("pubsub_topic")
58+
.addPaths("streaming_config.filter").build();
5459

5560
try (SecurityCenterClient client = SecurityCenterClient.create()) {
5661
NotificationConfig updatedConfig = client.updateNotificationConfig(configToUpdate, fieldMask);
@@ -60,4 +65,4 @@ public static NotificationConfig updateNotificationConfig(
6065
}
6166
}
6267
// [END scc_update_notification_config]
63-
}
68+
}

0 commit comments

Comments
 (0)