From 95a0b52aa114d5350eb6fada8cd9ea05734d0810 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Fri, 22 Sep 2023 10:56:29 -0500 Subject: [PATCH] Add user agent to requests --- setup.cfg | 2 +- singlestoredb/http/connection.py | 3 +++ singlestoredb/management/manager.py | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 6e11b29c..0820968b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name = singlestoredb version = 0.8.7 -description = Interface to the SingleStore database and cluster management APIs +description = Interface to the SingleStoreDB database and workspace management APIs long_description = file: README.md long_description_content_type = text/markdown url = https://github.com/singlestore-labs/singlestoredb-python diff --git a/singlestoredb/http/connection.py b/singlestoredb/http/connection.py index cd566355..c8030c57 100644 --- a/singlestoredb/http/connection.py +++ b/singlestoredb/http/connection.py @@ -853,6 +853,8 @@ class Connection(connection.Connection): paramstyle = 'qmark' def __init__(self, **kwargs: Any): + from .. import __version__ as client_version + connection.Connection.__init__(self, **kwargs) host = kwargs.get('host', get_option('host')) @@ -870,6 +872,7 @@ def __init__(self, **kwargs: Any): 'Content-Type': 'application/json', 'Accept': 'application/json', 'Accept-Encoding': 'compress,identity', + 'User-Agent': f'SingleStoreDB-Python/{client_version}', }) if kwargs.get('ssl_disabled', get_option('ssl_disabled')): diff --git a/singlestoredb/management/manager.py b/singlestoredb/management/manager.py index 2cf8241f..a30e9db1 100644 --- a/singlestoredb/management/manager.py +++ b/singlestoredb/management/manager.py @@ -30,6 +30,7 @@ def __init__( self, access_token: Optional[str] = None, version: Optional[str] = None, base_url: Optional[str] = None, ): + from .. import __version__ as client_version access_token = ( access_token or config.get_option('management.token') @@ -41,6 +42,7 @@ def __init__( 'Authorization': f'Bearer {access_token}', 'Content-Type': 'application/json', 'Accept': 'application/json', + 'User-Agent': f'SingleStoreDB-Python/{client_version}', }) self._base_url = urljoin( base_url or type(self).default_base_url,