管理切面并丰富元数据

元数据对于整理和了解数据资产至关重要。例如,受监管的行业需要保护个人身份信息 (PII),例如姓名、地址和政府签发的身份证号码。此类数据可能出现在分布式数据系统的多个实例中。Dataplex Universal Catalog 可帮助您快速发现和编目分布式数据资产。然后,您可以将数据归类为 PII。

通过为数据条目添加有意义的上下文,您可以让数据更易于发现且更有用。Dataplex Universal Catalog 通过以下方式实现上下文:

  • 切面类型:用于定义相关数据的 JSON 模板。例如,对于合规性信息,您可能需要提供个人身份信息分类和 GDPR 合规性。
  • 切面:切面类型的实例。例如,{"pii_classification": "confidential", "gdpr_compliant": true}。您可以将切面应用于整个表或单个表列。

对数据进行分类后,您可以对数据应用数据质量或访问政策。

如需了解详情,请参阅 Dataplex Universal Catalog 中的元数据管理简介

切面

利用切面,您可以捕获条目中的元数据,从而提供有意义的上下文。 您可以使用切面来存储:

  • 业务元数据:提供业务上下文,例如数据分类。

  • 技术元数据:数据资产的技术详细信息,例如其架构。

  • 数据派生元数据:根据数据本身生成的信息,例如 BigQuery 表中的统计信息。

切面被视为条目资源的一部分,而不是单独的资源。修改切面时,涉及修改包含该切面的条目。

您可以在条目级层指定用于描述条目的切面,也可以在列级层指定用于描述条目中列的切面。

每个切面都是切面类型的一个实例。切面类型用于为其切面定义模板。每个切面类型都包含一组字段。创建切面时,您必须为这些字段提供值。

对于给定的条目,每个切面类型最多只能有一个与该条目关联的切面。每个切面类型可以有多个与条目列关联的切面。

切面类别

切面分为以下几类:

  • 必需的切面:创建条目时必须使用的切面。此类切面由给定条目的条目类型定义。属于某个条目类型的所有条目都必须始终具有该条目类型定义的所有必需切面。

    Dataplex Universal Catalog 会管理系统条目所需的切面(例如架构)。

    请注意以下几点:

    • 您只能将必需的切面与条目相关联,而不能与条目列相关联。

    • 您无法从条目中删除必需的切面。

    • 您可以读取系统条目的必需切面,但无法修改它们。

    • 数据切面不能是必需的切面。

  • 可选切面:您可以将可选切面与条目或条目列相关联。您可以在创建条目时填充可选切面,也可以稍后通过更新条目来填充。

    填充可选切面后,您可以将其删除。

数据切面

切面可以包含从数据中派生的信息,例如数据分析或示例查询的结果。这些切面称为数据切面

切面类型

切面类型是可重复使用的资源,可为切面提供模板。

切面类型的类别

切面类型分为自定义切面类型和系统切面类型。

自定义切面类型

您在 Dataplex Universal Catalog 中创建的切面类型称为自定义切面类型。

自定义切面类型可以是全球性的,也可以是区域级的。您可以在特定区域位置(例如 us-central1)创建自定义切面类型,也可以将其创建为 global 资源。切面类型的位置会影响其适用范围,并决定它可以与哪些条目搭配使用:

  • 全球切面类型:可用于为任何区域中的条目创建切面。如果您需要将相同的结构应用于多个区域中的条目,请选择 global 切面类型,因为您只需定义一次。由于全球切面类型的定义会复制到所有区域,因此如果切面类型架构本身包含敏感信息,或者需要对所有元数据组件实施严格的数据驻留,则此选项可能不适合。
  • 区域切面类型:只能用于为与切面类型位于同一区域的条目创建切面。例如,在 us-central1 中创建的切面类型只能与 us-central1 中的条目搭配使用。如果某种切面类型仅与特定区域中的条目相关,或者为了确保切面类型定义位于所选区域内(这有助于满足数据主权和合规性要求),请选择区域位置。如果您使用区域切面类型,但需要在多个区域中使用相同的结构,则必须在每个区域中创建和管理单独的切面类型定义。

如需了解详情,请参阅项目和位置限制条件

系统切面类型

Dataplex Universal Catalog 提供、使用和管理的切面类型称为系统切面类型。系统切面类型始终是全球性的,因此可在任何区域使用。系统切面类型存储在项目编号为 655216118709 的 Google 管理的项目中。例如 projects/655216118709/locations/global/aspectTypes/schema

系统切面类型进一步分为可重复使用和受限两类。下表介绍了系统切面类型的类别,以及 Dataplex Universal Catalog 为每个类别提供的切面类型列表:

系统切面类型的类别 说明 Dataplex Universal Catalog 提供的切面类型
可重复使用的系统切面类型 您可以使用这些切面类型来创建或修改切面。
  • contacts
  • data-quality-scorecard
  • generic
  • overview
  • schema
  • usage
