Skip to content

Commit 54f09bc

Browse files
committed
Add teams endpoints
1 parent acf78de commit 54f09bc

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

gremlinapi/teams.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import logging
2+
import json
3+
4+
from gremlinapi.cli import register_cli_action
5+
from gremlinapi.exceptions import (
6+
GremlinParameterError,
7+
ProxyError,
8+
ClientError,
9+
HTTPTimeout,
10+
HTTPError
11+
)
12+
13+
from typing import Union, Type
14+
15+
from gremlinapi.gremlinapi import GremlinAPI
16+
from gremlinapi.http_clients import (
17+
get_gremlin_httpclient,
18+
GremlinAPIHttpClient
19+
)
20+
21+
log = logging.getLogger("GremlinAPI.client")
22+
23+
class GremlinAPITeam(GremlinAPI):
24+
25+
@classmethod
26+
def get_teams(
27+
cls,
28+
https_client: Type[GremlinAPIHttpClient] = get_gremlin_httpclient(),
29+
) -> dict:
30+
"""
31+
Get all teams
32+
"""
33+
method = 'GET'
34+
endpoint = '/teams'
35+
payload = cls._payload(**{"headers": https_client.header()})
36+
(resp,body) = https_client.api_call(method, endpoint, **payload)
37+
return body
38+
39+
@classmethod
40+
def delete_team(
41+
cls,
42+
https_client: Type[GremlinAPIHttpClient] = get_gremlin_httpclient(),
43+
**kwargs: dict,
44+
) -> dict:
45+
"""
46+
Delete a team
47+
"""
48+
method = 'DELETE'
49+
team_id = cls._error_if_not_param("team_id", **kwargs)
50+
endpoint = f'/teams/{team_id}'
51+
payload = cls._payload(**{"headers": https_client.header()})
52+
(resp,body) = https_client.api_call(method, endpoint, **payload)
53+
return body
54+
55+
@classmethod
56+
def update_team(
57+
cls,
58+
https_client: Type[GremlinAPIHttpClient] = get_gremlin_httpclient(),
59+
**kwargs: dict,
60+
) -> dict:
61+
"""
62+
Update a team
63+
"""
64+
method = 'PATCH'
65+
team_id = cls._error_if_not_param("team_id", **kwargs)
66+
endpoint = f'/teams/{team_id}'
67+
data = kwargs
68+
data.pop('team_id')
69+
payload = cls._payload(**{"headers": https_client.header(),"data": json.dumps(data)})
70+
(resp,body) = https_client.api_call(method, endpoint, **payload)
71+
return body
72+
73+
@classmethod
74+
def get_config_yaml(
75+
cls,
76+
https_client: Type[GremlinAPIHttpClient] = get_gremlin_httpclient(),
77+
**kwargs: dict,
78+
) -> dict:
79+
"""
80+
Get the config.yaml for a team
81+
"""
82+
method = 'GET'
83+
endpoint = cls._required_team_endpoint("/teams/client/install", **kwargs)
84+
payload = cls._payload(**{"headers": https_client.header()})
85+
(resp,body) = https_client.api_call(method, endpoint, **payload)
86+
return body
87+
88+
@classmethod
89+
def get_team(
90+
cls,
91+
https_client: Type[GremlinAPIHttpClient] = get_gremlin_httpclient(),
92+
**kwargs: dict,
93+
) -> dict:
94+
"""
95+
Get a team
96+
"""
97+
method = 'GET'
98+
team_id = cls._error_if_not_param("team_id", **kwargs)
99+
endpoint = f'/teams/{team_id}'
100+
payload = cls._payload(**{"headers": https_client.header()})
101+
(resp,body) = https_client.api_call(method, endpoint, **payload)
102+
return body
103+
104+
@classmethod
105+
def get_kubectl_install_manifest(
106+
cls,
107+
https_client: Type[GremlinAPIHttpClient] = get_gremlin_httpclient(),
108+
**kwargs: dict,
109+
) -> dict:
110+
"""
111+
Get the kubectl install manifest for a team
112+
"""
113+
method = 'GET'
114+
endpoint = cls._required_team_endpoint("/teams/kubernetes/install", **kwargs)
115+
payload = cls._payload(**{"headers": https_client.header()})
116+
(resp,body) = https_client.api_call(method, endpoint, **payload)
117+
return body

0 commit comments

Comments
 (0)