mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-05-02 14:46:12 -04:00
Converting CICD from Bash to Python Scripts [ci dryrun]
This commit is contained in:
parent
ab3cf25647
commit
40f39a2c9b
14 changed files with 869 additions and 38 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