in assets/scripts/setup.py [0:0]
def create_data_store() -> str:
client_options = (
ClientOptions(api_endpoint=f"{DATA_STORE_LOCATION}-discoveryengine.googleapis.com")
if DATA_STORE_LOCATION != "global"
else None
)
# Create a client
client = discoveryengine.DataStoreServiceClient(client_options=client_options)
parent = client.collection_path(
project=PROJECT_ID,
location=DATA_STORE_LOCATION,
collection="default_collection",
)
data_store = discoveryengine.DataStore(
display_name=DATA_STORE_NAME,
industry_vertical=discoveryengine.IndustryVertical.GENERIC,
solution_types=[discoveryengine.SolutionType.SOLUTION_TYPE_SEARCH],
content_config=discoveryengine.DataStore.ContentConfig.CONTENT_REQUIRED,
)
request = discoveryengine.CreateDataStoreRequest(
parent=parent,
data_store_id=DATA_STORE_ID,
data_store=data_store,
)
operation = client.create_data_store(request=request)
print(f"Waiting for operation to complete: {operation.operation.name}")
operation.result()