コード例 #1
0
    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);
    }
コード例 #4
0
    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);
    }
コード例 #5
0
    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);
    }
コード例 #6
0
 protected void SetupManagementClients(MockContext context)
 {
     SecurityCenterClient = GetSecurityCenterClient(context);
     _helper.SetupManagementClients(SecurityCenterClient);
 }