keystoneauth1.adapter module

class keystoneauth1.adapter.Adapter(session: Session, service_type: str | None = None, service_name: str | None = None, interface: str | list[str] | None = None, region_name: str | None = None, endpoint_override: str | None = None, version: str | None = None, auth: BaseAuthPlugin | None = None, user_agent: str | None = None, connect_retries: int | None = None, logger: Logger | None = None, allow: dict[str, Any] | None = None, additional_headers: MutableMapping[str, str] | None = None, client_name: str | None = None, client_version: str | None = None, allow_version_hack: bool | None = None, global_request_id: str | None = None, min_version: str | None = None, max_version: str | None = None, default_microversion: str | None = None, status_code_retries: int | None = None, retriable_status_codes: list[int] | None = None, raise_exc: bool | None = None, rate_limit: float | None = None, concurrency: int | None = None, connect_retry_delay: float | None = None, status_code_retry_delay: float | None = None)

Bases: _BaseAdapter

__annotations__ = {}
__doc__ = None
__module__ = 'keystoneauth1.adapter'
delete(url: str, **kwargs: Any) Response

Perform a DELETE request.

This calls request() with method set to DELETE.

get(url: str, **kwargs: Any) Response

Perform a GET request.

This calls request() with method set to GET.

head(url: str, **kwargs: Any) Response

Perform a HEAD request.

This calls request() with method set to HEAD.

patch(url: str, **kwargs: Any) Response

Perform a PATCH request.

This calls request() with method set to PATCH.

post(url: str, **kwargs: Any) Response

Perform a POST request.

This calls request() with method set to POST.

put(url: str, **kwargs: Any) Response

Perform a PUT request.

This calls request() with method set to PUT.

request(url: str, method: str, **kwargs: Any) Response
class keystoneauth1.adapter.LegacyJsonAdapter(session: Session, service_type: str | None = None, service_name: str | None = None, interface: str | list[str] | None = None, region_name: str | None = None, endpoint_override: str | None = None, version: str | None = None, auth: BaseAuthPlugin | None = None, user_agent: str | None = None, connect_retries: int | None = None, logger: Logger | None = None, allow: dict[str, Any] | None = None, additional_headers: MutableMapping[str, str] | None = None, client_name: str | None = None, client_version: str | None = None, allow_version_hack: bool | None = None, global_request_id: str | None = None, min_version: str | None = None, max_version: str | None = None, default_microversion: str | None = None, status_code_retries: int | None = None, retriable_status_codes: list[int] | None = None, raise_exc: bool | None = None, rate_limit: float | None = None, concurrency: int | None = None, connect_retry_delay: float | None = None, status_code_retry_delay: float | None = None)

Bases: _BaseAdapter

Make something that looks like an old HTTPClient.

A common case when using an adapter is that we want an interface similar to the HTTPClients of old which returned the body as JSON as well.

You probably don’t want this if you are starting from scratch.

__annotations__ = {}
__doc__ = "Make something that looks like an old HTTPClient.\n\n    A common case when using an adapter is that we want an interface similar to\n    the HTTPClients of old which returned the body as JSON as well.\n\n    You probably don't want this if you are starting from scratch.\n    "
__module__ = 'keystoneauth1.adapter'
delete(url: str, **kwargs: Any) tuple[Response, object]

Perform a DELETE request.

This calls request() with method set to DELETE.

get(url: str, **kwargs: Any) tuple[Response, object]

Perform a GET request.

This calls request() with method set to GET.

head(url: str, **kwargs: Any) tuple[Response, object]

Perform a HEAD request.

This calls request() with method set to HEAD.

patch(url: str, **kwargs: Any) tuple[Response, object]

Perform a PATCH request.

This calls request() with method set to PATCH.

post(url: str, **kwargs: Any) tuple[Response, object]

Perform a POST request.

This calls request() with method set to POST.

put(url: str, **kwargs: Any) tuple[Response, object]

