-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrs.py
More file actions
29 lines (24 loc) · 910 Bytes
/
rs.py
File metadata and controls
29 lines (24 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from scheduler.exceptions import KubeHTTPException
from scheduler.resources import Resource
class ReplicaSet(Resource):
api_prefix = 'apis'
api_version = 'apps/v1'
short_name = 'rs'
def get(self, namespace, name=None, **kwargs):
"""
Fetch a single ReplicaSet or a list
"""
url = '/namespaces/{}/replicasets'
args = [namespace]
if name is not None:
args.append(name)
url += '/{}'
message = 'get ReplicaSet "{}" in Namespace "{}"'
else:
message = 'get ReplicaSets in Namespace "{}"'
url = self.api(url, *args)
response = self.http_get(url, params=self.query_params(**kwargs))
if self.unhealthy(response.status_code):
args.reverse() # error msg is in reverse order
raise KubeHTTPException(response, message, *args)
return response