Cómo buscar recursos en Knowledge Catalog

En este documento, se proporcionan instrucciones para buscar recursos de datos en Knowledge Catalog.

Antes de comenzar

Antes de realizar la búsqueda, asegúrate de que se te hayan otorgado los roles necesarios y de haber habilitado la API necesaria.

Roles obligatorios

Para obtener los permisos que necesitas para buscar entradas y acceder a los resultados de la búsqueda en Knowledge Catalog, pídele a tu administrador que te otorgue los siguientes roles de IAM:

Para obtener más información sobre cómo otorgar roles, consulta Administra el acceso a proyectos, carpetas y organizaciones.

También puedes obtener los permisos necesarios a través de roles personalizados o cualquier otro rol predefinido.

Permisos a nivel del activo

Los resultados de la búsqueda se limitan a tu nivel de acceso, independientemente del proyecto seleccionado. Para encontrar un activo en Knowledge Catalog, debes tener los permisos de lectura adecuados para ese recurso en su sistema fuente subyacente.

Por ejemplo, para encontrar una tabla de BigQuery, se requiere el rol de roles/bigquery.metadataViewer, mientras que, para encontrar una instancia de Cloud SQL, se requieren sus permisos de Cloud SQL equivalentes. Para obtener más detalles, consulta Alcance de la búsqueda.

Habilita la API

Habilitar la API de Dataplex

Roles necesarios para habilitar las APIs

Para habilitar APIs, necesitas el permiso serviceusage.services.enable. Si creaste el proyecto, es probable que ya tengas este permiso a través del rol de propietario (roles/owner). De lo contrario, puedes obtener este permiso a través del rol de administrador de Service Usage (roles/serviceusage.serviceUsageAdmin). Obtén más información para otorgar roles.

Habilitar la API

Buscar recursos

Console

Para buscar recursos, sigue estos pasos:

  1. En la consola de Google Cloud , ve a la página Búsqueda de Knowledge Catalog.

    Ir a Búsqueda

  2. Si ves el mensaje del botón Probar la búsqueda en lenguaje natural, haz clic en él. De forma predeterminada, se selecciona la búsqueda en lenguaje natural.

  3. En el campo Encuentra recursos en todos los proyectos con lenguaje natural, ingresa tu consulta y, luego, haz clic en Intro.

  4. Para definir mejor tu búsqueda, haz clic en Filtros.

    • Los filtros de varias secciones se evalúan con el operador lógico AND.
    • Los múltiples filtros dentro de una misma sección se evalúan con el operador lógico OR.

    Están disponibles los siguientes filtros:

    • Alcance: Busca en toda la organización (opción predeterminada), en el proyecto actual o solo en los recursos destacados. Para obtener más información, consulta Alcance de la búsqueda.
    • Sistemas: El Google Cloud servicio al que pertenece el recurso, como BigQuery. El sistema de Knowledge Catalog contiene grupos de entradas.
    • Proyectos: Son los proyectos en los que se realizará la búsqueda.
    • Tipo: Es el tipo de recurso, como conexión de BigQuery, bucket de Cloud Storage o base de datos. Según el tipo de recurso, también puedes filtrar por subtipo, como el tipo de conexión o el dialecto de SQL.
    • Selecciona ubicaciones: Son las ubicaciones en las que se realizará la búsqueda.
    • Seleccionar conjuntos de datos: Los resultados de la búsqueda se limitan a los recursos de BigQuery que pertenecen a los conjuntos de datos de BigQuery seleccionados. En el campo Escribe para filtrar, ingresa el nombre del conjunto de datos.
    • Tipos de aspectos: Son los tipos de aspectos de Knowledge Catalog que se asocian con el recurso que buscas. Para filtrar por valores de aspecto, haz clic en Filtrar los valores de tipo de aspecto y, luego, selecciona los valores.
  5. Para ver más información sobre el recurso buscado, haz clic en su nombre en los resultados de la búsqueda para abrir la página de detalles de la entrada.

Google Cloud CLI

Para buscar recursos, usa el comando gcloud dataplex entries search:

