Skip to content

Commit 7391b63

Browse files
author
Clark Perkins
committed
Changed name back to stackdio, removed accepted_version things
1 parent 316d286 commit 7391b63

File tree

11 files changed

+32
-182
lines changed

11 files changed

+32
-182
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_python_version():
5353
# Call the setup method from setuptools that does all the heavy lifting
5454
# of packaging stackdio-client
5555
setup(
56-
name='stackdio-client',
56+
name='stackdio',
5757
version=__version__,
5858
url='http://stackd.io',
5959
author='Digital Reasoning Systems, Inc.',
@@ -67,7 +67,7 @@ def test_python_version():
6767
install_requires=requirements,
6868
dependency_links=[],
6969
classifiers=[
70-
'Development Status :: 3 - Alpha',
70+
'Development Status :: 4 - Beta',
7171
'Environment :: Web Environment',
7272
'Framework :: Django',
7373
'Intended Audience :: Developers',

stackdio/client/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import logging
2020

2121
from .http import use_admin_auth, endpoint
22-
from .exceptions import BlueprintException, StackException
22+
from .exceptions import BlueprintException, StackException, IncompatibleVersionException
2323

2424
from .blueprint import BlueprintMixin
2525
from .formula import FormulaMixin
@@ -57,6 +57,10 @@ def __init__(self, protocol="https", host="localhost", port=443,
5757

5858
_, self.version = _parse_version_string(self.get_version())
5959

60+
if self.version[0] != 0 or self.version[1] != 7:
61+
raise IncompatibleVersionException('Server version {0}.{1}.{2} not '
62+
'supported.'.format(**self.version))
63+
6064
@endpoint("")
6165
def get_root(self):
6266
"""Get the api root"""

stackdio/client/account.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
import json
1919

20-
from .exceptions import StackException
21-
from .http import HttpMixin, endpoint, use_admin_auth
22-
from .version import accepted_versions, deprecated
20+
from .http import HttpMixin, endpoint
2321

2422

2523
class AccountMixin(HttpMixin):
@@ -29,26 +27,11 @@ def list_providers(self):
2927
"""List all providers"""
3028
return self._get(endpoint, jsonify=True)['results']
3129

32-
@accepted_versions(">=0.6.1")
3330
@endpoint("cloud/providers/")
3431
def search_providers(self, provider_id):
3532
"""List all providers"""
3633
return self._get(endpoint, jsonify=True)['results']
3734

38-
@deprecated
39-
@accepted_versions("<0.7")
40-
@endpoint("cloud/providers/")
41-
def get_provider_id(self, type_name):
42-
"""Get the id for the provider specified by type_name"""
43-
44-
result = self._get(endpoint, jsonify=True)
45-
for provider in result['results']:
46-
if provider.get("type_name") == type_name:
47-
return provider.get("id")
48-
49-
raise StackException("Provider type %s not found" % type_name)
50-
51-
@use_admin_auth
5235
@endpoint("cloud/accounts/")
5336
def create_account(self, **kwargs):
5437
"""Create an account"""
@@ -81,7 +64,6 @@ def get_account(self, account_id, none_on_404=False):
8164
"""Return the account that matches the given id"""
8265
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
8366

84-
@accepted_versions(">=0.6.1")
8567
@endpoint("accounts/")
8668
def search_accounts(self, account_id):
8769
"""List all accounts"""
@@ -91,17 +73,3 @@ def search_accounts(self, account_id):
9173
def delete_account(self, account_id):
9274
"""List all accounts"""
9375
return self._delete(endpoint, jsonify=True)['results']
94-
95-
@deprecated
96-
@accepted_versions("<0.7")
97-
def get_account_id(self, slug, title=False):
98-
"""Get the id for a account that matches slug. If title is True will
99-
look at title instead."""
100-
101-
accounts = self.list_accounts()
102-
103-
for account in accounts:
104-
if account.get("slug" if not title else "title") == slug:
105-
return account.get("id")
106-
107-
raise StackException("Provider %s not found" % slug)

stackdio/client/blueprint.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
import json
1919

20-
from .exceptions import StackException
2120
from .http import HttpMixin, endpoint
22-
from .version import accepted_versions, deprecated
2321

2422

2523
class BlueprintMixin(HttpMixin):
@@ -76,15 +74,3 @@ def search_blueprints(self, **kwargs):
7674
@endpoint("blueprints/{blueprint_id}")
7775
def delete_blueprint(self, blueprint_id):
7876
return self._delete(endpoint, jsonify=True)
79-
80-
@deprecated
81-
@accepted_versions("<0.7")
82-
def get_blueprint_id(self, title):
83-
"""Get the id for a blueprint that matches title"""
84-
85-
blueprints = self.search_blueprints(title=title)
86-
87-
if not len(blueprints):
88-
raise StackException("Blueprint %s not found" % title)
89-
90-
return blueprints[0]['id']

stackdio/client/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18+
1819
class StackException(Exception):
1920
pass
2021

stackdio/client/formula.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import json
1919

20-
from .exceptions import StackException
2120
from .http import HttpMixin, endpoint
2221

2322

@@ -55,23 +54,3 @@ def delete_formula(self, formula_id):
5554
def update_formula(self, formula_id):
5655
"""Delete formula with matching id"""
5756
return self._post(endpoint, json.dumps({"action": "update"}), jsonify=True)
58-
59-
def get_formula_id(self, title):
60-
"""Find a stack id"""
61-
62-
formulas = self.list_formulas()
63-
for formula in formulas:
64-
if formula.get("title") == title:
65-
return formula.get("id")
66-
67-
raise StackException("Formula %s not found" % title)
68-
69-
def get_component_id(self, formula, component_title):
70-
"""Get the id for a component from formula_id that matches title"""
71-
72-
for component in formula.get("components"):
73-
if component.get("title") == component_title:
74-
return component.get("id")
75-
76-
raise StackException("Component %s not found for formula %s" %
77-
(component_title, formula.get("title")))

stackdio/client/http.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ def __init__(self, auth=None, verify=True):
122122
from requests.packages.urllib3 import disable_warnings
123123
disable_warnings()
124124

125-
126-
127125
def _request(self, verb, url, quiet=False,
128126
none_on_404=False, jsonify=False, raise_for_status=True,
129127
*args, **kwargs):

stackdio/client/image.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717

1818
import json
1919

20-
from .exceptions import StackException
21-
from .http import HttpMixin, endpoint, use_admin_auth
22-
from .version import accepted_versions, deprecated
20+
from .http import HttpMixin, endpoint
2321

2422

2523
class ImageMixin(HttpMixin):
2624

27-
@use_admin_auth
28-
@endpoint("image/")
25+
@endpoint("cloud/images/")
2926
def create_image(self, title, image_id, ssh_user, cloud_provider,
3027
default_instance_size=None):
3128
"""Create a image"""
@@ -38,41 +35,22 @@ def create_image(self, title, image_id, ssh_user, cloud_provider,
3835
}
3936
return self._post(endpoint, data=json.dumps(data), jsonify=True)
4037

41-
42-
@endpoint("images/")
38+
@endpoint("cloud/images/")
4339
def list_images(self):
4440
"""List all images"""
4541
return self._get(endpoint, jsonify=True)['results']
4642

47-
48-
@endpoint("images/{image_id}/")
43+
@endpoint("cloud/images/{image_id}/")
4944
def get_image(self, image_id, none_on_404=False):
5045
"""Return the image that matches the given id"""
5146
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
5247

53-
54-
@accepted_versions(">=0.6.1")
55-
@endpoint("images/")
48+
@endpoint("cloud/images/")
5649
def search_images(self, image_id):
5750
"""List all images"""
5851
return self._get(endpoint, jsonify=True)['results']
5952

60-
61-
@endpoint("images/{image_id}/")
53+
@endpoint("cloud/images/{image_id}/")
6254
def delete_image(self, image_id):
6355
"""Delete the image with the given id"""
6456
return self._delete(endpoint, jsonify=True)['results']
65-
66-
67-
@deprecated
68-
@accepted_versions("<0.7")
69-
def get_image_id(self, slug, title=False):
70-
"""Get the id for a image that matches slug. If title is True will look
71-
at title instead."""
72-
73-
images = self.list_images()
74-
for image in images:
75-
if image.get("slug" if not title else "title") == slug:
76-
return image.get("id")
77-
78-
raise StackException("Profile %s not found" % slug)

stackdio/client/region.py

Lines changed: 11 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -15,83 +15,30 @@
1515
# limitations under the License.
1616
#
1717

18-
from .exceptions import StackException
1918
from .http import HttpMixin, endpoint
20-
from .version import accepted_versions, deprecated
2119

2220

2321
class RegionMixin(HttpMixin):
24-
25-
26-
@accepted_versions(">=0.6.1")
27-
@endpoint("regions/")
28-
def list_regions(self):
22+
@endpoint("cloud/providers/{provider_name}/regions/")
23+
def list_regions(self, provider_name):
2924
return self._get(endpoint, jsonify=True)['results']
3025

31-
32-
@endpoint("regions/{region_id}")
33-
def get_region(self, region_id, none_on_404=False):
26+
@endpoint("cloud/providers/{provider_name}/regions/{region_id}")
27+
def get_region(self, provider_name, region_id, none_on_404=False):
3428
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
3529

36-
37-
@accepted_versions(">=0.6.1")
38-
@endpoint("regions/")
39-
def search_regions(self, **kwargs):
30+
@endpoint("cloud/providers/{provider_name}/regions/")
31+
def search_regions(self, provider_name, **kwargs):
4032
return self._get(endpoint, params=kwargs, jsonify=True)['results']
4133

42-
43-
@deprecated
44-
@accepted_versions(">=0.6", "<0.7")
45-
@endpoint("regions/")
46-
def get_region_id(self, title, type_name="ec2"):
47-
"""Get a zone id for title"""
48-
49-
provider_type = self.get_provider_type(type_name)
50-
params = {
51-
"title": title,
52-
"provider_type": provider_type["id"]
53-
}
54-
result = self._get(endpoint, params=params, jsonify=True)
55-
if len(result['results']) == 1:
56-
return result['results'][0]['id']
57-
58-
raise StackException("Zone %s not found for %s" % (title, type_name))
59-
60-
61-
@accepted_versions("!=0.6")
62-
@endpoint("zones/")
34+
@endpoint("cloud/providers/{provider_name}/zones/")
6335
def list_zones(self):
6436
return self._get(endpoint, jsonify=True)['results']
6537

66-
@endpoint("zones/{zone_id}")
67-
def get_zone(self, zone_id, none_on_404=False):
38+
@endpoint("cloud/providers/{provider_name}/zones/{zone_id}")
39+
def get_zone(self, provider_name, zone_id, none_on_404=False):
6840
return self._get(endpoint, jsonify=True, none_on_404=none_on_404)
6941

70-
@accepted_versions(">=0.6.1")
71-
@endpoint("zones/")
72-
def search_zones(self, **kwargs):
42+
@endpoint("cloud/providers/{provider_name}/zones/")
43+
def search_zones(self, provider_name, **kwargs):
7344
return self._get(endpoint, params=kwargs, jsonify=True)['results']
74-
75-
76-
@deprecated
77-
@accepted_versions("!=0.6", "<0.7")
78-
@endpoint("zones/")
79-
def get_zone_id(self, title, type_name="ec2"):
80-
"""Get a zone id for title"""
81-
82-
result = self._get(endpoint, jsonify=True)
83-
84-
type_id = self.get_provider_type_id(type_name)
85-
for zone in result['results']:
86-
if zone.get("title") == title:
87-
if 'region' in zone:
88-
# For version 0.6.1
89-
region = self._get(zone['region'], jsonify=True)
90-
if region.get("provider_type") == type_id:
91-
return zone.get("id")
92-
elif 'provider_type' in zone:
93-
# For versions 0.5.*
94-
if zone['provider_type'] == type_id:
95-
return zone.get("id")
96-
97-
raise StackException("Zone %s not found for %s" % (title, type_name))

stackdio/client/settings.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
class SettingsMixin(HttpMixin):
2525

26-
@endpoint("settings/")
26+
@endpoint("user/")
2727
def set_public_key(self, public_key):
2828
"""Upload a public key for our user. public_key can be the actual key, a
2929
file handle, or a path to a key file"""
@@ -35,6 +35,8 @@ def set_public_key(self, public_key):
3535
public_key = open(public_key, "r").read()
3636

3737
data = {
38-
"public_key": public_key
38+
"settings": {
39+
"public_key": public_key,
40+
}
3941
}
40-
return self._put(endpoint, data=json.dumps(data), jsonify=True)
42+
return self._patch(endpoint, data=json.dumps(data), jsonify=True)

0 commit comments

Comments
 (0)