Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SchemaRegistry] renaming from archboard feedback #20766

Merged
6 commits merged into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
- `register_schema` and `get_schema_properties` methods on sync and async `SchemaRegistryClient` now take in the following parameters in the given order:
- `group_name`, which has been renamed from `schema_group`
- `name`, which has been renamed from `schema_name`
- `content`, which has been renamed from `schema_content`
- `serialization_type`
- `schema_definition`, which has been renamed from `schema_content`
yunhaoling marked this conversation as resolved.
Show resolved Hide resolved
- `format`, which has been renamed from `serialization_type`
- `endpoint` parameter in `SchemaRegistryClient` constructor has been renamed `fully_qualified_namespace`

### Bugs Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
__version__ = VERSION

from ._schema_registry_client import SchemaRegistryClient
from ._common._constants import SerializationType
from ._common._constants import SchemaFormat
from ._common._schema import Schema, SchemaProperties

__all__ = [
"SchemaRegistryClient",
"SerializationType",
"SchemaFormat",
"Schema",
"SchemaProperties"
]
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
from enum import Enum


class SerializationType(str, Enum):
class SchemaFormat(str, Enum):
AVRO = "avro"
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@

def _parse_schema_properties_dict(response):
return {
'location': response.headers.get('location'),
'id': response.headers.get('schema-id'),
'serialization_type': response.headers.get('serialization-type'),
'format': response.headers.get('serialization-type'),
'version': int(response.headers.get('schema-version'))
}

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

def _parse_response_schema(response):
return Schema(
content=response.text(),
schema_definition=response.text(),
yunhaoling marked this conversation as resolved.
Show resolved Hide resolved
properties=SchemaProperties(**_parse_schema_properties_dict(response))
)
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ class SchemaProperties(object):

:ivar id: References specific schema in registry namespace.
:type id: str
:ivar location: URL location of schema, identified by schema group, schema name, and version.
:type location: str
:ivar serialization_type: Serialization type for the schema being stored.
:type serialization_type: str
:ivar format: Format for the schema being stored.
:type format: str
:ivar version: Version of the returned schema.
:type version: int

Expand All @@ -57,17 +55,16 @@ def __init__(
):
# type: (Optional[str], Any) -> None
self.id = id
self.location = kwargs.get('location')
self.serialization_type = kwargs.get('serialization_type')
self.format = kwargs.get('format')
self.version = kwargs.get('version')


class Schema(object):
"""
The schema content of a schema, along with id and meta properties.

:ivar content: The content of the schema.
:type content: str
:ivar schema_definition: The content of the schema.
:type schema_definition: str
:ivar properties: The properties of the schema.
:type properties: SchemaProperties

Expand All @@ -84,9 +81,9 @@ class Schema(object):

def __init__(
self,
content,
schema_definition,
properties,
):
# type: (str, SchemaProperties) -> None
self.content = content
self.schema_definition = schema_definition
self.properties = properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# --------------------------------------------------------------------------
from typing import Any, TYPE_CHECKING, Union

from ._common._constants import SerializationType
from ._common._constants import SchemaFormat
from ._common._schema import Schema, SchemaProperties
from ._common._response_handlers import (
_parse_response_schema,
Expand All @@ -44,7 +44,8 @@ class SchemaRegistryClient(object):
SchemaRegistryClient is as a central schema repository for enterprise-level data infrastructure,
complete with support for versioning and management.

:param str endpoint: The Schema Registry service endpoint, for example my-namespace.servicebus.windows.net.
:param str fully_qualified_namespace: The Schema Registry service fully qualified host name,
for example my-namespace.servicebus.windows.net.
:param credential: To authenticate to manage the entities of the SchemaRegistry namespace.
:type credential: TokenCredential

Expand All @@ -59,10 +60,10 @@ class SchemaRegistryClient(object):

"""

def __init__(self, endpoint, credential, **kwargs):
def __init__(self, fully_qualified_namespace, credential, **kwargs):
# type: (str, TokenCredential, Any) -> None
self._generated_client = AzureSchemaRegistry(
credential=credential, endpoint=endpoint, **kwargs
credential=credential, endpoint=fully_qualified_namespace, **kwargs
)

def __enter__(self):
Expand All @@ -82,22 +83,20 @@ def close(self):
self._generated_client.close()

def register_schema(
self, group_name, name, content, serialization_type, **kwargs
self, group_name, name, schema_definition, format, **kwargs # pylint:disable=redefined-builtin
yunhaoling marked this conversation as resolved.
Show resolved Hide resolved
):
# type: (str, str, str, Union[str, SerializationType], Any) -> SchemaProperties
# type: (str, str, str, Union[str, SchemaFormat], Any) -> SchemaProperties
"""
Register new schema. If schema of specified name does not exist in specified group,
schema is created at version 1. If schema of specified name exists already in specified group,
schema is created at latest version + 1.

:param str group_name: Schema group under which schema should be registered.
:param str name: Name of schema being registered.
:param str content: String representation of the schema being registered.
:param serialization_type: Serialization type for the schema being registered.
For now Avro is the only supported serialization type by the service.
:type serialization_type: Union[str, SerializationType]
:keyword content_type: The content type of the request. Default value is 'application/json'.
:paramtype content_type: str
:param str schema_definition: String representation of the schema being registered.
:param format: Format for the schema being registered.
For now Avro is the only supported schema format by the service.
:type format: Union[str, SchemaFormat]
:rtype: SchemaProperties

.. admonition:: Example:
Expand All @@ -111,15 +110,15 @@ def register_schema(

"""
try:
serialization_type = serialization_type.value
format = format.value
except AttributeError:
pass

