Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.

Commit

Permalink
exclude az,nodetype,provider,region from namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tifayuki committed Jun 10, 2016
1 parent 8b79e77 commit ef94b85
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dockercloud/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, **kwargs):

class Restful(BasicObject):
_detail_uri = None
namespaced = True

def __init__(self, **kwargs):
"""Simply reflect all the values in kwargs"""
Expand Down Expand Up @@ -58,7 +59,7 @@ def _loaddict(self, dict):
assert subsystem, "Subsystem not specified for %s" % self.__class__.__name__
for k, v in list(dict.items()):
setattr(self, k, v)
if dockercloud.namespace:
if self.namespaced and dockercloud.namespace:
self._detail_uri = "/".join(["api", subsystem, self._api_version, dockercloud.namespace,
endpoint.strip("/"), self.pk])
else:
Expand Down Expand Up @@ -130,7 +131,7 @@ def fetch(cls, pk):
subsystem = getattr(cls, 'subsystem', None)
assert endpoint, "Endpoint not specified for %s" % cls.__name__
assert subsystem, "Subsystem not specified for %s" % cls.__name__
if dockercloud.namespace:
if cls.namespaced and dockercloud.namespace:
detail_uri = "/".join(["api", subsystem, cls._api_version, dockercloud.namespace, endpoint.strip("/"), pk])
else:
detail_uri = "/".join(["api", subsystem, cls._api_version, endpoint.strip("/"), pk])
Expand All @@ -148,7 +149,7 @@ def list(cls, limit=None, **kwargs):
assert endpoint, "Endpoint not specified for %s" % cls.__name__
assert subsystem, "Subsystem not specified for %s" % cls.__name__

if dockercloud.namespace:
if cls.namespaced and dockercloud.namespace:
detail_uri = "/".join(["api", subsystem, cls._api_version, dockercloud.namespace, endpoint.strip("/")])
else:
detail_uri = "/".join(["api", subsystem, cls._api_version, endpoint.strip("/")])
Expand Down Expand Up @@ -229,7 +230,7 @@ def save(self):
# Figure out whether we should do a create or update
if not self._detail_uri:
action = "POST"
if dockercloud.namespace:
if cls.namespaced and dockercloud.namespace:
path = "/".join(["api", subsystem, self._api_version, dockercloud.namespace, endpoint.lstrip("/")])
else:
path = "/".join(["api", subsystem, self._api_version, endpoint.lstrip("/")])
Expand Down
1 change: 1 addition & 0 deletions dockercloud/api/nodeaz.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class AZ(Immutable):
subsystem = "infra"
endpoint = "/az"
namespaced = False

@classmethod
def _pk_key(cls):
Expand Down
1 change: 1 addition & 0 deletions dockercloud/api/nodeprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class Provider(Immutable):
subsystem = "infra"
endpoint = "/provider"
namespaced = False

@classmethod
def _pk_key(cls):
Expand Down
1 change: 1 addition & 0 deletions dockercloud/api/noderegion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class Region(Immutable):
subsystem = "infra"
endpoint = "/region"
namespaced = False

@classmethod
def _pk_key(cls):
Expand Down
1 change: 1 addition & 0 deletions dockercloud/api/nodetype.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class NodeType(Immutable):
subsystem = "infra"
endpoint = "/nodetype"
namespaced = False

@classmethod
def _pk_key(cls):
Expand Down

0 comments on commit ef94b85

Please sign in to comment.