메타데이터 변경 피드로 알림 수신

이 문서에서는 Knowledge Catalog (이전 명칭: Dataplex Universal Catalog) 메타데이터 변경 피드를 구성하여 Knowledge Catalog 내의 메타데이터가 생성, 업데이트 또는 삭제될 때 Pub/Sub를 통해 알림을 받는 방법을 설명합니다.

메타데이터 변경 피드에 대한 자세한 내용은 메타데이터 변경 피드 개요를 참고하세요.

시작하기 전에

Pub/SubDataplex API를 숙지합니다.

  1. Dataplex API 및 Pub/Sub API를 사용 설정합니다.

    API 사용 설정에 필요한 역할

    API를 사용 설정하려면 serviceusage.services.enable 권한이 포함된 서비스 사용량 관리자 IAM 역할(roles/serviceusage.serviceUsageAdmin)이 필요합니다. 역할 부여 방법 알아보기

    API 사용 설정

  2. 알림을 수신할 Pub/Sub 주제를 만듭니다. 자세한 내용은 주제 만들기를 참고하세요.

  3. gcloud를 설치합니다. gcloud의 짧은 별칭이 설정되어 있는지 확인합니다.

  4. gcurl의 별칭을 설정합니다. 이렇게 하면 인증 토큰이 포함된 바로가기가 생성되고 API 요청의 JSON 콘텐츠 유형이 설정됩니다.

    alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
    
  5. DATAPLEX_API 변수를 설정합니다.

    DATAPLEX_API="dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION"
    

    다음을 바꿉니다.

    • PROJECT_ID: Dataplex API가 사용 설정된 프로젝트 ID
    • LOCATION: 작업이 실행되는 위치입니다(예: us-central1, europe-west3, asia-south1).

필수 역할 및 권한

메타데이터 변경 피드를 구성하려면 사용자와 Knowledge Catalog 서비스 계정에 필요한 IAM 역할과 권한이 있는지 확인하세요.

사용자 역할 및 권한

메타데이터를 내보내고 메타데이터 변경 피드 메시지에 액세스하는 데 필요한 권한을 얻으려면 관리자에게 프로젝트 또는 조직에 대해 다음 IAM 역할을 부여해 달라고 요청하세요.

역할 부여에 대한 자세한 내용은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.

이러한 사전 정의된 역할에는 메타데이터를 내보내고 메타데이터 변경 피드 메시지에 액세스하는 데 필요한 권한이 포함되어 있습니다. 필요한 정확한 권한을 보려면 필수 권한 섹션을 펼치세요.

필수 권한

메타데이터를 내보내고 메타데이터 변경 피드 메시지에 액세스하려면 다음 권한이 필요합니다.

  • 메타데이터 내보내기:
    • 프로젝트에 대한 dataplex.metadataFeeds.create 권한
    • 피드의 범위를 정의하는 리소스 (조직, 프로젝트 또는 항목 그룹)에 대한 dataplex.entryGroups.export 권한
    • 프로젝트에 대한 resourcemanager.projects.get 권한
    • 프로젝트에 대한 resourcemanager.projects.list 권한
  • 메타데이터 변경 피드 메시지에 액세스합니다.
    • 구독에 대한 pubsub.subscriptions.consume 권한
    • 주제에 대한 pubsub.topics.attachSubscription 권한

커스텀 역할이나 다른 사전 정의된 역할을 사용하여 이 권한을 부여받을 수도 있습니다.

Knowledge Catalog 서비스 계정 역할 및 권한

Knowledge Catalog 서비스 계정에 메타데이터 변경 피드 메시지를 게시하는 데 필요한 권한이 있는지 확인하려면 관리자에게 Pub/Sub 주제에 대한 Knowledge Catalog 서비스 계정에 Pub/Sub 게시자 (roles/pubsub.publisher) 및 Pub/Sub 보기 권한 (roles/pubsub.viewer) IAM 역할을 부여해 달라고 요청하세요.

역할 부여에 대한 자세한 내용은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.

이 사전 정의된 역할에는 메타데이터 변경 피드 메시지를 게시하는 데 필요한 pubsub.topics.publishpubsub.topics.get 권한이 포함되어 있습니다.

