Skip to content

Commit 9415b6d

Browse files
committed
update
1 parent b30765e commit 9415b6d

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/confluent_kafka/schema_registry/_async/schema_registry_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from cachetools import Cache, LRUCache, TTLCache
3232
from httpx import Response
3333

34+
from confluent_kafka import version
3435
from confluent_kafka.schema_registry.common.schema_registry_client import (
3536
RegisteredSchema,
3637
Schema,
@@ -479,6 +480,7 @@ async def send_request(
479480
'Content-Length': str(len(body_str)),
480481
'Content-Type': "application/vnd.schemaregistry.v1+json",
481482
'Confluent-Accept-Unknown-Properties': "true",
483+
'Confluent-Client-Version': f"python/{version()}"
482484
}
483485

484486
if self.bearer_auth_credentials_source:

src/confluent_kafka/schema_registry/_sync/schema_registry_client.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
from cachetools import Cache, LRUCache, TTLCache
3232
from httpx import Response
3333

34+
from confluent_kafka import version
3435
from confluent_kafka.schema_registry.common.schema_registry_client import (
3536
RegisteredSchema,
3637
Schema,
3738
SchemaVersion,
3839
ServerConfig,
3940
_BearerFieldProvider,
40-
_SchemaCache,
4141
_StaticFieldProvider,
42+
_SchemaCache,
4243
full_jitter,
4344
is_retriable,
4445
is_success,
@@ -441,7 +442,9 @@ def delete(self, url: str) -> Any:
441442
def put(self, url: str, body: Optional[dict] = None) -> Any:
442443
return self.send_request(url, method='PUT', body=body)
443444

444-
def send_request(self, url: str, method: str, body: Optional[dict] = None, query: Optional[dict] = None) -> Any:
445+
def send_request(
446+
self, url: str, method: str, body: Optional[dict] = None, query: Optional[dict] = None
447+
) -> Any:
445448
"""
446449
Sends HTTP request to the SchemaRegistry, trying each base URL in turn.
447450
@@ -477,6 +480,7 @@ def send_request(self, url: str, method: str, body: Optional[dict] = None, query
477480
'Content-Length': str(len(body_str)),
478481
'Content-Type': "application/vnd.schemaregistry.v1+json",
479482
'Confluent-Accept-Unknown-Properties': "true",
483+
'Confluent-Client-Version': f"python/{version()}"
480484
}
481485

482486
if self.bearer_auth_credentials_source:
@@ -942,7 +946,9 @@ def lookup_schema(
942946

943947
query_string = '&'.join(f"{key}={value}" for key, value in query_params.items())
944948

945-
response = self._rest_client.post('subjects/{}?{}'.format(_urlencode(subject_name), query_string), body=request)
949+
response = self._rest_client.post(
950+
'subjects/{}?{}'.format(_urlencode(subject_name), query_string), body=request
951+
)
946952

947953
result = RegisteredSchema.from_dict(response)
948954

@@ -1043,7 +1049,9 @@ def get_latest_version(self, subject_name: str, fmt: Optional[str] = None) -> 'R
10431049
return registered_schema
10441050

10451051
query = {'format': fmt} if fmt is not None else None
1046-
response = self._rest_client.get('subjects/{}/versions/{}'.format(_urlencode(subject_name), 'latest'), query)
1052+
response = self._rest_client.get(
1053+
'subjects/{}/versions/{}'.format(_urlencode(subject_name), 'latest'), query
1054+
)
10471055

10481056
registered_schema = RegisteredSchema.from_dict(response)
10491057

@@ -1123,7 +1131,9 @@ def get_version(
11231131
return registered_schema
11241132

11251133
query: dict[str, Any] = {'deleted': deleted, 'format': fmt} if fmt is not None else {'deleted': deleted}
1126-
response = self._rest_client.get('subjects/{}/versions/{}'.format(_urlencode(subject_name), version), query)
1134+
response = self._rest_client.get(
1135+
'subjects/{}/versions/{}'.format(_urlencode(subject_name), version), query
1136+
)
11271137

11281138
registered_schema = RegisteredSchema.from_dict(response)
11291139

@@ -1210,7 +1220,9 @@ def delete_version(self, subject_name: str, version: int, permanent: bool = Fals
12101220
'subjects/{}/versions/{}?permanent=true'.format(_urlencode(subject_name), version)
12111221
)
12121222
else:
1213-
response = self._rest_client.delete('subjects/{}/versions/{}'.format(_urlencode(subject_name), version))
1223+
response = self._rest_client.delete(
1224+
'subjects/{}/versions/{}'.format(_urlencode(subject_name), version)
1225+
)
12141226

12151227
# Clear cache for both soft and hard deletes to maintain consistency
12161228
self._cache.remove_by_subject_version(subject_name, version)
@@ -1338,7 +1350,9 @@ def test_compatibility_all_versions(
13381350
)
13391351
return response['is_compatible']
13401352

1341-
def set_config(self, subject_name: Optional[str] = None, config: Optional['ServerConfig'] = None) -> 'ServerConfig':
1353+
def set_config(
1354+
self, subject_name: Optional[str] = None, config: Optional['ServerConfig'] = None
1355+
) -> 'ServerConfig':
13421356
"""
13431357
Update global or subject config.
13441358

0 commit comments

Comments
 (0)