gcloud dataplex entries search 'foo' \
  --project=PROJECT_ID \
  --semantic-search

Reemplaza PROJECT_ID por el ID del proyecto Google Cloud .

C#

C#

Antes de probar este ejemplo, sigue las instrucciones de configuración para C# que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog C#.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

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

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for SearchEntries</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 SearchEntriesRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        SearchEntriesRequest request = new SearchEntriesRequest
        {
            LocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            Query = "",
            OrderBy = "",
            Scope = "",
            SemanticSearch = false,
        };
        // Make the request
        PagedEnumerable<SearchEntriesResponse, SearchEntriesResult> response = catalogServiceClient.SearchEntries(request);

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

Antes de probar este ejemplo, sigue las instrucciones de configuración para Go que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog Go.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


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

Java

Java

Antes de probar este ejemplo, sigue las instrucciones de configuración para Java que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog Java.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.LocationName;
import com.google.cloud.dataplex.v1.SearchEntriesRequest;
import com.google.cloud.dataplex.v1.SearchEntriesResult;

public class SyncSearchEntries {

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

  public static void syncSearchEntries() 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()) {
      SearchEntriesRequest request =
          SearchEntriesRequest.newBuilder()
              .setName(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .setQuery("query107944136")
              .setPageSize(883849137)
              .setPageToken("pageToken873572522")
              .setOrderBy("orderBy-1207110587")
              .setScope("scope109264468")
              .setSemanticSearch(true)
              .build();
      for (SearchEntriesResult element : catalogServiceClient.searchEntries(request).iterateAll()) {
        // doThingsWith(element);
      }
    }
  }
}

Node.js

Node.js

Antes de probar este ejemplo, sigue las instrucciones de configuración para Node.js que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog Node.js.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

/**
 * 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 project to which the request should be attributed in the
 *  following form: `projects/{project}/locations/global`.
 */
// const name = 'abc123'
/**
 *  Required. The query against which entries in scope should be matched.
 *  The query syntax is defined in Search syntax for Dataplex Universal
 *  Catalog (https://cloud.google.com/dataplex/docs/search-syntax).
 */
// const query = 'abc123'
/**
 *  Optional. Number of results in the search page. If <=0, then defaults
 *  to 10. Max limit for page_size is 1000. Throws an invalid argument for
 *  page_size > 1000.
 */
// const pageSize = 1234
/**
 *  Optional. Page token received from a previous `SearchEntries` call. Provide
 *  this to retrieve the subsequent page.
 */
// const pageToken = 'abc123'
/**
 *  Optional. Specifies the ordering of results.
 *  Supported values are:
 *  * `relevance`
 *  * `last_modified_timestamp`
 *  * `last_modified_timestamp asc`
 */
// const orderBy = 'abc123'
/**
 *  Optional. The scope under which the search should be operating. It must
 *  either be `organizations/<org_id>` or `projects/<project_ref>`. If it is
 *  unspecified, it defaults to the organization where the project provided in
 *  `name` is located.
 */
// const scope = 'abc123'
/**
 *  Optional. Specifies whether the search should understand the meaning and
 *  intent behind the query, rather than just matching keywords.
 */
// const semanticSearch = true

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

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

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

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

callSearchEntries();

PHP

PHP

Antes de probar este ejemplo, sigue las instrucciones de configuración para PHP que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog PHP.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dataplex\V1\Client\CatalogServiceClient;
use Google\Cloud\Dataplex\V1\SearchEntriesRequest;
use Google\Cloud\Dataplex\V1\SearchEntriesResult;

/**
 * Searches for Entries matching the given query and scope.
 *
 * @param string $formattedName The project to which the request should be attributed in the
 *                              following form: `projects/{project}/locations/global`. Please see
 *                              {@see CatalogServiceClient::locationName()} for help formatting this field.
 * @param string $query         The query against which entries in scope should be matched.
 *                              The query syntax is defined in [Search syntax for Dataplex Universal
 *                              Catalog](https://cloud.google.com/dataplex/docs/search-syntax).
 */
