Skip to content

Commit 93ac02a

Browse files
authored
add get_all_resources api (#5)
1 parent 6b561ac commit 93ac02a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="staroid", # Replace with your own username
8-
version="0.0.4",
8+
version="0.0.5",
99
license='MIT',
1010
author="Staroid",
1111
author_email="support@staroid.com",

staroid/namespace.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,20 @@ def shell_stop(self, instance_name):
203203
else:
204204
logging.error("Can not stop shell {}", r.status_code)
205205
return None
206+
207+
def get_all_resources(self, instance_name):
208+
ns = self.get(instance_name)
209+
if ns == None:
210+
return None
211+
212+
r = self.__staroid._api_get(
213+
"namespace/{}".format(
214+
ns.namespace()
215+
)
216+
)
217+
if r.status_code == 200:
218+
js = json.loads(r.text)
219+
return js
220+
else:
221+
logging.error("Can not get namespace resources {}", r.status_code)
222+
return None

tests/test_namespace.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def test_crud_namespace(self):
3434
# start shell
3535
ns_api.shell_start("instance1")
3636

37+
resources = ns_api.get_all_resources("instance1")
38+
self.assertTrue(len(resources["services"]) > 0)
39+
3740
# stop shell
3841
ns_api.shell_stop("instance1")
3942

0 commit comments

Comments
 (0)