def getInfo(request_extension, deviceid):
    """Sends Request For Device Info JSON"""
    headers = getHeader()
    url = (Globals.BASE_DEVICE_URL.format(
        configuration_host=Globals.configuration.host,
        enterprise_id=Globals.enterprise_id,
        device_id=deviceid,
    ) + request_extension)
    resp = performGetRequestWithRetry(url, headers=headers)
    json_resp = resp.json()
    logBadResponse(url, resp, json_resp)

    return json_resp
def fetchGroupName(groupURL):
    headers = getHeader()
    resp = performGetRequestWithRetry(groupURL, headers=headers)
    try:
        if resp.status_code < 300:
            json_resp = resp.json()
            logBadResponse(groupURL, resp, json_resp)

            if "name" in json_resp:
                return json_resp["name"]
    except Exception as e:
        ApiToolLog().LogError(e)
        logBadResponse(groupURL, resp, None)
    return None
def getDeviceApplicationById(device_id, application_id):
    try:
        headers = getHeader()
        url = "https://%s-api.esper.cloud/api/enterprise/%s/device/%s/app/%s" % (
            Globals.configuration.host.split("-api")[0].replace(
                "https://", ""),
            Globals.enterprise_id,
            device_id,
            application_id,
        )
        resp = performGetRequestWithRetry(url, headers=headers)
        json_resp = resp.json()
        logBadResponse(url, resp, json_resp)
    except Exception as e:
        ApiToolLog().LogError(e)
    return resp, json_resp
Ejemplo n.º 4
0
 def getTemplate(self, link, key, enterprise_id, template_id):
     try:
         headers = {
             "Authorization": f"Bearer {key}",
             "Content-Type": "application/json",
         }
         if not link.endswith("/v0/enterprise/") or not link.endswith(
                 "v0/enterprise/"):
             if not link.endswith("/"):
                 link = link + "/"
             link = link + "v0/enterprise/"
         url = link + enterprise_id + self.template_extension + str(
             template_id)
         resp = performGetRequestWithRetry(url, headers=headers)
         json_resp = resp.json()
         return json_resp
     except Exception as e:
         raise e