Administrar tipos de entidades

Aprende a crear, enumerar y borrar tipos de entidades.

Crea un tipo de entidad

Crea un tipo de entidad para poder crear sus atributos relacionados.

IU web

  1. En la sección de Vertex AI de la consola de Google Cloud, ve a la página Funciones.

    Ve a la página Atributos

  2. En la barra de acciones, haz clic en Crear tipo de entidad para abrir la ventana Crear tipo de entidad.
  3. Selecciona una región de la lista desplegable Región que incluye el almacén de atributos en el que deseas crear un tipo de entidad.
  4. Selecciona un almacén de atributos.
  5. Especifica un nombre para el tipo de entidad.
  6. Si deseas incluir una descripción para el tipo de entidad, ingresa una descripción.
  7. Para habilitar la supervisión del valor de las características (Vista previa), establece la supervisión en Habilitada y, luego, especifica el intervalo de la instantánea en días. Esta configuración de supervisión se aplica a todas las funciones en este tipo de entidad. Para obtener más información, consulta Supervisión del valor de los atributos.
  8. Haz clic en Crear.

Terraform

En el siguiente ejemplo, se crea un featurestore nuevo y, luego, se usa el recurso google_vertex_ai_featurestore_entitytype de Terraform para crear un tipo de entidad llamado featurestore_entitytype dentro de ese almacén de atributos.

Si deseas obtener más información para aplicar o quitar una configuración de Terraform, consulta los comandos básicos de Terraform.

# Featurestore name must be unique for the project
resource "random_id" "featurestore_name_suffix" {
  byte_length = 8
}

resource "google_vertex_ai_featurestore" "featurestore" {
  name   = "featurestore_${random_id.featurestore_name_suffix.hex}"
  region = "us-central1"
  labels = {
    environment = "testing"
  }

  online_serving_config {
    fixed_node_count = 1
  }

  force_destroy = true
}

output "featurestore_id" {
  value = google_vertex_ai_featurestore.featurestore.id
}

resource "google_vertex_ai_featurestore_entitytype" "entity" {
  name = "featurestore_entitytype"
  labels = {
    environment = "testing"
  }

  featurestore = google_vertex_ai_featurestore.featurestore.id

  monitoring_config {
    snapshot_analysis {
      disabled = false
    }
  }

  depends_on = [google_vertex_ai_featurestore.featurestore]
}

REST

Para crear un tipo de entidad, envía una solicitud POST mediante el método featurestores.entityTypes.create.

Antes de usar cualquiera de los datos de solicitud a continuación, realiza los siguientes reemplazos:

  • LOCATION_ID: Región donde se encuentra el featurestore, como us-central1.
  • PROJECT_ID: El ID del proyecto.
  • FEATURESTORE_ID: ID del featurestore.
  • ENTITY_TYPE_ID: ID del tipo de entidad.
  • DESCRIPTION: Descripción del tipo de entidad.

Método HTTP y URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes?entityTypeId=ENTITY_TYPE_ID

Cuerpo JSON de la solicitud:

{
  "description": "DESCRIPTION"
}

Para enviar tu solicitud, elige una de estas opciones:

curl

Guarda el cuerpo de la solicitud en un archivo llamado request.json y ejecuta el siguiente comando:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes?entityTypeId=ENTITY_TYPE_ID"

PowerShell

Guarda el cuerpo de la solicitud en un archivo llamado request.json y ejecuta el siguiente comando:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes?entityTypeId=ENTITY_TYPE_ID" | Select-Object -Expand Content

Deberías ver un resultado similar al siguiente. Puedes usar el OPERATION_ID en la respuesta para obtener el estado de la operación.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/bikes/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateEntityTypeOperationMetadata",
    "genericMetadata": {
      "createTime": "2021-03-02T00:04:13.039166Z",
      "updateTime": "2021-03-02T00:04:13.039166Z"
    }
  }
}