관리자는 커스텀 역할이나 다른 사전 정의된 역할을 사용하여 Knowledge Catalog 서비스 계정에 이 권한을 부여할 수도 있습니다.

Knowledge Catalog 서비스 계정에 권한 부여

Knowledge Catalog의 서비스 에이전트는 Dataplex API를 사용 설정할 때 생성됩니다. 이메일 ID로 서비스 에이전트를 식별할 수 있습니다.

service-PROJECT_NUMBER@gcp-sa-dataplex.iam.gserviceaccount.com

여기서 PROJECT_NUMBER는 Dataplex API를 사용 설정한 프로젝트의 프로젝트 번호입니다.

Knowledge Catalog 서비스 계정은 Pub/Sub 주제에 메시지를 게시하고 주제 메타데이터를 검색할 수 있어야 합니다. 이러한 권한을 부여하려면 Pub/Sub 주제에 대한 서비스 계정에 Pub/Sub 게시자 역할 (roles/pubsub.publisher)과 Pub/Sub 뷰어 역할 (roles/pubsub.viewer)을 부여하세요.

gcloud

gcloud pubsub topics add-iam-policy-binding 명령어를 실행합니다.

gcloud pubsub topics add-iam-policy-binding TOPIC_ID \
    --member="serviceAccount:service-PROJECT_NUMBER@gcp-sa-dataplex.iam.gserviceaccount.com" \
    --role="roles/pubsub.publisher"

gcloud pubsub topics add-iam-policy-binding TOPIC_ID \
    --member="serviceAccount:service-PROJECT_NUMBER@gcp-sa-dataplex.iam.gserviceaccount.com" \
    --role="roles/pubsub.viewer"

다음을 바꿉니다.

  • TOPIC_ID: 메타데이터 변경 피드 메시지가 게시되는 Pub/Sub 주제의 ID입니다.
  • PROJECT_NUMBER: 서비스 계정이 있는 Knowledge Catalog 프로젝트의 프로젝트 번호입니다.

콘솔

  1. Google Cloud 콘솔에서 Pub/Sub 주제 페이지로 이동합니다.

    주제로 이동

  2. 메타데이터 피드 알림에 사용할 주제를 선택하고 필요한 경우 정보 패널 표시를 클릭합니다.

  3. 권한 탭에서 주 구성원 추가를 클릭합니다.

  4. 새 주 구성원 필드에 Knowledge Catalog 서비스 계정(service-PROJECT_NUMBER@gcp-sa-dataplex.iam.gserviceaccount.com)을 입력합니다.

  5. 역할 할당 필드에서 Pub/Sub 게시자를 선택합니다.

  6. 다른 역할 추가를 클릭하고 Pub/Sub 뷰어를 선택합니다.

  7. 저장을 클릭합니다.

메타데이터 변경 피드 만들기

알림을 생성하는 변경사항을 제어하려면 특정 리소스를 모니터링하도록 메타데이터 변경 피드를 구성하면 됩니다. 전체 조직, 특정 프로젝트 또는 특정 항목 그룹과 같은 범위를 지정하여 이 작업을 실행합니다. 범위를 사용하면 모니터링할 리소스를 정의할 수 있지만, 필터를 사용하면 Knowledge Catalog에서 알림을 보내는 시점을 더 세부적으로 조정할 수 있습니다.

자세한 내용은 메타데이터 변경 피드를 참고하세요.

C#

C#

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

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

using Google.Api.Gax.ResourceNames;
using Google.Cloud.Dataplex.V1;
using Google.LongRunning;

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for CreateMetadataFeed</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void CreateMetadataFeedRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        CreateMetadataFeedRequest request = new CreateMetadataFeedRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            MetadataFeed = new MetadataFeed(),
            MetadataFeedId = "",
            ValidateOnly = false,
        };
        // Make the request
        Operation<MetadataFeed, OperationMetadata> response = catalogServiceClient.CreateMetadataFeed(request);

        // Poll until the returned long-running operation is complete
        Operation<MetadataFeed, OperationMetadata> completedResponse = response.PollUntilCompleted();
        // Retrieve the operation result
        MetadataFeed result = completedResponse.Result;

        // Or get the name of the operation
        string operationName = response.Name;
        // This name can be stored, then the long-running operation retrieved later by name
        Operation<MetadataFeed, OperationMetadata> retrievedResponse = catalogServiceClient.PollOnceCreateMetadataFeed(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            MetadataFeed retrievedResult = retrievedResponse.Result;
        }
    }
}

