Skip to content

Commit c789163

Browse files
committed
Merge pull request #10 from WLPhoenix/master
Usability changes to get_{x} functions
2 parents 010cfa4 + 75c3827 commit c789163

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

stackdio/client/blueprint.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def create_blueprint(self, blueprint, provider="ec2"):
3737
host["zone"] = self.get_zone_id(host["zone"], provider)
3838

3939
if isinstance(host["cloud_profile"], basestring):
40-
host["cloud_profile"] = self.get_profile_id(host["cloud_profile"], title=True)
40+
host["cloud_profile"] = self.get_profile_id(host["cloud_profile"], title=True) # noqa
4141

4242
for component in host["formula_components"]:
4343
if isinstance(component["id"], (tuple, list)):
@@ -55,9 +55,9 @@ def list_blueprints(self):
5555
return self._get(endpoint, jsonify=True)['results']
5656

5757
@endpoint("blueprints/{blueprint_id}/")
58-
def get_blueprint(self, blueprint_id):
58+
def get_blueprint(self, blueprint_id, none_on_404=False):
5959
"""Return info for a specific blueprint_id"""
60-
return self._get(endpoint, jsonify=True)
60+
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
6161

6262
@endpoint("blueprints/")
6363
def search_blueprints(self, **kwargs):

stackdio/client/formula.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def list_formulas(self):
3737
return self._get(endpoint, jsonify=True)['results']
3838

3939
@endpoint("formulas/{formula_id}/")
40-
def get_formula(self, formula_id):
40+
def get_formula(self, formula_id, none_on_404=False):
4141
"""Get a formula with matching id"""
42-
return self._get(endpoint, jsonify=True)
42+
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
4343

4444
@endpoint("formulas/")
4545
def search_formulas(self, **kwargs):

stackdio/client/profile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def list_profiles(self):
4646

4747

4848
@endpoint("profiles/{profile_id}/")
49-
def get_profile(self, profile_id):
49+
def get_profile(self, profile_id, none_on_404=False):
5050
"""Return the profile that matches the given id"""
51-
return self._get(endpoint, jsonify=True)
51+
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
5252

5353

5454
@accepted_versions(">=0.6.1")

stackdio/client/provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def list_providers(self):
8282

8383

8484
@endpoint("providers/{provider_id}/")
85-
def get_provider(self, provider_id):
85+
def get_provider(self, provider_id, none_on_404=False):
8686
"""Return the provider that matches the given id"""
87-
return self._get(endpoint, jsonify=True)
87+
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
8888

8989

9090
@accepted_versions(">=0.6.1")

stackdio/client/region.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ def list_regions(self):
2929
return self._get(endpoint, jsonify=True)['results']
3030

3131

32+
@endpoint("regions/{region_id}")
33+
def get_region(self, region_id, none_on_404=False):
34+
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
35+
36+
3237
@accepted_versions(">=0.6.1")
3338
@endpoint("regions/")
3439
def search_regions(self, **kwargs):
@@ -58,6 +63,9 @@ def get_region_id(self, title, type_name="ec2"):
5863
def list_zones(self):
5964
return self._get(endpoint, jsonify=True)['results']
6065

66+
@endpoint("zones/{zone_id}")
67+
def get_zone(self, zone_id, none_on_404=False):
68+
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
6169

6270
@accepted_versions(">=0.6.1")
6371
@endpoint("zones/")

stackdio/client/stack.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def list_stacks(self):
4141
return self._get(endpoint, jsonify=True)['results']
4242

4343
@endpoint("stacks/{stack_id}/")
44-
def get_stack(self, stack_id):
44+
def get_stack(self, stack_id, none_on_404=False):
4545
"""Get stack info"""
46-
return self._get(endpoint, jsonify=True)
46+
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
4747

4848
@endpoint("stacks/")
4949
def search_stacks(self, **kwargs):
@@ -154,7 +154,7 @@ def get_access_rule_id(self, stack_id, title):
154154
for group in rules:
155155
if group.get("blueprint_host_definition").get("title") == title:
156156
return group.get("id")
157-
except TypeError, e:
157+
except TypeError:
158158
pass
159159

160160
raise StackException("Access Rule %s not found" % title)
@@ -168,4 +168,3 @@ def edit_access_rule(self, group_id, data=None):
168168
"""Add an access rule to a group"""
169169

170170
return self._put(endpoint, jsonify=True, data=json.dumps(data))
171-

0 commit comments

Comments
 (0)