# -*- coding: utf-8 -*-
#    Copyright 2015 Mirantis, 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.


class BaseTasksSchema(object):

    base_task_schema = {
        '$schema': 'http://json-schema.org/draft-04/schema#',
        'type': 'object',
        'required': ['type', 'id'],
        'properties': {
            'id': {'type': 'string',
                   'minLength': 1},
            'type': {'enum': [],
                     'type': 'string'},
            'parameters': {'type': 'object'},
            'required_for': {'type': 'array'},
            'requires': {'type': 'array'},
        }}

    base_tasks_schema = {
        '$schema': 'http://json-schema.org/draft-04/schema#',
        'type': 'array',
        'items': ''}

    types = {'enum': ['puppet', 'shell'],
             'type': 'string'},

    @property
    def task_schema(self):
        self.base_task_schema['properties']['type'] = self.types
        return self.base_task_schema

    @property
    def tasks_schema(self):
        self.base_tasks_schema['items'] = self.task_schema
        return self.base_tasks_schema


class TasksSchema61(BaseTasksSchema):

    types = {'enum': ['puppet', 'shell', 'group', 'stage', 'copy_files',
                      'sync', 'upload_file'],
             'type': 'string'}


VERSIONS_SCHEMAS_MAP = {
    "6.1": TasksSchema61,
    "last": TasksSchema61,
}

@@ -1813,16 +1813,229 @@
 ing'%7D%0A%0A%0A
+class TasksSchema70(BaseTasksSchema):%0A%0A    types = %7B'enum': %5B'puppet', 'shell', 'sync', 'upload_file', 'group',%0A                      'stage', 'skipped', 'reboot',  'copy_files'%5D,%0A             'type': 'string'%7D%0A%0A%0A
 VERSIONS
@@ -2077,16 +2077,68 @@
 hema61,%0A
+    %227.0%22: TasksSchema70,%0A    %228.0%22: TasksSchema70,%0A
     %22las
@@ -2152,14 +2152,14 @@
 ksSchema
-61
+70
 ,%0A%7D%0A

Update task types to current nailgun task schema