Skip to content

Commit 2da45a2

Browse files
authored
feat: Add Min-Server-Version header support (#50)
1 parent 7b4885f commit 2da45a2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/codeocean/client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ class CodeOcean:
3333
retries: Optional[Retry | int] = 0
3434
agent_id: Optional[str] = None
3535

36+
# Minimum server version required by this SDK
37+
MIN_SERVER_VERSION = "3.6.0"
38+
3639
def __post_init__(self):
3740
self.session = BaseUrlSession(base_url=f"{self.domain}/api/v1/")
3841
self.session.auth = (self.token, "")
39-
self.session.headers.update({"Content-Type": "application/json"})
42+
self.session.headers.update({
43+
"Content-Type": "application/json",
44+
"Min-Server-Version": CodeOcean.MIN_SERVER_VERSION,
45+
})
4046
if self.agent_id:
4147
self.session.headers.update({"Agent-Id": self.agent_id})
4248
self.session.hooks["response"] = [

tests/test_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def test_basic_init(self):
3131
headers = client.session.headers
3232
self.assertIn("Content-Type", headers)
3333
self.assertEqual(headers["Content-Type"], "application/json")
34+
self.assertIn("Min-Server-Version", headers)
35+
self.assertEqual(headers["Min-Server-Version"], CodeOcean.MIN_SERVER_VERSION)
3436

3537
@patch("codeocean.client.TCPKeepAliveAdapter")
3638
def test_retry_configuration_types(self, mock_adapter):

0 commit comments

Comments
 (0)