public static NotificationConfig CreateNotificationConfig( string organizationId, string notificationConfigId, string projectId, string topicName) { OrganizationName orgName = new OrganizationName(organizationId); TopicName pubsubTopic = new TopicName(projectId, topicName); SecurityCenterClient client = SecurityCenterClient.Create(); CreateNotificationConfigRequest request = new CreateNotificationConfigRequest { ParentAsOrganizationName = orgName, ConfigId = notificationConfigId, NotificationConfig = new NotificationConfig { Description = ".Net notification config", PubsubTopicAsTopicName = pubsubTopic, StreamingConfig = new NotificationConfig.Types.StreamingConfig { Filter = "state = \"ACTIVE\"" } } }; NotificationConfig response = client.CreateNotificationConfig(request); Console.WriteLine($"Notification config was created: {response}"); return(response); }
public static NotificationConfig UpdateNotificationConfig( string organizationId, string notificationConfigId, string projectId, string topicName) { NotificationConfigName notificationConfigName = new NotificationConfigName(organizationId, notificationConfigId); TopicName pubsubTopic = new TopicName(projectId, topicName); NotificationConfig configToUpdate = new NotificationConfig { NotificationConfigName = notificationConfigName, Description = "updated description", PubsubTopicAsTopicName = pubsubTopic, StreamingConfig = new StreamingConfig { Filter = "state = \"INACTIVE\"" } }; FieldMask fieldMask = new FieldMask { Paths = { "description", "pubsub_topic", "streaming_config.filter" } }; SecurityCenterClient client = SecurityCenterClient.Create(); NotificationConfig updatedConfig = client.UpdateNotificationConfig(configToUpdate, fieldMask); Console.WriteLine($"Notification config updated: {updatedConfig}"); return(updatedConfig); }
public static bool DeleteNotificationConfig(string organizationId, string notificationConfigId) { NotificationConfigName notificationConfigName = new NotificationConfigName(organizationId, notificationConfigId); SecurityCenterClient client = SecurityCenterClient.Create(); client.DeleteNotificationConfig(notificationConfigName); Console.WriteLine($"Deleted Notification config: {notificationConfigName}"); return(true); }
public static NotificationConfig GetNotificationConfig(string organizationId, string configId) { SecurityCenterClient client = SecurityCenterClient.Create(); NotificationConfigName notificationConfigName = new NotificationConfigName(organizationId, configId); NotificationConfig response = client.GetNotificationConfig(notificationConfigName); Console.WriteLine($"Notification config: {response}"); return(response); }
public static PagedEnumerable <ListNotificationConfigsResponse, NotificationConfig> ListNotificationConfigs(string organizationId) { OrganizationName orgName = new OrganizationName(organizationId); SecurityCenterClient client = SecurityCenterClient.Create(); PagedEnumerable <ListNotificationConfigsResponse, NotificationConfig> notificationConfigs = client.ListNotificationConfigs(orgName); // Print Notification Configuration names. foreach (var config in notificationConfigs) { Console.WriteLine(config.NotificationConfigName); } return(notificationConfigs); }
protected void SetupManagementClients(MockContext context) { SecurityCenterClient = GetSecurityCenterClient(context); _helper.SetupManagementClients(SecurityCenterClient); }