Remove kwargs from adapter.get_endpoint_data

get_endpoint_data on an adapater is intended to return the endpoint_data
for the endpoint the adapter is mounted to, so passing in additional
kwargs doesn't make any sense. What's more, the interaction between the
existing values and the passed in values is hard to reason about.

Update the docs on using get_endpoint_data to highlight this.

Change-Id: I851c615407bc3e22af4350a4facf8488fa9c7945
This commit is contained in:
Monty Taylor 2017-07-11 18:10:31 -05:00
parent 98b7292aad
commit de41fec992
2 changed files with 23 additions and 17 deletions

View File

@ -334,21 +334,26 @@ Endpoint Metadata
Both :class:`keystoneauth1.adapter.Adapter` and
:class:`keystoneauth1.session.Session` have a method for getting metadata about
the endpoint found for a given service: ``get_endpoint_data``. It takes the
same arguments as the `Adapter` constructor and `endpoint_filter`, and returns
a :class:`keystoneauth1.discovery.EndpointData` object. This object can be used
to determine which major `api_version` was found, or which `interface` in case
of ranges, lists of input values or ``latest`` version. It can also be used to
determine the `min_microversion` and `max_microversion` supported by the API.
If an API does not support microversions, the values will be ``None``.
the endpoint found for a given service: ``get_endpoint_data``.
Note that endpoint filter-related arguments can be omitted from calls to
``Adapter.get_endpoint_data``, in which case they are gleaned from those set
on the Adapter when it was initialized.
On the :class:`keystoneauth1.session.Session` it takes the same arguments as
`endpoint_filter`.
On the :class:`keystoneauth1.adapter.Adapter` it does not take arguments, as
it returns the information for the Endpoint the Adapter is mounted on.
``get_endpoint_data`` returns an :class:`keystoneauth1.discovery.EndpointData`
object. This object can be used to find information about the Endpoint,
including which major `api_version` was found, or which `interface` in case
of ranges, lists of input values or ``latest`` version.
It can also be used to determine the `min_microversion` and `max_microversion`
supported by the API. If an API does not support microversions, the values for
both will be ``None``.
``get_endpoint_data`` makes use of the same cache as the rest of the discovery
process, so calling it should incur no undue expense. It will make at least one
version discovery call so that it can fetch microversion metadata. If the user
knows a service does not support microversions and is merely curious as to
which major version was discovered, `discover_versions` can be set to `False`
to prevent fetching microversion metadata.
process, so calling it should incur no undue expense. By default it will make
at least one version discovery call so that it can fetch microversion metadata.
If the user knows a service does not support microversions and is merely
curious as to which major version was discovered, `discover_versions` can be
set to `False` to prevent fetching microversion metadata.

View File

@ -216,8 +216,8 @@ class Adapter(object):
self._set_endpoint_filter_kwargs(kwargs)
return self.session.get_endpoint(auth or self.auth, **kwargs)
def get_endpoint_data(self, auth=None, **kwargs):
"""Get the endpoint data as provided by the auth plugin.
def get_endpoint_data(self, auth=None):
"""Get the endpoint data for this Adapter's endpoint.
:param auth: The auth plugin to use for token. Overrides the plugin on
the session. (optional)
@ -230,6 +230,7 @@ class Adapter(object):
:returns: Endpoint data if available or None.
:rtype: keystoneauth1.discover.EndpointData
"""
kwargs = {}
self._set_endpoint_filter_kwargs(kwargs)
if self.endpoint_override:
kwargs['endpoint_override'] = self.endpoint_override