Created
May 18, 2023 12:10
-
-
Save arssher/0a94230d971f56957845f3a8dadf6c0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import time | |
| import requests | |
| import sys | |
| HEADERS = { | |
| 'Authorization': 'Bearer ' + os.environ['NEON_API_KEY'], | |
| } | |
| params = {'limit': 100} | |
| while True: | |
| projects = requests.get( | |
| 'https://console.stage.neon.tech/api/v2/projects', | |
| headers=HEADERS, | |
| params=params | |
| ).json() | |
| cursor = projects['pagination']['cursor'] | |
| params['cursor'] = cursor | |
| projects = projects['projects'] | |
| print(f"fetched {len(projects)} projects") | |
| if len(projects) == 0: | |
| break | |
| for p in projects: | |
| if p['region_id'] == 'aws-eu-west-1': | |
| p_id = p['id'] | |
| print(f"deleting project {p_id}") | |
| del_resp = requests.delete( | |
| f"https://console.stage.neon.tech/api/v2/projects/{p_id}", | |
| headers=HEADERS, | |
| ) | |
| del_resp.raise_for_status() | |
| time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment