cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
cFSPlib.python_api_client.swagger_client.api_client.ApiClient Class Reference
Inheritance diagram for cFSPlib.python_api_client.swagger_client.api_client.ApiClient:
[legend]
Collaboration diagram for cFSPlib.python_api_client.swagger_client.api_client.ApiClient:
[legend]

Public Member Functions

def __init__ (self, configuration=None, header_name=None, header_value=None, cookie=None)
 
def __del__ (self)
 
def user_agent (self)
 
def user_agent (self, value)
 
def set_default_header (self, header_name, header_value)
 
def sanitize_for_serialization (self, obj)
 
def deserialize (self, response, response_type)
 
def call_api (self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, response_type=None, auth_settings=None, async_req=None, _return_http_data_only=None, collection_formats=None, _preload_content=True, _request_timeout=None)
 
def request (self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)
 
def parameters_to_tuples (self, params, collection_formats)
 
def prepare_post_parameters (self, post_params=None, files=None)
 
def select_header_accept (self, accepts)
 
def select_header_content_type (self, content_types)
 
def update_params_for_auth (self, headers, querys, auth_settings)
 

Public Attributes

 configuration
 
 pool
 
 rest_client
 
 default_headers
 
 cookie
 
 user_agent
 
 last_response
 

Static Public Attributes

tuple PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
 
dictionary NATIVE_TYPES_MAPPING
 

Detailed Description

Generic API client for Swagger client library builds.

Swagger generic API client. This client handles the client-
server communication, and is invariant across implementations. Specifics of
the methods and models for each application are generated from the Swagger
templates.

NOTE: This class is auto generated by the swagger code generator program.
Ref: https://github.com/swagger-api/swagger-codegen
Do not edit the class manually.

:param configuration: .Configuration object for this client
:param header_name: a header to pass when making calls to the API.
:param header_value: a header value to pass when making calls to
    the API.
:param cookie: a cookie to include in the header when making calls
    to the API

Definition at line 30 of file api_client.py.

Constructor & Destructor Documentation

◆ __init__()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.__init__ (   self,
  configuration = None,
  header_name = None,
  header_value = None,
  cookie = None 
)

Definition at line 62 of file api_client.py.

63  cookie=None):
64  if configuration is None:
65  configuration = Configuration()
66  self.configuration = configuration
67 
68  self.pool = ThreadPool()
69  self.rest_client = rest.RESTClientObject(configuration)
70  self.default_headers = {}
71  if header_name is not None:
72  self.default_headers[header_name] = header_value
73  self.cookie = cookie
74  # Set default User-Agent.
75  self.user_agent = 'Swagger-Codegen/1.0.0/python'
76 

◆ __del__()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.__del__ (   self)

Definition at line 77 of file api_client.py.

77  def __del__(self):
78  self.pool.close()
79  self.pool.join()
80 

Member Function Documentation

◆ call_api()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.call_api (   self,
  resource_path,
  method,
  path_params = None,
  query_params = None,
  header_params = None,
  body = None,
  post_params = None,
  files = None,
  response_type = None,
  auth_settings = None,
  async_req = None,
  _return_http_data_only = None,
  collection_formats = None,
  _preload_content = True,
  _request_timeout = None 
)
Makes the HTTP request (synchronous) and returns deserialized data.

To make an async request, set the async_req parameter.

:param resource_path: Path to method endpoint.
:param method: Method to call.
:param path_params: Path parameters in the url.
:param query_params: Query parameters in the url.
:param header_params: Header parameters to be
    placed in the request header.
:param body: Request body.
:param post_params dict: Request post form parameters,
    for `application/x-www-form-urlencoded`, `multipart/form-data`.
:param auth_settings list: Auth Settings names for the request.
:param response: Response data type.
:param files dict: key -> filename, value -> filepath,
    for `multipart/form-data`.
:param async_req bool: execute request asynchronously
:param _return_http_data_only: response data without head status code
                               and headers
:param collection_formats: dict of collection formats for path, query,
    header, and post parameters.
:param _preload_content: if False, the urllib3.HTTPResponse object will
                         be returned without reading/decoding response
                         data. Default is True.
:param _request_timeout: timeout setting for this request. If one
                         number provided, it will be total request
                         timeout. It can also be a pair (tuple) of
                         (connection, read) timeouts.
:return:
    If async_req parameter is True,
    the request will be called asynchronously.
    The method will return the request thread.
    If parameter async_req is False or missing,
    then the method will return the response directly.

Definition at line 273 of file api_client.py.

