Gestione dei tipi di entità

Scopri come creare, elencare ed eliminare i tipi di entità.

Creare un tipo di entità

Crea un tipo di entità in modo da poter creare le relative funzionalità.

UI web

  1. Nella sezione Vertex AI della console Google Cloud, vai alla pagina Funzionalità.

    Vai alla pagina Funzionalità

  2. Nella barra delle azioni, fai clic su Crea tipo di entità per aprire il riquadro Crea tipo di entità.
  3. Seleziona dall'elenco a discesa Regione una regione che includa l'archivio di caratteristiche in cui vuoi creare un tipo di entità.
  4. Seleziona un archivio di caratteristiche.
  5. Specifica un nome per il tipo di entità.
  6. Se vuoi includere una descrizione per il tipo di entità, inserisci una descrizione.
  7. Per abilitare il monitoraggio dei valori delle funzionalità (anteprima), imposta il monitoraggio su Enabled e specifica l'intervallo di snapshot in giorni. Questa configurazione del monitoraggio si applica a tutte le funzionalità in questo tipo di entità. Per maggiori informazioni, consulta Monitoraggio del valore delle funzionalità.
  8. Fai clic su Crea.

Terraform

L'esempio seguente crea un nuovo archivio di caratteristiche, quindi utilizza la risorsa Terraform google_vertex_ai_featurestore_entitytype per creare un tipo di entità denominato featurestore_entitytype all'interno di quell'archivio di caratteristiche.

Per scoprire come applicare o rimuovere una configurazione Terraform, consulta Comandi Terraform di base.

# 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

Per creare un tipo di entità, invia una richiesta POST utilizzando il metodo featurestores.entityTypes.create.

Prima di utilizzare i dati della richiesta, effettua le seguenti sostituzioni:

  • LOCATION_ID: regione in cui si trova l'archivio di caratteristiche, ad esempio us-central1.
  • PROJECT_ID: il tuo ID progetto.
  • FEATURESTORE_ID: ID dell'archivio di caratteristiche.
  • ENTITY_TYPE_ID: ID del tipo di entità.
  • DESCRIPTION: descrizione del tipo di entità.

Metodo HTTP e URL:

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

Corpo JSON della richiesta:

{
  "description": "DESCRIPTION"
}

Per inviare la richiesta, scegli una delle seguenti opzioni:

arricciatura

Salva il corpo della richiesta in un file denominato request.json ed esegui questo 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

Salva il corpo della richiesta in un file denominato request.json ed esegui questo 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

Dovresti vedere un output simile al seguente. Puoi utilizzare OPERATION_ID nella risposta per recuperare lo stato dell'operazione.

{
  "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

Per scoprire come installare o aggiornare l'SDK Vertex AI per Python, consulta Installare l'SDK Vertex AI per Python. Per saperne di più, consulta la documentazione di riferimento dell'API 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 libreria client per Vertex AI è inclusa nell'installazione dell'SDK Vertex AI per Python. Per scoprire come installare l'SDK Vertex AI per Python, consulta Installare l'SDK Vertex AI per Python. Per maggiori informazioni, consulta la documentazione di riferimento dell'SDK Vertex AI per l'API 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

Prima di provare questo esempio, segui le istruzioni di configurazione di Java riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Java Vertex AI.

Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.


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

Prima di provare questo esempio, segui le istruzioni di configurazione di Node.js riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Node.js Vertex AI.

Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

/**
 * 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();

Elenco tipi di entità

Elenca tutti i tipi di entità in un archivio di caratteristiche.

UI web

  1. Nella sezione Vertex AI della console Google Cloud, vai alla pagina Funzionalità.

    Vai alla pagina Funzionalità

  2. Seleziona una regione dall'elenco a discesa Regione.
  3. Nella tabella delle funzionalità, visualizza la colonna Tipo di entità per vedere i tipi di entità nel tuo progetto per la regione selezionata.

REST

Per elencare i tipi di entità, invia una richiesta GET utilizzando il metodo featurestores.entityTypes.list.

Prima di utilizzare i dati della richiesta, effettua le seguenti sostituzioni:

  • LOCATION_ID: regione in cui si trova l'archivio di caratteristiche, ad esempio us-central1.
  • PROJECT_ID: il tuo ID progetto.
  • FEATURESTORE_ID: ID dell'archivio di caratteristiche.

Metodo HTTP e URL:

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

Per inviare la richiesta, scegli una delle seguenti opzioni:

arricciatura

Esegui questo 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

Esegui questo 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

Dovresti ricevere una risposta JSON simile alla seguente:

{
  "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

Prima di provare questo esempio, segui le istruzioni di configurazione di Java riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Java Vertex AI.

Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.


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

Prima di provare questo esempio, segui le istruzioni di configurazione di Node.js riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Node.js Vertex AI.

Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

/**
 * 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();

Linguaggi aggiuntivi

Per scoprire come installare e utilizzare l'SDK Vertex AI per Python, consulta Utilizzare l'SDK Vertex AI per Python. Per saperne di più, consulta la documentazione di riferimento dell'SDK Vertex AI per l'API Python.

Elimina un tipo di entità

Elimina un tipo di entità. Se utilizzi la console Google Cloud, Vertex AI Feature Store (legacy) elimina il tipo di entità e tutti i suoi contenuti. Se utilizzi l'API, abilita il parametro di query force per eliminare il tipo di entità e tutti i relativi contenuti.

UI web

  1. Nella sezione Vertex AI della console Google Cloud, vai alla pagina Funzionalità.

    Vai alla pagina Funzionalità

  2. Seleziona una regione dall'elenco a discesa Regione.
  3. Nella tabella delle funzionalità, visualizza la colonna Tipo di entità e individua il tipo di entità da eliminare.
  4. Fai clic sul nome del tipo di entità.
  5. Nella barra delle azioni, fai clic su Elimina.
  6. Fai clic su Conferma per eliminare il tipo di entità.

REST

Per eliminare un tipo di entità, invia una richiesta DELETE utilizzando il metodo featurestores.entityTypes.delete.

Prima di utilizzare i dati della richiesta, effettua le seguenti sostituzioni:

  • LOCATION_ID: regione in cui si trova l'archivio di caratteristiche, ad esempio us-central1.
  • PROJECT_ID: il tuo ID progetto.
  • FEATURESTORE_ID: ID dell'archivio di caratteristiche.
  • ENTITY_TYPE_ID: ID del tipo di entità.
  • BOOLEAN: indica se eliminare il tipo di entità anche se contiene funzionalità. Il parametro di query force è facoltativo ed è false per impostazione predefinita.

Metodo HTTP e URL:

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

Per inviare la richiesta, scegli una delle seguenti opzioni:

arricciatura

Esegui questo 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

Esegui questo 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

Dovresti ricevere una risposta JSON simile alla seguente:

{
  "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

Prima di provare questo esempio, segui le istruzioni di configurazione di Java riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Java Vertex AI.

Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.


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

Prima di provare questo esempio, segui le istruzioni di configurazione di Node.js riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Node.js Vertex AI.

Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

/**
 * 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();

Linguaggi aggiuntivi

Per scoprire come installare e utilizzare l'SDK Vertex AI per Python, consulta Utilizzare l'SDK Vertex AI per Python. Per saperne di più, consulta la documentazione di riferimento dell'SDK Vertex AI per l'API Python.

Passaggi successivi