mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-05-03 07:04:58 -04:00
Initial work to create and delete droplets
This commit is contained in:
parent
f79198c545
commit
86076c8700
13 changed files with 481 additions and 0 deletions
20
scripts/cicd-python/utils/test_credentials.py
Normal file
20
scripts/cicd-python/utils/test_credentials.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
import aiohttp
|
||||
import sys
|
||||
|
||||
async def test_api_credentials(token: str) -> None:
|
||||
headers = {
|
||||
"Authorization": f"Bearer {token}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = "https://api.digitalocean.com/v2/droplets"
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url, headers=headers) as resp:
|
||||
if resp.status == 200:
|
||||
data = await resp.json()
|
||||
droplets = data.get("droplets", [])
|
||||
print("API credentials are valid.")
|
||||
print(f"Retrieved {len(droplets)} droplet(s).")
|
||||
else:
|
||||
error_text = await resp.text()
|
||||
print("Failed to authenticate API credentials:", error_text, file=sys.stderr)
|
||||
sys.exit(error_text)
|
Loading…
Add table
Add a link
Reference in a new issue