Python

Si deseas obtener información para instalar o actualizar el SDK de Python, consulta Instala el SDK de Vertex AI para Python. Si deseas obtener más información, consulta la documentación de referencia de la API de Python.

from google.cloud import aiplatform

def create_entity_type_sample(
    project: str,
    location: str,
    entity_type_id: str,
    featurestore_name: str,
):

    aiplatform.init(project=project, location=location)

    my_entity_type = aiplatform.EntityType.create(
        entity_type_id=entity_type_id, featurestore_name=featurestore_name
    )

    my_entity_type.wait()

    return my_entity_type

Python

La biblioteca cliente de Vertex AI se incluye cuando instalas el SDK de Vertex AI para Python. Si deseas obtener información sobre cómo instalar el SDK de Vertex AI para Python, consulta Instala el SDK de Vertex AI para Python. Si deseas obtener más información, consulta la documentación de referencia del SDK de AI de Vertex para la API de Python.

from google.cloud import aiplatform

def create_entity_type_sample(
    project: str,
    featurestore_id: str,
    entity_type_id: str,
    description: str = "sample entity type",
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 300,
):
    # The AI Platform services require regional API endpoints, which need to be
    # in the same region or multi-region overlap with the Feature Store location.
    client_options = {"api_endpoint": api_endpoint}
    # Initialize client that will be used to create and send requests.
    # This client only needs to be created once, and can be reused for multiple requests.
    client = aiplatform.gapic.FeaturestoreServiceClient(client_options=client_options)
    parent = f"projects/{project}/locations/{location}/featurestores/{featurestore_id}"
    create_entity_type_request = aiplatform.gapic.CreateEntityTypeRequest(
        parent=parent,
        entity_type_id=entity_type_id,
        entity_type=aiplatform.gapic.EntityType(description=description),
    )
    lro_response = client.create_entity_type(request=create_entity_type_request)
    print("Long running operation:", lro_response.operation.name)
    create_entity_type_response = lro_response.result(timeout=timeout)
    print("create_entity_type_response:", create_entity_type_response)

Java

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

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


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.CreateEntityTypeOperationMetadata;
import com.google.cloud.aiplatform.v1.CreateEntityTypeRequest;
import com.google.cloud.aiplatform.v1.EntityType;
import com.google.cloud.aiplatform.v1.FeaturestoreName;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateEntityTypeSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String description = "YOUR_ENTITY_TYPE_DESCRIPTION";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 300;
    createEntityTypeSample(
        project, featurestoreId, entityTypeId, description, location, endpoint, timeout);
  }

  static void createEntityTypeSample(
      String project,
      String featurestoreId,
      String entityTypeId,
      String description,
      String location,
      String endpoint,
      int timeout)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {

    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      EntityType entityType = EntityType.newBuilder().setDescription(description).build();

      CreateEntityTypeRequest createEntityTypeRequest =
          CreateEntityTypeRequest.newBuilder()
              .setParent(FeaturestoreName.of(project, location, featurestoreId).toString())
              .setEntityType(entityType)
              .setEntityTypeId(entityTypeId)
              .build();

      OperationFuture<EntityType, CreateEntityTypeOperationMetadata> entityTypeFuture =
          featurestoreServiceClient.createEntityTypeAsync(createEntityTypeRequest);
      System.out.format(
          "Operation name: %s%n", entityTypeFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      EntityType entityTypeResponse = entityTypeFuture.get(timeout, TimeUnit.SECONDS);
      System.out.println("Create Entity Type Response");
      System.out.format("Name: %s%n", entityTypeResponse.getName());
    }
  }
}

