keystoneauth1.session module¶
- class keystoneauth1.session.NoOpSemaphore
基类:
object用于作为默认信号量的一个空上下文管理器。
- __dict__ = mappingproxy({'__module__': 'keystoneauth1.session', '__doc__': '用于作为默认信号量的一个空上下文管理器。', '__enter__': <function NoOpSemaphore.__enter__>, '__exit__': <function NoOpSemaphore.__exit__>, '__dict__': <attribute '__dict__' of 'NoOpSemaphore' objects>, '__weakref__': <attribute '__weakref__' of 'NoOpSemaphore' objects>, '__annotations__': {}})
- __doc__ = '用于作为默认信号量的一个空上下文管理器。'
- __enter__() None
进入上下文管理器,不执行任何操作。
- __exit__(exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) None
退出上下文管理器,不执行任何操作。
- __module__ = 'keystoneauth1.session'
- __weakref__
对该对象的弱引用列表
- class keystoneauth1.session.RequestTiming(method: str | None, url: str | None, elapsed: timedelta)
基类:
object包含 HTTP 交互的计时信息。
- __annotations__ = {'elapsed': <class 'datetime.timedelta'>, 'method': str | None, 'url': str | None}
- __dict__ = mappingproxy({'__module__': 'keystoneauth1.session', '__annotations__': {'method': str | None, 'url': str | None, 'elapsed': <class 'datetime.timedelta'>}, '__doc__': '包含 HTTP 交互的计时信息。', '__init__': <function RequestTiming.__init__>, '__dict__': <attribute '__dict__' of 'RequestTiming' objects>, '__weakref__': <attribute '__weakref__' of 'RequestTiming' objects>})
- __doc__ = '包含 HTTP 交互的计时信息。'
- __module__ = 'keystoneauth1.session'
- __weakref__
对该对象的弱引用列表
- elapsed: timedelta
经过的时间信息
- class keystoneauth1.session.Session(auth: plugin.BaseAuthPlugin | None = None, session: Session | None = None, original_ip: str | None = None, verify: bool | str | None = True, cert: str | tuple[str, str] | None = None, timeout: int | None = None, user_agent: str | None = None, redirect: int | bool = 30, additional_headers: MutableMapping[str, str] | None = None, app_name: str | None = None, app_version: str | None = None, additional_user_agent: list[tuple[str, str]] | None = None, discovery_cache: dict[str, Any] | None = None, split_loggers: bool | None = None, collect_timing: bool = False, rate_semaphore: ContextManager[None] | None = None, connect_retries: int = 0)
基类:
object维护客户端通信状态和通用功能。
尽可能地,此类中的参数反映并直接传递给
requests库。- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于使用身份验证插件对会话进行身份验证。 (可选,默认为 None)
session (requests.Session) – 用于发出请求的 requests 会话对象。 (可选)
original_ip (str) – 请求用户的原始 IP,将在 ‘Forwarded’ 标头中发送到身份服务。 (可选)
verify – 传递给 requests 的验证参数。 这些形式与 requests 期望的形式相同,因此 True 或 False 以验证(或不验证)系统证书,或者使用路径到捆绑包或 CA 证书进行检查,或者 None 以让 requests 尝试找到并使用证书。 (可选,默认为 True)
cert – 传递给 requests 的客户端证书。 这些形式与 requests 期望的形式相同。 要么包含证书和密钥的单个文件名,要么包含证书路径然后是密钥路径的元组。 (可选)
timeout (float) – 传递给 requests 的超时时间。 这应该是一个数值,表示一定量(或分数)的秒数,或者 0 表示没有超时时间。 (可选,默认为 0)
user_agent (str) – 用于请求的 User-Agent 标头字符串。 如果未提供,则使用
DEFAULT_USER_AGENT的默认值,其中包含 keystoneauth1 版本以及 requests 库和正在使用的 Python 版本。 传递非 None 值时,它将附加到默认值之前。redirect (int/bool) – 控制请求可以遵循的最大重定向次数。 要么是特定计数的整数,要么是 forever/never 的 True/False。 (可选,默认值为 30)
additional_headers (dict) – 附加到通过会话传递的每个请求的额外标头。 相同名称的标头在每个请求中指定将具有优先权。
app_name (str) – 创建会话的应用程序的名称。 这将用于创建 user_agent。
app_version (str) – 创建会话的应用程序的版本。 这将用于创建 user_agent。
additional_user_agent (list) – 将添加到 user agent 的名称、版本元组列表。 这可以由参与通信过程的库使用。
discovery_cache (dict) – 用于缓存发现信息的字典。通常由系统透明管理,但如果用户希望在多个不共享身份验证插件的会话之间共享单个缓存,则可以在此处提供。(可选,默认为 None,表示自动管理)
split_loggers (bool) – 将请求的日志记录拆分为多个日志记录器,而不是仅使用一个。默认为 False。
collect_timing (bool) – 是否为每个 API 调用收集每个方法的计时信息。(可选,默认为 False)
rate_semaphore – 用于控制请求并发和速率限制的信号量。(可选,默认为无并发或速率控制)
connect_retries (int) – 应该尝试的连接错误的重试次数上限。(可选,默认为 0 - 从不重试)。
- _DEFAULT_REDIRECT_LIMIT = 30
- _REDIRECT_STATUSES = (301, 302, 303, 305, 307, 308)
- __del__() → None
在删除时清理资源。
- __dict__ = mappingproxy({'__module__': 'keystoneauth1.session', '__doc__': "Maintains client communication state and common functionality.\n\n As much as possible the parameters to this class reflect and are passed\n directly to the :mod:`requests` library.\n\n :param auth: An authentication plugin to authenticate the session with.\n (optional, defaults to None)\n :type auth: keystoneauth1.plugin.BaseAuthPlugin\n :param requests.Session session: A requests session object that can be used\n for issuing requests. (optional)\n :param str original_ip: The original IP of the requesting user which will\n be sent to identity service in a 'Forwarded'\n header. (optional)\n :param verify: The verification arguments to pass to requests. These are of\n the same form as requests expects, so True or False to\n verify (or not) against system certificates or a path to a\n bundle or CA certs to check against or None for requests to\n attempt to locate and use certificates. (optional, defaults\n to True)\n :param cert: A client certificate to pass to requests. These are of the\n same form as requests expects. Either a single filename\n containing both the certificate and key or a tuple containing\n the path to the certificate then a path to the key. (optional)\n :param float timeout: A timeout to pass to requests. This should be a\n numerical value indicating some amount (or fraction)\n of seconds or 0 for no timeout. (optional, defaults\n to 0)\n :param str user_agent: A User-Agent header string to use for the request.\n If not provided, a default of\n :attr:`~keystoneauth1.session.DEFAULT_USER_AGENT` is\n used, which contains the keystoneauth1 version as\n well as those of the requests library and which\n Python is being used. When a non-None value is\n passed, it will be prepended to the default.\n :param int/bool redirect: Controls the maximum number of redirections that\n can be followed by a request. Either an integer\n for a specific count or True/False for\n forever/never. (optional, default to 30)\n :param dict additional_headers: Additional headers that should be attached\n to every request passing through the\n session. Headers of the same name specified\n per request will take priority.\n :param str app_name: The name of the application that is creating the\n session. This will be used to create the user_agent.\n :param str app_version: The version of the application creating the\n session. This will be used to create the\n user_agent.\n :param list additional_user_agent: A list of tuple of name, version that\n will be added to the user agent. This\n can be used by libraries that are part\n of the communication process.\n :param dict discovery_cache: A dict to be used for caching of discovery\n information. This is normally managed\n transparently, but if the user wants to\n share a single cache across multiple sessions\n that do not share an auth plugin, it can\n be provided here. (optional, defaults to\n None which means automatically manage)\n :param bool split_loggers: Split the logging of requests across multiple\n loggers instead of just one. Defaults to False.\n :param bool collect_timing: Whether or not to collect per-method timing\n information for each API call. (optional,\n defaults to False)\n :param rate_semaphore: Semaphore to be used to control concurrency\n and rate limiting of requests. (optional,\n defaults to no concurrency or rate control)\n :param int connect_retries: the maximum number of retries that should\n be attempted for connection errors.\n (optional, defaults to 0 - never retry).\n ", 'user_agent': None, '_REDIRECT_STATUSES': (301, 302, 303, 305, 307, 308), '_DEFAULT_REDIRECT_LIMIT': 30, '__init__': <function Session.__init__>, '__del__': <function Session.__del__>, 'adapters': <property object>, 'mount': <function Session.mount>, '_remove_service_catalog': <function Session._remove_service_catalog>, '_process_header': <staticmethod(<function Session._process_header>)>, '_get_split_loggers': <function Session._get_split_loggers>, '_http_log_request': <function Session._http_log_request>, '_http_log_response': <function Session._http_log_response>, '_set_microversion_headers': <staticmethod(<function Session._set_microversion_headers>)>, 'request': <function Session.request>, '_send_request': <function Session._send_request>, 'get': <function Session.get>, 'head': <function Session.head>, 'post': <function Session.post>, 'put': <function Session.put>, 'patch': <function Session.patch>, 'delete': <function Session.delete>, '_auth_required': <function Session._auth_required>, 'get_auth_headers': <function Session.get_auth_headers>, 'get_token': <function Session.get_token>, 'get_endpoint': <function Session.get_endpoint>, 'get_endpoint_data': <function Session.get_endpoint_data>, 'get_api_major_version': <function Session.get_api_major_version>, 'get_all_version_data': <function Session.get_all_version_data>, 'get_auth_connection_params': <function Session.get_auth_connection_params>, 'invalidate': <function Session.invalidate>, 'get_user_id': <function Session.get_user_id>, 'get_project_id': <function Session.get_project_id>, 'get_timings': <function Session.get_timings>, 'reset_timings': <function Session.reset_timings>, '__dict__': <attribute '__dict__' of 'Session' objects>, '__weakref__': <attribute '__weakref__' of 'Session' objects>, '__annotations__': {'_session': 'requests.Session | None', '_determined_user_agent': 'str | None', '_api_times': 'list[RequestTiming]'}})
- __doc__ = "Maintains client communication state and common functionality.\n\n As much as possible the parameters to this class reflect and are passed\n directly to the :mod:`requests` library.\n\n :param auth: An authentication plugin to authenticate the session with.\n (optional, defaults to None)\n :type auth: keystoneauth1.plugin.BaseAuthPlugin\n :param requests.Session session: A requests session object that can be used\n for issuing requests. (optional)\n :param str original_ip: The original IP of the requesting user which will\n be sent to identity service in a 'Forwarded'\n header. (optional)\n :param verify: The verification arguments to pass to requests. These are of\n the same form as requests expects, so True or False to\n verify (or not) against system certificates or a path to a\n bundle or CA certs to check against or None for requests to\n attempt to locate and use certificates. (optional, defaults\n to True)\n :param cert: A client certificate to pass to requests. These are of the\n same form as requests expects. Either a single filename\n containing both the certificate and key or a tuple containing\n the path to the certificate then a path to the key. (optional)\n :param float timeout: A timeout to pass to requests. This should be a\n numerical value indicating some amount (or fraction)\n of seconds or 0 for no timeout. (optional, defaults\n to 0)\n :param str user_agent: A User-Agent header string to use for the request.\n If not provided, a default of\n :attr:`~keystoneauth1.session.DEFAULT_USER_AGENT` is\n used, which contains the keystoneauth1 version as\n well as those of the requests library and which\n Python is being used. When a non-None value is\n passed, it will be prepended to the default.\n :param int/bool redirect: Controls the maximum number of redirections that\n can be followed by a request. Either an integer\n for a specific count or True/False for\n forever/never. (optional, default to 30)\n :param dict additional_headers: Additional headers that should be attached\n to every request passing through the\n session. Headers of the same name specified\n per request will take priority.\n :param str app_name: The name of the application that is creating the\n session. This will be used to create the user_agent.\n :param str app_version: The version of the application creating the\n session. This will be used to create the\n user_agent.\n :param list additional_user_agent: A list of tuple of name, version that\n will be added to the user agent. This\n can be used by libraries that are part\n of the communication process.\n :param dict discovery_cache: A dict to be used for caching of discovery\n information. This is normally managed\n transparently, but if the user wants to\n share a single cache across multiple sessions\n that do not share an auth plugin, it can\n be provided here. (optional, defaults to\n None which means automatically manage)\n :param bool split_loggers: Split the logging of requests across multiple\n loggers instead of just one. Defaults to False.\n :param bool collect_timing: Whether or not to collect per-method timing\n information for each API call. (optional,\n defaults to False)\n :param rate_semaphore: Semaphore to be used to control concurrency\n and rate limiting of requests. (optional,\n defaults to no concurrency or rate control)\n :param int connect_retries: the maximum number of retries that should\n be attempted for connection errors.\n (optional, defaults to 0 - never retry).\n "
- __init__(auth: plugin.BaseAuthPlugin | None = None, session: Session | None = None, original_ip: str | None = None, verify: bool | str | None = True, cert: str | tuple[str, str] | None = None, timeout: int | None = None, user_agent: str | None = None, redirect: int | bool = 30, additional_headers: MutableMapping[str, str] | None = None, app_name: str | None = None, app_version: str | None = None, additional_user_agent: list[tuple[str, str]] | None = None, discovery_cache: dict[str, Any] | None = None, split_loggers: bool | None = None, collect_timing: bool = False, rate_semaphore: ContextManager[None] | None = None, connect_retries: int = 0)
- __module__ = 'keystoneauth1.session'
- __weakref__
对该对象的弱引用列表
- _auth_required(auth: plugin.BaseAuthPlugin | None, msg: str) → plugin.BaseAuthPlugin
- _get_split_loggers(split_loggers: bool | None) → bool | None
从各种参数来源获取布尔值。
我们在 Session 构造函数的 kwargs 中将 split_loggers 默认为 None,以便跟踪设置与未设置。我们还在其他一些地方接受 split_loggers 作为参数。在每个需要该参数的地方,如果用户提供了该参数,则该参数应优先。
- _http_log_request(url: str, method: str | None = None, data: str | bytes | None = None, json: object = None, headers: MutableMapping[str, str] | None = None, query_params: dict[str, Any] | None = None, logger: Logger | None = None, split_loggers: bool | None = None) None
- _http_log_response(response: Response | None = None, json: object = None, status_code: int | None = None, headers: MutableMapping[str, str] | None = None, text: str | None = None, *,logger: Logger, split_loggers: bool | None = None) None
- _send_request(url: str, method: str, redirect: int | bool, log: bool, logger: Logger, split_loggers: bool | None, connect_retries: int, status_code_retries: int, retriable_status_codes: list[int], rate_semaphore: ContextManager[None], connect_retry_delays: _Retries, status_code_retry_delays: _Retries, **kwargs: Any) Response
- static _set_microversion_headers(headers: MutableMapping[str, str], microversion: str, service_type: str | None, endpoint_filter: dict[str, Any] | None) None
- property adapters: MutableMapping[Any, Any]
- get_all_version_data(auth: plugin.BaseAuthPlugin | None = None, interface: str | list[str] | None = 'public', region_name: str | None = None, service_type: str | None = None) dict[str, dict[str, dict[str, list[VersionData]]]]
获取目录中所有服务的版本数据。
- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于令牌的身份验证插件。覆盖会话上的插件。(可选)
interface – 要获取版本数据的端点类型。可以是一个单一值或一个值列表。值为 None 表示应查询所有接口。(可选,默认为 public)
region_name (string) – 要获取版本数据的端点区域。值为 None 表示应查询所有区域。(可选,默认为 None)
service_type (string) – 限制版本数据到单个服务。(可选,默认为 None)
- 返回值:
一个字典,键为 region_name,值为包含字典的字典,字典的键为 interface,值为 ~keystoneauth1.discover.VersionData 列表。
- get_api_major_version(auth: plugin.BaseAuthPlugin | None = None, **kwargs: Any) tuple[int | float, ...] | None
获取身份验证插件提供的主要 API 版本。
- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于令牌的身份验证插件。覆盖会话上的插件。(可选)
- 引发:
keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – 如果没有可用的插件。
- 返回值:
服务发现的 API 主要版本。
- 返回类型:
tuple 或 None
- get_auth_connection_params(auth: plugin.BaseAuthPlugin | None = None) plugin.ConnectionParams
返回身份验证插件提供的身份验证连接参数。
身份验证插件可以指定连接参数到请求,例如为通信提供客户端证书。
我们限制此函数返回的值,以防止身份验证插件覆盖与连接参数无关的值。当前接受的值是
cert:客户端证书的路径,或用于此请求的客户端证书和密钥对的元组。
verify:一个布尔值,指示是否针对系统 CA 验证 SSL 证书,或者用于验证的 CA 文件的路径。
这些值传递给 requests 库,有关接受的值的更多信息,请参见那里。
- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于令牌的身份验证插件。覆盖会话上的插件。(可选)
- 引发:
keystoneauth1.exceptions.auth.AuthorizationFailure – 如果新的令牌获取失败。
keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – 如果没有可用的插件。
keystoneauth1.exceptions.auth_plugins.UnsupportedParameters – 如果插件返回此会话不支持的参数。
- 返回值:
身份验证标头或失败为 None。
- 返回类型:
- get_auth_headers(auth: plugin.BaseAuthPlugin | None = None) dict[str, str] | None
返回身份验证插件提供的身份验证标头。
- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于令牌的身份验证插件。覆盖会话上的插件。(可选)
- 引发:
keystoneauth1.exceptions.auth.AuthorizationFailure – 如果新的令牌获取失败。
keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – 如果没有可用的插件。
- 返回值:
身份验证标头或失败为 None。
- 返回类型:
- get_endpoint(auth: plugin.BaseAuthPlugin | None = None, *, endpoint_override: str | None = None, **kwargs: Any) str | None
获取由认证插件提供的端点。
- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于令牌的身份验证插件。覆盖会话上的插件。(可选)
- 引发:
keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – 如果没有可用的插件。
- 返回值:
如果可用,则返回端点,否则返回 None。
- 返回类型:
字符串
- get_endpoint_data(auth: plugin.BaseAuthPlugin | None = None, **kwargs: Any) EndpointData | None
获取由认证插件提供的端点数据。
- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于令牌的身份验证插件。覆盖会话上的插件。(可选)
- 引发:
keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – 如果没有可用的插件。
TypeError – 如果参数无效
- 返回值:
如果可用,则返回端点数据,否则返回 None。
- 返回类型:
keystoneauth1.discover.EndpointData
- get_project_id(auth: plugin.BaseAuthPlugin | None = None) str | None
返回由认证插件提供的已认证的项目 ID。
- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于令牌的身份验证插件。覆盖会话上的插件。(可选)
- 引发:
keystoneauth1.exceptions.auth.AuthorizationFailure – 如果新的令牌获取失败。
keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – 如果没有可用的插件。
- 返回值:
当前项目 ID,如果插件不支持,则返回 None。
- 返回类型:
- get_timings() list[RequestTiming]
返回收集到的 API 定时信息。
- 返回值:
RequestTiming 对象列表。
- get_token(auth: plugin.BaseAuthPlugin | None = None) str | None
返回由认证插件提供的令牌。
- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于令牌的身份验证插件。覆盖会话上的插件。(可选)
- 引发:
keystoneauth1.exceptions.auth.AuthorizationFailure – 如果新的令牌获取失败。
keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – 如果没有可用的插件。
警告
已弃用:此方法假定用于认证消息的唯一标头是
X-Auth-Token。这可能不正确。请使用get_auth_headers()代替。- 返回值:
一个有效的 token。
- 返回类型:
字符串
- get_user_id(auth: plugin.BaseAuthPlugin | None = None) str | None
返回由认证插件提供的已认证的用户 ID。
- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于令牌的身份验证插件。覆盖会话上的插件。(可选)
- 引发:
keystoneauth1.exceptions.auth.AuthorizationFailure – 如果新的令牌获取失败。
keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – 如果没有可用的插件。
- 返回值:
当前用户 ID,如果插件不支持,则返回 None。
- 返回类型:
- invalidate(auth: plugin.BaseAuthPlugin | None = None) bool
使认证插件失效。
- 参数:
auth (keystoneauth1.plugin.BaseAuthPlugin) – 要使之失效的认证插件。覆盖会话上的插件。(可选)
- request(url: str, method: str, json: object | None = None, original_ip: str | None = None, user_agent: str | None = None, redirect: int | bool | None = None, authenticated: bool | None = None, endpoint_filter: dict[str, Any] | None = None, auth: plugin.BaseAuthPlugin | None = None, requests_auth: requests.auth.AuthBase | None = None, raise_exc: bool = True, allow_reauth: bool = True, log: bool = True, endpoint_override: str | None = None, connect_retries: int | None = None, logger: Logger | None = None, allow: dict[str, Any] | None = None, client_name: str | None = None, client_version: str | None = None, microversion: str | None = None, microversion_service_type: str | None = None, status_code_retries: int = 0, retriable_status_codes: list[int] | None = None, rate_semaphore: ContextManager[None] | None = None, global_request_id: str | None = None, connect_retry_delay: float | None = None, status_code_retry_delay: float | None = None, **kwargs: Any) Response
发送具有指定特征的 HTTP 请求。
对 requests.Session.request 的封装,用于处理诸如设置标头、JSON 编码/解码和错误处理之类的任务。
未处理的参数将传递给 requests 库。
- 参数:
url (str) – HTTP 请求的路径或完全限定的 URL。如果仅提供路径,则还必须提供 endpoint_filter,以便可以确定基本 URL。如果提供完全限定的 URL,则将忽略 endpoint_filter。
method (str) – 要使用的 http 方法。(例如‘GET’、‘POST’)
json – 要表示为 JSON 的一些数据。(可选)
original_ip (str) – 将此请求标记为转发此 IP 的请求。(可选)
headers (dict) – 要包含在请求中的标头。(可选)
user_agent (str) – 要用于请求的用户代理。如果存在,将覆盖标头中存在的用户代理。(可选)
redirect (int/bool) – 请求可以遵循的最大重定向次数。整数表示特定计数,True/False 表示永远/从不。(可选)
connect_retries (int) – 应尝试连接错误的重试的最大次数。(可选,默认为 None - 从不重试)。
authenticated (bool) – 如果应将令牌附加到此请求,则为 True;如果为 False,或者如果可用 auth_plugin,则为 None。(可选,默认为 None)
endpoint_filter (dict) – 要提供给 auth 插件的数据,auth 插件应能够使用该数据确定用于此请求的端点。如果未提供,则预计 URL 是完全限定的 URL。(可选)
endpoint_override (str) – 使用 auth 插件中查找端点 URL 之外的 URL。如果提供了完全限定的 URL,则会忽略此设置,但它优先于 endpoint_filter。此字符串可以包含
%(project_id)s和%(user_id)s这些值,以便将它们替换为当前身份验证的 project_id/user_id。(可选)auth (keystoneauth1.plugin.BaseAuthPlugin) – 用于验证此请求的 auth 插件。这将覆盖会话中附加的插件(如果有)。(可选)
requests_auth (requests.auth.AuthBase) – 一个 requests 库 auth 插件,由于 auth 参数与我们自己的 auth 插件冲突,因此无法通过关键字参数传递。(可选)
raise_exc (bool) – 如果为 True,则对失败的 HTTP 请求引发适当的异常。如果为 False,则返回请求对象。(可选,默认值为 True)
allow_reauth (bool) – 允许在收到 401 Unauthorized 响应时获取新的令牌并重试请求。(可选,默认值为 True)
log (bool) – 如果为 True,则将请求和响应数据记录到调试日志中。(可选,默认值为 True)
logger (logging.Logger) – 用于记录请求和响应的 logger 对象。如果未提供,将使用 keystoneauth1.session 默认 logger。
allow (dict) – 在发现 API 版本时传递的额外筛选器。(可选)
microversion – 要为此请求发送的 microversion。microversion 可以作为字符串或元组给出。(可选)
microversion_service_type (str) – 如果提供了 microversion,则要在 microversion header 中发送的 service_type。默认值为 endpoint_filter 中的 service_type(如果存在)。如果未提供 endpoint_filter 或 endpoint_filter 没有 service_type,并且提供了 microversion 但未提供 microversion_service_type,则会引发异常。
status_code_retries (int) – 应该尝试的可重试 HTTP 状态代码的最大重试次数(可选,默认值为 0 - 从不重试)。
retriable_status_codes (list) – 应该重试的 HTTP 状态代码列表(可选,默认值为 HTTP 503,当 status_code_retries 为 0 时不起作用)。
rate_semaphore – 用于控制请求并发和速率限制的信号量。(可选,默认为无并发或速率控制)
global_request_id – X-Openstack-Request-Id header 的值。
connect_retry_delay (float) – 两次连接重试之间的延迟(以秒为单位)(如果启用)。默认情况下,从 0.5 秒开始,最大为 60 秒的指数重试。
status_code_retry_delay (float) – 两次状态代码重试之间的延迟(以秒为单位)(如果启用)。默认情况下,从 0.5 秒开始,最大为 60 秒的指数重试。
kwargs –
任何可以传递到
requests.Session.request()的其他参数(例如 headers)。除了data 将被 json 参数中的数据覆盖。
allow_redirects 被忽略,因为重定向由会话处理。
- 引发:
keystoneauth1.exceptions.base.ClientException – 用于连接失败,或指示错误响应代码。
- 返回值:
对请求的响应。
- reset_timings() None
清除 API 定时信息。
- user_agent = None
- class keystoneauth1.session.TCPKeepAliveAdapter(pool_connections=10, pool_maxsize=10, max_retries=0, pool_block=False)
继承自
HTTPAdapter用于在所有连接上设置 TCP Keep-Alive 的自定义适配器。
此适配器还保留 Requests 的默认行为,即禁用 Nagle 算法。请参阅:https://blogs.msdn.com/b/windowsazurestorage/archive/2010/06/25/nagle-s-algorithm-is-not-friendly-towards-small-requests.aspx
- __doc__ = "The custom adapter used to set TCP Keep-Alive on all connections.\n\n This Adapter also preserves the default behaviour of Requests which\n disables Nagle's Algorithm. See also:\n https://blogs.msdn.com/b/windowsazurestorage/archive/2010/06/25/nagle-s-algorithm-is-not-friendly-towards-small-requests.aspx\n "
- __module__ = 'keystoneauth1.session'
- class keystoneauth1.session._JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
基类:
JSONEncoder- __doc__ = None
- __module__ = 'keystoneauth1.session'
- class keystoneauth1.session._Retries(fixed_delay: float | None = None)
基类:
object- __annotations__ = {'_current': <class 'float'>, '_fixed_delay': float | None}
- __doc__ = None
- __module__ = 'keystoneauth1.session'
- __next__() float
- __slots__ = ('_fixed_delay', '_current')
- _current: float
- reset() None
- class keystoneauth1.session._StringFormatter(session: Session, auth: plugin.BaseAuthPlugin | None)
基类:
object一个按需获取值的字符串格式化器。
- __dict__ = mappingproxy({'__module__': 'keystoneauth1.session', '__doc__': '一个 字符串 格式化器 ,按需获取值。', '__init__': <function _StringFormatter.__init__>, '__getitem__': <function _StringFormatter.__getitem__>, '__dict__': <attribute '__dict__' of '_StringFormatter' 对象>, '__weakref__': <attribute '__weakref__' of '_StringFormatter' 对象>, '__annotations__': {}})
- __doc__ = '一个 字符串 格式化器 ,按需获取值。'
- __init__(session: Session, auth: plugin.BaseAuthPlugin | None)
- __module__ = 'keystoneauth1.session'
- __weakref__
对该对象的弱引用列表
- keystoneauth1.session._construct_session(session_obj: Session | None = None) Session
- keystoneauth1.session._determine_calling_package() str
遍历调用帧,尝试确定正在使用此模块的内容。
- keystoneauth1.session._determine_user_agent() str
尝试以编程方式生成用户代理字符串。
首先,查看进程的名称。如果它不在忽略列表中,则返回此名称。否则,查看函数调用堆栈,并尝试找到调用此模块的代码的名称。