Rename session_client to make_rest_client

While writing some docs, it became clear that session_client was just a
horrible horrible name and that I'm a bad person. Rename it so that we
can make docs that make humans happy.

Also, move the REST client section of the README up a bit.

Change-Id: I1a27853e3031489da5916308a76f19bc72185d24
This commit is contained in:
Monty Taylor 2016-06-01 10:28:51 +03:00
parent 41ac1562b5
commit 6a834063a2
No known key found for this signature in database
GPG Key ID: 3390DB68041A12F0
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.