Node.js

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

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

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const description = 'YOUR_ENTITY_TYPE_DESCRIPTION';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function createEntityType() {
  // Configure the parent resource
  const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`;

  const entityType = {
    description: description,
  };

  const request = {
    parent: parent,
    entityTypeId: entityTypeId,
    entityType: entityType,
  };

  // Create EntityType request
  const [operation] = await featurestoreServiceClient.createEntityType(
    request,
    {timeout: Number(timeout)}
  );
  const [response] = await operation.promise();

  console.log('Create entity type response');
  console.log(`Name : ${response.name}`);
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
createEntityType();

Enumera tipos de entidades

Enumera todos los tipos de entidades en un almacén de atributos.

IU web

  1. En la sección de Vertex AI de la consola de Google Cloud, ve a la página Funciones.

    Ve a la página Atributos

  2. Selecciona una región de la lista desplegable Región.
  3. En la tabla de atributos, consulta la columna Tipo de entidad para ver los tipos de entidades en tu proyecto de la región seleccionada.

REST

Para enumerar los tipos de entidades, envía una solicitud GET mediante el método featurestores.entityTypes.list.

Antes de usar cualquiera de los datos de solicitud a continuación, realiza los siguientes reemplazos:

  • LOCATION_ID: Región donde se encuentra el featurestore, como us-central1.
  • PROJECT_ID: El ID del proyecto.
  • FEATURESTORE_ID: ID del featurestore.

Método HTTP y URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes

Para enviar tu solicitud, elige una de estas opciones:

curl

Ejecuta el siguiente comando:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes"

PowerShell

Ejecuta el siguiente comando:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes" | Select-Object -Expand Content

Deberías recibir una respuesta JSON similar a la que se muestra a continuación:

{
  "entityTypes": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID_1",
      "description": "ENTITY_TYPE_DESCRIPTION",
      "createTime": "2021-02-25T01:20:43.082628Z",
      "updateTime": "2021-02-25T01:20:43.082628Z",
      "etag": "AMEw9yOBqKIdbBGZcxdKLrlZJAf9eTO2DEzcE81YDKA2LymDMFB8ucRbmKwKo2KnvOg="
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID_2",
      "description": "ENTITY_TYPE_DESCRIPTION",
      "createTime": "2021-02-25T01:34:26.198628Z",
      "updateTime": "2021-02-25T01:34:26.198628Z",
      "etag": "AMEw9yNuv-ILYG8VLLm1lgIKc7asGIAVFErjvH2Cyc_wIQm7d6DL4ZGv59cwZmxTumU="
    }
  ]
}

Java

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

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


import com.google.cloud.aiplatform.v1.EntityType;
import com.google.cloud.aiplatform.v1.FeaturestoreName;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.ListEntityTypesRequest;
import java.io.IOException;

public class ListEntityTypesSample {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    listEntityTypesSample(project, featurestoreId, location, endpoint);
  }

  static void listEntityTypesSample(
      String project, String featurestoreId, String location, String endpoint) throws IOException {

    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      ListEntityTypesRequest listEntityTypeRequest =
          ListEntityTypesRequest.newBuilder()
              .setParent(FeaturestoreName.of(project, location, featurestoreId).toString())
              .build();
      System.out.println("List Entity Types Response");
      for (EntityType element :
          featurestoreServiceClient.listEntityTypes(listEntityTypeRequest).iterateAll()) {
        System.out.println(element);
      }
    }
  }
}

Node.js

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

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

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function listEntityTypes() {
  // Configure the parent resource
  const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`;

  const request = {
    parent: parent,
  };

  // List EntityTypes request
  const [response] = await featurestoreServiceClient.listEntityTypes(
    request,
    {timeout: Number(timeout)}
  );

  console.log('List entity types response');
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
listEntityTypes();

Idiomas adicionales

Si deseas obtener información sobre cómo instalar y usar el SDK de Vertex AI para Python, consulta Cómo usar el SDK de Vertex AI para Python. Si deseas obtener más información, consulta la documentación de referencia del SDK de IA de Vertex para Python.

Borra un tipo de entidad

Borra un tipo de entidad. Si usas la consola de Google Cloud, Vertex AI Feature Store (Legacy) borra el tipo de entidad y todo su contenido. Si usas la API, habilita el parámetro de consulta force para borrar el tipo de entidad y todo su contenido.

IU web

  1. En la sección de Vertex AI de la consola de Google Cloud, ve a la página Funciones.

    Ve a la página Atributos

  2. Selecciona una región de la lista desplegable Región.
  3. En la tabla de atributos, consulta la columna Tipo de entidad y busca el tipo de entidad que deseas borrar.
  4. Haz clic en el nombre del tipo de entidad.
  5. En la barra de acciones, haz clic en Borrar.
  6. Haz clic en Confirmar para borrar el tipo de entidad.

REST

Para borrar un tipo de entidad, envía una solicitud DELETE mediante el método featurestores.entityTypes.delete.

Antes de usar cualquiera de los datos de solicitud a continuación, realiza los siguientes reemplazos:

  • LOCATION_ID: Región donde se encuentra el featurestore, como us-central1.
  • PROJECT_ID: El ID del proyecto.
  • FEATURESTORE_ID: ID del featurestore.
  • ENTITY_TYPE_ID: ID del tipo de entidad.
  • BOOLEAN: Indica si se debe borrar el tipo de entidad, incluso si contiene atributos. El parámetro de consulta force es opcional y es false de forma predeterminada.

Método HTTP y URL:

DELETE https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?force=BOOLEAN

Para enviar tu solicitud, elige una de estas opciones:

curl

Ejecuta el siguiente comando:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?force=BOOLEAN"

PowerShell

Ejecuta el siguiente comando:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?force=BOOLEAN" | Select-Object -Expand Content

Deberías recibir una respuesta JSON similar a la que se muestra a continuación:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.DeleteOperationMetadata",
    "genericMetadata": {
      "createTime": "2021-02-26T17:32:56.008325Z",
      "updateTime": "2021-02-26T17:32:56.008325Z"
    }
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.protobuf.Empty"
  }
}

