Skip to content

Commit 486e6db

Browse files
authored
[Schema Registry] rename request kwargs to request options (Azure#23325)
update param name
1 parent 74a192a commit 486e6db

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

sdk/eventhub/azure-eventhub/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Breaking Changes
66

7-
- `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`.
7+
- `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`.
88

99
## 5.9.0b1 (2022-02-09)
1010

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Features Added
66

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

1010
### Breaking Changes

sdk/schemaregistry/azure-schemaregistry-avroencoder/azure/schemaregistry/encoder/avroencoder/_schema_registry_avro_encoder.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def encode(
132132
*,
133133
schema: str,
134134
message_type: Optional[Callable] = None,
135-
request_kwargs: Dict[str, Any] = None,
135+
request_options: Dict[str, Any] = None,
136136
**kwargs: Any,
137137
) -> Union[MessageType, MessageContent]:
138138
"""
@@ -157,8 +157,8 @@ def encode(
157157
`(content: bytes, content_type: str, **kwargs) -> MessageType`, where `content` and `content_type`
158158
are positional parameters.
159159
:paramtype message_type: Callable or None
160-
:keyword request_kwargs: The keyword arguments for http requests to be passed to the client.
161-
:paramtype request_kwargs: Dict[str, Any]
160+
:keyword request_options: The keyword arguments for http requests to be passed to the client.
161+
:paramtype request_options: Dict[str, Any]
162162
:rtype: MessageType or MessageContent
163163
:raises ~azure.schemaregistry.encoder.avroencoder.exceptions.SchemaParseError:
164164
Indicates an issue with parsing schema.
@@ -176,8 +176,8 @@ def encode(
176176
).raise_with_traceback()
177177

178178
cache_misses = self._get_schema_id.cache_info().misses # pylint: disable=no-value-for-parameter
179-
request_kwargs = request_kwargs or {}
180-
schema_id = self._get_schema_id(schema_fullname, raw_input_schema, **request_kwargs)
179+
request_options = request_options or {}
180+
schema_id = self._get_schema_id(schema_fullname, raw_input_schema, **request_options)
181181
new_cache_misses = self._get_schema_id.cache_info().misses # pylint: disable=no-value-for-parameter
182182
if new_cache_misses > cache_misses:
183183
cache_size = self._get_schema_id.cache_info().currsize # pylint: disable=no-value-for-parameter
@@ -237,7 +237,7 @@ def decode(
237237
message: Union[MessageType, MessageContent],
238238
*,
239239
readers_schema: Optional[str] = None,
240-
request_kwargs: Dict[str, Any] = None,
240+
request_options: Dict[str, Any] = None,
241241
**kwargs, # pylint: disable=unused-argument
242242
) -> Dict[str, Any]:
243243
"""
@@ -254,8 +254,8 @@ def decode(
254254
:type message: MessageType or MessageContent
255255
:keyword readers_schema: An optional reader's schema as defined by the Apache Avro specification.
256256
:paramtype readers_schema: str or None
257-
:keyword request_kwargs: The keyword arguments for http requests to be passed to the client.
258-
:paramtype request_kwargs: Dict[str, Any]
257+
:keyword request_options: The keyword arguments for http requests to be passed to the client.
258+
:paramtype request_options: Dict[str, Any]
259259
:rtype: Dict[str, Any]
260260
:raises ~azure.schemaregistry.encoder.avroencoder.exceptions.SchemaParseError:
261261
Indicates an issue with parsing schema.
@@ -284,8 +284,8 @@ def decode(
284284
schema_id = content_type.split("+")[1]
285285

286286
cache_misses = self._get_schema.cache_info().misses # pylint: disable=no-value-for-parameter
287-
request_kwargs = request_kwargs or {}
288-
schema_definition = self._get_schema(schema_id, **request_kwargs)
287+
request_options = request_options or {}
288+
schema_definition = self._get_schema(schema_id, **request_options)
289289
new_cache_misses = self._get_schema.cache_info().misses # pylint: disable=no-value-for-parameter
290290
if new_cache_misses > cache_misses:
291291
cache_size = self._get_schema.cache_info().currsize # pylint: disable=no-value-for-parameter

sdk/schemaregistry/azure-schemaregistry-avroencoder/azure/schemaregistry/encoder/avroencoder/aio/_schema_registry_avro_encoder_async.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ async def encode(
128128
*,
129129
schema: str,
130130
message_type: Optional[Callable] = None,
131-
request_kwargs: Dict[str, Any] = None,
131+
request_options: Dict[str, Any] = None,
132132
**kwargs: Any,
133133
) -> Union[MessageType, MessageContent]:
134134

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

175175
cache_misses = self._get_schema_id.cache_info().misses # pylint: disable=no-value-for-parameter disable=no-member
176-
request_kwargs = request_kwargs or {}
177-
schema_id = await self._get_schema_id(schema_fullname, raw_input_schema, **request_kwargs)
176+
request_options = request_options or {}
177+
schema_id = await self._get_schema_id(schema_fullname, raw_input_schema, **request_options)
178178
new_cache_misses = self._get_schema_id.cache_info().misses # pylint: disable=no-value-for-parameter disable=no-member
179179
if new_cache_misses > cache_misses:
180180
cache_size = self._get_schema_id.cache_info().currsize # pylint: disable=no-value-for-parameter disable=no-member
@@ -230,7 +230,7 @@ async def decode(
230230
message: Union[MessageType, MessageContent],
231231
*,
232232
readers_schema: Optional[str] = None,
233-
request_kwargs: Dict[str, Any] = None,
233+
request_options: Dict[str, Any] = None,
234234
**kwargs, # pylint: disable=unused-argument
235235
) -> Dict[str, Any]:
236236
"""
@@ -247,8 +247,8 @@ async def decode(
247247
:type message: MessageType or MessageContent
248248
:keyword readers_schema: An optional reader's schema as defined by the Apache Avro specification.
249249
:paramtype readers_schema: str or None
250-
:keyword request_kwargs: The keyword arguments for http requests to be passed to the client.
251-
:paramtype request_kwargs: Dict[str, Any]
250+
:keyword request_options: The keyword arguments for http requests to be passed to the client.
251+
:paramtype request_options: Dict[str, Any]
252252
:rtype: Dict[str, Any]
253253
:raises ~azure.schemaregistry.encoder.avroencoder.exceptions.SchemaParseError:
254254
Indicates an issue with parsing schema.
@@ -277,8 +277,8 @@ async def decode(
277277
schema_id = content_type.split("+")[1]
278278

279279
cache_misses = self._get_schema.cache_info().misses # pylint: disable=no-value-for-parameter disable=no-member
280-
request_kwargs = request_kwargs or {}
281-
schema_definition = await self._get_schema(schema_id, **request_kwargs)
280+
request_options = request_options or {}
281+
schema_definition = await self._get_schema(schema_id, **request_options)
282282
new_cache_misses = self._get_schema.cache_info().misses # pylint: disable=no-value-for-parameter disable=no-member
283283
if new_cache_misses > cache_misses:
284284
cache_size = self._get_schema.cache_info().currsize # pylint: disable=no-value-for-parameter disable=no-member
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ interactions:
2323
content-length:
2424
- '0'
2525
date:
26-
- Tue, 01 Mar 2022 02:26:49 GMT
26+
- Thu, 03 Mar 2022 22:32:53 GMT
2727
location:
28-
- https://fake_resource.servicebus.windows.net/:443/$schemagroups/fakegroup/schemas/example.avro.User/versions/1?api-version=2021-10
28+
- https://swathip-test-eh-westus.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/example.avro.User/versions/1?api-version=2021-10
2929
schema-group-name:
3030
- swathip-test-schema
3131
schema-id:
32-
- 08a5597bec1a47188aa3e0c99a69f5a3
32+
- bc24cde138814b81b1479d73249d849d
3333
schema-id-location:
34-
- https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/$schemas/08a5597bec1a47188aa3e0c99a69f5a3?api-version=2021-10
34+
- https://swathip-test-eh-westus.servicebus.windows.net:443/$schemagroups/$schemas/bc24cde138814b81b1479d73249d849d?api-version=2021-10
3535
schema-name:
3636
- example.avro.User
3737
schema-version:
3838
- '1'
3939
schema-versions-location:
40-
- https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/example.avro.User/versions?api-version=2021-10
40+
- https://swathip-test-eh-westus.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/example.avro.User/versions?api-version=2021-10
4141
server:
4242
- Microsoft-HTTPAPI/2.0
4343
strict-transport-security:

sdk/schemaregistry/azure-schemaregistry-avroencoder/tests/test_avro_encoder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,23 +201,23 @@ def test_basic_sr_avro_encoder_decode_readers_schema(self, schemaregistry_fully_
201201
decoded_content = sr_avro_encoder.decode(encoded_content_dict, readers_schema=readers_schema_change_name)
202202

203203
@SchemaRegistryPowerShellPreparer()
204-
def test_basic_sr_avro_encoder_with_request_kwargs(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs):
204+
def test_basic_sr_avro_encoder_with_request_options(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs):
205205
sr_client = self.create_basic_client(SchemaRegistryClient, fully_qualified_namespace=schemaregistry_fully_qualified_namespace)
206206
sr_avro_encoder = AvroEncoder(client=sr_client, group_name=schemaregistry_group, auto_register_schemas=True)
207207

208208
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"]}]}"""
209209

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

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

223223

0 commit comments

Comments
 (0)