Manage aspects and enrich metadata

Aspects and aspect types in Knowledge Catalog (formerly Dataplex Universal Catalog) let you add structured metadata to entries, columns, and entry links to describe your data assets and their relationships. This context improves data discoverability and helps you classify sensitive information, such as personally identifiable information (PII), to apply data quality or access policies.

For conceptual information about aspect schemas, system versus custom aspect types, target levels, and data residency constraints, see About aspects and aspect types. For an architectural overview of the entire metadata metamodel, see About metadata in Knowledge Catalog. If this is your first time working with Knowledge Catalog metadata, see the Add metadata to a BigQuery table or Create and use a business glossary quickstarts.

Before you begin

Before you create and manage aspect types and aspects, complete the tasks described in this section.

Required roles

To get the permissions that you need to create and manage aspect types and aspects, ask your administrator to grant you the following IAM roles on the project. You don't need all of these roles simultaneously; choose the role or combination that matches your specific workflow:

To get the permissions that you need to create and manage aspect types and aspects, ask your administrator to grant you the following IAM roles on the project:

  • To manage all catalog resources, including aspect types and entries, with broad administrator access: Dataplex Catalog Admin (roles/dataplex.catalogAdmin) or Dataplex Catalog Editor (roles/dataplex.catalogEditor)
  • To create and manage custom aspect types only, with least-privilege access for aspect type administrators: Dataplex Aspect Type Owner (roles/dataplex.aspectTypeOwner)
  • To use aspect types when creating or modifying entries, with least-privilege access for data curators: Dataplex Aspect Type User (roles/dataplex.aspectTypeUser)
  • To attach reusable system aspect types, such as schema, contacts, and overview, to entries and entry links: Dataplex Entry and EntryLink Owner (roles/dataplex.entryOwner)
  • To view aspect types and their IAM policies without modifying them: Dataplex Catalog Viewer (roles/dataplex.catalogViewer)

For more information about granting roles, see Manage access to projects, folders, and organizations.

These predefined roles contain the permissions required to create and manage aspect types and aspects. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to create and manage aspect types and aspects:

  • Create, view, list, update, and delete aspect types:
    • dataplex.aspectTypes.create
    • dataplex.aspectTypes.get
    • dataplex.aspectTypes.list
    • dataplex.aspectTypes.update
    • dataplex.aspectTypes.delete
  • Use aspect types to enrich entries: dataplex.aspectTypes.use
  • Create, view, update, and delete entries and their aspects:
    • dataplex.entries.create
    • dataplex.entries.get
    • dataplex.entries.list
    • dataplex.entries.update
    • dataplex.entries.delete
  • Create, view, update, and delete entry links and their aspects:
    • dataplex.entryLinks.create
    • dataplex.entryLinks.get
    • dataplex.entryLinks.list
    • dataplex.entryLinks.update
    • dataplex.entryLinks.delete

You might also be able to get these permissions with custom roles or other predefined roles.

For more information, see Knowledge Catalog IAM roles.

Enable the API

Enable the Dataplex API in your Knowledge Catalog project. If you are using a new Google Cloud project or a project in which the BigQuery API is enabled, the Dataplex API is enabled by default.

Enable the API

Create a custom aspect type

Console

To create a custom aspect type in the Google Cloud console, follow these subtasks:

  1. Configure basic details:

    1. In the Google Cloud console, go to the Knowledge Catalog Metadata types page.

      Go to Metadata types

    2. Click the Aspect types > Custom tab, and then click Create aspect type.

    3. In the Details section, enter the following:

      • Optional: Display name: A user-friendly name for the aspect type.
      • Aspect type ID: A unique identifier for the aspect type.
      • Optional: Description: A description of the aspect type and its purpose.
      • Location: Select a location for the aspect type. You can't modify the location after creation. For guidance on global versus regional location tradeoffs, see Custom aspect types.
  2. Define the schema template:

    The template defines the format and schema of the metadata fields grouped within your aspect type. You can define fields manually or accelerate schema creation by selecting a starter template from the Template gallery, such as Data Sensitivity, Data Governance, or Data Ingestion. For example, selecting the Data Sensitivity template automatically adds the boolean fields Is Encrypted and Has PII, and the enum field PII Type.

    To define fields manually:

    1. In the Template section, click Add field.
    2. In the New field panel, specify the following:
      • Name: An identifier for the field.
      • Optional: Display name: A user-friendly label.
      • Optional: Description: A brief description of the field.
      • Type: Select the field data type. Supported types include Text, Integer, Boolean, Date and Time, Double, Enum, Array, Map, and Record.
      • Optional: Is required: Select this checkbox to make the field mandatory when users attach this aspect.
    3. Click Done. To add more fields, click Add field and repeat these steps.
  3. Add resource labels and save:

    Resource labels are arbitrary key-value pairs that help you organize and filter your Google Cloud resources. For example, you can organize resources by environment or team ownership using labels such as environment: production or team: analytics.

    1. In the Labels section, click Add label.
    2. Enter the label Key and Value.
    3. Click Save.

gcloud

To create a custom aspect type, use the gcloud dataplex aspect-types create command.

C#

C#

