From 6a834063a25852f7f6cd45d6f7331aa0f77ff4c5 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 1 Jun 2016 10:28:51 +0300 Subject: 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 --- README.rst | 34 +++++++++++----------- os_client_config/__init__.py | 8 +++-- .../notes/make-rest-client-dd3d365632a26fa0.yaml | 4 +++ 3 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 releasenotes/notes/make-rest-client-dd3d365632a26fa0.yaml diff --git a/README.rst b/README.rst index 223fcfa..99ed287 100644 --- a/README.rst +++ b/README.rst @@ -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 `_ +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 ------ diff --git a/os_client_config/__init__.py b/os_client_config/__init__.py index c88ccb2..6142853 100644 --- a/os_client_config/__init__.py +++ b/os_client_config/__init__.py @@ -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` """ diff --git a/releasenotes/notes/make-rest-client-dd3d365632a26fa0.yaml b/releasenotes/notes/make-rest-client-dd3d365632a26fa0.yaml new file mode 100644 index 0000000..8e34e51 --- /dev/null +++ b/releasenotes/notes/make-rest-client-dd3d365632a26fa0.yaml @@ -0,0 +1,4 @@ +--- +deprecations: + - Renamed session_client to make_rest_client. session_client + will continue to be supported for backwards compatability. -- cgit v1.2.1