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] remove schema prefix in params #21675

Merged
4 commits merged into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 4 additions & 8 deletions sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Release History

## 1.0.0 (2021-11-09)
## 1.0.0 (2021-11-10)

**Note:** This is the first stable release of our efforts to create a user-friendly and Pythonic client library for Azure Schema Registry.

### Features Added

- `SchemaRegistryClient` is the top-level client class interacting with the Azure Schema Registry Service. It provides three methods:
- `register_schema`: Store schema in the service by providing schema group name, schema name, schema format and schema definition.
- `register_schema`: Store schema in the service by providing schema group name, schema name, schema definition, and schema format.
- `get_schema`: Get schema definition and its properties by schema id.
- `get_schema_properties`: Get schema properties by providing schema group name, schema name, schema format and schema definition.
- `get_schema_properties`: Get schema properties by providing schema group name, schema name, schema definition, and schema format.
- `SchemaProperties` has the following instance variables: `id` and `format`:
- The type of `format` has been changed from `str` to `SchemaFormat`.
- `Schema` has the following properties: `properties` and `definition`.
Expand All @@ -21,11 +21,7 @@
- `version` instance variable in `SchemaProperties` has been removed.
- `schema_definition` instance variable in `Schema` has been renamed `definition`.
- `id` parameter in `get_schema` method on sync and async `SchemaRegistryClient` has been renamed `schema_id`.
- `name` parameter in `register_schema` and `get_schema_properties` methods on sync and async `SchemaRegistryClient` has been renamed `schema_name`.

### Bugs Fixed

### Other Changes
- `schema_definition` parameter in `register_schema` and `get_schema_properties` methods on sync and async `SchemaRegistryClient` has been renamed `definition`.

## 1.0.0b3 (2021-10-05)