Before trying this sample, follow the C# setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog C# API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

Before trying this sample, follow the Go setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Go API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


//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.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

Before trying this sample, follow the Java setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Java API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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();
    }
  }
}

Node.js

Node.js

Before trying this sample, follow the Node.js setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Node.js API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * 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 AspectType, of the form:
 *  projects/{project_number}/locations/{location_id}
 *  where `location_id` refers to a Google Cloud region.
 */
// const parent = 'abc123'
/**
 *  Required. AspectType identifier.
 */
// const aspectTypeId = 'abc123'
/**
 *  Required. AspectType Resource.
 */
// const aspectType = {}
/**
 *  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 callCreateAspectType() {
  // Construct request
  const request = {
    parent,
    aspectTypeId,
    aspectType,
  };

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

callCreateAspectType();

Python

Python

Before trying this sample, follow the Python setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Python API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# 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

Before trying this sample, follow the Ruby setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Ruby API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

To create a custom aspect type, use the aspectType.create method.

After you create a custom aspect type, you can add aspects to entries.

Example for using the Record ID and Record reference fields

You can use the Record ID and Record reference fields for recursive references. The following example shows how to use these fields:

Consider an aspect type called Employee, with the following fields:

  • Name (type: Text)
  • Start date (type: Date & time)
  • Designation (type: Text)
  • Current address (type: Record)
  • Permanent address (type: Record)

The two address fields Current address and Permanent address are of the same data type Record. To avoid duplication, you can set the Record ID and Record reference values when defining these fields.

When you define the field Current address, you can specify Record ID as address-field. For Permanent address, you can specify the same value (address-field) for Record reference. For example:

  • Name (type: Text)
  • Start date (type: Date & time)
  • Designation (type: Text)
  • Current address (type: Record, Record ID: address-field)
  • Permanent address (type: Record, Record reference: address-field)

This way, you don't need to duplicate the fields of another address.

Add aspects to an entry

After you create a custom aspect type, you can create aspects of that type. To add aspects to an entry, you must update the entry, as aspects are stored within entries.

Note the following limitations:

  • You can add aspects to an entry or to the columns of an entry.
  • You can edit the required aspects only for custom entries. You can't delete the required aspects.
  • You can edit and delete the optional aspects for both custom entries and system entries.
  • When you replace or reload a BigQuery table using a CREATE OR REPLACE TABLE statement, a TRUNCATE TABLE statement, or a WRITE_TRUNCATE job, Knowledge Catalog preserves the entry's user-attached aspects. Column-level aspects are also preserved for columns that remain in the schema. However, if you drop and recreate a table using a DROP TABLE statement and a CREATE TABLE statement, Knowledge Catalog creates a new entry without the original table's user-attached aspects. To keep aspects when reloading a table, use CREATE OR REPLACE TABLE, TRUNCATE TABLE, or WRITE_TRUNCATE. Alternatively, you can create a BigQuery view and attach aspects to the view.

Console

  1. In the Google Cloud console, go to the Knowledge Catalog Search page.

    Go to Search

  2. Search for the entry that you want to add aspects to, and click the entry. The entry details page opens.

  3. On the entry details page, click the Details tab.

  4. In the Aspects section, click Add in the Required aspects or Optional aspects area. You can add required aspects only if the entry type defines required aspects.

  5. Search for and select the aspect that you want to add.

  6. In the Add aspect window, enter the values for the fields.

  7. Click Save.

To add aspects to a column of the entry:

  1. On the entry details page, click the Schema tab.
  2. Select the columns to which you want to add aspects.
  3. Click Add aspect.
  4. Search for and select the aspect that you want to add.
  5. In the Add aspect window, enter the values for the fields.
  6. Click Save.

gcloud

To add aspects to an entry or to a column of an entry, use the gcloud dataplex entries update command.

C#

C#

Before trying this sample, follow the C# setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog C# API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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);
    }
}

To add aspects to the entry object, see Aspects.

Go

Go

Before trying this sample, follow the Go setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Go API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


//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.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
}

To add aspects to the entry object, see Entry.

Java

Java

Before trying this sample, follow the Java setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Java API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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);
    }
  }
}

Node.js

Node.js

Before trying this sample, follow the Node.js setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Node.js API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * 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. Entry resource.
 */
// const entry = {}
/**
 *  Optional. Mask of fields to update. To update Aspects, the update_mask must
 *  contain the value "aspects".
 *  If the update_mask is empty, the service will update all modifiable fields
 *  present in the request.
 */
// const updateMask = {}
/**
 *  Optional. If set to true and the entry doesn't exist, the service will
 *  create it.
 */
// const allowMissing = true
/**
 *  Optional. If set to true and the aspect_keys specify aspect ranges, the
 *  service deletes any existing aspects from that range that weren't provided
 *  in the request.
 */
