Skip to content

Commit b2bdfe6

Browse files
authored
[Search] Regenerate with latest autorest (Azure#20597)
* Regenerate with latest autorest. * Bump azure.core dependency to resolve CI issues.
1 parent 53ea0c0 commit b2bdfe6

27 files changed

+7100
-5730
lines changed

sdk/search/azure-search-documents/azure/search/documents/_generated/_search_client.py

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
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 . import models
16+
from ._configuration import SearchClientConfiguration
17+
from .operations import DocumentsOperations
18+
1419
if TYPE_CHECKING:
1520
# pylint: disable=unused-import,ungrouped-imports
1621
from typing import Any
1722

18-
from azure.core.pipeline.transport import HttpRequest, HttpResponse
19-
20-
from ._configuration import SearchClientConfiguration
21-
from .operations import DocumentsOperations
22-
from . import models
23-
23+
from azure.core.rest import HttpRequest, HttpResponse
2424

2525
class SearchClient(object):
2626
"""Client that can be used to query an index and upload, merge, or delete documents.
@@ -40,36 +40,48 @@ def __init__(
4040
**kwargs # type: Any
4141
):
4242
# type: (...) -> None
43-
base_url = '{endpoint}/indexes(\'{indexName}\')'
43+
_base_url = '{endpoint}/indexes(\'{indexName}\')'
4444
self._config = SearchClientConfiguration(endpoint, index_name, **kwargs)
45-
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
45+
self._client = PipelineClient(base_url=_base_url, config=self._config, **kwargs)
4646

4747
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
4848
self._serialize = Serializer(client_models)
49-
self._serialize.client_side_validation = False
5049
self._deserialize = Deserializer(client_models)
50+
self._serialize.client_side_validation = False
51+
self.documents = DocumentsOperations(self._client, self._config, self._serialize, self._deserialize)
5152

52-
self.documents = DocumentsOperations(
53-
self._client, self._config, self._serialize, self._deserialize)
5453

55-
def _send_request(self, http_request, **kwargs):
56-
# type: (HttpRequest, Any) -> HttpResponse
54+
def _send_request(
55+
self,
56+
request, # type: HttpRequest
57+
**kwargs # type: Any
58+
):
59+
# type: (...) -> HttpResponse
5760
"""Runs the network request through the client's chained policies.
5861
59-
:param http_request: The network request you want to make. Required.
60-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
61-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
62+
>>> from azure.core.rest import HttpRequest
63+
>>> request = HttpRequest("GET", "https://www.example.org/")
64+
<HttpRequest [GET], url: 'https://www.example.org/'>
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+
:param request: The network request you want to make. Required.
71+
:type request: ~azure.core.rest.HttpRequest
72+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
6273
:return: The response of your network call. Does not do error handling on your response.
63-
:rtype: ~azure.core.pipeline.transport.HttpResponse
74+
:rtype: ~azure.core.rest.HttpResponse
6475
"""
76+
77+
request_copy = deepcopy(request)
6578
path_format_arguments = {
66-
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
67-
'indexName': self._serialize.url("self._config.index_name", self._config.index_name, 'str'),
79+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
80+
"indexName": self._serialize.url("self._config.index_name", self._config.index_name, 'str'),
6881
}
69-
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
70-
stream = kwargs.pop("stream", True)
71-
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
72-
return pipeline_response.http_response
82+
83+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
84+
return self._client.send_request(request_copy, **kwargs)
7385

7486
def close(self):
7587
# type: () -> None

sdk/search/azure-search-documents/azure/search/documents/_generated/aio/_search_client.py

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

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

1112
from azure.core import AsyncPipelineClient
12-
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
13+
from azure.core.rest import AsyncHttpResponse, HttpRequest
1314
from msrest import Deserializer, Serializer
1415

16+
from .. import models
1517
from ._configuration import SearchClientConfiguration
1618
from .operations import DocumentsOperations
17-
from .. import models
18-
1919

20-
class SearchClient(object):
20+
class SearchClient:
2121
"""Client that can be used to query an index and upload, merge, or delete documents.
2222
2323
:ivar documents: DocumentsOperations operations
@@ -34,35 +34,47 @@ def __init__(
3434
index_name: str,
3535
**kwargs: Any
3636
) -> None:
37-
base_url = '{endpoint}/indexes(\'{indexName}\')'
37+
_base_url = '{endpoint}/indexes(\'{indexName}\')'
3838
self._config = SearchClientConfiguration(endpoint, index_name, **kwargs)
39-
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)
39+
self._client = AsyncPipelineClient(base_url=_base_url, config=self._config, **kwargs)
4040

4141
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
4242
self._serialize = Serializer(client_models)
43-
self._serialize.client_side_validation = False
4443
self._deserialize = Deserializer(client_models)
44+
self._serialize.client_side_validation = False
45+
self.documents = DocumentsOperations(self._client, self._config, self._serialize, self._deserialize)
4546

46-
self.documents = DocumentsOperations(
47-
self._client, self._config, self._serialize, self._deserialize)
4847

49-
async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse:
48+
def _send_request(
49+
self,
50+
request: HttpRequest,
51+
**kwargs: Any
52+
) -> Awaitable[AsyncHttpResponse]:
5053
"""Runs the network request through the client's chained policies.
5154
52-
:param http_request: The network request you want to make. Required.
53-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
54-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
55+
>>> from azure.core.rest import HttpRequest
56+
>>> request = HttpRequest("GET", "https://www.example.org/")
57+
<HttpRequest [GET], url: 'https://www.example.org/'>
58+
>>> response = await client._send_request(request)
59+
<AsyncHttpResponse: 200 OK>
60+
61+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
62+
63+
:param request: The network request you want to make. Required.
64+
:type request: ~azure.core.rest.HttpRequest
65+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
5566
:return: The response of your network call. Does not do error handling on your response.
56-
:rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
67+
:rtype: ~azure.core.rest.AsyncHttpResponse
5768
"""
69+
70+
request_copy = deepcopy(request)
5871
path_format_arguments = {
59-
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
60-
'indexName': self._serialize.url("self._config.index_name", self._config.index_name, 'str'),
72+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
73+
"indexName": self._serialize.url("self._config.index_name", self._config.index_name, 'str'),
6174
}
62-
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
63-
stream = kwargs.pop("stream", True)
64-
pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs)
65-
return pipeline_response.http_response
75+
76+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
77+
return self._client.send_request(request_copy, **kwargs)
6678

6779
async def close(self) -> None:
6880
await self._client.close()

0 commit comments

Comments
 (0)