Merge "Rename session_client to make_rest_client"

This commit is contained in:
Jenkins 2016-06-01 14:48:20 +00:00 committed by Gerrit Code Review
commit afbb28817e
3 changed files with 26 additions and 20 deletions

View File

@ -392,6 +392,23 @@ for additional flexibility. If the helper function here does not meet your
needs, you should see the `from_config` method of
`openstack.connection.Connection <http://developer.openstack.org/sdks/python/openstacksdk/users/guides/connect_from_config.html>`_
Constructing REST API Clients
-----------------------------
What if you want to make direct REST calls via a Session interface? You're
in luck. The same interface for `make_sdk` is supported for
`make_rest_client` and will return you a keystoneauth Session object that is
mounted on the endpoint for the service you're looking for.
.. code-block:: python
import os_client_config
session = os_client_config.make_rest_client('compute', cloud='vexxhost')
response = session.get('/servers')
server_list = response.json()['servers']
Constructing Legacy Client objects
----------------------------------
@ -428,23 +445,6 @@ If you want to do the same thing but also support command line parsing.
If you want to get fancier than that in your python, then the rest of the
API is available to you. But often times, you just want to do the one thing.
Constructing Mounted Session Objects
------------------------------------
What if you want to make direct REST calls via a Session interface? You're
in luck. The same interface for `make_client` is supported for `session_client`
and will return you a keystoneauth Session object that is mounted on the
endpoint for the service you're looking for.
.. code-block:: python
import os_client_config
session = os_client_config.session_client('compute', cloud='vexxhost')
response = session.get('/servers')
server_list = response.json()['servers']
Source
------

View File

@ -34,7 +34,7 @@ def get_config(service_key=None, options=None, **kwargs):
return config.get_one_cloud(options=parsed_options, **kwargs)
def session_client(service_key, options=None, **kwargs):
def make_rest_client(service_key, options=None, **kwargs):
"""Simple wrapper function. It has almost no features.
This will get you a raw requests Session Adapter that is mounted
@ -50,7 +50,9 @@ def session_client(service_key, options=None, **kwargs):
cloud = get_config(service_key=service_key, options=options, **kwargs)
return cloud.get_session_client(service_key)
# Backwards compat - simple_client was a terrible name
simple_client = session_client
simple_client = make_rest_client
# Backwards compat - session_client was a terrible name
session_client = make_rest_client
def make_client(service_key, constructor=None, options=None, **kwargs):
@ -73,7 +75,7 @@ def make_sdk(options=None, **kwargs):
"""Simple wrapper for getting an OpenStack SDK Connection.
For completeness, provide a mechanism that matches make_client and
session_client. The heavy lifting here is done in openstacksdk.
make_rest_client. The heavy lifting here is done in openstacksdk.
:rtype: :class:`~openstack.connection.Connection`
"""

View File

@ -0,0 +1,4 @@
---
deprecations:
- Renamed session_client to make_rest_client. session_client
will continue to be supported for backwards compatability.