// const deleteMissingAspects = true
/**
 *  Optional. The map keys of the Aspects which the service should modify. It
 *  supports the following syntaxes:
 *  * `<aspect_type_reference>` - matches an aspect of the given type and empty
 *  path.
 *  * `<aspect_type_reference>@path` - matches an aspect of the given type and
 *  specified path. For example, to attach an aspect to a field that is
 *  specified by the `schema` aspect, the path should have the format
 *  `Schema.<field_name>`.
 *  * `<aspect_type_reference>@*` - matches aspects of the given type for all
 *  paths.
 *  * `*@path` - matches aspects of all types on the given path.
 *  The service will not remove existing aspects matching the syntax unless
 *  `delete_missing_aspects` is set to true.
 *  If this field is left empty, the service treats it as specifying
 *  exactly those Aspects present in the request.
 */
// const aspectKeys = ['abc','def']

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

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

async function callUpdateEntry() {
  // Construct request
  const request = {
    entry,
  };

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

callUpdateEntry();

Python

Python

Before trying this sample, follow the Python setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Python API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

Before trying this sample, follow the Ruby setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Ruby API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

To add aspects to the entry object, see #required_aspects=.

REST

To add aspects to an entry or to a column of an entry, use the entry.patch method.

Creating and using aspects in an entry where the respective aspect type and the entry are in different Google Cloud organizations isn't supported.

Attach aspects of reusable system aspect types

Knowledge Catalog provides predefined system aspect types that you can attach to entries to capture standardized metadata. For example, you can use these aspect types to record ownership contacts, schema definitions, usage metrics, and data quality results.

General workflow and payload rules

When attaching aspects of reusable system aspect types, follow these rules:

  • Console versus CLI/REST: For aspect types without nested fields, such as generic, you can use the Google Cloud console, the gcloud CLI, or the REST API. For aspect types with complex or nested structures, such as data-quality-scorecard, contacts, or data-profile, you must use the gcloud CLI or the REST API.
  • Payload structure:
    • gcloud CLI: Pass the aspect map directly, keyed by the global aspect type identifier: {"dataplex-types.global.<ASPECT_TYPE>": {"data": { ... }}}.
    • REST API: Wrap the aspect map inside an "aspects" container object: {"aspects": {"dataplex-types.global.<ASPECT_TYPE>": {"data": { ... }}}}.
  • Overwrite behavior: Updating an aspect replaces any existing data for that specific aspect type on the target entry or column; it does not merge fields.

The following sections provide examples and schemas for attaching common reusable system aspects, beginning with the data quality scorecard.

Data quality scorecard

A data quality scorecard is an aspect that provides a summary of data quality, often based on data quality scans or other processes. You can attach a data quality scorecard to an entry to provide custom data quality information. To do so, attach an aspect of the system-defined type data-quality-scorecard.

The data field within the data-quality-scorecard aspect can include the following fields:

  • job: Optional. A record containing details about the job that generated the scorecard.

    • name: The resource name of the data quality job.

    • runTime: The run time of the data quality job.

  • score: Optional. The overall data quality score. The score ranges between [0, 100].

  • status: Required. The status of the data quality scorecard, indicating if it passed or failed the quality threshold (PASS or FAIL).

  • dimensions: Optional. An array of dimension results. Each result includes:

    • name: The name of the dimension. This can be one of ACCURACY, COMPLETENESS, CONSISTENCY, FRESHNESS, UNIQUENESS, VALIDITY, or VOLUME, or a custom dimension name. Custom dimension names must use uppercase letters and be 30 characters or less.

    • score: The overall dimension-level score, ranging from [0, 100].

    • status: The status of the dimension, indicating if it passed or failed the quality threshold (PASS or FAIL).

  • columns: Optional. An array of column results. Each result includes:

    • name: The name of the column.

    • score: The overall column-level score, ranging from [0, 100].

    • status: The status of the column, indicating if it passed or failed the quality threshold (PASS or FAIL).

    • dimensions: An array of dimension scores for the column. Each dimension score includes:

      • name: The name of the dimension.

      • score: The score for the dimension, ranging from [0, 100].

      • status: The status of the dimension for the column, indicating if it passed or failed the quality threshold (PASS, FAIL, UNKNOWN, or NOT_APPLICABLE).

    • details (optional map): Key-value pairs providing additional context about the evaluation.

    • evaluatedAssetCount (optional integer): The number of assets evaluated.

When you run the command to attach an aspect, it replaces any existing data for that specific aspect. For example, if you update a scorecard that has a score of 80 with a new file showing a score of 90, the 80 is overwritten. It does not merge the data.

To attach a data quality scorecard, follow these steps:

gcloud

To update aspects for an entry, use the gcloud dataplex entries update-aspects command.

  1. Create a JSON file (dq-aspect.json) with the following content.

    {
      "dataplex-types.global.data-quality-scorecard": {
        "data": {
          "score": 80,
          "status": "PASS",
          "dimensions": [
            {
              "name": "completeness",
              "score": 90,
              "status": "PASS"
            },
            {
              "name": "uniqueness",
              "score": 70,
              "status": "FAIL"
            }
          ],
          "columns": [
            {
              "name": "col1",
              "score": 85,
              "status": "PASS"
            }
          ]
        }
      }
    }
    
  2. Run the following command:

      gcloud dataplex entries update-aspects ENTRY_ID \
      --location=LOCATION \
      --entry-group=ENTRY_GROUP_ID \
      --project=PROJECT_ID \
      --aspects=dq-aspect.json
    

    Replace the following variables:

    • ENTRY_ID: the ID of the entry—for example, example-entry
    • LOCATION: the location of the entry—for example, us-central1
    • ENTRY_GROUP_ID: the ID of the entry group—for example, example-entry-group
    • PROJECT_ID: the ID of the project—for example, example-project

REST

To update aspects for an entry, use the entry.patch method.

  1. Create a file named payload.json and paste the JSON content from your request into it.

    
      {
        "aspects": {
          "dataplex-types.global.data-quality-scorecard": {
            "data": {
              "score": 80,
              "status": "PASS",
              "dimensions": [
                {
                  "name": "completeness",
                  "score": 90,
                  "status": "PASS"
                },
                {
                  "name": "uniqueness",
                  "score": 70,
                  "status": "FAIL"
                }
              ],
              "columns": [
                {
                  "name": "col1",
                  "score": 85,
                  "status": "PASS"
                }
              ]
            }
          }
        }
      }
    
  2. Run this command in your terminal:

     curl -X PATCH \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json" \
     -d @payload.json \
     "https://dataplex.googleapis.com/v1/projects/<var>PROJECT_ID</var>/locations/<var>LOCATION</var>/entryGroups/<var>ENTRY_GROUP_ID</var>/entries/<var>ENTRY_ID</var>?updateMask=aspects"
    

    Replace the following:

    • PROJECT_ID: the ID of the project—for example, example-project
    • LOCATION: the location of the entry—for example, us-central1
    • ENTRY_GROUP_ID: the ID of the entry group—for example, example-entry-group
    • ENTRY_ID: the ID of the entry—for example, example-entry

Other reusable aspect types

The following system aspect types are also available for entry enrichment. The frontloaded summaries are listed in the following sections. Click each expandable section to view field schemas and example JSON payloads.

Contacts (dataplex-types.global.contacts)

Use the contacts aspect type to assign ownership, stewardship, or operational roles to entries.

  • identities (array): A list of contacts. Each contact includes role (for example, owner, steward, producer, or admin), name, and id (email address).

Example payload (REST API):

{
  "aspects": {
    "dataplex-types.global.contacts": {
      "data": {
        "identities": [
          {
            "role": "steward",
            "name": "Jane Doe",
            "id": "jane.doe@example.com"
          }
        ]
      }
    }
  }
}
    

Data profile (dataplex-types.global.data-profile)

Use the data-profile aspect type to capture statistical profiling results generated from source data scans. For more information, see About data profiling.

  • sourceDataInfo (record): Metadata about the scan, including scope (PREVIEW, SAMPLED, or ALL), scannedRows, and samplingPercentage.
  • fields (map): Column-level statistics, including nullness, uniqueness, and type-specific metrics for numeric, string, datetime, and array columns.

Example payload (REST API):

{
  "aspects": {
    "dataplex-types.global.data-profile": {
      "data": {
        "sourceDataInfo": {
          "scope": "ALL",
          "scannedRows": 100
        },
        "fields": {
          "col1": {
            "nullness": 0.0,
            "uniqueness": 0.1,
            "string": {
              "length": {
                "min": 1,
                "max": 20,
                "avg": 12.54
              }
            }
          }
        }
      }
    }
  }
}
    

Generic (dataplex-types.global.generic)

Use the generic aspect type to capture freeform entry information and source system metadata without defining a custom aspect schema.

  • type (string): A user-specified entry categorization string.
  • system (string): The source system identifier of the custom entry.

Example payload (REST API):

{
  "aspects": {
    "dataplex-types.global.generic": {
      "data": {
        "type": "custom-type",
        "system": "custom-system"
      }
    }
  }
}
    

Overview (dataplex-types.global.overview)

Use the overview aspect type to provide human-readable rich text documentation and helpful external links.

  • content (string): Rich text description supporting HTML formatting.
  • links (array): External resources and documentation links, each containing url and title.

Example payload (REST API):

{
  "aspects": {
    "dataplex-types.global.overview": {
      "data": {
        "content": "This is a rich text description.",
        "links": [
          {
            "url": "https://example.com",
            "title": "Example Link"
          }
        ]
      }
    }
  }
}
    

Schema (dataplex-types.global.schema)

Use the schema aspect type to describe the tabular schema, column names, modes, and data types of data assets.

  • fields (array): List of columns, each containing name, dataType, metadataType (such as STRING, BOOLEAN), mode (NULLABLE, REQUIRED, REPEATED), and optional description.

Example payload (REST API):

{
  "aspects": {
    "dataplex-types.global.schema": {
      "data": {
        "fields": [
          {
            "name": "id",
            "dataType": "string",
            "metadataType": "STRING",
            "mode": "REQUIRED"
          }
        ]
      }
    }
  }
}
    

Usage (dataplex-types.global.usage)

Use the usage aspect type to track consumption metrics, view counts, and time-series query patterns.

  • metrics (array): Consumption metrics, each containing name (such as views or reads) and timeSeries data points with aggregation intervals and values.
  • refreshTime (datetime): Timestamp when usage metrics were last computed.

Example payload (REST API):

{
  "aspects": {
    "dataplex-types.global.usage": {
      "data": {
        "metrics": [
          {
            "name": "views",
            "timeSeries": [
              {
                "interval": "30d",
                "value": 100
              }
            ]
          }
        ],
        "refreshTime": "2025-01-01T12:00:00Z"
      }
    }
  }
}
    

Create an entry link

You can establish a relationship between two entries by creating an entry link.

An entry link can be symmetric such as a synonym or asymmetric such as a definition.

C#

Before trying this sample, follow the C# setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog C# API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

using Google.Cloud.Dataplex.V1;

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for CreateEntryLink</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 CreateEntryLinkRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        CreateEntryLinkRequest request = new CreateEntryLinkRequest
        {
            ParentAsEntryGroupName = EntryGroupName.FromProjectLocationEntryGroup("[PROJECT]", "[LOCATION]", "[ENTRY_GROUP]"),
            EntryLinkId = "",
            EntryLink = new EntryLink(),
        };
        // Make the request
        EntryLink response = catalogServiceClient.CreateEntryLink(request);
    }
}