278  _preload_content=True, _request_timeout=None):
279  """Makes the HTTP request (synchronous) and returns deserialized data.
280 
281  To make an async request, set the async_req parameter.
282 
283  :param resource_path: Path to method endpoint.
284  :param method: Method to call.
285  :param path_params: Path parameters in the url.
286  :param query_params: Query parameters in the url.
287  :param header_params: Header parameters to be
288  placed in the request header.
289  :param body: Request body.
290  :param post_params dict: Request post form parameters,
291  for `application/x-www-form-urlencoded`, `multipart/form-data`.
292  :param auth_settings list: Auth Settings names for the request.
293  :param response: Response data type.
294  :param files dict: key -> filename, value -> filepath,
295  for `multipart/form-data`.
296  :param async_req bool: execute request asynchronously
297  :param _return_http_data_only: response data without head status code
298  and headers
299  :param collection_formats: dict of collection formats for path, query,
300  header, and post parameters.
301  :param _preload_content: if False, the urllib3.HTTPResponse object will
302  be returned without reading/decoding response
303  data. Default is True.
304  :param _request_timeout: timeout setting for this request. If one
305  number provided, it will be total request
306  timeout. It can also be a pair (tuple) of
307  (connection, read) timeouts.
308  :return:
309  If async_req parameter is True,
310  the request will be called asynchronously.
311  The method will return the request thread.
312  If parameter async_req is False or missing,
313  then the method will return the response directly.
314  """
315  if not async_req:
316  return self.__call_api(resource_path, method,
317  path_params, query_params, header_params,
318  body, post_params, files,
319  response_type, auth_settings,
320  _return_http_data_only, collection_formats,
321  _preload_content, _request_timeout)
322  else:
323  thread = self.pool.apply_async(self.__call_api, (resource_path,
324  method, path_params, query_params,
325  header_params, body,
326  post_params, files,
327  response_type, auth_settings,
328  _return_http_data_only,
329  collection_formats,
330  _preload_content, _request_timeout))
331  return thread
332 
Here is the call graph for this function:

◆ deserialize()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.deserialize (   self,
  response,
  response_type 
)
Deserializes response into an object.

:param response: RESTResponse object to be deserialized.
:param response_type: class literal for
    deserialized object, or string of class name.

:return: deserialized object.

Definition at line 212 of file api_client.py.

212  def deserialize(self, response, response_type):
213  """Deserializes response into an object.
214 
215  :param response: RESTResponse object to be deserialized.
216  :param response_type: class literal for
217  deserialized object, or string of class name.
218 
219  :return: deserialized object.
220  """
221  # handle file downloading
222  # save response body into a tmp file and return the instance
223  if response_type == "file":
224  return self.__deserialize_file(response)
225 
226  # fetch data from response object
227  try:
228  data = json.loads(response.data)
229  except ValueError:
230  data = response.data
231 
232  return self.__deserialize(data, response_type)
233 
Here is the call graph for this function:

◆ parameters_to_tuples()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.parameters_to_tuples (   self,
  params,
  collection_formats 
)
Get parameters as list of tuples, formatting collections.

:param params: Parameters as dict or list of two-tuples
:param dict collection_formats: Parameter collection formats
:return: Parameters as list of tuples, collections formatted

Definition at line 394 of file api_client.py.

394  def parameters_to_tuples(self, params, collection_formats):
395  """Get parameters as list of tuples, formatting collections.
396 
397  :param params: Parameters as dict or list of two-tuples
398  :param dict collection_formats: Parameter collection formats
399  :return: Parameters as list of tuples, collections formatted
400  """
401  new_params = []
402  if collection_formats is None:
403  collection_formats = {}
404  for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501
405  if k in collection_formats:
406  collection_format = collection_formats[k]
407  if collection_format == 'multi':
408  new_params.extend((k, value) for value in v)
409  else:
410  if collection_format == 'ssv':
411  delimiter = ' '
412  elif collection_format == 'tsv':
413  delimiter = '\t'
414  elif collection_format == 'pipes':
415  delimiter = '|'
416  else: # csv is the default
417  delimiter = ','
418  new_params.append(
419  (k, delimiter.join(str(value) for value in v)))
420  else:
421  new_params.append((k, v))
422  return new_params
423 
Here is the caller graph for this function:

◆ prepare_post_parameters()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.prepare_post_parameters (   self,
  post_params = None,
  files = None 
)
Builds form parameters.

:param post_params: Normal form parameters.
:param files: File parameters.
:return: Form parameters with files.

Definition at line 424 of file api_client.py.

424  def prepare_post_parameters(self, post_params=None, files=None):
425  """Builds form parameters.
426 
427  :param post_params: Normal form parameters.
428  :param files: File parameters.
429  :return: Form parameters with files.
430  """
431  params = []
432 
433  if post_params:
434  params = post_params
435 
436  if files:
437  for k, v in six.iteritems(files):
438  if not v:
439  continue
440  file_names = v if type(v) is list else [v]
441  for n in file_names:
442  with open(n, 'rb') as f:
443  filename = os.path.basename(f.name)
444  filedata = f.read()
445  mimetype = (mimetypes.guess_type(filename)[0] or
446  'application/octet-stream')
447  params.append(
448  tuple([k, tuple([filename, filedata, mimetype])]))
449 
450  return params
451 
Here is the caller graph for this function:

