분류 만들기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 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"]],[],[[["\u003cp\u003eThis page provides code samples in Go, Node.js, and Python for creating a new taxonomy within Google Cloud Data Catalog.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples illustrate how to define a taxonomy's display name, description, and its validity for fine-grained access control.\u003c/p\u003e\n"],["\u003cp\u003eSetting up Application Default Credentials is required for authenticating with the Data Catalog, as mentioned in the documentation and code comments for all samples.\u003c/p\u003e\n"],["\u003cp\u003eEach code example references its respective language-specific setup instructions and API documentation for further details on using Google Cloud Data Catalog.\u003c/p\u003e\n"]]],[],null,["# Create taxonomy\n\nCreate a new taxonomy.\n\nCode sample\n-----------\n\n### Go\n\n\nBefore trying this sample, follow the Go setup instructions in the\n[Data Catalog quickstart using\nclient libraries](/data-catalog/docs/reference/libraries).\n\n\nFor more information, see the\n[Data Catalog Go API\nreference documentation](https://godoc.org/cloud.google.com/go/datacatalog).\n\n\nTo authenticate to Data Catalog, 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 \tdatacatalog \"cloud.google.com/go/datacatalog/apiv1beta1\"\n \t\"cloud.google.com/go/datacatalog/apiv1beta1/datacatalogpb\"\n )\n\n // createTaxonomy creates a taxonomy resource, which holds the collection of policy tags.\n //\n // This example marks the taxonomy as valid for defining fine grained access control, also\n // known as column-level access control when used in conjunction with BigQuery.\n func createTaxonomy(w io.Writer, projectID, location, displayName string) (string, error) {\n \t// projectID := \"my-project-id\"\n \t// location := \"us\"\n \t// displayName := \"example-taxonomy\"\n \tctx := context.Background()\n \tpolicyClient, err := datacatalog.NewPolicyTagManagerClient(ctx)\n \tif err != nil {\n \t\treturn \"\", fmt.Errorf(\"datacatalog.NewPolicyTagManagerClient: %w\", err)\n \t}\n \tdefer policyClient.Close()\n\n \treq := &datacatalogpb.CreateTaxonomyRequest{\n \t\tParent: fmt.Sprintf(\"projects/%s/locations/%s\", projectID, location),\n \t\tTaxonomy: &datacatalogpb.Taxonomy{\n \t\t\tDisplayName: displayName,\n \t\t\tDescription: \"Taxonomy created via basic snippet testing\",\n \t\t\tActivatedPolicyTypes: []datacatalogpb.Taxonomy_PolicyType{\n \t\t\t\tdatacatalogpb.https://cloud.google.com/go/docs/reference/cloud.google.com/go/datacatalog/latest/apiv1beta1/datacatalogpb.html#cloud_google_com_go_datacatalog_apiv1beta1_datacatalogpb_Taxonomy_POLICY_TYPE_UNSPECIFIED_Taxonomy_FINE_GRAINED_ACCESS_CONTROL,\n \t\t\t},\n \t\t},\n \t}\n \tresp, err := policyClient.CreateTaxonomy(ctx, req)\n \tif err != nil {\n \t\treturn \"\", fmt.Errorf(\"CreateTaxonomy: %w\", err)\n \t}\n\n \tfmt.Fprintf(w, \"Taxonomy %s was created.\\n\", resp.Name)\n \treturn resp.Name, nil\n }\n\n### Node.js\n\n\nBefore trying this sample, follow the Node.js setup instructions in the\n[Data Catalog quickstart using\nclient libraries](/data-catalog/docs/reference/libraries).\n\n\nFor more information, see the\n[Data Catalog Node.js API\nreference documentation](https://googleapis.dev/nodejs/datacatalog/latest/index.html).\n\n\nTo authenticate to Data Catalog, 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 the Google Cloud client library.\n const {DataCatalogClient, PolicyTagManagerClient} =\n require('https://cloud.google.com/nodejs/docs/reference/datacatalog/latest/overview.html').v1;\n const dataCatalog = new https://cloud.google.com/nodejs/docs/reference/datacatalog/latest/overview.html();\n const policyTagManager = new https://cloud.google.com/nodejs/docs/reference/datacatalog/latest/overview.html();\n\n async function createTaxonomy() {\n // const location = 'us';\n /**\n * TODO(developer): Uncomment the following lines before running the sample.\n */\n // const projectId = 'my_project'; // Google Cloud Platform project\n // const location = 'us'\n // const displayName = 'my_display_name'; // Display name for new taxonomy.\n\n // Parent project location format is `projects/${projectId}/locations/${location}`\n const parent = dataCatalog.locationPath(projectId, location);\n\n const request = {\n parent: parent,\n taxonomy: {\n displayName: displayName,\n activatedPolicyTypes: ['FINE_GRAINED_ACCESS_CONTROL'],\n },\n };\n\n try {\n const [metadata] = await policyTagManager.createTaxonomy(request);\n console.log(`Created taxonomy: ${metadata.name}`);\n } catch (e) {\n console.error(e);\n process.exitCode = 1;\n }\n }\n\n### Python\n\n\nBefore trying this sample, follow the Python setup instructions in the\n[Data Catalog quickstart using\nclient libraries](/data-catalog/docs/reference/libraries).\n\n\nFor more information, see the\n[Data Catalog Python API\nreference documentation](/python/docs/reference/datacatalog/latest).\n\n\nTo authenticate to Data Catalog, 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 https://cloud.google.com/python/docs/reference/datacatalog/latest/\n\n\n def create_taxonomy(\n # TODO(developer): Set project_id to the ID of the project the\n # taxonomy will belong to.\n project_id: str = \"your-project-id\",\n # TODO(developer): Specify the geographic location where the\n # taxonomy should reside.\n location_id: str = \"us\",\n # TODO(developer): Set the display name of the taxonomy.\n display_name: str = \"example-taxonomy\",\n ):\n # TODO(developer): Construct a Policy Tag Manager client object. To avoid\n # extra delays due to authentication, create a single client for your\n # program and share it across operations.\n client = https://cloud.google.com/python/docs/reference/datacatalog/latest/.https://cloud.google.com/python/docs/reference/datacatalog/latest/google.cloud.datacatalog_v1.services.policy_tag_manager.PolicyTagManagerClient.html()\n\n # Construct a full location path to be the parent of the taxonomy.\n parent = https://cloud.google.com/python/docs/reference/datacatalog/latest/.https://cloud.google.com/python/docs/reference/datacatalog/latest/google.cloud.datacatalog_v1.services.policy_tag_manager.PolicyTagManagerClient.html.common_location_path(\n project_id, location_id\n )\n\n # TODO(developer): Construct a full Taxonomy object to send to the API.\n taxonomy = https://cloud.google.com/python/docs/reference/datacatalog/latest/.https://cloud.google.com/python/docs/reference/datacatalog/latest/google.cloud.datacatalog_v1.types.Taxonomy.html()\n taxonomy.display_name = display_name\n taxonomy.description = \"This Taxonomy represents ...\"\n\n # Send the taxonomy to the API for creation.\n taxonomy = client.https://cloud.google.com/python/docs/reference/datacatalog/latest/google.cloud.datacatalog_v1.services.policy_tag_manager.PolicyTagManagerClient.html#google_cloud_datacatalog_v1_services_policy_tag_manager_PolicyTagManagerClient_create_taxonomy(parent=parent, taxonomy=taxonomy)\n print(f\"Created taxonomy {taxonomy.name}\")\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=data_catalog)."]]