Go

Before trying this sample, follow the Go setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Go API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


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

Java

Before trying this sample, follow the Java setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Java API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.CreateEntryLinkRequest;
import com.google.cloud.dataplex.v1.EntryGroupName;
import com.google.cloud.dataplex.v1.EntryLink;

public class SyncCreateEntryLink {

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

  public static void syncCreateEntryLink() 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()) {
      CreateEntryLinkRequest request =
          CreateEntryLinkRequest.newBuilder()
              .setParent(EntryGroupName.of("[PROJECT]", "[LOCATION]", "[ENTRY_GROUP]").toString())
              .setEntryLinkId("entryLinkId-1349584441")
              .setEntryLink(EntryLink.newBuilder().build())
              .build();
      EntryLink response = catalogServiceClient.createEntryLink(request);
    }
  }
}

Node.js

Before trying this sample, follow the Node.js setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Node.js API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * 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 Entry Group:
 *  `projects/{project_id_or_number}/locations/{location_id}/entryGroups/{entry_group_id}`.
 */
// const parent = 'abc123'
/**
 *  Required. Entry Link identifier
 *  * Must contain only lowercase letters, numbers and hyphens.
 *  * Must start with a letter.
 *  * Must be between 1-63 characters.
 *  * Must end with a number or a letter.
 *  * Must be unique within the EntryGroup.
 */
