Skip to content

Commit 1bca8e1

Browse files
Loschcodeclaude
andcommitted
feat: identify the SDK with Linkbreakers-Client and its own User-Agent
Every request now sends Linkbreakers-Client: sdk-python/<version> (python <x.y.z>; <linux|darwin|windows|other>) User-Agent: linkbreakers-python-sdk/<version> from a template override of api_client.mustache, so it survives regeneration. A header passed to ApiClient or set with set_default_header still wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 74bf365 commit 1bca8e1

2 files changed

Lines changed: 859 additions & 3 deletions

File tree

‎linkbreakers/api_client.py‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import json
2020
import mimetypes
2121
import os
22+
import platform
2223
import re
24+
import sys
2325
import tempfile
2426
import uuid
2527

@@ -73,6 +75,20 @@ class ApiClient:
7375
}
7476
_pool = None
7577

78+
# Linkbreakers: identifies this SDK to the API. Overridable with
79+
# set_default_header or header_name/header_value.
80+
@staticmethod
81+
def linkbreakers_client() -> str:
82+
if sys.platform.startswith('linux'):
83+
os_family = 'linux'
84+
elif sys.platform == 'darwin':
85+
os_family = 'darwin'
86+
elif sys.platform in ('win32', 'cygwin'):
87+
os_family = 'windows'
88+
else:
89+
os_family = 'other'
90+
return 'sdk-python/1.183.3 (python %s; %s)' % (platform.python_version(), os_family)
91+
7692
def __init__(
7793
self,
7894
configuration=None,
@@ -86,12 +102,13 @@ def __init__(
86102
self.configuration = configuration
87103

88104
self.rest_client = rest.RESTClientObject(configuration)
89-
self.default_headers = {}
105+
self.default_headers = {
106+
'User-Agent': 'linkbreakers-python-sdk/1.183.3',
107+
'Linkbreakers-Client': self.linkbreakers_client(),
108+
}
90109
if header_name is not None:
91110
self.default_headers[header_name] = header_value
92111
self.cookie = cookie
93-
# Set default User-Agent.
94-
self.user_agent = 'OpenAPI-Generator/1.183.3/python'
95112
self.client_side_validation = configuration.client_side_validation
96113

97114
def __enter__(self):

0 commit comments

Comments
 (0)