Go

Go

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

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


//go:build examples

package main

import (
	"context"

	dataplex "cloud.google.com/go/dataplex/apiv1"
	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataplex.NewCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataplexpb.CreateMetadataFeedRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#CreateMetadataFeedRequest.
	}
	op, err := c.CreateMetadataFeed(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

자바

Java

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

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

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.CreateMetadataFeedRequest;
import com.google.cloud.dataplex.v1.LocationName;
import com.google.cloud.dataplex.v1.MetadataFeed;

public class SyncCreateMetadataFeed {

  public static void main(String[] args) throws Exception {
    syncCreateMetadataFeed();
  }

  public static void syncCreateMetadataFeed() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
      CreateMetadataFeedRequest request =
          CreateMetadataFeedRequest.newBuilder()
              .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .setMetadataFeed(MetadataFeed.newBuilder().build())
              .setMetadataFeedId("metadataFeedId1633421160")
              .setValidateOnly(true)
              .build();
      MetadataFeed response = catalogServiceClient.createMetadataFeedAsync(request).get();
    }
  }
}

Node.js

Node.js

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

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

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The resource name of the parent location, in the format
 *  `projects/{project_id_or_number}/locations/{location_id}`
 */
// const parent = 'abc123'
/**
 *  Required. The metadata job resource.
 */
// const metadataFeed = {}
/**
 *  Optional. The metadata job ID. If not provided, a unique ID is generated
 *  with the prefix `metadata-job-`.
 */
// const metadataFeedId = 'abc123'
/**
 *  Optional. The service validates the request without performing any
 *  mutations. The default is false.
 */
// const validateOnly = true

// Imports the Dataplex library
const {CatalogServiceClient} = require('@google-cloud/dataplex').v1;

// Instantiates a client
const dataplexClient = new CatalogServiceClient();

async function callCreateMetadataFeed() {
  // Construct request
  const request = {
    parent,
    metadataFeed,
  };

  // Run request
  const [operation] = await dataplexClient.createMetadataFeed(request);
  const [response] = await operation.promise();
  console.log(response);
}

callCreateMetadataFeed();

Python

Python

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

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

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dataplex_v1


def sample_create_metadata_feed():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    metadata_feed = dataplex_v1.MetadataFeed()
    metadata_feed.pubsub_topic = "pubsub_topic_value"

    request = dataplex_v1.CreateMetadataFeedRequest(
        parent="parent_value",
        metadata_feed=metadata_feed,
    )

    # Make the request
    operation = client.create_metadata_feed(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)

REST

메타데이터 변경 피드를 만들려면 projects.locations.metadataFeeds.create 메서드를 사용합니다.

조직 범위

다음 명령어를 실행하여 전체 조직을 모니터링하는 메타데이터 변경 피드를 만듭니다.

gcurl -X POST -d "$(cat <<EOF
{
  "scope": {
    "organizationLevel": true
  },
  "pubsubTopic": "projects/PROJECT_ID_PUBSUB/topics/TOPIC_ID"
}
EOF
)" "https://${DATAPLEX_API}/metadataFeeds?metadataFeedId=FEED_ID"

다음을 바꿉니다.

  • PROJECT_ID_PUBSUB: Pub/Sub 주제가 있는 프로젝트 ID(예: example-project)
  • TOPIC_ID: 메타데이터 변경 피드 메시지가 게시되는 Pub/Sub 주제 ID입니다(예: example-topic).
  • FEED_ID: 만들려는 메타데이터 변경 피드 ID입니다(예: example-feed).

프로젝트 범위

다음 명령어를 실행하여 특정 프로젝트를 모니터링하는 메타데이터 변경 피드를 만듭니다.

