88def get_all () -> DataframableList [TeamRef ]:
99 """No fuzzy name matching."""
1010 res = get_nexus_client ().get (
11- "/api/v5/user/ teams" ,
11+ "/api/teams/v1beta2 " ,
1212 )
1313
1414 if res .status_code != 200 :
@@ -18,10 +18,10 @@ def get_all() -> DataframableList[TeamRef]:
1818 [
1919 TeamRef (
2020 id = team ["id" ],
21- name = team ["team_name " ],
22- description = team ["description" ],
21+ name = team ["attributes" ][ "name " ],
22+ description = team ["attributes" ][ " description" ],
2323 )
24- for team in res .json ()
24+ for team in res .json ()[ "data" ]
2525 ]
2626 )
2727
@@ -31,9 +31,11 @@ def get(name: str) -> TeamRef:
3131 Get a single team using filters. Throws an exception if the filters do not
3232 match exactly one object.
3333 """
34- res = get_nexus_client ().get ("/api/v5/user/teams" , params = {"name" : name })
34+ res = get_nexus_client ().get (
35+ "/api/teams/v1beta2" , params = {"filter[team][name]" : name }
36+ )
3537
36- if res .status_code == 404 or res .json () == []:
38+ if res .status_code == 404 or res .json ()[ "data" ] == []:
3739 raise qnx_exc .ZeroMatches
3840
3941 if res .status_code != 200 :
@@ -42,13 +44,14 @@ def get(name: str) -> TeamRef:
4244 teams_list = [
4345 TeamRef (
4446 id = team ["id" ],
45- name = team ["team_name " ],
46- description = team ["description" ],
47+ name = team ["attributes" ][ "name " ],
48+ description = team ["attributes" ][ " description" ],
4749 )
48- for team in res .json ()
50+ for team in res .json ()[ "data" ]
4951 ]
5052
5153 if len (teams_list ) > 1 :
54+ print (teams_list )
5255 raise qnx_exc .NoUniqueMatch
5356
5457 return teams_list [0 ]
@@ -58,31 +61,38 @@ def _fetch_by_id(team_id: str) -> TeamRef:
5861 """
5962 Get a single team by id.
6063 """
61- res = get_nexus_client ().get (f"/api/v5/user/ teams/{ team_id } " )
64+ res = get_nexus_client ().get (f"/api/teams/v1beta2 /{ team_id } " )
6265
6366 if res .status_code == 404 :
6467 raise qnx_exc .ZeroMatches
6568
6669 if res .status_code != 200 :
6770 raise qnx_exc .ResourceFetchFailed (message = res .text , status_code = res .status_code )
6871
69- team_dict = res .json ()
72+ team_dict = res .json ()[ "data" ]
7073
7174 return TeamRef (
7275 id = team_dict ["id" ],
73- name = team_dict ["team_name " ],
74- description = team_dict ["description" ],
76+ name = team_dict ["attributes" ][ "name " ],
77+ description = team_dict ["attributes" ][ " description" ],
7578 )
7679
7780
7881def create (name : str , description : str | None = None ) -> TeamRef :
7982 """Create a team in Nexus."""
8083
8184 resp = get_nexus_client ().post (
82- "api/v5/user/ teams/new " ,
85+ "/ api/teams/v1beta2 " ,
8386 json = {
84- "team_name" : name ,
85- "description" : description ,
87+ "data" : {
88+ "attributes" : {
89+ "name" : name ,
90+ "description" : description ,
91+ "display_name" : name ,
92+ },
93+ "relationships" : {},
94+ "type" : "team" ,
95+ },
8696 },
8797 )
8898
@@ -91,9 +101,9 @@ def create(name: str, description: str | None = None) -> TeamRef:
91101 message = resp .text , status_code = resp .status_code
92102 )
93103
94- team_dict = resp .json ()
104+ team_dict = resp .json ()[ "data" ]
95105 return TeamRef (
96106 id = team_dict ["id" ],
97- name = team_dict ["team_name " ],
98- description = team_dict ["description" ],
107+ name = team_dict ["attributes" ][ "name " ],
108+ description = team_dict ["attributes" ][ " description" ],
99109 )
0 commit comments