'Curry API management commands with the API name.'

def __getattr__(self, attr):

    if (attr == 'name'):
        return self.name
    elif (attr == 'settings'):
        return self.api.settings[self.name]
    elif (attr == 'register'):
        def partial(handler, op, jid=None, node=None, default=False):
            register = getattr(self.api, attr)
            return register(handler, self.name, op, jid, node, default)
        return partial
    elif (attr == 'register_default'):
        def partial(handler, op, jid=None, node=None):
            return getattr(self.api, attr)(handler, self.name, op)
        return partial
    elif (attr in ('run', 'restore_default', 'unregister')):
        def partial(*args, **kwargs):
            return getattr(self.api, attr)(self.name, *args, **kwargs)
        return partial
    return None
