zilliz-cli 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. zilliz_cli-0.1.1/.coverage +0 -0
  2. zilliz_cli-0.1.1/.gitignore +2 -0
  3. zilliz_cli-0.1.1/PKG-INFO +223 -0
  4. zilliz_cli-0.1.1/README.md +194 -0
  5. zilliz_cli-0.1.1/pyproject.toml +83 -0
  6. zilliz_cli-0.1.1/scripts/cleanup_test_resources.py +89 -0
  7. zilliz_cli-0.1.1/src/zilliz_cli/__init__.py +1 -0
  8. zilliz_cli-0.1.1/src/zilliz_cli/__main__.py +3 -0
  9. zilliz_cli-0.1.1/src/zilliz_cli/auth/__init__.py +0 -0
  10. zilliz_cli-0.1.1/src/zilliz_cli/auth/config.py +318 -0
  11. zilliz_cli-0.1.1/src/zilliz_cli/auth/credentials.py +33 -0
  12. zilliz_cli-0.1.1/src/zilliz_cli/auth/oauth.py +227 -0
  13. zilliz_cli-0.1.1/src/zilliz_cli/builtin_models/control-plane.json +284 -0
  14. zilliz_cli-0.1.1/src/zilliz_cli/builtin_models/data-plane.json +432 -0
  15. zilliz_cli-0.1.1/src/zilliz_cli/cli.py +84 -0
  16. zilliz_cli-0.1.1/src/zilliz_cli/commands/__init__.py +0 -0
  17. zilliz_cli-0.1.1/src/zilliz_cli/commands/auth.py +303 -0
  18. zilliz_cli-0.1.1/src/zilliz_cli/commands/configure.py +96 -0
  19. zilliz_cli-0.1.1/src/zilliz_cli/commands/context.py +70 -0
  20. zilliz_cli-0.1.1/src/zilliz_cli/commands/version.py +14 -0
  21. zilliz_cli-0.1.1/src/zilliz_cli/core/__init__.py +0 -0
  22. zilliz_cli-0.1.1/src/zilliz_cli/core/api_caller.py +67 -0
  23. zilliz_cli-0.1.1/src/zilliz_cli/core/command_factory.py +230 -0
  24. zilliz_cli-0.1.1/src/zilliz_cli/core/exceptions.py +31 -0
  25. zilliz_cli-0.1.1/src/zilliz_cli/core/model.py +130 -0
  26. zilliz_cli-0.1.1/src/zilliz_cli/core/model_loader.py +24 -0
  27. zilliz_cli-0.1.1/src/zilliz_cli/formatter/__init__.py +0 -0
  28. zilliz_cli-0.1.1/src/zilliz_cli/formatter/base.py +27 -0
  29. zilliz_cli-0.1.1/src/zilliz_cli/formatter/json.py +11 -0
  30. zilliz_cli-0.1.1/src/zilliz_cli/formatter/table.py +44 -0
  31. zilliz_cli-0.1.1/src/zilliz_cli/formatter/text.py +18 -0
  32. zilliz_cli-0.1.1/tests/__init__.py +0 -0
  33. zilliz_cli-0.1.1/tests/acceptance/__init__.py +0 -0
  34. zilliz_cli-0.1.1/tests/acceptance/conftest.py +277 -0
  35. zilliz_cli-0.1.1/tests/acceptance/test_phase1_local.py +204 -0
  36. zilliz_cli-0.1.1/tests/acceptance/test_phase2_backup.py +55 -0
  37. zilliz_cli-0.1.1/tests/acceptance/test_phase2_cluster.py +87 -0
  38. zilliz_cli-0.1.1/tests/acceptance/test_phase2_project.py +51 -0
  39. zilliz_cli-0.1.1/tests/acceptance/test_phase2_region.py +44 -0
  40. zilliz_cli-0.1.1/tests/acceptance/test_phase3_alias.py +84 -0
  41. zilliz_cli-0.1.1/tests/acceptance/test_phase3_collection.py +114 -0
  42. zilliz_cli-0.1.1/tests/acceptance/test_phase3_context.py +43 -0
  43. zilliz_cli-0.1.1/tests/acceptance/test_phase3_database.py +42 -0
  44. zilliz_cli-0.1.1/tests/acceptance/test_phase3_index.py +77 -0
  45. zilliz_cli-0.1.1/tests/acceptance/test_phase3_partition.py +117 -0
  46. zilliz_cli-0.1.1/tests/acceptance/test_phase3_role.py +109 -0
  47. zilliz_cli-0.1.1/tests/acceptance/test_phase3_user.py +109 -0
  48. zilliz_cli-0.1.1/tests/acceptance/test_phase3_vector.py +224 -0
  49. zilliz_cli-0.1.1/tests/conftest.py +16 -0
  50. zilliz_cli-0.1.1/tests/e2e/__init__.py +0 -0
  51. zilliz_cli-0.1.1/tests/e2e/conftest.py +24 -0
  52. zilliz_cli-0.1.1/tests/e2e/test_collection_e2e.py +36 -0
  53. zilliz_cli-0.1.1/tests/e2e/test_configure_e2e.py +45 -0
  54. zilliz_cli-0.1.1/tests/e2e/test_context_e2e.py +35 -0
  55. zilliz_cli-0.1.1/tests/e2e/test_vector_e2e.py +43 -0
  56. zilliz_cli-0.1.1/tests/unit/__init__.py +0 -0
  57. zilliz_cli-0.1.1/tests/unit/test_api_caller.py +87 -0
  58. zilliz_cli-0.1.1/tests/unit/test_cluster_cmd.py +112 -0
  59. zilliz_cli-0.1.1/tests/unit/test_collection_cmd.py +195 -0
  60. zilliz_cli-0.1.1/tests/unit/test_command_factory.py +278 -0
  61. zilliz_cli-0.1.1/tests/unit/test_config.py +88 -0
  62. zilliz_cli-0.1.1/tests/unit/test_configure_cmd.py +66 -0
  63. zilliz_cli-0.1.1/tests/unit/test_context_cmd.py +136 -0
  64. zilliz_cli-0.1.1/tests/unit/test_credentials.py +33 -0
  65. zilliz_cli-0.1.1/tests/unit/test_formatter.py +89 -0
  66. zilliz_cli-0.1.1/tests/unit/test_model.py +99 -0
  67. zilliz_cli-0.1.1/tests/unit/test_model_loader.py +236 -0
  68. zilliz_cli-0.1.1/tests/unit/test_vector_cmd.py +176 -0
  69. zilliz_cli-0.1.1/tests/unit/test_version_cmd.py +19 -0
