Sicherheitsquelle erstellen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Zeigt das Erstellen einer Sicherheitsquelle
Codebeispiel
Nächste Schritte
Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],[],[],[],null,["Demonstrates how to create a security source\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 )\n\n // createSource creates a new source for organization orgID. orgID is\n // the numeric identifier of the organization\n func createSource(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.CreateSourceRequest{\n \t\tSource: &securitycenterpb.Source{\n \t\t\tDisplayName: \"Customized Display Name\",\n \t\t\tDescription: \"A new custom source that does X\",\n \t\t},\n \t\tParent: fmt.Sprintf(\"organizations/%s\", orgID),\n \t}\n \tsource, err := client.CreateSource(ctx, req)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"CreateSource: %w\", err)\n \t}\n\n \tfmt.Fprintf(w, \"New source created: %s\\n\", source.Name)\n \tfmt.Fprintf(w, \"Display Name: %s\\n\", source.DisplayName)\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 Source createSource(OrganizationName organizationName) {\n try (SecurityCenterClient client = SecurityCenterClient.create()) {\n // Start setting up a request to create a source in an organization.\n // OrganizationName organizationName = OrganizationName.of(/*organizationId=*/\"123234324\");\n Source source =\n Source.newBuilder()\n .setDisplayName(\"Customized Display Name\")\n .setDescription(\"A new custom source that does X\")\n .build();\n\n CreateSourceRequest.Builder request =\n CreateSourceRequest.newBuilder().setParent(organizationName.toString()).setSource(source);\n\n // Call the API.\n Source response = client.createSource(request.build());\n\n System.out.println(\"Created Source: \" + 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 // organizationId is numeric organization identifier.\n /*\n * TODO(developer): Uncomment the following lines\n */\n // const organizationId = \"1234567777\";\n async function createSource() {\n const [source] = await client.createSource({\n source: {\n displayName: 'Customized Display Name',\n description: 'A new custom source that does X',\n },\n parent: client.organizationPath(organizationId),\n });\n console.log('New Source: %j', source);\n }\n createSource();\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_v1\n\n client = securitycenter_v1.SecurityCenterClient()\n # organization_id is the numeric ID of the organization. e.g.:\n # organization_id = \"111122222444\"\n org_name = f\"organizations/{organization_id}\"\n\n created = 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_create_source(\n request={\n \"parent\": org_name,\n \"source\": {\n \"display_name\": \"Customized Display Name\",\n \"description\": \"A new custom source that does X\",\n },\n }\n )\n print(f\"Created Source: {created.name}\")\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)."]]