刪除 Security Health Analytics 自訂模組
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
刪除 Security Health Analytics 自訂模組的程式碼範例。
程式碼範例
Java
如要向 Security Command Center 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Node.js
如要向 Security Command Center 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Python
如要向 Security Command Center 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],[],[],[],null,["Sample code for deletion of Security Health Analytics custom modules.\n\nCode sample \n\nJava\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import com.google.cloud.securitycentermanagement.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.DeleteSecurityHealthAnalyticsCustomModuleRequest.html;\n import com.google.cloud.securitycentermanagement.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient.html;\n import java.io.IOException;\n\n public class DeleteSecurityHealthAnalyticsCustomModule {\n\n public static void main(String[] args) throws IOException {\n // https://cloud.google.com/security-command-center/docs/reference/security-center-management/rest/v1/organizations.locations.securityHealthAnalyticsCustomModules/delete\n // TODO: Developer should replace project_id with a real project ID before running this code\n String projectId = \"project_id\";\n\n String customModuleId = \"custom_module_id\";\n\n deleteSecurityHealthAnalyticsCustomModule(projectId, customModuleId);\n }\n\n public static boolean deleteSecurityHealthAnalyticsCustomModule(\n String projectId, String customModuleId) throws IOException {\n\n // Initialize client that will be used to send requests. This client only needs\n // to be created\n // once, and can be reused for multiple requests.\n try (https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient.html.create()) {\n\n String name =\n String.format(\n \"projects/%s/locations/global/securityHealthAnalyticsCustomModules/%s\",\n projectId, customModuleId);\n\n https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.DeleteSecurityHealthAnalyticsCustomModuleRequest.html request =\n https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.DeleteSecurityHealthAnalyticsCustomModuleRequest.html.newBuilder().setName(name).build();\n\n client.deleteSecurityHealthAnalyticsCustomModule(request);\n\n return true;\n }\n }\n }\n\nNode.js\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n // npm install '@google-cloud/securitycentermanagement'\n const {\n SecurityCenterManagementClient,\n } = require('https://cloud.google.com/nodejs/docs/reference/securitycentermanagement/latest/overview.html');\n\n const client = new https://cloud.google.com/nodejs/docs/reference/securitycentermanagement/latest/overview.html();\n\n /*\n * Required. Resource name of security health analytics module.\n * Its format is\n * `organizations/[organization_id]/locations/[location_id]/securityHealthAnalyticsCustomModules/[custom_module]`\n * `folders/[folder_id]/locations/[location_id]/securityHealthAnalyticsCustomModules/[custom_module]`\n * `projects/[project_id]/locations/[location_id]/securityHealthAnalyticsCustomModules/[custom_module]`\n */\n const name = `organizations/${organizationId}/locations/${locationId}/securityHealthAnalyticsCustomModules/${customModuleId}`;\n\n async function deleteSecurityHealthAnalyticsCustomModule() {\n const [response] = await client.deleteSecurityHealthAnalyticsCustomModule({\n name: name,\n });\n console.log(\n 'Security Health Analytics Custom Module delete succeeded: ',\n response\n );\n }\n\n deleteSecurityHealthAnalyticsCustomModule();\n\nPython\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n def delete_security_health_analytics_custom_module(parent: str, module_id: str):\n \"\"\"\n Deletes a Security Health Analytics custom module.\n Args:\n parent: Use any one of the following options:\n - organizations/{organization_id}/locations/{location_id}\n - folders/{folder_id}/locations/{location_id}\n - projects/{project_id}/locations/{location_id}\n Returns:\n The deleted Security Health Analytics custom module.\n Raises:\n NotFound: If the specified custom module does not exist.\n \"\"\"\n client = securitycentermanagement_v1.SecurityCenterManagementClient()\n\n try:\n request = securitycentermanagement_v1.DeleteSecurityHealthAnalyticsCustomModuleRequest(\n name=f\"{parent}/securityHealthAnalyticsCustomModules/{module_id}\",\n )\n\n client.delete_security_health_analytics_custom_module(request=request)\n print(f\"Deleted SecurityHealthAnalyticsCustomModule Successfully: {module_id}\")\n except NotFound as e:\n print(f\"Custom Module not found: {module_id}\")\n raise e\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=securitycenter)."]]