gcurl -X POST -d "$(cat <<EOF
{
  "scope": {
    "projects": [
      "projects/PROJECT_ID_1",
      "projects/PROJECT_ID_2"
    ]
  },
  "pubsubTopic": "projects/PROJECT_ID_PUBSUB/topics/TOPIC_ID"
}
EOF
)" "https://${DATAPLEX_API}/metadataFeeds?metadataFeedId=FEED_ID"

다음을 바꿉니다.

  • PROJECT_ID_PUBSUB: Pub/Sub 주제가 있는 프로젝트 ID(예: example-project)
  • TOPIC_ID: 메타데이터 변경 피드 메시지가 게시되는 Pub/Sub 주제 ID입니다(예: example-topic).
  • FEED_ID: 만들려는 메타데이터 변경 피드 ID입니다(예: example-feed).

항목 그룹 범위

다음 명령어를 실행하여 특정 항목 그룹을 모니터링하는 메타데이터 변경 피드를 만듭니다.

gcurl -X POST -d "$(cat <<EOF
{
  "scope": {
    "entryGroups": [
      "projects/PROJECT_ID/locations/LOCATION/entryGroups/ENTRY_GROUP_ID_1",
      "projects/PROJECT_ID/locations/LOCATION/entryGroups/ENTRY_GROUP_ID_2"
    ]
  },
  "pubsubTopic": "projects/PROJECT_ID_PUBSUB/topics/TOPIC_ID"
}
EOF
)" "https://${DATAPLEX_API}/metadataFeeds?metadataFeedId=FEED_ID"

다음을 바꿉니다.

  • PROJECT_ID_PUBSUB: Pub/Sub 주제가 있는 프로젝트 ID(예: example-project)
  • LOCATION: 피드를 만들려는 위치(예: us-central1)
  • ENTRY_GROUP_ID: 모니터링할 항목 그룹 ID(예: example-entry-group)
  • TOPIC_ID: 메타데이터 변경 피드 메시지가 게시되는 Pub/Sub 주제 ID입니다(예: example-topic).
  • FEED_ID: 만들려는 메타데이터 변경 피드 ID입니다(예: example-feed).

필터 사용

다음 명령어를 실행하여 필터가 있는 메타데이터 변경 피드를 만듭니다(항목 유형별 필터링).

gcurl -X POST -d "$(cat <<EOF
{
  "scope": {
    "projects": [
      "projects/PROJECT_ID_1",
      "projects/PROJECT_ID_2"
    ]
  },
  "filter": {
    "entryTypes": [
      "projects/PROJECT_ID/locations/global/entryTypes/bigquery-table"
    ]
  },
  "pubsubTopic": "projects/PROJECT_ID_PUBSUB/topics/TOPIC_ID"
}
EOF
)" "https://${DATAPLEX_API}/metadataFeeds?metadataFeedId=FEED_ID"

다음을 바꿉니다.

  • PROJECT_ID_PUBSUB: Pub/Sub 주제가 있는 프로젝트 ID(예: example-project)
  • TOPIC_ID: 메타데이터 변경 피드 메시지가 게시되는 Pub/Sub 주제 ID입니다(예: example-topic).
  • FEED_ID: 만들려는 메타데이터 변경 피드 ID입니다(예: example-feed).

응답:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.dataplex.v1.OperationMetadata",
    "createTime": "2023-10-02T15:01:23Z",
    "target": "projects/PROJECT_ID/locations/LOCATION/metadataFeeds/FEED_ID",
    "verb": "create",
    "apiVersion": "v1"
  },
  "done": false
}

메타데이터 변경 피드 보기

메타데이터 변경 피드의 세부정보를 볼 수 있습니다.

C#

C#

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

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

using Google.Cloud.Dataplex.V1;

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for GetMetadataFeed</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void GetMetadataFeedRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        GetMetadataFeedRequest request = new GetMetadataFeedRequest
        {
            MetadataFeedName = MetadataFeedName.FromProjectLocationMetadataFeed("[PROJECT]", "[LOCATION]", "[METADATA_FEED]"),
        };
        // Make the request
        MetadataFeed response = catalogServiceClient.GetMetadataFeed(request);
    }
}

Go

Go

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

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


//go:build examples

package main