Binary file
@@ -0,0 +1,2 @@
1
+ # Documentation (design docs, plans)
2
+ docs/
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: zilliz-cli
3
+ Version: 0.1.1
4
+ Summary: CLI for Zilliz Cloud resource management and Milvus operations
5
+ Project-URL: Homepage, https://zilliz.com
6
+ Project-URL: Documentation, https://docs.zilliz.com
7
+ Author-email: Zilliz <support@zilliz.com>
8
+ License-Expression: Apache-2.0
9
+ Keywords: cli,milvus,vector-database,zilliz
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: click>=8.1.0
19
+ Requires-Dist: httpx>=0.25.0
20
+ Requires-Dist: questionary>=2.0.0
21
+ Requires-Dist: rich>=13.0.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: mypy>=1.10.0; extra == 'dev'
24
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
25
+ Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
26
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Zilliz CLI
31
+
32
+ Command-line tool for Zilliz Cloud cluster management and Milvus vector database operations.
33
+
34
+ ## Requirements
35
+
36
+ - Python 3.10+
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ pip install zilliz-cli
42
+ ```
43
+
44
+ For development (from source):
45
+
46
+ ```bash
47
+ git clone git@github.com:zilliztech/zilliz-cloud.git
48
+ cd zilliz-cloud/vdc/zilliz-cli
49
+ pip install -e ".[dev]"
50
+ ```
51
+
52
+ ## Quick Start
53
+
54
+ ```bash
55
+ # 1. Configure API Key
56
+ zilliz configure
57
+ # or
58
+ export ZILLIZ_API_KEY=your-api-key
59
+
60
+ # 2. List clusters
61
+ zilliz cluster list
62
+
63
+ # 3. Set cluster context (auto-resolves endpoint)
64
+ zilliz context set --cluster-id in01-xxxx
65
+
66
+ # 4. Work with collections and vectors
67
+ zilliz collection list
68
+ zilliz vector search --collection my_col --data '[[0.1, 0.2, 0.3]]' --limit 5
69
+ ```
70
+
71
+ ## Commands
72
+
73
+ ### Configuration
74
+
75
+ ```bash
76
+ # Interactive setup
77
+ zilliz configure
78
+
79
+ # Set individual values
80
+ zilliz configure set api_key YOUR_KEY
81
+ zilliz configure set output json
82
+
83
+ # View values
84
+ zilliz configure get api_key
85
+ zilliz configure list
86
+ ```
87
+
88
+ ### Context
89
+
90
+ ```bash
91
+ # Set cluster context (endpoint auto-resolved)
92
+ zilliz context set --cluster-id in01-xxxx
93
+
94
+ # Set with specific database
95
+ zilliz context set --cluster-id in01-xxxx --database mydb
96
+
97
+ # Change database only
98
+ zilliz context set --database another_db
99
+
100
+ # Manual endpoint override
101
+ zilliz context set --cluster-id in01-xxxx --endpoint https://custom.endpoint.com
102
+
103
+ # View current context
104
+ zilliz context current
105
+ ```
106
+
107
+ ### Cluster Management
108
+
109
+ ```bash
110
+ # List all clusters
111
+ zilliz cluster list
112
+ zilliz cluster list --output json
113
+
114
+ # Describe a cluster
115
+ zilliz cluster describe --cluster-id in01-xxxx
116
+
117
+ # Create a serverless cluster
118
+ zilliz cluster create --name my-cluster --project-id p1 --region gcp-us-west1
119
+
120
+ # Delete a cluster
121
+ zilliz cluster delete --cluster-id in01-xxxx
122
+ ```
123
+
124
+ ### Collection Operations
125
+
126
+ Requires a context to be set first (`zilliz context set --cluster-id ...`).
127
+
128
+ ```bash
129
+ # List collections
130
+ zilliz collection list
131
+
132
+ # Describe a collection
133
+ zilliz collection describe --name my_collection
134
+
135
+ # Quick Setup: create with dimension and metric type
136
+ zilliz collection create --name my_collection --dimension 768 --metric-type COSINE
137
+
138
+ # Custom Setup: create with full JSON schema
139
+ zilliz collection create --body '{"collectionName": "my_col", "schema": {...}}'
140
+ zilliz collection create --body file://schema.json
141
+ ```
142
+
143
+ ### Vector Operations
144
+
145
+ Requires a context to be set first (`zilliz context set --cluster-id ...`).
146
+
147
+ ```bash
148
+ # Vector search
149
+ zilliz vector search --collection my_col --data '[[0.1, 0.2, 0.3]]' --limit 10
150
+ zilliz vector search --collection my_col --data '[[0.1, 0.2, 0.3]]' --filter "age > 20" --output-fields '["name", "age"]'
151
+
152
+ # Query by filter
153
+ zilliz vector query --collection my_col --filter "id in [1, 2, 3]" --limit 10
154
+ zilliz vector query --collection my_col --filter "age > 20" --output-fields '["name", "age"]'
155
+
156
+ # Insert data
157
+ zilliz vector insert --collection my_col --data '[{"id": 1, "vector": [0.1, 0.2], "name": "doc1"}]'
158
+ ```
159
+
160
+ ### Version
161
+
162
+ ```bash
163
+ zilliz version
164
+ zilliz version --output json
165
+ ```
166
+
167
+ ## Global Options
168
+
169
+ | Option | Description |
170
+ |--------|-------------|
171
+ | `--output`, `-o` | Output format: `json`, `table`, `text` |
172
+ | `--api-key` | API key (overrides config file and env var) |
173
+ | `--help` | Show help |
174
+
175
+ ## Configuration
176
+
177
+ ### Credential Resolution
178
+
179
+ API Key is resolved in order (first found wins):
180
+ 1. `--api-key` CLI flag
181
+ 2. `ZILLIZ_API_KEY` environment variable
182
+ 3. `~/.zilliz/credentials` file
183
+
184
+ ### Config Files
185
+
186
+ ```
187
+ ~/.zilliz/
188
+ credentials # API key
189
+ config # CLI settings + cluster context
190
+ ```
191
+
192
+ ## Output Formats
193
+
194
+ ```bash
195
+ # Table (default, human-friendly)
196
+ zilliz cluster list
197
+
198
+ # JSON (machine/agent-friendly)
199
+ zilliz cluster list --output json
200
+
201
+ # Plain text
202
+ zilliz cluster list --output text
203
+ ```
204
+
205
+ ## Testing
206
+
207
+ ```bash
208
+ # Run unit tests
209
+ pytest tests/unit/
210
+
211
+ # Run all tests (E2E tests skipped without API key)
212
+ pytest
213
+
214
+ # Run E2E tests (requires real API key)
215
+ ZILLIZ_API_KEY=your-key pytest -m e2e
216
+
217
+ # Run E2E tests with data plane (requires cluster)
218
+ ZILLIZ_API_KEY=your-key ZILLIZ_CLUSTER_ID=in01-xxxx pytest -m e2e
219
+ ```
220
+
221
+ ## License
222
+
223
+ Apache-2.0
@@ -0,0 +1,194 @@
1
+ # Zilliz CLI
2
+
3
+ Command-line tool for Zilliz Cloud cluster management and Milvus vector database operations.
4
+
5
+ ## Requirements
6
+
7
+ - Python 3.10+
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install zilliz-cli
13
+ ```
14
+
15
+ For development (from source):
16
+
17
+ ```bash
18
+ git clone git@github.com:zilliztech/zilliz-cloud.git
19
+ cd zilliz-cloud/vdc/zilliz-cli
20
+ pip install -e ".[dev]"
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```bash
26
+ # 1. Configure API Key
27
+ zilliz configure
28
+ # or
29
+ export ZILLIZ_API_KEY=your-api-key
30
+
31
+ # 2. List clusters
32
+ zilliz cluster list
33
+
34
+ # 3. Set cluster context (auto-resolves endpoint)
35
+ zilliz context set --cluster-id in01-xxxx
36
+
37
+ # 4. Work with collections and vectors
38
+ zilliz collection list
39
+ zilliz vector search --collection my_col --data '[[0.1, 0.2, 0.3]]' --limit 5
40
+ ```
41
+
42
+ ## Commands
43
+
44
+ ### Configuration
45
+
46
+ ```bash
47
+ # Interactive setup
48
+ zilliz configure
49
+
50
+ # Set individual values
51
+ zilliz configure set api_key YOUR_KEY
52
+ zilliz configure set output json
53
+
54
+ # View values
55
+ zilliz configure get api_key
56
+ zilliz configure list
57
+ ```
58
+
59
+ ### Context
60
+
61
+ ```bash
62
+ # Set cluster context (endpoint auto-resolved)
63
+ zilliz context set --cluster-id in01-xxxx
64
+
65
+ # Set with specific database
66
+ zilliz context set --cluster-id in01-xxxx --database mydb
67
+
68
+ # Change database only
69
+ zilliz context set --database another_db
70
+
71
+ # Manual endpoint override
72
+ zilliz context set --cluster-id in01-xxxx --endpoint https://custom.endpoint.com
73
+
74
+ # View current context
75
+ zilliz context current
76
+ ```
77
+
78
+ ### Cluster Management
79
+
80
+ ```bash
81
+ # List all clusters
82
+ zilliz cluster list
83
+ zilliz cluster list --output json
84
+
85
+ # Describe a cluster
86
+ zilliz cluster describe --cluster-id in01-xxxx
87
+
88
+ # Create a serverless cluster
89
+ zilliz cluster create --name my-cluster --project-id p1 --region gcp-us-west1
90
+
91
+ # Delete a cluster
92
+ zilliz cluster delete --cluster-id in01-xxxx
93
+ ```
94
+
95
+ ### Collection Operations
96
+
97
+ Requires a context to be set first (`zilliz context set --cluster-id ...`).
98
+
99
+ ```bash
100
+ # List collections
101
+ zilliz collection list
102
+
103
+ # Describe a collection
104
+ zilliz collection describe --name my_collection
105
+
106
+ # Quick Setup: create with dimension and metric type
107
+ zilliz collection create --name my_collection --dimension 768 --metric-type COSINE
108
+
109
+ # Custom Setup: create with full JSON schema
110
+ zilliz collection create --body '{"collectionName": "my_col", "schema": {...}}'
111
+ zilliz collection create --body file://schema.json
112
+ ```
113
+
114
+ ### Vector Operations
115
+
116
+ Requires a context to be set first (`zilliz context set --cluster-id ...`).
117
+
118
+ ```bash
119
+ # Vector search
120
+ zilliz vector search --collection my_col --data '[[0.1, 0.2, 0.3]]' --limit 10
121
+ zilliz vector search --collection my_col --data '[[0.1, 0.2, 0.3]]' --filter "age > 20" --output-fields '["name", "age"]'
122
+
123
+ # Query by filter
124
+ zilliz vector query --collection my_col --filter "id in [1, 2, 3]" --limit 10
125
+ zilliz vector query --collection my_col --filter "age > 20" --output-fields '["name", "age"]'
126
+
127
+ # Insert data
128
+ zilliz vector insert --collection my_col --data '[{"id": 1, "vector": [0.1, 0.2], "name": "doc1"}]'
129
+ ```
130
+
131
+ ### Version
132
+
133
+ ```bash
134
+ zilliz version
135
+ zilliz version --output json
136
+ ```
137
+
138
+ ## Global Options
139
+
140
+ | Option | Description |
141
+ |--------|-------------|
142
+ | `--output`, `-o` | Output format: `json`, `table`, `text` |
143
+ | `--api-key` | API key (overrides config file and env var) |
144
+ | `--help` | Show help |
145
+
146
+ ## Configuration
147
+
148
+ ### Credential Resolution
149
+
150
+ API Key is resolved in order (first found wins):
151
+ 1. `--api-key` CLI flag
152
+ 2. `ZILLIZ_API_KEY` environment variable
153
+ 3. `~/.zilliz/credentials` file
154
+
155
+ ### Config Files
156
+
157
+ ```
158
+ ~/.zilliz/
159
+ credentials # API key
160
+ config # CLI settings + cluster context
161
+ ```
162
+
163
+ ## Output Formats
164
+
165
+ ```bash
166
+ # Table (default, human-friendly)
167
+ zilliz cluster list
168
+
169
+ # JSON (machine/agent-friendly)
170
+ zilliz cluster list --output json
171
+
172
+ # Plain text
173
+ zilliz cluster list --output text
174
+ ```
175
+
176
+ ## Testing
177
+
178
+ ```bash
179
+ # Run unit tests
180
+ pytest tests/unit/
181
+
182
+ # Run all tests (E2E tests skipped without API key)
183
+ pytest
184
+
185
+ # Run E2E tests (requires real API key)
186
+ ZILLIZ_API_KEY=your-key pytest -m e2e
187
+
188
+ # Run E2E tests with data plane (requires cluster)
189
+ ZILLIZ_API_KEY=your-key ZILLIZ_CLUSTER_ID=in01-xxxx pytest -m e2e
190
+ ```
191
+
192
+ ## License
193
+
194
+ Apache-2.0
@@ -0,0 +1,83 @@
1
+ # Copyright (c) 2026 Zilliz Inc. All rights reserved.
2
+ #
3
+ # PROPRIETARY AND CONFIDENTIAL
4
+ #
5
+ # This file contains proprietary information of Zilliz Inc.
6
+ #
7
+ # No part of this file may be reproduced, stored, transmitted,
8
+ # or disclosed to any third party without the prior written
9
+ # permission of Zilliz Inc.
10
+ #
11
+ # Unauthorized use is strictly prohibited.
12
+
13
+ [build-system]
14
+ requires = ["hatchling"]
15
+ build-backend = "hatchling.build"
16
+
17
+ [project]
18
+ name = "zilliz-cli"
19
+ version = "0.1.1"
20
+ description = "CLI for Zilliz Cloud resource management and Milvus operations"
21
+ readme = "README.md"
22
+ license = "Apache-2.0"
23
+ requires-python = ">=3.10"
24
+ authors = [
25
+ { name = "Zilliz", email = "support@zilliz.com" }
26
+ ]
27
+ keywords = ["zilliz", "milvus", "vector-database", "cli"]
28
+ classifiers = [
29
+ "Development Status :: 3 - Alpha",
30
+ "Environment :: Console",
31
+ "Intended Audience :: Developers",
32
+ "License :: OSI Approved :: Apache Software License",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ ]
37
+ dependencies = [
38
+ "click>=8.1.0",
39
+ "httpx>=0.25.0",
40
+ "rich>=13.0.0",
41
+ "questionary>=2.0.0",
42
+ ]
43
+
44
+ [project.optional-dependencies]
45
+ dev = [
46
+ "pytest>=7.0.0",
47
+ "pytest-cov>=4.0.0",
48
+ "pytest-httpx>=0.30.0",
49
+ "ruff>=0.4.0",
50
+ "mypy>=1.10.0",
51
+ ]
52
+
53
+ [project.scripts]
54
+ zilliz = "zilliz_cli.cli:main"
55
+
56
+ [project.urls]
57
+ Homepage = "https://zilliz.com"
58
+ Documentation = "https://docs.zilliz.com"
59
+
60
+ [tool.hatch.build.targets.wheel]
61
+ packages = ["src/zilliz_cli"]
62
+
63
+ [tool.pytest.ini_options]
64
+ testpaths = ["tests"]
65
+ addopts = "-v"
66
+ markers = [
67
+ "e2e: end-to-end tests that run the CLI as a subprocess",
68
+ "acceptance: full lifecycle acceptance tests requiring ZILLIZ_API_KEY",
69
+ ]
70
+
71
+ [tool.ruff]
72
+ target-version = "py310"
73
+ line-length = 120
74
+
75
+ [tool.ruff.lint]
76
+ select = ["E", "F", "W", "I"]
77
+ ignore = ["E501"]
78
+
79
+ [tool.mypy]
80
+ python_version = "3.10"
81
+ warn_return_any = false
82
+ warn_unused_configs = true
83
+ ignore_missing_imports = true
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env python3
2
+ """Clean up leftover acceptance test resources (clusters and collections).
3
+
4
+ Usage:
5
+ ZILLIZ_API_KEY=xxx python scripts/cleanup_test_resources.py # actual cleanup
6
+ ZILLIZ_API_KEY=xxx python scripts/cleanup_test_resources.py --dry-run # list only
7
+ """
8
+ import argparse
9
+ import json
10
+ import os
11
+ import subprocess
12
+ import sys
13
+
14
+ CLUSTER_PREFIX = "zilliz-cli-test-"
15
+ COLLECTION_PREFIX = "zilliz_cli_test_"
16
+
17
+
18
+ def run_cli(*args):
19
+ env = os.environ.copy()
20
+ result = subprocess.run(
21
+ ["zilliz", *args],
22
+ capture_output=True,
23
+ text=True,
24
+ env=env,
25
+ timeout=30,
26
+ )
27
+ return result
28
+
29
+
30
+ def main():
31
+ parser = argparse.ArgumentParser(description="Clean up test resources")
32
+ parser.add_argument("--dry-run", action="store_true", help="List resources without deleting")
33
+ args = parser.parse_args()
34
+
35
+ if not os.environ.get("ZILLIZ_API_KEY"):
36
+ print("Error: ZILLIZ_API_KEY environment variable is required", file=sys.stderr)
37
+ sys.exit(1)
38
+
39
+ # Find test clusters
40
+ result = run_cli("cluster", "list", "--all", "-o", "json")
41
+ if result.returncode != 0:
42
+ print(f"Error listing clusters: {result.stderr}", file=sys.stderr)
43
+ sys.exit(1)
44
+
45
+ clusters = json.loads(result.stdout)
46
+ test_clusters = [c for c in clusters if c["clusterName"].startswith(CLUSTER_PREFIX)]
47
+
48
+ if not test_clusters:
49
+ print("No test resources found.")
50
+ return
51
+
52
+ print(f"Found {len(test_clusters)} test cluster(s):")
53
+ for c in test_clusters:
54
+ print(f" {c['clusterId']} ({c['clusterName']}) - {c['status']}")
55
+
56
+ if args.dry_run:
57
+ print("\n[DRY RUN] No resources deleted.")
58
+ return
59
+
60
+ # Clean up each cluster
61
+ for c in test_clusters:
62
+ cluster_id = c["clusterId"]
63
+ print(f"\nCleaning up cluster {cluster_id} ({c['clusterName']})...")
64
+
65
+ # Try to set context and clean collections
66
+ if c["status"] == "RUNNING":
67
+ ctx_result = run_cli("context", "set", "--cluster-id", cluster_id)
68
+ if ctx_result.returncode == 0:
69
+ col_result = run_cli("collection", "list", "-o", "json")
70
+ if col_result.returncode == 0:
71
+ collections = json.loads(col_result.stdout)
72
+ for col_name in collections:
73
+ if col_name.startswith(COLLECTION_PREFIX):
74
+ print(f" Dropping collection: {col_name}")
75
+ run_cli("collection", "drop", "--name", col_name)
76
+
77
+ # Delete cluster
78
+ print(f" Deleting cluster: {cluster_id}")
79
+ del_result = run_cli("cluster", "delete", "--cluster-id", cluster_id)
80
+ if del_result.returncode == 0:
81
+ print(f" Deleted: {cluster_id}")
82
+ else:
83
+ print(f" Failed to delete {cluster_id}: {del_result.stderr}")
84
+
85
+ print("\nCleanup complete.")
86
+
87
+
88
+ if __name__ == "__main__":
89
+ main()
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,3 @@
1
+ from zilliz_cli.cli import main
2
+
3
+ main()
File without changes