// const entryLinkId = 'abc123'
/**
 *  Required. Entry Link resource.
 */
// const entryLink = {}

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

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

async function callCreateEntryLink() {
  // Construct request
  const request = {
    parent,
    entryLinkId,
    entryLink,
  };

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

callCreateEntryLink();

Python

Before trying this sample, follow the Python setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Python API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# 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_entry_link():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    entry_link = dataplex_v1.EntryLink()
    entry_link.entry_link_type = "entry_link_type_value"
    entry_link.entry_references.name = "name_value"
    entry_link.entry_references.type_ = "TARGET"

    request = dataplex_v1.CreateEntryLinkRequest(
        parent="parent_value",
        entry_link_id="entry_link_id_value",
        entry_link=entry_link,
    )

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

    # Handle the response
    print(response)

REST

To create an entry link with the required aspect, use the entryLinks.create method, including the aspect data in the request body.

Add aspects to an entry link

To enrich metadata with information about relationships between the entries, add aspects to entry links.

You can configure entry link types to require a specific aspect. When you create an entry link of such type, you must provide the required aspect.

You can add these aspects when you create an entry link, or by updating an existing entry link, as follows:

C#

Before trying this sample, follow the C# setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog C# API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

using Google.Cloud.Dataplex.V1;

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for UpdateEntryLink</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 UpdateEntryLinkRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        UpdateEntryLinkRequest request = new UpdateEntryLinkRequest
        {
            EntryLink = new EntryLink(),
            AllowMissing = false,
            AspectKeys = { "", },
        };
        // Make the request
        EntryLink response = catalogServiceClient.UpdateEntryLink(request);
    }
}

Go

Before trying this sample, follow the Go setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Go API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


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

Java

Before trying this sample, follow the Java setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Java API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.EntryLink;
import com.google.cloud.dataplex.v1.UpdateEntryLinkRequest;
import java.util.ArrayList;

public class SyncUpdateEntryLink {

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

  public static void syncUpdateEntryLink() 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()) {
      UpdateEntryLinkRequest request =
          UpdateEntryLinkRequest.newBuilder()
              .setEntryLink(EntryLink.newBuilder().build())
              .setAllowMissing(true)
              .addAllAspectKeys(new ArrayList<String>())
              .build();
      EntryLink response = catalogServiceClient.updateEntryLink(request);
    }
  }
}

Node.js

Before trying this sample, follow the Node.js setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Node.js API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * 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. Entry Link resource.
 */
// const entryLink = {}
/**
 *  Optional. If set to true and the entry link doesn't exist, the service will
 *  create it.
 */
