분류 나열

기존 분류를 나열합니다.

코드 샘플

Go

이 샘플을 사용해 보기 전에 Data Catalog 빠른 시작: 클라이언트 라이브러리 사용Go 설정 안내를 따르세요. 자세한 내용은 Data Catalog Go API 참조 문서를 참조하세요.

Data Catalog에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	datacatalog "cloud.google.com/go/datacatalog/apiv1beta1"
	"cloud.google.com/go/datacatalog/apiv1beta1/datacatalogpb"
	"google.golang.org/api/iterator"
)

// listTaxonomies prints information about the taxonomies contained within a specific
// project and location.
func listTaxonomies(w io.Writer, projectID, location string) error {
	// projectID := "my-project-id"
	// location := "us"
	ctx := context.Background()
	policyClient, err := datacatalog.NewPolicyTagManagerClient(ctx)
	if err != nil {
		return fmt.Errorf("datacatalog.NewPolicyTagManagerClient: %w", err)
	}
	defer policyClient.Close()

	req := &datacatalogpb.ListTaxonomiesRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),
	}
	it := policyClient.ListTaxonomies(ctx, req)
	fmt.Fprintf(w, "listing taxonomies in project %s and location %s\n", projectID, location)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("ListTaxonomies iteration error: %w", err)
		}

		fmt.Fprintf(w, "\t- %s: %s\n", resp.Name, resp.DisplayName)
	}
	return nil
}

Node.js

이 샘플을 사용해 보기 전에 Data Catalog 빠른 시작: 클라이언트 라이브러리 사용Node.js 설정 안내를 따르세요. 자세한 내용은 Data Catalog Node.js API 참조 문서를 참조하세요.

Data Catalog에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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

async function listTaxonomies() {
  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = 'my_project'; // Google Cloud Platform project
  // const location = 'us';

  // Parent project location format is `projects/${projectId}/locations/${location}`
  const parent = dataCatalog.locationPath(projectId, location);

  const request = {
    parent: parent,
  };

  try {
    const [taxonomies] = await policyTagManager.listTaxonomies(request);
    console.log('Taxonomies:');
    taxonomies.forEach(taxonomy => {
      console.log(taxonomy.name);
    });
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  }
}

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저를 참조하세요.