Perform a PUT request.

This calls request() with method set to PUT.

request(url: str, method: str, **kwargs: Any) tuple[Response, object]
class keystoneauth1.adapter._BaseAdapter(session: Session, service_type: str | None = None, service_name: str | None = None, interface: str | list[str] | None = None, region_name: str | None = None, endpoint_override: str | None = None, version: str | None = None, auth: BaseAuthPlugin | None = None, user_agent: str | None = None, connect_retries: int | None = None, logger: Logger | None = None, allow: dict[str, Any] | None = None, additional_headers: MutableMapping[str, str] | None = None, client_name: str | None = None, client_version: str | None = None, allow_version_hack: bool | None = None, global_request_id: str | None = None, min_version: str | None = None, max_version: str | None = None, default_microversion: str | None = None, status_code_retries: int | None = None, retriable_status_codes: list[int] | None = None, raise_exc: bool | None = None, rate_limit: float | None = None, concurrency: int | None = None, connect_retry_delay: float | None = None, status_code_retry_delay: float | None = None)

Bases: object

An instance of a session with local variables.

A session is a global object that is shared around amongst many clients. It therefore contains state that is relevant to everyone. There is a lot of state such as the service type and region_name that are only relevant to a particular client that is using the session. An adapter provides a wrapper of client local data around the global session object.

version, min_version, max_version and default_microversion can all be given either as a string or a tuple.

Parameters:
  • session – The session object to wrap.

  • service_type – The default service_type for URL discovery.

  • service_name – The default service_name for URL discovery.

  • interface – The default interface for URL discovery.

  • region_name – The default region_name for URL discovery.

  • endpoint_override – Always use this endpoint URL for requests for this client.

  • version – The minimum version restricted to a given Major API. Mutually exclusive with min_version and max_version. (optional)

  • auth – An auth plugin to use instead of the session one.

  • user_agent – The User-Agent string to set.

  • connect_retries – The maximum number of retries that should be attempted for connection errors. Default None - use session default which is don’t retry.

  • logger – A logging object to use for requests that pass through this adapter.

  • allow – Extra filters to pass when discovering API versions. (optional)

  • additional_headers – Additional headers that should be attached to every request passing through the adapter. Headers of the same name specified per request will take priority.

  • client_name – The name of the client that created the adapter. This will be used to create the user_agent.

  • client_version – The version of the client that created the adapter. This will be used to create the user_agent.

  • allow_version_hack – Allow keystoneauth to hack up catalog URLS to support older schemes. (optional, default True)

  • global_request_id – A global_request_id (in the form of req-$uuid) that will be passed on all requests. Enables cross project request id tracking.

  • min_version – The minimum major version of a given API, intended to be used as the lower bound of a range with max_version. Mutually exclusive with version. If min_version is given with no max_version it is as if max version is ‘latest’. (optional)

  • max_version – The maximum major version of a given API, intended to be used as the upper bound of a range with min_version. Mutually exclusive with version. (optional)

  • default_microversion – The default microversion value to send with API requests. While microversions are a per-request feature, a user may know they want to default to sending a specific value. (optional)

  • status_code_retries – The maximum number of retries that should be attempted for retriable HTTP status codes (optional, defaults to 0 - never retry).

  • retriable_status_codes – List of HTTP status codes that should be retried (optional, defaults to HTTP 503, has no effect when status_code_retries is 0).

  • raise_exc – If True, requests returning failing HTTP responses will raise an exception; if False, the response is returned. This can be overridden on a per-request basis via the kwarg of the same name.

  • rate_limit – A client-side rate limit to impose on requests made through this adapter in requests per second. For instance, a rate_limit of 2 means to allow no more than 2 requests per second, and a rate_limit of 0.5 means to allow no more than 1 request every two seconds. (optional, defaults to None, which means no rate limiting will be applied).

  • concurrency – How many simultaneous http requests this Adapter can be used for. (optional, defaults to None, which means no limit).

  • connect_retry_delay – Delay (in seconds) between two connect retries (if enabled). By default exponential retry starting with 0.5 seconds up to a maximum of 60 seconds is used.

  • status_code_retry_delay – Delay (in seconds) between two status code retries (if enabled). By default exponential retry starting with 0.5 seconds up to a maximum of 60 seconds is used.

