Skip to content

Commit ce02f73

Browse files
authored
[SchemaRegistry] Update swagger and use autorest.python llc (Azure#19957)
* init llc based commit * sync schema registry based on llc * update sync test recordings * update response parsing part * update async code * rerecord * fix pylint * update core dependency * update shared requirements * fix python 27 * typo * update recordings * update recordings * azure core change * update azure-core dep * update shared req * update recordings * fix tests and dep * revert back serializer updates * review feedback * revert recording processors change and update records
1 parent 62116d4 commit ce02f73

35 files changed

+957
-1078
lines changed

sdk/schemaregistry/azure-schemaregistry-avroserializer/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Release History
22

3+
## 1.0.0b3 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
### Bugs Fixed
10+
11+
### Other Changes
12+
313
## 1.0.0b2 (2021-08-18)
414

515
This version and all future versions will require Python 2.7 or Python 3.6+, Python 3.5 is no longer supported.

sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Other Changes
1212

13+
- Updated azure-core dependency to 1.17.1.
14+
1315
## 1.0.0b2 (2021-08-17)
1416

1517
This version and all future versions will require Python 2.7 or Python 3.6+, Python 3.5 is no longer supported.

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

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,29 @@
2323
# IN THE SOFTWARE.
2424
#
2525
# --------------------------------------------------------------------------
26-
from typing import Any, Dict
27-
28-
from azure.core.pipeline import PipelineResponse
29-
30-
from .._generated.models import SchemaId as InternalSchemaId
3126
from ._schema import SchemaProperties, Schema
3227

3328

34-
def _parse_response_schema_id(pipeline_response, deserialized, response_headers): # pylint: disable=unused-argument
35-
# type: (PipelineResponse, InternalSchemaId, Dict[str, Any]) -> SchemaProperties
36-
"""
37-
38-
:param pipeline_response:
39-
:param deserialized:
40-
:param response_headers:
41-
:return:
42-
"""
43-
return SchemaProperties(schema_id=deserialized.id, **response_headers)
29+
def _parse_schema_properties_dict(response):
30+
return {
31+
'location': response.headers.get('location'),
32+
'location_by_id': response.headers.get('schema-id-location'),
33+
'schema_id': response.headers.get('schema-id'),
34+
'serialization_type': response.headers.get('serialization-type'),
35+
'version': int(response.headers.get('schema-version'))
36+
}
4437

4538

46-
def _parse_response_schema(pipeline_response, deserialized, response_headers): # pylint: disable=unused-argument
47-
# type: (PipelineResponse, str, Dict[str, Any]) -> Schema
48-
"""
39+
def _parse_response_schema_properties(response):
40+
properties_dict = _parse_schema_properties_dict(response)
41+
properties_dict['schema_id'] = response.json()["id"]
42+
return SchemaProperties(
43+
**properties_dict
44+
)
4945

50-
:param pipeline_response:
51-
:param deserialized:
52-
:param response_headers:
53-
:return:
54-
"""
5546

56-
return Schema(schema_content=deserialized, schema_properties=SchemaProperties(**response_headers))
47+
def _parse_response_schema(response):
48+
return Schema(
49+
schema_content=response.text(),
50+
schema_properties=SchemaProperties(**_parse_schema_properties_dict(response))
51+
)

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,18 @@ class SchemaProperties(object):
5151
:caption: SchemaProperties object.
5252
5353
"""
54+
5455
def __init__(
5556
self,
5657
schema_id=None,
5758
**kwargs
5859
):
5960
# type: (Optional[str], Any) -> None
60-
self.location = kwargs.get('Location')
61-
self.schema_id = schema_id or kwargs.get("X-Schema-Id")
62-
self.location_by_id = kwargs.get('X-Schema-Id-Location')
63-
self.serialization_type = kwargs.get('X-Schema-Type')
64-
self.version = kwargs.get('X-Schema-Version')
61+
self.schema_id = schema_id
62+
self.location = kwargs.get('location')
63+
self.location_by_id = kwargs.get('location_by_id')
64+
self.serialization_type = kwargs.get('serialization_type')
65+
self.version = kwargs.get('version')
6566

6667

6768
class Schema(object):
@@ -83,6 +84,7 @@ class Schema(object):
8384
:caption: Schema object.
8485
8586
"""
87+
8688
def __init__(
8789
self,
8890
schema_content,

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_generated/_azure_schema_registry.py

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,28 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9+
from copy import deepcopy
910
from typing import TYPE_CHECKING
1011

1112
from azure.core import PipelineClient
1213
from msrest import Deserializer, Serializer
1314

15+
from ._configuration import AzureSchemaRegistryConfiguration
16+
1417
if TYPE_CHECKING:
1518
# pylint: disable=unused-import,ungrouped-imports
16-
from typing import Any
19+
from typing import Any, Dict
1720

1821
from azure.core.credentials import TokenCredential
19-
20-
from ._configuration import AzureSchemaRegistryConfiguration
21-
from .operations import SchemaOperations
22-
from . import models
23-
22+
from azure.core.rest import HttpRequest, HttpResponse
2423

2524
class AzureSchemaRegistry(object):
26-
"""Azure Schema Registry is as a central schema repository for enterprise-level data infrastructure, complete with support for versioning and management.
25+
"""Azure Schema Registry is as a central schema repository, complete with support for versioning, management, compatibility checking, and RBAC.
2726
28-
:ivar schema: SchemaOperations operations
29-
:vartype schema: azure.schemaregistry._generated.operations.SchemaOperations
3027
:param credential: Credential needed for the client to connect to Azure.
3128
:type credential: ~azure.core.credentials.TokenCredential
32-
:param endpoint: The Schema Registry service endpoint, for example my-namespace.servicebus.windows.net.
29+
:param endpoint: The Schema Registry service endpoint, for example
30+
my-namespace.servicebus.windows.net.
3331
:type endpoint: str
3432
"""
3533

@@ -44,12 +42,47 @@ def __init__(
4442
self._config = AzureSchemaRegistryConfiguration(credential, endpoint, **kwargs)
4543
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
4644

47-
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
45+
client_models = {} # type: Dict[str, Any]
4846
self._serialize = Serializer(client_models)
4947
self._deserialize = Deserializer(client_models)
48+
self._serialize.client_side_validation = False
49+
50+
51+
def send_request(
52+
self,
53+
request, # type: HttpRequest
54+
**kwargs # type: Any
55+
):
56+
# type: (...) -> HttpResponse
57+
"""Runs the network request through the client's chained policies.
58+
59+
We have helper methods to create requests specific to this service in `azure.schemaregistry._generated.rest`.
60+
Use these helper methods to create the request you pass to this method.
61+
62+
>>> from azure.schemaregistry._generated.rest import schema
63+
>>> request = schema.build_get_by_id_request(schema_id, **kwargs)
64+
<HttpRequest [GET], url: '/$schemagroups/getSchemaById/{schema-id}'>
65+
>>> response = client.send_request(request)
66+
<HttpResponse: 200 OK>
67+
68+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
69+
70+
For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest`
71+
and pass it in.
72+
73+
:param request: The network request you want to make. Required.
74+
:type request: ~azure.core.rest.HttpRequest
75+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
76+
:return: The response of your network call. Does not do error handling on your response.
77+
:rtype: ~azure.core.rest.HttpResponse
78+
"""
5079

51-
self.schema = SchemaOperations(
52-
self._client, self._config, self._serialize, self._deserialize)
80+
request_copy = deepcopy(request)
81+
path_format_arguments = {
82+
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
83+
}
84+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
85+
return self._client.send_request(request_copy, **kwargs)
5386

5487
def close(self):
5588
# type: () -> None

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_generated/_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(
4747

4848
self.credential = credential
4949
self.endpoint = endpoint
50-
self.api_version = "2017-04"
50+
self.api_version = "2020-09-01-preview"
5151
self.credential_scopes = kwargs.pop('credential_scopes', ['https://eventhubs.azure.net/.default'])
5252
kwargs.setdefault('sdk_moniker', 'azureschemaregistry/{}'.format(VERSION))
5353
self._configure(**kwargs)

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_generated/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "1.0.0b1"
9+
VERSION = "1.0.0b3"

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_generated/aio/_azure_schema_registry.py

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from typing import Any, TYPE_CHECKING
9+
from copy import deepcopy
10+
from typing import Any, Awaitable, TYPE_CHECKING
1011

1112
from azure.core import AsyncPipelineClient
13+
from azure.core.rest import AsyncHttpResponse, HttpRequest
1214
from msrest import Deserializer, Serializer
1315

16+
from ._configuration import AzureSchemaRegistryConfiguration
17+
1418
if TYPE_CHECKING:
1519
# pylint: disable=unused-import,ungrouped-imports
16-
from azure.core.credentials_async import AsyncTokenCredential
17-
18-
from ._configuration import AzureSchemaRegistryConfiguration
19-
from .operations import SchemaOperations
20-
from .. import models
20+
from typing import Dict
2121

22+
from azure.core.credentials_async import AsyncTokenCredential
2223

23-
class AzureSchemaRegistry(object):
24-
"""Azure Schema Registry is as a central schema repository for enterprise-level data infrastructure, complete with support for versioning and management.
24+
class AzureSchemaRegistry:
25+
"""Azure Schema Registry is as a central schema repository, complete with support for versioning, management, compatibility checking, and RBAC.
2526
26-
:ivar schema: SchemaOperations operations
27-
:vartype schema: azure.schemaregistry._generated.aio.operations.SchemaOperations
2827
:param credential: Credential needed for the client to connect to Azure.
2928
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
30-
:param endpoint: The Schema Registry service endpoint, for example my-namespace.servicebus.windows.net.
29+
:param endpoint: The Schema Registry service endpoint, for example
30+
my-namespace.servicebus.windows.net.
3131
:type endpoint: str
3232
"""
3333

@@ -41,12 +41,46 @@ def __init__(
4141
self._config = AzureSchemaRegistryConfiguration(credential, endpoint, **kwargs)
4242
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)
4343

44-
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
44+
client_models = {} # type: Dict[str, Any]
4545
self._serialize = Serializer(client_models)
4646
self._deserialize = Deserializer(client_models)
47+
self._serialize.client_side_validation = False
48+
49+
50+
def send_request(
51+
self,
52+
request: HttpRequest,
53+
**kwargs: Any
54+
) -> Awaitable[AsyncHttpResponse]:
55+
"""Runs the network request through the client's chained policies.
56+
57+
We have helper methods to create requests specific to this service in `azure.schemaregistry._generated.rest`.
58+
Use these helper methods to create the request you pass to this method.
59+
60+
>>> from azure.schemaregistry._generated.rest import schema
61+
>>> request = schema.build_get_by_id_request(schema_id, **kwargs)
62+
<HttpRequest [GET], url: '/$schemagroups/getSchemaById/{schema-id}'>
63+
>>> response = await client.send_request(request)
64+
<AsyncHttpResponse: 200 OK>
65+
66+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
67+
68+
For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest`
69+
and pass it in.
70+
71+
:param request: The network request you want to make. Required.
72+
:type request: ~azure.core.rest.HttpRequest
73+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
74+
:return: The response of your network call. Does not do error handling on your response.
75+
:rtype: ~azure.core.rest.AsyncHttpResponse
76+
"""
4777

48-
self.schema = SchemaOperations(
49-
self._client, self._config, self._serialize, self._deserialize)
78+
request_copy = deepcopy(request)
79+
path_format_arguments = {
80+
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
81+
}
82+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
83+
return self._client.send_request(request_copy, **kwargs)
5084

5185
async def close(self) -> None:
5286
await self._client.close()

sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_generated/aio/_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(
4444

4545
self.credential = credential
4646
self.endpoint = endpoint
47-
self.api_version = "2017-04"
47+
self.api_version = "2020-09-01-preview"
4848
self.credential_scopes = kwargs.pop('credential_scopes', ['https://eventhubs.azure.net/.default'])
4949
kwargs.setdefault('sdk_moniker', 'azureschemaregistry/{}'.format(VERSION))
5050
self._configure(**kwargs)

0 commit comments

Comments
 (0)