4 cloudFPGA Resource Manager API
6 No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
8 OpenAPI spec version: 0.8
10 Generated by: https://github.com/swagger-api/swagger-codegen.git
13 from __future__
import absolute_import
24 from six.moves.urllib.parse
import urlencode
29 raise ImportError(
'Swagger python client requires urllib3.')
32 logger = logging.getLogger(__name__)
44 """Returns a dictionary of the response headers."""
48 """Returns a given response header."""
54 def __init__(self, configuration, pools_size=4, maxsize=None):
62 if configuration.verify_ssl:
63 cert_reqs = ssl.CERT_REQUIRED
65 cert_reqs = ssl.CERT_NONE
68 if configuration.ssl_ca_cert:
69 ca_certs = configuration.ssl_ca_cert
72 ca_certs = certifi.where()
74 addition_pool_args = {}
75 if configuration.assert_hostname
is not None:
76 addition_pool_args[
'assert_hostname'] = configuration.assert_hostname
79 if configuration.connection_pool_maxsize
is not None:
80 maxsize = configuration.connection_pool_maxsize
85 if configuration.proxy:
91 cert_file=configuration.cert_file,
92 key_file=configuration.key_file,
93 proxy_url=configuration.proxy,
102 cert_file=configuration.cert_file,
103 key_file=configuration.key_file,
107 def request(self, method, url, query_params=None, headers=None,
108 body=None, post_params=None, _preload_content=True,
109 _request_timeout=None):
112 :param method: http request method
113 :param url: http request url
114 :param query_params: query parameters in the url
115 :param headers: http request headers
116 :param body: request json body, for `application/json`
117 :param post_params: request post parameters,
118 `application/x-www-form-urlencoded`
119 and `multipart/form-data`
120 :param _preload_content: if False, the urllib3.HTTPResponse object will
121 be returned without reading/decoding response
122 data. Default is True.
123 :param _request_timeout: timeout setting for this request. If one
124 number provided, it will be total request
125 timeout. It can also be a pair (tuple) of
126 (connection, read) timeouts.
128 method = method.upper()
129 assert method
in [
'GET',
'HEAD',
'DELETE',
'POST',
'PUT',
132 if post_params
and body:
134 "body parameter cannot be used with post_params parameter."
137 post_params = post_params
or {}
138 headers = headers
or {}
142 if isinstance(_request_timeout, (int, )
if six.PY3
else (int, long)):
143 timeout = urllib3.Timeout(total=_request_timeout)
144 elif (isinstance(_request_timeout, tuple)
and
145 len(_request_timeout) == 2):
146 timeout = urllib3.Timeout(
147 connect=_request_timeout[0], read=_request_timeout[1])
149 if 'Content-Type' not in headers:
150 headers[
'Content-Type'] =
'application/json'
154 if method
in [
'POST',
'PUT',
'PATCH',
'OPTIONS',
'DELETE']:
156 url +=
'?' + urlencode(query_params)
157 if re.search(
'json', headers[
'Content-Type'], re.IGNORECASE):
160 request_body = json.dumps(body)
164 preload_content=_preload_content,
167 elif headers[
'Content-Type'] ==
'application/x-www-form-urlencoded':
171 encode_multipart=
False,
172 preload_content=_preload_content,
175 elif headers[
'Content-Type'] ==
'multipart/form-data':
179 del headers[
'Content-Type']
183 encode_multipart=
True,
184 preload_content=_preload_content,
190 elif isinstance(body, str):
195 preload_content=_preload_content,
200 msg =
"""Cannot prepare a request message for provided
201 arguments. Please check that your arguments match
202 declared content type."""
208 preload_content=_preload_content,
211 except urllib3.exceptions.SSLError
as e:
212 msg =
"{0}\n{1}".format(
type(e).__name__,
str(e))
219 logger.debug(
"response body: %s", r.data)
221 if not 200 <= r.status <= 299:
226 def GET(self, url, headers=None, query_params=None, _preload_content=True,
227 _request_timeout=None):
228 return self.
requestrequest(
"GET", url,
230 _preload_content=_preload_content,
231 _request_timeout=_request_timeout,
232 query_params=query_params)
234 def HEAD(self, url, headers=None, query_params=None, _preload_content=True,
235 _request_timeout=None):
236 return self.
requestrequest(
"HEAD", url,
238 _preload_content=_preload_content,
239 _request_timeout=_request_timeout,
240 query_params=query_params)
242 def OPTIONS(self, url, headers=None, query_params=None, post_params=None,
243 body=None, _preload_content=True, _request_timeout=None):
244 return self.
requestrequest(
"OPTIONS", url,
246 query_params=query_params,
247 post_params=post_params,
248 _preload_content=_preload_content,
249 _request_timeout=_request_timeout,
252 def DELETE(self, url, headers=None, query_params=None, body=None,
253 _preload_content=True, _request_timeout=None):
254 return self.
requestrequest(
"DELETE", url,
256 query_params=query_params,
257 _preload_content=_preload_content,
258 _request_timeout=_request_timeout,
261 def POST(self, url, headers=None, query_params=None, post_params=None,
262 body=None, _preload_content=True, _request_timeout=None):
263 return self.
requestrequest(
"POST", url,
265 query_params=query_params,
266 post_params=post_params,
267 _preload_content=_preload_content,
268 _request_timeout=_request_timeout,
271 def PUT(self, url, headers=None, query_params=None, post_params=None,
272 body=None, _preload_content=True, _request_timeout=None):
273 return self.
requestrequest(
"PUT", url,
275 query_params=query_params,
276 post_params=post_params,
277 _preload_content=_preload_content,
278 _request_timeout=_request_timeout,
281 def PATCH(self, url, headers=None, query_params=None, post_params=None,
282 body=None, _preload_content=True, _request_timeout=None):
283 return self.
requestrequest(
"PATCH", url,
285 query_params=query_params,
286 post_params=post_params,
287 _preload_content=_preload_content,
288 _request_timeout=_request_timeout,
294 def __init__(self, status=None, reason=None, http_resp=None):
301 self.
statusstatus = status
302 self.
reasonreason = reason
307 """Custom error messages for exception"""
308 error_message =
"({0})\n"\
309 "Reason: {1}\n".format(self.
statusstatus, self.
reasonreason)
311 error_message +=
"HTTP response headers: {0}\n".format(
315 error_message +=
"HTTP response body: {0}\n".format(self.
bodybody)
def __init__(self, status=None, reason=None, http_resp=None)
def POST(self, url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)
def HEAD(self, url, headers=None, query_params=None, _preload_content=True, _request_timeout=None)
def GET(self, url, headers=None, query_params=None, _preload_content=True, _request_timeout=None)
def PATCH(self, url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)
def __init__(self, configuration, pools_size=4, maxsize=None)
def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None)
def DELETE(self, url, headers=None, query_params=None, body=None, _preload_content=True, _request_timeout=None)
def PUT(self, url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)
def OPTIONS(self, url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)
def getheader(self, name, default=None)