Java

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

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


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.DeleteEntityTypeRequest;
import com.google.cloud.aiplatform.v1.DeleteOperationMetadata;
import com.google.cloud.aiplatform.v1.EntityTypeName;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class DeleteEntityTypeSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 300;
    deleteEntityTypeSample(project, featurestoreId, entityTypeId, location, endpoint, timeout);
  }

  static void deleteEntityTypeSample(
      String project,
      String featurestoreId,
      String entityTypeId,
      String location,
      String endpoint,
      int timeout)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {

    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      DeleteEntityTypeRequest deleteEntityTypeRequest =
          DeleteEntityTypeRequest.newBuilder()
              .setName(
                  EntityTypeName.of(project, location, featurestoreId, entityTypeId).toString())
              .setForce(true)
              .build();

      OperationFuture<Empty, DeleteOperationMetadata> operationFuture =
          featurestoreServiceClient.deleteEntityTypeAsync(deleteEntityTypeRequest);
      System.out.format("Operation name: %s%n", operationFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      operationFuture.get(timeout, TimeUnit.SECONDS);

      System.out.format("Deleted Entity Type.");
    }
  }
}

Node.js

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

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

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const force = <BOOLEAN>;
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function deleteEntityType() {
  // Configure the name resource
  const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`;

  const request = {
    name: name,
    force: Boolean(force),
  };

  // Delete EntityType request
  const [operation] = await featurestoreServiceClient.deleteEntityType(
    request,
    {timeout: Number(timeout)}
  );
  const [response] = await operation.promise();

  console.log('Delete entity type response');
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
deleteEntityType();

Idiomas adicionales

Si deseas obtener información sobre cómo instalar y usar el SDK de Vertex AI para Python, consulta Cómo usar el SDK de Vertex AI para Python. Si deseas obtener más información, consulta la documentación de referencia del SDK de IA de Vertex para Python.

¿Qué sigue?