Skip to content
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
2 changes: 1 addition & 1 deletion sdk/eventhub/azure-eventhub/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Breaking Changes

- `from_message_data` and `__message_data__` on `EventData` have been renamed `from_message_content` and `__message_content__` for interoperability with the Schema Registry Avro Encoder library. The `data` parameter has been renamed to `content`.
- `from_message_data` on `EventData` has been renamed `from_message_content` for interoperability with the Schema Registry Avro Encoder library. The `data` parameter has been renamed to `content`.

## 5.9.0b1 (2022-02-09)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Features Added

- `request_kwargs` has been added to `encode` and `decode` on `AvroEncoder` as an optional parameter to be passed into client requests.
- `request_options` has been added to `encode` and `decode` on `AvroEncoder` as an optional parameter to be passed into client requests.
- The size of the current schema/schema ID caches will be logged at an info level when a new entry has been added.

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def encode(
*,
schema: str,
message_type: Optional[Callable] = None,
request_kwargs: Dict[str, Any] = None,
request_options: Dict[str, Any] = None,
**kwargs: Any,
) -> Union[MessageType, MessageContent]:
"""
Expand All @@ -157,8 +157,8 @@ def encode(
`(content: bytes, content_type: str, **kwargs) -> MessageType`, where `content` and `content_type`
are positional parameters.
:paramtype message_type: Callable or None
:keyword request_kwargs: The keyword arguments for http requests to be passed to the client.
:paramtype request_kwargs: Dict[str, Any]
:keyword request_options: The keyword arguments for http requests to be passed to the client.
:paramtype request_options: Dict[str, Any]
:rtype: MessageType or MessageContent
:raises ~azure.schemaregistry.encoder.avroencoder.exceptions.SchemaParseError:
Indicates an issue with parsing schema.
Expand All @@ -176,8 +176,8 @@ def encode(
).raise_with_traceback()

cache_misses = self._get_schema_id.cache_info().misses # pylint: disable=no-value-for-parameter
request_kwargs = request_kwargs or {}
schema_id = self._get_schema_id(schema_fullname, raw_input_schema, **request_kwargs)
request_options = request_options or {}
schema_id = self._get_schema_id(schema_fullname, raw_input_schema, **request_options)
new_cache_misses = self._get_schema_id.cache_info().misses # pylint: disable=no-value-for-parameter
if new_cache_misses > cache_misses:
cache_size = self._get_schema_id.cache_info().currsize # pylint: disable=no-value-for-parameter
Expand Down Expand Up @@ -237,7 +237,7 @@ def decode(
message: Union[MessageType, MessageContent],
*,
readers_schema: Optional[str] = None,
request_kwargs: Dict[str, Any] = None,
request_options: Dict[str, Any] = None,
**kwargs, # pylint: disable=unused-argument
) -> Dict[str, Any]:
"""
Expand All @@ -254,8 +254,8 @@ def decode(
:type message: MessageType or MessageContent
:keyword readers_schema: An optional reader's schema as defined by the Apache Avro specification.
:paramtype readers_schema: str or None
:keyword request_kwargs: The keyword arguments for http requests to be passed to the client.
:paramtype request_kwargs: Dict[str, Any]
:keyword request_options: The keyword arguments for http requests to be passed to the client.
:paramtype request_options: Dict[str, Any]
:rtype: Dict[str, Any]
:raises ~azure.schemaregistry.encoder.avroencoder.exceptions.SchemaParseError:
Indicates an issue with parsing schema.
Expand Down Expand Up @@ -284,8 +284,8 @@ def decode(
schema_id = content_type.split("+")[1]

cache_misses = self._get_schema.cache_info().misses # pylint: disable=no-value-for-parameter
request_kwargs = request_kwargs or {}
schema_definition = self._get_schema(schema_id, **request_kwargs)
request_options = request_options or {}
schema_definition = self._get_schema(schema_id, **request_options)
new_cache_misses = self._get_schema.cache_info().misses # pylint: disable=no-value-for-parameter
if new_cache_misses > cache_misses:
cache_size = self._get_schema.cache_info().currsize # pylint: disable=no-value-for-parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async def encode(
*,
schema: str,
message_type: Optional[Callable] = None,
request_kwargs: Dict[str, Any] = None,
request_options: Dict[str, Any] = None,
**kwargs: Any,
) -> Union[MessageType, MessageContent]:

Expand All @@ -154,8 +154,8 @@ async def encode(
`(content: bytes, content_type: str, **kwargs) -> MessageType`, where `content` and `content_type`
are positional parameters.
:paramtype message_type: Callable or None
:keyword request_kwargs: The keyword arguments for http requests to be passed to the client.
:paramtype request_kwargs: Dict[str, Any]
:keyword request_options: The keyword arguments for http requests to be passed to the client.
:paramtype request_options: Dict[str, Any]
:rtype: MessageType or MessageContent
:raises ~azure.schemaregistry.encoder.avroencoder.exceptions.SchemaParseError:
Indicates an issue with parsing schema.
Expand All @@ -173,8 +173,8 @@ async def encode(
).raise_with_traceback()

cache_misses = self._get_schema_id.cache_info().misses # pylint: disable=no-value-for-parameter disable=no-member
request_kwargs = request_kwargs or {}
schema_id = await self._get_schema_id(schema_fullname, raw_input_schema, **request_kwargs)
request_options = request_options or {}
schema_id = await self._get_schema_id(schema_fullname, raw_input_schema, **request_options)
new_cache_misses = self._get_schema_id.cache_info().misses # pylint: disable=no-value-for-parameter disable=no-member
if new_cache_misses > cache_misses:
cache_size = self._get_schema_id.cache_info().currsize # pylint: disable=no-value-for-parameter disable=no-member
Expand Down Expand Up @@ -230,7 +230,7 @@ async def decode(
message: Union[MessageType, MessageContent],
*,
readers_schema: Optional[str] = None,
request_kwargs: Dict[str, Any] = None,
request_options: Dict[str, Any] = None,
**kwargs, # pylint: disable=unused-argument
) -> Dict[str, Any]:
"""
Expand All @@ -247,8 +247,8 @@ async def decode(
:type message: MessageType or MessageContent
:keyword readers_schema: An optional reader's schema as defined by the Apache Avro specification.
:paramtype readers_schema: str or None
:keyword request_kwargs: The keyword arguments for http requests to be passed to the client.
:paramtype request_kwargs: Dict[str, Any]
:keyword request_options: The keyword arguments for http requests to be passed to the client.
:paramtype request_options: Dict[str, Any]
:rtype: Dict[str, Any]
:raises ~azure.schemaregistry.encoder.avroencoder.exceptions.SchemaParseError:
Indicates an issue with parsing schema.
Expand Down Expand Up @@ -277,8 +277,8 @@ async def decode(
schema_id = content_type.split("+")[1]

cache_misses = self._get_schema.cache_info().misses # pylint: disable=no-value-for-parameter disable=no-member
request_kwargs = request_kwargs or {}
schema_definition = await self._get_schema(schema_id, **request_kwargs)
request_options = request_options or {}
schema_definition = await self._get_schema(schema_id, **request_options)
new_cache_misses = self._get_schema.cache_info().misses # pylint: disable=no-value-for-parameter disable=no-member
if new_cache_misses > cache_misses:
cache_size = self._get_schema.cache_info().currsize # pylint: disable=no-value-for-parameter disable=no-member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ interactions:
content-length:
- '0'
date:
- Tue, 01 Mar 2022 02:26:49 GMT
- Thu, 03 Mar 2022 22:32:53 GMT
location:
- https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/example.avro.User/versions/1?api-version=2021-10
- https://swathip-test-eh-westus.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/example.avro.User/versions/1?api-version=2021-10
schema-group-name:
- swathip-test-schema
schema-id:
- 08a5597bec1a47188aa3e0c99a69f5a3
- bc24cde138814b81b1479d73249d849d
schema-id-location:
- https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/$schemas/08a5597bec1a47188aa3e0c99a69f5a3?api-version=2021-10
- https://swathip-test-eh-westus.servicebus.windows.net:443/$schemagroups/$schemas/bc24cde138814b81b1479d73249d849d?api-version=2021-10
schema-name:
- example.avro.User
schema-version:
- '1'
schema-versions-location:
- https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/example.avro.User/versions?api-version=2021-10
- https://swathip-test-eh-westus.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/example.avro.User/versions?api-version=2021-10
server:
- Microsoft-HTTPAPI/2.0
strict-transport-security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,23 @@ def test_basic_sr_avro_encoder_decode_readers_schema(self, schemaregistry_fully_
decoded_content = sr_avro_encoder.decode(encoded_content_dict, readers_schema=readers_schema_change_name)

@SchemaRegistryPowerShellPreparer()
def test_basic_sr_avro_encoder_with_request_kwargs(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs):
def test_basic_sr_avro_encoder_with_request_options(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs):
sr_client = self.create_basic_client(SchemaRegistryClient, fully_qualified_namespace=schemaregistry_fully_qualified_namespace)
sr_avro_encoder = AvroEncoder(client=sr_client, group_name=schemaregistry_group, auto_register_schemas=True)

schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}"""

dict_content = {"name": u"Ben", "favorite_number": 7, "favorite_color": u"red"}
with pytest.raises(TypeError) as e:
encoded_message_content = sr_avro_encoder.encode(dict_content, schema=schema_str, request_kwargs={"fake_kwarg": True})
encoded_message_content = sr_avro_encoder.encode(dict_content, schema=schema_str, request_options={"fake_kwarg": True})
assert 'request() got an unexpected keyword' in str(e.value)
encoded_message_content = sr_avro_encoder.encode(dict_content, schema=schema_str)
content_type = encoded_message_content["content_type"]
encoded_content = encoded_message_content["content"]

encoded_content_dict = {"content": encoded_content, "content_type": content_type}
with pytest.raises(TypeError) as e:
decoded_content = sr_avro_encoder.decode(encoded_content_dict, request_kwargs={"fake_kwarg": True})
decoded_content = sr_avro_encoder.decode(encoded_content_dict, request_options={"fake_kwarg": True})
assert 'request() got an unexpected keyword' in str(e.value)


Expand Down