// const allowMissing = true
/**
 *  Optional. The map keys of the Aspects which the service should modify.
 *  It should be the aspect type reference in the format
 *  `{project_id_or_number}.{location_id}.{aspect_type_id}`.
 *  If this field is left empty, the service treats it as specifying
 *  exactly those Aspects present in the request.
 */
// const aspectKeys = ['abc','def']

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

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

async function callUpdateEntryLink() {
  // Construct request
  const request = {
    entryLink,
  };

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

callUpdateEntryLink();

Python

Before trying this sample, follow the Python setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Python API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# 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_link():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    entry_link = dataplex_v1.EntryLink()
    entry_link.entry_link_type = "entry_link_type_value"
    entry_link.entry_references.name = "name_value"
    entry_link.entry_references.type_ = "TARGET"

    request = dataplex_v1.UpdateEntryLinkRequest(
        entry_link=entry_link,
    )

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

    # Handle the response
    print(response)

REST

To update an entry link, use the entryLinks.patch method, including the aspect data in the entryLink body.

Note the following limitations for using aspects with entry links:

  • Optional aspects aren't supported.
  • Data aspects are not supported.
  • Aspects of custom types aren't supported.
  • You can only manage required aspects defined by system aspect types, for example, schema-join.
  • Searching for entry links based on the content of their aspects isn't supported.
  • Importing or exporting entry link aspects isn't supported.

Manage existing aspects for an entry

This section describes how to update and delete the existing aspects for an entry.

Update an aspect

You can edit the optional aspects for both custom entries and system entries. You can edit the required aspects only for custom entries.

For first-party (1P) system entries, such as BigQuery tables, you can update aspects using the modifyEntry API. This lets you use the source system's metadata update permissions (for example, BigQuery Data Editor (roles/bigquery.dataEditor)).

Console

  1. In the Google Cloud console, go to the Knowledge Catalog Search page.

    Go to Search

  2. Search for the entry whose aspects you want to update, and click the entry.

The entry details page opens.

  1. Click the Details tab.
  2. In the Aspects section, expand the aspect that you want to update, and click Edit.
  3. In the Edit aspect window, update the required fields.
  4. Click Save.

gcloud

To update aspects for an entry or a column of an entry, use the gcloud dataplex entries update command or gcloud dataplex entries update-aspects.

To update aspects using a JSON file:

gcloud dataplex entries update-aspects ENTRY_ID \
  --location=LOCATION \
  --entry-group=ENTRY_GROUP_ID \
  --project=PROJECT_ID \
  --aspects=ASPECTS_JSON_FILE

Replace the following:

  • ENTRY_ID: the ID of the entry.
  • LOCATION: the location of the entry.
  • ENTRY_GROUP_ID: the ID of the entry group.
  • PROJECT_ID: the ID of the project.
  • ASPECTS_JSON_FILE: the path to the JSON file containing the aspect map.

C#

C#

Before trying this sample, follow the C# setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog C# API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

Before trying this sample, follow the Go setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Go API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


//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.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

Before trying this sample, follow the Java setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Java API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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);
    }
  }
}

Node.js

Node.js

Before trying this sample, follow the Node.js setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Node.js API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * 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. Entry resource.
 */
// const entry = {}
/**
 *  Optional. Mask of fields to update. To update Aspects, the update_mask must
 *  contain the value "aspects".
 *  If the update_mask is empty, the service will update all modifiable fields
 *  present in the request.
 */
// const updateMask = {}
/**
 *  Optional. If set to true and the entry doesn't exist, the service will
 *  create it.
 */
// const allowMissing = true
/**
 *  Optional. If set to true and the aspect_keys specify aspect ranges, the
 *  service deletes any existing aspects from that range that weren't provided
 *  in the request.
 */
// const deleteMissingAspects = true
/**
 *  Optional. The map keys of the Aspects which the service should modify. It
 *  supports the following syntaxes:
 *  * `<aspect_type_reference>` - matches an aspect of the given type and empty
 *  path.
 *  * `<aspect_type_reference>@path` - matches an aspect of the given type and
 *  specified path. For example, to attach an aspect to a field that is
 *  specified by the `schema` aspect, the path should have the format
 *  `Schema.<field_name>`.
 *  * `<aspect_type_reference>@*` - matches aspects of the given type for all
 *  paths.
 *  * `*@path` - matches aspects of all types on the given path.
 *  The service will not remove existing aspects matching the syntax unless
 *  `delete_missing_aspects` is set to true.
 *  If this field is left empty, the service treats it as specifying
 *  exactly those Aspects present in the request.
 */
// const aspectKeys = ['abc','def']

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

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

