Example #1
0
def list(cli):
    """
    Get list of accounts or a specific one
    """
    uid = cli._arg(0)
    url = "" 
    if len(uid) == 0 :
        url = build_url("account")
    else:
        url = build_url("account/" + uid)
    log.debug(url)
    if cli.args.format == 'json':
        httpiecolor.console_response(httpapi.doapi(url))
    else:
        resp = httpapi.doapi(url)
        if resp.status_code < 400:
            data = json.loads(resp.text)
            out = [['Name', "YourId","Account ID","apikey"]]
            if "data" in data:
                if isinstance(data["data"],dict):
                    httpiecolor.console_response(resp)
                else:
                    for u in data["data"]:
                        out.append([u["name"],u["fid"],u["aid"],u["apikey"]])
                    print("")
                    pprint_table(sys.stdout,out)
Example #2
0
def list(cli):
    """
    Get list of Users or a specific one
    """
    uid = cli._arg(0)
    url = "" 
    if len(uid) == 0 :
        url = build_url("user")
    else:
        url = build_url("user/" + uid)
    log.debug(url)
    if cli.args.format == 'json':
        httpiecolor.console_response(httpapi.doapi(url))
    else:
        resp = httpapi.doapi(url)
        if resp.status_code < 400:
            data = json.loads(resp.text)
            out = [['Name', "Email","Roles"]]
            if "data" in data:
                if isinstance(data["data"],dict):
                    httpiecolor.console_response(resp)
                else:
                    for u in data["data"]:
                        roles = ""
                        if "roles" in u and type(u["roles"]) == type([]):
                            roles = ",".join(u['roles'])
                        out.append([u["name"],u["email"],roles])
                    print("")
                    pprint_table(sys.stdout,out)
Example #3
0
def list(cli):
    """
    Get list of accounts or a specific one
    """
    uid = cli._arg(0)
    url = ""
    if len(uid) == 0:
        url = build_url("account")
    else:
        url = build_url("account/" + uid)
    log.debug(url)
    if cli.args.format == 'json':
        httpiecolor.console_response(httpapi.doapi(url))
    else:
        resp = httpapi.doapi(url)
        if resp.status_code < 400:
            data = json.loads(resp.text)
            out = [['Name', "YourId", "Account ID", "apikey"]]
            if "data" in data:
                if isinstance(data["data"], dict):
                    httpiecolor.console_response(resp)
                else:
                    for u in data["data"]:
                        out.append(
                            [u["name"], u["fid"], u["aid"], u["apikey"]])
                    print("")
                    pprint_table(sys.stdout, out)