Merge "Fix H404/405 violations in client.py,base.py,api_version.py"
This commit is contained in:
commit
f02ca48a4e
@ -40,13 +40,22 @@ _type_error_msg = _("'%(other)s' should be an instance of '%(cls)s'")
|
||||
|
||||
|
||||
class APIVersion(object):
|
||||
"""This class represents an API Version with convenience
|
||||
methods for manipulation and comparison of version
|
||||
numbers that we need to do to implement microversions.
|
||||
"""This class represents an API Version Request.
|
||||
|
||||
This class provides convenience methods for manipulation
|
||||
and comparison of version numbers that we need to do to
|
||||
implement microversions.
|
||||
"""
|
||||
|
||||
def __init__(self, version_str=None):
|
||||
"""Create an API version object."""
|
||||
"""Create an API version object.
|
||||
|
||||
:param version_string: String representation of APIVersionRequest.
|
||||
Correct format is 'X.Y', where 'X' and 'Y'
|
||||
are int values. None value should be used
|
||||
to create Null APIVersionRequest, which is
|
||||
equal to 0.0
|
||||
"""
|
||||
self.ver_major = 0
|
||||
self.ver_minor = 0
|
||||
|
||||
@ -120,7 +129,9 @@ class APIVersion(object):
|
||||
return self > other or self == other
|
||||
|
||||
def matches(self, min_version, max_version):
|
||||
"""Returns whether the version object represents a version
|
||||
"""Matches the version object.
|
||||
|
||||
Returns whether the version object represents a version
|
||||
greater than or equal to the minimum version and less than
|
||||
or equal to the maximum version.
|
||||
|
||||
@ -145,7 +156,9 @@ class APIVersion(object):
|
||||
return min_version <= self <= max_version
|
||||
|
||||
def get_string(self):
|
||||
"""Converts object to string representation which if used to create
|
||||
"""Version string representation.
|
||||
|
||||
Converts object to string representation which if used to create
|
||||
an APIVersion object results in the same version.
|
||||
"""
|
||||
if self.is_null():
|
||||
@ -242,14 +255,15 @@ def _get_server_version_range(client):
|
||||
|
||||
|
||||
def discover_version(client, requested_version):
|
||||
"""Checks ``requested_version`` and returns the most recent version
|
||||
"""Discover most recent version supported by API and client.
|
||||
|
||||
Checks ``requested_version`` and returns the most recent version
|
||||
supported by both the API and the client.
|
||||
|
||||
:param client: client object
|
||||
:param requested_version: requested version represented by APIVersion obj
|
||||
:returns: APIVersion
|
||||
"""
|
||||
|
||||
server_start_version, server_end_version = _get_server_version_range(
|
||||
client)
|
||||
|
||||
|
@ -36,7 +36,8 @@ Resource = base.Resource
|
||||
|
||||
|
||||
def getid(obj):
|
||||
"""
|
||||
"""Get object's ID or object.
|
||||
|
||||
Abstracts the common pattern of allowing both an object or an object's ID
|
||||
as a parameter when dealing with relationships.
|
||||
"""
|
||||
@ -47,7 +48,8 @@ def getid(obj):
|
||||
|
||||
|
||||
class Manager(base.HookableMixin):
|
||||
"""
|
||||
"""Manager for API service.
|
||||
|
||||
Managers interact with a particular type of API (servers, flavors, images,
|
||||
etc.) and provide CRUD operations for them.
|
||||
"""
|
||||
@ -102,7 +104,8 @@ class Manager(base.HookableMixin):
|
||||
|
||||
@contextlib.contextmanager
|
||||
def completion_cache(self, cache_type, obj_class, mode):
|
||||
"""
|
||||
"""The completion cache for bash autocompletion.
|
||||
|
||||
The completion cache store items that can be used for bash
|
||||
autocompletion, like UUIDs or human-friendly IDs.
|
||||
|
||||
@ -192,18 +195,14 @@ class Manager(base.HookableMixin):
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class ManagerWithFind(Manager):
|
||||
"""
|
||||
Like a `Manager`, but with additional `find()`/`findall()` methods.
|
||||
"""
|
||||
"""Like a `Manager`, but with additional `find()`/`findall()` methods."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def list(self):
|
||||
pass
|
||||
|
||||
def find(self, **kwargs):
|
||||
"""
|
||||
Find a single item with attributes matching ``**kwargs``.
|
||||
"""
|
||||
"""Find a single item with attributes matching ``**kwargs``."""
|
||||
matches = self.findall(**kwargs)
|
||||
num_matches = len(matches)
|
||||
if num_matches == 0:
|
||||
@ -215,9 +214,7 @@ class ManagerWithFind(Manager):
|
||||
return matches[0]
|
||||
|
||||
def findall(self, **kwargs):
|
||||
"""
|
||||
Find all items with attributes matching ``**kwargs``.
|
||||
"""
|
||||
"""Find all items with attributes matching ``**kwargs``."""
|
||||
found = []
|
||||
searches = kwargs.items()
|
||||
|
||||
|
@ -60,9 +60,7 @@ class _ClientConnectionPool(object):
|
||||
self._adapters = {}
|
||||
|
||||
def get(self, url):
|
||||
"""
|
||||
Store and reuse HTTP adapters per Service URL.
|
||||
"""
|
||||
"""Store and reuse HTTP adapters per Service URL."""
|
||||
if url not in self._adapters:
|
||||
self._adapters[url] = session.TCPKeepAliveAdapter()
|
||||
|
||||
@ -103,9 +101,10 @@ class SessionClient(adapter.LegacyJsonAdapter):
|
||||
|
||||
|
||||
def _original_only(f):
|
||||
"""Indicates and enforces that this function can only be used if we are
|
||||
using the original HTTPClient object.
|
||||
"""Decorator to indicate and enforce original HTTPClient object.
|
||||
|
||||
Indicates and enforces that this function can only be used if we are
|
||||
using the original HTTPClient object.
|
||||
We use this to specify that if you use the newer Session HTTP client then
|
||||
you are aware that the way you use your client has been updated and certain
|
||||
functions are no longer allowed to be used.
|
||||
@ -471,7 +470,9 @@ class HTTPClient(object):
|
||||
return self.services_url[service_type]
|
||||
|
||||
def _extract_service_catalog(self, url, resp, body, extract_token=True):
|
||||
"""See what the auth service told us and process the response.
|
||||
"""Extract service catalog from input resource body.
|
||||
|
||||
See what the auth service told us and process the response.
|
||||
We may get redirected to another site, fail or actually get
|
||||
back a service catalog with a token and our endpoints.
|
||||
"""
|
||||
@ -505,7 +506,9 @@ class HTTPClient(object):
|
||||
raise exceptions.from_response(resp, body, url)
|
||||
|
||||
def _fetch_endpoints_from_auth(self, url):
|
||||
"""We have a token, but don't know the final endpoint for
|
||||
"""Fetch endpoint using token.
|
||||
|
||||
We have a token, but don't know the final endpoint for
|
||||
the region. We have to go back to the auth service and
|
||||
ask again. This request requires an admin-level token
|
||||
to work. The proxy token supplied could be from a low-level enduser.
|
||||
|
Loading…
x
Reference in New Issue
Block a user