#!/usr/bin/env python
# -*- coding: utf-8 -*-


from napixd.managers import Manager
from napixd.managers.views import view, content_type
from napixd.managers.actions import action, parameter


class MyManager(Manager):
    resource_fields = {
        'field1': {
            'description': 'A field that describes some value',
            'example': 'A typical representation of this fields',
            'type': int,
            #'optional': True,
            #'computed': True,
            #'editable': True,
        }
    }

    managed_class = [
    ]

    auto_load = False

    @classmethod
    def detect(self):
        return self.auto_load

    def list_resource_filter(self, filters):
        if not filters:
            return self.list_resource()

        return

    def list_resource(self):
        return []

    def get_resource(self, id):
        return {
        }

    def modify_resource(self, resource_wrapper, diffdict):
        #resource_wrapper.id
        #resource_wrapper.resource

        #diffdict.added, diffdict.changed, diffdict.deleted

        return resource_wrapper.id

    def create_resource(self, resource_dict):
        return 'new_id'

    def delete_resource(self, resource_wrapper):
        pass

    def validate_resource_field1(self, field1):
        return field1

    def validate_resource(self, resource_dict, original):
        return resource_dict

    @action
    @parameter('param', description='This param defines the param')
    def do_something(self, resource_wrapper, param):
        return

    @view
    @content_type('text/plain')
    def as_text(self, resource_wrapper):
        return ''
