Skip to content

Commit 710eab6

Browse files
authored
add name, group_name to schema_properties (Azure#24047)
1 parent fc7a164 commit 710eab6

File tree

9 files changed

+43
-12
lines changed

9 files changed

+43
-12
lines changed

sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This version and all future versions will require Python 3.6+. Python 2.7 is no
66

77
### Features Added
88

9+
- `group_name` and `name` have been added as instance variables to `SchemaProperties`.
10+
911
### Breaking Changes
1012

1113
### Bugs Fixed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
#
2525
# --------------------------------------------------------------------------
2626
from enum import Enum
27+
from azure.core import CaseInsensitiveEnumMeta
2728

2829

29-
class SchemaFormat(str, Enum):
30+
class SchemaFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta):
3031
"""
3132
Represents the format of the schema to be stored by the Schema Registry service.
3233
"""
@@ -35,7 +36,7 @@ class SchemaFormat(str, Enum):
3536
"""Represents the Apache Avro schema format."""
3637

3738

38-
class ApiVersion(str, Enum):
39+
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
3940
"""
4041
Represents the Schema Registry API version to use for requests.
4142
"""

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828

2929

3030
def _parse_schema_properties_dict(response):
31-
return {"id": response.headers.get("schema-id")}
31+
return {
32+
"id": response.headers.get("schema-id"),
33+
"group_name": response.headers.get("schema-group-name"),
34+
"name": response.headers.get("schema-name")
35+
}
3236

3337