受限的系统切面类型 Dataplex Universal Catalog 会管理这些切面类型。
您可以读取这些切面类型下的切面,但无法在这些切面类型下创建或修改切面。
包括但不限于:
  • analytics-hub
  • aspecttype-aspect
  • bigquery-dataset
  • bigquery-table
  • cloudsql-database
  • cloudsql-instance
  • cloudsql-table
  • entrygroup-aspect
  • entrytype-aspect
  • sensitive-data-protection-profile
  • storage
  • storage-bucket
  • storage-folder

准备工作

在创建和管理方面类型及切面之前,请完成本部分中所述的任务。

所需的角色

如需获得创建和管理切面类型及切面所需的权限,请让您的管理员为您授予资源的以下 IAM 角色:

  • 拥有 Dataplex Universal Catalog 中的元数据资源(包括切面类型和数据切面)的整套权限:Dataplex Catalog Admin (roles/dataplex.catalogAdmin)
  • 在 Dataplex Universal Catalog 中创建和管理元数据资源,包括切面类型和数据切面:Dataplex Catalog Editor (roles/dataplex.catalogEditor)
  • 拥有自定义切面类型的整套权限(除了使用切面类型创建或修改条目的权限):Dataplex Aspect Type Owner (roles/dataplex.aspectTypeOwner)
  • 查看切面类型以及与其关联的 IAM 政策:Dataplex Catalog Viewer (roles/dataplex.catalogViewer)
  • 使用切面类型创建和修改具有相应切面的条目:Dataplex Aspect Type User (roles/dataplex.aspectTypeUser)
  • 添加一些系统切面类型的切面,例如 schemaoverviewcontactsDataplex Entry and EntryLink Owner (roles/dataplex.entryOwner)

如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

您也可以通过自定义角色或其他预定义角色来获取所需的权限。

如需了解详情,请参阅 Dataplex Universal Catalog IAM 角色

启用 API

在 Dataplex Universal Catalog 项目中启用 Dataplex API。

启用该 API

创建自定义切面类型

控制台

  1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 目录页面。

    前往“目录”

  2. 点击切面类型和标记模板 > 自定义标签页。

  3. 点击创建切面类型

  4. 创建切面类型窗口中,输入以下内容:

    1. 可选:在显示名称字段中,输入切面类型的名称。
    2. 切面类型 ID 字段中,输入切面类型的唯一 ID。
    3. 可选:在说明字段中,输入切面类型的说明。
    4. 位置字段中,为切面类型选择一个位置。创建切面类型后,您无法修改其位置。 如需了解选择全球位置与区域位置的影响,请参阅自定义切面类型部分。
  5. 可选:为切面类型定义模板。

    模板部分中,点击添加字段。在新字段部分中,输入以下内容:

    1. 名称字段中,输入一个名称。
    2. 可选:在显示名称字段中,输入一个显示名称。
    3. 可选:在说明字段中,输入说明。
    4. 类型字段中,为该字段选择一种数据类型。系统会根据您的选择显示下一组字段和选项:

      • 如果您选择了文本作为数据类型,请按照以下步骤操作:

        1. 文本类型字段中,选择文本类型。
        2. 文本值字段中,为文本字段提供提示。为此,请点击添加值,然后输入提示。您可以为文本字段添加多个提示。
        3. 点击完成
      • 如果您选择了枚举作为数据类型,请添加枚举值:

        1. 点击添加枚举值
        2. 字段中,输入一个枚举值。您可以添加多个枚举值。
        3. 点击完成
      • 如果您选择了数组作为数据类型,请在数组项部分中,定义要在数组中显示的项的类型:

        1. 点击添加数组项
        2. 名称字段中,输入数组项的名称。
        3. 可选:在显示名称字段中,输入数组项的显示名称。
        4. 可选:在说明字段中,输入数组项的说明。
        5. 类型字段中,为数组项选择一种数据类型。

          系统会根据您的选择显示下一组字段和选项。它们与本部分其他位置针对文本枚举映射数组记录数据类型描述的选项类似。

        6. 点击完成

      • 如果您选择了映射作为数据类型,请在映射值部分中,定义要在映射中显示的值的类型:

        1. 点击添加映射值
        2. 名称字段中,输入映射的名称。
        3. 可选:在显示名称字段中,输入映射的显示名称。
        4. 可选:在说明字段中,输入映射的说明。
        5. 类型字段中,为映射选择一种数据类型。

          系统会根据您的选择显示下一组字段和选项。它们与本部分其他位置针对文本枚举映射数组记录数据类型描述的选项类似。

        6. 点击完成

      • 如果您选择了记录作为数据类型,请输入以下内容:

        1. 记录 ID 字段中,输入一个唯一 ID,其他记录字段可以使用该 ID 来引用此记录。请参阅本文档的使用记录 ID 和记录引用字段的示例部分。
        2. 可选:如果您想添加对此模板中其他记录的引用,请使用记录引用字段。创建切面类型后,您无法修改此字段。请参阅本文档的使用记录 ID 和记录引用字段的示例部分。
        3. 记录字段部分,您可以定义包含多个嵌套字段的复杂对象。为此,请点击添加记录字段项,然后指定以下内容:

        4. 名称字段中,输入记录字段的名称。

        5. 可选:在显示名称字段中,输入记录字段的显示名称。

        6. 可选:在说明字段中,输入记录字段的说明。

        7. 类型字段中,选择一种数据类型。

          系统会根据您的选择显示下一组字段和选项。它们与本部分前面针对文本枚举映射数组记录数据类型描述的选项类似。

        8. 点击完成

    5. 如需将相应字段设为此类型的切面的必填字段,请选择为必填项。如需详细了解必需的切面和可选切面,请参阅本文档的切面类别部分。

    6. 点击完成

    7. 如需添加多个字段,请点击添加字段,然后重复执行上述步骤。

  6. 可选:在标签部分中,为资源添加键值对形式的任意标签:

    1. 点击添加标签
    2. 字段中,输入一个键。
    3. 字段中,输入该键的值。
    4. 如需添加更多标签,请点击添加标签,然后重复执行上述步骤。
  7. 点击保存