__annotations__ = {'additional_headers': collections.abc.MutableMapping[str, str], 'allow': dict[str, typing.Any], 'allow_version_hack': bool | None, 'auth': keystoneauth1.plugin.BaseAuthPlugin | None, 'client_name': str | None, 'client_version': str | None, 'connect_retries': int | None, 'connect_retry_delay': float | None, 'default_microversion': str | None, 'endpoint_override': str | None, 'global_request_id': str | None, 'interface': str | list[str] | None, 'logger': logging.Logger | None, 'max_version': str | None, 'min_version': str | None, 'raise_exc': bool | None, 'region_name': str | None, 'retriable_status_codes': list[int] | None, 'service_name': str | None, 'service_type': str | None, 'session': <class 'keystoneauth1.session.Session'>, 'status_code_retries': int | None, 'status_code_retry_delay': float | None, 'user_agent': str | None, 'version': str | None}
__dict__ = mappingproxy({'__module__': 'keystoneauth1.adapter', '__annotations__': {'session': <class 'keystoneauth1.session.Session'>, 'service_type': str | None, 'service_name': str | None, 'interface': str | list[str] | None, 'region_name': str | None, 'endpoint_override': str | None, 'version': str | None, 'auth': keystoneauth1.plugin.BaseAuthPlugin | None, 'user_agent': str | None, 'connect_retries': int | None, 'logger': logging.Logger | None, 'allow': dict[str, typing.Any], 'additional_headers': collections.abc.MutableMapping[str, str], 'client_name': str | None, 'client_version': str | None, 'allow_version_hack': bool | None, 'global_request_id': str | None, 'min_version': str | None, 'max_version': str | None, 'default_microversion': str | None, 'status_code_retries': int | None, 'retriable_status_codes': list[int] | None, 'raise_exc': bool | None, 'connect_retry_delay': float | None, 'status_code_retry_delay': float | None}, '__doc__': "An instance of a session with local variables.\n\n    A session is a global object that is shared around amongst many clients. It\n    therefore contains state that is relevant to everyone. There is a lot of\n    state such as the service type and region_name that are only relevant to a\n    particular client that is using the session. An adapter provides a wrapper\n    of client local data around the global session object.\n\n    version, min_version, max_version and default_microversion can all be\n    given either as a string or a tuple.\n\n    :param session: The session object to wrap.\n    :param service_type: The default service_type for URL discovery.\n    :param service_name: The default service_name for URL discovery.\n    :param interface: The default interface for URL discovery.\n    :param region_name: The default region_name for URL discovery.\n    :param endpoint_override: Always use this endpoint URL for requests for\n        this client.\n    :param version: The minimum version restricted to a given Major API.\n        Mutually exclusive with min_version and max_version. (optional)\n    :param auth: An auth plugin to use instead of the session one.\n    :param user_agent: The User-Agent string to set.\n    :param connect_retries: The maximum number of retries that should be\n        attempted for connection errors. Default None - use session default\n        which is don't retry.\n    :param logger: A logging object to use for requests that pass through this\n        adapter.\n    :param allow: Extra filters to pass when discovering API versions.\n        (optional)\n    :param additional_headers: Additional headers that should be attached to\n        every request passing through the adapter. Headers of the same name\n        specified per request will take priority.\n    :param client_name: The name of the client that created the adapter. This\n        will be used to create the user_agent.\n    :param client_version: The version of the client that created the adapter.\n        This will be used to create the user_agent.\n    :param allow_version_hack: Allow keystoneauth to hack up catalog URLS to\n        support older schemes. (optional, default True)\n    :param global_request_id: A global_request_id (in the form of\n        ``req-$uuid``) that will be passed on all requests. Enables cross\n        project request id tracking.\n    :param min_version: The minimum major version of a given API, intended to\n        be used as the lower bound of a range with max_version. Mutually\n        exclusive with version. If min_version is given with no max_version it\n        is as if max version is 'latest'. (optional)\n    :param max_version: The maximum major version of a given API, intended to\n        be used as the upper bound of a range with min_version. Mutually\n        exclusive with version. (optional)\n    :param default_microversion: The default microversion value to send with\n        API requests. While microversions are a per-request feature, a user may\n        know they want to default to sending a specific value.  (optional)\n    :param status_code_retries: The maximum number of retries that should be\n        attempted for retriable HTTP status codes (optional, defaults to 0 -\n        never retry).\n    :param retriable_status_codes: List of HTTP status codes that should be\n        retried (optional, defaults to HTTP 503, has no effect when\n        status_code_retries is 0).\n    :param raise_exc: If True, requests returning failing HTTP responses will\n        raise an exception; if False, the response is returned. This can be\n        overridden on a per-request basis via the kwarg of the same name.\n    :param rate_limit: A client-side rate limit to impose on requests made\n        through this adapter in requests per second. For instance, a rate_limit\n        of 2 means to allow no more than 2 requests per second, and a\n        rate_limit of 0.5 means to allow no more than 1 request every two\n        seconds. (optional, defaults to None, which means no rate limiting will\n        be applied).\n    :param concurrency: How many simultaneous http requests this Adapter can be\n        used for. (optional, defaults to None, which means no limit).\n    :param connect_retry_delay: Delay (in seconds) between two connect retries\n        (if enabled). By default exponential retry starting with 0.5 seconds up\n        to a maximum of 60 seconds is used.\n    :param status_code_retry_delay: Delay (in seconds) between two status code\n        retries (if enabled). By default exponential retry starting with 0.5\n        seconds up to a maximum of 60 seconds is used.\n    ", 'client_name': None, 'client_version': None, '__init__': <function _BaseAdapter.__init__>, '_set_endpoint_filter_kwargs': <function _BaseAdapter._set_endpoint_filter_kwargs>, '_request': <function _BaseAdapter._request>, 'get_token': <function _BaseAdapter.get_token>, 'get_endpoint': <function _BaseAdapter.get_endpoint>, 'get_endpoint_data': <function _BaseAdapter.get_endpoint_data>, 'get_all_version_data': <function _BaseAdapter.get_all_version_data>, 'get_api_major_version': <function _BaseAdapter.get_api_major_version>, 'invalidate': <function _BaseAdapter.invalidate>, 'get_user_id': <function _BaseAdapter.get_user_id>, 'get_project_id': <function _BaseAdapter.get_project_id>, 'register_argparse_arguments': <classmethod(<function _BaseAdapter.register_argparse_arguments>)>, 'register_service_argparse_arguments': <classmethod(<function _BaseAdapter.register_service_argparse_arguments>)>, '__dict__': <attribute '__dict__' of '_BaseAdapter' objects>, '__weakref__': <attribute '__weakref__' of '_BaseAdapter' objects>})
__doc__ = "An instance of a session with local variables.\n\n    A session is a global object that is shared around amongst many clients. It\n    therefore contains state that is relevant to everyone. There is a lot of\n    state such as the service type and region_name that are only relevant to a\n    particular client that is using the session. An adapter provides a wrapper\n    of client local data around the global session object.\n\n    version, min_version, max_version and default_microversion can all be\n    given either as a string or a tuple.\n\n    :param session: The session object to wrap.\n    :param service_type: The default service_type for URL discovery.\n    :param service_name: The default service_name for URL discovery.\n    :param interface: The default interface for URL discovery.\n    :param region_name: The default region_name for URL discovery.\n    :param endpoint_override: Always use this endpoint URL for requests for\n        this client.\n    :param version: The minimum version restricted to a given Major API.\n        Mutually exclusive with min_version and max_version. (optional)\n    :param auth: An auth plugin to use instead of the session one.\n    :param user_agent: The User-Agent string to set.\n    :param connect_retries: The maximum number of retries that should be\n        attempted for connection errors. Default None - use session default\n        which is don't retry.\n    :param logger: A logging object to use for requests that pass through this\n        adapter.\n    :param allow: Extra filters to pass when discovering API versions.\n        (optional)\n    :param additional_headers: Additional headers that should be attached to\n        every request passing through the adapter. Headers of the same name\n        specified per request will take priority.\n    :param client_name: The name of the client that created the adapter. This\n        will be used to create the user_agent.\n    :param client_version: The version of the client that created the adapter.\n        This will be used to create the user_agent.\n    :param allow_version_hack: Allow keystoneauth to hack up catalog URLS to\n        support older schemes. (optional, default True)\n    :param global_request_id: A global_request_id (in the form of\n        ``req-$uuid``) that will be passed on all requests. Enables cross\n        project request id tracking.\n    :param min_version: The minimum major version of a given API, intended to\n        be used as the lower bound of a range with max_version. Mutually\n        exclusive with version. If min_version is given with no max_version it\n        is as if max version is 'latest'. (optional)\n    :param max_version: The maximum major version of a given API, intended to\n        be used as the upper bound of a range with min_version. Mutually\n        exclusive with version. (optional)\n    :param default_microversion: The default microversion value to send with\n        API requests. While microversions are a per-request feature, a user may\n        know they want to default to sending a specific value.  (optional)\n    :param status_code_retries: The maximum number of retries that should be\n        attempted for retriable HTTP status codes (optional, defaults to 0 -\n        never retry).\n    :param retriable_status_codes: List of HTTP status codes that should be\n        retried (optional, defaults to HTTP 503, has no effect when\n        status_code_retries is 0).\n    :param raise_exc: If True, requests returning failing HTTP responses will\n        raise an exception; if False, the response is returned. This can be\n        overridden on a per-request basis via the kwarg of the same name.\n    :param rate_limit: A client-side rate limit to impose on requests made\n        through this adapter in requests per second. For instance, a rate_limit\n        of 2 means to allow no more than 2 requests per second, and a\n        rate_limit of 0.5 means to allow no more than 1 request every two\n        seconds. (optional, defaults to None, which means no rate limiting will\n        be applied).\n    :param concurrency: How many simultaneous http requests this Adapter can be\n        used for. (optional, defaults to None, which means no limit).\n    :param connect_retry_delay: Delay (in seconds) between two connect retries\n        (if enabled). By default exponential retry starting with 0.5 seconds up\n        to a maximum of 60 seconds is used.\n    :param status_code_retry_delay: Delay (in seconds) between two status code\n        retries (if enabled). By default exponential retry starting with 0.5\n        seconds up to a maximum of 60 seconds is used.\n    "
__init__(session: Session, service_type: str | None = None, service_name: str | None = None, interface: str | list[str] | None = None, region_name: str | None = None, endpoint_override: str | None = None, version: str | None = None, auth: BaseAuthPlugin | None = None, user_agent: str | None = None, connect_retries: int | None = None, logger: Logger | None = None, allow: dict[str, Any] | None = None, additional_headers: MutableMapping[str, str] | None = None, client_name: str | None = None, client_version: str | None = None, allow_version_hack: bool | None = None, global_request_id: str | None = None, min_version: str | None = None, max_version: str | None = None, default_microversion: str | None = None, status_code_retries: int | None = None, retriable_status_codes: list[int] | None = None, raise_exc: bool | None = None, rate_limit: float | None = None, concurrency: int | None = None, connect_retry_delay: float | None = None, status_code_retry_delay: float | None = None)
__module__ = 'keystoneauth1.adapter'
__weakref__

