Skip to content

Commit ddf1826

Browse files
committed
update
1 parent 363c7af commit ddf1826

File tree

2 files changed

+54
-6
lines changed

2 files changed

+54
-6
lines changed

src/confluent_kafka/schema_registry/_async/schema_registry_client.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,8 @@ async def test_compatibility(
12041204
self, subject_name: str, schema: 'Schema',
12051205
version: Union[int, str] = "latest"
12061206
) -> bool:
1207-
"""Test the compatibility of a candidate schema for a given subject and version
1207+
"""
1208+
Test the compatibility of a candidate schema for a given subject and version
12081209
12091210
Args:
12101211
subject_name (str): Subject name the schema is registered under
@@ -1222,13 +1223,36 @@ async def test_compatibility(
12221223
""" # noqa: E501
12231224

12241225
request = schema.to_dict()
1225-
12261226
response = await self._rest_client.post(
12271227
'compatibility/subjects/{}/versions/{}'.format(_urlencode(subject_name), version), body=request
12281228
)
1229-
12301229
return response['is_compatible']
12311230

1231+
async def test_compatibility_against_all(
1232+
self, subject_name: str, schema: 'Schema', normalize: bool = False, verbose: bool = False
1233+
) -> bool:
1234+
"""
1235+
Test the input schema against all of the subject's schemas for compatibility.
1236+
1237+
Args:
1238+
subject_name (str): Name of the schema against which compatibility is to be tested.
1239+
schema (Schema): Schema instance.
1240+
normalize (bool): Whether to normalize the input schema. # TODO: missing in cp + cc docs
1241+
verbose (bool): Wehther to return detailed error messages.
1242+
1243+
Returns:
1244+
bool: True if the schema is compatible with all of the subject's schemas.
1245+
See Also:
1246+
`POST Test Compatibility Against All API Reference <https://docs.confluent.io/platform/current/schema-registry/develop/api.html#post--compatibility-subjects-(string-%20subject)-versions>`_
1247+
"""
1248+
request = schema.to_dict()
1249+
response = await self._rest_client.post(
1250+
'compatibility/subjects/{}/versions'.format(_urlencode(subject_name)),
1251+
query={'normalize': normalize, 'verbose': verbose},
1252+
body=request,
1253+
)
1254+
return response['is_compatible'] # TODO: should it return entire response
1255+
12321256
async def set_config(
12331257
self, subject_name: Optional[str] = None,
12341258
config: Optional['ServerConfig'] = None

src/confluent_kafka/schema_registry/_sync/schema_registry_client.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,8 @@ def test_compatibility(
12041204
self, subject_name: str, schema: 'Schema',
12051205
version: Union[int, str] = "latest"
12061206
) -> bool:
1207-
"""Test the compatibility of a candidate schema for a given subject and version
1207+
"""
1208+
Test the compatibility of a candidate schema for a given subject and version
12081209
12091210
Args:
12101211
subject_name (str): Subject name the schema is registered under
@@ -1222,13 +1223,36 @@ def test_compatibility(
12221223
""" # noqa: E501
12231224

12241225
request = schema.to_dict()
1225-
12261226
response = self._rest_client.post(
12271227
'compatibility/subjects/{}/versions/{}'.format(_urlencode(subject_name), version), body=request
12281228
)
1229-
12301229
return response['is_compatible']
12311230

1231+
def test_compatibility_against_all(
1232+
self, subject_name: str, schema: 'Schema', normalize: bool = False, verbose: bool = False
1233+
) -> bool:
1234+
"""
1235+
Test the input schema against all of the subject's schemas for compatibility.
1236+
1237+
Args:
1238+
subject_name (str): Name of the schema against which compatibility is to be tested.
1239+
schema (Schema): Schema instance.
1240+
normalize (bool): Whether to normalize the input schema. # TODO: missing in cp + cc docs
1241+
verbose (bool): Wehther to return detailed error messages.
1242+
1243+
Returns:
1244+
bool: True if the schema is compatible with all of the subject's schemas.
1245+
See Also:
1246+
`POST Test Compatibility Against All API Reference <https://docs.confluent.io/platform/current/schema-registry/develop/api.html#post--compatibility-subjects-(string-%20subject)-versions>`_
1247+
"""
1248+
request = schema.to_dict()
1249+
response = self._rest_client.post(
1250+
'compatibility/subjects/{}/versions'.format(_urlencode(subject_name)),
1251+
query={'normalize': normalize, 'verbose': verbose},
1252+
body=request,
1253+
)
1254+
return response['is_compatible'] # TODO: should it return entire response
1255+
12321256
def set_config(
12331257
self, subject_name: Optional[str] = None,
12341258
config: Optional['ServerConfig'] = None

0 commit comments

Comments
 (0)