gcloud

如需创建自定义切面类型,请使用 gcloud dataplex aspect-types create 命令

C#

C#

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 C# 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog C# API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

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

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for CreateAspectType</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 CreateAspectTypeRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        CreateAspectTypeRequest request = new CreateAspectTypeRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            AspectTypeId = "",
            AspectType = new AspectType(),
            ValidateOnly = false,
        };
        // Make the request
        Operation<AspectType, OperationMetadata> response = catalogServiceClient.CreateAspectType(request);

        // Poll until the returned long-running operation is complete
        Operation<AspectType, OperationMetadata> completedResponse = response.PollUntilCompleted();
        // Retrieve the operation result
        AspectType 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<AspectType, OperationMetadata> retrievedResponse = catalogServiceClient.PollOnceCreateAspectType(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            AspectType retrievedResult = retrievedResponse.Result;
        }
    }
}

Go

Go

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Go 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Go API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证


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.CreateAspectTypeRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#CreateAspectTypeRequest.
	}
	op, err := c.CreateAspectType(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

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

Java

Java

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Java 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Java API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

import com.google.cloud.dataplex.v1.AspectType;
import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.CreateAspectTypeRequest;
import com.google.cloud.dataplex.v1.LocationName;

public class SyncCreateAspectType {

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

  public static void syncCreateAspectType() 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()) {
      CreateAspectTypeRequest request =
          CreateAspectTypeRequest.newBuilder()
              .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .setAspectTypeId("aspectTypeId-423030675")
              .setAspectType(AspectType.newBuilder().build())
              .setValidateOnly(true)
              .build();
      AspectType response = catalogServiceClient.createAspectTypeAsync(request).get();
    }
  }
}

Python

Python

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Python 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Python API 参考文档

如需向 Dataplex Universal 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_aspect_type():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    aspect_type = dataplex_v1.AspectType()
    aspect_type.metadata_template.name = "name_value"
    aspect_type.metadata_template.type_ = "type__value"

    request = dataplex_v1.CreateAspectTypeRequest(
        parent="parent_value",
        aspect_type_id="aspect_type_id_value",
        aspect_type=aspect_type,
    )

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

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

    response = operation.result()

    # Handle the response
    print(response)

Ruby

Ruby

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Ruby 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Ruby API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

require "google/cloud/dataplex/v1"

##
# Snippet for the create_aspect_type call in the CatalogService service
#
# 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/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::CatalogService::Client#create_aspect_type.
#
def create_aspect_type
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::CatalogService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::CreateAspectTypeRequest.new

  # Call the create_aspect_type method.
  result = client.create_aspect_type request

  # The returned object is of type Gapic::Operation. You can use it to
  # check the status of an operation, cancel it, or wait for results.
  # Here is how to wait for a response.
  result.wait_until_done! timeout: 60
  if result.response?
    p result.response
  else
    puts "No response received."
  end
end

REST

如需创建自定义切面类型,请使用 aspectType.create 方法。

创建自定义切面类型后,您可以向条目添加切面

使用记录 ID 和记录引用字段的示例

您可以使用记录 ID记录引用字段进行递归引用。以下示例展示了如何使用这些字段:

