66# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77# --------------------------------------------------------------------------
88
9+ from copy import deepcopy
910from typing import TYPE_CHECKING
1011
1112from azure .core import PipelineClient
1213from msrest import Deserializer , Serializer
1314
15+ from . import models
16+ from ._configuration import SearchClientConfiguration
17+ from .operations import DocumentsOperations
18+
1419if 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
2525class 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
0 commit comments