Skip to content

Commit dbf8e9e

Browse files
author
Max Wang
committed
add versioning
1 parent de6539c commit dbf8e9e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/dataverse_sdk/odata.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
from .errors import *
1818
from . import error_codes as ec
1919

20+
from .__version__ import __version__ as _SDK_VERSION
2021

22+
23+
_USER_AGENT = f"DataversePythonSDK/{_SDK_VERSION}"
2124
_GUID_RE = re.compile(r"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}")
2225

2326

@@ -58,14 +61,13 @@ def _headers(self) -> Dict[str, str]:
5861
"""Build standard OData headers with bearer auth."""
5962
scope = f"{self.base_url}/.default"
6063
token = self.auth.acquire_token(scope).access_token
61-
# TODO: add version to User-Agent
6264
return {
6365
"Authorization": f"Bearer {token}",
6466
"Accept": "application/json",
6567
"Content-Type": "application/json",
6668
"OData-MaxVersion": "4.0",
6769
"OData-Version": "4.0",
68-
"User-Agent": "DataversePythonSDK",
70+
"User-Agent": _USER_AGENT,
6971
}
7072

7173
def _merge_headers(self, headers: Optional[Dict[str, str]] = None) -> Dict[str, str]:

0 commit comments

Comments
 (0)