import (
	"context"

	dataplex "cloud.google.com/go/dataplex/apiv1"
	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataplex.NewCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataplexpb.GetMetadataFeedRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#GetMetadataFeedRequest.
	}
	resp, err := c.GetMetadataFeed(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

자바

Java

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

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

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.GetMetadataFeedRequest;
import com.google.cloud.dataplex.v1.MetadataFeed;
import com.google.cloud.dataplex.v1.MetadataFeedName;

public class SyncGetMetadataFeed {

  public static void main(String[] args) throws Exception {
    syncGetMetadataFeed();
  }

  public static void syncGetMetadataFeed() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
      GetMetadataFeedRequest request =
          GetMetadataFeedRequest.newBuilder()
              .setName(MetadataFeedName.of("[PROJECT]", "[LOCATION]", "[METADATA_FEED]").toString())
              .build();
      MetadataFeed response = catalogServiceClient.getMetadataFeed(request);
    }
  }
}

Node.js

Node.js

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

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

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The resource name of the metadata feed, in the format
 *  `projects/{project_id_or_number}/locations/{location_id}/MetadataFeeds/{metadata_feed_id}`.
 */
// const name = 'abc123'

// Imports the Dataplex library
const {CatalogServiceClient} = require('@google-cloud/dataplex').v1;

// Instantiates a client
const dataplexClient = new CatalogServiceClient();

async function callGetMetadataFeed() {
  // Construct request
  const request = {
    name,
  };

  // Run request
  const response = await dataplexClient.getMetadataFeed(request);
  console.log(response);
}

callGetMetadataFeed();

Python

Python

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

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

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dataplex_v1


def sample_get_metadata_feed():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    request = dataplex_v1.GetMetadataFeedRequest(
        name="name_value",
    )

    # Make the request
    response = client.get_metadata_feed(request=request)

    # Handle the response
    print(response)

REST

메타데이터 변경 피드를 보려면 projects.locations.metadataFeeds.get 메서드를 사용합니다.

다음 명령어를 실행합니다.

gcurl "https://${DATAPLEX_API}/metadataFeeds/FEED_ID"

다음을 바꿉니다.

  • FEED_ID: 보려는 메타데이터 변경 피드 ID입니다(예: example-feed).

메타데이터 변경 피드 나열

프로젝트 및 위치의 메타데이터 변경 피드를 나열할 수 있습니다.

C#

C#

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

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

using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Dataplex.V1;
using System;

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for ListMetadataFeeds</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void ListMetadataFeedsRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        ListMetadataFeedsRequest request = new ListMetadataFeedsRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            Filter = "",
            OrderBy = "",
        };
        // Make the request
        PagedEnumerable<ListMetadataFeedsResponse, MetadataFeed> response = catalogServiceClient.ListMetadataFeeds(request);

        // Iterate over all response items, lazily performing RPCs as required
        foreach (MetadataFeed item in response)
        {
            // Do something with each item
            Console.WriteLine(item);
        }

        // Or iterate over pages (of server-defined size), performing one RPC per page
        foreach (ListMetadataFeedsResponse page in response.AsRawResponses())
        {
            // Do something with each page of items
            Console.WriteLine("A page of results:");
            foreach (MetadataFeed item in page)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
        }

        // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
        int pageSize = 10;
        Page<MetadataFeed> singlePage = response.ReadPage(pageSize);
        // Do something with the page of items
        Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
        foreach (MetadataFeed item in singlePage)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
        // Store the pageToken, for when the next page is required.
        string nextPageToken = singlePage.NextPageToken;
    }
}

Go

Go

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

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


//go:build examples

package main

import (
	"context"

	dataplex "cloud.google.com/go/dataplex/apiv1"
	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
	"google.golang.org/api/iterator"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataplex.NewCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataplexpb.ListMetadataFeedsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#ListMetadataFeedsRequest.
	}
	it := c.ListMetadataFeeds(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp

		// If you need to access the underlying RPC response,
		// you can do so by casting the `Response` as below.
		// Otherwise, remove this line. Only populated after
		// first call to Next(). Not safe for concurrent access.
		_ = it.Response.(*dataplexpb.ListMetadataFeedsResponse)
	}
}

자바

