Skip to content

Commit 128227a

Browse files
swathipiliscai-msft
authored andcommitted
[SchemaRegistry] renaming from archboard feedback (#20766)
addressing part of #20703
1 parent 0a8aabf commit 128227a

20 files changed

+195
-214
lines changed

sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
- `register_schema` and `get_schema_properties` methods on sync and async `SchemaRegistryClient` now take in the following parameters in the given order:
1212
- `group_name`, which has been renamed from `schema_group`
1313
- `name`, which has been renamed from `schema_name`
14-
- `content`, which has been renamed from `schema_content`
15-
- `serialization_type`
14+
- `schema_definition`, which has been renamed from `schema_content`
15+
- `format`, which has been renamed from `serialization_type`
16+
- `endpoint` parameter in `SchemaRegistryClient` constructor has been renamed `fully_qualified_namespace`
1617

1718
### Bugs Fixed
1819

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
__version__ = VERSION
2828

2929
from ._schema_registry_client import SchemaRegistryClient
30-
from ._common._constants import SerializationType
30+
from ._common._constants import SchemaFormat
3131
from ._common._schema import Schema, SchemaProperties
3232

3333
__all__ = [
3434
"SchemaRegistryClient",
35-
"SerializationType",
35+
"SchemaFormat",
3636
"Schema",
3737
"SchemaProperties"
3838
]

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
from enum import Enum
2727

2828

29-
class SerializationType(str, Enum):
29+
class SchemaFormat(str, Enum):
3030
AVRO = "avro"

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_response_handlers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828

2929
def _parse_schema_properties_dict(response):
3030
return {
31-
'location': response.headers.get('location'),
3231
'id': response.headers.get('schema-id'),
33-
'serialization_type': response.headers.get('serialization-type'),
32+
'format': response.headers.get('serialization-type'),
3433
'version': int(response.headers.get('schema-version'))
3534
}
3635

@@ -45,6 +44,6 @@ def _parse_response_schema_properties(response):
4544

4645
def _parse_response_schema(response):
4746
return Schema(
48-
content=response.text(),
47+
schema_definition=response.text(),
4948
properties=SchemaProperties(**_parse_schema_properties_dict(response))
5049
)

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_schema.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ class SchemaProperties(object):
3232
3333
:ivar id: References specific schema in registry namespace.
3434
:type id: str
35-
:ivar location: URL location of schema, identified by schema group, schema name, and version.
36-
:type location: str
37-
:ivar serialization_type: Serialization type for the schema being stored.
38-
:type serialization_type: str
35+
:ivar format: Format for the schema being stored.
36+
:type format: str
3937
:ivar version: Version of the returned schema.
4038
:type version: int
4139
@@ -57,17 +55,16 @@ def __init__(
5755
):
5856
# type: (Optional[str], Any) -> None
5957
self.id = id
60-
self.location = kwargs.get('location')
61-
self.serialization_type = kwargs.get('serialization_type')
58+
self.format = kwargs.get('format')
6259
self.version = kwargs.get('version')
6360

6461

6562
class Schema(object):
6663
"""
6764
The schema content of a schema, along with id and meta properties.
6865
69-
:ivar content: The content of the schema.
70-
:type content: str
66+
:ivar schema_definition: The content of the schema.
67+
:type schema_definition: str
7168
:ivar properties: The properties of the schema.
7269
:type properties: SchemaProperties
7370
@@ -84,9 +81,9 @@ class Schema(object):
8481

8582
def __init__(
8683
self,
87-
content,
84+
schema_definition,
8885
properties,
8986
):
9087
# type: (str, SchemaProperties) -> None
91-
self.content = content
88+
self.schema_definition = schema_definition
9289
self.properties = properties

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_schema_registry_client.py

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# --------------------------------------------------------------------------
2626
from typing import Any, TYPE_CHECKING, Union
2727

28-
from ._common._constants import SerializationType
28+
from ._common._constants import SchemaFormat
2929
from ._common._schema import Schema, SchemaProperties
3030
from ._common._response_handlers import (
3131
_parse_response_schema,
@@ -44,7 +44,8 @@ class SchemaRegistryClient(object):
4444
SchemaRegistryClient is as a central schema repository for enterprise-level data infrastructure,
4545
complete with support for versioning and management.
4646
47-
:param str endpoint: The Schema Registry service endpoint, for example my-namespace.servicebus.windows.net.
47+
:param str fully_qualified_namespace: The Schema Registry service fully qualified host name,
48+
for example my-namespace.servicebus.windows.net.
4849
:param credential: To authenticate to manage the entities of the SchemaRegistry namespace.
4950
:type credential: TokenCredential
5051
@@ -59,10 +60,10 @@ class SchemaRegistryClient(object):
5960
6061
"""
6162

62-
def __init__(self, endpoint, credential, **kwargs):
63+
def __init__(self, fully_qualified_namespace, credential, **kwargs):
6364
# type: (str, TokenCredential, Any) -> None
6465
self._generated_client = AzureSchemaRegistry(
65-
credential=credential, endpoint=endpoint, **kwargs
66+
credential=credential, endpoint=fully_qualified_namespace, **kwargs
6667
)
6768

6869
def __enter__(self):
@@ -82,22 +83,20 @@ def close(self):
8283
self._generated_client.close()
8384

8485
def register_schema(
85-
self, group_name, name, content, serialization_type, **kwargs
86+
self, group_name, name, schema_definition, format, **kwargs # pylint:disable=redefined-builtin
8687
):
87-
# type: (str, str, str, Union[str, SerializationType], Any) -> SchemaProperties
88+
# type: (str, str, str, Union[str, SchemaFormat], Any) -> SchemaProperties
8889
"""
8990
Register new schema. If schema of specified name does not exist in specified group,
9091
schema is created at version 1. If schema of specified name exists already in specified group,
9192
schema is created at latest version + 1.
9293
9394
:param str group_name: Schema group under which schema should be registered.
9495
:param str name: Name of schema being registered.
95-
:param str content: String representation of the schema being registered.
96-
:param serialization_type: Serialization type for the schema being registered.
97-
For now Avro is the only supported serialization type by the service.
98-
:type serialization_type: Union[str, SerializationType]
99-
:keyword content_type: The content type of the request. Default value is 'application/json'.
100-
:paramtype content_type: str
96+
:param str schema_definition: String representation of the schema being registered.
97+
:param format: Format for the schema being registered.
98+
For now Avro is the only supported schema format by the service.
99+
:type format: Union[str, SchemaFormat]
101100
:rtype: SchemaProperties
102101
103102
.. admonition:: Example:
@@ -111,15 +110,15 @@ def register_schema(
111110
112111
"""
113112
try:
114-
serialization_type = serialization_type.value
113+
format = format.value
115114
except AttributeError:
116115
pass
117116

118117
request = schema_rest.build_register_request(
119118
group_name=group_name,
120119
schema_name=name,
121-
content=content,
122-
serialization_type=serialization_type,
120+
content=schema_definition,
121+
serialization_type=format,
123122
content_type=kwargs.pop("content_type", "application/json"),
124123
**kwargs
125124
)
@@ -153,20 +152,18 @@ def get_schema(self, id, **kwargs): # pylint:disable=redefined-builtin
153152
return _parse_response_schema(response)
154153

155154
def get_schema_properties(
156-
self, group_name, name, content, serialization_type, **kwargs
155+
self, group_name, name, schema_definition, format, **kwargs # pylint:disable=redefined-builtin
157156
):
158-
# type: (str, str, str, Union[str, SerializationType], Any) -> SchemaProperties
157+
# type: (str, str, str, Union[str, SchemaFormat], Any) -> SchemaProperties
159158
"""
160159
Gets the ID referencing an existing schema within the specified schema group,
161-
as matched by schema content comparison.
160+
as matched by schema definition comparison.
162161
163162
:param str group_name: Schema group under which schema should be registered.
164163
:param str name: Name of schema being registered.
165-
:param str content: String representation of the schema being registered.
166-
:param serialization_type: Serialization type for the schema being registered.
167-
:type serialization_type: Union[str, SerializationType]
168-
:keyword content_type: The content type of the request. Default value is 'application/json'.
169-
:paramtype content_type: str
164+
:param str schema_definition: String representation of the schema being registered.
165+
:param format: Format for the schema being registered.
166+
:type format: Union[str, SchemaFormat]
170167
:rtype: SchemaProperties
171168
172169
.. admonition:: Example:
@@ -180,15 +177,15 @@ def get_schema_properties(
180177
181178
"""
182179
try:
183-
serialization_type = serialization_type.value
180+
format = format.value
184181
except AttributeError:
185182
pass
186183

187184
request = schema_rest.build_query_id_by_content_request(
188185
group_name=group_name,
189186
schema_name=name,
190-
content=content,
191-
serialization_type=serialization_type,
187+
content=schema_definition,
188+
serialization_type=format,
192189
content_type=kwargs.pop("content_type", "application/json"),
193190
**kwargs
194191
)

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/aio/_schema_registry_client_async.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# --------------------------------------------------------------------------
2626
from typing import Any, TYPE_CHECKING, Union
2727

28-
from .._common._constants import SerializationType
28+
from .._common._constants import SchemaFormat
2929
from .._common._schema import Schema, SchemaProperties
3030
from .._common._response_handlers import (
3131
_parse_response_schema,
@@ -44,7 +44,8 @@ class SchemaRegistryClient(object):
4444
SchemaRegistryClient is as a central schema repository for enterprise-level data infrastructure,
4545
complete with support for versioning and management.
4646
47-
:param str endpoint: The Schema Registry service endpoint, for example my-namespace.servicebus.windows.net.
47+
:param str fully_qualified_namespace: The Schema Registry service fully qualified host name,
48+
for example my-namespace.servicebus.windows.net.
4849
:param credential: To authenticate to manage the entities of the SchemaRegistry namespace.
4950
:type credential: AsyncTokenCredential
5051
@@ -60,11 +61,11 @@ class SchemaRegistryClient(object):
6061
"""
6162
def __init__(
6263
self,
63-
endpoint: str,
64+
fully_qualified_namespace: str,
6465
credential: "AsyncTokenCredential",
6566
**kwargs: Any
6667
) -> None:
67-
self._generated_client = AzureSchemaRegistry(credential, endpoint, **kwargs)
68+
self._generated_client = AzureSchemaRegistry(credential, fully_qualified_namespace, **kwargs)
6869

6970
async def __aenter__(self):
7071
await self._generated_client.__aenter__()
@@ -83,8 +84,8 @@ async def register_schema(
8384
self,
8485
group_name: str,
8586
name: str,
86-
content: str,
87-
serialization_type: Union[str, SerializationType],
87+
schema_definition: str,
88+
format: Union[str, SchemaFormat], # pylint:disable=redefined-builtin
8889
**kwargs: Any
8990
) -> SchemaProperties:
9091
"""
@@ -94,10 +95,10 @@ async def register_schema(
9495
9596
:param str group_name: Schema group under which schema should be registered.
9697
:param str name: Name of schema being registered.
97-
:param str content: String representation of the schema being registered.
98-
:param serialization_type: Serialization type for the schema being registered.
99-
For now Avro is the only supported serialization type by the service.
100-
:type serialization_type: Union[str, SerializationType]
98+
:param str schema_definition: String representation of the schema being registered.
99+
:param format: Format for the schema being registered.
100+
For now Avro is the only supported schema format by the service.
101+
:type format: Union[str, SchemaFormat]
101102
:rtype: SchemaProperties
102103
103104
.. admonition:: Example:
@@ -111,15 +112,15 @@ async def register_schema(
111112
112113
"""
113114
try:
114-
serialization_type = serialization_type.value
115+
format = format.value
115116
except AttributeError:
116117
pass
117118

118119
request = schema_rest.build_register_request(
119120
group_name=group_name,
120121
schema_name=name,
121-
content=content,
122-
serialization_type=serialization_type,
122+
content=schema_definition,
123+
serialization_type=format,
123124
content_type=kwargs.pop("content_type", "application/json"),
124125
**kwargs
125126
)
@@ -159,19 +160,19 @@ async def get_schema_properties(
159160
self,
160161
group_name: str,
161162
name: str,
162-
content: str,
163-
serialization_type: Union[str, SerializationType],
163+
schema_definition: str,
164+
format: Union[str, SchemaFormat], # pylint:disable=redefined-builtin
164165
**kwargs: Any
165166
) -> SchemaProperties:
166167
"""
167168
Gets the ID referencing an existing schema within the specified schema group,
168-
as matched by schema content comparison.
169+
as matched by schema defintion comparison.
169170
170171
:param str group_name: Schema group under which schema should be registered.
171172
:param str name: Name of schema being registered.
172-
:param str content: String representation of the schema being registered.
173-
:param serialization_type: Serialization type for the schema being registered.
174-
:type serialization_type: Union[str, SerializationType]
173+
:param str schema_definition: String representation of the schema being registered.
174+
:param format: Format for the schema being registered.
175+
:type format: Union[str, SchemaFormat]
175176
:rtype: SchemaProperties
176177
177178
.. admonition:: Example:
@@ -185,15 +186,15 @@ async def get_schema_properties(
185186
186187
"""
187188
try:
188-
serialization_type = serialization_type.value
189+
format = format.value
189190
except AttributeError:
190191
pass
191192

192193
request = schema_rest.build_query_id_by_content_request(
193194
group_name=group_name,
194195
schema_name=name,
195-
content=content,
196-
serialization_type=serialization_type,
196+
content=schema_definition,
197+
serialization_type=format,
197198
content_type=kwargs.pop("content_type", "application/json"),
198199
**kwargs
199200
)

0 commit comments

Comments
 (0)