forked from vast-ai/vast-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_verify_status.py
More file actions
executable file
·57 lines (48 loc) · 1.8 KB
/
set_verify_status.py
File metadata and controls
executable file
·57 lines (48 loc) · 1.8 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
#!/usr/bin/env python3
import sys
import os
import requests
import json
def main():
if len(sys.argv) < 3:
print("Usage: set_verify_status.py <machine_id> <verification_status>")
print("Example: set_verify_status.py 29309 verified")
sys.exit(1)
machine_id = sys.argv[1]
verification_status = sys.argv[2]
# Get your admin token from env variable (or hardcode for testing)
# For example, if you have `export ADMIN_TOKEN="eyJhbGciOiJIUzI1NiIsInR..."`
admin_token = os.getenv("ADMIN_TOKEN")
if not admin_token:
print("ERROR: ADMIN_TOKEN environment variable not set.")
sys.exit(1)
# The payload to match your admin_set_machines_verification_status endpoint
payload = {
"machine_ids": [int(machine_id)],
"verification": verification_status
}
# Adjust the URL to your deployment or dev server:
url = "https://cloud.vast.ai/api/admin/set_machines_verification_status"
headers = {
"Content-Type": "application/json",
# For example, if you do Bearer tokens:
"Authorization": f"Bearer {admin_token}"
}
try:
response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
except requests.exceptions.HTTPError as e:
print(f"HTTP Error: {e}")
print("Response content:", response.text)
sys.exit(1)
except requests.exceptions.RequestException as e:
print(f"Request Error: {e}")
sys.exit(1)
# If we got here, the request succeeded (2xx)
resp_json = response.json()
if "success" in resp_json and resp_json["success"] == True:
print(f"Success: Machine {machine_id} set to {verification_status}")
else:
print("Response from server:", resp_json)
if __name__ == "__main__":
main()