MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / request

Method request

sdks/python/src/e2a/v1/generated/rest.py:78–177  ·  view source on GitHub ↗

Execute request :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/x

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

Source from the content-addressed store, hash-verified

76 await self.pool_manager.aclose()
77
78 async def request(
79 self,
80 method,
81 url,
82 headers=None,
83 body=None,
84 post_params=None,
85 _request_timeout=None):
86 """Execute request
87
88 :param method: http request method
89 :param url: http request url
90 :param headers: http request headers
91 :param body: request json body, for `application/json`
92 :param post_params: request post parameters,
93 `application/x-www-form-urlencoded`
94 and `multipart/form-data`
95 :param _request_timeout: timeout setting for this request. If one
96 number provided, it will be total request
97 timeout. It can also be a pair (tuple) of
98 (connection, read) timeouts.
99 """
100 method = method.upper()
101 assert method in [
102 'GET',
103 'HEAD',
104 'DELETE',
105 'POST',
106 'PUT',
107 'PATCH',
108 'OPTIONS'
109 ]
110
111 if post_params and body:
112 raise ApiValueError(
113 "body parameter cannot be used with post_params parameter."
114 )
115
116 post_params = post_params or {}
117 headers = headers or {}
118 timeout = _request_timeout or 5 * 60
119
120 if 'Content-Type' not in headers:
121 headers['Content-Type'] = 'application/json'
122
123 args = {
124 "method": method,
125 "url": url,
126 "timeout": timeout,
127 "headers": headers
128 }
129
130 # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
131 if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
132 if re.search('json', headers['Content-Type'], re.IGNORECASE):
133 if body is not None:
134 args["json"] = body
135 elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501

Callers 3

call_apiMethod · 0.45
_rawMethod · 0.45
_exec_requestMethod · 0.45

Calls 4

_create_pool_managerMethod · 0.95
ApiValueErrorClass · 0.90
ApiExceptionClass · 0.90
RESTResponseClass · 0.85

Tested by 2

_rawMethod · 0.36
_exec_requestMethod · 0.36