Skip to content
26 changes: 7 additions & 19 deletions backend/scripts/vertex_ai_list_datastores.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
"""
Dump out info on project datastores in Google Workspace

Note: does not require credentials or authentication(?)
"""Dump info on Vertex AI Search datastores for a GCP project.

To run:
% uv run simple_langchain_example.py
uv run python -m scripts.vertex_ai_list_datastores
"""

from google.api_core.client_options import ClientOptions
from google.cloud import discoveryengine

from tenantfirstaid.google_auth import discoveryengine_client_options

project_id = "tenantfirstaid" # Replace with your GCP project ID
location = "global" # Values: "global"


def list_data_stores(
project_id: str,
location: str,
): # -> discoveryengine.ListDataStoresResponse:
# For more information, refer to:
# https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_store
client_options = (
ClientOptions(api_endpoint=f"{location}-discoveryengine.googleapis.com")
if location != "global"
else None
def list_data_stores(project_id: str, location: str) -> None:
client = discoveryengine.DataStoreServiceClient(
client_options=discoveryengine_client_options(location)
)

# Create a client
client = discoveryengine.DataStoreServiceClient(client_options=client_options)

request = discoveryengine.ListDataStoresRequest(
# The full resource name of the data store
parent=client.collection_path(
Expand Down
Loading
Loading