Add utils

This commit is contained in:
Anibal Angulo
2026-02-24 16:32:25 +00:00
parent ba7581055c
commit 39ebb60428
3 changed files with 173 additions and 1 deletions

40
utils/delete_endpoint.py Normal file
View File

@@ -0,0 +1,40 @@
"""Delete a GCP Vector Search endpoint by ID.
Undeploys any deployed indexes before deleting the endpoint.
Usage:
uv run python utils/delete_endpoint.py <endpoint_id> [--project PROJECT] [--location LOCATION]
"""
import argparse
from google.cloud import aiplatform
def delete_endpoint(endpoint_id: str, project: str, location: str) -> None:
aiplatform.init(project=project, location=location)
endpoint = aiplatform.MatchingEngineIndexEndpoint(endpoint_id)
print(f"Endpoint: {endpoint.display_name}")
for deployed in endpoint.deployed_indexes:
print(f"Undeploying index: {deployed.id}")
endpoint.undeploy_index(deployed_index_id=deployed.id)
print(f"Undeployed: {deployed.id}")
endpoint.delete()
print(f"Endpoint {endpoint_id} deleted successfully.")
def main():
parser = argparse.ArgumentParser(description="Delete a GCP Vector Search endpoint.")
parser.add_argument("endpoint_id", help="The endpoint ID to delete.")
parser.add_argument("--project", default="bnt-orquestador-cognitivo-dev")
parser.add_argument("--location", default="us-central1")
args = parser.parse_args()
delete_endpoint(args.endpoint_id, args.project, args.location)
if __name__ == "__main__":
main()