summaryrefslogtreecommitdiff
path: root/keystoneclient/client.py
diff options
context:
space:
mode:
authorJamie Lennox <jamielennox@redhat.com>2013-09-23 11:50:57 +1000
committerJamie Lennox <jamielennox@redhat.com>2013-12-03 12:00:03 +1000
commitfd0a176a49b5ead812567018a00fc3db4b7f531a (patch)
tree491f28c357caf9f9342adda6d5e30aeaf2274769 /keystoneclient/client.py
parent2477c334a25ae93638a63b889fc06a0b56a58641 (diff)
downloadpython-keystoneclient-fd0a176a49b5ead812567018a00fc3db4b7f531a.tar.gz
Discover supported APIs
Allow discovery of the API versions a server supports and create an appropriate client based on this. Implements: blueprint api-version-discovery Change-Id: I63e6759889066a784dc47e35152c82e1ead7951d
Diffstat (limited to 'keystoneclient/client.py')
-rw-r--r--keystoneclient/client.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/keystoneclient/client.py b/keystoneclient/client.py
index bfd69ab..72620eb 100644
--- a/keystoneclient/client.py
+++ b/keystoneclient/client.py
@@ -12,7 +12,30 @@
# License for the specific language governing permissions and limitations
# under the License.
+from keystoneclient import discover
from keystoneclient import httpclient
# Using client.HTTPClient is deprecated. Use httpclient.HTTPClient instead.
HTTPClient = httpclient.HTTPClient
+
+
+def Client(version=None, unstable=False, **kwargs):
+ """Factory function to create a new identity service client.
+
+ :param tuple version: The required version of the identity API. If
+ specified the client will be selected such that the
+ major version is equivalent and an endpoint provides
+ at least the specified minor version. For example to
+ specify the 3.1 API use (3, 1).
+ :param bool unstable: Accept endpoints not marked as 'stable'. (optional)
+ :param kwargs: Additional arguments are passed through to the client
+ that is being created.
+ :returns: New keystone client object
+ (keystoneclient.v2_0.Client or keystoneclient.v3.Client).
+
+ :raises: DiscoveryFailure if the server's response is invalid
+ :raises: VersionNotAvailable if a suitable client cannot be found.
+ """
+
+ return discover.Discover(**kwargs).create_client(version=version,
+ unstable=unstable)