import requests, os

token = open(os.path.expanduser('~/.pypirc')).read().split('password = ')[1].split()[0]
headers = {'Authorization': f'token {token}'}

# Try various yank endpoints
endpoints = [
    ('POST', '/manage/project/aalgoi/release/2.0.0/_yank/'),
    ('POST', '/manage/project/aalgoi/release/2.0.0/yank/'),
    ('POST', '/pypi/aalgoi/2.0.0/_yank/'),
    ('POST', '/api/v2/project/aalgoi/version/2.0.0/'),
]

for method, path in endpoints:
    url = f'https://pypi.org{path}'
    if method == 'POST':
        r = requests.post(url, data={}, headers=headers, allow_redirects=False)
    else:
        r = requests.patch(url, json={}, headers=headers, allow_redirects=False)
    print(f'{method} {path}: {r.status_code}', end='')
    loc = r.headers.get('Location', '')
    if loc:
        print(f' -> {loc}')
    else:
        print()