function search_entries_sample(string $formattedName, string $query): void
{
    // Create a client.
    $catalogServiceClient = new CatalogServiceClient();

    // Prepare the request message.
    $request = (new SearchEntriesRequest())
        ->setName($formattedName)
        ->setQuery($query);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $catalogServiceClient->searchEntries($request);

        /** @var SearchEntriesResult $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = CatalogServiceClient::locationName('[PROJECT]', '[LOCATION]');
    $query = '[QUERY]';

    search_entries_sample($formattedName, $query);
}

Python

Python

Antes de probar este ejemplo, sigue las instrucciones de configuración para Python que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog Python.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

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

    # Initialize request argument(s)
    request = dataplex_v1.SearchEntriesRequest(
        name="name_value",
        query="query_value",
    )

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

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

Ruby

Ruby

Antes de probar este ejemplo, sigue las instrucciones de configuración para Ruby que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog Ruby.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

require "google/cloud/dataplex/v1"

##
# Snippet for the search_entries 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#search_entries.
#
def search_entries
  # 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::SearchEntriesRequest.new

  # Call the search_entries method.
  result = client.search_entries 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::SearchEntriesResult.
    p item
  end
end

REST

Para buscar recursos, usa el método searchEntries con el parámetro SemanticSearch establecido en true.

POST https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION:searchEntries?query=foo&semanticSearch=true

Reemplaza lo siguiente:

  • PROJECT_ID: Es el ID de tu proyecto de Google Cloud .
  • LOCATION: Es la región en la que existe el proyecto (por ejemplo, us-central1).

Cómo ver los detalles de un activo que se devolvió en la búsqueda

Console

Usa la búsqueda de Knowledge Catalog para ver los detalles de un recurso.

  1. Busca un recurso en Knowledge Catalog.

  2. En los resultados de la búsqueda, haz clic en el activo cuyos detalles deseas ver.

    Se abrirá la página de detalles de la entrada. La página incluye las siguientes secciones:

    • Detalles de la entrada: Incluye información como el tipo de entrada, el sistema, la plataforma, el nombre completamente calificado, la hora de creación, la hora de última modificación, la descripción y los administradores.
    • Descripción general: Es una descripción general de la entrada, si está disponible.
    • Aspectos: Son los aspectos obligatorios y opcionales definidos para la entrada. Para obtener más información, consulta Categorías de aspectos.

gcloud

Comando gcloud dataplex entries lookup:

gcloud dataplex entries lookup ENTRY_ID \
  --entry-group=ENTRY_GROUP_ID \
  --location=LOCATION \
  --project=PROJECT_ID

Reemplaza lo siguiente:

  • ENTRY_ID: Es el ID de la entrada.
  • ENTRY_GROUP_ID: Es el ID del grupo de entradas.
  • LOCATION: Es la región en la que existe el proyecto.
  • PROJECT_ID: Es el ID del proyecto de Google Cloud .

C#

C#

Antes de probar este ejemplo, sigue las instrucciones de configuración para C# que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog C#.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

using Google.Cloud.Dataplex.V1;

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for LookupEntry</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 LookupEntryRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        LookupEntryRequest request = new LookupEntryRequest
        {
            Name = "",
            View = EntryView.Unspecified,
            AspectTypes = { "", },
            Paths = { "", },
            EntryAsEntryName = EntryName.FromProjectLocationEntryGroupEntry("[PROJECT]", "[LOCATION]", "[ENTRY_GROUP]", "[ENTRY]"),
        };
        // Make the request
        Entry response = catalogServiceClient.LookupEntry(request);
    }
}

Go

Go

Antes de probar este ejemplo, sigue las instrucciones de configuración para Go que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog Go.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


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

Java

Java

Antes de probar este ejemplo, sigue las instrucciones de configuración para Java que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog Java.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

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.EntryView;
import com.google.cloud.dataplex.v1.LookupEntryRequest;
import java.util.ArrayList;

public class SyncLookupEntry {

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

  public static void syncLookupEntry() 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()) {
      LookupEntryRequest request =
          LookupEntryRequest.newBuilder()
              .setName("name3373707")
              .setView(EntryView.forNumber(0))
              .addAllAspectTypes(new ArrayList<String>())
              .addAllPaths(new ArrayList<String>())
              .setEntry(
                  EntryName.of("[PROJECT]", "[LOCATION]", "[ENTRY_GROUP]", "[ENTRY]").toString())
              .build();
      Entry response = catalogServiceClient.lookupEntry(request);
    }
  }
}

Node.js

Node.js

Antes de probar este ejemplo, sigue las instrucciones de configuración para Node.js que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog Node.js.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

/**
 * 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 project to which the request should be attributed in the
 *  following form: `projects/{project}/locations/{location}`.
 */
// const name = 'abc123'
/**
 *  Optional. View to control which parts of an entry the service should
 *  return.
 *  **Please check the limitations on returned aspects in the Entry view
 *  documentation. Amount of returned aspects depends on the selected Entry
 *  View.**
 */
// const view = {}
/**
 *  Optional. Limits the aspects returned to the provided aspect types.
 *  It only works for CUSTOM view.
 */
// const aspectTypes = ['abc','def']
/**
 *  Optional. Limits the aspects returned to those associated with the provided
 *  paths within the Entry. It only works for CUSTOM view.
 */
// const paths = ['abc','def']
/**
 *  Required. The resource name of the Entry:
 *  `projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}`.
 */
// const entry = 'abc123'

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

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

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

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

callLookupEntry();

PHP

PHP

Antes de probar este ejemplo, sigue las instrucciones de configuración para PHP que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog PHP.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Client\CatalogServiceClient;
use Google\Cloud\Dataplex\V1\Entry;
use Google\Cloud\Dataplex\V1\LookupEntryRequest;

/**
 * Looks up an entry by name using the permission on the source system.
 *
 * @param string $name           The project to which the request should be attributed in the
 *                               following form: `projects/{project}/locations/{location}`.
 * @param string $formattedEntry The resource name of the Entry:
 *                               `projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}`. Please see
 *                               {@see CatalogServiceClient::entryName()} for help formatting this field.
 */
function lookup_entry_sample(string $name, string $formattedEntry): void
{
    // Create a client.
    $catalogServiceClient = new CatalogServiceClient();

    // Prepare the request message.
    $request = (new LookupEntryRequest())
        ->setName($name)
        ->setEntry($formattedEntry);

    // Call the API and handle any network failures.
    try {
        /** @var Entry $response */
        $response = $catalogServiceClient->lookupEntry($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $name = '[NAME]';
    $formattedEntry = CatalogServiceClient::entryName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTRY_GROUP]',
        '[ENTRY]'
    );

    lookup_entry_sample($name, $formattedEntry);
}

Python

Python

Antes de probar este ejemplo, sigue las instrucciones de configuración para Python que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog Python.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

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

    # Initialize request argument(s)
    request = dataplex_v1.LookupEntryRequest(
        name="name_value",
        entry="entry_value",
    )

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

    # Handle the response
    print(response)

Ruby

Ruby

Antes de probar este ejemplo, sigue las instrucciones de configuración para Ruby que encontrarás en la guía de inicio rápido de Knowledge Catalog sobre cómo usar las bibliotecas cliente. Para obtener más información, consulta la documentación de referencia de la API de Knowledge Catalog Ruby.

Para autenticarte en Knowledge Catalog, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

require "google/cloud/dataplex/v1"

##
# Snippet for the lookup_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#lookup_entry.
#
def lookup_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::LookupEntryRequest.new

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

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

REST

Para ver los detalles de un activo, usa el método lookupEntry.

Limitaciones

La Búsqueda tiene las siguientes limitaciones:

  • Los recursos públicos no se incluyen en el alcance de la búsqueda en lenguaje natural.
  • Los aspectos adjuntos a los vínculos de entrada no se incluyen en el alcance de la búsqueda en lenguaje natural.

¿Qué sigue?