3     cloudFPGA Resource Manager API 
    5     No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)  # noqa: E501 
    7     OpenAPI spec version: 0.8 
    9     Generated by: https://github.com/swagger-api/swagger-codegen.git 
   11 from __future__ 
import absolute_import
 
   16 from multiprocessing.pool 
import ThreadPool
 
   23 from six.moves.urllib.parse 
import quote
 
   25 from swagger_client.configuration 
import Configuration
 
   26 import swagger_client.models
 
   27 from swagger_client 
import rest
 
   31     """Generic API client for Swagger client library builds. 
   33     Swagger generic API client. This client handles the client- 
   34     server communication, and is invariant across implementations. Specifics of 
   35     the methods and models for each application are generated from the Swagger 
   38     NOTE: This class is auto generated by the swagger code generator program. 
   39     Ref: https://github.com/swagger-api/swagger-codegen 
   40     Do not edit the class manually. 
   42     :param configuration: .Configuration object for this client 
   43     :param header_name: a header to pass when making calls to the API. 
   44     :param header_value: a header value to pass when making calls to 
   46     :param cookie: a cookie to include in the header when making calls 
   50     PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
 
   51     NATIVE_TYPES_MAPPING = {
 
   53         'long': int 
if six.PY3 
else long,  
 
   57         'date': datetime.date,
 
   58         'datetime': datetime.datetime,
 
   62     def __init__(self, configuration=None, header_name=None, header_value=None,
 
   64         if configuration 
is None:
 
   68         self.
poolpool = ThreadPool()
 
   71         if header_name 
is not None:
 
   83         """User agent for this API client""" 
   94             self, resource_path, method, path_params=None,
 
   95             query_params=None, header_params=None, body=None, post_params=None,
 
   96             files=None, response_type=None, auth_settings=None,
 
   97             _return_http_data_only=None, collection_formats=None,
 
   98             _preload_content=True, _request_timeout=None):
 
  103         header_params = header_params 
or {}
 
  106             header_params[
'Cookie'] = self.
cookiecookie
 
  117             for k, v 
in path_params:
 
  119                 resource_path = resource_path.replace(
 
  121                     quote(
str(v), safe=config.safe_chars_for_path_param)
 
  131         if post_params 
or files:
 
  148         response_data = self.
requestrequest(
 
  149             method, url, query_params=query_params, headers=header_params,
 
  150             post_params=post_params, body=body,
 
  151             _preload_content=_preload_content,
 
  152             _request_timeout=_request_timeout)
 
  156         return_data = response_data
 
  160                 return_data = self.
deserializedeserialize(response_data, response_type)
 
  164         if _return_http_data_only:
 
  167             return (return_data, response_data.status,
 
  168                     response_data.getheaders())
 
  171         """Builds a JSON POST object. 
  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. 
  181         :param obj: The data to serialize. 
  182         :return: The serialized form of data. 
  188         elif isinstance(obj, list):
 
  191         elif isinstance(obj, tuple):
 
  194         elif isinstance(obj, (datetime.datetime, datetime.date)):
 
  195             return obj.isoformat()
 
  197         if isinstance(obj, dict):
 
  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}
 
  210                 for key, val 
in six.iteritems(obj_dict)}
 
  213         """Deserializes response into an object. 
  215         :param response: RESTResponse object to be deserialized. 
  216         :param response_type: class literal for 
  217             deserialized object, or string of class name. 
  219         :return: deserialized object. 
  223         if response_type == 
"file":
 
  228             data = json.loads(response.data)
 
  234     def __deserialize(self, data, klass):
 
  235         """Deserializes dict, list, str into an object. 
  237         :param data: dict, list or str. 
  238         :param klass: class literal, or string of class name. 
  245         if type(klass) == str:
 
  246             if klass.startswith(
'list['):
 
  247                 sub_kls = re.match(
r'list\[(.*)\]', klass).group(1)
 
  249                         for sub_data 
in data]
 
  251             if klass.startswith(
'dict('):
 
  252                 sub_kls = re.match(
r'dict\(([^,]*), (.*)\)', klass).group(2)
 
  254                         for k, v 
