Ottenere un modulo personalizzato per Event Threat Detection
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Codice di esempio per ottenere un modulo personalizzato di Event Threat Detection.
Esempio di codice
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],[],[],[],null,["Sample code for getting an Event Threat Detection custom module.\n\nCode sample \n\nGo\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\n import (\n \t\"context\"\n \t\"fmt\"\n \t\"io\"\n\n \tsecuritycentermanagement \"cloud.google.com/go/securitycentermanagement/apiv1\"\n \tsecuritycentermanagementpb \"cloud.google.com/go/securitycentermanagement/apiv1/securitycentermanagementpb\"\n )\n\n // getEventThreatDetectionCustomModule retrieves a specific custom module by its name.\n func getEventThreatDetectionCustomModule(w io.Writer, parent string, customModuleID string) error {\n \t// parent: Use any one of the following options:\n \t// - organizations/{organization_id}/locations/{location_id}\n \t// - folders/{folder_id}/locations/{location_id}\n \t// - projects/{project_id}/locations/{location_id}\n \t// customModuleID := \"your-module-id\"\n \tctx := context.Background()\n \tclient, err := securitycentermanagement.https://cloud.google.com/go/docs/reference/cloud.google.com/go/securitycentermanagement/latest/apiv1.html#cloud_google_com_go_securitycentermanagement_apiv1_Client_NewClient(ctx)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"securitycentermanagement.NewClient: %w\", err)\n \t}\n \tdefer client.https://cloud.google.com/go/docs/reference/cloud.google.com/go/securitycentermanagement/latest/apiv1.html#cloud_google_com_go_securitycentermanagement_apiv1_Client_Close()\n\n \treq := &securitycentermanagementpb.GetEventThreatDetectionCustomModuleRequest{\n \t\tName: fmt.Sprintf(\"%s/eventThreatDetectionCustomModules/%s\", parent, customModuleID),\n \t}\n\n \tmodule, err := client.GetEventThreatDetectionCustomModule(ctx, req)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"Failed to get EventThreatDetectionCustomModule: %w\", err)\n \t}\n\n \tfmt.Fprintf(w, \"Retrieved EventThreatDetectionCustomModule: %s\\n\", module.Name)\n \treturn nil\n }\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.EventThreatDetectionCustomModule.html;\n import com.google.cloud.securitycentermanagement.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.GetEventThreatDetectionCustomModuleRequest.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 GetEventThreatDetectionCustomModule {\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.eventThreatDetectionCustomModules/get\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 getEventThreatDetectionCustomModule(projectId, customModuleId);\n }\n\n public static https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.EventThreatDetectionCustomModule.html getEventThreatDetectionCustomModule(\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 qualifiedModuleName =\n String.format(\n \"projects/%s/locations/global/eventThreatDetectionCustomModules/%s\",\n projectId, customModuleId);\n\n https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.GetEventThreatDetectionCustomModuleRequest.html request =\n https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.GetEventThreatDetectionCustomModuleRequest.html.newBuilder()\n .setName(qualifiedModuleName)\n .build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.EventThreatDetectionCustomModule.html response =\n client.getEventThreatDetectionCustomModule(request);\n\n return response;\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 // Imports the Google Cloud client library.\n const {SecurityCenterManagementClient} =\n require('https://cloud.google.com/nodejs/docs/reference/securitycentermanagement/latest/overview.html').v1;\n\n // Create a Security Center Management client\n const client = new https://cloud.google.com/nodejs/docs/reference/securitycentermanagement/latest/overview.html();\n\n /*\n * Required. Resource name of event threat detection module.\n * Its format is\n * `organizations/[organization_id]/locations/[location_id]/eventThreatDetectionCustomModules/[custom_module]`\n * `folders/[folder_id]/locations/[location_id]/eventThreatDetectionCustomModules/[custom_module]`\n * `projects/[project_id]/locations/[location_id]/eventThreatDetectionCustomModules/[custom_module]`\n */\n // TODO(developer): Update the following references for your own environment before running the sample.\n // const organizationId = 'YOUR_ORGANIZATION_ID';\n // const location = 'LOCATION_ID';\n // const customModuleId = 'CUSTOM_MODULE_ID';\n const name = `organizations/${organizationId}/locations/${location}/eventThreatDetectionCustomModules/${customModuleId}`;\n\n // Build the request.\n const getEventThreatDetectionCustomModuleRequest = {\n name: name,\n };\n\n async function getEventThreatDetectionCustomModule() {\n // Call the API.\n const [response] = await client.getEventThreatDetectionCustomModule(\n getEventThreatDetectionCustomModuleRequest\n );\n console.log('Retrieved EventThreatDetectionCustomModule: %j', response);\n }\n\n getEventThreatDetectionCustomModule();\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 get_event_threat_detection_custom_module(parent: str, module_id: str):\n \"\"\"\n Retrieves a Event Threat Detection 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 retrieved Event Threat Detection 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.GetEventThreatDetectionCustomModuleRequest(\n name=f\"{parent}/eventThreatDetectionCustomModules/{module_id}\",\n )\n\n response = client.get_event_threat_detection_custom_module(request=request)\n print(f\"Retrieved Event Threat Detection Custom Module: {response.name}\")\n return response\n except NotFound as e:\n print(f\"Custom Module not found: {e.message}\")\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)."]]