◆ request()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.request (   self,
  method,
  url,
  query_params = None,
  headers = None,
  post_params = None,
  body = None,
  _preload_content = True,
  _request_timeout = None 
)
Makes the HTTP request using RESTClient.

Definition at line 333 of file api_client.py.

335  _request_timeout=None):
336  """Makes the HTTP request using RESTClient."""
337  if method == "GET":
338  return self.rest_client.GET(url,
339  query_params=query_params,
340  _preload_content=_preload_content,
341  _request_timeout=_request_timeout,
342  headers=headers)
343  elif method == "HEAD":
344  return self.rest_client.HEAD(url,
345  query_params=query_params,
346  _preload_content=_preload_content,
347  _request_timeout=_request_timeout,
348  headers=headers)
349  elif method == "OPTIONS":
350  return self.rest_client.OPTIONS(url,
351  query_params=query_params,
352  headers=headers,
353  post_params=post_params,
354  _preload_content=_preload_content,
355  _request_timeout=_request_timeout,
356  body=body)
357  elif method == "POST":
358  return self.rest_client.POST(url,
359  query_params=query_params,
360  headers=headers,
361  post_params=post_params,
362  _preload_content=_preload_content,
363  _request_timeout=_request_timeout,
364  body=body)
365  elif method == "PUT":
366  return self.rest_client.PUT(url,
367  query_params=query_params,
368  headers=headers,
369  post_params=post_params,
370  _preload_content=_preload_content,
371  _request_timeout=_request_timeout,
372  body=body)
373  elif method == "PATCH":
374  return self.rest_client.PATCH(url,
375  query_params=query_params,
376  headers=headers,
377  post_params=post_params,
378  _preload_content=_preload_content,
379  _request_timeout=_request_timeout,
380  body=body)
381  elif method == "DELETE":
382  return self.rest_client.DELETE(url,
383  query_params=query_params,
384  headers=headers,
385  _preload_content=_preload_content,
386  _request_timeout=_request_timeout,
387  body=body)
388  else:
389  raise ValueError(
390  "http method must be `GET`, `HEAD`, `OPTIONS`,"
391  " `POST`, `PATCH`, `PUT` or `DELETE`."
392  )
393 
@ DELETE
Definition: nts_types.hpp:382
@ GET
@ POST
@ PUT
Here is the caller graph for this function:

◆ sanitize_for_serialization()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.sanitize_for_serialization (   self,
  obj 
)
Builds a JSON POST object.

If obj is None, return None.
If obj is str, int, long, float, bool, return directly.
If obj is datetime.datetime, datetime.date
    convert to string in iso8601 format.
If obj is list, sanitize each element in the list.
If obj is dict, return the dict.
If obj is swagger model, return the properties dict.

:param obj: The data to serialize.
:return: The serialized form of data.

Definition at line 170 of file api_client.py.

170  def sanitize_for_serialization(self, obj):
171  """Builds a JSON POST object.
172 
173  If obj is None, return None.
174  If obj is str, int, long, float, bool, return directly.
175  If obj is datetime.datetime, datetime.date
176  convert to string in iso8601 format.
177  If obj is list, sanitize each element in the list.
178  If obj is dict, return the dict.
179  If obj is swagger model, return the properties dict.
180 
181  :param obj: The data to serialize.
182  :return: The serialized form of data.
183  """
184  if obj is None:
185  return None
186  elif isinstance(obj, self.PRIMITIVE_TYPES):
187  return obj
188  elif isinstance(obj, list):
189  return [self.sanitize_for_serialization(sub_obj)
190  for sub_obj in obj]
191  elif isinstance(obj, tuple):
192  return tuple(self.sanitize_for_serialization(sub_obj)
193  for sub_obj in obj)
194  elif isinstance(obj, (datetime.datetime, datetime.date)):
195  return obj.isoformat()
196 
197  if isinstance(obj, dict):
198  obj_dict = obj
199  else:
200  # Convert model obj to dict except
201  # attributes `swagger_types`, `attribute_map`
202  # and attributes which value is not None.
203  # Convert attribute name to json key in
204  # model definition for request.
205  obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
206  for attr, _ in six.iteritems(obj.swagger_types)
207  if getattr(obj, attr) is not None}
208 
209  return {key: self.sanitize_for_serialization(val)
210  for key, val in six.iteritems(obj_dict)}
211 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ select_header_accept()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.select_header_accept (   self,
  accepts 
)
Returns `Accept` based on an array of accepts provided.

:param accepts: List of headers.
:return: Accept (e.g. application/json).

Definition at line 452 of file api_client.py.

