Skip to content
Snippets Groups Projects
Commit c6abdd4f authored by Daniel Hornung's avatar Daniel Hornung
Browse files

ENH: Added auto-generated swagger client.

parent d30a4efa
Branches
Tags
2 merge requests!22Release 0.3,!3Bloxberg proof of concept
Showing
with 2780 additions and 0 deletions
# coding: utf-8
# flake8: noqa
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
# Fake the installation
import sys, pathlib
__this_dir = str(pathlib.Path(__file__).parent.parent)
if __this_dir not in sys.path:
sys.path.append(__this_dir)
# import apis into sdk package
from swagger_client.api.certificate_api import CertificateApi
from swagger_client.api.pdf_api import PdfApi
# import ApiClient
from swagger_client.api_client import ApiClient
from swagger_client.configuration import Configuration
# import models into sdk package
from swagger_client.models.batch import Batch
from swagger_client.models.controller_cert_tools_generate_pdf_json_certificate import ControllerCertToolsGeneratePdfJsonCertificate
from swagger_client.models.controller_cert_tools_generate_unsigned_certificate_json_certificate import ControllerCertToolsGenerateUnsignedCertificateJsonCertificate
from swagger_client.models.http_validation_error import HTTPValidationError
from swagger_client.models.validation_error import ValidationError
from __future__ import absolute_import
# flake8: noqa
# import apis into api package
from swagger_client.api.certificate_api import CertificateApi
from swagger_client.api.pdf_api import PdfApi
# coding: utf-8
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import re # noqa: F401
# python 2 and python 3 compatibility library
import six
from swagger_client.api_client import ApiClient
class CertificateApi(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
def create_bloxberg_certificate_create_bloxberg_certificate_post(self, body, **kwargs): # noqa: E501
"""Createbloxbergcertificate # noqa: E501
Creates, transacts, and signs a research object certificate on the bloxberg blockchain. Hashes must be generated client side for each desired file and provided in an array. Each hash corresponds to one research object certificate returned in a JSON object array. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.create_bloxberg_certificate_create_bloxberg_certificate_post(body, async_req=True)
>>> result = thread.get()
:param async_req bool
:param Batch body: (required)
:return: list[ControllerCertToolsGenerateUnsignedCertificateJsonCertificate]
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.create_bloxberg_certificate_create_bloxberg_certificate_post_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.create_bloxberg_certificate_create_bloxberg_certificate_post_with_http_info(body, **kwargs) # noqa: E501
return data
def create_bloxberg_certificate_create_bloxberg_certificate_post_with_http_info(self, body, **kwargs): # noqa: E501
"""Createbloxbergcertificate # noqa: E501
Creates, transacts, and signs a research object certificate on the bloxberg blockchain. Hashes must be generated client side for each desired file and provided in an array. Each hash corresponds to one research object certificate returned in a JSON object array. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.create_bloxberg_certificate_create_bloxberg_certificate_post_with_http_info(body, async_req=True)
>>> result = thread.get()
:param async_req bool
:param Batch body: (required)
:return: list[ControllerCertToolsGenerateUnsignedCertificateJsonCertificate]
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['body'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method create_bloxberg_certificate_create_bloxberg_certificate_post" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'body' is set
if ('body' not in params or
params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `create_bloxberg_certificate_create_bloxberg_certificate_post`") # noqa: E501
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'body' in params:
body_params = params['body']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
# Authentication setting
auth_settings = [] # noqa: E501
return self.api_client.call_api(
'/createBloxbergCertificate', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='list[ControllerCertToolsGenerateUnsignedCertificateJsonCertificate]', # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
# coding: utf-8
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import re # noqa: F401
# python 2 and python 3 compatibility library
import six
from swagger_client.api_client import ApiClient
class PdfApi(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
def generate_pdf_generate_pdf_post(self, body, **kwargs): # noqa: E501
"""Generatepdf # noqa: E501
Accepts as input the response from the createBloxbergCertificate endpoint, for example a research object JSON array. Returns as response a zip archive with PDF files that correspond to the number of cryptographic identifiers provided. PDF files are embedded with the Research Object Certification which is used for verification. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.generate_pdf_generate_pdf_post(body, async_req=True)
>>> result = thread.get()
:param async_req bool
:param list[ControllerCertToolsGeneratePdfJsonCertificate] body: (required)
:return: Object
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.generate_pdf_generate_pdf_post_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.generate_pdf_generate_pdf_post_with_http_info(body, **kwargs) # noqa: E501
return data
def generate_pdf_generate_pdf_post_with_http_info(self, body, **kwargs): # noqa: E501
"""Generatepdf # noqa: E501
Accepts as input the response from the createBloxbergCertificate endpoint, for example a research object JSON array. Returns as response a zip archive with PDF files that correspond to the number of cryptographic identifiers provided. PDF files are embedded with the Research Object Certification which is used for verification. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.generate_pdf_generate_pdf_post_with_http_info(body, async_req=True)
>>> result = thread.get()
:param async_req bool
:param list[ControllerCertToolsGeneratePdfJsonCertificate] body: (required)
:return: Object
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['body'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method generate_pdf_generate_pdf_post" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'body' is set
if ('body' not in params or
params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `generate_pdf_generate_pdf_post`") # noqa: E501
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'body' in params:
body_params = params['body']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
# Authentication setting
auth_settings = [] # noqa: E501
return self.api_client.call_api(
'/generatePDF', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Object', # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
# coding: utf-8
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import datetime
import json
import mimetypes
from multiprocessing.pool import ThreadPool
import os
import re
import tempfile
# python 2 and python 3 compatibility library
import six
from six.moves.urllib.parse import quote
from swagger_client.configuration import Configuration
import swagger_client.models
from swagger_client import rest
class ApiClient(object):
"""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
"""
PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
NATIVE_TYPES_MAPPING = {
'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,
}
def __init__(self, configuration=None, header_name=None, header_value=None,
cookie=None):
if configuration is None:
configuration = Configuration()
self.configuration = configuration
self.pool = ThreadPool()
self.rest_client = rest.RESTClientObject(configuration)
self.default_headers = {}
if header_name is not None:
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'Swagger-Codegen/1.0.0/python'
def __del__(self):
self.pool.close()
self.pool.join()
@property
def user_agent(self):
"""User agent for this API client"""
return self.default_headers['User-Agent']
@user_agent.setter
def user_agent(self, value):
self.default_headers['User-Agent'] = value
def set_default_header(self, header_name, header_value):
self.default_headers[header_name] = header_value
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):
config = self.configuration
# header parameters
header_params = header_params or {}
header_params.update(self.default_headers)
if self.cookie:
header_params['Cookie'] = self.cookie
if header_params:
header_params = self.sanitize_for_serialization(header_params)
header_params = dict(self.parameters_to_tuples(header_params,
collection_formats))
# path parameters
if path_params:
path_params = self.sanitize_for_serialization(path_params)
path_params = self.parameters_to_tuples(path_params,
collection_formats)
for k, v in path_params:
# specified safe chars, encode everything
resource_path = resource_path.replace(
'{%s}' % k,
quote(str(v), safe=config.safe_chars_for_path_param)
)
# query parameters
if query_params:
query_params = self.sanitize_for_serialization(query_params)
query_params = self.parameters_to_tuples(query_params,
collection_formats)
# post parameters
if post_params or files:
post_params = self.prepare_post_parameters(post_params, files)
post_params = self.sanitize_for_serialization(post_params)
post_params = self.parameters_to_tuples(post_params,
collection_formats)
# auth setting
self.update_params_for_auth(header_params, query_params, auth_settings)
# body
if body:
body = self.sanitize_for_serialization(body)
# request url
url = self.configuration.host + resource_path
# perform request and return response
response_data = self.request(
method, url, query_params=query_params, headers=header_params,
post_params=post_params, body=body,
_preload_content=_preload_content,
_request_timeout=_request_timeout)
self.last_response = response_data
return_data = response_data
if _preload_content:
# deserialize response data
if response_type:
return_data = self.deserialize(response_data, response_type)
else:
return_data = None
if _return_http_data_only:
return (return_data)
else:
return (return_data, response_data.status,
response_data.getheaders())
def 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.
"""
if obj is None:
return None
elif isinstance(obj, self.PRIMITIVE_TYPES):
return obj
elif isinstance(obj, list):
return [self.sanitize_for_serialization(sub_obj)
for sub_obj in obj]
elif isinstance(obj, tuple):
return tuple(self.sanitize_for_serialization(sub_obj)
for sub_obj in obj)
elif isinstance(obj, (datetime.datetime, datetime.date)):
return obj.isoformat()
if isinstance(obj, dict):
obj_dict = obj
else:
# Convert model obj to dict except
# attributes `swagger_types`, `attribute_map`
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
for attr, _ in six.iteritems(obj.swagger_types)
if getattr(obj, attr) is not None}
return {key: self.sanitize_for_serialization(val)
for key, val in six.iteritems(obj_dict)}
def 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.
"""
# handle file downloading
# save response body into a tmp file and return the instance
if response_type == "file":
return self.__deserialize_file(response)
# fetch data from response object
try:
data = json.loads(response.data)
except ValueError:
data = response.data
return self.__deserialize(data, response_type)
def __deserialize(self, data, klass):
"""Deserializes dict, list, str into an object.
:param data: dict, list or str.
:param klass: class literal, or string of class name.
:return: object.
"""
if data is None:
return None
if type(klass) == str:
if klass.startswith('list['):
sub_kls = re.match(r'list\[(.*)\]', klass).group(1)
return [self.__deserialize(sub_data, sub_kls)
for sub_data in data]
if klass.startswith('dict('):
sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2)
return {k: self.__deserialize(v, sub_kls)
for k, v in six.iteritems(data)}
# convert str to class
if klass in self.NATIVE_TYPES_MAPPING:
klass = self.NATIVE_TYPES_MAPPING[klass]
else:
klass = getattr(swagger_client.models, klass)
if klass in self.PRIMITIVE_TYPES:
return self.__deserialize_primitive(data, klass)
elif klass == object:
return self.__deserialize_object(data)
elif klass == datetime.date:
return self.__deserialize_date(data)
elif klass == datetime.datetime:
return self.__deserialize_datatime(data)
else:
return self.__deserialize_model(data, klass)
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):
"""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.
"""
if not async_req:
return self.__call_api(resource_path, method,
path_params, query_params, header_params,
body, post_params, files,
response_type, auth_settings,
_return_http_data_only, collection_formats,
_preload_content, _request_timeout)
else:
thread = self.pool.apply_async(self.__call_api, (resource_path,
method, path_params, query_params,
header_params, body,
post_params, files,
response_type, auth_settings,
_return_http_data_only,
collection_formats,
_preload_content, _request_timeout))
return thread
def 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."""
if method == "GET":
return self.rest_client.GET(url,
query_params=query_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
headers=headers)
elif method == "HEAD":
return self.rest_client.HEAD(url,
query_params=query_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
headers=headers)
elif method == "OPTIONS":
return self.rest_client.OPTIONS(url,
query_params=query_params,
headers=headers,
post_params=post_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
elif method == "POST":
return self.rest_client.POST(url,
query_params=query_params,
headers=headers,
post_params=post_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
elif method == "PUT":
return self.rest_client.PUT(url,
query_params=query_params,
headers=headers,
post_params=post_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
elif method == "PATCH":
return self.rest_client.PATCH(url,
query_params=query_params,
headers=headers,
post_params=post_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
elif method == "DELETE":
return self.rest_client.DELETE(url,
query_params=query_params,
headers=headers,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
else:
raise ValueError(
"http method must be `GET`, `HEAD`, `OPTIONS`,"
" `POST`, `PATCH`, `PUT` or `DELETE`."
)
def 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
"""
new_params = []
if collection_formats is None:
collection_formats = {}
for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501
if k in collection_formats:
collection_format = collection_formats[k]
if collection_format == 'multi':
new_params.extend((k, value) for value in v)
else:
if collection_format == 'ssv':
delimiter = ' '
elif collection_format == 'tsv':
delimiter = '\t'
elif collection_format == 'pipes':
delimiter = '|'
else: # csv is the default
delimiter = ','
new_params.append(
(k, delimiter.join(str(value) for value in v)))
else:
new_params.append((k, v))
return new_params
def 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.
"""
params = []
if post_params:
params = post_params
if files:
for k, v in six.iteritems(files):
if not v:
continue
file_names = v if type(v) is list else [v]
for n in file_names:
with open(n, 'rb') as f:
filename = os.path.basename(f.name)
filedata = f.read()
mimetype = (mimetypes.guess_type(filename)[0] or
'application/octet-stream')
params.append(
tuple([k, tuple([filename, filedata, mimetype])]))
return params
def 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).
"""
if not accepts:
return
accepts = [x.lower() for x in accepts]
if 'application/json' in accepts:
return 'application/json'
else:
return ', '.join(accepts)
def 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).
"""
if not content_types:
return 'application/json'
content_types = [x.lower() for x in content_types]
if 'application/json' in content_types or '*/*' in content_types:
return 'application/json'
else:
return content_types[0]
def 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.
"""
if not auth_settings:
return
for auth in auth_settings:
auth_setting = self.configuration.auth_settings().get(auth)
if auth_setting:
if not auth_setting['value']:
continue
elif auth_setting['in'] == 'header':
headers[auth_setting['key']] = auth_setting['value']
elif auth_setting['in'] == 'query':
querys.append((auth_setting['key'], auth_setting['value']))
else:
raise ValueError(
'Authentication token must be in `query` or `header`'
)
def __deserialize_file(self, response):
"""Deserializes body to file
Saves response body into a file in a temporary folder,
using the filename from the `Content-Disposition` header if provided.
:param response: RESTResponse.
:return: file path.
"""
fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
os.close(fd)
os.remove(path)
content_disposition = response.getheader("Content-Disposition")
if content_disposition:
filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?',
content_disposition).group(1)
path = os.path.join(os.path.dirname(path), filename)
with open(path, "wb") as f:
f.write(response.data)
return path
def __deserialize_primitive(self, data, klass):
"""Deserializes string to primitive type.
:param data: str.
:param klass: class literal.
:return: int, long, float, str, bool.
"""
try:
return klass(data)
except UnicodeEncodeError:
return six.text_type(data)
except TypeError:
return data
def __deserialize_object(self, value):
"""Return a original value.
:return: object.
"""
return value
def __deserialize_date(self, string):
"""Deserializes string to date.
:param string: str.
:return: date.
"""
try:
from dateutil.parser import parse
return parse(string).date()
except ImportError:
return string
except ValueError:
raise rest.ApiException(
status=0,
reason="Failed to parse `{0}` as date object".format(string)
)
def __deserialize_datatime(self, string):
"""Deserializes string to datetime.
The string should be in iso8601 datetime format.
:param string: str.
:return: datetime.
"""
try:
from dateutil.parser import parse
return parse(string)
except ImportError:
return string
except ValueError:
raise rest.ApiException(
status=0,
reason=(
"Failed to parse `{0}` as datetime object"
.format(string)
)
)
def __hasattr(self, object, name):
return name in object.__class__.__dict__
def __deserialize_model(self, data, klass):
"""Deserializes list or dict to model.
:param data: dict, list.
:param klass: class literal.
:return: model object.
"""
if not klass.swagger_types and not self.__hasattr(klass, 'get_real_child_model'):
return data
kwargs = {}
if klass.swagger_types is not None:
for attr, attr_type in six.iteritems(klass.swagger_types):
if (data is not None and
klass.attribute_map[attr] in data and
isinstance(data, (list, dict))):
value = data[klass.attribute_map[attr]]
kwargs[attr] = self.__deserialize(value, attr_type)
instance = klass(**kwargs)
if (isinstance(instance, dict) and
klass.swagger_types is not None and
isinstance(data, dict)):
for key, value in data.items():
if key not in klass.swagger_types:
instance[key] = value
if self.__hasattr(instance, 'get_real_child_model'):
klass_name = instance.get_real_child_model(data)
if klass_name:
instance = self.__deserialize(data, klass_name)
return instance
# coding: utf-8
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import copy
import logging
import multiprocessing
import sys
import urllib3
import six
from six.moves import http_client as httplib
class TypeWithDefault(type):
def __init__(cls, name, bases, dct):
super(TypeWithDefault, cls).__init__(name, bases, dct)
cls._default = None
def __call__(cls):
if cls._default is None:
cls._default = type.__call__(cls)
return copy.copy(cls._default)
def set_default(cls, default):
cls._default = copy.copy(default)
class Configuration(six.with_metaclass(TypeWithDefault, object)):
"""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.
"""
def __init__(self):
"""Constructor"""
# Default Base url
self.host = "https://qa.certify.bloxberg.org"
# Temp file folder for downloading files
self.temp_folder_path = None
# Authentication Settings
# dict to store API key(s)
self.api_key = {}
# dict to store API prefix (e.g. Bearer)
self.api_key_prefix = {}
# function to refresh API key if expired
self.refresh_api_key_hook = None
# Username for HTTP basic authentication
self.username = ""
# Password for HTTP basic authentication
self.password = ""
# Logging Settings
self.logger = {}
self.logger["package_logger"] = logging.getLogger("swagger_client")
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
# Log format
self.logger_format = '%(asctime)s %(levelname)s %(message)s'
# Log stream handler
self.logger_stream_handler = None
# Log file handler
self.logger_file_handler = None
# Debug file location
self.logger_file = None
# Debug switch
self.debug = False
# SSL/TLS verification
# Set this to false to skip verifying SSL certificate when calling API
# from https server.
self.verify_ssl = True
# Set this to customize the certificate file to verify the peer.
self.ssl_ca_cert = None
# client certificate file
self.cert_file = None
# client key file
self.key_file = None
# Set this to True/False to enable/disable SSL hostname verification.
self.assert_hostname = None
# urllib3 connection pool's maximum number of connections saved
# per pool. urllib3 uses 1 connection as default value, but this is
# not the best value when you are making a lot of possibly parallel
# requests to the same host, which is often the case here.
# cpu_count * 5 is used as default value to increase performance.
self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
# Proxy URL
self.proxy = None
# Safe chars for path_param
self.safe_chars_for_path_param = ''
@property
def logger_file(self):
"""The logger file.
If the logger_file is None, then add stream handler and remove file
handler. Otherwise, add file handler and remove stream handler.
:param value: The logger_file path.
:type: str
"""
return self.__logger_file
@logger_file.setter
def logger_file(self, value):
"""The logger file.
If the logger_file is None, then add stream handler and remove file
handler. Otherwise, add file handler and remove stream handler.
:param value: The logger_file path.
:type: str
"""
self.__logger_file = value
if self.__logger_file:
# If set logging file,
# then add file handler and remove stream handler.
self.logger_file_handler = logging.FileHandler(self.__logger_file)
self.logger_file_handler.setFormatter(self.logger_formatter)
for _, logger in six.iteritems(self.logger):
logger.addHandler(self.logger_file_handler)
if self.logger_stream_handler:
logger.removeHandler(self.logger_stream_handler)
else:
# If not set logging file,
# then add stream handler and remove file handler.
self.logger_stream_handler = logging.StreamHandler()
self.logger_stream_handler.setFormatter(self.logger_formatter)
for _, logger in six.iteritems(self.logger):
logger.addHandler(self.logger_stream_handler)
if self.logger_file_handler:
logger.removeHandler(self.logger_file_handler)
@property
def debug(self):
"""Debug status
:param value: The debug status, True or False.
:type: bool
"""
return self.__debug
@debug.setter
def debug(self, value):
"""Debug status
:param value: The debug status, True or False.
:type: bool
"""
self.__debug = value
if self.__debug:
# if debug status is True, turn on debug logging
for _, logger in six.iteritems(self.logger):
logger.setLevel(logging.DEBUG)
# turn on httplib debug
httplib.HTTPConnection.debuglevel = 1
else:
# if debug status is False, turn off debug logging,
# setting log level to default `logging.WARNING`
for _, logger in six.iteritems(self.logger):
logger.setLevel(logging.WARNING)
# turn off httplib debug
httplib.HTTPConnection.debuglevel = 0
@property
def logger_format(self):
"""The logger format.
The logger_formatter will be updated when sets logger_format.
:param value: The format string.
:type: str
"""
return self.__logger_format
@logger_format.setter
def logger_format(self, value):
"""The logger format.
The logger_formatter will be updated when sets logger_format.
:param value: The format string.
:type: str
"""
self.__logger_format = value
self.logger_formatter = logging.Formatter(self.__logger_format)
def get_api_key_with_prefix(self, identifier):
"""Gets API key (with prefix if set).
:param identifier: The identifier of apiKey.
:return: The token for api key authentication.
"""
if self.refresh_api_key_hook:
self.refresh_api_key_hook(self)
key = self.api_key.get(identifier)
if key:
prefix = self.api_key_prefix.get(identifier)
if prefix:
return "%s %s" % (prefix, key)
else:
return key
def get_basic_auth_token(self):
"""Gets HTTP basic authentication header (string).
:return: The token for basic HTTP authentication.
"""
return urllib3.util.make_headers(
basic_auth=self.username + ':' + self.password
).get('authorization')
def auth_settings(self):
"""Gets Auth Settings dict for api client.
:return: The Auth Settings information dict.
"""
return {
}
def to_debug_report(self):
"""Gets the essential information for debugging.
:return: The report for debugging.
"""
return "Python SDK Debug Report:\n"\
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: 0.2.0\n"\
"SDK Package Version: 1.0.0".\
format(env=sys.platform, pyversion=sys.version)
# coding: utf-8
# flake8: noqa
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
# import models into model package
from swagger_client.models.batch import Batch
from swagger_client.models.controller_cert_tools_generate_pdf_json_certificate import ControllerCertToolsGeneratePdfJsonCertificate
from swagger_client.models.controller_cert_tools_generate_unsigned_certificate_json_certificate import ControllerCertToolsGenerateUnsignedCertificateJsonCertificate
from swagger_client.models.http_validation_error import HTTPValidationError
from swagger_client.models.validation_error import ValidationError
# coding: utf-8
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
class Batch(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
'public_key': 'str',
'crid': 'list[str]',
'crid_type': 'str',
'enable_ipfs': 'bool',
'metadata_json': 'str'
}
attribute_map = {
'public_key': 'publicKey',
'crid': 'crid',
'crid_type': 'cridType',
'enable_ipfs': 'enableIPFS',
'metadata_json': 'metadataJson'
}
def __init__(self, public_key=None, crid=None, crid_type=None, enable_ipfs=None, metadata_json=None): # noqa: E501
"""Batch - a model defined in Swagger""" # noqa: E501
self._public_key = None
self._crid = None
self._crid_type = None
self._enable_ipfs = None
self._metadata_json = None
self.discriminator = None
self.public_key = public_key
self.crid = crid
if crid_type is not None:
self.crid_type = crid_type
self.enable_ipfs = enable_ipfs
if metadata_json is not None:
self.metadata_json = metadata_json
@property
def public_key(self):
"""Gets the public_key of this Batch. # noqa: E501
Public bloxberg address where the Research Object Certificate token will be minted # noqa: E501
:return: The public_key of this Batch. # noqa: E501
:rtype: str
"""
return self._public_key
@public_key.setter
def public_key(self, public_key):
"""Sets the public_key of this Batch.
Public bloxberg address where the Research Object Certificate token will be minted # noqa: E501
:param public_key: The public_key of this Batch. # noqa: E501
:type: str
"""
if public_key is None:
raise ValueError("Invalid value for `public_key`, must not be `None`") # noqa: E501
self._public_key = public_key
@property
def crid(self):
"""Gets the crid of this Batch. # noqa: E501
Cryptographic Identifier of each file you wish to certify. One certificate will be generated per hash up to a maximum of 1001 in a single request # noqa: E501
:return: The crid of this Batch. # noqa: E501
:rtype: list[str]
"""
return self._crid
@crid.setter
def crid(self, crid):
"""Sets the crid of this Batch.
Cryptographic Identifier of each file you wish to certify. One certificate will be generated per hash up to a maximum of 1001 in a single request # noqa: E501
:param crid: The crid of this Batch. # noqa: E501
:type: list[str]
"""
if crid is None:
raise ValueError("Invalid value for `crid`, must not be `None`") # noqa: E501
self._crid = crid
@property
def crid_type(self):
"""Gets the crid_type of this Batch. # noqa: E501
If crid is not self-describing, provide the type of cryptographic function you used to generate the cryptographic identifier. Please use the name field from the multihash list to ensure compatibility: https://github.com/multiformats/multicodec/blob/master/table.csv # noqa: E501
:return: The crid_type of this Batch. # noqa: E501
:rtype: str
"""
return self._crid_type
@crid_type.setter
def crid_type(self, crid_type):
"""Sets the crid_type of this Batch.
If crid is not self-describing, provide the type of cryptographic function you used to generate the cryptographic identifier. Please use the name field from the multihash list to ensure compatibility: https://github.com/multiformats/multicodec/blob/master/table.csv # noqa: E501
:param crid_type: The crid_type of this Batch. # noqa: E501
:type: str
"""
self._crid_type = crid_type
@property
def enable_ipfs(self):
"""Gets the enable_ipfs of this Batch. # noqa: E501
EXPERIMENTAL: Set to true to enable posting certificate to IPFS. If set to false, will simply return certificates in the response. By default, this is disabled on the server due to performance and storage problems with IPFS # noqa: E501
:return: The enable_ipfs of this Batch. # noqa: E501
:rtype: bool
"""
return self._enable_ipfs
@enable_ipfs.setter
def enable_ipfs(self, enable_ipfs):
"""Sets the enable_ipfs of this Batch.
EXPERIMENTAL: Set to true to enable posting certificate to IPFS. If set to false, will simply return certificates in the response. By default, this is disabled on the server due to performance and storage problems with IPFS # noqa: E501
:param enable_ipfs: The enable_ipfs of this Batch. # noqa: E501
:type: bool
"""
if enable_ipfs is None:
raise ValueError("Invalid value for `enable_ipfs`, must not be `None`") # noqa: E501
self._enable_ipfs = enable_ipfs
@property
def metadata_json(self):
"""Gets the metadata_json of this Batch. # noqa: E501
Provide optional metadata to describe the research object batch in more detail that will be included in the certificate. # noqa: E501
:return: The metadata_json of this Batch. # noqa: E501
:rtype: str
"""
return self._metadata_json
@metadata_json.setter
def metadata_json(self, metadata_json):
"""Sets the metadata_json of this Batch.
Provide optional metadata to describe the research object batch in more detail that will be included in the certificate. # noqa: E501
:param metadata_json: The metadata_json of this Batch. # noqa: E501
:type: str
"""
self._metadata_json = metadata_json
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
if issubclass(Batch, dict):
for key, value in self.items():
result[key] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, Batch):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other
# coding: utf-8
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
class ControllerCertToolsGeneratePdfJsonCertificate(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
'context': 'list[str]',
'id': 'str',
'type': 'list[str]',
'issuer': 'str',
'issuance_date': 'str',
'credential_subject': 'object',
'display_html': 'str',
'crid': 'str',
'crid_type': 'str',
'metadata_json': 'str',
'proof': 'object'
}
attribute_map = {
'context': '@context',
'id': 'id',
'type': 'type',
'issuer': 'issuer',
'issuance_date': 'issuanceDate',
'credential_subject': 'credentialSubject',
'display_html': 'displayHtml',
'crid': 'crid',
'crid_type': 'cridType',
'metadata_json': 'metadataJson',
'proof': 'proof'
}
def __init__(self, context=None, id=None, type=None, issuer=None, issuance_date=None, credential_subject=None, display_html=None, crid=None, crid_type=None, metadata_json=None, proof=None): # noqa: E501
"""ControllerCertToolsGeneratePdfJsonCertificate - a model defined in Swagger""" # noqa: E501
self._context = None
self._id = None
self._type = None
self._issuer = None
self._issuance_date = None
self._credential_subject = None
self._display_html = None
self._crid = None
self._crid_type = None
self._metadata_json = None
self._proof = None
self.discriminator = None
if context is not None:
self.context = context
self.id = id
self.type = type
self.issuer = issuer
self.issuance_date = issuance_date
self.credential_subject = credential_subject
if display_html is not None:
self.display_html = display_html
self.crid = crid
if crid_type is not None:
self.crid_type = crid_type
if metadata_json is not None:
self.metadata_json = metadata_json
self.proof = proof
@property
def context(self):
"""Gets the context of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
Relevant JSON-LD context links in order to validate Verifiable Credentials according to their spec. # noqa: E501
:return: The context of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: list[str]
"""
return self._context
@context.setter
def context(self, context):
"""Sets the context of this ControllerCertToolsGeneratePdfJsonCertificate.
Relevant JSON-LD context links in order to validate Verifiable Credentials according to their spec. # noqa: E501
:param context: The context of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: list[str]
"""
self._context = context
@property
def id(self):
"""Gets the id of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:return: The id of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: str
"""
return self._id
@id.setter
def id(self, id):
"""Sets the id of this ControllerCertToolsGeneratePdfJsonCertificate.
:param id: The id of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: str
"""
if id is None:
raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501
self._id = id
@property
def type(self):
"""Gets the type of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:return: The type of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: list[str]
"""
return self._type
@type.setter
def type(self, type):
"""Sets the type of this ControllerCertToolsGeneratePdfJsonCertificate.
:param type: The type of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: list[str]
"""
if type is None:
raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
self._type = type
@property
def issuer(self):
"""Gets the issuer of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:return: The issuer of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: str
"""
return self._issuer
@issuer.setter
def issuer(self, issuer):
"""Sets the issuer of this ControllerCertToolsGeneratePdfJsonCertificate.
:param issuer: The issuer of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: str
"""
if issuer is None:
raise ValueError("Invalid value for `issuer`, must not be `None`") # noqa: E501
self._issuer = issuer
@property
def issuance_date(self):
"""Gets the issuance_date of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:return: The issuance_date of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: str
"""
return self._issuance_date
@issuance_date.setter
def issuance_date(self, issuance_date):
"""Sets the issuance_date of this ControllerCertToolsGeneratePdfJsonCertificate.
:param issuance_date: The issuance_date of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: str
"""
if issuance_date is None:
raise ValueError("Invalid value for `issuance_date`, must not be `None`") # noqa: E501
self._issuance_date = issuance_date
@property
def credential_subject(self):
"""Gets the credential_subject of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:return: The credential_subject of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: object
"""
return self._credential_subject
@credential_subject.setter
def credential_subject(self, credential_subject):
"""Sets the credential_subject of this ControllerCertToolsGeneratePdfJsonCertificate.
:param credential_subject: The credential_subject of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: object
"""
if credential_subject is None:
raise ValueError("Invalid value for `credential_subject`, must not be `None`") # noqa: E501
self._credential_subject = credential_subject
@property
def display_html(self):
"""Gets the display_html of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:return: The display_html of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: str
"""
return self._display_html
@display_html.setter
def display_html(self, display_html):
"""Sets the display_html of this ControllerCertToolsGeneratePdfJsonCertificate.
:param display_html: The display_html of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: str
"""
self._display_html = display_html
@property
def crid(self):
"""Gets the crid of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:return: The crid of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: str
"""
return self._crid
@crid.setter
def crid(self, crid):
"""Sets the crid of this ControllerCertToolsGeneratePdfJsonCertificate.
:param crid: The crid of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: str
"""
if crid is None:
raise ValueError("Invalid value for `crid`, must not be `None`") # noqa: E501
self._crid = crid
@property
def crid_type(self):
"""Gets the crid_type of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:return: The crid_type of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: str
"""
return self._crid_type
@crid_type.setter
def crid_type(self, crid_type):
"""Sets the crid_type of this ControllerCertToolsGeneratePdfJsonCertificate.
:param crid_type: The crid_type of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: str
"""
self._crid_type = crid_type
@property
def metadata_json(self):
"""Gets the metadata_json of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:return: The metadata_json of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: str
"""
return self._metadata_json
@metadata_json.setter
def metadata_json(self, metadata_json):
"""Sets the metadata_json of this ControllerCertToolsGeneratePdfJsonCertificate.
:param metadata_json: The metadata_json of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: str
"""
self._metadata_json = metadata_json
@property
def proof(self):
"""Gets the proof of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:return: The proof of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:rtype: object
"""
return self._proof
@proof.setter
def proof(self, proof):
"""Sets the proof of this ControllerCertToolsGeneratePdfJsonCertificate.
:param proof: The proof of this ControllerCertToolsGeneratePdfJsonCertificate. # noqa: E501
:type: object
"""
if proof is None:
raise ValueError("Invalid value for `proof`, must not be `None`") # noqa: E501
self._proof = proof
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
if issubclass(ControllerCertToolsGeneratePdfJsonCertificate, dict):
for key, value in self.items():
result[key] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, ControllerCertToolsGeneratePdfJsonCertificate):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other
# coding: utf-8
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
class ControllerCertToolsGenerateUnsignedCertificateJsonCertificate(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
'context': 'list[str]',
'id': 'str',
'type': 'list[str]',
'issuer': 'str',
'issuance_date': 'str',
'credential_subject': 'object',
'display_html': 'str',
'crid': 'str',
'crid_type': 'str',
'metadata_json': 'str',
'proof': 'object'
}
attribute_map = {
'context': '@context',
'id': 'id',
'type': 'type',
'issuer': 'issuer',
'issuance_date': 'issuanceDate',
'credential_subject': 'credentialSubject',
'display_html': 'displayHtml',
'crid': 'crid',
'crid_type': 'cridType',
'metadata_json': 'metadataJson',
'proof': 'proof'
}
def __init__(self, context=None, id=None, type=None, issuer=None, issuance_date=None, credential_subject=None, display_html=None, crid=None, crid_type=None, metadata_json=None, proof=None): # noqa: E501
"""ControllerCertToolsGenerateUnsignedCertificateJsonCertificate - a model defined in Swagger""" # noqa: E501
self._context = None
self._id = None
self._type = None
self._issuer = None
self._issuance_date = None
self._credential_subject = None
self._display_html = None
self._crid = None
self._crid_type = None
self._metadata_json = None
self._proof = None
self.discriminator = None
if context is not None:
self.context = context
self.id = id
self.type = type
self.issuer = issuer
self.issuance_date = issuance_date
self.credential_subject = credential_subject
if display_html is not None:
self.display_html = display_html
self.crid = crid
if crid_type is not None:
self.crid_type = crid_type
if metadata_json is not None:
self.metadata_json = metadata_json
self.proof = proof
@property
def context(self):
"""Gets the context of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
Relevant JSON-LD context links in order to validate Verifiable Credentials according to their spec. # noqa: E501
:return: The context of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: list[str]
"""
return self._context
@context.setter
def context(self, context):
"""Sets the context of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
Relevant JSON-LD context links in order to validate Verifiable Credentials according to their spec. # noqa: E501
:param context: The context of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: list[str]
"""
self._context = context
@property
def id(self):
"""Gets the id of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:return: The id of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: str
"""
return self._id
@id.setter
def id(self, id):
"""Sets the id of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
:param id: The id of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: str
"""
if id is None:
raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501
self._id = id
@property
def type(self):
"""Gets the type of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:return: The type of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: list[str]
"""
return self._type
@type.setter
def type(self, type):
"""Sets the type of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
:param type: The type of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: list[str]
"""
if type is None:
raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
self._type = type
@property
def issuer(self):
"""Gets the issuer of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:return: The issuer of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: str
"""
return self._issuer
@issuer.setter
def issuer(self, issuer):
"""Sets the issuer of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
:param issuer: The issuer of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: str
"""
if issuer is None:
raise ValueError("Invalid value for `issuer`, must not be `None`") # noqa: E501
self._issuer = issuer
@property
def issuance_date(self):
"""Gets the issuance_date of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:return: The issuance_date of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: str
"""
return self._issuance_date
@issuance_date.setter
def issuance_date(self, issuance_date):
"""Sets the issuance_date of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
:param issuance_date: The issuance_date of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: str
"""
if issuance_date is None:
raise ValueError("Invalid value for `issuance_date`, must not be `None`") # noqa: E501
self._issuance_date = issuance_date
@property
def credential_subject(self):
"""Gets the credential_subject of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:return: The credential_subject of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: object
"""
return self._credential_subject
@credential_subject.setter
def credential_subject(self, credential_subject):
"""Sets the credential_subject of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
:param credential_subject: The credential_subject of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: object
"""
if credential_subject is None:
raise ValueError("Invalid value for `credential_subject`, must not be `None`") # noqa: E501
self._credential_subject = credential_subject
@property
def display_html(self):
"""Gets the display_html of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:return: The display_html of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: str
"""
return self._display_html
@display_html.setter
def display_html(self, display_html):
"""Sets the display_html of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
:param display_html: The display_html of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: str
"""
self._display_html = display_html
@property
def crid(self):
"""Gets the crid of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:return: The crid of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: str
"""
return self._crid
@crid.setter
def crid(self, crid):
"""Sets the crid of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
:param crid: The crid of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: str
"""
if crid is None:
raise ValueError("Invalid value for `crid`, must not be `None`") # noqa: E501
self._crid = crid
@property
def crid_type(self):
"""Gets the crid_type of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:return: The crid_type of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: str
"""
return self._crid_type
@crid_type.setter
def crid_type(self, crid_type):
"""Sets the crid_type of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
:param crid_type: The crid_type of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: str
"""
self._crid_type = crid_type
@property
def metadata_json(self):
"""Gets the metadata_json of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:return: The metadata_json of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: str
"""
return self._metadata_json
@metadata_json.setter
def metadata_json(self, metadata_json):
"""Sets the metadata_json of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
:param metadata_json: The metadata_json of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: str
"""
self._metadata_json = metadata_json
@property
def proof(self):
"""Gets the proof of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:return: The proof of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:rtype: object
"""
return self._proof
@proof.setter
def proof(self, proof):
"""Sets the proof of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate.
:param proof: The proof of this ControllerCertToolsGenerateUnsignedCertificateJsonCertificate. # noqa: E501
:type: object
"""
if proof is None:
raise ValueError("Invalid value for `proof`, must not be `None`") # noqa: E501
self._proof = proof
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
if issubclass(ControllerCertToolsGenerateUnsignedCertificateJsonCertificate, dict):
for key, value in self.items():
result[key] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, ControllerCertToolsGenerateUnsignedCertificateJsonCertificate):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other
# coding: utf-8
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
class HTTPValidationError(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
'detail': 'list[ValidationError]'
}
attribute_map = {
'detail': 'detail'
}
def __init__(self, detail=None): # noqa: E501
"""HTTPValidationError - a model defined in Swagger""" # noqa: E501
self._detail = None
self.discriminator = None
if detail is not None:
self.detail = detail
@property
def detail(self):
"""Gets the detail of this HTTPValidationError. # noqa: E501
:return: The detail of this HTTPValidationError. # noqa: E501
:rtype: list[ValidationError]
"""
return self._detail
@detail.setter
def detail(self, detail):
"""Sets the detail of this HTTPValidationError.
:param detail: The detail of this HTTPValidationError. # noqa: E501
:type: list[ValidationError]
"""
self._detail = detail
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
if issubclass(HTTPValidationError, dict):
for key, value in self.items():
result[key] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, HTTPValidationError):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other
# coding: utf-8
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
class ValidationError(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
'loc': 'list[str]',
'msg': 'str',
'type': 'str'
}
attribute_map = {
'loc': 'loc',
'msg': 'msg',
'type': 'type'
}
def __init__(self, loc=None, msg=None, type=None): # noqa: E501
"""ValidationError - a model defined in Swagger""" # noqa: E501
self._loc = None
self._msg = None
self._type = None
self.discriminator = None
self.loc = loc
self.msg = msg
self.type = type
@property
def loc(self):
"""Gets the loc of this ValidationError. # noqa: E501
:return: The loc of this ValidationError. # noqa: E501
:rtype: list[str]
"""
return self._loc
@loc.setter
def loc(self, loc):
"""Sets the loc of this ValidationError.
:param loc: The loc of this ValidationError. # noqa: E501
:type: list[str]
"""
if loc is None:
raise ValueError("Invalid value for `loc`, must not be `None`") # noqa: E501
self._loc = loc
@property
def msg(self):
"""Gets the msg of this ValidationError. # noqa: E501
:return: The msg of this ValidationError. # noqa: E501
:rtype: str
"""
return self._msg
@msg.setter
def msg(self, msg):
"""Sets the msg of this ValidationError.
:param msg: The msg of this ValidationError. # noqa: E501
:type: str
"""
if msg is None:
raise ValueError("Invalid value for `msg`, must not be `None`") # noqa: E501
self._msg = msg
@property
def type(self):
"""Gets the type of this ValidationError. # noqa: E501
:return: The type of this ValidationError. # noqa: E501
:rtype: str
"""
return self._type
@type.setter
def type(self, type):
"""Sets the type of this ValidationError.
:param type: The type of this ValidationError. # noqa: E501
:type: str
"""
if type is None:
raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
self._type = type
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
if issubclass(ValidationError, dict):
for key, value in self.items():
result[key] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, ValidationError):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other
# coding: utf-8
"""
Research Object Certification
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 0.2.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import io
import json
import logging
import re
import ssl
import certifi
# python 2 and python 3 compatibility library
import six
from six.moves.urllib.parse import urlencode
try:
import urllib3
except ImportError:
raise ImportError('Swagger python client requires urllib3.')
logger = logging.getLogger(__name__)
class RESTResponse(io.IOBase):
def __init__(self, resp):
self.urllib3_response = resp
self.status = resp.status
self.reason = resp.reason
self.data = resp.data
def getheaders(self):
"""Returns a dictionary of the response headers."""
return self.urllib3_response.getheaders()
def getheader(self, name, default=None):
"""Returns a given response header."""
return self.urllib3_response.getheader(name, default)
class RESTClientObject(object):
def __init__(self, configuration, pools_size=4, maxsize=None):
# urllib3.PoolManager will pass all kw parameters to connectionpool
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501
# maxsize is the number of requests to host that are allowed in parallel # noqa: E501
# Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501
# cert_reqs
if configuration.verify_ssl:
cert_reqs = ssl.CERT_REQUIRED
else:
cert_reqs = ssl.CERT_NONE
# ca_certs
if configuration.ssl_ca_cert:
ca_certs = configuration.ssl_ca_cert
else:
# if not set certificate file, use Mozilla's root certificates.
ca_certs = certifi.where()
addition_pool_args = {}
if configuration.assert_hostname is not None:
addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501
if maxsize is None:
if configuration.connection_pool_maxsize is not None:
maxsize = configuration.connection_pool_maxsize
else:
maxsize = 4
# https pool manager
if configuration.proxy:
self.pool_manager = urllib3.ProxyManager(
num_pools=pools_size,
maxsize=maxsize,
cert_reqs=cert_reqs,
ca_certs=ca_certs,
cert_file=configuration.cert_file,
key_file=configuration.key_file,
proxy_url=configuration.proxy,
**addition_pool_args
)
else:
self.pool_manager = urllib3.PoolManager(
num_pools=pools_size,
maxsize=maxsize,
cert_reqs=cert_reqs,
ca_certs=ca_certs,
cert_file=configuration.cert_file,
key_file=configuration.key_file,
**addition_pool_args
)
def request(self, method, url, query_params=None, headers=None,
body=None, post_params=None, _preload_content=True,
_request_timeout=None):
"""Perform requests.
:param method: http request method
:param url: http request url
:param query_params: query parameters in the url
:param headers: http request headers
:param body: request json body, for `application/json`
:param post_params: request post parameters,
`application/x-www-form-urlencoded`
and `multipart/form-data`
: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.
"""
method = method.upper()
assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT',
'PATCH', 'OPTIONS']
if post_params and body:
raise ValueError(
"body parameter cannot be used with post_params parameter."
)
post_params = post_params or {}
headers = headers or {}
timeout = None
if _request_timeout:
if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821
timeout = urllib3.Timeout(total=_request_timeout)
elif (isinstance(_request_timeout, tuple) and
len(_request_timeout) == 2):
timeout = urllib3.Timeout(
connect=_request_timeout[0], read=_request_timeout[1])
if 'Content-Type' not in headers:
headers['Content-Type'] = 'application/json'
try:
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
if query_params:
url += '?' + urlencode(query_params)
if re.search('json', headers['Content-Type'], re.IGNORECASE):
request_body = '{}'
if body is not None:
request_body = json.dumps(body)
r = self.pool_manager.request(
method, url,
body=request_body,
preload_content=_preload_content,
timeout=timeout,
headers=headers)
elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
r = self.pool_manager.request(
method, url,
fields=post_params,
encode_multipart=False,
preload_content=_preload_content,
timeout=timeout,
headers=headers)
elif headers['Content-Type'] == 'multipart/form-data':
# must del headers['Content-Type'], or the correct
# Content-Type which generated by urllib3 will be
# overwritten.
del headers['Content-Type']
r = self.pool_manager.request(
method, url,
fields=post_params,
encode_multipart=True,
preload_content=_preload_content,
timeout=timeout,
headers=headers)
# Pass a `string` parameter directly in the body to support
# other content types than Json when `body` argument is
# provided in serialized form
elif isinstance(body, str):
request_body = body
r = self.pool_manager.request(
method, url,
body=request_body,
preload_content=_preload_content,
timeout=timeout,
headers=headers)
else:
# Cannot generate the request from given parameters
msg = """Cannot prepare a request message for provided
arguments. Please check that your arguments match
declared content type."""
raise ApiException(status=0, reason=msg)
# For `GET`, `HEAD`
else:
r = self.pool_manager.request(method, url,
fields=query_params,
preload_content=_preload_content,
timeout=timeout,
headers=headers)
except urllib3.exceptions.SSLError as e:
msg = "{0}\n{1}".format(type(e).__name__, str(e))
raise ApiException(status=0, reason=msg)
if _preload_content:
r = RESTResponse(r)
# In the python 3, the response.data is bytes.
# we need to decode it to string.
if six.PY3:
r.data = r.data.decode('utf8')
# log response body
logger.debug("response body: %s", r.data)
if not 200 <= r.status <= 299:
raise ApiException(http_resp=r)
return r
def GET(self, url, headers=None, query_params=None, _preload_content=True,
_request_timeout=None):
return self.request("GET", url,
headers=headers,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
query_params=query_params)
def HEAD(self, url, headers=None, query_params=None, _preload_content=True,
_request_timeout=None):
return self.request("HEAD", url,
headers=headers,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
query_params=query_params)
def OPTIONS(self, url, headers=None, query_params=None, post_params=None,
body=None, _preload_content=True, _request_timeout=None):
return self.request("OPTIONS", url,
headers=headers,
query_params=query_params,
post_params=post_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
def DELETE(self, url, headers=None, query_params=None, body=None,
_preload_content=True, _request_timeout=None):
return self.request("DELETE", url,
headers=headers,
query_params=query_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
def POST(self, url, headers=None, query_params=None, post_params=None,
body=None, _preload_content=True, _request_timeout=None):
return self.request("POST", url,
headers=headers,
query_params=query_params,
post_params=post_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
def PUT(self, url, headers=None, query_params=None, post_params=None,
body=None, _preload_content=True, _request_timeout=None):
return self.request("PUT", url,
headers=headers,
query_params=query_params,
post_params=post_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
def PATCH(self, url, headers=None, query_params=None, post_params=None,
body=None, _preload_content=True, _request_timeout=None):
return self.request("PATCH", url,
headers=headers,
query_params=query_params,
post_params=post_params,
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
class ApiException(Exception):
def __init__(self, status=None, reason=None, http_resp=None):
if http_resp:
self.status = http_resp.status
self.reason = http_resp.reason
self.body = http_resp.data
self.headers = http_resp.getheaders()
else:
self.status = status
self.reason = reason
self.body = None
self.headers = None
def __str__(self):
"""Custom error messages for exception"""
error_message = "({0})\n"\
"Reason: {1}\n".format(self.status, self.reason)
if self.headers:
error_message += "HTTP response headers: {0}\n".format(
self.headers)
if self.body:
error_message += "HTTP response body: {0}\n".format(self.body)
return error_message
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment