Delete a NotificationConfig

Stay organized with collections Save and categorize content based on your preferences.

Demonstrates how to delete a NotificationConfig

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample


using Google.Cloud.SecurityCenter.V1;
using System;

/// <summary>Snippet for DeleteNotificationConfig</summary>
public class DeleteNotificationConfigSnippets
    public static bool DeleteNotificationConfig(string organizationId, string notificationConfigId)
        NotificationConfigName notificationConfigName = new NotificationConfigName(organizationId, notificationConfigId);
        SecurityCenterClient client = SecurityCenterClient.Create();

        Console.WriteLine($"Deleted Notification config: {notificationConfigName}");
        return true;


import (

	securitycenter ""

func deleteNotificationConfig(w io.Writer, orgID string, notificationConfigID string) error {
	// orgID := "your-org-id"
	// notificationConfigID := "config-to-delete"

	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)

	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %v", err)
	defer client.Close()

	name := fmt.Sprintf("organizations/%s/notificationConfigs/%s", orgID, notificationConfigID)
	req := &securitycenterpb.DeleteNotificationConfigRequest{
		Name: name,

	if err = client.DeleteNotificationConfig(ctx, req); err != nil {
		return fmt.Errorf("Failed to retrieve notification config: %v", err)
	fmt.Fprintln(w, "Deleted config: ", name)

	return nil



public class DeleteNotificationConfigSnippets {

  public static void main(String[] args) throws IOException {
    // parentId: must be in one of the following formats:
    //    "organizations/{organization_id}"
    //    "projects/{project_id}"
    //    "folders/{folder_id}"
    String parentId = String.format("organizations/%s", "ORG_ID");

    String notificationConfigId = "{config-id}";

    deleteNotificationConfig(parentId, notificationConfigId);

  // Delete a notification config.
  public static boolean deleteNotificationConfig(String parentId, String notificationConfigId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

          parentId, notificationConfigId));

      System.out.printf("Deleted Notification config: %s%n", notificationConfigId);
    return true;


// npm install @google-cloud/security-center/
const {SecurityCenterClient} = require('@google-cloud/security-center');

const client = new SecurityCenterClient();

// organizationId = "your-org-id";
// configId = "your-config-id";
const formattedConfigName = client.organizationNotificationConfigPath(

async function deleteNotificationConfg() {
  await client.deleteNotificationConfig({name: formattedConfigName});
  console.log('Notification config deleted: ', formattedConfigName);



use Google\Cloud\SecurityCenter\V1\SecurityCenterClient;

 * @param string $organizationId        Your org ID
 * @param string $notificationConfigId  A unique identifier
function delete_notification(string $organizationId, string $notificationConfigId): void
    $securityCenterClient = new SecurityCenterClient();
    $notificationConfigName = $securityCenterClient::notificationConfigName(

    $response = $securityCenterClient->deleteNotificationConfig($notificationConfigName);
    print('Notification config was deleted' . PHP_EOL);


def delete_notification_config(parent_id, notification_config_id):
        parent_id: must be in one of the following formats:
        notification_config_id: "your-config-id"
    from import securitycenter as securitycenter

    client = securitycenter.SecurityCenterClient()

    notification_config_name = (

    client.delete_notification_config(request={"name": notification_config_name})
    print(f"Deleted notification config: {notification_config_name}")


require "google/cloud/security_center"

# Your organization id. e.g. for "organizations/123", this would be "123".

# Your notification config id. e.g. for
# "organizations/123/notificationConfigs/my-config" this would be "my-config".
# config_id = "YOUR_CONFIG_ID"

client = Google::Cloud::SecurityCenter.security_center

config_path = client.notification_config_path organization:        org_id,
                                              notification_config: config_id

response = client.delete_notification_config name: config_path
puts "Deleted notification config #{config_id} with response: #{response}"

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.