in six.iteritems(data)}
 
  260                 klass = getattr(swagger_client.models, klass)
 
  264         elif klass == object:
 
  266         elif klass == datetime.date:
 
  268         elif klass == datetime.datetime:
 
  274                  path_params=None, query_params=None, header_params=None,
 
  275                  body=None, post_params=None, files=None,
 
  276                  response_type=None, auth_settings=None, async_req=None,
 
  277                  _return_http_data_only=None, collection_formats=None,
 
  278                  _preload_content=True, _request_timeout=None):
 
  279         """Makes the HTTP request (synchronous) and returns deserialized data. 
  281         To make an async request, set the async_req parameter. 
  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 
  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. 
  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. 
  316             return self.
__call_api__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)
 
  323             thread = self.
poolpool.apply_async(self.
__call_api__call_api, (resource_path,
 
  324                                            method, path_params, query_params,
 
  327                                            response_type, auth_settings,
 
  328                                            _return_http_data_only,
 
  330                                            _preload_content, _request_timeout))
 
  333     def request(self, method, url, query_params=None, headers=None,
 
  334                 post_params=None, body=None, _preload_content=True,
 
  335                 _request_timeout=None):
 
  336         """Makes the HTTP request using RESTClient.""" 
  339                                         query_params=query_params,
 
  340                                         _preload_content=_preload_content,
 
  341                                         _request_timeout=_request_timeout,
 
  343         elif method == 
"HEAD":
 
  345                                          query_params=query_params,
 
  346                                          _preload_content=_preload_content,
 
  347                                          _request_timeout=_request_timeout,
 
  349         elif method == 
"OPTIONS":
 
  351                                             query_params=query_params,
 
  353                                             post_params=post_params,
 
  354                                             _preload_content=_preload_content,
 
  355                                             _request_timeout=_request_timeout,
 
  357         elif method == 
"POST":
 
  359                                          query_params=query_params,
 
  361                                          post_params=post_params,
 
  362                                          _preload_content=_preload_content,
 
  363                                          _request_timeout=_request_timeout,
 
  365         elif method == 
"PUT":
 
  367                                         query_params=query_params,
 
  369                                         post_params=post_params,
 
  370                                         _preload_content=_preload_content,
 
  371                                         _request_timeout=_request_timeout,
 
  373         elif method == 
"PATCH":
 
  375                                           query_params=query_params,
 
  377                                           post_params=post_params,
 
  378                                           _preload_content=_preload_content,
 
  379                                           _request_timeout=_request_timeout,
 
  381         elif method == 
"DELETE":
 
  383                                            query_params=query_params,
 
  385                                            _preload_content=_preload_content,
 
  386                                            _request_timeout=_request_timeout,
 
  390                 "http method must be `GET`, `HEAD`, `OPTIONS`," 
  391                 " `POST`, `PATCH`, `PUT` or `DELETE`." 
  395         """Get parameters as list of tuples, formatting collections. 
  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 
  402         if collection_formats 
is None:
 
  403             collection_formats = {}
 
  404         for k, v 
in six.iteritems(params) 
if isinstance(params, dict) 
else params:  
 
  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)
 
  410                     if collection_format == 
'ssv':
 
  412                     elif collection_format == 
'tsv':
 
  414                     elif collection_format == 
'pipes':
 
  419                         (k, delimiter.join(
str(value) 
for value 
in v)))
 
  421                 new_params.append((k, v))
 
  425         """Builds form parameters. 
  427         :param post_params: Normal form parameters. 
  428         :param files: File parameters. 
  429         :return: Form parameters with files. 
  437             for k, v 
in six.iteritems(files):
 
  440                 file_names = v 
if type(v) 
is list 
else [v]
 
  442                     with open(n, 
'rb') 
as f:
 
  443                         filename = os.path.basename(f.name)
 
  445                         mimetype = (mimetypes.guess_type(filename)[0] 
or 
  446                                     'application/octet-stream')
 
  448                             tuple([k, tuple([filename, filedata, mimetype])]))
 
  453         """Returns `Accept` based on an array of accepts provided. 
  455         :param accepts: List of headers. 
  456         :return: Accept (e.g. application/json). 
  461         accepts = [x.lower() 
for x 
in accepts]
 
  463         if 'application/json' in accepts:
 
  464             return 'application/json' 
  466             return ', '.join(accepts)
 
  469         """Returns `Content-Type` based on an array of content_types provided. 
  471         :param content_types: List of content-types. 
  472         :return: Content-Type (e.g. application/json). 
  474         if not content_types:
 
  475             return 'application/json' 
  477         content_types = [x.lower() 
for x 
in content_types]
 
  479         if 'application/json' in content_types 
or '*/*' in content_types:
 
  480             return 'application/json' 
  482             return content_types[0]
 
  485         """Updates header and query params based on authentication setting. 
  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. 
  491         if not auth_settings:
 
  494         for auth 