假设一个名为 Employee 的切面类型,其中包含以下字段:

  • 名称(类型:Text
  • 开始日期(类型:Date & time
  • 标识(类型:Text
  • 当前地址(类型:Record
  • 永久地址(类型:Record

两个地址字段(当前地址和永久地址)的数据类型均为 Record。为避免重复,您可以在定义这些字段时设置记录 ID记录引用 值。

定义当前地址字段时,您可以将记录 ID 指定为 address-field。对于永久地址,您可以为记录引用指定相同的值 (address-field)。例如:

  • 名称(类型:Text
  • 开始日期(类型:Date & time
  • 标识(类型:Text
  • 当前地址(类型:Record,记录 ID:address-field
  • 永久地址(类型:Record,记录引用:address-field

这样一来,您便无需重复其他地址的字段。

向条目添加切面

创建切面类型后,您可以创建该类型的切面。如需向条目添加切面,您必须更新该条目,因为切面存储在条目中。

请注意以下几点:

  • 您可以向条目或条目列添加切面。
  • 您只能修改自定义条目的必需切面。您无法删除必需的切面。
  • 您可以修改和删除自定义条目及系统条目的可选切面。

控制台

  1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 搜索页面。

    转到搜索

  2. 对于选择搜索平台,选择 Dataplex Universal Catalog 作为搜索模式。

  3. 搜索要向其添加切面的条目,然后点击该条目。系统会打开条目详情页面。

  4. 如需向条目添加切面,请按照以下步骤操作:

    1. 点击详情标签页。
    2. 如需向条目添加必需的切面或可选切面,请在标记和切面部分中,针对相应类别点击 添加
      如果所选条目的条目类型未定义必需的切面,则您无法添加必需的切面。
    3. 搜索并选择您要添加的切面。
    4. 添加切面窗口中,输入相应字段的值。
    5. 点击保存
  5. 如需向条目列添加切面,请按照以下步骤操作:

    1. 在条目详情页面上,点击架构标签页。
    2. 选择要向其添加切面的列。
    3. 点击添加切面
    4. 搜索并选择您要添加的切面。
    5. 添加切面窗口中,输入相应字段的值。
    6. 点击保存

gcloud

如需向条目或条目列添加切面,请使用 gcloud dataplex entries update 命令

C#

C#

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 C# 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog C# API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

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

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for UpdateEntry</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 UpdateEntryRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        UpdateEntryRequest request = new UpdateEntryRequest
        {
            Entry = new Entry(),
            UpdateMask = new FieldMask(),
            AllowMissing = false,
            DeleteMissingAspects = false,
            AspectKeys = { "", },
        };
        // Make the request
        Entry response = catalogServiceClient.UpdateEntry(request);
    }
}

如需向条目对象添加切面,请参阅切面

Go

Go

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Go 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Go API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证


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.UpdateEntryRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#UpdateEntryRequest.
	}
	resp, err := c.UpdateEntry(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

如需向条目对象添加切面,请参阅条目

Java

Java

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Java 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Java API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

import com.google.cloud.dataplex.v1.Aspect;
import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.Entry;
import com.google.cloud.dataplex.v1.EntryName;
import com.google.cloud.dataplex.v1.EntrySource;
import com.google.protobuf.FieldMask;
import com.google.protobuf.Struct;
import com.google.protobuf.Value;
import java.util.Map;

public class UpdateEntry {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "MY_PROJECT_ID";
    // Available locations: https://cloud.google.com/dataplex/docs/locations
    String location = "MY_LOCATION";
    String entryGroupId = "MY_ENTRY_GROUP_ID";
    String entryId = "MY_ENTRY_ID";

    Entry createdEntry = updateEntry(projectId, location, entryGroupId, entryId);
    System.out.println("Successfully updated entry: " + createdEntry.getName());
  }

  // Method to update Entry located in projectId, location, entryGroupId and with entryId
  public static Entry updateEntry(
      String projectId, String location, String entryGroupId, String entryId) throws Exception {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (CatalogServiceClient client = CatalogServiceClient.create()) {
      Entry entry =
          Entry.newBuilder()
              .setName(EntryName.of(projectId, location, entryGroupId, entryId).toString())
              .setEntrySource(
                  EntrySource.newBuilder()
                      .setDescription("updated description of the entry")
                      .build())
              .putAllAspects(
                  Map.of(
                      "dataplex-types.global.generic",
                      Aspect.newBuilder()
                          .setAspectType(
                              "projects/dataplex-types/locations/global/aspectTypes/generic")
                          .setData(
                              Struct.newBuilder()
                                  // "Generic" Aspect Type have fields called "type" and "system.
                                  // The values below are a sample of possible options.
                                  .putFields(
                                      "type",
                                      Value.newBuilder()
                                          .setStringValue("updated example value")
                                          .build())
                                  .putFields(
                                      "system",
                                      Value.newBuilder()
                                          .setStringValue("updated example system")
                                          .build())
                                  .build())
                          .build()))
              .build();

      // Update mask specifies which fields will be updated.
      // For more information on update masks, see: https://google.aip.dev/161
      FieldMask updateMask =
          FieldMask.newBuilder().addPaths("aspects").addPaths("entry_source.description").build();
      return client.updateEntry(entry, updateMask);
    }
  }
}

Python

Python

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Python 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Python API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

from google.cloud import dataplex_v1
from google.protobuf import struct_pb2


def update_entry(
    project_id: str, location: str, entry_group_id: str, entry_id: str
) -> dataplex_v1.Entry:
    """Method to update Entry located in project_id, location, entry_group_id and with entry_id"""

    # Initialize client that will be used to send requests across threads. This
    # client only needs to be created once, and can be reused for multiple requests.
    # After completing all of your requests, call the "__exit__()" method to safely
    # clean up any remaining background resources. Alternatively, use the client as
    # a context manager.
    with dataplex_v1.CatalogServiceClient() as client:
        # The resource name of the Entry
        name = f"projects/{project_id}/locations/{location}/entryGroups/{entry_group_id}/entries/{entry_id}"
        entry = dataplex_v1.Entry(
            name=name,
            entry_source=dataplex_v1.EntrySource(
                description="updated description of the entry"
            ),
            aspects={
                "dataplex-types.global.generic": dataplex_v1.Aspect(
                    aspect_type="projects/dataplex-types/locations/global/aspectTypes/generic",
                    data=struct_pb2.Struct(
                        fields={
                            # "Generic" Aspect Type have fields called "type" and "system.
                            # The values below are a sample of possible options.
                            "type": struct_pb2.Value(
                                string_value="updated example value"
                            ),
                            "system": struct_pb2.Value(
                                string_value="updated example system"
                            ),
                        }
                    ),
                )
            },
        )

        # Update mask specifies which fields will be updated.
        # For more information on update masks, see: https://google.aip.dev/161
        update_mask = {"paths": ["aspects", "entry_source.description"]}
        return client.update_entry(entry=entry, update_mask=update_mask)


if __name__ == "__main__":
    # TODO(developer): Replace these variables before running the sample.
    project_id = "MY_PROJECT_ID"
    # Available locations: https://cloud.google.com/dataplex/docs/locations
    location = "MY_LOCATION"
    entry_group_id = "MY_ENTRY_GROUP_ID"
    entry_id = "MY_ENTRY_ID"

    updated_entry = update_entry(project_id, location, entry_group_id, entry_id)
    print(f"Successfully updated entry: {updated_entry.name}")

Ruby

Ruby

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Ruby 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Ruby API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

require "google/cloud/dataplex/v1"

##
# Snippet for the update_entry call in the CatalogService service
#
# 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/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::CatalogService::Client#update_entry.
#
def update_entry
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::CatalogService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::UpdateEntryRequest.new

  # Call the update_entry method.
  result = client.update_entry request

  # The returned object is of type Google::Cloud::Dataplex::V1::Entry.
  p result
end

如需向条目对象添加切面,请参阅 #required_aspects=

REST

如需向条目或条目列添加切面,请使用 entry.patch 方法。

不支持在条目中创建和使用切面,因为相应的切面类型和条目位于不同的 Google Cloud 组织中。

管理条目的现有切面

本部分介绍了如何更新和删除条目的现有切面。

更新切面

您可以修改自定义条目和系统条目的可选切面。您只能修改自定义条目的必需切面。

控制台

  1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 搜索页面。

    转到搜索

  2. 对于选择搜索平台,选择 Dataplex Universal Catalog 作为搜索模式。

  3. 搜索要更新其切面的条目,然后点击该条目。

    系统会打开条目详情页面。

  4. 点击详情标签页。

  5. 标记和切面部分中,展开要更新的切面或标记,然后点击 修改

  6. 修改切面窗口中,更新必填字段。

  7. 点击保存

gcloud

如需更新条目或条目列的切面,请使用 gcloud dataplex entries update 命令

C#

C#

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 C# 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog C# API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

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

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for UpdateEntry</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 UpdateEntryRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        UpdateEntryRequest request = new UpdateEntryRequest
        {
            Entry = new Entry(),
            UpdateMask = new FieldMask(),
            AllowMissing = false,
            DeleteMissingAspects = false,
            AspectKeys = { "", },
        };
        // Make the request
        Entry response = catalogServiceClient.UpdateEntry(request);
    }
}

Go

Go

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Go 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Go API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证


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.UpdateEntryRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#UpdateEntryRequest.
	}
	resp, err := c.UpdateEntry(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

Java

Java

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Java 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Java API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.Entry;
import com.google.cloud.dataplex.v1.UpdateEntryRequest;
import com.google.protobuf.FieldMask;
import java.util.ArrayList;

public class SyncUpdateEntry {

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

  public static void syncUpdateEntry() 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()) {
      UpdateEntryRequest request =
          UpdateEntryRequest.newBuilder()
              .setEntry(Entry.newBuilder().build())
              .setUpdateMask(FieldMask.newBuilder().build())
              .setAllowMissing(true)
              .setDeleteMissingAspects(true)
              .addAllAspectKeys(new ArrayList<String>())
              .build();
      Entry response = catalogServiceClient.updateEntry(request);
    }
  }
}

Python

Python

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Python 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Python API 参考文档

如需向 Dataplex Universal 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_entry():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    entry = dataplex_v1.Entry()
    entry.entry_type = "entry_type_value"

    request = dataplex_v1.UpdateEntryRequest(
        entry=entry,
    )

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

    # Handle the response
    print(response)

Ruby

Ruby

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Ruby 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Ruby API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

require "google/cloud/dataplex/v1"

##
# Snippet for the update_entry call in the CatalogService service
#
# 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/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::CatalogService::Client#update_entry.
#
def update_entry
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::CatalogService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::UpdateEntryRequest.new

  # Call the update_entry method.
  result = client.update_entry request

  # The returned object is of type Google::Cloud::Dataplex::V1::Entry.
  p result
end

REST

如需更新条目或条目列的切面,请使用 entry.patch 方法。

删除切面

控制台

  1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 搜索页面。

    转到搜索

  2. 对于选择搜索平台,选择 Dataplex Universal Catalog 作为搜索模式。

  3. 搜索要删除其切面的条目,然后点击该条目。

    系统会打开条目详情页面。

  4. 点击详情标签页。

  5. 标记和切面部分中,展开要删除的切面或标记,然后点击 删除

  6. 点击确认

gcloud

如需删除条目的切面,请使用 gcloud dataplex entries update 命令

C#

C#

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 C# 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog C# API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

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

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for UpdateEntry</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 UpdateEntryRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        UpdateEntryRequest request = new UpdateEntryRequest
        {
            Entry = new Entry(),
            UpdateMask = new FieldMask(),
            AllowMissing = false,
            DeleteMissingAspects = false,
            AspectKeys = { "", },
        };
        // Make the request
        Entry response = catalogServiceClient.UpdateEntry(request);
    }
}

Go

Go

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Go 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Go API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证


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.UpdateEntryRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#UpdateEntryRequest.
	}
	resp, err := c.UpdateEntry(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

Java

Java

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Java 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Java API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.Entry;
import com.google.cloud.dataplex.v1.UpdateEntryRequest;
import com.google.protobuf.FieldMask;
import java.util.ArrayList;

public class SyncUpdateEntry {

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

  public static void syncUpdateEntry() 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()) {
      UpdateEntryRequest request =
          UpdateEntryRequest.newBuilder()
              .setEntry(Entry.newBuilder().build())
              .setUpdateMask(FieldMask.newBuilder().build())
              .setAllowMissing(true)
              .setDeleteMissingAspects(true)
              .addAllAspectKeys(new ArrayList<String>())
              .build();
      Entry response = catalogServiceClient.updateEntry(request);
    }
  }
}

