diff --git a/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md b/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md index 4cffbf0a375fd..91df0fb9ada9c 100644 --- a/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md +++ b/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md @@ -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` + - `format`, which has been renamed from `serialization_type` +- `endpoint` parameter in `SchemaRegistryClient` constructor has been renamed `fully_qualified_namespace` ### Bugs Fixed diff --git a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/__init__.py b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/__init__.py index b0b43faf4258a..861214080424f 100644 --- a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/__init__.py +++ b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/__init__.py @@ -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" ] diff --git a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_constants.py b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_constants.py index a22d118f4b84a..48973ddb76732 100644 --- a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_constants.py +++ b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_constants.py @@ -26,5 +26,5 @@ from enum import Enum -class SerializationType(str, Enum): +class SchemaFormat(str, Enum): AVRO = "avro" diff --git a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_response_handlers.py b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_response_handlers.py index ad1fda4b2bdc4..fe63016100940 100644 --- a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_response_handlers.py +++ b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_response_handlers.py @@ -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')) } @@ -45,6 +44,6 @@ def _parse_response_schema_properties(response): def _parse_response_schema(response): return Schema( - content=response.text(), + schema_definition=response.text(), properties=SchemaProperties(**_parse_schema_properties_dict(response)) ) diff --git a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_schema.py b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_schema.py index 582cb729f7b41..f7f32b18f4c62 100644 --- a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_schema.py +++ b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_schema.py @@ -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 @@ -57,8 +55,7 @@ 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') @@ -66,8 +63,8 @@ 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 @@ -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 diff --git a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_schema_registry_client.py b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_schema_registry_client.py index f48234650710d..7f41db19957fa 100644 --- a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_schema_registry_client.py +++ b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_schema_registry_client.py @@ -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, @@ -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 @@ -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): @@ -82,9 +83,9 @@ 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 ): - # 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, @@ -92,12 +93,10 @@ 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] - :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: @@ -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 ) @@ -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: @@ -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 ) diff --git a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/aio/_schema_registry_client_async.py b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/aio/_schema_registry_client_async.py index f9de1bbc2d5f8..242284a4cd6e4 100644 --- a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/aio/_schema_registry_client_async.py +++ b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/aio/_schema_registry_client_async.py @@ -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, @@ -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 @@ -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__() @@ -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: """ @@ -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: @@ -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 ) @@ -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: @@ -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 ) diff --git a/sdk/schemaregistry/azure-schemaregistry/samples/async_samples/sample_code_schemaregistry_async.py b/sdk/schemaregistry/azure-schemaregistry/samples/async_samples/sample_code_schemaregistry_async.py index 6d4b8aaa8540a..f304528c73328 100644 --- a/sdk/schemaregistry/azure-schemaregistry/samples/async_samples/sample_code_schemaregistry_async.py +++ b/sdk/schemaregistry/azure-schemaregistry/samples/async_samples/sample_code_schemaregistry_async.py @@ -27,21 +27,21 @@ import asyncio from azure.schemaregistry.aio import SchemaRegistryClient -from azure.schemaregistry import SerializationType +from azure.schemaregistry import SchemaFormat from azure.identity.aio import ClientSecretCredential, DefaultAzureCredential def create_client(): # [START create_sr_client_async] - SCHEMA_REGISTRY_ENDPOINT = os.environ['SCHEMA_REGISTRY_ENDPOINT'] + SCHEMA_REGISTRY_FQN = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE'] token_credential = DefaultAzureCredential() - schema_registry_client = SchemaRegistryClient(endpoint=SCHEMA_REGISTRY_ENDPOINT, credential=token_credential) + schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=SCHEMA_REGISTRY_FQN, credential=token_credential) # [END create_sr_client_async] TENANT_ID = os.environ['SCHEMA_REGISTRY_AZURE_TENANT_ID'] CLIENT_ID = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_ID'] CLIENT_SECRET = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_SECRET'] token_credential = ClientSecretCredential(TENANT_ID, CLIENT_ID, CLIENT_SECRET) - schema_registry_client = SchemaRegistryClient(endpoint=SCHEMA_REGISTRY_ENDPOINT, credential=token_credential) + schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=SCHEMA_REGISTRY_FQN, credential=token_credential) return schema_registry_client, token_credential @@ -49,9 +49,9 @@ async def register_schema(schema_registry_client): # [START register_schema_async] GROUP_NAME = os.environ['SCHEMA_REGISTRY_GROUP'] NAME = 'your-schema-name' - SERIALIZATION_TYPE = SerializationType.AVRO - CONTENT = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" - schema_properties = await schema_registry_client.register_schema(GROUP_NAME, NAME, CONTENT, SERIALIZATION_TYPE) + FORMAT = SchemaFormat.AVRO + SCHEMA_DEFINITION = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" + schema_properties = await schema_registry_client.register_schema(GROUP_NAME, NAME, SCHEMA_DEFINITION, FORMAT) schema_id = schema_properties.id # [END register_schema_async] return schema_id @@ -60,19 +60,19 @@ async def register_schema(schema_registry_client): async def get_schema(schema_registry_client, id): # [START get_schema_async] schema = await schema_registry_client.get_schema(id) - schema_content = schema.content + schema_definition = schema.schema_definition # [END get_schema_async] - return schema_content + return schema_definition async def get_schema_id(schema_registry_client): group_name = os.environ['SCHEMA_REGISTRY_GROUP'] name = 'your-schema-name' - serialization_type = SerializationType.AVRO - content = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" + format = SchemaFormat.AVRO + schema_definition = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" # [START get_schema_id_async] - schema_properties = await schema_registry_client.get_schema_properties(group_name, name, content, serialization_type) + schema_properties = await schema_registry_client.get_schema_properties(group_name, name, schema_definition, format) schema_id = schema_properties.id # [END get_schema_id_async] return schema_id diff --git a/sdk/schemaregistry/azure-schemaregistry/samples/async_samples/schema_registry_async.py b/sdk/schemaregistry/azure-schemaregistry/samples/async_samples/schema_registry_async.py index d115aa4ccbc6f..20799e5aa353d 100644 --- a/sdk/schemaregistry/azure-schemaregistry/samples/async_samples/schema_registry_async.py +++ b/sdk/schemaregistry/azure-schemaregistry/samples/async_samples/schema_registry_async.py @@ -16,22 +16,22 @@ from azure.identity.aio import ClientSecretCredential from azure.schemaregistry.aio import SchemaRegistryClient -from azure.schemaregistry import SerializationType +from azure.schemaregistry import SchemaFormat TENANT_ID = os.environ['SCHEMA_REGISTRY_AZURE_TENANT_ID'] CLIENT_ID = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_ID'] CLIENT_SECRET = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_SECRET'] -SCHEMA_REGISTRY_ENDPOINT = os.environ['SCHEMA_REGISTRY_ENDPOINT'] +SCHEMA_REGISTRY_FQN = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE'] GROUP_NAME = os.environ['SCHEMA_REGISTRY_GROUP'] NAME = 'your-schema-name' -SERIALIZATION_TYPE = SerializationType.AVRO +FORMAT = SchemaFormat.AVRO SCHEMA_STRING = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" -async def register_schema(client, group_name, name, schema_string, serialization_type): +async def register_schema(client, group_name, name, schema_string, format): print("Registering schema...") - schema_properties = await client.register_schema(group_name, name, schema_string, serialization_type) + schema_properties = await client.register_schema(group_name, name, schema_string, format) print("Schema registered, returned schema id is {}".format(schema_properties.id)) print("Schema properties are {}".format(schema_properties)) return schema_properties.id @@ -40,14 +40,14 @@ async def register_schema(client, group_name, name, schema_string, serialization async def get_schema_by_id(client, id): print("Getting schema by id...") schema = await client.get_schema(id) - print("The schema string of schema id: {} string is {}".format(id, schema.content)) + print("The schema string of schema id: {} string is {}".format(id, schema.schema_definition)) print("Schema properties are {}".format(id)) - return schema.content + return schema.schema_definition -async def get_schema_id(client, group_name, name, schema_string, serialization_type): +async def get_schema_id(client, group_name, name, schema_string, format): print("Getting schema id...") - schema_properties = await client.get_schema_properties(group_name, name, schema_string, serialization_type) + schema_properties = await client.get_schema_properties(group_name, name, schema_string, format) print("The schema id is: {}".format(schema_properties.id)) print("Schema properties are {}".format(schema_properties)) return schema_properties.id @@ -59,11 +59,11 @@ async def main(): client_id=CLIENT_ID, client_secret=CLIENT_SECRET ) - schema_registry_client = SchemaRegistryClient(endpoint=SCHEMA_REGISTRY_ENDPOINT, credential=token_credential) + schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=SCHEMA_REGISTRY_FQN, credential=token_credential) async with token_credential, schema_registry_client: - schema_id = await register_schema(schema_registry_client, GROUP_NAME, NAME, SCHEMA_STRING, SERIALIZATION_TYPE) + schema_id = await register_schema(schema_registry_client, GROUP_NAME, NAME, SCHEMA_STRING, FORMAT) schema_str = await get_schema_by_id(schema_registry_client, schema_id) - schema_id = await get_schema_id(schema_registry_client, GROUP_NAME, NAME, SCHEMA_STRING, SERIALIZATION_TYPE) + schema_id = await get_schema_id(schema_registry_client, GROUP_NAME, NAME, SCHEMA_STRING, FORMAT) loop = asyncio.get_event_loop() diff --git a/sdk/schemaregistry/azure-schemaregistry/samples/sync_samples/sample_code_schemaregistry.py b/sdk/schemaregistry/azure-schemaregistry/samples/sync_samples/sample_code_schemaregistry.py index 1f3d638fb5bd5..f3aede39c512e 100644 --- a/sdk/schemaregistry/azure-schemaregistry/samples/sync_samples/sample_code_schemaregistry.py +++ b/sdk/schemaregistry/azure-schemaregistry/samples/sync_samples/sample_code_schemaregistry.py @@ -25,21 +25,21 @@ # -------------------------------------------------------------------------- import os -from azure.schemaregistry import SchemaRegistryClient, SerializationType +from azure.schemaregistry import SchemaRegistryClient, SchemaFormat from azure.identity import ClientSecretCredential, DefaultAzureCredential def create_client(): # [START create_sr_client_sync] - SCHEMA_REGISTRY_ENDPOINT = os.environ['SCHEMA_REGISTRY_ENDPOINT'] + SCHEMA_REGISTRY_FQN = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE'] token_credential = DefaultAzureCredential() - schema_registry_client = SchemaRegistryClient(endpoint=SCHEMA_REGISTRY_ENDPOINT, credential=token_credential) + schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=SCHEMA_REGISTRY_FQN, credential=token_credential) # [END create_sr_client_sync] TENANT_ID = os.environ['SCHEMA_REGISTRY_AZURE_TENANT_ID'] CLIENT_ID = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_ID'] CLIENT_SECRET = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_SECRET'] token_credential = ClientSecretCredential(TENANT_ID, CLIENT_ID, CLIENT_SECRET) - schema_registry_client = SchemaRegistryClient(endpoint=SCHEMA_REGISTRY_ENDPOINT, credential=token_credential) + schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=SCHEMA_REGISTRY_FQN, credential=token_credential) return schema_registry_client @@ -47,16 +47,15 @@ def register_schema(schema_registry_client): # [START register_schema_sync] GROUP_NAME = os.environ['SCHEMA_REGISTRY_GROUP'] NAME = 'your-schema-name' - SERIALIZATION_TYPE = SerializationType.AVRO - CONTENT = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" - schema_properties = schema_registry_client.register_schema(GROUP_NAME, NAME, CONTENT, SERIALIZATION_TYPE) + FORMAT = SchemaFormat.AVRO + SCHEMA_DEFINITION = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" + schema_properties = schema_registry_client.register_schema(GROUP_NAME, NAME, SCHEMA_DEFINITION, FORMAT) schema_id = schema_properties.id # [END register_schema_sync] # [START print_schema_properties] print(schema_properties.id) - print(schema_properties.location) - print(schema_properties.serialization_type) + print(schema_properties.format) print(schema_properties.version) # [END print_schema_properties] @@ -66,11 +65,11 @@ def register_schema(schema_registry_client): def get_schema(schema_registry_client, id): # [START get_schema_sync] schema = schema_registry_client.get_schema(id) - schema_content = schema.content + schema_definition = schema.schema_definition # [END get_schema_sync] # [START print_schema] - print(schema.content) + print(schema.schema_definition) print(schema.properties) # [END print_schema] return schema @@ -79,10 +78,10 @@ def get_schema(schema_registry_client, id): def get_schema_id(schema_registry_client): group_name = os.environ['SCHEMA_REGISTRY_GROUP'] name = 'your-schema-name' - serialization_type = SerializationType.AVRO - content = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" + format = SchemaFormat.AVRO + schema_definition = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" # [START get_schema_id_sync] - schema_properties = schema_registry_client.get_schema_properties(group_name, name, content, serialization_type) + schema_properties = schema_registry_client.get_schema_properties(group_name, name, schema_definition, format) schema_id = schema_properties.id # [END get_schema_id_sync] return schema_id diff --git a/sdk/schemaregistry/azure-schemaregistry/samples/sync_samples/schema_registry.py b/sdk/schemaregistry/azure-schemaregistry/samples/sync_samples/schema_registry.py index 1d9338b2d0552..08f5a539b383c 100644 --- a/sdk/schemaregistry/azure-schemaregistry/samples/sync_samples/schema_registry.py +++ b/sdk/schemaregistry/azure-schemaregistry/samples/sync_samples/schema_registry.py @@ -36,16 +36,16 @@ import json from azure.identity import ClientSecretCredential -from azure.schemaregistry import SchemaRegistryClient, SerializationType +from azure.schemaregistry import SchemaRegistryClient, SchemaFormat TENANT_ID = os.environ['SCHEMA_REGISTRY_AZURE_TENANT_ID'] CLIENT_ID = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_ID'] CLIENT_SECRET = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_SECRET'] -SCHEMA_REGISTRY_ENDPOINT = os.environ['SCHEMA_REGISTRY_ENDPOINT'] +SCHEMA_REGISTRY_FQN = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE'] GROUP_NAME = os.environ['SCHEMA_REGISTRY_GROUP'] NAME = 'your-schema-name' -SERIALIZATION_TYPE = SerializationType.AVRO +FORMAT = SchemaFormat.AVRO SCHEMA_JSON = { "namespace": "example.avro", @@ -69,9 +69,9 @@ SCHEMA_STRING = json.dumps(SCHEMA_JSON, separators=(',', ':')) -def register_schema(client, group_name, name, schema_string, serialization_type): +def register_schema(client, group_name, name, schema_string, format): print("Registering schema...") - schema_properties = client.register_schema(group_name, name, schema_string, serialization_type) + schema_properties = client.register_schema(group_name, name, schema_string, format) print("Schema registered, returned schema id is {}".format(schema_properties.id)) print("Schema properties are {}".format(schema_properties)) return schema_properties.id @@ -80,14 +80,14 @@ def register_schema(client, group_name, name, schema_string, serialization_type) def get_schema_by_id(client, id): print("Getting schema by id...") schema = client.get_schema(id) - print("The schema string of schema id: {} string is {}".format(id, schema.content)) + print("The schema string of schema id: {} string is {}".format(id, schema.schema_definition)) print("Schema properties are {}".format(id)) - return schema.content + return schema.schema_definition -def get_schema_id(client, group_name, name, schema_string, serialization_type): +def get_schema_id(client, group_name, name, schema_string, format): print("Getting schema id...") - schema_properties = client.get_schema_properties(group_name, name, schema_string, serialization_type) + schema_properties = client.get_schema_properties(group_name, name, schema_string, format) print("The schema id is: {}".format(schema_properties.id)) print("Schema properties are {}".format(schema_properties)) return schema_properties.id @@ -99,8 +99,8 @@ def get_schema_id(client, group_name, name, schema_string, serialization_type): client_id=CLIENT_ID, client_secret=CLIENT_SECRET ) - schema_registry_client = SchemaRegistryClient(endpoint=SCHEMA_REGISTRY_ENDPOINT, credential=token_credential) + schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=SCHEMA_REGISTRY_FQN, credential=token_credential) with schema_registry_client: - schema_id = register_schema(schema_registry_client, GROUP_NAME, NAME, SCHEMA_STRING, SERIALIZATION_TYPE) + schema_id = register_schema(schema_registry_client, GROUP_NAME, NAME, SCHEMA_STRING, FORMAT) schema_str = get_schema_by_id(schema_registry_client, schema_id) - schema_id = get_schema_id(schema_registry_client, GROUP_NAME, NAME, SCHEMA_STRING, SERIALIZATION_TYPE) + schema_id = get_schema_id(schema_registry_client, GROUP_NAME, NAME, SCHEMA_STRING, FORMAT) diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_basic_async.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_basic_async.yaml index 9b3e501481e57..b447bcde69e7a 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_basic_async.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_basic_async.yaml @@ -19,7 +19,7 @@ interactions: string: '{"id":"d919a8923e2446e69614c0220d967dd7"}' headers: content-type: application/json - date: Mon, 20 Sep 2021 20:08:28 GMT + date: Wed, 22 Sep 2021 00:45:44 GMT location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482/versions/1?api-version=2020-09-01-preview schema-id: d919a8923e2446e69614c0220d967dd7 schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview @@ -47,7 +47,7 @@ interactions: string: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}' headers: content-type: application/json - date: Mon, 20 Sep 2021 20:08:29 GMT + date: Wed, 22 Sep 2021 00:45:44 GMT location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482/versions/1?api-version=2020-09-01-preview schema-id: d919a8923e2446e69614c0220d967dd7 schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview @@ -81,7 +81,7 @@ interactions: string: '{"id":"d919a8923e2446e69614c0220d967dd7"}' headers: content-type: application/json - date: Mon, 20 Sep 2021 20:08:30 GMT + date: Wed, 22 Sep 2021 00:45:44 GMT location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482/versions/1?api-version=2020-09-01-preview schema-id: d919a8923e2446e69614c0220d967dd7 schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_negative_no_schema_async.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_negative_no_schema_async.yaml index 82908a2118082..acd9965c636c6 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_negative_no_schema_async.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_negative_no_schema_async.yaml @@ -11,12 +11,12 @@ interactions: response: body: string: '{"Code":400,"Detail":"SubCode=40000, UnknownType:The request is invalid. - [MGResponseHttpError=BadRequest]. TrackingId:4f653bc2-9ef4-4b83-8632-3aa321d9b8e5_G29, + [MGResponseHttpError=BadRequest]. TrackingId:f2315fcb-9423-493d-b69a-755243ae804f_G4, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/a, - Timestamp:2021-09-20T20:08:31"}' + Timestamp:2021-09-22T00:45:46"}' headers: content-type: application/json - date: Mon, 20 Sep 2021 20:08:30 GMT + date: Wed, 22 Sep 2021 00:45:45 GMT server: Microsoft-HTTPAPI/2.0 strict-transport-security: max-age=31536000 transfer-encoding: chunked @@ -36,11 +36,11 @@ interactions: response: body: string: '{"Code":404,"Detail":"Schema id aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa does - not exist. TrackingId:79cdec74-b17a-4334-a0bd-0ceeb9253ca4_G29, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, - Timestamp:2021-09-20T20:08:31"}' + not exist. TrackingId:a7bda221-9b86-4e4f-b0b1-2e8db2e1d063_G4, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + Timestamp:2021-09-22T00:45:46"}' headers: content-type: application/json - date: Mon, 20 Sep 2021 20:08:31 GMT + date: Wed, 22 Sep 2021 00:45:46 GMT server: Microsoft-HTTPAPI/2.0 strict-transport-security: max-age=31536000 transfer-encoding: chunked diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/test_schema_registry_async.py b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/test_schema_registry_async.py index e9a737ca043a0..8258fe3b39e11 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/test_schema_registry_async.py +++ b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/test_schema_registry_async.py @@ -38,7 +38,7 @@ class SchemaRegistryAsyncTests(AzureTestCase): def create_client(self, endpoint): credential = self.get_credential(SchemaRegistryClient, is_async=True) - return self.create_client_from_credential(SchemaRegistryClient, credential, endpoint=endpoint, is_async=True) + return self.create_client_from_credential(SchemaRegistryClient, credential, fully_qualified_namespace=endpoint, is_async=True) @SchemaRegistryPowerShellPreparer() async def test_schema_basic_async(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): @@ -46,29 +46,25 @@ async def test_schema_basic_async(self, schemaregistry_endpoint, schemaregistry_ async with client: schema_name = self.get_resource_name('test-schema-basic-async') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" - serialization_type = "Avro" - schema_properties = await client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) + format = "Avro" + schema_properties = await client.register_schema(schemaregistry_group, schema_name, schema_str, format) assert schema_properties.id is not None - assert schema_properties.location is not None assert schema_properties.version is 1 - assert schema_properties.serialization_type == "Avro" + assert schema_properties.format == "Avro" returned_schema = await client.get_schema(id=schema_properties.id) assert returned_schema.properties.id == schema_properties.id - assert returned_schema.properties.location is not None assert returned_schema.properties.version == 1 - assert returned_schema.properties.serialization_type == "Avro" - assert returned_schema.content == schema_str + assert returned_schema.properties.format == "Avro" + assert returned_schema.schema_definition == schema_str - returned_schema_properties = await client.get_schema_properties(schemaregistry_group, schema_name, schema_str, serialization_type) + returned_schema_properties = await client.get_schema_properties(schemaregistry_group, schema_name, schema_str, format) assert returned_schema_properties.id == schema_properties.id - assert returned_schema_properties.location is not None assert returned_schema_properties.version == 1 - assert returned_schema_properties.serialization_type == "Avro" - + assert returned_schema_properties.format == "Avro" await client._generated_client._config.credential.close() @SchemaRegistryPowerShellPreparer() @@ -77,30 +73,27 @@ async def test_schema_update_async(self, schemaregistry_endpoint, schemaregistry async with client: schema_name = self.get_resource_name('test-schema-update-async') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" - serialization_type = "Avro" - schema_properties = await client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) + format = "Avro" + schema_properties = await client.register_schema(schemaregistry_group, schema_name, schema_str, format) assert schema_properties.id is not None - assert schema_properties.location is not None assert schema_properties.version != 0 - assert schema_properties.serialization_type == "Avro" + assert schema_properties.format == "Avro" schema_str_new = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_food","type":["string","null"]}]}""" - new_schema_properties = await client.register_schema(schemaregistry_group, schema_name, schema_str_new, serialization_type) + new_schema_properties = await client.register_schema(schemaregistry_group, schema_name, schema_str_new, format) assert new_schema_properties.id is not None - assert new_schema_properties.location is not None assert new_schema_properties.version == schema_properties.version + 1 - assert new_schema_properties.serialization_type == "Avro" + assert new_schema_properties.format == "Avro" new_schema = await client.get_schema(id=new_schema_properties.id) assert new_schema.properties.id != schema_properties.id assert new_schema.properties.id == new_schema_properties.id - assert new_schema.properties.location is not None - assert new_schema.content == schema_str_new + assert new_schema.schema_definition == schema_str_new assert new_schema.properties.version == schema_properties.version + 1 - assert new_schema.properties.serialization_type == "Avro" + assert new_schema.properties.format == "Avro" await client._generated_client._config.credential.close() @@ -109,23 +102,23 @@ async def test_schema_same_twice_async(self, schemaregistry_endpoint, schemaregi client = self.create_client(schemaregistry_endpoint) schema_name = self.get_resource_name('test-schema-twice-async') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"age","type":["int","null"]},{"name":"city","type":["string","null"]}]}""" - serialization_type = "Avro" + format = "Avro" async with client: - schema_properties = await client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) - schema_properties_second = await client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) + schema_properties = await client.register_schema(schemaregistry_group, schema_name, schema_str, format) + schema_properties_second = await client.register_schema(schemaregistry_group, schema_name, schema_str, format) assert schema_properties.id == schema_properties_second.id await client._generated_client._config.credential.close() @SchemaRegistryPowerShellPreparer() async def test_schema_negative_wrong_credential_async(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): credential = ClientSecretCredential(tenant_id="fake", client_id="fake", client_secret="fake") - client = SchemaRegistryClient(endpoint=schemaregistry_endpoint, credential=credential) + client = SchemaRegistryClient(fully_qualified_namespace=schemaregistry_endpoint, credential=credential) async with client, credential: schema_name = self.get_resource_name('test-schema-negative-async') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" - serialization_type = "Avro" + format = "Avro" with pytest.raises(ClientAuthenticationError): - await client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) + await client.register_schema(schemaregistry_group, schema_name, schema_str, format) @SchemaRegistryPowerShellPreparer() async def test_schema_negative_wrong_endpoint_async(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): @@ -133,9 +126,9 @@ async def test_schema_negative_wrong_endpoint_async(self, schemaregistry_endpoin async with client: schema_name = self.get_resource_name('test-schema-nonexist-async') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" - serialization_type = "Avro" + format = "Avro" with pytest.raises(ServiceRequestError): - await client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) + await client.register_schema(schemaregistry_group, schema_name, schema_str, format) await client._generated_client._config.credential.close() @SchemaRegistryPowerShellPreparer() diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_basic.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_basic.yaml index 4c737cf75275e..4630b204158a5 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_basic.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_basic.yaml @@ -25,7 +25,7 @@ interactions: content-type: - application/json date: - - Mon, 20 Sep 2021 20:08:15 GMT + - Wed, 22 Sep 2021 00:45:29 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88/versions/1?api-version=2020-09-01-preview schema-id: @@ -67,7 +67,7 @@ interactions: content-type: - application/json date: - - Mon, 20 Sep 2021 20:08:15 GMT + - Wed, 22 Sep 2021 00:45:30 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88/versions/1?api-version=2020-09-01-preview schema-id: @@ -115,7 +115,7 @@ interactions: content-type: - application/json date: - - Mon, 20 Sep 2021 20:08:16 GMT + - Wed, 22 Sep 2021 00:45:30 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88/versions/1?api-version=2020-09-01-preview schema-id: diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_negative_no_schema.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_negative_no_schema.yaml index 7e8724dc80848..337f4d08bfb90 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_negative_no_schema.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_negative_no_schema.yaml @@ -15,14 +15,14 @@ interactions: response: body: string: '{"Code":400,"Detail":"SubCode=40000, UnknownType:The request is invalid. - [MGResponseHttpError=BadRequest]. TrackingId:0f167d85-f54f-4afe-aae9-949d2b894663_G28, + [MGResponseHttpError=BadRequest]. TrackingId:89eef0c1-0916-4518-aaa0-63459130469a_G15, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/a, - Timestamp:2021-09-20T20:08:17"}' + Timestamp:2021-09-22T00:45:32"}' headers: content-type: - application/json date: - - Mon, 20 Sep 2021 20:08:17 GMT + - Wed, 22 Sep 2021 00:45:31 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: @@ -48,13 +48,13 @@ interactions: response: body: string: '{"Code":404,"Detail":"Schema id aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa does - not exist. TrackingId:8c8699e7-a6dc-437f-88fc-f6fddd2d64ef_G28, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, - Timestamp:2021-09-20T20:08:17"}' + not exist. TrackingId:52b44c02-c087-449e-bd04-02c7fb57b43d_G15, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + Timestamp:2021-09-22T00:45:33"}' headers: content-type: - application/json date: - - Mon, 20 Sep 2021 20:08:17 GMT + - Wed, 22 Sep 2021 00:45:32 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_same_twice.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_same_twice.yaml index 6e445c1c3ea9b..c4d7a39fa68ab 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_same_twice.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_same_twice.yaml @@ -25,7 +25,7 @@ interactions: content-type: - application/json date: - - Mon, 20 Sep 2021 20:08:24 GMT + - Wed, 22 Sep 2021 00:45:40 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-twice863b11a7/versions/1?api-version=2020-09-01-preview schema-id: @@ -73,7 +73,7 @@ interactions: content-type: - application/json date: - - Mon, 20 Sep 2021 20:08:25 GMT + - Wed, 22 Sep 2021 00:45:40 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-twice863b11a7/versions/1?api-version=2020-09-01-preview schema-id: diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_update.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_update.yaml index f74ee88cd64b2..3dc42f20085e2 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_update.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_update.yaml @@ -20,20 +20,20 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-update423f1009?api-version=2020-09-01-preview response: body: - string: '{"id":"320a8369b8454479bce5f9eb26dc3d5a"}' + string: '{"id":"bbb495c5729844bbba2db5dd793b3243"}' headers: content-type: - application/json date: - - Mon, 20 Sep 2021 20:08:26 GMT + - Wed, 22 Sep 2021 00:45:42 GMT location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/1?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/3?api-version=2020-09-01-preview schema-id: - - 320a8369b8454479bce5f9eb26dc3d5a + - bbb495c5729844bbba2db5dd793b3243 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/320a8369b8454479bce5f9eb26dc3d5a?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/bbb495c5729844bbba2db5dd793b3243?api-version=2020-09-01-preview schema-version: - - '1' + - '3' schema-versions-location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update423f1009/versions?api-version=2020-09-01-preview serialization-type: @@ -68,20 +68,20 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-update423f1009?api-version=2020-09-01-preview response: body: - string: '{"id":"003d87aaf24648aabf4255d7292f73e9"}' + string: '{"id":"a4a4e528cbd64dce8587e07d1aebc040"}' headers: content-type: - application/json date: - - Mon, 20 Sep 2021 20:08:26 GMT + - Wed, 22 Sep 2021 00:45:42 GMT location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/2?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/4?api-version=2020-09-01-preview schema-id: - - 003d87aaf24648aabf4255d7292f73e9 + - a4a4e528cbd64dce8587e07d1aebc040 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/003d87aaf24648aabf4255d7292f73e9?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/a4a4e528cbd64dce8587e07d1aebc040?api-version=2020-09-01-preview schema-version: - - '2' + - '4' schema-versions-location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update423f1009/versions?api-version=2020-09-01-preview serialization-type: @@ -107,7 +107,7 @@ interactions: User-Agent: - azsdk-python-azureschemaregistry/1.0.0b3 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: GET - uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/003d87aaf24648aabf4255d7292f73e9?api-version=2020-09-01-preview + uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/a4a4e528cbd64dce8587e07d1aebc040?api-version=2020-09-01-preview response: body: string: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_food","type":["string","null"]}]}' @@ -115,15 +115,15 @@ interactions: content-type: - application/json date: - - Mon, 20 Sep 2021 20:08:27 GMT + - Wed, 22 Sep 2021 00:45:42 GMT location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/2?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/4?api-version=2020-09-01-preview schema-id: - - 003d87aaf24648aabf4255d7292f73e9 + - a4a4e528cbd64dce8587e07d1aebc040 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/003d87aaf24648aabf4255d7292f73e9?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/a4a4e528cbd64dce8587e07d1aebc040?api-version=2020-09-01-preview schema-version: - - '2' + - '4' schema-versions-location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update423f1009/versions?api-version=2020-09-01-preview serialization-type: diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py b/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py index 9e9c4692e97b1..863e355ae840f 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py +++ b/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py @@ -34,94 +34,88 @@ class SchemaRegistryTests(AzureTestCase): def create_client(self, endpoint): credential = self.get_credential(SchemaRegistryClient) - return self.create_client_from_credential(SchemaRegistryClient, credential, endpoint=endpoint) + return self.create_client_from_credential(SchemaRegistryClient, credential, fully_qualified_namespace=endpoint) @SchemaRegistryPowerShellPreparer() def test_schema_basic(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): client = self.create_client(schemaregistry_endpoint) schema_name = self.get_resource_name('test-schema-basic') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" - serialization_type = "Avro" - schema_properties = client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) + format = "Avro" + schema_properties = client.register_schema(schemaregistry_group, schema_name, schema_str, format) assert schema_properties.id is not None - assert schema_properties.location is not None assert schema_properties.version is 1 - assert schema_properties.serialization_type == "Avro" + assert schema_properties.format == "Avro" returned_schema = client.get_schema(id=schema_properties.id) assert returned_schema.properties.id == schema_properties.id - assert returned_schema.properties.location is not None assert returned_schema.properties.version == 1 - assert returned_schema.properties.serialization_type == "Avro" - assert returned_schema.content == schema_str + assert returned_schema.properties.format == "Avro" + assert returned_schema.schema_definition == schema_str - returned_schema_properties = client.get_schema_properties(schemaregistry_group, schema_name, schema_str, serialization_type) + returned_schema_properties = client.get_schema_properties(schemaregistry_group, schema_name, schema_str, format) assert returned_schema_properties.id == schema_properties.id - assert returned_schema_properties.location is not None assert returned_schema_properties.version == 1 - assert returned_schema_properties.serialization_type == "Avro" + assert returned_schema_properties.format == "Avro" @SchemaRegistryPowerShellPreparer() def test_schema_update(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): client = self.create_client(schemaregistry_endpoint) schema_name = self.get_resource_name('test-schema-update') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" - serialization_type = "Avro" - schema_properties = client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) + format = "Avro" + schema_properties = client.register_schema(schemaregistry_group, schema_name, schema_str, format) assert schema_properties.id is not None - assert schema_properties.location is not None assert schema_properties.version != 0 - assert schema_properties.serialization_type == "Avro" + assert schema_properties.format == "Avro" schema_str_new = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_food","type":["string","null"]}]}""" - new_schema_properties = client.register_schema(schemaregistry_group, schema_name, schema_str_new, serialization_type) + new_schema_properties = client.register_schema(schemaregistry_group, schema_name, schema_str_new, format) assert new_schema_properties.id is not None - assert new_schema_properties.location is not None assert new_schema_properties.version == schema_properties.version + 1 - assert new_schema_properties.serialization_type == "Avro" + assert new_schema_properties.format == "Avro" new_schema = client.get_schema(id=new_schema_properties.id) assert new_schema.properties.id != schema_properties.id assert new_schema.properties.id == new_schema_properties.id - assert new_schema.properties.location is not None - assert new_schema.content == schema_str_new + assert new_schema.schema_definition == schema_str_new assert new_schema.properties.version == schema_properties.version + 1 - assert new_schema.properties.serialization_type == "Avro" + assert new_schema.properties.format == "Avro" @SchemaRegistryPowerShellPreparer() def test_schema_same_twice(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): client = self.create_client(schemaregistry_endpoint) schema_name = self.get_resource_name('test-schema-twice') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"age","type":["int","null"]},{"name":"city","type":["string","null"]}]}""" - serialization_type = "Avro" - schema_properties = client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) - schema_properties_second = client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) + format = "Avro" + schema_properties = client.register_schema(schemaregistry_group, schema_name, schema_str, format) + schema_properties_second = client.register_schema(schemaregistry_group, schema_name, schema_str, format) assert schema_properties.id == schema_properties_second.id @SchemaRegistryPowerShellPreparer() def test_schema_negative_wrong_credential(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): credential = ClientSecretCredential(tenant_id="fake", client_id="fake", client_secret="fake") - client = SchemaRegistryClient(endpoint=schemaregistry_endpoint, credential=credential) + client = SchemaRegistryClient(fully_qualified_namespace=schemaregistry_endpoint, credential=credential) schema_name = self.get_resource_name('test-schema-negative') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" - serialization_type = "Avro" + format = "Avro" with pytest.raises(ClientAuthenticationError): - client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) + client.register_schema(schemaregistry_group, schema_name, schema_str, format) @SchemaRegistryPowerShellPreparer() def test_schema_negative_wrong_endpoint(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): client = self.create_client("nonexist.servicebus.windows.net") schema_name = self.get_resource_name('test-schema-nonexist') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" - serialization_type = "Avro" + format = "Avro" with pytest.raises(ServiceRequestError): - client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) + client.register_schema(schemaregistry_group, schema_name, schema_str, format) @SchemaRegistryPowerShellPreparer() def test_schema_negative_no_schema(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): diff --git a/sdk/schemaregistry/test-resources.json b/sdk/schemaregistry/test-resources.json index b6dd07b6f929b..590ce9afed54e 100644 --- a/sdk/schemaregistry/test-resources.json +++ b/sdk/schemaregistry/test-resources.json @@ -82,7 +82,7 @@ "type": "string", "value": "[variables('schemaRegistryGroup')]" }, - "SCHEMAREGISTRY_ENDPOINT": { + "SCHEMAREGISTRY_FULLY_QUALIFIED_NAMESPACE": { "type": "string", "value": "[variables('schemaRegistryEndpoint')]" }