import requests
import json


def add_class_to_group(base_url, gid, classname, classparams=None):
    """
    adds a class to a group in NodeMeister, returns True on success or False on failure
    """
    payload = {'group': gid, 'classname': classname, 'classparams': classparams}
    headers = {'content-type': 'application/json'}
    r = requests.post("%senc/classes/groups/" % base_url, data=json.dumps(payload), headers=headers)
    if r.status_code == 201:
        return True
    return False