Python

Python

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Python 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Python API 参考文档

如需向 Dataplex Universal 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_entry():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    entry = dataplex_v1.Entry()
    entry.entry_type = "entry_type_value"

    request = dataplex_v1.UpdateEntryRequest(
        entry=entry,
    )

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

    # Handle the response
    print(response)

Ruby

Ruby

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Ruby 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Ruby API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

require "google/cloud/dataplex/v1"

##
# Snippet for the update_entry call in the CatalogService service
#
# 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/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::CatalogService::Client#update_entry.
#
def update_entry
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::CatalogService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::UpdateEntryRequest.new

  # Call the update_entry method.
  result = client.update_entry request

  # The returned object is of type Google::Cloud::Dataplex::V1::Entry.
  p result
end

REST

如需删除条目的切面,请使用 entry.patch 方法。

管理切面类型

本部分介绍了如何查看、更新和删除切面类型。

查看可用切面类型和标记模板的列表

控制台

  1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 目录页面。

    前往“目录”

  2. 点击切面类型和标记模板标签页。

    此页面列出了所有可用的 Dataplex Universal Catalog 切面类型和 Data Catalog 标记模板。

  3. 如需查看自定义切面类型和标记模板,请点击自定义标签页。在自定义标签页中,目录来源列会显示资源所在的位置,即 Dataplex Universal Catalog 或 Data Catalog。

    如需查看系统切面类型,请点击系统标签页。

    如需详细了解自定义切面类型和系统切面类型,请参阅本文档的切面类型的类别部分。

  4. 可选:如需查看所选项目中的切面类型和标记模板列表,请点击自定义标签页,然后点击显示所有项目中的切面类型切换开关,将其切换到关闭位置。

    显示所有项目中的切面类型切换开关默认处于开启状态,并且该列表包含所选组织中的 Dataplex Universal Catalog 资源以及您可以访问的所有组织中的 Data Catalog 资源。

