# Path: watcher_dashboard/api/watcher.py
# LOG = logging.getLogger(__name__)
# WATCHER_SERVICE = 'infra-optim'
# def watcherclient(request, password=None):
# def insert_watcher_policy_file():
#     def __init__(self, apiresource, request=None):
#     def create(cls, request, audit_template_uuid, audit_type, name=None,
#                auto_trigger=False, interval=None):
#     def list(cls, request, **filters):
#     def get(cls, request, audit_id):
#     def delete(cls, request, audit_id):
#     def id(self):
#     def __init__(self, apiresource, request=None):
#     def create(cls, request, name, goal, strategy,
#                description, scope):
#     def patch(cls, request, audit_template_id, parameters):
#     def list(cls, request, **filters):
#     def get(cls, request, audit_template_id):
#     def delete(cls, request, audit_template_id):
#     def id(self):
#     def __init__(self, apiresource, request=None):
#     def list(cls, request, **filters):
#     def get(cls, request, action_plan_id):
#     def delete(cls, request, action_plan_id):
#     def start(cls, request, action_plan_id):
#     def id(self):
#     def __init__(self, apiresource, request=None):
#     def list(cls, request, **filters):
#     def get(cls, request, action_id):
#     def delete(cls, request, action_id):
#     def start(cls, request, action_id):
#     def id(self):
#     def __init__(self, apiresource, request=None):
#     def list(cls, request, **filters):
#     def get(cls, request, goal):
#     def id(self):
#     def __init__(self, apiresource, request=None):
#     def list(cls, request, **filters):
#     def get(cls, request, strategy):
#     def id(self):
#     def __init__(self, indicator):
# class Audit(base.APIDictWrapper):
# class AuditTemplate(base.APIDictWrapper):
# class ActionPlan(base.APIDictWrapper):
# class Action(base.APIDictWrapper):
# class Goal(base.APIDictWrapper):
# class Strategy(base.APIDictWrapper):
# class EfficacyIndicatorSpec(base.APIDictWrapper):
# class EfficacyIndicator(base.APIDictWrapper):


from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from watcher_dashboard.api import watcher
import horizon.exceptions
import horizon.messages
import horizon.tables


class LaunchAudit(horizon.tables.BatchAction):
    name = "launch_audit"
    verbose_name = _("Launch Audit")
    data_type_singular = _("Launch Audit")
    data_type_plural = _("Launch Audits")
    success_url = "horizon:admin:audits:index"
    policy_rules = (("infra-optim", "audit:create"),)

    @staticmethod
    def action_present(count):
        return ungettext_lazy(
            "Launch Audit",
            "Launch Audits",
            count
        )

    @staticmethod
    def action_past(count):
        return ungettext_lazy(
            "Launched Audit",
            "Launched Audits",
            count
        )

    def action(self, request, obj_id):
        params = {'audit_template_uuid': obj_id}
        params['audit_type'] = 'ONESHOT'
        params['auto_trigger'] = False

# Path: watcher_dashboard/api/watcher.py
# LOG = logging.getLogger(__name__)
# WATCHER_SERVICE = 'infra-optim'
# def watcherclient(request, password=None):
# def insert_watcher_policy_file():
#     def __init__(self, apiresource, request=None):
#     def create(cls, request, audit_template_uuid, audit_type, name=None,
#                auto_trigger=False, interval=None):
#     def list(cls, request, **filters):
#     def get(cls, request, audit_id):
#     def delete(cls, request, audit_id):
#     def id(self):
#     def __init__(self, apiresource, request=None):
#     def create(cls, request, name, goal, strategy,
#                description, scope):
#     def patch(cls, request, audit_template_id, parameters):
#     def list(cls, request, **filters):
#     def get(cls, request, audit_template_id):
#     def delete(cls, request, audit_template_id):
#     def id(self):
#     def __init__(self, apiresource, request=None):
#     def list(cls, request, **filters):
#     def get(cls, request, action_plan_id):
#     def delete(cls, request, action_plan_id):
#     def start(cls, request, action_plan_id):
#     def id(self):
#     def __init__(self, apiresource, request=None):
#     def list(cls, request, **filters):
#     def get(cls, request, action_id):
#     def delete(cls, request, action_id):
#     def start(cls, request, action_id):
#     def id(self):
#     def __init__(self, apiresource, request=None):
#     def list(cls, request, **filters):
#     def get(cls, request, goal):
#     def id(self):
#     def __init__(self, apiresource, request=None):
#     def list(cls, request, **filters):
#     def get(cls, request, strategy):
#     def id(self):
#     def __init__(self, indicator):
# class Audit(base.APIDictWrapper):
# class AuditTemplate(base.APIDictWrapper):
# class ActionPlan(base.APIDictWrapper):
# class Action(base.APIDictWrapper):
# class Goal(base.APIDictWrapper):
# class Strategy(base.APIDictWrapper):
# class EfficacyIndicatorSpec(base.APIDictWrapper):
# class EfficacyIndicator(base.APIDictWrapper):


# Path: watcher_dashboard/content/audit_templates/tables.py
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from watcher_dashboard.api import watcher
import horizon.exceptions
import horizon.messages
import horizon.tables



class LaunchAudit(horizon.tables.BatchAction):
    name = "launch_audit"
    verbose_name = _("Launch Audit")
    data_type_singular = _("Launch Audit")
    data_type_plural = _("Launch Audits")
    success_url = "horizon:admin:audits:index"
    policy_rules = (("infra-optim", "audit:create"),)

    @staticmethod
    def action_present(count):
        return ungettext_lazy(
            "Launch Audit",
            "Launch Audits",
            count
        )

    @staticmethod
    def action_past(count):
        return ungettext_lazy(
            "Launched Audit",
            "Launched Audits",
            count
        )

    def action(self, request, obj_id):
        params = {'audit_template_uuid': obj_id}
        params['audit_type'] = 'ONESHOT'
        params['auto_trigger'] = False

        watcher.Audit.create(request, **params)