audit_taiga.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import requests
  2. import urllib3
  3. urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
  4. base_url = 'https://192.168.130.161/taiga/api/v1'
  5. def audit():
  6. try:
  7. auth = requests.post(f'{base_url}/auth', json={'type': 'normal', 'username': 'FrancoisLange', 'password': 'BTSai123'}, verify=False).json()
  8. headers = {'Authorization': f'Bearer {auth["auth_token"]}', 'Content-Type': 'application/json'}
  9. proj_id = 21
  10. milestones = requests.get(f'{base_url}/milestones?project={proj_id}', headers=headers, verify=False).json()
  11. sprint11 = next((m for m in milestones if m['name'] == 'Sprint 11'), None)
  12. if not sprint11:
  13. print("Sprint 11 not found.")
  14. return
  15. sprint_id = sprint11['id']
  16. print(f"--- SPRINT 11 AUDIT ---")
  17. us_statuses = requests.get(f'{base_url}/userstory-statuses?project={proj_id}', headers=headers, verify=False).json()
  18. status_map = {s['id']: s['name'] for s in us_statuses}
  19. us_list = requests.get(f'{base_url}/userstories?project={proj_id}&milestone={sprint_id}', headers=headers, verify=False).json()
  20. all_closed = True
  21. for us in us_list:
  22. status_name = status_map.get(us['status'], 'Unknown')
  23. print(f"[US] {us['subject']} - Status: {status_name}")
  24. if status_name.lower() != 'closed':
  25. all_closed = False
  26. print(f"Sprint fully closed? {'YES' if all_closed else 'NO'}")
  27. except Exception as e:
  28. print(f"Failed to audit Taiga: {e}")
  29. if __name__ == "__main__":
  30. audit()