41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""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()
|