gcloud

如需列出所有可用的切面类型,请使用 gcloud dataplex aspect-types list 命令

C#

C#

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 C# 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog C# API 参考文档

如需向 Dataplex Universal 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 ListAspectTypes</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 ListAspectTypesRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        ListAspectTypesRequest request = new ListAspectTypesRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            Filter = "",
            OrderBy = "",
        };
        // Make the request
        PagedEnumerable<ListAspectTypesResponse, AspectType> response = catalogServiceClient.ListAspectTypes(request);

        // Iterate over all response items, lazily performing RPCs as required
        foreach (AspectType 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 (ListAspectTypesResponse page in response.AsRawResponses())
        {
            // Do something with each page of items
            Console.WriteLine("A page of results:");
            foreach (AspectType 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<AspectType> 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 (AspectType 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

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Go 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Go API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证


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.ListAspectTypesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#ListAspectTypesRequest.
	}
	it := c.ListAspectTypes(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.ListAspectTypesResponse)
	}
}

Java

Java

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Java 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Java API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

import com.google.cloud.dataplex.v1.AspectType;
import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.ListAspectTypesRequest;
import com.google.cloud.dataplex.v1.LocationName;

public class SyncListAspectTypes {

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

  public static void syncListAspectTypes() 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()) {
      ListAspectTypesRequest request =
          ListAspectTypesRequest.newBuilder()
              .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .setPageSize(883849137)
              .setPageToken("pageToken873572522")
              .setFilter("filter-1274492040")
              .setOrderBy("orderBy-1207110587")
              .build();
      for (AspectType element : catalogServiceClient.listAspectTypes(request).iterateAll()) {
        // doThingsWith(element);
      }
    }
  }
}

Python

Python

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Python 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Python API 参考文档

如需向 Dataplex Universal 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_aspect_types():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

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

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

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

Ruby

Ruby

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Ruby 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Ruby API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

require "google/cloud/dataplex/v1"