Java

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

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

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.ListMetadataFeedsRequest;
import com.google.cloud.dataplex.v1.LocationName;
import com.google.cloud.dataplex.v1.MetadataFeed;

public class SyncListMetadataFeeds {

  public static void main(String[] args) throws Exception {
    syncListMetadataFeeds();
  }

  public static void syncListMetadataFeeds() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
      ListMetadataFeedsRequest request =
          ListMetadataFeedsRequest.newBuilder()
              .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .setPageSize(883849137)
              .setPageToken("pageToken873572522")
              .setFilter("filter-1274492040")
              .setOrderBy("orderBy-1207110587")
              .build();
      for (MetadataFeed element : catalogServiceClient.listMetadataFeeds(request).iterateAll()) {
        // doThingsWith(element);
      }
    }
  }
}

Node.js

Node.js

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

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

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The resource name of the parent location, in the format
 *  `projects/{project_id_or_number}/locations/{location_id}`
 */
// const parent = 'abc123'
/**
 *  Optional. The maximum number of metadata feeds to return. The service
 *  might return fewer feeds than this value. If unspecified, at most 10 feeds
 *  are returned. The maximum value is 1,000.
 */
// const pageSize = 1234
/**
 *  Optional. The page token received from a previous `ListMetadataFeeds` call.
 *  Provide this token to retrieve the subsequent page of results. When
 *  paginating, all other parameters that are provided to the
 *  `ListMetadataFeeds` request must match the call that provided the
 *  page token.
 */
// const pageToken = 'abc123'
/**
 *  Optional. Filter request. Filters are case-sensitive.
 *  The service supports the following formats:
 *  * `labels.key1 = "value1"`
 *  * `labels:key1`
 *  * `name = "value"`
 *  You can combine filters with `AND`, `OR`, and `NOT` operators.
 */
// const filter = 'abc123'
/**
 *  Optional. The field to sort the results by, either `name` or `create_time`.
 *  If not specified, the ordering is undefined.
 */
// const orderBy = 'abc123'

// Imports the Dataplex library
const {CatalogServiceClient} = require('@google-cloud/dataplex').v1;

// Instantiates a client
const dataplexClient = new CatalogServiceClient();

async function callListMetadataFeeds() {
  // Construct request
  const request = {
    parent,
  };

  // Run request
  const iterable = dataplexClient.listMetadataFeedsAsync(request);
  for await (const response of iterable) {
      console.log(response);
  }
}

callListMetadataFeeds();

Python

Python

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

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

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dataplex_v1


def sample_list_metadata_feeds():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    request = dataplex_v1.ListMetadataFeedsRequest(
        parent="parent_value",
    )

    # Make the request
    page_result = client.list_metadata_feeds(request=request)

    # Handle the response
    for response in page_result:
        print(response)

REST

메타데이터 변경 피드를 나열하려면 projects.locations.metadataFeeds.list 메서드를 사용합니다.

다음 명령어를 실행합니다.

gcurl "https://${DATAPLEX_API}/metadataFeeds"

메타데이터 변경 피드 업데이트

기존 메타데이터 변경 피드의 범위 또는 필터를 업데이트할 수 있습니다.

C#

C#

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

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

using Google.Cloud.Dataplex.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for UpdateMetadataFeed</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void UpdateMetadataFeedRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        UpdateMetadataFeedRequest request = new UpdateMetadataFeedRequest
        {
            MetadataFeed = new MetadataFeed(),
            UpdateMask = new FieldMask(),
            ValidateOnly = false,
        };
        // Make the request
        Operation<MetadataFeed, OperationMetadata> response = catalogServiceClient.UpdateMetadataFeed(request);

        // Poll until the returned long-running operation is complete
        Operation<MetadataFeed, OperationMetadata> completedResponse = response.PollUntilCompleted();
        // Retrieve the operation result
        MetadataFeed result = completedResponse.Result;

        // Or get the name of the operation
        string operationName = response.Name;
        // This name can be stored, then the long-running operation retrieved later by name
        Operation<MetadataFeed, OperationMetadata> retrievedResponse = catalogServiceClient.PollOnceUpdateMetadataFeed(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            MetadataFeed retrievedResult = retrievedResponse.Result;
        }
    }
}