request = schema_rest.build_register_request(
group_name=group_name,
schema_name=name,
content=content,
serialization_type=serialization_type,
content=schema_definition,
serialization_type=format,
content_type=kwargs.pop("content_type", "application/json"),
**kwargs
)
Expand Down Expand Up @@ -153,20 +152,18 @@ def get_schema(self, id, **kwargs): # pylint:disable=redefined-builtin
return _parse_response_schema(response)

def get_schema_properties(
self, group_name, name, content, serialization_type, **kwargs
self, group_name, name, schema_definition, format, **kwargs # pylint:disable=redefined-builtin
):
# type: (str, str, str, Union[str, SerializationType], Any) -> SchemaProperties
# type: (str, str, str, Union[str, SchemaFormat], Any) -> SchemaProperties
"""
Gets the ID referencing an existing schema within the specified schema group,
as matched by schema content comparison.
as matched by schema definition comparison.

:param str group_name: Schema group under which schema should be registered.
:param str name: Name of schema being registered.
:param str content: String representation of the schema being registered.
:param serialization_type: Serialization type for the schema being registered.
:type serialization_type: Union[str, SerializationType]
:keyword content_type: The content type of the request. Default value is 'application/json'.
:paramtype content_type: str
:param str schema_definition: String representation of the schema being registered.
:param format: Format for the schema being registered.
:type format: Union[str, SchemaFormat]
:rtype: SchemaProperties

.. admonition:: Example:
Expand All @@ -180,15 +177,15 @@ def get_schema_properties(

"""
try:
serialization_type = serialization_type.value
format = format.value
except AttributeError:
pass

request = schema_rest.build_query_id_by_content_request(
group_name=group_name,
schema_name=name,
content=content,
serialization_type=serialization_type,
content=schema_definition,
serialization_type=format,
content_type=kwargs.pop("content_type", "application/json"),
**kwargs
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# --------------------------------------------------------------------------
from typing import Any, TYPE_CHECKING, Union

from .._common._constants import SerializationType
from .._common._constants import SchemaFormat
from .._common._schema import Schema, SchemaProperties
from .._common._response_handlers import (
_parse_response_schema,
Expand All @@ -44,7 +44,8 @@ class SchemaRegistryClient(object):
SchemaRegistryClient is as a central schema repository for enterprise-level data infrastructure,
complete with support for versioning and management.

:param str endpoint: The Schema Registry service endpoint, for example my-namespace.servicebus.windows.net.
:param str fully_qualified_namespace: The Schema Registry service fully qualified host name,
for example my-namespace.servicebus.windows.net.
:param credential: To authenticate to manage the entities of the SchemaRegistry namespace.
:type credential: AsyncTokenCredential

Expand All @@ -60,11 +61,11 @@ class SchemaRegistryClient(object):
"""
def __init__(
self,
endpoint: str,
fully_qualified_namespace: str,
credential: "AsyncTokenCredential",
**kwargs: Any
) -> None:
self._generated_client = AzureSchemaRegistry(credential, endpoint, **kwargs)
self._generated_client = AzureSchemaRegistry(credential, fully_qualified_namespace, **kwargs)

async def __aenter__(self):
await self._generated_client.__aenter__()
Expand All @@ -83,8 +84,8 @@ async def register_schema(
self,
group_name: str,
name: str,
content: str,
serialization_type: Union[str, SerializationType],
schema_definition: str,
format: Union[str, SchemaFormat], # pylint:disable=redefined-builtin
**kwargs: Any
) -> SchemaProperties:
"""
Expand All @@ -94,10 +95,10 @@ async def register_schema(

:param str group_name: Schema group under which schema should be registered.
:param str name: Name of schema being registered.
:param str content: String representation of the schema being registered.
:param serialization_type: Serialization type for the schema being registered.
For now Avro is the only supported serialization type by the service.
:type serialization_type: Union[str, SerializationType]
:param str schema_definition: String representation of the schema being registered.
:param format: Format for the schema being registered.
For now Avro is the only supported schema format by the service.
:type format: Union[str, SchemaFormat]
:rtype: SchemaProperties

.. admonition:: Example:
Expand All @@ -111,15 +112,15 @@ async def register_schema(

"""
try:
serialization_type = serialization_type.value
format = format.value
except AttributeError:
pass

request = schema_rest.build_register_request(
group_name=group_name,
schema_name=name,
content=content,
serialization_type=serialization_type,
content=schema_definition,
serialization_type=format,
content_type=kwargs.pop("content_type", "application/json"),
**kwargs
)
Expand Down Expand Up @@ -159,19 +160,19 @@ async def get_schema_properties(
self,
group_name: str,
name: str,
content: str,
serialization_type: Union[str, SerializationType],
schema_definition: str,
format: Union[str, SchemaFormat], # pylint:disable=redefined-builtin
**kwargs: Any
) -> SchemaProperties:
"""
Gets the ID referencing an existing schema within the specified schema group,
as matched by schema content comparison.
as matched by schema defintion comparison.

:param str group_name: Schema group under which schema should be registered.
:param str name: Name of schema being registered.
:param str content: String representation of the schema being registered.
:param serialization_type: Serialization type for the schema being registered.
:type serialization_type: Union[str, SerializationType]
:param str schema_definition: String representation of the schema being registered.
:param format: Format for the schema being registered.
:type format: Union[str, SchemaFormat]
:rtype: SchemaProperties

.. admonition:: Example:
Expand All @@ -185,15 +186,15 @@ async def get_schema_properties(

"""
try:
serialization_type = serialization_type.value
format = format.value
except AttributeError:
pass

request = schema_rest.build_query_id_by_content_request(
group_name=group_name,
schema_name=name,
content=content,
serialization_type=serialization_type,
content=schema_definition,
serialization_type=format,
content_type=kwargs.pop("content_type", "application/json"),
**kwargs
)
Expand Down
Loading