text: # Copyright 2019 Extreme Networks, Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  from __future__ import absolute_import
  import mongoengine as me
  
  from st2common import log as logging
  from st2common.models.db import MongoDBAccess
  from st2common.models.db import stormbase
  from st2common.constants.types import ResourceType
  
  __all__ = [
      'RunnerTypeDB',
  ]
  
  
  LOG = logging.getLogger(__name__)
  
  PACK_SEPARATOR = '.'
  
  
  class RunnerTypeDB(stormbase.StormBaseDB, stormbase.UIDFieldMixin):
      """
      The representation of an RunnerType in the system. An RunnerType
      has a one-to-one mapping to a particular ActionRunner implementation.
  
      Attributes:
          id: See StormBaseAPI
          name: See StormBaseAPI
          description: See StormBaseAPI
          enabled: A flag indicating whether the runner for this type is enabled.
          runner_module: The python module that implements the action runner for this type.
          runner_parameters: The specification for parameters for the action runner.
      """
  
      RESOURCE_TYPE = ResourceType.RUNNER_TYPE
      UID_FIELDS = ['name']
  
      enabled = me.BooleanField(
          required=True, default=True,
          help_text='A flag indicating whether the runner for this type is enabled.')
      runner_package = me.StringField(
          required=False,
          help_text=('The python package that implements the action runner for this type. If'
                     'not provided it assumes package name equals module name.'))
      runner_module = me.StringField(
          required=True,
          help_text='The python module that implements the action runner for this type.')
      runner_parameters = me.DictField(
          help_text='The specification for parameters for the action runner.')
      output_key = me.StringField(
          help_text='Default key to expect results to be published to.')
      output_schema = me.DictField(
          help_text='The schema for runner output.')
      query_module = me.StringField(
          required=False,
          help_text='The python module that implements the query module for this runner.')
  
      meta = {
          'indexes': stormbase.UIDFieldMixin.get_indexes()
      }
  
      def __init__(self, *args, **values):
          super(RunnerTypeDB, self).__init__(*args, **values)
          self.uid = self.get_uid()
  
  
  # specialized access objects
  runnertype_access = MongoDBAccess(RunnerTypeDB)
  
  MODELS = [RunnerTypeDB]
  