keystoneauth1.adapter module

class keystoneauth1.adapter.Adapter(session: Session, service_type: str | None = None, service_name: str | None = None, interface: str | None = None, region_name: str | None = None, endpoint_override: str | None = None, version: str | None = None, auth: plugin.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 | None = None, region_name: str | None = None, endpoint_override: str | None = None, version: str | None = None, auth: plugin.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 | None = None, region_name: str | None = None, endpoint_override: str | None = None, version: str | None = None, auth: plugin.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 (keystoneauth1.session.Session) – The session object to wrap.

  • service_type (str) – The default service_type for URL discovery.

  • service_name (str) – The default service_name for URL discovery.

  • interface (str) – The default interface for URL discovery.

  • region_name (str) – The default region_name for URL discovery.

  • endpoint_override (str) – 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 (keystoneauth1.plugin.BaseAuthPlugin) – An auth plugin to use instead of the session one.

  • user_agent (str) – The User-Agent string to set.

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

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

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

  • additional_headers (dict) – 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 (str) – The name of the client that created the adapter. This will be used to create the user_agent.

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

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

  • global_request_id (str) – 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 (int) – The maximum number of retries that should be attempted for retriable HTTP status codes (optional, defaults to 0 - never retry).

  • retriable_status_codes (list) – 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 (bool) – 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 (float) – 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 (int) – How many simultaneous http requests this Adapter can be used for. (optional, defaults to None, which means no limit).

  • connect_retry_delay (float) – 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 (float) – 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__ = {'client_name': typing.Optional[str], 'client_version': typing.Optional[str]}
__dict__ = mappingproxy({'__module__': 'keystoneauth1.adapter', '__annotations__': {'client_name': typing.Optional[str], 'client_version': typing.Optional[str]}, '__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    :type session: keystoneauth1.session.Session\n    :param str service_type: The default service_type for URL discovery.\n    :param str service_name: The default service_name for URL discovery.\n    :param str interface: The default interface for URL discovery.\n    :param str region_name: The default region_name for URL discovery.\n    :param str endpoint_override:\n        Always use this endpoint URL for requests for this client.\n    :param version:\n        The minimum version restricted to a given Major API.\n        Mutually exclusive with min_version and max_version.\n        (optional)\n    :param auth: An auth plugin to use instead of the session one.\n    :type auth: keystoneauth1.plugin.BaseAuthPlugin\n    :param str user_agent: The User-Agent string to set.\n    :param int connect_retries:\n        The maximum number of retries that should be attempted for\n        connection errors. Default None - use session default which\n        is don't retry.\n    :param logger:\n        A logging object to use for requests that pass through this\n        adapter.\n    :type logger: logging.Logger\n    :param dict allow:\n        Extra filters to pass when discovering API versions.  (optional)\n    :param dict additional_headers:\n        Additional headers that should be attached to every request\n        passing through the adapter. Headers of the same name specified\n        per request will take priority.\n    :param str client_name:\n        The name of the client that created the adapter. This will be\n        used to create the user_agent.\n    :param str client_version:\n        The version of the client that created the adapter. This will\n        be used to create the user_agent.\n    :param bool allow_version_hack:\n        Allow keystoneauth to hack up catalog URLS to support older schemes.\n        (optional, default True)\n    :param str global_request_id:\n        A global_request_id (in the form of ``req-$uuid``) that will be\n        passed on all requests. Enables cross project request id tracking.\n    :param min_version:\n        The minimum major version of a given API, intended to be used as\n        the lower bound of a range with max_version. Mutually exclusive with\n        version. If min_version is given with no max_version it is as\n        if max version is 'latest'. (optional)\n    :param max_version:\n        The maximum major version of a given API, intended to be used as\n        the upper bound of a range with min_version. Mutually exclusive with\n        version. (optional)\n    :param default_microversion:\n        The default microversion value to send with API requests. While\n        microversions are a per-request feature, a user may know they\n        want to default to sending a specific value.  (optional)\n    :param int status_code_retries:\n        The maximum number of retries that should be attempted for retriable\n        HTTP status codes (optional, defaults to 0 - never retry).\n    :param list retriable_status_codes:\n        List of HTTP status codes that should be retried (optional,\n        defaults to HTTP 503, has no effect when status_code_retries is 0).\n    :param bool raise_exc:\n        If True, requests returning failing HTTP responses will raise an\n        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 float rate_limit:\n        A client-side rate limit to impose on requests made through this\n        adapter in requests per second. For instance, a rate_limit of 2\n        means to allow no more than 2 requests per second, and a rate_limit\n        of 0.5 means to allow no more than 1 request every two seconds.\n        (optional, defaults to None, which means no rate limiting will be\n        applied).\n    :param int concurrency:\n        How many simultaneous http requests this Adapter can be used for.\n        (optional, defaults to None, which means no limit).\n    :param float connect_retry_delay:\n        Delay (in seconds) between two connect retries (if enabled).\n        By default exponential retry starting with 0.5 seconds up to\n        a maximum of 60 seconds is used.\n    :param float status_code_retry_delay:\n        Delay (in seconds) between two status code retries (if enabled).\n        By default exponential retry starting with 0.5 seconds up to\n        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    :type session: keystoneauth1.session.Session\n    :param str service_type: The default service_type for URL discovery.\n    :param str service_name: The default service_name for URL discovery.\n    :param str interface: The default interface for URL discovery.\n    :param str region_name: The default region_name for URL discovery.\n    :param str endpoint_override:\n        Always use this endpoint URL for requests for this client.\n    :param version:\n        The minimum version restricted to a given Major API.\n        Mutually exclusive with min_version and max_version.\n        (optional)\n    :param auth: An auth plugin to use instead of the session one.\n    :type auth: keystoneauth1.plugin.BaseAuthPlugin\n    :param str user_agent: The User-Agent string to set.\n    :param int connect_retries:\n        The maximum number of retries that should be attempted for\n        connection errors. Default None - use session default which\n        is don't retry.\n    :param logger:\n        A logging object to use for requests that pass through this\n        adapter.\n    :type logger: logging.Logger\n    :param dict allow:\n        Extra filters to pass when discovering API versions.  (optional)\n    :param dict additional_headers:\n        Additional headers that should be attached to every request\n        passing through the adapter. Headers of the same name specified\n        per request will take priority.\n    :param str client_name:\n        The name of the client that created the adapter. This will be\n        used to create the user_agent.\n    :param str client_version:\n        The version of the client that created the adapter. This will\n        be used to create the user_agent.\n    :param bool allow_version_hack:\n        Allow keystoneauth to hack up catalog URLS to support older schemes.\n        (optional, default True)\n    :param str global_request_id:\n        A global_request_id (in the form of ``req-$uuid``) that will be\n        passed on all requests. Enables cross project request id tracking.\n    :param min_version:\n        The minimum major version of a given API, intended to be used as\n        the lower bound of a range with max_version. Mutually exclusive with\n        version. If min_version is given with no max_version it is as\n        if max version is 'latest'. (optional)\n    :param max_version:\n        The maximum major version of a given API, intended to be used as\n        the upper bound of a range with min_version. Mutually exclusive with\n        version. (optional)\n    :param default_microversion:\n        The default microversion value to send with API requests. While\n        microversions are a per-request feature, a user may know they\n        want to default to sending a specific value.  (optional)\n    :param int status_code_retries:\n        The maximum number of retries that should be attempted for retriable\n        HTTP status codes (optional, defaults to 0 - never retry).\n    :param list retriable_status_codes:\n        List of HTTP status codes that should be retried (optional,\n        defaults to HTTP 503, has no effect when status_code_retries is 0).\n    :param bool raise_exc:\n        If True, requests returning failing HTTP responses will raise an\n        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 float rate_limit:\n        A client-side rate limit to impose on requests made through this\n        adapter in requests per second. For instance, a rate_limit of 2\n        means to allow no more than 2 requests per second, and a rate_limit\n        of 0.5 means to allow no more than 1 request every two seconds.\n        (optional, defaults to None, which means no rate limiting will be\n        applied).\n    :param int concurrency:\n        How many simultaneous http requests this Adapter can be used for.\n        (optional, defaults to None, which means no limit).\n    :param float connect_retry_delay:\n        Delay (in seconds) between two connect retries (if enabled).\n        By default exponential retry starting with 0.5 seconds up to\n        a maximum of 60 seconds is used.\n    :param float status_code_retry_delay:\n        Delay (in seconds) between two status code retries (if enabled).\n        By default exponential retry starting with 0.5 seconds up to\n        a maximum of 60 seconds is used.\n    "
__init__(session: Session, service_type: str | None = None, service_name: str | None = None, interface: str | None = None, region_name: str | None = None, endpoint_override: str | None = None, version: str | None = None, auth: plugin.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 (if defined)

_request(url: str, method: str, **kwargs: Any) Response
_set_endpoint_filter_kwargs(kwargs: Dict[str, object]) None
client_name: str | None = None
client_version: str | None = None
get_all_version_data(interface: str = '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 (string) – Region of endpoints to get version data for. A valueof 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: plugin.BaseAuthPlugin | None = None, **kwargs: Any) Tuple[int | float, ...] | None

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

Parameters:

auth (keystoneauth1.plugin.BaseAuthPlugin) – 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.

Return type:

tuple or None

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

Get an endpoint as provided by the auth plugin.

Parameters:

auth (keystoneauth1.plugin.BaseAuthPlugin) – 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.

Return type:

str

get_endpoint_data(auth: plugin.BaseAuthPlugin | None = None) discover.EndpointData | None

Get the endpoint data for this Adapter’s endpoint.

Parameters:

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

Raises:
Returns:

Endpoint data if available or None.

Return type:

keystoneauth1.discover.EndpointData

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

Return the authenticated project_id as provided by the auth plugin.

Parameters:

auth (keystoneauth1.plugin.BaseAuthPlugin) – 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.

Return type:

str

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

Return a token as provided by the auth plugin.

Parameters:

auth (keystoneauth1.plugin.BaseAuthPlugin) – 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.

Return type:

str

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

Return the authenticated user_id as provided by the auth plugin.

Parameters:

auth (keystoneauth1.plugin.BaseAuthPlugin) – 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.

Return type:

str

invalidate(auth: plugin.BaseAuthPlugin | None = None) bool

Invalidate an authentication plugin.

Parameters:

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

classmethod register_argparse_arguments(parser: ArgumentParser, service_type: str | None = None) None

Attach arguments to a given argparse Parser for Adapters.

Parameters:
  • parser (argparse.ArgumentParser) – The argparse parser to attach options to.

  • service_type (str) – 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 (argparse.ArgumentParser) – The argparse parser to attach options to.

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

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