summaryrefslogtreecommitdiff
path: root/saharaclient/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'saharaclient/client.py')
-rw-r--r--saharaclient/client.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/saharaclient/client.py b/saharaclient/client.py
index 80af29d..2af15ca 100644
--- a/saharaclient/client.py
+++ b/saharaclient/client.py
@@ -13,7 +13,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from savannaclient import client as savannaclient
+from saharaclient.openstack.common import importutils
-Client = savannaclient.Client
+class UnsupportedVersion(Exception):
+ """Indicates that the user is trying to use an unsupported
+ version of the API.
+ """
+ pass
+
+
+def get_client_class(version):
+ version_map = {
+ '1.0': 'saharaclient.api.client.Client',
+ '1.1': 'saharaclient.api.client.Client',
+ }
+ try:
+ client_path = version_map[str(version)]
+ except (KeyError, ValueError):
+ supported_versions = ''.join(version_map.keys())
+ msg = ("Invalid client version '%(version)s'; must be one of: "
+ "%(versions)s") % {'version': version,
+ 'versions': supported_versions}
+ raise UnsupportedVersion(msg)
+
+ return importutils.import_class(client_path)
+
+
+def Client(version, *args, **kwargs):
+ client_class = get_client_class(version)
+ return client_class(*args, **kwargs)