Build common REST client
A single REST client library will do the HTTP work for all supported services, whether core, plugin, or otherwise. No individual service client should be making HTTP requests to an API on its own.
Blueprint information
- Status:
- Complete
- Approver:
- Terry Howe
- Priority:
- Essential
- Drafter:
- Brian Curtin
- Direction:
- Approved
- Assignee:
- Terry Howe
- Definition:
- Approved
- Series goal:
- None
- Implementation:
- Implemented
- Milestone target:
- None
- Started by
- Terry Howe
- Completed by
- Terry Howe
Related branches
Related bugs
Sprints
Whiteboard
Dean's Transport class implements this.
This library should be implemented to support HTTPS from the beginning.
(dtroyer):
Some ideas on organizing the library stack were outlined in an Etherpad a while back., here is a cleaned up summary of the lower layers.
* A new Session class that subclasses requests.Session and adds some additional features useful for OpenStack clients:
* set session-wide defaults for user_agent and verify
* encode request body to JSON as requested
* populate headers as required: User-Agent, Forwarded, Content-Type
* change requests' redirect handling to be more appropriate for an API
* debug logging of request/response data
* populate the X-Auth-Token header from an auth object contained by the Session
* An ApiVersion class that handles the mechanics of API version discovery
* subclasses can add hacks for specific services (ie, Keystone's current 'values' struct that no other service has)
* A base Client class that contains the hooks for common operations:
* create a new Session instance if one is not supplied
* performs the API version discovery (see ApiVersion class below)
* contains a ServiceCatalog instance (applications requiring multiple identity contexts at a time should use multiple Client instances)
* define the cache interface for client-side caching of API data
* include wrappers for the REST methods: head(), get(), post(), put(), delete(), patch()
* A base AuthPlugin class:
* handles the specifics of authenticating a user and providing a token to Session when requested
* creates a ServiceCatalog from the token received from Identity
* A ServiceCatalog class similar to the existing one in keystoneclient (so far)