##
# Snippet for the list_aspect_types call in the CatalogService service
#
# 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/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::CatalogService::Client#list_aspect_types.
#
def list_aspect_types
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::CatalogService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::ListAspectTypesRequest.new

  # Call the list_aspect_types method.
  result = client.list_aspect_types request

  # The returned object is of type Gapic::PagedEnumerable. You can iterate
  # over elements, and API calls will be issued to fetch pages as needed.
  result.each do |item|
    # Each element is of type ::Google::Cloud::Dataplex::V1::AspectType.
    p item
  end
end

REST

如需列出所有可用的切面类型,请使用 aspectTypes.list 方法。

查看切面类型或标记模板的详细信息

控制台

  1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 目录页面。

    前往“目录”

  2. 点击切面类型和标记模板标签页。

  3. 如需查看 Dataplex Universal Catalog 切面类型的详细信息,请点击该切面类型。系统会打开切面类型详细信息页面,您可以在其中查看显示名称、切面类型 ID、说明、项目 ID、位置、标签、创建日期和上次修改日期等详细信息。

    • 如需查看所选切面类型的结构,请点击模板标签页。
    • 如需查看最近创建的 10 个相关条目的列表,请点击示例条目标签页。
    • 如需搜索所有相关条目,请点击在搜索结果中显示所有相关条目。仅当至少存在一个相关条目时,才会显示此按钮。
  4. 如需查看 Data Catalog 标记模板的详细信息,请点击该标记模板。Data Catalog 中会打开标记模板详细信息页面,您可以在其中查看显示名称、模板 ID、项目 ID、位置、可见性和标签等详细信息。

gcloud

如需获取切面类型的详细信息,请使用 gcloud dataplex aspect-types describe 命令

C#

C#

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 C# 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog C# API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

using Google.Cloud.Dataplex.V1;

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for GetAspectType</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 GetAspectTypeRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        GetAspectTypeRequest request = new GetAspectTypeRequest
        {
            AspectTypeName = AspectTypeName.FromProjectLocationAspectType("[PROJECT]", "[LOCATION]", "[ASPECT_TYPE]"),
        };
        // Make the request
        AspectType response = catalogServiceClient.GetAspectType(request);
    }
}

Go

Go

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Go 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Go API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证


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.GetAspectTypeRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#GetAspectTypeRequest.
	}
	resp, err := c.GetAspectType(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

Java

Java

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Java 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Java API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

import com.google.cloud.dataplex.v1.AspectType;
import com.google.cloud.dataplex.v1.AspectTypeName;
import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.GetAspectTypeRequest;

public class SyncGetAspectType {

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

  public static void syncGetAspectType() 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()) {
      GetAspectTypeRequest request =
          GetAspectTypeRequest.newBuilder()
              .setName(AspectTypeName.of("[PROJECT]", "[LOCATION]", "[ASPECT_TYPE]").toString())
              .build();
      AspectType response = catalogServiceClient.getAspectType(request);
    }
  }
}

Python

Python

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Python 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Python API 参考文档

如需向 Dataplex Universal 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_aspect_type():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

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

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

    # Handle the response
    print(response)

Ruby

Ruby

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Ruby 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Ruby API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

require "google/cloud/dataplex/v1"

##
# Snippet for the get_aspect_type call in the CatalogService service
#
# 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/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::CatalogService::Client#get_aspect_type.
#
def get_aspect_type
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::CatalogService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::GetAspectTypeRequest.new

  # Call the get_aspect_type method.
  result = client.get_aspect_type request

  # The returned object is of type Google::Cloud::Dataplex::V1::AspectType.
  p result
end

REST

如需获取切面类型的详细信息,请使用 aspectTypes.get 方法。

更新自定义切面类型

您可以更新自定义切面类型的显示名称、说明、模板字段和标签。您无法删除模板中的现有字段。

创建切面类型后,您无法更新切面类型 ID 和位置。

控制台

  1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 目录页面。

    前往“目录”

  2. 点击切面类型和标记模板标签页。

  3. 点击要更新的切面类型。

  4. 切面类型详细信息页面上,点击修改

  5. 根据需要修改显示名称、说明、模板字段和标签。

  6. 可选:如需将切面类型中的某个字段标记为已弃用,请按照以下步骤操作:

    1. 模板部分,展开相应字段。
    2. 选择已弃用
    3. 弃用原因字段中,输入弃用所选字段的原因。
    4. 点击完成
  7. 点击保存

gcloud

如需更新自定义切面类型,请使用 gcloud dataplex aspect-types update 命令

C#

C#

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 C# 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog C# API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

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

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for UpdateAspectType</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 UpdateAspectTypeRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        UpdateAspectTypeRequest request = new UpdateAspectTypeRequest
        {
            AspectType = new AspectType(),
            UpdateMask = new FieldMask(),
            ValidateOnly = false,
        };
        // Make the request
        Operation<AspectType, OperationMetadata> response = catalogServiceClient.UpdateAspectType(request);

        // Poll until the returned long-running operation is complete
        Operation<AspectType, OperationMetadata> completedResponse = response.PollUntilCompleted();
        // Retrieve the operation result
        AspectType 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<AspectType, OperationMetadata> retrievedResponse = catalogServiceClient.PollOnceUpdateAspectType(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            AspectType retrievedResult = retrievedResponse.Result;
        }
    }
}

