'Idempotent function to ensure the host group settings
(alertenable, properties, etc) in the
LogicMonitor account match the current object.'

def update(self):

    self.module.debug('Running    Hostgroup.update')
    if self.info:
        if self.is_changed():
            self.module.debug('System    changed')
            self.change = True
            if self.check_mode:
                self.exit(changed=True)
            h = self._build_host_group_hash(self.fullpath, self.description, self.properties, self.alertenable)
            h['opType'] = 'replace'
            if (self.fullpath != '/'):
                h['id'] = self.info['id']
            self.module.debug("Making    RPC    call    to    'updateHostGroup'")
            resp = json.loads(self.rpc('updateHostGroup', h))
            if (resp['status'] == 200):
                self.module.debug('RPC    call    succeeded')
                return resp['data']
            else:
                self.module.debug('RPC    call    failed')
                self.fail(msg=(('Error:    Unable    to    update    the    ' + 'host.\n') + resp['errmsg']))
        else:
            self.module.debug(('Group    properties    match    supplied    properties.    ' + 'No    changes    to    make'))
            return self.info
    else:
        self.module.debug("Group    doesn't    exist.    Creating.")
        self.module.debug('System    changed')
        self.change = True
        if self.check_mode:
            self.exit(changed=True)
        return self.add()