3438
def _parse_response_schema_properties(response, format):

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,23 @@ class SchemaProperties(object):
3434
:vartype id: str
3535
:ivar format: Format for the schema being stored.
3636
:vartype format: ~azure.schemaregistry.SchemaFormat
37+
:ivar group_name: Schema group under which schema is stored.
38+
:vartype group_name: str
39+
:ivar name: Name of schema.
3740
"""
3841

3942
def __init__(self, **kwargs):
4043
# type: (Any) -> None
4144
self.id = kwargs.pop("id")
4245
self.format = kwargs.pop("format")
46+
self.group_name = kwargs.pop("group_name")
47+
self.name = kwargs.pop("name")
4348

4449
def __repr__(self):
45-
return "SchemaProperties(id={}, format={})".format(self.id, self.format)[:1024]
50+
return (
51+
f"SchemaProperties(id={self.id}, format={self.format}, "
52+
f"group_name={self.group_name}, name={self.name})"[:1024]
53+
)
4654

4755

4856
class Schema(object):

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ def get_schema_properties(
184184
as matched by schema definition comparison.
185185
186186
:param str group_name: Schema group under which schema should be registered.
187-
:param str name: Name of schema being registered.
188-
:param str definition: String representation of the schema being registered.
189-
:param format: Format for the schema being registered.
187+
:param str name: Name of schema for which properties should be retrieved.
188+
:param str definition: String representation of the schema for which properties should be retrieved.
189+
:param format: Format for the schema for which properties should be retrieved.
190190
:type format: Union[str, SchemaFormat]
191191
:rtype: ~azure.schemaregistry.SchemaProperties
192192
:raises: :class:`~azure.core.exceptions.HttpResponseError`

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ async def get_schema_properties(
182182
as matched by schema defintion comparison.
183183
184184
:param str group_name: Schema group under which schema should be registered.
185-
:param str name: Name of schema being registered.
186-
:param str definition: String representation of the schema being registered.
187-
:param format: Format for the schema being registered.
188-
:type format: Union[str, ~azure.schemaregistry.SchemaFormat]
185+
:param str name: Name of schema for which properties should be retrieved.
186+
:param str definition: String representation of the schema for which properties should be retrieved.
187+
:param format: Format for the schema for which properties should be retrieved.
188+
:type format: Union[str, SchemaFormat]
189189
:rtype: ~azure.schemaregistry.SchemaProperties
190190
:raises: :class:`~azure.core.exceptions.HttpResponseError`
191191

sdk/schemaregistry/azure-schemaregistry/samples/sync_samples/schema_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def get_schema_by_id(client, schema_id):
8080
print("Getting schema by id...")
8181
schema = client.get_schema(schema_id)
8282
print(
83-
"The schema string of schema id: {} string is {}".format(id, schema.definition)
83+
"The schema string of schema id: {} string is {}".format(schema_id, schema.definition)
8484
)
8585
print("Schema properties are {}".format(schema_id))
8686
return schema.definition

sdk/schemaregistry/azure-schemaregistry/tests/async_tests/test_schema_registry_async.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,15 @@ async def test_schema_basic_async(self, schemaregistry_fully_qualified_namespace
5858

5959
assert returned_schema.properties.id == schema_properties.id
6060
assert returned_schema.properties.format == "Avro"
61+
assert returned_schema.properties.group_name == schemaregistry_group
62+
assert returned_schema.properties.name == name
6163
assert returned_schema.definition == schema_str
6264

6365
returned_schema_properties = await client.get_schema_properties(schemaregistry_group, name, schema_str, format, logging_enable=True)
6466

6567
assert returned_schema_properties.id == schema_properties.id
68+
assert returned_schema.properties.group_name == schemaregistry_group
69+
assert returned_schema.properties.name == name
6670
assert returned_schema_properties.format == "Avro"
6771
await client._generated_client._config.credential.close()
6872

@@ -84,13 +88,17 @@ async def test_schema_update_async(self, schemaregistry_fully_qualified_namespac
8488

8589
assert new_schema_properties.id is not None
8690
assert new_schema_properties.format == "Avro"
91+
assert new_schema_properties.group_name == schemaregistry_group
92+
assert new_schema_properties.name == name
8793

8894
new_schema = await client.get_schema(schema_id=new_schema_properties.id)
8995

9096
assert new_schema.properties.id != schema_properties.id
9197
assert new_schema.properties.id == new_schema_properties.id
9298
assert new_schema.definition == schema_str_new
9399
assert new_schema.properties.format == "Avro"
100+
assert new_schema.properties.group_name == schemaregistry_group
101+
assert new_schema.properties.name == name
94102

95103
await client._generated_client._config.credential.close()
96104

sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@ def test_schema_basic(self, **kwargs):
5454

5555
assert returned_schema.properties.id == schema_properties.id
5656
assert returned_schema.properties.format == "Avro"
57+
assert returned_schema.properties.group_name == schemaregistry_group
58+
assert returned_schema.properties.name == name
5759
assert returned_schema.definition == schema_str
5860

5961
returned_schema_properties = client.get_schema_properties(schemaregistry_group, name, schema_str, format, logging_enable=True)
6062

6163
assert returned_schema_properties.id == schema_properties.id
6264
assert returned_schema_properties.format == "Avro"
65+
assert returned_schema.properties.group_name == schemaregistry_group
66+
assert returned_schema.properties.name == name
6367

6468
@SchemaRegistryEnvironmentVariableLoader()
6569
@recorded_by_proxy
@@ -80,13 +84,17 @@ def test_schema_update(self, **kwargs):
8084

8185
assert new_schema_properties.id is not None
8286
assert new_schema_properties.format == "Avro"
87+
assert new_schema_properties.group_name == schemaregistry_group
88+
assert new_schema_properties.name == name
8389

8490
new_schema = client.get_schema(schema_id=new_schema_properties.id)
8591

8692
assert new_schema.properties.id != schema_properties.id
8793
assert new_schema.properties.id == new_schema_properties.id
8894
assert new_schema.definition == schema_str_new
8995
assert new_schema.properties.format == "Avro"
96+
assert new_schema.properties.group_name == schemaregistry_group
97+
assert new_schema.properties.name == name
9098

9199
@SchemaRegistryEnvironmentVariableLoader()
92100
@recorded_by_proxy

0 commit comments

Comments
 (0)