taiga_closeout.py 894 B

123456789101112
  1. import requests, urllib3
  2. urllib3.disable_warnings()
  3. auth = requests.post('https://192.168.130.161/taiga/api/v1/auth', json={'type': 'normal', 'username': 'FrancoisLange', 'password': 'BTSai123'}, verify=False).json()
  4. headers = {'Authorization': f'Bearer {auth["auth_token"]}'}
  5. epic_statuses = requests.get('https://192.168.130.161/taiga/api/v1/epic-statuses?project=21', headers=headers, verify=False).json()
  6. epic_closed_status = next((s['id'] for s in epic_statuses if s['is_closed']), None)
  7. epic = requests.get('https://192.168.130.161/taiga/api/v1/epics/by_ref?ref=28&project=21', headers=headers, verify=False).json()
  8. if 'id' in epic:
  9. resp = requests.patch(f'https://192.168.130.161/taiga/api/v1/epics/{epic["id"]}', headers=headers, json={'status': epic_closed_status, 'version': epic['version']}, verify=False)
  10. print(f'Epic TG-{epic["ref"]} Closing Status: {resp.status_code}')