OpenStack Identity (Keystone) Client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

__init__.py 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Copyright 2012 OpenStack Foundation
  2. # All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. """The python bindings for the OpenStack Identity (Keystone) project.
  16. A Client object will allow you to communicate with the Identity server. The
  17. recommended way to get a Client object is to use
  18. :py:func:`keystoneclient.client.Client()`. :py:func:`~.Client()` uses version
  19. discovery to create a V3 or V2 client depending on what versions the Identity
  20. server supports and what version is requested.
  21. Identity V2 and V3 clients can also be created directly. See
  22. :py:class:`keystoneclient.v3.client.Client` for the V3 client and
  23. :py:class:`keystoneclient.v2_0.client.Client` for the V2 client.
  24. """
  25. import importlib
  26. import sys
  27. import pbr.version
  28. __version__ = pbr.version.VersionInfo('python-keystoneclient').version_string()
  29. __all__ = (
  30. # Modules
  31. 'generic',
  32. 'v2_0',
  33. 'v3',
  34. # Packages
  35. 'access',
  36. 'client',
  37. 'exceptions',
  38. 'httpclient',
  39. 'service_catalog',
  40. )
  41. class _LazyImporter(object):
  42. def __init__(self, module):
  43. self._module = module
  44. def __getattr__(self, name):
  45. # NB: this is only called until the import has been done.
  46. # These submodules are part of the API without explicit importing, but
  47. # expensive to load, so we load them on-demand rather than up-front.
  48. lazy_submodules = [
  49. 'access',
  50. 'client',
  51. 'exceptions',
  52. 'generic',
  53. 'httpclient',
  54. 'service_catalog',
  55. 'v2_0',
  56. 'v3',
  57. ]
  58. if name in lazy_submodules:
  59. return importlib.import_module('keystoneclient.%s' % name)
  60. # Return module attributes like __all__ etc.
  61. return getattr(self._module, name)
  62. sys.modules[__name__] = _LazyImporter(sys.modules[__name__])