list of weak references to the object

_request(url: str, method: str, **kwargs: Any) Response
_set_endpoint_filter_kwargs(kwargs: dict[str, object]) None
additional_headers: MutableMapping[str, str]
allow: dict[str, Any]
allow_version_hack: bool | None
auth: BaseAuthPlugin | None
client_name: str | None = None
client_version: str | None = None
connect_retries: int | None
connect_retry_delay: float | None
default_microversion: str | None
endpoint_override: str | None
get_all_version_data(interface: str | list[str] | None = 'public', region_name: str | None = None) dict[str, dict[str, dict[str, list[VersionData]]]]

Get data about all versions of a service.

Parameters:
  • interface – Type of endpoint to get version data for. Can be a single value or a list of values. A value of None indicates that all interfaces should be queried. (optional, defaults to public)

  • region_name – Region of endpoints to get version data for. A value of None indicates that all regions should be queried. (optional, defaults to None)

Returns:

A dictionary keyed by region_name with values containing dictionaries keyed by interface with values being a list of VersionData.

get_api_major_version(auth: BaseAuthPlugin | None = None, **kwargs: Any) tuple[int | float, ...] | None

Get the major API version as provided by the auth plugin.

Parameters:

auth – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises:

keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – if a plugin is not available.

Returns:

