Menghapus modul kustom Security Health Analytics

Contoh kode untuk penghapusan modul kustom Security Health Analytics.

Contoh kode

Java

Untuk melakukan autentikasi ke Security Command Center, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

import com.google.cloud.securitycentermanagement.v1.DeleteSecurityHealthAnalyticsCustomModuleRequest;
import com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient;
import java.io.IOException;

public class DeleteSecurityHealthAnalyticsCustomModule {

  public static void main(String[] args) throws IOException {
    // https://cloud.google.com/security-command-center/docs/reference/security-center-management/rest/v1/organizations.locations.securityHealthAnalyticsCustomModules/delete
    // TODO: Developer should replace project_id with a real project ID before running this code
    String projectId = "project_id";

    String customModuleId = "custom_module_id";

    deleteSecurityHealthAnalyticsCustomModule(projectId, customModuleId);
  }

  public static boolean deleteSecurityHealthAnalyticsCustomModule(
      String projectId, String customModuleId) 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.
    try (SecurityCenterManagementClient client = SecurityCenterManagementClient.create()) {

      String name =
          String.format(
              "projects/%s/locations/global/securityHealthAnalyticsCustomModules/%s",
              projectId, customModuleId);

      DeleteSecurityHealthAnalyticsCustomModuleRequest request =
          DeleteSecurityHealthAnalyticsCustomModuleRequest.newBuilder().setName(name).build();

      client.deleteSecurityHealthAnalyticsCustomModule(request);

      return true;
    }
  }
}

Langkah selanjutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat browser contoh Google Cloud .