Taxonomie löschen

Vorhandene Taxonomie löschen

Codebeispiel

Go

Bevor Sie dieses Beispiel ausprobieren, folgen Sie der Einrichtungsanleitung für Go in der Data Catalog-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Data Catalog Go API.

Richten Sie Standardanmeldedaten für Anwendungen ein, um sich bei Data Catalog zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

import (
	"context"
	"fmt"

	datacatalog "cloud.google.com/go/datacatalog/apiv1beta1"
	"cloud.google.com/go/datacatalog/apiv1beta1/datacatalogpb"
)

// deleteTaxonomy removes an existing taxonomy resource.
func deleteTaxonomy(taxonomyID string) error {
	// taxonomyID := "projects/myproject/locations/us/taxonomies/1234"
	ctx := context.Background()
	policyClient, err := datacatalog.NewPolicyTagManagerClient(ctx)
	if err != nil {
		return fmt.Errorf("datacatalog.NewPolicyTagManagerClient: %w", err)
	}
	defer policyClient.Close()

	req := &datacatalogpb.DeleteTaxonomyRequest{
		Name: taxonomyID,
	}
	return policyClient.DeleteTaxonomy(ctx, req)
}

Node.js

Bevor Sie dieses Beispiel ausprobieren, folgen Sie der Einrichtungsanleitung für Node.js in der Data Catalog-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Data Catalog Node.js API.

Richten Sie Standardanmeldedaten für Anwendungen ein, um sich bei Data Catalog zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

// Import the Google Cloud client library.
const {PolicyTagManagerClient} = require('@google-cloud/datacatalog').v1;
const policyTagManager = new PolicyTagManagerClient();

async function deleteTaxonomy() {
  /**
   * TODO(developer): Uncomment the following line before running the sample.
   */
  // const projectId = 'my_project'; // Google Cloud Platform project
  // const location = 'us';
  // const taxonomy = 'my_existing_taxonomy';
  // const taxonomyName = `projects/${projectId}/locations/${location}/taxonomies/${taxonomy}`;

  const request = {
    name: taxonomyName,
  };

  try {
    await policyTagManager.deleteTaxonomy(request);
    console.log(`Deleted taxonomy: ${taxonomyName}`);
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  }
}

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.