in auth_settings:
 
  495             auth_setting = self.
configurationconfiguration.auth_settings().get(auth)
 
  497                 if not auth_setting[
'value']:
 
  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']))
 
  505                         'Authentication token must be in `query` or `header`' 
  508     def __deserialize_file(self, response):
 
  509         """Deserializes body to file 
  511         Saves response body into a file in a temporary folder, 
  512         using the filename from the `Content-Disposition` header if provided. 
  514         :param response:  RESTResponse. 
  517         fd, path = tempfile.mkstemp(dir=self.
configurationconfiguration.temp_folder_path)
 
  521         content_disposition = response.getheader(
"Content-Disposition")
 
  522         if content_disposition:
 
  523             filename = re.search(
r'filename=[\'"]?([^\'"\s]+)[\'"]?',
 
  524                                  content_disposition).group(1)
 
  525             path = os.path.join(os.path.dirname(path), filename)
 
  526             response_data = response.data
 
  527             with open(path, 
"wb") 
as f:
 
  528                 if isinstance(response_data, str):
 
  530                     response_data = response_data.encode(
'utf-8')
 
  531                     f.write(response_data)
 
  533                     f.write(response_data)
 
  536     def __deserialize_primitive(self, data, klass):
 
  537         """Deserializes string to primitive type. 
  540         :param klass: class literal. 
  542         :return: int, long, float, str, bool. 
  546         except UnicodeEncodeError:
 
  547             return six.text_type(data)
 
  551     def __deserialize_object(self, value):
 
  552         """Return a original value. 
  558     def __deserialize_date(self, string):
 
  559         """Deserializes string to date. 
  565             from dateutil.parser 
import parse
 
  566             return parse(string).date()
 
  572                 reason=
"Failed to parse `{0}` as date object".format(string)
 
  575     def __deserialize_datatime(self, string):
 
  576         """Deserializes string to datetime. 
  578         The string should be in iso8601 datetime format. 
  584             from dateutil.parser 
import parse
 
  592                     "Failed to parse `{0}` as datetime object" 
  597     def __hasattr(self, object, name):
 
  598             return name 
in object.__class__.__dict__
 
  600     def __deserialize_model(self, data, klass):
 
  601         """Deserializes list or dict to model. 
  603         :param data: dict, list. 
  604         :param klass: class literal. 
  605         :return: model object. 
  608         if not klass.swagger_types 
and not self.
__hasattr__hasattr(klass, 
'get_real_child_model'):
 
  612         if klass.swagger_types 
is not None:
 
  613             for attr, attr_type 
in six.iteritems(klass.swagger_types):
 
  614                 if (data 
is not None and 
  615                         klass.attribute_map[attr] 
in data 
and 
  616                         isinstance(data, (list, dict))):
 
  617                     value = data[klass.attribute_map[attr]]
 
  618                     kwargs[attr] = self.
__deserialize__deserialize(value, attr_type)
 
  620         instance = klass(**kwargs)
 
  622         if (isinstance(instance, dict) 
and 
  623                 klass.swagger_types 
is not None and 
  624                 isinstance(data, dict)):
 
  625             for key, value 
in data.items():
 
  626                 if key 
not in klass.swagger_types:
 
  627                     instance[key] = value
 
  628         if self.
__hasattr__hasattr(instance, 
'get_real_child_model'):
 
  629             klass_name = instance.get_real_child_model(data)
 
def set_default_header(self, header_name, header_value)
def sanitize_for_serialization(self, obj)
def update_params_for_auth(self, headers, querys, auth_settings)
def deserialize(self, response, response_type)
def __deserialize_model(self, data, klass)
def parameters_to_tuples(self, params, collection_formats)
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, _return_http_data_only=None, collection_formats=None, _preload_content=True, _request_timeout=None)
def __deserialize_file(self, response)
def __deserialize_date(self, string)
def __deserialize_object(self, value)
def __deserialize_primitive(self, data, klass)
def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None)
def select_header_content_type(self, content_types)
def user_agent(self, value)
def prepare_post_parameters(self, post_params=None, files=None)
dictionary NATIVE_TYPES_MAPPING
def __hasattr(self, object, name)
def select_header_accept(self, accepts)
def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)
def __deserialize_datatime(self, string)
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 __deserialize(self, data, klass)