Go

Go

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Go 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Go API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证


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.UpdateAspectTypeRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#UpdateAspectTypeRequest.
	}
	op, err := c.UpdateAspectType(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

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

Java

Java

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Java 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Java API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

import com.google.cloud.dataplex.v1.AspectType;
import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.UpdateAspectTypeRequest;
import com.google.protobuf.FieldMask;

public class SyncUpdateAspectType {

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

  public static void syncUpdateAspectType() 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()) {
      UpdateAspectTypeRequest request =
          UpdateAspectTypeRequest.newBuilder()
              .setAspectType(AspectType.newBuilder().build())
              .setUpdateMask(FieldMask.newBuilder().build())
              .setValidateOnly(true)
              .build();
      AspectType response = catalogServiceClient.updateAspectTypeAsync(request).get();
    }
  }
}

Python

Python

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Python 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Python API 参考文档

如需向 Dataplex Universal 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_aspect_type():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    aspect_type = dataplex_v1.AspectType()
    aspect_type.metadata_template.name = "name_value"
    aspect_type.metadata_template.type_ = "type__value"

    request = dataplex_v1.UpdateAspectTypeRequest(
        aspect_type=aspect_type,
    )

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

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

    response = operation.result()

    # Handle the response
    print(response)

Ruby

Ruby

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Ruby 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Ruby API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

require "google/cloud/dataplex/v1"

##
# Snippet for the update_aspect_type call in the CatalogService service
#
# 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/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::CatalogService::Client#update_aspect_type.
#
def update_aspect_type
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::CatalogService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::UpdateAspectTypeRequest.new

  # Call the update_aspect_type method.
  result = client.update_aspect_type request

  # The returned object is of type Gapic::Operation. You can use it to
  # check the status of an operation, cancel it, or wait for results.
  # Here is how to wait for a response.
  result.wait_until_done! timeout: 60
  if result.response?
    p result.response
  else
    puts "No response received."
  end
end

REST

如需更新自定义切面类型,请使用 aspectTypes.patch 方法。

删除自定义切面类型

控制台

  1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 目录页面。

    前往“目录”

  2. 点击切面类型和标记模板标签页。

  3. 点击要删除的切面类型。

  4. 切面类型详细信息页面上,点击删除。在系统提示时确认。

gcloud

如需删除自定义切面类型,请使用 gcloud dataplex aspect-types delete 命令

C#

C#

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 C# 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog C# API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

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

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for DeleteAspectType</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 DeleteAspectTypeRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        DeleteAspectTypeRequest request = new DeleteAspectTypeRequest
        {
            AspectTypeName = AspectTypeName.FromProjectLocationAspectType("[PROJECT]", "[LOCATION]", "[ASPECT_TYPE]"),
            Etag = "",
        };
        // Make the request
        Operation<Empty, OperationMetadata> response = catalogServiceClient.DeleteAspectType(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.PollOnceDeleteAspectType(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

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Go 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Go API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证


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.DeleteAspectTypeRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#DeleteAspectTypeRequest.
	}
	op, err := c.DeleteAspectType(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

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

Java

Java

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Java 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Java API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

import com.google.cloud.dataplex.v1.AspectTypeName;
import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.DeleteAspectTypeRequest;
import com.google.protobuf.Empty;

public class SyncDeleteAspectType {

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

  public static void syncDeleteAspectType() 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()) {
      DeleteAspectTypeRequest request =
          DeleteAspectTypeRequest.newBuilder()
              .setName(AspectTypeName.of("[PROJECT]", "[LOCATION]", "[ASPECT_TYPE]").toString())
              .setEtag("etag3123477")
              .build();
      catalogServiceClient.deleteAspectTypeAsync(request).get();
    }
  }
}

Python

Python

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Python 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Python API 参考文档

如需向 Dataplex Universal 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_aspect_type():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

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

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

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

    response = operation.result()

    # Handle the response
    print(response)

Ruby

Ruby

在尝试此示例之前,请按照 Dataplex Universal Catalog 快速入门:使用客户端库中的 Ruby 设置说明进行操作。如需了解详情,请参阅 Dataplex Universal Catalog Ruby API 参考文档

如需向 Dataplex Universal Catalog 进行身份验证,请设置应用默认凭证。如需了解详情,请参阅为本地开发环境设置身份验证

require "google/cloud/dataplex/v1"

##
# Snippet for the delete_aspect_type call in the CatalogService service
#
# 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/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::CatalogService::Client#delete_aspect_type.
#
def delete_aspect_type
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::CatalogService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::DeleteAspectTypeRequest.new

  # Call the delete_aspect_type method.
  result = client.delete_aspect_type request

  # The returned object is of type Gapic::Operation. You can use it to
  # check the status of an operation, cancel it, or wait for results.
  # Here is how to wait for a response.
  result.wait_until_done! timeout: 60
  if result.response?
    p result.response
  else
    puts "No response received."
  end
end

REST

如需删除现有的自定义切面类型,请使用 aspectTypes.delete 方法。

后续步骤