azure.schemaregistry.aio package¶
-
class
azure.schemaregistry.aio.
SchemaRegistryClient
(fully_qualified_namespace: str, credential: AsyncTokenCredential, **kwargs: Any)[source]¶ SchemaRegistryClient is as a central schema repository for enterprise-level data infrastructure, complete with support for versioning and management.
- Parameters
fully_qualified_namespace (str) – The Schema Registry service fully qualified host name, for example my-namespace.servicebus.windows.net.
credential (AsyncTokenCredential) – To authenticate to manage the entities of the SchemaRegistry namespace.
Example:
SCHEMAREGISTRY_FQN = os.environ['SCHEMAREGISTRY_FULLY_QUALIFIED_NAMESPACE'] token_credential = DefaultAzureCredential() schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=SCHEMAREGISTRY_FQN, credential=token_credential)
-
async
close
() → None[source]¶ This method is to close the sockets opened by the client. It need not be used when using with a context manager.
-
async
get_schema
(id: str, **kwargs: Any) → azure.schemaregistry._common._schema.Schema[source]¶ Gets a registered schema by its unique ID. Azure Schema Registry guarantees that ID is unique within a namespace.
Example:
schema = await schema_registry_client.get_schema(id) schema_definition = schema.schema_definition
-
async
get_schema_properties
(group_name: str, name: str, schema_definition: str, format: str, **kwargs: Any) → azure.schemaregistry._common._schema.SchemaProperties[source]¶ Gets the ID referencing an existing schema within the specified schema group, as matched by schema defintion comparison.
- Parameters
group_name (str) – Schema group under which schema should be registered.
name (str) – Name of schema being registered.
schema_definition (str) – String representation of the schema being registered.
format (Union[str, SchemaFormat]) – Format for the schema being registered.
- Return type
Example:
schema_properties = await schema_registry_client.get_schema_properties(group_name, name, schema_definition, format) schema_id = schema_properties.id
-
async
register_schema
(group_name: str, name: str, schema_definition: str, format: str, **kwargs: Any) → azure.schemaregistry._common._schema.SchemaProperties[source]¶ 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.
- Parameters
group_name (str) – Schema group under which schema should be registered.
name (str) – Name of schema being registered.
schema_definition (str) – String representation of the schema being registered.
format (Union[str, SchemaFormat]) – Format for the schema being registered. For now Avro is the only supported schema format by the service.
- Return type
Example:
GROUP_NAME = os.environ['SCHEMAREGISTRY_GROUP'] NAME = 'your-schema-name' 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