import insightconnect_plugin_runtime
from .schema import ListVulnerabilitySyncTasksInput, ListVulnerabilitySyncTasksOutput, Input, Output, Component

# Custom imports below


class ListVulnerabilitySyncTasks(insightconnect_plugin_runtime.Action):
    def __init__(self):
        super(self.__class__, self).__init__(
            name="list_vulnerability_sync_tasks",
            description=Component.DESCRIPTION,
            input=ListVulnerabilitySyncTasksInput(),
            output=ListVulnerabilitySyncTasksOutput(),
        )

    def run(self, params={}):
        parameters = {"batch_id:equals": params.get(Input.BATCH_ID), "status:equals": params.get(Input.STATUS)}

        tasks = self.connection.automox_api.get_vulnerability_sync_tasks(params.get(Input.ORG_ID), parameters)
        self.logger.info(f"Returned {len(tasks)} tasks")

        return {Output.TASKS: tasks}

import insightconnect_plugin_runtime
from .schema import ListVulnerabilitySyncTasksInput, ListVulnerabilitySyncTasksOutput, Input, Output, Component

# Custom imports below


class ListVulnerabilitySyncTasks(insightconnect_plugin_runtime.Action):
    def __init__(self):
        super(self.__class__, self).__init__(
            name="list_vulnerability_sync_tasks",
            description=Component.DESCRIPTION,
            input=ListVulnerabilitySyncTasksInput(),
            output=ListVulnerabilitySyncTasksOutput(),
        )

    def run(self, params={}):
        parameters = {"batch_id:equals": params.get(Input.BATCH_ID), "status:equals": params.get(Input.STATUS)}

        tasks = self.connection.automox_api.get_vulnerability_sync_tasks(params.get(Input.ORG_ID), parameters)
        self.logger.info(f"Returned {len(tasks)} tasks")

        return {Output.TASKS: tasks}

# Custom imports below