Coverage for src / main / python / services / projects.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-17 22:29 +0000

1import sys 

2from typing import Any, cast 

3 

4import requests 

5 

6 

7def get_projects_by_team( 

8 bearer_token: str, org_name: str, team_name: str 

9) -> list[dict[str, Any]]: 

10 """ 

11 Retrieve a list of projects for a given team using bearer token authentication. 

12 

13 Args: 

14 bearer_token (str): The bearer token for authentication 

15 team_name (str): The name of the team to get projects for 

16 

17 Returns: 

18 List[Dict[str, Any]]: A list of project dictionaries 

19 """ 

20 headers = { 

21 "Authorization": f"Bearer {bearer_token}", 

22 "Content-Type": "application/json", 

23 } 

24 

25 # Replace with actual API endpoint 

26 url = f"https://{org_name}.pam.okta.com/v1/teams/{team_name}/projects" 

27 

28 try: 

29 # print(f"Fetching projects from URL: {url} with headers: {headers}") 

30 response = requests.get(url, headers=headers) 

31 response.raise_for_status() 

32 return cast(list[dict[str, Any]], response.json()) 

33 except requests.exceptions.RequestException as e: 

34 print(f"Error fetching projects: {e}", file=sys.stderr) 

35 return []