Go

Go

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

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


//go:build examples

package main

import (
	"context"

	dataplex "cloud.google.com/go/dataplex/apiv1"
	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataplex.NewCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataplexpb.UpdateMetadataFeedRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#UpdateMetadataFeedRequest.
	}
	op, err := c.UpdateMetadataFeed(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

자바

Java

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

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

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.MetadataFeed;
import com.google.cloud.dataplex.v1.UpdateMetadataFeedRequest;
import com.google.protobuf.FieldMask;

public class SyncUpdateMetadataFeed {

  public static void main(String[] args) throws Exception {
    syncUpdateMetadataFeed();
  }

  public static void syncUpdateMetadataFeed() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
      UpdateMetadataFeedRequest request =
          UpdateMetadataFeedRequest.newBuilder()
              .setMetadataFeed(MetadataFeed.newBuilder().build())
              .setUpdateMask(FieldMask.newBuilder().build())
              .setValidateOnly(true)
              .build();
      MetadataFeed response = catalogServiceClient.updateMetadataFeedAsync(request).get();
    }
  }
}

Node.js

Node.js

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

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

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. Update description.
 *  Only fields specified in `update_mask` are updated.
 */
// const metadataFeed = {}
/**
 *  Optional. Mask of fields to update.
 */
// const updateMask = {}
/**
 *  Optional. Only validate the request, but do not perform mutations.
 *  The default is false.
 */
// const validateOnly = true

// Imports the Dataplex library
const {CatalogServiceClient} = require('@google-cloud/dataplex').v1;

// Instantiates a client
const dataplexClient = new CatalogServiceClient();

async function callUpdateMetadataFeed() {
  // Construct request
  const request = {
    metadataFeed,
  };

  // Run request
  const [operation] = await dataplexClient.updateMetadataFeed(request);
  const [response] = await operation.promise();
  console.log(response);
}

callUpdateMetadataFeed();

Python

Python

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

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

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dataplex_v1


def sample_update_metadata_feed():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    metadata_feed = dataplex_v1.MetadataFeed()
    metadata_feed.pubsub_topic = "pubsub_topic_value"

    request = dataplex_v1.UpdateMetadataFeedRequest(
        metadata_feed=metadata_feed,
    )

    # Make the request
    operation = client.update_metadata_feed(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)

REST

메타데이터 변경 피드를 업데이트하려면 projects.locations.metadataFeeds.patch 메서드를 사용합니다.

다음 명령어를 실행하여 메타데이터 변경 피드를 업데이트하여 항목 유형 필터를 삭제합니다.

gcurl -X PATCH -d "$(cat <<EOF
{
  "filter": {
    "entryTypes": []
  }
}
EOF
)" "https://${DATAPLEX_API}/metadataFeeds/FEED_ID?updateMask=filter"

다음을 바꿉니다.

  • FEED_ID: 업데이트하려는 메타데이터 변경 피드 ID입니다(예: example-feed).

메타데이터 변경 피드 삭제

더 이상 알림을 받지 않으려면 메타데이터 변경 피드를 삭제하면 됩니다.

메타데이터 변경 피드를 삭제하면 피드에서 새 메타데이터 변경사항을 Pub/Sub 주제에 게시하지 않습니다. 하지만 주제나 피드와 연결된 구독은 삭제되지 않습니다. 더 이상 필요하지 않은 경우 수동으로 삭제해야 합니다.

피드 또는 구독을 삭제하기 전에 구독자 애플리케이션이 Pub/Sub 구독에서 미처리된 모든 메시지를 처리했는지 확인합니다.

C#

C#

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

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

using Google.Cloud.Dataplex.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for DeleteMetadataFeed</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void DeleteMetadataFeedRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        DeleteMetadataFeedRequest request = new DeleteMetadataFeedRequest
        {
            MetadataFeedName = MetadataFeedName.FromProjectLocationMetadataFeed("[PROJECT]", "[LOCATION]", "[METADATA_FEED]"),
        };
        // Make the request
        Operation<Empty, OperationMetadata> response = catalogServiceClient.DeleteMetadataFeed(request);

        // Poll until the returned long-running operation is complete
        Operation<Empty, OperationMetadata> completedResponse = response.PollUntilCompleted();
        // Retrieve the operation result
        Empty result = completedResponse.Result;

        // Or get the name of the operation
        string operationName = response.Name;
        // This name can be stored, then the long-running operation retrieved later by name
        Operation<Empty, OperationMetadata> retrievedResponse = catalogServiceClient.PollOnceDeleteMetadataFeed(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            Empty retrievedResult = retrievedResponse.Result;
        }
    }
}

