From b55fb6a71bddefc0d32130d7e90cd3fd10472277 Mon Sep 17 00:00:00 2001 From: NguyenHoangSon96 Date: Thu, 4 Jun 2026 13:09:49 +0700 Subject: [PATCH] refactor: remove signin and signout services --- CHANGELOG.md | 6 + influxdb_client_3/__init__.py | 5 - influxdb_client_3/write_client/__init__.py | 3 - .../write_client/_sync/api_client.py | 22 +-- .../write_client/client/__init__.py | 2 - .../write_client/client/_base.py | 25 +--- .../write_client/client/influxdb_client.py | 10 -- .../write_client/client/write/__init__.py | 2 - .../write_client/configuration.py | 25 ---- influxdb_client_3/write_client/rest.py | 10 -- .../write_client/service/__init__.py | 4 +- .../write_client/service/signin_service.py | 129 ------------------ .../write_client/service/signout_service.py | 124 ----------------- 13 files changed, 10 insertions(+), 357 deletions(-) delete mode 100644 influxdb_client_3/write_client/service/signin_service.py delete mode 100644 influxdb_client_3/write_client/service/signout_service.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 4871ddcc..2d9c742c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## 0.20.0 [unreleased] +### Others + +1. [#215](https://github.com/InfluxCommunity/influxdb3-python/pull/215): + - Remove cookie/session-based signin/signout support from the writing client. + - Remove basic authentication with a username and password. + ### Features 1. [#208](https://github.com/InfluxCommunity/influxdb3-python/pull/208): Add `influx3 query` CLI support for executing SQL/InfluxQL queries with JSON/JSONL/CSV/pretty output, including module execution via `python -m influxdb_client_3`. diff --git a/influxdb_client_3/__init__.py b/influxdb_client_3/__init__.py index 36bcd6fb..824d5b70 100644 --- a/influxdb_client_3/__init__.py +++ b/influxdb_client_3/__init__.py @@ -228,11 +228,6 @@ def __init__( Defaults to "multiprocessing.cpu_count() * 5". :key urllib3.util.retry.Retry retries: Set the default retry strategy that is used for all HTTP requests except batching writes. As a default there is no one retry strategy. - :key bool auth_basic: Set this to true to enable basic authentication when talking to a InfluxDB 1.8.x that - does not use auth-enabled but is protected by a reverse proxy with basic authentication. - (defaults to false, don't set to true when talking to InfluxDB 2) - :key str username: ``username`` to authenticate via username and password credentials to the InfluxDB 2.x - :key str password: ``password`` to authenticate via username and password credentials to the InfluxDB 2.x :key str query_timeout: int value used to set the client query API timeout in milliseconds. :key str write_timeout: int value used to set the client write API timeout in milliseconds. :key bool write_accept_partial: allow partial writes when some lines fail. diff --git a/influxdb_client_3/write_client/__init__.py b/influxdb_client_3/write_client/__init__.py index 7a1cc05b..feae8448 100644 --- a/influxdb_client_3/write_client/__init__.py +++ b/influxdb_client_3/write_client/__init__.py @@ -10,9 +10,6 @@ from influxdb_client_3.write_client.client.write.point import Point from influxdb_client_3.write_client.service.write_service import WriteService -from influxdb_client_3.write_client.service.signin_service import SigninService -from influxdb_client_3.write_client.service.signout_service import SignoutService - from influxdb_client_3.write_client.domain.write_precision import WritePrecision diff --git a/influxdb_client_3/write_client/_sync/api_client.py b/influxdb_client_3/write_client/_sync/api_client.py index 2954327f..6064c2dc 100644 --- a/influxdb_client_3/write_client/_sync/api_client.py +++ b/influxdb_client_3/write_client/_sync/api_client.py @@ -12,11 +12,8 @@ from urllib.parse import quote import influxdb_client_3.write_client.domain -from influxdb_client_3.write_client import SigninService -from influxdb_client_3.write_client import SignoutService from influxdb_client_3.write_client._sync import rest from influxdb_client_3.write_client.configuration import Configuration -from influxdb_client_3.write_client.rest import _requires_create_user_session, _requires_expire_user_session class ApiClient(object): @@ -25,8 +22,6 @@ class ApiClient(object): :param header_name: a header to pass when making calls to the API. :param header_value: a header value to pass when making calls to the API. - :param cookie: a cookie to include in the header when making calls - to the API :param pool_threads: The number of threads to use for async requests to the API. More threads means more concurrent API requests. """ @@ -45,7 +40,7 @@ class ApiClient(object): _pool = None def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None, pool_threads=None, retries=False): + pool_threads=None, retries=False): """Initialize generic API client.""" if configuration is None: configuration = Configuration() @@ -56,14 +51,12 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value - self.cookie = cookie # Set default User-Agent. from influxdb_client_3.version import USER_AGENT self.user_agent = USER_AGENT def __del__(self): """Dispose pools.""" - self._signout() if self._pool: self._pool.close() self._pool.join() @@ -134,7 +127,6 @@ def __call_api( _preload_content=True, _request_timeout=None, urlopen_kw=None): config = self.configuration - self._signin(resource_path=resource_path) # body should_gzip = False @@ -147,8 +139,6 @@ def __call_api( header_params = header_params or {} config.update_request_header_params(resource_path, header_params, should_gzip) header_params.update(self.default_headers) - if self.cookie: - header_params['Cookie'] = self.cookie if header_params: header_params = self.sanitize_for_serialization(header_params) header_params = dict(self.parameters_to_tuples(header_params, @@ -670,13 +660,3 @@ def __deserialize_model(self, data, klass): if klass_name: instance = self.__deserialize(data, klass_name) return instance - - def _signin(self, resource_path: str): - if _requires_create_user_session(self.configuration, self.cookie, resource_path): - http_info = SigninService(self).post_signin_with_http_info() - self.cookie = http_info[2]['set-cookie'] - - def _signout(self): - if _requires_expire_user_session(self.configuration, self.cookie): - SignoutService(self).post_signout() - self.cookie = None diff --git a/influxdb_client_3/write_client/client/__init__.py b/influxdb_client_3/write_client/client/__init__.py index 7809220a..5b960961 100644 --- a/influxdb_client_3/write_client/client/__init__.py +++ b/influxdb_client_3/write_client/client/__init__.py @@ -3,6 +3,4 @@ from __future__ import absolute_import # import apis into api package -from influxdb_client_3.write_client.service.signin_service import SigninService -from influxdb_client_3.write_client.service.signout_service import SignoutService from influxdb_client_3.write_client.service.write_service import WriteService diff --git a/influxdb_client_3/write_client/client/_base.py b/influxdb_client_3/write_client/client/_base.py index 34ff05d5..8acae180 100644 --- a/influxdb_client_3/write_client/client/_base.py +++ b/influxdb_client_3/write_client/client/_base.py @@ -1,7 +1,6 @@ """Commons function for Sync and Async client.""" from __future__ import absolute_import -import base64 import configparser import logging import os @@ -66,8 +65,6 @@ def __init__(self, url, token, debug=None, timeout=10_000, enable_gzip=False, or self.conf.loggers[client_logger] = logging.getLogger(client_logger) self.conf.debug = debug - self.conf.username = kwargs.get('username', None) - self.conf.password = kwargs.get('password', None) # defaults self.auth_header_name = None self.auth_header_value = None @@ -76,15 +73,6 @@ def __init__(self, url, token, debug=None, timeout=10_000, enable_gzip=False, or auth_scheme = kwargs.get('auth_scheme', "Token") self.auth_header_name = "Authorization" self.auth_header_value = f"{auth_scheme} {token}" - # by HTTP basic - auth_basic = kwargs.get('auth_basic', False) - if auth_basic: - self.auth_header_name = "Authorization" - self.auth_header_value = "Basic " + base64.b64encode(token.encode()).decode() - # by username, password - if self.conf.username and self.conf.password: - self.auth_header_name = None - self.auth_header_value = None self.retries = kwargs.get('retries', False) @@ -149,10 +137,6 @@ def _has_section(key: str): if _has_option('connection_pool_maxsize'): connection_pool_maxsize = _config_value('connection_pool_maxsize') - auth_basic = False - if _has_option('auth_basic'): - auth_basic = _config_value('auth_basic') - default_tags = None if _has_section('tags'): if is_json: @@ -172,8 +156,7 @@ def _has_section(key: str): return cls(url, token, debug=debug, timeout=_to_int(timeout), org=org, default_tags=default_tags, enable_gzip=enable_gzip, verify_ssl=_to_bool(verify_ssl), ssl_ca_cert=ssl_ca_cert, cert_file=cert_file, cert_key_file=cert_key_file, cert_key_password=cert_key_password, - connection_pool_maxsize=_to_int(connection_pool_maxsize), auth_basic=_to_bool(auth_basic), - profilers=profilers, proxy=proxy, **kwargs) + connection_pool_maxsize=_to_int(connection_pool_maxsize), profilers=profilers, proxy=proxy, **kwargs) @classmethod @deprecated('Use InfluxDBClient3.from_env() instead.') @@ -188,7 +171,6 @@ def _from_env_properties(cls, debug=None, enable_gzip=False, **kwargs): cert_key_file = os.getenv('INFLUXDB_V2_CERT_KEY_FILE', None) cert_key_password = os.getenv('INFLUXDB_V2_CERT_KEY_PASSWORD', None) connection_pool_maxsize = os.getenv('INFLUXDB_V2_CONNECTION_POOL_MAXSIZE', None) - auth_basic = os.getenv('INFLUXDB_V2_AUTH_BASIC', "False") prof = os.getenv("INFLUXDB_V2_PROFILERS", None) profilers = None @@ -204,8 +186,7 @@ def _from_env_properties(cls, debug=None, enable_gzip=False, **kwargs): return cls(url, token, debug=debug, timeout=_to_int(timeout), org=org, default_tags=default_tags, enable_gzip=enable_gzip, verify_ssl=_to_bool(verify_ssl), ssl_ca_cert=ssl_ca_cert, cert_file=cert_file, cert_key_file=cert_key_file, cert_key_password=cert_key_password, - connection_pool_maxsize=_to_int(connection_pool_maxsize), auth_basic=_to_bool(auth_basic), - profilers=profilers, **kwargs) + connection_pool_maxsize=_to_int(connection_pool_maxsize), profilers=profilers, **kwargs) class _BaseWriteApi(object): @@ -276,8 +257,6 @@ class _Configuration(Configuration): def __init__(self): Configuration.__init__(self) self.enable_gzip = False - self.username = None - self.password = None def update_request_header_params(self, path: str, params: dict, should_gzip: bool = False): super().update_request_header_params(path, params, should_gzip) diff --git a/influxdb_client_3/write_client/client/influxdb_client.py b/influxdb_client_3/write_client/client/influxdb_client.py index 182c0a02..3ea97f60 100644 --- a/influxdb_client_3/write_client/client/influxdb_client.py +++ b/influxdb_client_3/write_client/client/influxdb_client.py @@ -45,11 +45,6 @@ def __init__(self, url, token: str = None, debug=None, timeout=10_000, enable_gz Defaults to "multiprocessing.cpu_count() * 5". :key urllib3.util.retry.Retry retries: Set the default retry strategy that is used for all HTTP requests except batching writes. As a default there is no one retry strategy. - :key bool auth_basic: Set this to true to enable basic authentication when talking to a InfluxDB 1.8.x that - does not use auth-enabled but is protected by a reverse proxy with basic authentication. - (defaults to false, don't set to true when talking to InfluxDB 2) - :key str username: ``username`` to authenticate via username and password credentials to the InfluxDB 2.x - :key str password: ``password`` to authenticate via username and password credentials to the InfluxDB 2.x :key list[str] profilers: list of enabled Flux profilers """ super().__init__(url=url, token=token, debug=debug, timeout=timeout, enable_gzip=enable_gzip, @@ -109,7 +104,6 @@ def from_config_file(cls, config_file: str = "config.ini", debug=None, enable_gz - cert_key_file - cert_key_password - connection_pool_maxsize - - auth_basic - profilers - proxy @@ -122,7 +116,6 @@ def from_config_file(cls, config_file: str = "config.ini", debug=None, enable_gz token=my-token timeout=6000 connection_pool_maxsize=25 - auth_basic=false profilers=query,operator proxy=http:proxy.domain.org:8080 @@ -139,7 +132,6 @@ def from_config_file(cls, config_file: str = "config.ini", debug=None, enable_gz org = "my-org" timeout = 6000 connection_pool_maxsize = 25 - auth_basic = false profilers="query, operator" proxy = "http://proxy.domain.org:8080" @@ -157,7 +149,6 @@ def from_config_file(cls, config_file: str = "config.ini", debug=None, enable_gz "active": true, "timeout": 6000, "connection_pool_maxsize": 55, - "auth_basic": false, "profilers": "query, operator", "tags": { "id": "132-987-655", @@ -198,7 +189,6 @@ def from_env_properties(cls, debug=None, enable_gzip=False, **kwargs): - INFLUXDB_V2_CERT_KEY_FILE - INFLUXDB_V2_CERT_KEY_PASSWORD - INFLUXDB_V2_CONNECTION_POOL_MAXSIZE - - INFLUXDB_V2_AUTH_BASIC - INFLUXDB_V2_PROFILERS - INFLUXDB_V2_TAG """ diff --git a/influxdb_client_3/write_client/client/write/__init__.py b/influxdb_client_3/write_client/client/write/__init__.py index 7809220a..5b960961 100644 --- a/influxdb_client_3/write_client/client/write/__init__.py +++ b/influxdb_client_3/write_client/client/write/__init__.py @@ -3,6 +3,4 @@ from __future__ import absolute_import # import apis into api package -from influxdb_client_3.write_client.service.signin_service import SigninService -from influxdb_client_3.write_client.service.signout_service import SignoutService from influxdb_client_3.write_client.service.write_service import WriteService diff --git a/influxdb_client_3/write_client/configuration.py b/influxdb_client_3/write_client/configuration.py index 29461565..d52e9a34 100644 --- a/influxdb_client_3/write_client/configuration.py +++ b/influxdb_client_3/write_client/configuration.py @@ -7,8 +7,6 @@ import multiprocessing import sys -import urllib3 - class TypeWithDefault(type): @@ -42,10 +40,6 @@ def __init__(self): self.api_key = {} # dict to store API prefix (e.g. Bearer) self.api_key_prefix = {} - # Username for HTTP basic authentication - self.username = "" - # Password for HTTP basic authentication - self.password = "" # Logging Settings self.loggers = {} @@ -88,9 +82,6 @@ def __init__(self): # It can also be a pair (tuple) of (connection, read) timeouts. self.timeout = None - # Set to True/False to enable basic authentication when using proxied InfluxDB 1.8.x with no auth-enabled - self.auth_basic = False - # Proxy URL self.proxy = None # A dictionary containing headers that will be sent to the proxy @@ -204,28 +195,12 @@ def get_api_key_with_prefix(self, identifier): elif self.api_key.get(identifier): return self.api_key[identifier] - def get_basic_auth_token(self): - """Get HTTP basic authentication header (string). - - :return: The token for basic HTTP authentication. - """ - return urllib3.util.make_headers( - basic_auth=self.username + ':' + self.password - ).get('authorization') - def auth_settings(self): """Get Auth Settings dict for api client. :return: The Auth Settings information dict. """ return { - 'BasicAuthentication': - { - 'type': 'basic', - 'in': 'header', - 'key': 'Authorization', - 'value': self.get_basic_auth_token() - }, 'TokenAuthentication': { 'type': 'api_key', diff --git a/influxdb_client_3/write_client/rest.py b/influxdb_client_3/write_client/rest.py index 0c34c985..125af3e4 100644 --- a/influxdb_client_3/write_client/rest.py +++ b/influxdb_client_3/write_client/rest.py @@ -6,7 +6,6 @@ from typing import Dict from influxdb_client_3.exceptions import InfluxDBError -from influxdb_client_3.write_client.configuration import Configuration _UTF_8_encoding = 'utf-8' @@ -63,12 +62,3 @@ def log_headers(headers: Dict[str, str], prefix: str): if 'authorization' == key.lower(): value = '***' _BaseRESTClient.logger.debug(f"{prefix} {key}: {value}") - - -def _requires_create_user_session(configuration: Configuration, cookie: str, resource_path: str): - _unauthorized = ['/api/v2/signin', '/api/v2/signout'] - return configuration.username and configuration.password and not cookie and resource_path not in _unauthorized - - -def _requires_expire_user_session(configuration: Configuration, cookie: str): - return configuration.username and configuration.password and cookie diff --git a/influxdb_client_3/write_client/service/__init__.py b/influxdb_client_3/write_client/service/__init__.py index 9bd5f0ce..805c6d98 100644 --- a/influxdb_client_3/write_client/service/__init__.py +++ b/influxdb_client_3/write_client/service/__init__.py @@ -3,6 +3,4 @@ from __future__ import absolute_import # import apis into api package -from influxdb_client_3.write_client.service.write_service import WriteService -from influxdb_client_3.write_client.service.signin_service import SigninService -from influxdb_client_3.write_client.service.signout_service import SignoutService \ No newline at end of file +from influxdb_client_3.write_client.service.write_service import WriteService \ No newline at end of file diff --git a/influxdb_client_3/write_client/service/signin_service.py b/influxdb_client_3/write_client/service/signin_service.py deleted file mode 100644 index a1b7eb51..00000000 --- a/influxdb_client_3/write_client/service/signin_service.py +++ /dev/null @@ -1,129 +0,0 @@ -# coding: utf-8 - -from __future__ import absolute_import - -import re # noqa: F401 - -from influxdb_client_3.write_client.service._base_service import _BaseService - - -class SigninService(_BaseService): - - def __init__(self, api_client=None): # noqa: E501,D401,D403 - """SigninService - a operation defined in OpenAPI.""" - super().__init__(api_client) - - def post_signin(self, **kwargs): # noqa: E501,D401,D403 - """Create a user session.. - - Authenticates [Basic authentication credentials](#section/Authentication/BasicAuthentication) for a [user](https://docs.influxdata.com/influxdb/latest/reference/glossary/#user), and then, if successful, generates a user session. To authenticate a user, pass the HTTP `Authorization` header with the `Basic` scheme and the base64-encoded username and password. For syntax and more information, see [Basic Authentication](#section/Authentication/BasicAuthentication) for syntax and more information. If authentication is successful, InfluxDB creates a new session for the user and then returns the session cookie in the `Set-Cookie` response header. InfluxDB stores user sessions in memory only. They expire within ten minutes and during restarts of the InfluxDB instance. #### User sessions with authorizations - In InfluxDB Cloud, a user session inherits all the user's permissions for the organization. - In InfluxDB OSS, a user session inherits all the user's permissions for all the organizations that the user belongs to. #### Related endpoints - [Signout](#tag/Signout) - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.post_signin(async_req=True) - >>> result = thread.get() - - :param async_req bool - :param str zap_trace_span: OpenTracing span context - :param str authorization: An auth credential for the Basic scheme - :return: None - If the method is called asynchronously, - returns the request thread. - """ # noqa: E501 - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.post_signin_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.post_signin_with_http_info(**kwargs) # noqa: E501 - return data - - def post_signin_with_http_info(self, **kwargs): # noqa: E501,D401,D403 - """Create a user session.. - - Authenticates [Basic authentication credentials](#section/Authentication/BasicAuthentication) for a [user](https://docs.influxdata.com/influxdb/latest/reference/glossary/#user), and then, if successful, generates a user session. To authenticate a user, pass the HTTP `Authorization` header with the `Basic` scheme and the base64-encoded username and password. For syntax and more information, see [Basic Authentication](#section/Authentication/BasicAuthentication) for syntax and more information. If authentication is successful, InfluxDB creates a new session for the user and then returns the session cookie in the `Set-Cookie` response header. InfluxDB stores user sessions in memory only. They expire within ten minutes and during restarts of the InfluxDB instance. #### User sessions with authorizations - In InfluxDB Cloud, a user session inherits all the user's permissions for the organization. - In InfluxDB OSS, a user session inherits all the user's permissions for all the organizations that the user belongs to. #### Related endpoints - [Signout](#tag/Signout) - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.post_signin_with_http_info(async_req=True) - >>> result = thread.get() - - :param async_req bool - :param str zap_trace_span: OpenTracing span context - :param str authorization: An auth credential for the Basic scheme - :return: None - If the method is called asynchronously, - returns the request thread. - """ # noqa: E501 - local_var_params, path_params, query_params, header_params, body_params = \ - self._post_signin_prepare(**kwargs) # noqa: E501 - - return self.api_client.call_api( - '/api/v2/signin', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=[], - files={}, - response_type=None, # noqa: E501 - auth_settings=['BasicAuthentication'], - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats={}, - urlopen_kw=kwargs.get('urlopen_kw', None)) - - async def post_signin_async(self, **kwargs): # noqa: E501,D401,D403 - """Create a user session.. - - Authenticates [Basic authentication credentials](#section/Authentication/BasicAuthentication) for a [user](https://docs.influxdata.com/influxdb/latest/reference/glossary/#user), and then, if successful, generates a user session. To authenticate a user, pass the HTTP `Authorization` header with the `Basic` scheme and the base64-encoded username and password. For syntax and more information, see [Basic Authentication](#section/Authentication/BasicAuthentication) for syntax and more information. If authentication is successful, InfluxDB creates a new session for the user and then returns the session cookie in the `Set-Cookie` response header. InfluxDB stores user sessions in memory only. They expire within ten minutes and during restarts of the InfluxDB instance. #### User sessions with authorizations - In InfluxDB Cloud, a user session inherits all the user's permissions for the organization. - In InfluxDB OSS, a user session inherits all the user's permissions for all the organizations that the user belongs to. #### Related endpoints - [Signout](#tag/Signout) - This method makes an asynchronous HTTP request. - - :param async_req bool - :param str zap_trace_span: OpenTracing span context - :param str authorization: An auth credential for the Basic scheme - :return: None - If the method is called asynchronously, - returns the request thread. - """ # noqa: E501 - local_var_params, path_params, query_params, header_params, body_params = \ - self._post_signin_prepare(**kwargs) # noqa: E501 - - return await self.api_client.call_api( - '/api/v2/signin', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=[], - files={}, - response_type=None, # noqa: E501 - auth_settings=['BasicAuthentication'], - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats={}, - urlopen_kw=kwargs.get('urlopen_kw', None)) - - def _post_signin_prepare(self, **kwargs): # noqa: E501,D401,D403 - local_var_params = dict(locals()) - - all_params = ['zap_trace_span', 'authorization'] # noqa: E501 - self._check_operation_params('post_signin', all_params, local_var_params) - - path_params = {} - - query_params = [] - - header_params = {} - if 'zap_trace_span' in local_var_params: - header_params['Zap-Trace-Span'] = local_var_params['zap_trace_span'] # noqa: E501 - if 'authorization' in local_var_params: - header_params['Authorization'] = local_var_params['authorization'] # noqa: E501 - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - return local_var_params, path_params, query_params, header_params, body_params diff --git a/influxdb_client_3/write_client/service/signout_service.py b/influxdb_client_3/write_client/service/signout_service.py deleted file mode 100644 index 24d8a314..00000000 --- a/influxdb_client_3/write_client/service/signout_service.py +++ /dev/null @@ -1,124 +0,0 @@ -# coding: utf-8 - -from __future__ import absolute_import - -import re # noqa: F401 - -from influxdb_client_3.write_client.service._base_service import _BaseService - - -class SignoutService(_BaseService): - - def __init__(self, api_client=None): # noqa: E501,D401,D403 - """SignoutService - a operation defined in OpenAPI.""" - super().__init__(api_client) - - def post_signout(self, **kwargs): # noqa: E501,D401,D403 - """Expire a user session. - - Expires a user session specified by a session cookie. Use this endpoint to expire a user session that was generated when the user authenticated with the InfluxDB Developer Console (UI) or the `POST /api/v2/signin` endpoint. For example, the `POST /api/v2/signout` endpoint represents the third step in the following three-step process to authenticate a user, retrieve the `user` resource, and then expire the session: 1. Send a request with the user's [Basic authentication credentials](#section/Authentication/BasicAuthentication) to the `POST /api/v2/signin` endpoint to create a user session and generate a session cookie. 2. Send a request to the `GET /api/v2/me` endpoint, passing the stored session cookie from step 1 to retrieve user information. 3. Send a request to the `POST /api/v2/signout` endpoint, passing the stored session cookie to expire the session. _See the complete example in request samples._ InfluxDB stores user sessions in memory only. If a user doesn't sign out, then the user session automatically expires within ten minutes or during a restart of the InfluxDB instance. To learn more about cookies in HTTP requests, see [Mozilla Developer Network (MDN) Web Docs, HTTP cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies). #### Related endpoints - [Signin](#tag/Signin) - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.post_signout(async_req=True) - >>> result = thread.get() - - :param async_req bool - :param str zap_trace_span: OpenTracing span context - :return: None - If the method is called asynchronously, - returns the request thread. - """ # noqa: E501 - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.post_signout_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.post_signout_with_http_info(**kwargs) # noqa: E501 - return data - - def post_signout_with_http_info(self, **kwargs): # noqa: E501,D401,D403 - """Expire a user session. - - Expires a user session specified by a session cookie. Use this endpoint to expire a user session that was generated when the user authenticated with the InfluxDB Developer Console (UI) or the `POST /api/v2/signin` endpoint. For example, the `POST /api/v2/signout` endpoint represents the third step in the following three-step process to authenticate a user, retrieve the `user` resource, and then expire the session: 1. Send a request with the user's [Basic authentication credentials](#section/Authentication/BasicAuthentication) to the `POST /api/v2/signin` endpoint to create a user session and generate a session cookie. 2. Send a request to the `GET /api/v2/me` endpoint, passing the stored session cookie from step 1 to retrieve user information. 3. Send a request to the `POST /api/v2/signout` endpoint, passing the stored session cookie to expire the session. _See the complete example in request samples._ InfluxDB stores user sessions in memory only. If a user doesn't sign out, then the user session automatically expires within ten minutes or during a restart of the InfluxDB instance. To learn more about cookies in HTTP requests, see [Mozilla Developer Network (MDN) Web Docs, HTTP cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies). #### Related endpoints - [Signin](#tag/Signin) - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.post_signout_with_http_info(async_req=True) - >>> result = thread.get() - - :param async_req bool - :param str zap_trace_span: OpenTracing span context - :return: None - If the method is called asynchronously, - returns the request thread. - """ # noqa: E501 - local_var_params, path_params, query_params, header_params, body_params = \ - self._post_signout_prepare(**kwargs) # noqa: E501 - - return self.api_client.call_api( - '/api/v2/signout', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=[], - files={}, - response_type=None, # noqa: E501 - auth_settings=[], - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats={}, - urlopen_kw=kwargs.get('urlopen_kw', None)) - - async def post_signout_async(self, **kwargs): # noqa: E501,D401,D403 - """Expire a user session. - - Expires a user session specified by a session cookie. Use this endpoint to expire a user session that was generated when the user authenticated with the InfluxDB Developer Console (UI) or the `POST /api/v2/signin` endpoint. For example, the `POST /api/v2/signout` endpoint represents the third step in the following three-step process to authenticate a user, retrieve the `user` resource, and then expire the session: 1. Send a request with the user's [Basic authentication credentials](#section/Authentication/BasicAuthentication) to the `POST /api/v2/signin` endpoint to create a user session and generate a session cookie. 2. Send a request to the `GET /api/v2/me` endpoint, passing the stored session cookie from step 1 to retrieve user information. 3. Send a request to the `POST /api/v2/signout` endpoint, passing the stored session cookie to expire the session. _See the complete example in request samples._ InfluxDB stores user sessions in memory only. If a user doesn't sign out, then the user session automatically expires within ten minutes or during a restart of the InfluxDB instance. To learn more about cookies in HTTP requests, see [Mozilla Developer Network (MDN) Web Docs, HTTP cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies). #### Related endpoints - [Signin](#tag/Signin) - This method makes an asynchronous HTTP request. - - :param async_req bool - :param str zap_trace_span: OpenTracing span context - :return: None - If the method is called asynchronously, - returns the request thread. - """ # noqa: E501 - local_var_params, path_params, query_params, header_params, body_params = \ - self._post_signout_prepare(**kwargs) # noqa: E501 - - return await self.api_client.call_api( - '/api/v2/signout', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=[], - files={}, - response_type=None, # noqa: E501 - auth_settings=[], - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats={}, - urlopen_kw=kwargs.get('urlopen_kw', None)) - - def _post_signout_prepare(self, **kwargs): # noqa: E501,D401,D403 - local_var_params = dict(locals()) - - all_params = ['zap_trace_span'] # noqa: E501 - self._check_operation_params('post_signout', all_params, local_var_params) - - path_params = {} - - query_params = [] - - header_params = {} - if 'zap_trace_span' in local_var_params: - header_params['Zap-Trace-Span'] = local_var_params['zap_trace_span'] # noqa: E501 - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - return local_var_params, path_params, query_params, header_params, body_params