async function callUpdateEntry() {
  // Construct request
  const request = {
    entry,
  };

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

callUpdateEntry();

Python

Python

Before trying this sample, follow the Python setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Python API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# 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

Before trying this sample, follow the Ruby setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Ruby API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

To update aspects for an entry or a column of an entry, use the entry.patch method.

Delete an aspect

Console

  1. In the Google Cloud console, go to the Knowledge Catalog Search page.

    Go to Search

  2. Search for the entry whose aspects you want to delete, and click the entry.

The entry details page opens.

  1. Click the Details tab.
  2. In the Aspects section, expand the aspect that you want to delete, click Delete.
  3. Click Confirm.

gcloud

To delete an aspect for an entry, use the gcloud dataplex entries update command with the --remove-aspects flag.

To delete an entry-level aspect:

gcloud dataplex entries update ENTRY_ID \
  --location=LOCATION \
  --entry-group=ENTRY_GROUP_ID \
  --project=PROJECT_ID \
  --remove-aspects='ASPECT_TYPE'

To delete a column-level aspect:

gcloud dataplex entries update ENTRY_ID \
  --location=LOCATION \
  --entry-group=ENTRY_GROUP_ID \
  --project=PROJECT_ID \
  --remove-aspects='ASPECT_TYPE@Schema.COLUMN_NAME'

Replace the following:

  • ENTRY_ID: the ID of the entry.
  • LOCATION: the location of the entry.
  • ENTRY_GROUP_ID: the ID of the entry group.
  • PROJECT_ID: the ID of the project.
  • ASPECT_TYPE: the full aspect type identifier—for example, dataplex-types.global.generic or <var>PROJECT_ID</var>.<var>LOCATION</var>.<var>ASPECT_TYPE_ID</var>.
  • COLUMN_NAME: the name of the column.

C#

C#

Before trying this sample, follow the C# setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog C# API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

Before trying this sample, follow the Go setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Go API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


//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.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

Before trying this sample, follow the Java setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Java API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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);
    }
  }
}

Node.js

Node.js

Before trying this sample, follow the Node.js setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Node.js API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * 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. Entry resource.
 */
// const entry = {}
/**
 *  Optional. Mask of fields to update. To update Aspects, the update_mask must
 *  contain the value "aspects".
 *  If the update_mask is empty, the service will update all modifiable fields
 *  present in the request.
 */
// const updateMask = {}
/**
 *  Optional. If set to true and the entry doesn't exist, the service will
 *  create it.
 */
// const allowMissing = true
/**
 *  Optional. If set to true and the aspect_keys specify aspect ranges, the
 *  service deletes any existing aspects from that range that weren't provided
 *  in the request.
 */
// const deleteMissingAspects = true
/**
 *  Optional. The map keys of the Aspects which the service should modify. It
 *  supports the following syntaxes:
 *  * `<aspect_type_reference>` - matches an aspect of the given type and empty
 *  path.
 *  * `<aspect_type_reference>@path` - matches an aspect of the given type and
 *  specified path. For example, to attach an aspect to a field that is
 *  specified by the `schema` aspect, the path should have the format
 *  `Schema.<field_name>`.
 *  * `<aspect_type_reference>@*` - matches aspects of the given type for all
 *  paths.
 *  * `*@path` - matches aspects of all types on the given path.
 *  The service will not remove existing aspects matching the syntax unless
 *  `delete_missing_aspects` is set to true.
 *  If this field is left empty, the service treats it as specifying
 *  exactly those Aspects present in the request.
 */
// const aspectKeys = ['abc','def']

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

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

async function callUpdateEntry() {
  // Construct request
  const request = {
    entry,
  };

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

callUpdateEntry();

Python

Python

Before trying this sample, follow the Python setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Python API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# 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

Before trying this sample, follow the Ruby setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Ruby API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

To delete an aspect for an entry, use the entry.patch method.

Manage existing aspects for an entry link

This section describes how to update the existing aspects for an entry link.

Update an aspect

For entry links, you can only update required aspects that use reusable system aspect types.

For more information, see IAM permissions for entry links operations.

REST

To update an entry link with the required aspect, use the entryLinks.patch method, including the aspect data in the request body.

Delete an aspect

You can't delete required aspect for an entry link.

Manage aspect types

This section describes how to view aspect types, and update and delete custom aspect types.

View the list of available aspect types

Console

  1. In the Google Cloud console, go to the Knowledge Catalog Metadata types page.

    Go to Metadata types

  2. Click the Aspect types tab.

This page lists all the available Knowledge Catalog aspect types.

  1. To view custom aspect types, click the Custom tab. In the Custom tab, the Catalog source column displays where the resource resides in Knowledge Catalog.

To view system aspect types, click the System tab.

For more information about custom and system aspect types, see the categories of aspect types section of this document.

  1. Optional: To view the list of aspect types in your selected project, click the Custom tab, and then click the Show from all projects toggle to the off position.

The Show from all projects toggle is on by default, and the list includes Knowledge Catalog resources from your selected organization.

gcloud

To list all the available aspect types, use the gcloud dataplex aspect-types list command.

C#

C#

Before trying this sample, follow the C# setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog C# API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

Before trying this sample, follow the Go setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Go API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


//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.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

Before trying this sample, follow the Java setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Java API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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);
      }
    }
  }
}

Node.js

Node.js

Before trying this sample, follow the Node.js setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Node.js API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * 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 AspectType location, of the form:
 *  `projects/{project_number}/locations/{location_id}`
 *  where `location_id` refers to a Google Cloud region.
 */
// const parent = 'abc123'
/**
 *  Optional. Maximum number of AspectTypes to return. The service may return
 *  fewer than this value. If unspecified, the service returns at most 10
 *  AspectTypes. The maximum value is 1000; values above 1000 will be coerced
 *  to 1000.
 */