Go

Go

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

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


//go:build examples

package main

import (
	"context"

	dataplex "cloud.google.com/go/dataplex/apiv1"
	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataplex.NewCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataplexpb.DeleteMetadataFeedRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#DeleteMetadataFeedRequest.
	}
	op, err := c.DeleteMetadataFeed(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

자바

Java

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

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

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.DeleteMetadataFeedRequest;
import com.google.cloud.dataplex.v1.MetadataFeedName;
import com.google.protobuf.Empty;

public class SyncDeleteMetadataFeed {

  public static void main(String[] args) throws Exception {
    syncDeleteMetadataFeed();
  }

  public static void syncDeleteMetadataFeed() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
      DeleteMetadataFeedRequest request =
          DeleteMetadataFeedRequest.newBuilder()
              .setName(MetadataFeedName.of("[PROJECT]", "[LOCATION]", "[METADATA_FEED]").toString())
              .build();
      catalogServiceClient.deleteMetadataFeedAsync(request).get();
    }
  }
}

Node.js

Node.js

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

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

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The resource name of the metadata feed, in the format
 *  `projects/{project_id_or_number}/locations/{location_id}/MetadataFeeds/{metadata_feed_id}`.
 */
// const name = 'abc123'

// Imports the Dataplex library
const {CatalogServiceClient} = require('@google-cloud/dataplex').v1;

// Instantiates a client
const dataplexClient = new CatalogServiceClient();

async function callDeleteMetadataFeed() {
  // Construct request
  const request = {
    name,
  };

  // Run request
  const [operation] = await dataplexClient.deleteMetadataFeed(request);
  const [response] = await operation.promise();
  console.log(response);
}

callDeleteMetadataFeed();

Python

Python

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

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

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dataplex_v1


def sample_delete_metadata_feed():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    request = dataplex_v1.DeleteMetadataFeedRequest(
        name="name_value",
    )

    # Make the request
    operation = client.delete_metadata_feed(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)

REST

메타데이터 변경 피드를 삭제하려면 projects.locations.metadataFeeds.delete 메서드를 사용합니다.

다음 명령어를 실행합니다.

gcurl -X DELETE \
"https://${DATAPLEX_API}/metadataFeeds/FEED_ID"

다음을 바꿉니다.

  • FEED_ID: 삭제하려는 메타데이터 변경 피드 ID입니다(예: example-feed).

알림 메시지 사용

메타데이터 변경 피드를 구성하면 메타데이터가 변경될 때마다 Knowledge Catalog에서 지정된 Pub/Sub 주제에 메시지를 게시합니다. 이러한 메시지를 사용하려면 주제에 대한 Pub/Sub 구독을 만드세요.

예를 들어 풀 구독을 만들고 Google Cloud CLI를 사용하여 메시지를 볼 수 있습니다.

  1. 구독을 만듭니다.

    gcloud pubsub subscriptions create SUBSCRIPTION_ID --topic=TOPIC_ID
    

    다음을 바꿉니다.

    • SUBSCRIPTION_ID: 생성하려는 정기 결제 ID
    • TOPIC_ID: 메타데이터 변경 피드 메시지가 게시되는 Pub/Sub 주제 ID입니다.
  2. 구독에서 메시지를 가져옵니다.

    gcloud pubsub subscriptions pull SUBSCRIPTION_ID --auto-ack --limit=10
    

    다음을 바꿉니다.

    • SUBSCRIPTION_ID: 메시지를 가져오려는 구독 ID

Pub/Sub 메시지 처리에 대한 자세한 내용은 풀 구독에서 메시지 수신을 참고하세요. 메시지 형식에 관한 자세한 내용은 데이터 페이로드를 참고하세요.

다음 단계