Expand Down
14 changes: 7 additions & 7 deletions sdk/schemaregistry/azure-schemaregistry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ from azure.schemaregistry import SchemaRegistryClient
token_credential = DefaultAzureCredential()
fully_qualified_namespace = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE']
group_name = os.environ['SCHEMA_REGISTRY_GROUP']
schema_name = "your-schema-name"
name = "your-schema-name"
format = "Avro"
schema_definition = """
definition = """
{"namespace": "example.avro",
"type": "record",
"name": "User",
Expand All @@ -102,7 +102,7 @@ schema_definition = """

schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=fully_qualified_namespace, credential=token_credential)
with schema_registry_client:
schema_properties = schema_registry_client.register_schema(group_name, schema_name, schema_definition, format)
schema_properties = schema_registry_client.register_schema(group_name, name, definition, format)
id = schema_properties.id
```

Expand Down Expand Up @@ -140,9 +140,9 @@ from azure.schemaregistry import SchemaRegistryClient
token_credential = DefaultAzureCredential()
fully_qualified_namespace = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE']
group_name = os.environ['SCHEMA_REGISTRY_GROUP']
schema_name = "your-schema-name"
name = "your-schema-name"
format = "Avro"
schema_definition = """
definition = """
{"namespace": "example.avro",
"type": "record",
"name": "User",
Expand All @@ -156,7 +156,7 @@ schema_definition = """

schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=fully_qualified_namespace, credential=token_credential)
with schema_registry_client:
schema_properties = schema_registry_client.register_schema(group_name, schema_name, schema_definition, format)
schema_properties = schema_registry_client.register_schema(group_name, name, definition, format)
id = schema_properties.id
```

Expand Down Expand Up @@ -196,7 +196,7 @@ schema_registry_client = SchemaRegistryClient("your_fully_qualified_namespace",
Similarly, `logging_enable` can enable detailed logging for a single operation,
even when it isn't enabled for the client:
```py
schema_registry_client.get_schema(id, logging_enable=True)
schema_registry_client.get_schema(schema_id, logging_enable=True)
```

## Next steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SchemaRegistryClient(object):
:param credential: To authenticate managing the entities of the SchemaRegistry namespace.
:type credential: ~azure.core.credentials.TokenCredential
:keyword str api_version: The Schema Registry service API version to use for requests.
Default value and only accepted value currently is "2021-10".
Default value and only accepted value currently is "2021-10".

.. admonition:: Example:

Expand Down Expand Up @@ -91,8 +91,8 @@ def close(self):
def register_schema(
self,
group_name,
schema_name,
schema_definition,
name,
definition,
format,
**kwargs # pylint:disable=redefined-builtin
):
Expand All @@ -103,8 +103,8 @@ def register_schema(
schema is created at latest version + 1.

:param str group_name: Schema group under which schema should be registered.
:param str schema_name: Name of schema being registered.
:param str schema_definition: String representation of the schema being registered.
:param str name: Name of schema being registered.
:param str 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]
Expand All @@ -130,8 +130,8 @@ def register_schema(
http_request_kwargs = get_http_request_kwargs(kwargs)
request = schema_rest.build_register_request(
group_name=group_name,
schema_name=schema_name,
content=schema_definition,
schema_name=name,
content=definition,
content_type=kwargs.pop(
"content_type", "application/json; serialization={}".format(format)
),
Expand Down Expand Up @@ -173,8 +173,8 @@ def get_schema(self, schema_id, **kwargs):
def get_schema_properties(
self,
group_name,
schema_name,
schema_definition,
name,
definition,
format,
**kwargs # pylint:disable=redefined-builtin
):
Expand All @@ -184,8 +184,8 @@ def get_schema_properties(
as matched by schema definition comparison.

:param str group_name: Schema group under which schema should be registered.
:param str schema_name: Name of schema being registered.
:param str schema_definition: String representation of the schema being registered.
:param str name: Name of schema being registered.
:param str definition: String representation of the schema being registered.
:param format: Format for the schema being registered.
:type format: Union[str, SchemaFormat]
:rtype: ~azure.schemaregistry.SchemaProperties
Expand All @@ -210,8 +210,8 @@ def get_schema_properties(
http_request_kwargs = get_http_request_kwargs(kwargs)
request = schema_rest.build_query_id_by_content_request(
group_name=group_name,
schema_name=schema_name,
content=schema_definition,
schema_name=name,
content=definition,
content_type=kwargs.pop(
"content_type", "application/json; serialization={}".format(format)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SchemaRegistryClient(object):
:param credential: To authenticate managing the entities of the SchemaRegistry namespace.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:keyword str api_version: The Schema Registry service API version to use for requests.
Default value and only accepted value currently is "2021-10".
Default value and only accepted value currently is "2021-10".

.. admonition:: Example:

Expand Down Expand Up @@ -92,8 +92,8 @@ async def close(self) -> None:
async def register_schema(
self,
group_name: str,
schema_name: str,
schema_definition: str,
name: str,
definition: str,
format: Union[str, SchemaFormat], # pylint:disable=redefined-builtin
**kwargs: Any
) -> SchemaProperties:
Expand All @@ -103,8 +103,8 @@ async def register_schema(
schema is created at latest version + 1.

:param str group_name: Schema group under which schema should be registered.
:param str schema_name: Name of schema being registered.
:param str schema_definition: String representation of the schema being registered.
:param str name: Name of schema being registered.
:param str 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, ~azure.schemaregistry.SchemaFormat]
Expand All @@ -130,8 +130,8 @@ async def register_schema(
http_request_kwargs = get_http_request_kwargs(kwargs)
request = schema_rest.build_register_request(
group_name=group_name,
schema_name=schema_name,
content=schema_definition,
schema_name=name,
content=definition,
content_type=kwargs.pop(
"content_type", "application/json; serialization={}".format(format)
),
Expand Down Expand Up @@ -172,8 +172,8 @@ async def get_schema(self, schema_id: str, **kwargs: Any) -> Schema:
async def get_schema_properties(
self,
group_name: str,
schema_name: str,
schema_definition: str,
name: str,
definition: str,
format: Union[str, SchemaFormat], # pylint:disable=redefined-builtin
**kwargs: Any
) -> SchemaProperties:
Expand All @@ -182,8 +182,8 @@ async def get_schema_properties(
as matched by schema defintion comparison.

:param str group_name: Schema group under which schema should be registered.
:param str schema_name: Name of schema being registered.
:param str schema_definition: String representation of the schema being registered.
:param str name: Name of schema being registered.
:param str definition: String representation of the schema being registered.
:param format: Format for the schema being registered.
:type format: Union[str, ~azure.schemaregistry.SchemaFormat]
:rtype: ~azure.schemaregistry.SchemaProperties
Expand All @@ -208,8 +208,8 @@ async def get_schema_properties(
http_request_kwargs = get_http_request_kwargs(kwargs)
request = schema_rest.build_query_id_by_content_request(
group_name=group_name,
schema_name=schema_name,
content=schema_definition,
schema_name=name,
content=definition,
content_type=kwargs.pop(
"content_type", "application/json; serialization={}".format(format)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def create_client():
async def register_schema(schema_registry_client):
# [START register_schema_async]
GROUP_NAME = os.environ["SCHEMAREGISTRY_GROUP"]
SCHEMA_NAME = "your-schema-name"
NAME = "your-schema-name"
FORMAT = "Avro"
SCHEMA_JSON = {
"namespace": "example.avro",
Expand All @@ -73,9 +73,9 @@ async def register_schema(schema_registry_client):
{"name": "favorite_color", "type": ["string", "null"]},
],
}
SCHEMA_DEFINITION = json.dumps(SCHEMA_JSON, separators=(",", ":"))
DEFINITION = json.dumps(SCHEMA_JSON, separators=(",", ":"))
schema_properties = await schema_registry_client.register_schema(
GROUP_NAME, SCHEMA_NAME, SCHEMA_DEFINITION, FORMAT
GROUP_NAME, NAME, DEFINITION, FORMAT
)
schema_id = schema_properties.id
# [END register_schema_async]
Expand All @@ -96,7 +96,7 @@ async def get_schema(schema_registry_client, schema_id):
async def get_schema_id(schema_registry_client):
# [START get_schema_id_async]
group_name = os.environ["SCHEMAREGISTRY_GROUP"]
schema_name = "your-schema-name"
name = "your-schema-name"
format = "Avro"
schema_json = {
"namespace": "example.avro",
Expand All @@ -108,9 +108,9 @@ async def get_schema_id(schema_registry_client):
{"name": "favorite_color", "type": ["string", "null"]},
],
}
schema_definition = json.dumps(schema_json, separators=(",", ":"))
definition = json.dumps(schema_json, separators=(",", ":"))
schema_properties = await schema_registry_client.get_schema_properties(
group_name, schema_name, schema_definition, format
group_name, name, definition, format
)
schema_id = schema_properties.id
# [END get_schema_id_async]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

SCHEMAREGISTRY_FQN = os.environ["SCHEMAREGISTRY_FULLY_QUALIFIED_NAMESPACE"]
GROUP_NAME = os.environ["SCHEMAREGISTRY_GROUP"]
SCHEMA_NAME = "your-schema-name"
NAME = "your-schema-name"
FORMAT = SchemaFormat.AVRO
SCHEMA_JSON = {
"namespace": "example.avro",
Expand All @@ -43,13 +43,13 @@
{"name": "favorite_color", "type": ["string", "null"]},
],
}
SCHEMA_STRING = json.dumps(SCHEMA_JSON, separators=(",", ":"))
DEFINITION = json.dumps(SCHEMA_JSON, separators=(",", ":"))


async def register_schema(client, group_name, schema_name, schema_string, format):
async def register_schema(client, group_name, name, definition, format):
print("Registering schema...")
schema_properties = await client.register_schema(
group_name, schema_name, schema_string, format
group_name, name, definition, format
)
print("Schema registered, returned schema id is {}".format(schema_properties.id))
print("Schema properties are {}".format(schema_properties))
Expand All @@ -68,10 +68,10 @@ async def get_schema_by_id(client, schema_id):
return schema.definition


async def get_schema_id(client, group_name, schema_name, schema_string, format):
async def get_schema_id(client, group_name, name, definition, format):
print("Getting schema id...")
schema_properties = await client.get_schema_properties(
group_name, schema_name, schema_string, format
group_name, name, definition, format
)
print("The schema id is: {}".format(schema_properties.id))
print("Schema properties are {}".format(schema_properties))
Expand All @@ -85,11 +85,11 @@ async def main():
)
async with token_credential, schema_registry_client:
schema_id = await register_schema(
schema_registry_client, GROUP_NAME, SCHEMA_NAME, SCHEMA_STRING, FORMAT
schema_registry_client, GROUP_NAME, NAME, DEFINITION, FORMAT
)
schema_str = await get_schema_by_id(schema_registry_client, schema_id)
schema_id = await get_schema_id(
schema_registry_client, GROUP_NAME, SCHEMA_NAME, SCHEMA_STRING, FORMAT
schema_registry_client, GROUP_NAME, NAME, DEFINITION, FORMAT
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create_client():
def register_schema(schema_registry_client):
# [START register_schema_sync]
GROUP_NAME = os.environ["SCHEMAREGISTRY_GROUP"]
SCHEMA_NAME = "your-schema-name"
NAME = "your-schema-name"
FORMAT = "Avro"
SCHEMA_JSON = {
"namespace": "example.avro",
Expand All @@ -72,9 +72,9 @@ def register_schema(schema_registry_client):
{"name": "favorite_color", "type": ["string", "null"]},
],
}
SCHEMA_DEFINITION = json.dumps(SCHEMA_JSON, separators=(",", ":"))
DEFINTION = json.dumps(SCHEMA_JSON, separators=(",", ":"))
schema_properties = schema_registry_client.register_schema(
GROUP_NAME, SCHEMA_NAME, SCHEMA_DEFINITION, FORMAT
GROUP_NAME, NAME, DEFINTION, FORMAT
)
schema_id = schema_properties.id
# [END register_schema_sync]
Expand All @@ -95,7 +95,7 @@ def get_schema(schema_registry_client, schema_id):
def get_schema_id(schema_registry_client):
# [START get_schema_id_sync]
group_name = os.environ["SCHEMAREGISTRY_GROUP"]
schema_name = "your-schema-name"
name = "your-schema-name"
format = "Avro"
schema_json = {
"namespace": "example.avro",
Expand All @@ -107,9 +107,9 @@ def get_schema_id(schema_registry_client):
{"name": "favorite_color", "type": ["string", "null"]},
],
}
schema_definition = json.dumps(schema_json, separators=(",", ":"))
definition = json.dumps(schema_json, separators=(",", ":"))
schema_properties = schema_registry_client.get_schema_properties(
group_name, schema_name, schema_definition, format
group_name, name, definition, format
)
schema_id = schema_properties.id
# [END get_schema_id_sync]
Expand Down
Loading