The major version of the API of the service discovered.

get_endpoint(auth: BaseAuthPlugin | None = None, **kwargs: Any) str | None

Get an endpoint as provided by the auth plugin.

Parameters:

auth – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises:

keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – if a plugin is not available.

Returns:

An endpoint if available or None.

get_endpoint_data(auth: BaseAuthPlugin | None = None) EndpointData | None

Get the endpoint data for this Adapter’s endpoint.

Parameters:

auth – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises:
Returns:

Endpoint data if available or None.

get_project_id(auth: BaseAuthPlugin | None = None) str | None

Return the authenticated project_id as provided by the auth plugin.

Parameters:

auth – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises:
Returns:

Current project_id or None if not supported by plugin.

get_token(auth: BaseAuthPlugin | None = None) str | None

Return a token as provided by the auth plugin.

Parameters:

auth – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises:

keystoneauth1.exceptions.auth.AuthorizationFailure – if a new token fetch fails.

Returns:

A valid token.

get_user_id(auth: BaseAuthPlugin | None = None) str | None

Return the authenticated user_id as provided by the auth plugin.

Parameters:

auth – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises:
Returns:

Current user_id or None if not supported by plugin.

global_request_id: str | None
interface: str | list[str] | None
invalidate(auth: BaseAuthPlugin | None = None) bool

Invalidate an authentication plugin.

Parameters:

auth – The auth plugin to invalidate. Overrides the plugin on the session. (optional)

logger: Logger | None
max_version: str | None
min_version: str | None
raise_exc: bool | None
region_name: str | None
classmethod register_argparse_arguments(parser: ArgumentParser, service_type: str | None = None) None

Attach arguments to a given argparse Parser for Adapters.

Parameters:
  • parser – The argparse parser to attach options to.

  • service_type – Default service_type value. (optional)

classmethod register_service_argparse_arguments(parser: ArgumentParser, service_type: str) None

Attach arguments to a given argparse Parser for Adapters.

Parameters:
  • parser – The argparse parser to attach options to.

  • service_type – Name of a service to generate additional arguments for.

retriable_status_codes: list[int] | None
service_name: str | None
service_type: str | None
session: Session
status_code_retries: int | None
status_code_retry_delay: float | None
user_agent: str | None
version: str | None
keystoneauth1.adapter.register_adapter_argparse_arguments(parser: ArgumentParser, service_type: str | None = None) None
keystoneauth1.adapter.register_service_adapter_argparse_arguments(parser: ArgumentParser, service_type: str) None