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)
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)
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)
def create(cli): """ Create A New user """ url = build_url("user") user = {} user['email'] = raw_input('What is their email: ') user['name'] = raw_input('What is their full name?: ') auth = raw_input('How will they logon? [google,github,password] (default = google): ') if auth == "google" or auth == "": pass if auth == "google": needsEmail = False if "email" not in user: needsEmail = True elif len(user["email"]) < 4: needsEmail = True if needsEmail: user['email'] =raw_input("To use google login requires google email: ") if auth == "password": user['password'] = raw_input('Password? ') if cli.args.preview: print("would have sent %s data=\n%s" % (url, user)) return log.debug(user) resp = httpapi.doapi(url, data=user, method="POST") httpiecolor.console_response(resp)
def create(cli): """ Create A New account """ data = {} data['fid'] = raw_input('What is the unique id for this account?: ') data['name'] = raw_input('What is the name of this account?: ') log.debug(data) resp = httpapi.doapi(build_url("account"), data=data, method="POST") httpiecolor.console_response(resp)
def api(self): """call arbitrary api """ if not self.valid(): return url = self._arg(0) if len(url) < 1: log.error("Requires url arg: lytics api account [user,account,query,meta etc]") return url = build_url(url) log.debug(url) httpiecolor.console_response(httpapi.doapi(url))
def api(self): """call arbitrary api """ if not self.valid(): return url = self._arg(0) if len(url) < 1: log.error("Requires url arg: lytics api account [user,account,query,meta etc]") return url = build_url(url) log.debug(url) resp = httpapi.doapi(url) print(resp.json)
def api(self): """call arbitrary api """ if not self.valid(): return url = self._arg(0) if len(url) < 1: log.error( "Requires url arg: lytics api account [user,account,query,meta etc]" ) return url = build_url(url) log.debug(url) httpiecolor.console_response(httpapi.doapi(url))