setup_sprint7_taiga.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import requests
  2. import urllib3
  3. from datetime import datetime, timedelta
  4. urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
  5. # Authenticate
  6. base_url = 'https://192.168.130.161/taiga/api/v1'
  7. auth_url = f'{base_url}/auth'
  8. auth = requests.post(auth_url, json={'type': 'normal', 'username': 'FrancoisLange', 'password': 'BTSai123'}, verify=False).json()
  9. headers = {'Authorization': f'Bearer {auth["auth_token"]}', 'Content-Type': 'application/json'}
  10. proj_id = 21
  11. print("Fetching Sprints...")
  12. milestones = requests.get(f'{base_url}/milestones?project={proj_id}', headers=headers, verify=False).json()
  13. sprint7 = next((m for m in milestones if m['name'] == 'Sprint 7'), None)
  14. if not sprint7:
  15. print("Sprint 7 not found, creating it...")
  16. payload = {
  17. "project": proj_id,
  18. "name": "Sprint 7",
  19. "estimated_start": datetime.now().strftime('%Y-%m-%d'),
  20. "estimated_finish": (datetime.now() + timedelta(days=7)).strftime('%Y-%m-%d')
  21. }
  22. sprint7 = requests.post(f'{base_url}/milestones', json=payload, headers=headers, verify=False).json()
  23. sprint_id = sprint7['id']
  24. print(f"Sprint 7 ID: {sprint_id}")
  25. stories = [
  26. {"subject": "Zabbix Server Docker Setup", "description": "Deploy Zabbix server, Zabbix Web, and Zabbix Agent via Docker compose utilizing the host MySQL database."},
  27. {"subject": "SNMPv3 Integration", "description": "Implement pysnmp to send AuthPriv SNMPv3 traps to Zabbix."},
  28. {"subject": "Application Component Traps", "description": "Inject SNMP traps into Streamlit app.py and background ingestion processes."}
  29. ]
  30. for s in stories:
  31. payload = {
  32. "project": proj_id,
  33. "subject": s["subject"],
  34. "description": s["description"],
  35. "milestone": sprint_id
  36. }
  37. res = requests.post(f'{base_url}/userstories', json=payload, headers=headers, verify=False)
  38. if res.status_code == 201:
  39. us = res.json()
  40. print(f"Created US: {us['subject']}")
  41. # Create a task for it
  42. t_payload = {
  43. "project": proj_id,
  44. "subject": f"Execute: {us['subject']}",
  45. "user_story": us['id'],
  46. "milestone": sprint_id
  47. }
  48. requests.post(f'{base_url}/tasks', json=t_payload, headers=headers, verify=False)
  49. else:
  50. print(f"Failed US: {res.text}")
  51. print("Sprint 7 populated!")