Security Health Analytics のカスタム モジュールを一覧表示する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Security Health Analytics カスタム モジュールを一覧表示するサンプルコード。
コードサンプル
Java
Security Command Center で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
Python
Security Command Center で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 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 listing 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.ListSecurityHealthAnalyticsCustomModulesRequest.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 com.google.cloud.securitycentermanagement.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient.html.https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient.ListSecurityHealthAnalyticsCustomModulesPagedResponse.html;\n import java.io.IOException;\n\n public class ListSecurityHealthAnalyticsCustomModules {\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/list\n // TODO: Developer should replace project_id with a real project ID before running this code\n String projectId = \"project_id\";\n\n listSecurityHealthAnalyticsCustomModules(projectId);\n }\n\n public static https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient.ListSecurityHealthAnalyticsCustomModulesPagedResponse.html\n listSecurityHealthAnalyticsCustomModules(String projectId) throws IOException {\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 https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.ListSecurityHealthAnalyticsCustomModulesRequest.html request =\n https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.ListSecurityHealthAnalyticsCustomModulesRequest.html.newBuilder()\n .setParent(String.format(\"projects/%s/locations/global\", projectId))\n .build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-securitycentermanagement/latest/com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient.ListSecurityHealthAnalyticsCustomModulesPagedResponse.html response =\n client.listSecurityHealthAnalyticsCustomModules(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 // 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. The name of the parent resource of security health analytics module\n * Its format is\n * `organizations/[organization_id]/locations/[location_id]`\n * `folders/[folder_id]/locations/[location_id]`\n * `projects/[project_id]/locations/[location_id]`\n */\n const parent = `organizations/${organizationId}/locations/${locationId}`;\n\n async function listSecurityHealthAnalyticsCustomModule() {\n const [response] = await client.listSecurityHealthAnalyticsCustomModules({\n parent: parent,\n });\n console.log(\n 'Security Health Analytics Custom Module list succeeded: ',\n response\n );\n }\n\n listSecurityHealthAnalyticsCustomModule();\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 list_security_health_analytics_custom_module(parent: str):\n \"\"\"\n Retrieves list of 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 List of retrieved Security Health Analytics custom modules.\n Raises:\n NotFound: If the specified custom module does not exist.\n \"\"\"\n\n client = securitycentermanagement_v1.SecurityCenterManagementClient()\n\n try:\n request = securitycentermanagement_v1.ListSecurityHealthAnalyticsCustomModulesRequest(\n parent=parent,\n )\n\n response = client.list_security_health_analytics_custom_modules(request=request)\n\n custom_modules = []\n for custom_module in response:\n print(f\"Custom Module: {custom_module.name}\")\n custom_modules.append(custom_module)\n return custom_modules\n except NotFound as e:\n print(f\"Parent resource not found: {parent}\")\n raise e\n except Exception as e:\n print(f\"An error occurred while listing custom modules: {e}\")\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)."]]