Security Health Analytics 커스텀 모듈 삭제

Security Health Analytics 커스텀 모듈 삭제를 위한 샘플 코드입니다.

코드 샘플

Java

Security Command Center에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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;
    }
  }
}

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저를 참고하세요.