Skip to content

Commit c18004e

Browse files
authored
[SchemaRegistry] update format type (Azure#21647)
1 parent 75de5ae commit c18004e

12 files changed

+62
-60
lines changed

sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
- `register_schema`: Store schema in the service by providing schema group name, schema name, schema format and schema definition.
1111
- `get_schema`: Get schema definition and its properties by schema id.
1212
- `get_schema_properties`: Get schema properties by providing schema group name, schema name, schema format and schema definition.
13-
- `SchemaProperties` has the following instance variables: `id` and `format`.
13+
- `SchemaProperties` has the following instance variables: `id` and `format`:
14+
- The type of `format` has been changed from `str` to `SchemaFormat`.
1415
- `Schema` has the following properties: `properties` and `definition`.
1516
- `SchemaFormat` provides the schema format to be stored by the service. Currently, the only supported format is `Avro`.
1617
- `api_version` has been added as a keyword arg to the sync and async `SchemaRegistryClient` constructors.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SchemaFormat(str, Enum):
3131
Represents the format of the schema to be stored by the Schema Registry service.
3232
"""
3333

34-
AVRO = "avro"
34+
AVRO = "Avro"
3535
"""Represents the Apache Avro schema format."""
3636

3737

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#
2525
# --------------------------------------------------------------------------
2626
from ._schema import SchemaProperties, Schema
27+
from ._constants import SchemaFormat
2728

2829

2930
def _parse_schema_properties_dict(response):
@@ -33,15 +34,15 @@ def _parse_schema_properties_dict(response):
3334
def _parse_response_schema_properties(response, format):
3435
# pylint:disable=redefined-builtin
3536
properties_dict = _parse_schema_properties_dict(response)
36-
properties_dict["format"] = format
37+
properties_dict["format"] = SchemaFormat(format)
3738
return SchemaProperties(**properties_dict)
3839

3940

4041
def _parse_response_schema(response):
4142
# pylint:disable=redefined-builtin
4243
schema_props_dict = _parse_schema_properties_dict(response)
4344
format = response.headers.get("content-type").split("serialization=")[1]
44-
schema_props_dict["format"] = format
45+
schema_props_dict["format"] = SchemaFormat(format)
4546
return Schema(
4647
definition=response.text(), properties=SchemaProperties(**schema_props_dict)
4748
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SchemaProperties(object):
3333
:ivar id: References specific schema in registry namespace.
3434
:vartype id: str
3535
:ivar format: Format for the schema being stored.
36-
:vartype format: str
36+
:vartype format: ~azure.schemaregistry.SchemaFormat
3737
"""
3838

3939
def __init__(self, **kwargs):

sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_basic_async.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interactions:
1717
string: ''
1818
headers:
1919
content-length: '0'
20-
date: Fri, 05 Nov 2021 23:19:13 GMT
20+
date: Mon, 08 Nov 2021 19:21:34 GMT
2121
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482/versions/1?api-version=2021-10
2222
schema-group-name: swathip-test-schema
2323
schema-id: 1051144b7fa7490ba07184606fd25d21
@@ -45,7 +45,7 @@ interactions:
4545
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"]}]}'
4646
headers:
4747
content-type: application/json;serialization=Avro
48-
date: Fri, 05 Nov 2021 23:19:14 GMT
48+
date: Mon, 08 Nov 2021 19:21:34 GMT
4949
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482/versions/1?api-version=2021-10
5050
schema-group-name: swathip-test-schema
5151
schema-id: 1051144b7fa7490ba07184606fd25d21
@@ -78,7 +78,7 @@ interactions:
7878
string: ''
7979
headers:
8080
content-length: '0'
81-
date: Fri, 05 Nov 2021 23:19:14 GMT
81+
date: Mon, 08 Nov 2021 19:21:35 GMT
8282
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482/versions/1?api-version=2021-10
8383
schema-group-name: swathip-test-schema
8484
schema-id: 1051144b7fa7490ba07184606fd25d21

sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_negative_no_schema_async.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ interactions:
1111
response:
1212
body:
1313
string: '{"Code":400,"Detail":"SubCode=40000, UnknownType:The request is invalid.
14-
[MGResponseHttpError=BadRequest]. TrackingId:6dcade5a-075b-4faf-87ca-7d4d56fa0939_G10,
14+
[MGResponseHttpError=BadRequest]. TrackingId:22b913ba-a4d9-4799-8f94-a6c248869d77_G28,
1515
SystemTracker:fake_resource.servicebus.windows.net/:$schemaGroups\/$schemas\/a,
16-
Timestamp:2021-11-05T23:19:16"}'
16+
Timestamp:2021-11-08T19:21:36"}'
1717
headers:
1818
content-type: application/json
19-
date: Fri, 05 Nov 2021 23:19:15 GMT
19+
date: Mon, 08 Nov 2021 19:21:35 GMT
2020
server: Microsoft-HTTPAPI/2.0
2121
strict-transport-security: max-age=31536000
2222
transfer-encoding: chunked
@@ -36,11 +36,11 @@ interactions:
3636
response:
3737
body:
3838
string: '{"Code":404,"Detail":"Schema id aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa does
39-
not exist. TrackingId:53ed334b-e1b4-4d3b-a2bb-2622a9e45ca7_G10, SystemTracker:fake_resource.servicebus.windows.net/:$schemaGroups\/$schemas\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
40-
Timestamp:2021-11-05T23:19:16"}'
39+
not exist. TrackingId:fae7aad8-cc69-417b-b713-86c4760011ed_G28, SystemTracker:fake_resource.servicebus.windows.net/:$schemaGroups\/$schemas\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
40+
Timestamp:2021-11-08T19:21:36"}'
4141
headers:
4242
content-type: application/json
43-
date: Fri, 05 Nov 2021 23:19:16 GMT
43+
date: Mon, 08 Nov 2021 19:21:36 GMT
4444
server: Microsoft-HTTPAPI/2.0
4545
strict-transport-security: max-age=31536000
4646
transfer-encoding: chunked

sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_same_twice_async.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interactions:
1717
string: ''
1818
headers:
1919
content-length: '0'
20-
date: Fri, 05 Nov 2021 23:19:24 GMT
20+
date: Mon, 08 Nov 2021 19:21:43 GMT
2121
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-twice-async7bfd16a1/versions/1?api-version=2021-10
2222
schema-group-name: swathip-test-schema
2323
schema-id: 3ad6620ea8f240059625d5922a912de0
@@ -49,7 +49,7 @@ interactions:
4949
string: ''
5050
headers:
5151
content-length: '0'
52-
date: Fri, 05 Nov 2021 23:19:25 GMT
52+
date: Mon, 08 Nov 2021 19:21:44 GMT
5353
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-twice-async7bfd16a1/versions/1?api-version=2021-10
5454
schema-group-name: swathip-test-schema
5555
schema-id: 3ad6620ea8f240059625d5922a912de0

sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_update_async.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ interactions:
1717
string: ''
1818
headers:
1919
content-length: '0'
20-
date: Fri, 05 Nov 2021 23:19:26 GMT
21-
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/1?api-version=2021-10
20+
date: Mon, 08 Nov 2021 19:21:46 GMT
21+
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/5?api-version=2021-10
2222
schema-group-name: swathip-test-schema
23-
schema-id: 5fa32292f1de4c658f589e8173452694
24-
schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/$schemas/5fa32292f1de4c658f589e8173452694?api-version=2021-10
23+
schema-id: 1469921a33fa425d99f8a6e187e8c97e
24+
schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/$schemas/1469921a33fa425d99f8a6e187e8c97e?api-version=2021-10
2525
schema-name: test-schema-update-async24591503
26-
schema-version: '1'
26+
schema-version: '5'
2727
schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update-async24591503/versions?api-version=2021-10
2828
server: Microsoft-HTTPAPI/2.0
2929
strict-transport-security: max-age=31536000
@@ -49,13 +49,13 @@ interactions:
4949
string: ''
5050
headers:
5151
content-length: '0'
52-
date: Fri, 05 Nov 2021 23:19:27 GMT
53-
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/2?api-version=2021-10
52+
date: Mon, 08 Nov 2021 19:21:46 GMT
53+
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/6?api-version=2021-10
5454
schema-group-name: swathip-test-schema
55-
schema-id: 0c1c191b9b544683b062fb61762ca796
56-
schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/$schemas/0c1c191b9b544683b062fb61762ca796?api-version=2021-10
55+
schema-id: d80c13495d934eefb2f7653563ac63ff
56+
schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/$schemas/d80c13495d934eefb2f7653563ac63ff?api-version=2021-10
5757
schema-name: test-schema-update-async24591503
58-
schema-version: '2'
58+
schema-version: '6'
5959
schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update-async24591503/versions?api-version=2021-10
6060
server: Microsoft-HTTPAPI/2.0
6161
strict-transport-security: max-age=31536000
@@ -71,25 +71,25 @@ interactions:
7171
User-Agent:
7272
- azsdk-python-azureschemaregistry/1.0.0 Python/3.9.0 (Windows-10-10.0.22000-SP0)
7373
method: GET
74-
uri: https://fake_resource.servicebus.windows.net/$schemaGroups/$schemas/0c1c191b9b544683b062fb61762ca796?api-version=2021-10
74+
uri: https://fake_resource.servicebus.windows.net/$schemaGroups/$schemas/d80c13495d934eefb2f7653563ac63ff?api-version=2021-10
7575
response:
7676
body:
7777
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"]}]}'
7878
headers:
7979
content-type: application/json;serialization=Avro
80-
date: Fri, 05 Nov 2021 23:19:28 GMT
81-
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/2?api-version=2021-10
80+
date: Mon, 08 Nov 2021 19:21:47 GMT
81+
location: https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/6?api-version=2021-10
8282
schema-group-name: swathip-test-schema
83-
schema-id: 0c1c191b9b544683b062fb61762ca796
84-
schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/$schemas/0c1c191b9b544683b062fb61762ca796?api-version=2021-10
83+
schema-id: d80c13495d934eefb2f7653563ac63ff
84+
schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/$schemas/d80c13495d934eefb2f7653563ac63ff?api-version=2021-10
8585
schema-name: test-schema-update-async24591503
86-
schema-version: '2'
86+
schema-version: '6'
8787
schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update-async24591503/versions?api-version=2021-10
8888
server: Microsoft-HTTPAPI/2.0
8989
strict-transport-security: max-age=31536000
9090
transfer-encoding: chunked
9191
status:
9292
code: 200
9393
message: OK
94-
url: https://swathip-test-eventhubs.servicebus.windows.net/$schemaGroups/$schemas/0c1c191b9b544683b062fb61762ca796?api-version=2021-10
94+
url: https://swathip-test-eventhubs.servicebus.windows.net/$schemaGroups/$schemas/d80c13495d934eefb2f7653563ac63ff?api-version=2021-10
9595
version: 1

sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_basic.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interactions:
2323
content-length:
2424
- '0'
2525
date:
26-
- Fri, 05 Nov 2021 23:18:55 GMT
26+
- Mon, 08 Nov 2021 19:21:14 GMT
2727
location:
2828
- https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88/versions/1?api-version=2021-10
2929
schema-group-name:
@@ -65,7 +65,7 @@ interactions:
6565
content-type:
6666
- application/json;serialization=Avro
6767
date:
68-
- Fri, 05 Nov 2021 23:18:56 GMT
68+
- Mon, 08 Nov 2021 19:21:15 GMT
6969
location:
7070
- https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88/versions/1?api-version=2021-10
7171
schema-group-name:
@@ -113,7 +113,7 @@ interactions:
113113
content-length:
114114
- '0'
115115
date:
116-
- Fri, 05 Nov 2021 23:18:56 GMT
116+
- Mon, 08 Nov 2021 19:21:15 GMT
117117
location:
118118
- https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88/versions/1?api-version=2021-10
119119
schema-group-name:

sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_negative_no_schema.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ interactions:
1515
response:
1616
body:
1717
string: '{"Code":400,"Detail":"SubCode=40000, UnknownType:The request is invalid.
18-
[MGResponseHttpError=BadRequest]. TrackingId:be206517-31bc-461b-b04f-220858a1b1de_G29,
18+
[MGResponseHttpError=BadRequest]. TrackingId:452ca5f5-1a75-4f0e-89a1-ed2d4db27174_G21,
1919
SystemTracker:fake_resource.servicebus.windows.net/:$schemaGroups\/$schemas\/a,
20-
Timestamp:2021-11-05T23:18:58"}'
20+
Timestamp:2021-11-08T19:21:17"}'
2121
headers:
2222
content-type:
2323
- application/json
2424
date:
25-
- Fri, 05 Nov 2021 23:18:57 GMT
25+
- Mon, 08 Nov 2021 19:21:17 GMT
2626
server:
2727
- Microsoft-HTTPAPI/2.0
2828
strict-transport-security:
@@ -48,13 +48,13 @@ interactions:
4848
response:
4949
body:
5050
string: '{"Code":404,"Detail":"Schema id aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa does
51-
not exist. TrackingId:223fc057-1866-470a-928f-ff6f27c259b8_G29, SystemTracker:fake_resource.servicebus.windows.net/:$schemaGroups\/$schemas\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
52-
Timestamp:2021-11-05T23:18:58"}'
51+
not exist. TrackingId:7f75b398-997b-4d32-ad30-f0d9b084e27b_G21, SystemTracker:fake_resource.servicebus.windows.net/:$schemaGroups\/$schemas\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
52+
Timestamp:2021-11-08T19:21:18"}'
5353
headers:
5454
content-type:
5555
- application/json
5656
date:
57-
- Fri, 05 Nov 2021 23:18:57 GMT
57+
- Mon, 08 Nov 2021 19:21:17 GMT
5858
server:
5959
- Microsoft-HTTPAPI/2.0
6060
strict-transport-security:

0 commit comments

Comments
 (0)