'Make a call to the LogicMonitor RPC library
and return the response'

def rpc(self, action, params):

    self.module.debug('Running    LogicMonitor.rpc')
    param_str = urlencode(params)
    creds = urlencode({'c': self.company, 'u': self.user, 'p': self.password})
    if param_str:
        param_str = (param_str + '&')
    param_str = (param_str + creds)
    try:
        url = ((((((('https://' + self.company) + '.') + self.lm_url) + '/rpc/') + action) + '?') + param_str)
        headers = {'X-LM-User-Agent': self.__version__}
        f = open_url(url, headers=headers)
        raw = f.read()
        resp = json.loads(raw)
        if (resp['status'] == 403):
            self.module.debug('Authentication    failed.')
            self.fail(msg=('Error:    ' + resp['errmsg']))
        else:
            return raw
    except IOError:
        ioe = get_exception()
        self.fail(msg=(((((((('Error:    Exception    making    RPC    call    to    ' + 'https://') + self.company) + '.') + self.lm_url) + '/rpc/') + action) + '\nException') + str(ioe)))
