-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_all_vector_stores.py
More file actions
73 lines (53 loc) · 1.82 KB
/
Copy pathlist_all_vector_stores.py
File metadata and controls
73 lines (53 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""
Author: L. Saetta
Last modified: 2026-03-17
License: MIT
Description:
List all vector stores in the configured project/compartment.
"""
from datetime import datetime, timezone
from common import get_control_plane_client, print_header, print_runtime_config
PAGE_SIZE = 100
def format_expiration(expires_at: int | None) -> str:
"""Format expiration epoch seconds into a readable UTC datetime string."""
if not expires_at:
return "N/A"
dt = datetime.fromtimestamp(expires_at, tz=timezone.utc)
return dt.strftime("%Y-%m-%d %H:%M:%S UTC")
def main() -> None:
"""List all vector stores using explicit page-by-page pagination."""
print_runtime_config()
print("")
cp_client = get_control_plane_client()
print_header("vector stores", where="compartment")
after = None
page_num = 1
total = 0
while True:
if after is None:
page = cp_client.vector_stores.list(limit=PAGE_SIZE, order="desc")
else:
page = cp_client.vector_stores.list(
limit=PAGE_SIZE,
order="desc",
after=after,
)
if not page.data:
break
print(f"\n=== Page {page_num} ({len(page.data)} vector stores) ===")
for i, vector_store in enumerate(page.data, start=1):
total += 1
expires_at = format_expiration(getattr(vector_store, "expires_at", None))
print(
f"{i:03d}. id={vector_store.id} "
f"name={vector_store.name} status={vector_store.status} "
f"expires_at={expires_at}"
)
if not page.has_more:
break
after = page.data[-1].id
page_num += 1
print(f"\nDone. Total vector stores listed: {total}")
print("")
if __name__ == "__main__":
main()