Skip to content

Commit fd4fb39

Browse files
author
Clark Perkins
committed
Added a couple of methods for the CLI
1 parent c6314a0 commit fd4fb39

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ docs/_build/
5252

5353
# PyBuilder
5454
target/
55+
56+
# PyCharm
57+
.idea/

stackdio/client/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ def __init__(self,
3333
self.auth = auth
3434
self.auth_admin = auth_admin
3535

36+
@endpoint("")
37+
def get_root(self):
38+
"""Get the api root"""
39+
return self._get(endpoint, jsonify=True)
40+
3641

3742
@use_admin_auth
3843
@endpoint("providers/")
@@ -135,6 +140,14 @@ def create_blueprint(self, blueprint, provider="ec2"):
135140
return self._post(endpoint, data=json.dumps(blueprint), jsonify=True)
136141

137142

143+
@endpoint("blueprints/{blueprint_id}/")
144+
def delete_blueprint(self, blueprint_id):
145+
result = self._delete(endpoint, jsonify=True)
146+
if result is None:
147+
raise BlueprintException("Blueprint %s not found" % blueprint_id)
148+
else:
149+
return result
150+
138151
@use_admin_auth
139152
@endpoint("security_groups/")
140153
def create_security_group(self, name, description, cloud_provider, is_default=True):
@@ -149,6 +162,11 @@ def create_security_group(self, name, description, cloud_provider, is_default=Tr
149162
return self._post(endpoint, data=json.dumps(data), jsonify=True)
150163

151164

165+
@endpoint("settings/")
166+
def get_public_key(self):
167+
"""Get the public key for the logged in uesr"""
168+
return self._get(endpoint, jsonify=True)['public_key']
169+
152170
@endpoint("settings/")
153171
def set_public_key(self, public_key):
154172
"""Upload a public key for our user. public_key can be the actual key, a
@@ -275,6 +293,12 @@ def get_stack_hosts(self, stack_id):
275293
return self._get(endpoint, jsonify=True)['results']
276294

277295

296+
@endpoint("blueprints/")
297+
def get_blueprints(self):
298+
"""Returns all the blueprints"""
299+
return self._get(endpoint, jsonify=True)['results']
300+
301+
278302
@endpoint("blueprints/{blueprint_id}/")
279303
def get_blueprint(self, blueprint_id):
280304
"""Return info for a specific blueprint_id"""

stackdio/client/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ class StackException(Exception):
44

55
class NoAdminException(Exception):
66
pass
7+
8+
9+
class BlueprintException(Exception):
10+
pass

0 commit comments

Comments
 (0)