lemur/lemur/plugins/bases/destination.py

56 lines
1.6 KiB
Python
Raw Normal View History

"""
.. module: lemur.plugins.bases.destination
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
from lemur.plugins.base import Plugin, plugins
2015-07-21 22:06:13 +02:00
class DestinationPlugin(Plugin):
2019-05-16 16:57:02 +02:00
type = "destination"
requires_key = True
sync_as_source = False
2019-05-16 16:57:02 +02:00
sync_as_source_name = ""
def upload(self, name, body, private_key, cert_chain, options, **kwargs):
raise NotImplementedError
class ExportDestinationPlugin(DestinationPlugin):
default_options = [
{
2019-05-16 16:57:02 +02:00
"name": "exportPlugin",
"type": "export-plugin",
"required": True,
"helpMessage": "Export plugin to use before sending data to destination.",
}
]
@property
def options(self):
2021-02-19 02:23:02 +01:00
"""
Gets/sets options for the plugin.
:return:
"""
return self.default_options + self.additional_options
def export(self, body, private_key, cert_chain, options):
2019-05-16 16:57:02 +02:00
export_plugin = self.get_option("exportPlugin", options)
if export_plugin:
2019-05-16 16:57:02 +02:00
plugin = plugins.get(export_plugin["slug"])
extension, passphrase, data = plugin.export(
body, cert_chain, private_key, export_plugin["plugin_options"]
)
return [(extension, passphrase, data)]
2019-05-16 16:57:02 +02:00
data = body + "\n" + cert_chain + "\n" + private_key
return [(".pem", "", data)]
def upload(self, name, body, private_key, cert_chain, options, **kwargs):
raise NotImplementedError