Esempio n. 1
0
class Command(MonitorMixin, Resource):
    #: The address to call (without protocol or domain). Eg:
    #: ``/api/<username>/groups/0/action``
    address = fields.String(v.Required())
    #: The body of the request
    body = fields.Dictionary()
    #: The HTTP request method
    method = fields.String(v.In(['GET', 'PUT', 'POST', 'DELETE']))
Esempio n. 2
0
class Schedule(MonitorMixin, Resource):
    #: The name of the schedule.
    name = fields.String(v.Required())
    #: Description of the schedule
    description = fields.String()
    #: Command to execute when the scheduled event occurs
    command = fields.Embedded(Command)
    #: Local time when the scheduled event will occur
    local_time = fields.TimePattern(name='localtime')
    #: Status, either 'enabled' or 'disabled'
    status = fields.String(v.In(['enabled', 'disabled']))
    #: If set to true, the schedule will be removed automatically if expired,
    #: if set to false it will be disabled. Default is true.
    auto_delete = fields.Boolean(name='autodelete')
    #: UTC time that the timer was started. Only provided for timers.
    start_time = fields.IsoDate(name='starttime', read_only=True)
Esempio n. 3
0
    def __init__(self, *validators, **kwargs):
        self.options = kwargs

        self.default = kwargs.get('default')

        # Setup field validators
        self.validators = []

        if kwargs.get('required'):
            self.validators.append(builtin_validators.Required())

        choices = kwargs.get('choices')

        if choices:
            self.validators.append(builtin_validators.In(choices))

        self.validators.extend(validators)
Esempio n. 4
0
    def __init__(self, *validators, **kwargs):
        self.options = kwargs

        self.default = kwargs.get('default')
        self.description = kwargs.get('description', '')
        self.required = kwargs.get('required', False)
        self.choices = kwargs.get('choices', [])

        assert isinstance(self.choices, list)

        # Setup field validators
        self.validators = []

        if self.required:
            self.validators.append(builtin_validators.Required())

        if self.choices:
            self.validators.append(builtin_validators.In(self.choices))

        self.validators.extend(validators)
Esempio n. 5
0
 def setup(self):
     self.validator = validators.In(['foo', 'bar'])