def changPwd(HOSTNAME, username, lastPassword, password): url = HOSTNAME + "/user/modpwd" textmod = { "username": username, "last_password": lastPassword, "password": password } return post(url, textmod)
def createRole(HOSTNAME, APPNAME, roleName, is_managent, create_uid): url = HOSTNAME + "/role/create" textmod = { "role": { "app_name": APPNAME, "name": roleName, "create_uid": create_uid, "is_managent": is_managent } } return post(url, textmod)
def changePermit(HOSTNAME, APPNAME, pid, name, desc): url = HOSTNAME + "/perms/change" textmod = { "perm": { "app_name": APPNAME, "id": pid, "name": name, "desc": desc } } return post(url, textmod)
def createOrg(HOSTNAME, APPNAME, name, code, owner="", desc="", rid=""): url = HOSTNAME + "/orgTree/create" textmod = { "rid": rid, "node": { "app_name": APPNAME, "code": code, "name": name, "desc": desc, "owner": owner } } return post(url, textmod)
def createPermit(HOSTNAME, APPNAME, permitName, code="", desc=""): url = HOSTNAME + "/perms/create" if not code: code = permitName # textmod = {"perm":{"app_name":APPNAME, "name":code, "desc" : desc}} textmod = { "perm": { "app_name": APPNAME, "name": permitName, "code": code, "desc": desc } } return post(url, textmod)
def createUser(HOSTNAME, APPNAME, username, password, orgName="网络管理员", nickname="", nid=0, sort_type=999999999): url = HOSTNAME + "/user/add" textmod = { "user": { "username": username, "password": password, "app_name": APPNAME, "nickname": nickname, "nid": nid, "sort_type": sort_type } } if orgName: textmod["user"]["payload"] = '{"organization":"%s"}' % orgName return post(url, textmod)
def cleanRoleBatch(HOSTNAME, APPNAME, username): url = HOSTNAME + "/user/cleanRole" textmod = {"username": username, "app_name": APPNAME} return post(url, textmod)
def assinRoleBatch(HOSTNAME, APPNAME, username, rid): url = HOSTNAME + "/user/assignRoleBatch" textmod = {"username": username, "rid": rid, "app_name": APPNAME} return post(url, textmod)
def assinRole(HOSTNAME, APPNAME, username, rid, init=None): url = HOSTNAME + "/user/assignRole" textmod = {"username": username, "rid": rid, "app_name": APPNAME} if init: textmod["init"] = 1 return post(url, textmod)
def bindOrgUser(HOSTNAME, uid, nid): url = HOSTNAME + "/orgTree/bindUser" textmod = {"uid": uid, "nid": nid} return post(url, textmod)
def login(HOSTNAME, APPNAME, username, password): url = HOSTNAME + "/user/login" textmod = {"username": username, "password": password, "app_name": APPNAME} return post(url, textmod)