taiga_feed.py 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. import requests, urllib3
  2. urllib3.disable_warnings()
  3. auth = requests.post(
  4. 'https://192.168.130.161/taiga/api/v1/auth',
  5. json={'type': 'normal', 'username': 'lanfr1904@outlook.com', 'password': 'BTSai123'},
  6. verify=False
  7. ).json()
  8. headers = {'Authorization': f'Bearer {auth["auth_token"]}'}
  9. proj_id = 21
  10. pts = requests.get(f'https://192.168.130.161/taiga/api/v1/points?project={proj_id}', headers=headers, verify=False).json()
  11. pt_map = {p['value']: p['id'] for p in pts}
  12. five_pt_id = pt_map.get(5)
  13. roles = requests.get(f'https://192.168.130.161/taiga/api/v1/roles?project={proj_id}', headers=headers, verify=False).json()
  14. role_id = roles[0]['id']
  15. us_list = requests.get(f'https://192.168.130.161/taiga/api/v1/userstories?project={proj_id}', headers=headers, verify=False).json()
  16. for us in us_list:
  17. if us.get('total_points') == 0 or us.get('total_points') is None:
  18. points_payload = us.get('points', {})
  19. points_payload[str(role_id)] = five_pt_id
  20. resp = requests.patch(
  21. f'https://192.168.130.161/taiga/api/v1/userstories/{us["id"]}',
  22. headers=headers,
  23. json={'points': points_payload, 'version': us['version']},
  24. verify=False
  25. )
  26. print(f"Patched US {us['ref']} to 5 Points! Status: {resp.status_code}")