// const pageSize = 1234
/**
 *  Optional. Page token received from a previous `ListAspectTypes` call.
 *  Provide this to retrieve the subsequent page. When paginating, all other
 *  parameters you provide to `ListAspectTypes` 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"
 *  These restrictions can be conjoined with AND, OR, and NOT conjunctions.
 */
// const filter = 'abc123'
/**
 *  Optional. Orders the result by `name` or `create_time` fields.
 *  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 callListAspectTypes() {
  // Construct request
  const request = {
    parent,
  };

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

callListAspectTypes();

Python

Python

Before trying this sample, follow the Python setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Python API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# 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

Before trying this sample, follow the Ruby setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Ruby API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

To list all the available aspect types, use the aspectTypes.list method.

View details of an aspect type

Console

  1. In the Google Cloud console, go to the Knowledge Catalog Metadata types page.

    Go to Metadata types

  2. Click the Aspect types tab.

  3. To view the details of a Knowledge Catalog aspect type, click the aspect type. The aspect type details page opens, where you can access details, such as display name, aspect type ID, description, project ID, location, labels, creation date, and last modified date.

    • To view the structure of the selected aspect type, click the Template tab.
    • To view the list of 10 related entries created recently, click the Sample entries tab.
    • To search for all related entries, click Show all related entries in Search. This button appears only if there's at least one related entry.

gcloud

To get the details of an aspect type, use the gcloud dataplex aspect-types describe command.

C#

C#

Before trying this sample, follow the C# setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog C# API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

Before trying this sample, follow the Go setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Go API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


//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.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

Before trying this sample, follow the Java setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Java API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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);
    }
  }
}

Node.js

Node.js

Before trying this sample, follow the Node.js setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Node.js API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * 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 AspectType:
 *  `projects/{project_number}/locations/{location_id}/aspectTypes/{aspect_type_id}`.
 */
// const name = 'abc123'

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

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

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

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

callGetAspectType();

Python

Python

Before trying this sample, follow the Python setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Python API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# 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

Before trying this sample, follow the Ruby setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Ruby API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

To get the details of an aspect type, use the aspectTypes.get method.

Update a custom aspect type

You can update the display name, description, template fields, and labels of a custom aspect type. You can't delete an existing field in a template.

You can't update the aspect type ID and location after you create the aspect type.

Console

  1. In the Google Cloud console, go to the Knowledge Catalog Metadata types page.

    Go to Metadata types

  2. Click the Aspect types tab.

  3. Click the aspect type that you want to update.

  4. On the Aspect type details page, click Edit.

  5. Edit the display name, description, template fields, and labels, as required.

  6. Optional: To mark a field in the aspect type as deprecated, follow these steps:

    1. In the Template section, expand the field.
    2. Select Is Deprecated.
    3. In the Deprecation reason field, enter a reason for deprecating the selected field.
    4. Click Done.

    5. Click Save.

gcloud

To update a custom aspect type, use the gcloud dataplex aspect-types update command.

C#

C#

Before trying this sample, follow the C# setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog C# API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

Before trying this sample, follow the Go setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Go API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


//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.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

Before trying this sample, follow the Java setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Java API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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();
    }
  }
}

Node.js

Node.js

Before trying this sample, follow the Node.js setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Node.js API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * 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. AspectType Resource
 */
// const aspectType = {}
/**
 *  Required. 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 callUpdateAspectType() {
  // Construct request
  const request = {
    aspectType,
    updateMask,
  };

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

callUpdateAspectType();

Python

Python

Before trying this sample, follow the Python setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Python API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# 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

Before trying this sample, follow the Ruby setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Ruby API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

To update a custom aspect type, use the aspectTypes.patch method.

Delete a custom aspect type

Console

  1. In the Google Cloud console, go to the Knowledge Catalog Metadata types page.

    Go to Metadata types

  2. Click the Aspect types tab.

  3. Click the aspect type that you want to delete.

  4. On the Aspect type details page, click Delete. Confirm when prompted.

gcloud

To delete a custom aspect type, use the gcloud dataplex aspect-types delete command.

C#

C#

Before trying this sample, follow the C# setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog C# API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

Before trying this sample, follow the Go setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Go API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


//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.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

Before trying this sample, follow the Java setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Java API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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();
    }
  }
}

Node.js

Node.js

Before trying this sample, follow the Node.js setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Node.js API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * 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 AspectType:
 *  `projects/{project_number}/locations/{location_id}/aspectTypes/{aspect_type_id}`.
 */
// const name = 'abc123'
/**
 *  Optional. If the client provided etag value does not match the current etag
 *  value, the DeleteAspectTypeRequest method returns an ABORTED error
 *  response.
 */
// const etag = 'abc123'

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

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

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

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

callDeleteAspectType();

Python

Python

Before trying this sample, follow the Python setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Python API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# 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

Before trying this sample, follow the Ruby setup instructions in the Knowledge Catalog quickstart using client libraries. For more information, see the Knowledge Catalog Ruby API reference documentation.

To authenticate to Knowledge Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

To delete an existing custom aspect type, use the aspectTypes.delete method.

What's next