애셋 검색 사용 설정
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
애셋 검색을 사용 또는 사용 중지하는 방법을 보여줍니다.
더 살펴보기
이 코드 샘플이 포함된 자세한 문서는 다음을 참조하세요.
코드 샘플
Go
Security Command Center에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Java
Security Command Center에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Node.js
Security Command Center에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Python
Security Command Center에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 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,["Demonstrates how to enable or disable asset discovery\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Configuring asset discovery using the Security Command Center API](/security-command-center/docs/how-to-api-configure-asset-discovery)\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 import (\n \t\"context\"\n \t\"fmt\"\n \t\"io\"\n\n \tsecuritycenter \"cloud.google.com/go/securitycenter/apiv1\"\n \t\"cloud.google.com/go/securitycenter/apiv1/securitycenterpb\"\n \t\"google.golang.org/genproto/protobuf/field_mask\"\n )\n\n // Turns on asset discovery for orgID and prints out updated settings to w.\n // settings. orgID is the numeric Organization ID.\n func enableAssetDiscovery(w io.Writer, orgID string) error {\n \t// orgID := \"12321311\"\n \t// Instantiate a context and a security service client to make API calls.\n \tctx := context.Background()\n \tclient, err := securitycenter.https://cloud.google.com/go/docs/reference/cloud.google.com/go/securitycenter/latest/apiv1.html#cloud_google_com_go_securitycenter_apiv1_Client_NewClient(ctx)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"securitycenter.NewClient: %w\", err)\n \t}\n \tdefer client.https://cloud.google.com/go/docs/reference/cloud.google.com/go/securitycenter/latest/apiv1.html#cloud_google_com_go_securitycenter_apiv1_Client_Close() // Closing the client safely cleans up background resources.\n\n \treq := &securitycenterpb.UpdateOrganizationSettingsRequest{\n \t\tOrganizationSettings: &securitycenterpb.OrganizationSettings{\n \t\t\tName: fmt.Sprintf(\"organizations/%s/organizationSettings\", orgID),\n \t\t\tEnableAssetDiscovery: true,\n \t\t},\n \t\t// Only update the asset discovery setting.\n \t\tUpdateMask: &field_mask.FieldMask{\n \t\t\tPaths: []string{\"enable_asset_discovery\"},\n \t\t},\n \t}\n \tsettings, err := client.UpdateOrganizationSettings(ctx, req)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"UpdateOrganizationSettings: %w\", err)\n \t}\n \tfmt.Fprintf(w, \"Updated Settings for: %s\\n\", settings.Name)\n \tfmt.Fprintf(w, \"Asset discovery on? %v\\n\", settings.EnableAssetDiscovery)\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 static OrganizationSettings updateOrganizationSettings(OrganizationName organizationName) {\n try (SecurityCenterClient client = SecurityCenterClient.create()) {\n // Start setting up a request to update OrganizationSettings for.\n // OrganizationName organizationName = OrganizationName.of(/*organizationId=*/\"123234324\");\n OrganizationSettings organizationSettings =\n OrganizationSettings.newBuilder()\n .setName(organizationName.toString() + \"/organizationSettings\")\n .setEnableAssetDiscovery(true)\n .build();\n FieldMask updateMask = FieldMask.newBuilder().addPaths(\"enable_asset_discovery\").build();\n\n UpdateOrganizationSettingsRequest.Builder request =\n UpdateOrganizationSettingsRequest.newBuilder()\n .setOrganizationSettings(organizationSettings)\n .setUpdateMask(updateMask);\n\n // Call the API.\n OrganizationSettings response = client.updateOrganizationSettings(request.build());\n\n System.out.println(\"Organization Settings have been updated:\");\n System.out.println(response);\n return response;\n } catch (IOException e) {\n throw new RuntimeException(\"Couldn't create client.\", e);\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 {SecurityCenterClient} = require('https://cloud.google.com/nodejs/docs/reference/security-center/latest/overview.html');\n\n // Creates a new client.\n const client = new https://cloud.google.com/nodejs/docs/reference/security-center/latest/overview.html();\n\n async function updateOrgSettings() {\n // organizationId is the numeric ID of the organization.\n /*\n * TODO(developer): Uncomment the following lines\n */\n // const organizationId = \"111122222444\";\n const orgName = client.organizationPath(organizationId);\n const [newSettings] = await client.updateOrganizationSettings({\n organizationSettings: {\n name: `${orgName}/organizationSettings`,\n enableAssetDiscovery: true,\n },\n // Only update the enableAssetDiscovery field.\n updateMask: {paths: ['enable_asset_discovery']},\n });\n\n console.log('New settings: %j', newSettings);\n }\n updateOrgSettings();\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 from google.cloud import securitycenter\n from google.protobuf import field_mask_pb2\n\n # Create the client\n client = securitycenter.SecurityCenterClient()\n # organization_id is numeric ID for the organization. e.g.\n # organization_id = \"111112223333\"\n org_settings_name = \"organizations/{org_id}/organizationSettings\".format(\n org_id=organization_id\n )\n # Only update the enable_asset_discovery_value (leave others untouched).\n field_mask = field_mask_pb2.FieldMask(paths=[\"enable_asset_discovery\"])\n # Call the service.\n updated = client.https://cloud.google.com/python/docs/reference/securitycenter/latest/google.cloud.securitycenter_v1.services.security_center.SecurityCenterClient.html#google_cloud_securitycenter_v1_services_security_center_SecurityCenterClient_update_organization_settings(\n request={\n \"organization_settings\": {\n \"name\": org_settings_name,\n \"enable_asset_discovery\": True,\n },\n \"update_mask\": field_mask,\n }\n )\n print(f\"Asset Discovery Enabled? {updated.enable_asset_discovery}\")\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)."]]