6
6
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
# --------------------------------------------------------------------------
8
8
9
+ from copy import deepcopy
9
10
from typing import TYPE_CHECKING
10
11
11
12
from azure .core import PipelineClient
12
13
from msrest import Deserializer , Serializer
13
14
15
+ from . import models
16
+ from ._configuration import SearchClientConfiguration
17
+ from .operations import DocumentsOperations
18
+
14
19
if TYPE_CHECKING :
15
20
# pylint: disable=unused-import,ungrouped-imports
16
21
from typing import Any
17
22
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
24
24
25
25
class SearchClient (object ):
26
26
"""Client that can be used to query an index and upload, merge, or delete documents.
@@ -40,36 +40,48 @@ def __init__(
40
40
** kwargs # type: Any
41
41
):
42
42
# type: (...) -> None
43
- base_url = '{endpoint}/indexes(\' {indexName}\' )'
43
+ _base_url = '{endpoint}/indexes(\' {indexName}\' )'
44
44
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 )
46
46
47
47
client_models = {k : v for k , v in models .__dict__ .items () if isinstance (v , type )}
48
48
self ._serialize = Serializer (client_models )
49
- self ._serialize .client_side_validation = False
50
49
self ._deserialize = Deserializer (client_models )
50
+ self ._serialize .client_side_validation = False
51
+ self .documents = DocumentsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
51
52
52
- self .documents = DocumentsOperations (
53
- self ._client , self ._config , self ._serialize , self ._deserialize )
54
53
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
57
60
"""Runs the network request through the client's chained policies.
58
61
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.
62
73
: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
64
75
"""
76
+
77
+ request_copy = deepcopy (request )
65
78
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' ),
68
81
}
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 )
73
85
74
86
def close (self ):
75
87
# type: () -> None
0 commit comments