MCPcopy Create free account
hub / github.com/devflowinc/trieve / request

Method request

clients/python-sdk/trieve_py_client/rest.py:115–256  ·  view source on GitHub ↗

Perform requests. :param method: http request method :param url: http request url :param headers: http request headers :param body: request json body, for `application/json` :param post_params: request post parameters, `application

(
        self,
        method,
        url,
        headers=None,
        body=None,
        post_params=None,
        _request_timeout=None
    )

Source from the content-addressed store, hash-verified

113 self.pool_manager = urllib3.PoolManager(**pool_args)
114
115 def request(
116 self,
117 method,
118 url,
119 headers=None,
120 body=None,
121 post_params=None,
122 _request_timeout=None
123 ):
124 """Perform requests.
125
126 :param method: http request method
127 :param url: http request url
128 :param headers: http request headers
129 :param body: request json body, for `application/json`
130 :param post_params: request post parameters,
131 `application/x-www-form-urlencoded`
132 and `multipart/form-data`
133 :param _request_timeout: timeout setting for this request. If one
134 number provided, it will be total request
135 timeout. It can also be a pair (tuple) of
136 (connection, read) timeouts.
137 """
138 method = method.upper()
139 assert method in [
140 'GET',
141 'HEAD',
142 'DELETE',
143 'POST',
144 'PUT',
145 'PATCH',
146 'OPTIONS'
147 ]
148
149 if post_params and body:
150 raise ApiValueError(
151 "body parameter cannot be used with post_params parameter."
152 )
153
154 post_params = post_params or {}
155 headers = headers or {}
156
157 timeout = None
158 if _request_timeout:
159 if isinstance(_request_timeout, (int, float)):
160 timeout = urllib3.Timeout(total=_request_timeout)
161 elif (
162 isinstance(_request_timeout, tuple)
163 and len(_request_timeout) == 2
164 ):
165 timeout = urllib3.Timeout(
166 connect=_request_timeout[0],
167 read=_request_timeout[1]
168 )
169
170 try:
171 # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
172 if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:

Callers 9

call_apiMethod · 0.80
search_within_groupMethod · 0.80
autocompleteMethod · 0.80
bulk_delete_chunkMethod · 0.80
count_chunksMethod · 0.80
create_chunkMethod · 0.80
scroll_dataset_chunksMethod · 0.80
search_chunksMethod · 0.80

Calls 4

ApiValueErrorClass · 0.90
ApiExceptionClass · 0.90
RESTResponseClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected