Skip to content
Snippets Groups Projects
Commit cb4bc1ed authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-remove-bloxberg' into 'dev'

MAINT: Removed Bloxberg code snippets.

See merge request !114
parents 5841e2c0 63bdb534
Branches
Tags
2 merge requests!128MNT: Added a warning when column metadata is not configured, and a better...,!114MAINT: Removed Bloxberg code snippets.
Pipeline #56317 failed
Showing
with 2 additions and 2988 deletions
......@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ###
- Bloxberg code snippets. These were just a proof of concept, untested and never used in production.
### Fixed ###
### Security ###
......
"""Integration with the Bloxberg proof-of-existence blockchain.
"""
print("Warning: The Bloxberg module is still experimental and under active development.")
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
# Copyright (C) 2021 Daniel Hornung <d.hornung@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""Interaction with the Bloxberg blockchain.
"""
import hashlib
import json
import secrets
import caosdb as db
from ..models.parser import parse_model_from_string
from . import swagger_client
__model_yaml = """
BloxbergCertificate:
obligatory_properties:
pepper:
datatype: TEXT
hash:
datatype: TEXT
proofValue:
datatype: TEXT
certificateJSON:
datatype: TEXT
recommended_properties:
certified:
datatype: REFERENCE
"""
__model = parse_model_from_string(__model_yaml)
class Bloxberg:
"""A Bloxberg instance can be used to obtain or verify certificates."""
def __init__(self, connection=None):
"""A Bloxberg instance can be used to obtain or verify certificates.
Parameters
----------
connection : dict
A dict with the following keys:
- url : The bloxberg URL. Default is "https://qa.certify.bloxberg.org"
"""
self._create_conf(connection)
self._api_client = swagger_client.ApiClient(configuration=self._conf)
self._api = swagger_client.CertificateApi(self._api_client)
def _create_conf(self, connection=None):
"""Generate a Swagger configuration object."""
self._conf = swagger_client.Configuration()
if connection:
if "URL" in connection:
self._conf.host = connection["URL"]
def certify(self, entity):
"""Attempt to certify the given `entity` and return a certificate Record.
Parameters
----------
entity : caosdb.Entity
The entity to be certified
Returns
-------
out : caosdb.Record
A BloxbergCertificate Record with all the necessary Properties.
"""
# Calculate hash
pepper = str(secrets.randbits(1024))
entity.retrieve()
hasher = hashlib.sha256()
hasher.update(pepper.encode(encoding="utf8"))
hasher.update(str(entity).encode(encoding="utf8"))
entity_hash = "0x" + hasher.hexdigest()
print(entity_hash)
pubkey = "0x9858eC18a269EE69ebfD7C38eb297996827DDa98" # TODO The key of the API server?
# Create body
body = swagger_client.Batch(public_key=pubkey, crid=[entity_hash], crid_type="sha2-256",
enable_ipfs=False)
# Submit hash & obtain response
result = self._api.create_bloxberg_certificate_create_bloxberg_certificate_post(body=body)
attribute_map = result[0].attribute_map
cert = result[0].to_dict()
for old, new in attribute_map.items():
if old == new:
continue
cert[new] = cert.pop(old)
json_s = json.dumps(cert)
# Generate result Record
cert_rec = db.Record().add_parent("BloxbergCertificate")
# Extract information and put into result
cert_rec.add_property(property="certified", value=entity)
cert_rec.add_property(property="pepper", value=pepper)
cert_rec.add_property(property="hash", value=entity_hash)
cert_rec.add_property(property="proofvalue", value=cert["proof"]["proofValue"])
cert_rec.add_property(property="certificateJSON", value=json_s)
# Return result
return cert_rec
def verify(self, certificate):
"""Attempt to verify the certificate.
A certificate passes verification if the Bloxberg instance says it is good. Typical use cases may
also include the `validate` step to make sure that the certificate's original data exists and
contains what it claimed to contain when the certificate was created.
This method does nothing if the verification passes, else it raises an exception.
Parameters
----------
certificate : caosdb.Record
The BloxbergCertificate Record which shall be verified.
"""
raise NotImplementedError("Bloxberg first needs to implement a verification API method.")
@staticmethod
def json_from_certificate(certificate, filename=None):
"""Generate a qa.certify.bloxberg.org JSON string, optionally writing it to a file.
Parameters
----------
certificate : caosdb.Record
The BloxbergCertificate Record for which the JSON is generated.
filename : str
Write the JSON to this file.
"""
content = {}
print(certificate, filename)
return content
def ensure_data_model(force=False):
"""Make sure that the data model fits our needs.
Most importantly, this means that a suitable RecordType "BoxbergCertificate" must exist.
"""
__model.sync_data_model(noquestion=force)
def certify_entity(entity, json_filename=None):
"""Certify the given entity and store the result in the CaosDB.
Parameters
----------
entity : caosdb.Entity
The Entity to be certified.
json_filename : str
If given, store the JSON here.
"""
if isinstance(entity, int):
entity = db.Entity(id=entity)
blx = Bloxberg()
print("Obtaining certificate...")
certificate = blx.certify(entity)
print("Certificate was successfully obtained.")
certificate.insert()
print("Certificate was stored in CaosDB.")
if json_filename:
with open(json_filename, "w") as json_file:
json_file.write(certificate.get_property("certificateJSON").value)
def demo_run():
"""Run the core functions for demonstration purposes."""
print("Making sure that the remote data model is up to date.")
ensure_data_model()
print("Data model is up to date.")
CertRT = db.RecordType(name="BloxbergCertificate").retrieve()
print("Certifying the `BloxbergCertificate` RecordType...")
json_filename = "/tmp/cert.json"
certify_entity(CertRT, json_filename=json_filename)
print("Certificate json file can be found here: {}".format(json_filename))
print("You can verify the certificate here: https://certify.bloxberg.org/verify")
# 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
from swagger_client.models.validation_error import ValidationError
from swagger_client.models.http_validation_error import HTTPValidationError
from swagger_client.models.controller_cert_tools_generate_unsigned_certificate_json_certificate import ControllerCertToolsGenerateUnsignedCertificateJsonCertificate
from swagger_client.models.controller_cert_tools_generate_pdf_json_certificate import ControllerCertToolsGeneratePdfJsonCertificate
from swagger_client.models.batch import Batch
from swagger_client.configuration import Configuration
from swagger_client.api_client import ApiClient
from swagger_client.api.pdf_api import PdfApi
from swagger_client.api.certificate_api import CertificateApi
# Fake the installation
import sys
import 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
# import ApiClient
# import models into sdk package
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)
This diff is collapsed.
# 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
......@@ -201,6 +201,5 @@ autodoc_default_options = {
'undoc-members': None,
}
autodoc_mock_imports = [
"caosadvancedtools.bloxberg",
"labfolder",
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment