# 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):


import logging
import yaml
from django.core import exceptions as core_exc
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from horizon import messages
from watcher_dashboard.api import watcher
    name = forms.CharField(max_length=255, label=_("Name"))
    description = forms.CharField(max_length=255, label=_("Description"),
                                  required=False)
    goal = forms.ChoiceField(label=_('Goal'))
    strategy = forms.DynamicChoiceField(label=_('Strategy'), required=False)

    scope = forms.CharField(
        label=_('Scope'), required=False,
        widget=forms.widgets.Textarea,
        validators=[YamlValidator()])

    failure_url = 'horizon:admin:audit_templates:index'

    def __init__(self, request, *args, **kwargs):
        super(CreateForm, self).__init__(request, *args, **kwargs)
        goals = self._get_goal_list(request)
        strategies = self._get_strategy_list(request, goals)

        if goals:
            self.fields['goal'].choices = goals
        else:
            del self.fields['goal']

        if strategies:
            self.fields['strategy'].choices = strategies
        else:
            del self.fields['strategy']

    def _get_goal_list(self, request):
        try:

# 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/forms.py
import logging
import yaml
from django.core import exceptions as core_exc
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from horizon import messages
from watcher_dashboard.api import watcher

    name = forms.CharField(max_length=255, label=_("Name"))
    description = forms.CharField(max_length=255, label=_("Description"),
                                  required=False)
    goal = forms.ChoiceField(label=_('Goal'))
    strategy = forms.DynamicChoiceField(label=_('Strategy'), required=False)

    scope = forms.CharField(
        label=_('Scope'), required=False,
        widget=forms.widgets.Textarea,
        validators=[YamlValidator()])

    failure_url = 'horizon:admin:audit_templates:index'

    def __init__(self, request, *args, **kwargs):
        super(CreateForm, self).__init__(request, *args, **kwargs)
        goals = self._get_goal_list(request)
        strategies = self._get_strategy_list(request, goals)

        if goals:
            self.fields['goal'].choices = goals
        else:
            del self.fields['goal']

        if strategies:
            self.fields['strategy'].choices = strategies
        else:
            del self.fields['strategy']

    def _get_goal_list(self, request):
        try:

            goals = watcher.Goal.list(self.request)