Delete taxonomy
Stay organized with collections
Save and categorize content based on your preferences.
Delete an existing taxonomy.
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page provides code samples in Go and Node.js for deleting an existing taxonomy within Google Cloud's Data Catalog.\u003c/p\u003e\n"],["\u003cp\u003eBefore running the provided samples, users are directed to complete the setup instructions found in the Data Catalog quickstart guide using client libraries.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication to Data Catalog requires setting up Application Default Credentials, with detailed instructions available for local development environments.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples provided use the \u003ccode\u003ePolicyTagManagerClient\u003c/code\u003e to perform the delete taxonomy action, and each have a specific function \u003ccode\u003edeleteTaxonomy\u003c/code\u003e that carries out this specific operation.\u003c/p\u003e\n"]]],[],null,["# Delete taxonomy\n\nDelete an existing 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\n \tdatacatalog \"cloud.google.com/go/datacatalog/apiv1beta1\"\n \t\"cloud.google.com/go/datacatalog/apiv1beta1/datacatalogpb\"\n )\n\n // deleteTaxonomy removes an existing taxonomy resource.\n func deleteTaxonomy(taxonomyID string) error {\n \t// taxonomyID := \"projects/myproject/locations/us/taxonomies/1234\"\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.DeleteTaxonomyRequest{\n \t\tName: taxonomyID,\n \t}\n \treturn policyClient.DeleteTaxonomy(ctx, req)\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 {PolicyTagManagerClient} = require('https://cloud.google.com/nodejs/docs/reference/datacatalog/latest/overview.html').v1;\n const policyTagManager = new https://cloud.google.com/nodejs/docs/reference/datacatalog/latest/overview.html();\n\n async function deleteTaxonomy() {\n /**\n * TODO(developer): Uncomment the following line before running the sample.\n */\n // const projectId = 'my_project'; // Google Cloud Platform project\n // const location = 'us';\n // const taxonomy = 'my_existing_taxonomy';\n // const taxonomyName = `projects/${projectId}/locations/${location}/taxonomies/${taxonomy}`;\n\n const request = {\n name: taxonomyName,\n };\n\n try {\n await policyTagManager.deleteTaxonomy(request);\n console.log(`Deleted taxonomy: ${taxonomyName}`);\n } catch (e) {\n console.error(e);\n process.exitCode = 1;\n }\n }\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)."]]