452  def select_header_accept(self, accepts):
453  """Returns `Accept` based on an array of accepts provided.
454 
455  :param accepts: List of headers.
456  :return: Accept (e.g. application/json).
457  """
458  if not accepts:
459  return
460 
461  accepts = [x.lower() for x in accepts]
462 
463  if 'application/json' in accepts:
464  return 'application/json'
465  else:
466  return ', '.join(accepts)
467 

◆ select_header_content_type()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.select_header_content_type (   self,
  content_types 
)
Returns `Content-Type` based on an array of content_types provided.

:param content_types: List of content-types.
:return: Content-Type (e.g. application/json).

Definition at line 468 of file api_client.py.

468  def select_header_content_type(self, content_types):
469  """Returns `Content-Type` based on an array of content_types provided.
470 
471  :param content_types: List of content-types.
472  :return: Content-Type (e.g. application/json).
473  """
474  if not content_types:
475  return 'application/json'
476 
477  content_types = [x.lower() for x in content_types]
478 
479  if 'application/json' in content_types or '*/*' in content_types:
480  return 'application/json'
481  else:
482  return content_types[0]
483 

◆ set_default_header()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.set_default_header (   self,
  header_name,
  header_value 
)

Definition at line 90 of file api_client.py.

90  def set_default_header(self, header_name, header_value):
91  self.default_headers[header_name] = header_value
92 
Here is the call graph for this function:

◆ update_params_for_auth()

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.update_params_for_auth (   self,
  headers,
  querys,
  auth_settings 
)
Updates header and query params based on authentication setting.

:param headers: Header parameters dict to be updated.
:param querys: Query parameters tuple list to be updated.
:param auth_settings: Authentication setting identifiers list.

Definition at line 484 of file api_client.py.

484  def update_params_for_auth(self, headers, querys, auth_settings):
485  """Updates header and query params based on authentication setting.
486 
487  :param headers: Header parameters dict to be updated.
488  :param querys: Query parameters tuple list to be updated.
489  :param auth_settings: Authentication setting identifiers list.
490  """
491  if not auth_settings:
492  return
493 
494  for auth in auth_settings:
495  auth_setting = self.configuration.auth_settings().get(auth)
496  if auth_setting:
497  if not auth_setting['value']:
498  continue
499  elif auth_setting['in'] == 'header':
500  headers[auth_setting['key']] = auth_setting['value']
501  elif auth_setting['in'] == 'query':
502  querys.append((auth_setting['key'], auth_setting['value']))
503  else:
504  raise ValueError(
505  'Authentication token must be in `query` or `header`'
506  )
507 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ user_agent() [1/2]

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.user_agent (   self)
User agent for this API client

Definition at line 82 of file api_client.py.

82  def user_agent(self):
83  """User agent for this API client"""
84  return self.default_headers['User-Agent']
85 

◆ user_agent() [2/2]

def cFSPlib.python_api_client.swagger_client.api_client.ApiClient.user_agent (   self,
  value 
)

Definition at line 87 of file api_client.py.

87  def user_agent(self, value):
88  self.default_headers['User-Agent'] = value
89 

Member Data Documentation

◆ configuration

cFSPlib.python_api_client.swagger_client.api_client.ApiClient.configuration

Definition at line 66 of file api_client.py.

◆ cookie

cFSPlib.python_api_client.swagger_client.api_client.ApiClient.cookie

Definition at line 73 of file api_client.py.

◆ default_headers

cFSPlib.python_api_client.swagger_client.api_client.ApiClient.default_headers

Definition at line 70 of file api_client.py.

◆ last_response

cFSPlib.python_api_client.swagger_client.api_client.ApiClient.last_response

Definition at line 154 of file api_client.py.

◆ NATIVE_TYPES_MAPPING

dictionary cFSPlib.python_api_client.swagger_client.api_client.ApiClient.NATIVE_TYPES_MAPPING
static
Initial value:
= {
'int': int,
'long': int if six.PY3 else long, # noqa: F821
'float': float,
'str': str,
'bool': bool,
'date': datetime.date,
'datetime': datetime.datetime,
'object': object,
}

Definition at line 51 of file api_client.py.

◆ pool

cFSPlib.python_api_client.swagger_client.api_client.ApiClient.pool

Definition at line 68 of file api_client.py.

◆ PRIMITIVE_TYPES

tuple cFSPlib.python_api_client.swagger_client.api_client.ApiClient.PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
static

Definition at line 50 of file api_client.py.

◆ rest_client

cFSPlib.python_api_client.swagger_client.api_client.ApiClient.rest_client

Definition at line 69 of file api_client.py.

◆ user_agent

cFSPlib.python_api_client.swagger_client.api_client.ApiClient.user_agent

Definition at line 75 of file api_client.py.


The documentation for this class was generated from the following file: