IBSng Handler Reference
از ویکی پارس پویش
(تفاوت بین نسخهها)
(صفحهای جدید حاوی 'Category:Programming ==AdminHandler== ===addNewAdmin=== <pre> Add...' ایجاد کرد) |
|||
(یک ویرایش میانی توسط یک کاربر نشان داده نشدهاست) | |||
سطر ۱: | سطر ۱: | ||
[[Category:Programming]] | [[Category:Programming]] | ||
− | + | <div dir=rtl lang=en> | |
+ | __TOC__ | ||
+ | </div> | ||
+ | <div dir=ltr lang=en> | ||
==AdminHandler== | ==AdminHandler== | ||
===addNewAdmin=== | ===addNewAdmin=== | ||
سطر ۶٬۶۳۰: | سطر ۶٬۶۳۳: | ||
</pre> | </pre> | ||
+ | </div> |
نسخهٔ کنونی تا ۱۳ سپتامبر ۲۰۱۱، ساعت ۱۰:۴۰
[ویرایش] AdminHandler
[ویرایش] addNewAdmin
Add a new admin<br> admin_username(str): Unique username of admin<br> admin_password(str): Password of new admin<br> admin_isp_name(str): name of isp, this admin will be child of<br> name(str)<br> email(str)<br> comment(str):<br>
- Arguments
- "admin_username", "admin_password", "admin_isp_name", "name", "email", "comment","admin_has_otp"
- Auth Type
- ADMIN
- Permission
- "ADD NEW ADMIN", request["admin_isp_name"]
- Code
def addNewAdmin(self, request): """ Add a new admin admin_username(str): Unique username of admin admin_password(str): Password of new admin admin_isp_name(str): name of isp, this admin will be child of name(str) email(str) comment(str): """ request.checkArgs("admin_username", "admin_password", "admin_isp_name", "name", "email", "comment","admin_has_otp") request.needAuthType(request.ADMIN) creator_admin_obj=request.getAuthNameObj() creator_admin_obj.canDo("ADD NEW ADMIN", request["admin_isp_name"]) admin_id = admin_main.getAdminActions().addNewAdmin(request["admin_username"], request["admin_password"], request["admin_isp_name"], creator_admin_obj.getAdminUsername(), request["name"], request["email"], request["comment"], request["admin_has_otp"], request.getRemoteAddr()) return admin_id
[ویرایش] changePassword
change password of "admin_username" to "new_password"<br>
- Auth Type
- ADMIN
- Arguments
- "admin_username", "new_password"
- Permission
- "CHANGE ADMIN PASSWORD", request["admin_username"]
- Code
def changePassword(self, request): """ change password of "admin_username" to "new_password" """ request.needAuthType(request.ADMIN) request.checkArgs("admin_username", "new_password") requester_obj = request.getAuthNameObj() if request.auth_name != request["admin_username"]: requester_obj.canDo("CHANGE ADMIN PASSWORD", request["admin_username"]) return admin_main.getAdminActions().changeAdminPassword(request["admin_username"], request["new_password"], request.getAuthNameObj().getAdminID(), request.getRemoteAddr())
[ویرایش] deleteAdmin
delete admin with username "admin_username"<br>
- Auth Type
- ADMIN
- Arguments
- "admin_username"
- Permission
- "DELETE ADMIN", request["admin_username"]
- Code
def deleteAdmin(self, request): """ delete admin with username "admin_username" """ request.needAuthType(request.ADMIN) request.checkArgs("admin_username") request.getAuthNameObj().canDo("DELETE ADMIN", request["admin_username"]) return admin_main.getAdminActions().deleteAdmin(request["admin_username"], request.getAuthNameObj().getAdminID(), request.getRemoteAddr())
[ویرایش] expireAllAdminOTPs
- Auth Type
- ADMIN
- Permission
- "CHANGE ADMIN INFO"
- Code
def expireAllAdminOTPs(self, request): request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() requester.canDo("CHANGE ADMIN INFO") admin_id = request.getAuthNameObj().getAdminID() admin_main.getAdminActions().expireAllAdminOTPs(admin_id)
[ویرایش] generateOTP
generates one time passwords for the admin with username, request[user_name]<br> admin_username : the username of the target admin<br> pass_len : lenght of each password<br> pass_counter : number of generated passwords <br>
- Auth Type
- ADMIN
- Arguments
- "pass_len", "pass_count", "admin_username"
- Permission
- "CHANGE ADMIN PASSWORD", request["admin_username"]
- Code
def generateOTP(self, request): """ generates one time passwords for the admin with username, request[user_name] admin_username : the username of the target admin pass_len : lenght of each password pass_counter : number of generated passwords """ request.needAuthType(request.ADMIN) request.checkArgs("pass_len", "pass_count", "admin_username") requester_obj = request.getAuthNameObj() requester_obj.canDo("CHANGE ADMIN PASSWORD", request["admin_username"]) pass_list = admin_main.getAdminActions().generateOTP(request["admin_username"], request["pass_count"], request["pass_len"], request.getAuthNameObj().getAdminID(), request.getRemoteAddr()) return pass_list
[ویرایش] getAdminInfo
returns a dictionary of admin information with username "admin_username"<br> returned dictionary format is :<br> {"admin_id":int<br> "username":str<br> "name":str<br> "email":str<br> "comment":str<br> "isp_name":str<br> "creator_admin_username":str<br> "locked":boolean<br> last_request_ip":str<br> "last_activity":str<br> "online_status":boolean<br> }<br>
- Auth Type
- ADMIN
- Arguments
- "admin_username"
- Permission
- "SEE ADMIN INFO", request["admin_username"]
- Code
def getAdminInfo(self, request): """ returns a dictionary of admin information with username "admin_username" returned dictionary format is : {"admin_id":int "username":str "name":str "email":str "comment":str "isp_name":str "creator_admin_username":str "locked":boolean last_request_ip":str "last_activity":str "online_status":boolean } """ request.needAuthType(request.ADMIN) request.checkArgs("admin_username") requester_obj = request.getAuthNameObj() if request["admin_username"] != requester_obj.getAdminUsername(): requester_obj.canDo("SEE ADMIN INFO", request["admin_username"]) return admin_main.getAdminLoader().getAdminByName(request["admin_username"]).getInfo(request.getDateType())
[ویرایش] getAllAdminUsernames
returns a list of usernames, the requester admin has access to.<br> If requester admin doesn't have SEE ADMIN INFO permission, returns a list containing<br> only requester username.<br> An optional argument "isp_name" can be passed to this method, to return only admins in specified isp<br>
- Auth Type
- ADMIN
- Code
def getAllAdminUsernames(self, request): """ returns a list of usernames, the requester admin has access to. If requester admin doesn't have SEE ADMIN INFO permission, returns a list containing only requester username. An optional argument "isp_name" can be passed to this method, to return only admins in specified isp """ request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() if not requester_obj.hasPermOrGod("SEE ADMIN INFO"): return [requester_obj.getAdminUsername()] if request.has_key("isp_name"): requester_obj.checkAccessToISP(request["isp_name"]) isp_obj = admin_main.getISPLoader().getISPByName(request["isp_name"]) admin_objs = isp_obj.getChildAdmins() admin_usernames = map(lambda admin_obj:admin_obj.getAdminUsername(), admin_objs) else: admin_usernames = requester_obj.getISPObj().getAllChildAdminUsernames() sorted=SortedList(admin_usernames) sorted.sort(0) return sorted.getList()
[ویرایش] searchOTPs
- Auth Type
- ADMIN
- Arguments
- "conds", "_from", "to", "sort_by", "desc"
- Permission
- "SEE ADMIN INFO"
- Code
def searchOTPs(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "_from", "to", "sort_by", "desc") requester = request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) requester.canDo("SEE ADMIN INFO") role = "admin" searcher = otp_searcher.OTPSearcher(conds, requester, role) return searcher.getAdminOTPs(request["_from"], request["to"], request["sort_by"], request["desc"], request.getDateType())
[ویرایش] updateAdminInfo
Updates admin informations<br> admin_id(int): ID of Admin<br> admin_username(str): new username of admin<br> admin_isp_name(str): new ISP of admin<br> admin_locked(boolean):<br> comment(str):<br>
- Auth Type
- ADMIN
- Arguments
- "admin_id", "admin_username", "admin_isp_name", "admin_locked", "name", "email", "comment", "admin_has_otp"
- Permission
- "CHANGE ADMIN INFO", admin_id, request["admin_isp_name"]
- Code
def updateAdminInfo(self, request): """ Updates admin informations admin_id(int): ID of Admin admin_username(str): new username of admin admin_isp_name(str): new ISP of admin admin_locked(boolean): comment(str): """ request.needAuthType(request.ADMIN) request.checkArgs("admin_id", "admin_username", "admin_isp_name", "admin_locked", "name", "email", "comment", "admin_has_otp") admin_id = to_int(request["admin_id"], "Admin ID") request.getAuthNameObj().canDo("CHANGE ADMIN INFO", admin_id, request["admin_isp_name"]) return admin_main.getAdminActions().updateAdmin(admin_id, request["admin_username"], request["admin_isp_name"], request["admin_locked"], request["admin_has_otp"], request["name"], request["email"], request["comment"], request.getAuthNameObj().getAdminID(), request.getRemoteAddr())
[ویرایش] ISPHandler
[ویرایش] addNewISP
Adds a new ISP<br> isp_name(str): unique name of new isp<br> parent_isp_name(str): name of parent ISP<br> isp_has_deposit_limit(bool): Has the new isp deposit limit?<br> isp_deposit(float): initial deposit amount of ISP<br> isp_mapped_user_id(int): Mapped User ID or -1 if it's not going to get used<br> isp_auth_domain (str): authentication domain which clients use on connection requests. <br> isp_web_domain(str):<br> isp_email (str): general email address to be used for this isp. <br> isp_comment(str):<br>
- Auth Type
- ADMIN
- Arguments
- "isp_name", "parent_isp_name", "isp_has_deposit_limit", "isp_deposit", "isp_mapped_user_id", \
"isp_auth_domain", "isp_web_domain", "isp_email", "prevent_neg_deposit_login", "isp_comment"
- Permission
- "MANIPULATE ISP", request["parent_isp_name"]
- Code
def addNewISP(self, request): """ Adds a new ISP isp_name(str): unique name of new isp parent_isp_name(str): name of parent ISP isp_has_deposit_limit(bool): Has the new isp deposit limit? isp_deposit(float): initial deposit amount of ISP isp_mapped_user_id(int): Mapped User ID or -1 if it's not going to get used isp_auth_domain (str): authentication domain which clients use on connection requests. isp_web_domain(str): isp_email (str): general email address to be used for this isp. isp_comment(str): """ request.needAuthType(request.ADMIN) request.checkArgs("isp_name", "parent_isp_name", "isp_has_deposit_limit", "isp_deposit", "isp_mapped_user_id", \ "isp_auth_domain", "isp_web_domain", "isp_email", "prevent_neg_deposit_login", "isp_comment") creator_admin_obj=request.getAuthNameObj() creator_admin_obj.canDo("MANIPULATE ISP", request["parent_isp_name"]) isp_mapped_user_id = to_int(request["isp_mapped_user_id"], "ISP Mapped User ID") if isp_mapped_user_id == -1: isp_mapped_user_id = None else: creator_admin_obj.checkAccessToUser(isp_mapped_user_id) admin_main.getISPActions().addNewISP(request["isp_name"], request["parent_isp_name"], request["isp_has_deposit_limit"], to_float(request["isp_deposit"], "ISP Deposit"), isp_mapped_user_id, request["isp_auth_domain"], request["isp_web_domain"], request["isp_email"], request["prevent_neg_deposit_login"], request["isp_comment"], creator_admin_obj.getAdminUsername(), request.getRemoteAddr())
[ویرایش] changeISPDeposit
Changes ISP deposit by "credit_change" amount<br> isp_name(str): name of isp credit will be changed<br> deposit_amount(float): amount of change<br> comment(str):<br>
- Auth Type
- ADMIN
- Arguments
- "isp_name", "deposit_amount", "comment"
- Permission
- "MANIPULATE ISP", request["isp_name"]
- Code
def changeISPDeposit(self, request): """ Changes ISP deposit by "credit_change" amount isp_name(str): name of isp credit will be changed deposit_amount(float): amount of change comment(str): """ request.needAuthType(request.ADMIN) request.checkArgs("isp_name", "deposit_amount", "comment") requester_obj=request.getAuthNameObj() requester_obj.canDo("MANIPULATE ISP", request["isp_name"]) isp_name = request["isp_name"] if not requester_obj.isGod() and requester_obj.getISPObj().getISPName() == isp_name: raise GeneralException(errorText("ISP", "CHANGE_OWN_DEPOSIT_DENIED")) admin_main.getISPActions().changeDeposit(isp_name, to_float(request["deposit_amount"], "Deposit Amount"), request["comment"], requester_obj.getAdminUsername(), request.getRemoteAddr())
[ویرایش] deleteISP
- Auth Type
- ADMIN
- Arguments
- "isp_name"
- Permission
- "DELETE ISP", request["isp_name"]
- Code
def deleteISP(self, request): request.needAuthType(request.ADMIN) request.checkArgs("isp_name") requester_obj=request.getAuthNameObj() requester_obj.canDo("DELETE ISP", request["isp_name"]) admin_main.getISPActions().deleteISP(request["isp_name"], requester_obj.getAdminUsername(), request.getRemoteAddr())
[ویرایش] getAllISPMappedUserIDs
Returns a list of mapped user ids of isps<br>
- Auth Type
- ADMIN
- Permission
- "GOD"
- Code
def getAllISPMappedUserIDs(self, request): """ Returns a list of mapped user ids of isps """ request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() requester_obj.canDo("GOD") return admin_main.getISPActions().getAllISPMappedUserIDs()
[ویرایش] getAllISPNames
returns a list of isp names, the requester admin has access to.<br> If requester admin doesn't have SEE ISP INFO permission, returns a list containing<br> only requester isp.<br>
- Auth Type
- ADMIN
- Code
def getAllISPNames(self, request): """ returns a list of isp names, the requester admin has access to. If requester admin doesn't have SEE ISP INFO permission, returns a list containing only requester isp. """ request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() return admin_main.getISPActions().getAccessibleISPNames(requester_obj)
[ویرایش] getISPInfo
Returns a dictionary of isp informations in format<br> {"isp_id":int<br> "isp_name":str,<br> "isp_parent_name":str,<br> "isp_has_deposit_limit":boolean,<br> "isp_deposit":float,<br> "isp_mapped_user_id":int, -1 means this isp doesn't have mapped user id<br> "isp_mapped_user_online_instances":int,<br> "isp_mapped_user_credit": float,<br> "isp_locked":boolean,<br> "isp_auth_domain":str,<br> "isp_web_domain":str<br> "isp_email":str,<br> "prevent_neg_deposit_login":boolean,<br> "isp_comment":str<br> }<br>
- Auth Type
- ADMIN
- Arguments
- "isp_name"
- Permission
- "SEE ISP INFO", request["isp_name"]
- Code
def getISPInfo(self, request): """ Returns a dictionary of isp informations in format {"isp_id":int "isp_name":str, "isp_parent_name":str, "isp_has_deposit_limit":boolean, "isp_deposit":float, "isp_mapped_user_id":int, -1 means this isp doesn't have mapped user id "isp_mapped_user_online_instances":int, "isp_mapped_user_credit": float, "isp_locked":boolean, "isp_auth_domain":str, "isp_web_domain":str "isp_email":str, "prevent_neg_deposit_login":boolean, "isp_comment":str } """ request.needAuthType(request.ADMIN) request.checkArgs("isp_name") requester_obj=request.getAuthNameObj() if request["isp_name"] != requester_obj.getISPObj().getISPName(): requester_obj.canDo("SEE ISP INFO", request["isp_name"]) return admin_main.getISPLoader().getISPByName(request["isp_name"]).getInfo(request.getDateType())
[ویرایش] getISPPageStyle
- Auth Type
- ADMIN
- Permission
- "SEE ISP INFO", admin_main.getISPLoader(
- Code
def getISPPageStyle(self, request): request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() isp_id = to_int(request["isp_id"], "ISP ID") requester_obj.canDo("SEE ISP INFO", admin_main.getISPLoader().getISPByID(isp_id).getISPName()) page_style = admin_main.getISPLoader().getISPPageStyleByISPID(isp_id) page_style["is_root"] = admin_main.getISPLoader().getISPByID(isp_id).isRootISP() return page_style
[ویرایش] getISPTree
Returns a dic in format {isp_name:{isp_name:{..}, {isp_name:{..}}}<br> Returned dic is a tree of isp hierarchy<br>
- Auth Type
- ADMIN
- Code
def getISPTree(self, request): """ Returns a dic in format {isp_name:{isp_name:{..}, {isp_name:{..}}} Returned dic is a tree of isp hierarchy """ request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() if request.has_key("isp_name"): requester_obj.checkAccessToISP(request["isp_name"]) isp_obj = admin_main.getISPLoader().getISPByName(request["isp_name"]) else: isp_obj = requester_obj.getISPObj() isp_tree = {isp_obj.getISPName():isp_obj.getISPTree()} return isp_tree
[ویرایش] resetISPPageStyle
- Auth Type
- ADMIN
- Permission
- "CHANGE ISP PAGE STYLE", admin_main.getISPLoader(
- Code
def resetISPPageStyle(self, request): request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() isp_id = to_int(request["isp_id"], "ISP ID") requester_obj.canDo("CHANGE ISP PAGE STYLE", admin_main.getISPLoader().getISPByID(isp_id).getISPName()) admin_main.getISPActions().resetISPPageStyle(isp_id, requester_obj.getAdminID(), request.getRemoteAddr())
[ویرایش] setISPPageStyle
- Auth Type
- ADMIN
- Permission
- "CHANGE ISP PAGE STYLE", admin_main.getISPLoader(
- Code
def setISPPageStyle(self, request): request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() isp_id = to_int(request["isp_id"], "ISP ID") requester_obj.canDo("CHANGE ISP PAGE STYLE", admin_main.getISPLoader().getISPByID(isp_id).getISPName()) admin_main.getISPActions().setISPPageStyle(isp_id, request["header_logo_ext"], request["header_logo_contents"], request["header_bg_color"], request["header_text_color"], request["footer_logo_ext"], request["footer_logo_contents"], request["footer_bg_color"], request["footer_text_color"], request["footer_msg"], requester_obj.getAdminID(), request.getRemoteAddr()) return {}
[ویرایش] updateISP
Update ISP with id "isp_id"<br> isp_id(int): Unique id of updating ISP<br> isp_name(str): New Unique name of ISP<br> isp_has_deposit_limit(boolean): Has new ISP deposit limit?<br> isp_mapped_user_id(int): Mapped User ID or -1 if it's not going to get used<br> isp_locked(boolean): Is this isp locked?<br> isp_auth_domain (str):<br> isp_web_domain(str):<br> isp_email (str):<br> prevent_neg_deposit_login (boolean): to prevent admins from logging in, when isp deposit is negative<br> isp_comment(str):<br>
- Auth Type
- ADMIN
- Arguments
- "isp_id", "isp_name", "isp_has_deposit_limit", "isp_mapped_user_id", "isp_locked",
"isp_auth_domain", "isp_web_domain", "isp_email", "isp_comment", "prevent_neg_deposit_login", "parent_isp_name"
- Permission
- "MANIPULATE ISP", isp_name
- Code
def updateISP(self, request): """ Update ISP with id "isp_id" isp_id(int): Unique id of updating ISP isp_name(str): New Unique name of ISP isp_has_deposit_limit(boolean): Has new ISP deposit limit? isp_mapped_user_id(int): Mapped User ID or -1 if it's not going to get used isp_locked(boolean): Is this isp locked? isp_auth_domain (str): isp_web_domain(str): isp_email (str): prevent_neg_deposit_login (boolean): to prevent admins from logging in, when isp deposit is negative isp_comment(str): """ request.needAuthType(request.ADMIN) request.checkArgs("isp_id", "isp_name", "isp_has_deposit_limit", "isp_mapped_user_id", "isp_locked", "isp_auth_domain", "isp_web_domain", "isp_email", "isp_comment", "prevent_neg_deposit_login", "parent_isp_name") requester_obj=request.getAuthNameObj() isp_id = to_int(request["isp_id"], "ISP ID") isp_obj = admin_main.getISPLoader().getISPByID(isp_id) isp_name = isp_obj.getISPName() parent_isp_name = request["parent_isp_name"] requester_obj.canDo("MANIPULATE ISP", isp_name) if not requester_obj.isGod() and requester_obj.getISPObj().getISPName() == isp_name: raise GeneralException(errorText("ISP", "ACCESS_TO_ISP_DENIED")%isp_name) if isp_id == 0: parent_isp_name = None isp_mapped_user_id = to_int(request["isp_mapped_user_id"], "ISP Mapped User ID") if isp_mapped_user_id == -1: isp_mapped_user_id = None else: requester_obj.checkAccessToUser(isp_mapped_user_id) admin_main.getISPActions().updateISP(isp_id, request["isp_name"], parent_isp_name, request["isp_has_deposit_limit"], isp_mapped_user_id, request["isp_locked"], request["isp_auth_domain"], request["isp_web_domain"], request["isp_email"], request["isp_comment"], request["prevent_neg_deposit_login"], requester_obj.getAdminID(), request.getRemoteAddr())
[ویرایش] PermHandler
[ویرایش] canDo
return True if "admin_username" canDo "perm_name" with params<br>
- Auth Type
- ADMIN
- Arguments
- "perm_name", "admin_username", "params"
- Permission
- "SEE ADMIN PERMISSIONS", request["admin_username"]
- Code
def canDo(self, request): """ return True if "admin_username" canDo "perm_name" with params """ request.needAuthType(request.ADMIN) request.checkArgs("perm_name", "admin_username", "params") if request.auth_name != request["admin_username"]: request.getAuthNameObj().canDo("SEE ADMIN PERMISSIONS", request["admin_username"]) args = [request["perm_name"]] + request.fixList("params") try: admin_main.getAdminLoader().getAdminByName(request["admin_username"]).canDo( *args ) return True except PermissionException: return False
[ویرایش] changePermission
- Auth Type
- ADMIN
- Arguments
- "admin_username", "perm_name", "perm_value"
- Permission
- "CHANGE ADMIN PERMISSIONS", request["admin_username"]
- Code
def changePermission(self, request): request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() request.checkArgs("admin_username", "perm_name", "perm_value") requester_obj.canDo("CHANGE ADMIN PERMISSIONS", request["admin_username"]) perm_obj = admin_main.getPermLoader()[request["perm_name"]] if not requester_obj.isGod() and perm_obj.shouldInherit() and \ not requester_obj.hasPerm(request["perm_name"]): raise GeneralException(errorText("PERMISSION", "ACCESS_TO_PERMISSION_DENIED")%request["perm_name"]) perm_value = request["perm_value"] if isinstance(perm_value, dict): perm_value = request.fixList("perm_value") elif not isinstance(perm_value, list): perm_value = MultiStr(perm_value) admin_main.getPermActions().changePermission( request["admin_username"], request["perm_name"], perm_value, requester_obj.getAdminID(), request.getRemoteAddr() )
[ویرایش] delPermission
delete "perm_name" from "admin_username"<br>
- Auth Type
- ADMIN
- Arguments
- "admin_username", "perm_name"
- Permission
- "CHANGE ADMIN PERMISSIONS", request["admin_username"]
- Code
def delPermission(self, request): """ delete "perm_name" from "admin_username" """ request.needAuthType(request.ADMIN) request.checkArgs("admin_username", "perm_name") request.getAuthNameObj().canDo("CHANGE ADMIN PERMISSIONS", request["admin_username"]) admin_main.getPermActions().deletePermission(request["admin_username"], request["perm_name"], request.getAuthNameObj().getAdminID(), request.getRemoteAddr())
[ویرایش] delPermissionValue
delete "perm_value" from multivalue perm "perm_name" for admin "admin_username"<br>
- Auth Type
- ADMIN
- Arguments
- "admin_username", "perm_name", "perm_value"
- Permission
- "CHANGE ADMIN PERMISSIONS", request["admin_username"]
- Code
def delPermissionValue(self, request): """ delete "perm_value" from multivalue perm "perm_name" for admin "admin_username" """ request.needAuthType(request.ADMIN) request.checkArgs("admin_username", "perm_name", "perm_value") request.getAuthNameObj().canDo("CHANGE ADMIN PERMISSIONS", request["admin_username"]) admin_main.getPermActions().deleteFromPermValues(request["admin_username"], request["perm_name"], request["perm_value"], request.getAuthNameObj().getAdminID(), request.getRemoteAddr())
[ویرایش] deletePermTemplate
- Auth Type
- ADMIN
- Permission
- "CHANGE ADMIN PERMISSIONS"
- Arguments
- "perm_template_name"
- Code
def deletePermTemplate(self, request): request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() requester_obj.canDo("CHANGE ADMIN PERMISSIONS") request.checkArgs("perm_template_name") return admin_main.getPermActions().deletePermTemplate(request["perm_template_name"], requester_obj.getAdminUsername(), requester_obj.getAdminID(), request.getRemoteAddr())
[ویرایش] getAdminPermVal
return value of perm_name for admin_username<br>
- Auth Type
- ADMIN
- Arguments
- "perm_name", "admin_username"
- Permission
- "SEE ADMIN PERMISSIONS", request["admin_username"]
- Code
def getAdminPermVal(self, request): """ return value of perm_name for admin_username """ request.needAuthType(request.ADMIN) request.checkArgs("perm_name", "admin_username") if request.auth_name != request["admin_username"]: request.getAuthNameObj().canDo("SEE ADMIN PERMISSIONS", request["admin_username"]) perms = admin_main.getAdminLoader().getAdminByName(request["admin_username"]).getPerms() if not perms.has_key(request["perm_name"]): return request.getErrorResponse(errorText("PERMISSION", "DONT_HAVE_PERMISSION")%request["perm_name"]) return perms[request["perm_name"]].getReprValue()
[ویرایش] getAllPerms
Returns a list of dics of all perms that this admin has access to sorted by permission name<br> Each dic has "name, description, value_type, category, affected_pages, dependencies" keys<br> Optional argument category tells handler to return only permission of specified category<br> Categories can be one of: USER, ADMIN, RAS, CHARGE, GROUP, MISC, ALL<br>
- Auth Type
- ADMIN
- Permission
- "CHANGE ADMIN PERMISSIONS"
- Code
def getAllPerms(self, request): """ Returns a list of dics of all perms that this admin has access to sorted by permission name Each dic has "name, description, value_type, category, affected_pages, dependencies" keys Optional argument category tells handler to return only permission of specified category Categories can be one of: USER, ADMIN, RAS, CHARGE, GROUP, MISC, ALL """ request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() requester_obj.canDo("CHANGE ADMIN PERMISSIONS") all_perms_dic = admin_main.getPermLoader().getAllPerms() if request.has_key("category"): category = request["category"] else: category = "ALL" all_perms_list = self.__createPermsList(all_perms_dic, requester_obj, category) sorted = SortedList(all_perms_list) sorted.sortByPostText('["dependencies"]', 0) return sorted.getList()
[ویرایش] getListOfPermTemplates
- Auth Type
- ADMIN
- Permission
- "CHANGE ADMIN PERMISSIONS"
- Code
def getListOfPermTemplates(self, request): request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() requester_obj.canDo("CHANGE ADMIN PERMISSIONS") return admin_main.getPermActions().getListOfPermTemplates(requester_obj.getAdminUsername())
[ویرایش] getPermsOfAdmin
return a list of dics containing admin permission and sorted by permission name<br> each dic has "name, value, description, value_type, category" keys<br>
- Auth Type
- ADMIN
- Arguments
- "admin_username"
- Permission
- "SEE ADMIN PERMISSIONS", request["admin_username"]
- Code
def getPermsOfAdmin(self, request): """ return a list of dics containing admin permission and sorted by permission name each dic has "name, value, description, value_type, category" keys """ request.needAuthType(request.ADMIN) request.checkArgs("admin_username") requester_obj = request.getAuthNameObj() if request.auth_name != request["admin_username"]: requester_obj.canDo("SEE ADMIN PERMISSIONS", request["admin_username"]) admin_perms=admin_main.getAdminLoader().getAdminByName(request["admin_username"]).getPerms() perms_list=self.__getPermsListFromAdminPerms(admin_perms, requester_obj) sorted=SortedList(perms_list) sorted.sortByPostText('["name"]', 0) return sorted.getList()
[ویرایش] getPermsOfTemplate
- Auth Type
- ADMIN
- Permission
- "CHANGE ADMIN PERMISSIONS"
- Arguments
- "perm_template_name"
- Code
def getPermsOfTemplate(self, request): request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() requester_obj.canDo("CHANGE ADMIN PERMISSIONS") request.checkArgs("perm_template_name") perms_dic = admin_main.getPermActions().getPermsOfTemplate(request["perm_template_name"], requester_obj.getAdminUsername()) perms_list = self.__createAdminPermsFromRawPerms(perms_dic, requester_obj) sorted=SortedList(perms_list) sorted.sortByPostText('["name"]', 0) return sorted.getList()
[ویرایش] hasPerm
return True if admin has permission and else False<br>
- Auth Type
- ADMIN
- Arguments
- "perm_name", "admin_username"
- Permission
- "SEE ADMIN PERMISSIONS", request["admin_username"]
- Code
def hasPerm(self, request): """ return True if admin has permission and else False """ request.needAuthType(request.ADMIN) request.checkArgs("perm_name", "admin_username") if request.auth_name != request["admin_username"]: request.getAuthNameObj().canDo("SEE ADMIN PERMISSIONS", request["admin_username"]) return admin_main.getAdminLoader().getAdminByName(request["admin_username"]).hasPerm( request["perm_name"] )
[ویرایش] loadPermTemplateToAdmin
- Auth Type
- ADMIN
- Arguments
- "perm_template_name", "admin_username"
- Permission
- "CHANGE ADMIN PERMISSIONS", request["admin_username"]
- Code
def loadPermTemplateToAdmin(self, request): request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() request.checkArgs("perm_template_name", "admin_username") requester_obj.canDo("CHANGE ADMIN PERMISSIONS", request["admin_username"]) return admin_main.getPermActions().loadPermTemplateToAdmin(request["perm_template_name"], request["admin_username"], requester_obj.getAdminUsername(), requester_obj.getAdminID(), request.getRemoteAddr())
[ویرایش] loadPermsFromAnotherAdmin
- Auth Type
- ADMIN
- Permission
- "CHANGE ADMIN PERMISSIONS"
- Arguments
- "admin_username", "load_from_admin_username"
- Code
def loadPermsFromAnotherAdmin(self, request): request.needAuthType(request.ADMIN) requester_obj = request.getAuthNameObj() requester_obj.canDo("CHANGE ADMIN PERMISSIONS") request.checkArgs("admin_username", "load_from_admin_username") requester_obj.checkAccessToAdmin(request["load_from_admin_username"]) return admin_main.getPermActions().loadPermsFromAnotherAdmin(request["admin_username"], request["load_from_admin_username"], requester_obj.getAdminUsername(), requester_obj.getAdminID(), request.getRemoteAddr())
[ویرایش] savePermsOfAdminToTemplate
- Auth Type
- ADMIN
- Arguments
- "admin_username", "perm_template_name"
- Permission
- "CHANGE ADMIN PERMISSIONS", request["admin_username"]
- Code
def savePermsOfAdminToTemplate(self, request): request.needAuthType(request.ADMIN) request.checkArgs("admin_username", "perm_template_name") requester = request.getAuthNameObj() requester.canDo("CHANGE ADMIN PERMISSIONS", request["admin_username"]) admin_main.getPermActions().savePermsOfAdminToTemplate( request["admin_username"], request["perm_template_name"], requester.getISPObj().getISPName())
[ویرایش] BWHandler
[ویرایش] addBwStaticIP
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "ip_addr", "tx_leaf_name", "rx_leaf_name"
- Code
def addBwStaticIP(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("ip_addr", "tx_leaf_name", "rx_leaf_name") bw_main.getActionsManager().addBwStaticIP(request["ip_addr"], request["tx_leaf_name"], request["rx_leaf_name"])
[ویرایش] addInterface
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "hostname", "interface_name", "comment"
- Code
def addInterface(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("hostname", "interface_name", "comment") bw_main.getActionsManager().addInterface(request["hostname"], request["interface_name"], request["comment"])
[ویرایش] addLeaf
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "leaf_name", "parent_id", "default_rate_kbits", "default_ceil_kbits", "total_rate_kbits", "total_ceil_kbits", "default_priority", "total_priority"
- Code
def addLeaf(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("leaf_name", "parent_id", "default_rate_kbits", "default_ceil_kbits", "total_rate_kbits", "total_ceil_kbits", "default_priority", "total_priority") bw_main.getActionsManager().addLeaf(request["leaf_name"], to_int(request["parent_id"], "parent id"), self.__fixLimitKbits(request["default_rate_kbits"]), self.__fixLimitKbits(request["default_ceil_kbits"]), self.__fixLimitKbits(request["total_rate_kbits"], "INVALID_TOTAL_LIMIT_KBITS"), self.__fixLimitKbits(request["total_ceil_kbits"], "INVALID_TOTAL_LIMIT_KBITS"), request["default_priority"], request["total_priority"])
[ویرایش] addLeafService
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "leaf_name", "dst_ip", "protocol", "filter", "rate_kbits", "ceil_kbits", "priority"
- Code
def addLeafService(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("leaf_name", "dst_ip", "protocol", "filter", "rate_kbits", "ceil_kbits", "priority") bw_main.getActionsManager().addLeafService(request["leaf_name"], request["dst_ip"], request["protocol"], request["filter"], self.__fixLimitKbits(request["rate_kbits"]), self.__fixLimitKbits(request["ceil_kbits"]), request["priority"])
[ویرایش] addNode
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "hostname", "interface_name", "parent_id", "rate_kbits", "ceil_kbits", "priority"
- Code
def addNode(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("hostname", "interface_name", "parent_id", "rate_kbits", "ceil_kbits", "priority") bw_main.getActionsManager().addNode(request["hostname"], request["interface_name"], to_int(request["parent_id"], "parent id"), self.__fixLimitKbits(request["rate_kbits"]), self.__fixLimitKbits(request["ceil_kbits"]), request["priority"])
[ویرایش] delBwStaticIP
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "ip_addr"
- Code
def delBwStaticIP(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("ip_addr") bw_main.getActionsManager().delBwStaticIP(request["ip_addr"])
[ویرایش] delInterface
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "hostname", "interface_name"
- Code
def delInterface(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("hostname", "interface_name") return bw_main.getActionsManager().delInterface(request["hostname"], request["interface_name"])
[ویرایش] delLeaf
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "leaf_name"
- Code
def delLeaf(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("leaf_name") return bw_main.getActionsManager().delLeaf(request["leaf_name"])
[ویرایش] delLeafService
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "leaf_service_id", "leaf_name"
- Code
def delLeafService(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("leaf_service_id", "leaf_name") return bw_main.getActionsManager().delLeafService(request["leaf_name"], to_int(request["leaf_service_id"], "leaf service id"))
[ویرایش] delNode
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "node_id"
- Code
def delNode(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("node_id") return bw_main.getActionsManager().delNode(to_int(request["node_id"], "node id"))
[ویرایش] getActiveLeaves
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Code
def getActiveLeaves(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") return self.__sortActiveLeaves(bw_main.getManager().getAllUserLeavesInfo(), request["order_by"], request["desc"])
[ویرایش] getAllBwStaticIPs
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Code
def getAllBwStaticIPs(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") return bw_main.getLoader().getAllStaticIPs()
[ویرایش] getAllLeafNames
- Auth Type
- ADMIN
- Permission
- "CHANGE CHARGE"
- Code
def getAllLeafNames(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE CHARGE") leaf_names = bw_main.getActionsManager().getAccessbileLeafNames(request.getAuthNameObj()) return leaf_names
[ویرایش] getBwStaticIPInfo
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "ip_addr"
- Code
def getBwStaticIPInfo(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("ip_addr") return bw_main.getLoader().getStaticIPByIP(request["ip_addr"]).getInfo()
[ویرایش] getInterfaces
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Code
def getInterfaces(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") infos={} for hostname, if_name in bw_main.getLoader().getAllInterfaceAndHostNames(): try: infos["%s/%s"%(hostname,if_name)]=bw_main.getLoader().getInterfaceByHostAndInterface(hostname, if_name).getInfo() except GeneralException: pass return infos
[ویرایش] getLeafCharges
return a list of charge_names that "leaf_name" used in<br>
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "leaf_name"
- Code
def getLeafCharges(self, request): """ return a list of charge_names that "leaf_name" used in """ request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("leaf_name") leaf_obj = bw_main.getLoader().getLeafByName(request["leaf_name"]) charge_names = charge_main.getActionManager().getChargesWithBWLeaf(leaf_obj.getLeafID()) sorted_charge_names = SortedList(charge_names) sorted_charge_names.sort(False) return sorted_charge_names.getList()
[ویرایش] getLeafInfo
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "leaf_name"
- Code
def getLeafInfo(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("leaf_name") return bw_main.getLoader().getLeafByName(request["leaf_name"]).getInfo()
[ویرایش] getNodeInfo
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "node_id"
- Code
def getNodeInfo(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("node_id") return bw_main.getLoader().getNodeByID(to_int(request["node_id"], "node id")).getInfo()
[ویرایش] getRealHostInterfaces
Returns a list of interfaces install on host "hostname"<br>
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "hostname"
- Code
def getRealHostInterfaces(self, request): """ Returns a list of interfaces install on host "hostname" """ request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("hostname") return bw_main.getHostTools().getInterfaces(request["hostname"])
[ویرایش] getTree
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "hostname", "interface_name"
- Code
def getTree(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("hostname", "interface_name") return bw_main.getActionsManager().getTree(request["hostname"], request["interface_name"])
[ویرایش] updateBwStaticIP
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "static_ip_id", "ip_addr", "tx_leaf_name", "rx_leaf_name"
- Code
def updateBwStaticIP(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("static_ip_id", "ip_addr", "tx_leaf_name", "rx_leaf_name") bw_main.getActionsManager().updateBwStaticIP(to_int(request["static_ip_id"], "StaticIP ID"), request["ip_addr"], request["tx_leaf_name"], request["rx_leaf_name"] )
[ویرایش] updateInterface
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "interface_id", "hostname", "interface_name", "comment"
- Code
def updateInterface(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("interface_id", "hostname", "interface_name", "comment") return bw_main.getActionsManager().updateInterface(to_int(request["interface_id"], "interface id"), request["hostname"], request["interface_name"], request["comment"])
[ویرایش] updateLeaf
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "leaf_id", "leaf_name", "default_rate_kbits", "default_ceil_kbits", "total_rate_kbits", "total_ceil_kbits", "default_priority", "total_priority"
- Code
def updateLeaf(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("leaf_id", "leaf_name", "default_rate_kbits", "default_ceil_kbits", "total_rate_kbits", "total_ceil_kbits", "default_priority", "total_priority") bw_main.getActionsManager().updateLeaf(to_int(request["leaf_id"], "leaf id"), request["leaf_name"], self.__fixLimitKbits(request["default_rate_kbits"]), self.__fixLimitKbits(request["default_ceil_kbits"]), self.__fixLimitKbits(request["total_rate_kbits"], "INVALID_TOTAL_LIMIT_KBITS"), self.__fixLimitKbits(request["total_ceil_kbits"], "INVALID_TOTAL_LIMIT_KBITS"), request["default_priority"], request["total_priority"])
[ویرایش] updateLeafService
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "leaf_name", "leaf_service_id", "dst_ip", "protocol", "filter", "rate_kbits", "ceil_kbits", "priority"
- Code
def updateLeafService(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("leaf_name", "leaf_service_id", "dst_ip", "protocol", "filter", "rate_kbits", "ceil_kbits", "priority") bw_main.getActionsManager().updateLeafService(request["leaf_name"], to_int(request["leaf_service_id"], "leaf service id"), request["dst_ip"], request["protocol"], request["filter"], self.__fixLimitKbits(request["rate_kbits"]), self.__fixLimitKbits(request["ceil_kbits"]), request["priority"])
[ویرایش] updateNode
- Auth Type
- ADMIN
- Permission
- "CHANGE BANDWIDTH MANAGER"
- Arguments
- "node_id", "rate_kbits", "ceil_kbits", "priority"
- Code
def updateNode(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANAGER") request.checkArgs("node_id", "rate_kbits", "ceil_kbits", "priority") return bw_main.getActionsManager().updateNode(to_int(request["node_id"], "node id"), self.__fixLimitKbits(request["rate_kbits"]), self.__fixLimitKbits(request["ceil_kbits"]), request["priority"])
[ویرایش] ChargeHandler
[ویرایش] addNewCharge
- Auth Type
- ADMIN
- Arguments
- "charge_name", "comment"
- Permission
- "CHANGE CHARGE"
- Code
def addNewCharge(self, request): request.needAuthType(request.ADMIN) request.checkArgs("charge_name", "comment") requester = request.getAuthNameObj() requester.canDo("CHANGE CHARGE") charge_main.getActionManager().addNewCharge(request["charge_name"], requester.getISPObj().getISPName(), requester.getAdminID(), request["comment"], request.getRemoteAddr())
[ویرایش] addNewChargeRule
- Auth Type
- ADMIN
- Arguments
- "charge_rule_description", "charge_rule_priority", "charge_name"
- Permission
- "CHANGE CHARGE"
- Code
def addNewChargeRule(self, request): request.needAuthType(request.ADMIN) request.checkArgs("charge_rule_description", "charge_rule_priority", "charge_name") requester = request.getAuthNameObj() requester.checkAccessToChargeByName(request["charge_name"]) requester.canDo("CHANGE CHARGE") charge_main.getActionManager().addNewChargeRule(request["charge_rule_description"], request["charge_rule_priority"], request["charge_name"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] deleteCharge
- Auth Type
- ADMIN
- Arguments
- "charge_name"
- Permission
- "CHANGE CHARGE"
- Code
def deleteCharge(self, request): request.needAuthType(request.ADMIN) request.checkArgs("charge_name") requester = request.getAuthNameObj() requester.checkAccessToChargeByName(request["charge_name"]) requester.canDo("CHANGE CHARGE") charge_main.getActionManager().deleteCharge(request["charge_name"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] deleteChargeRule
- Auth Type
- ADMIN
- Arguments
- "charge_rule_id", "charge_name"
- Permission
- "CHANGE CHARGE"
- Code
def deleteChargeRule(self, request): request.needAuthType(request.ADMIN) request.checkArgs("charge_rule_id", "charge_name") requester = request.getAuthNameObj() requester.checkAccessToChargeByName(request["charge_name"]) requester.canDo("CHANGE CHARGE") charge_main.getActionManager().deleteChargeRule(to_int(request["charge_rule_id"], "Charge Rule ID"), request["charge_name"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] getChargeInfo
- Auth Type
- ADMIN
- Arguments
- "charge_name"
- Code
def getChargeInfo(self, request): request.needAuthType(request.ADMIN) request.checkArgs("charge_name") request.getAuthNameObj().checkAccessToChargeByName(request["charge_name"]) charge_obj = charge_main.getLoader().getChargeByName(request["charge_name"]) return charge_obj.getInfo(request.getDateType())
[ویرایش] listCharges
return a list of charge names<br> NOTE: this handler take care of admin permissions and return only charges that admin<br> has access to<br>
- Auth Type
- ADMIN
- Code
def listCharges(self, request): """ return a list of charge names NOTE: this handler take care of admin permissions and return only charges that admin has access to """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() return charge_main.getActionManager().getListOfCharges(requester)
[ویرایش] updateCharge
- Auth Type
- ADMIN
- Arguments
- "charge_id", "charge_name", "comment"
- Permission
- "CHANGE CHARGE"
- Code
def updateCharge(self, request): request.needAuthType(request.ADMIN) request.checkArgs("charge_id", "charge_name", "comment") requester = request.getAuthNameObj() charge_id = to_int(request["charge_id"], "Charge ID") charge_obj = charge_main.getLoader().getChargeByID(charge_id) if not requester.hasAccessToCharge(charge_obj.getChargeID()): raise GeneralException(errorText("CHARGES", "CHARGE_CHANGE_DENIED")%charge_obj.getChargeName()) requester.canDo("CHANGE CHARGE") charge_main.getActionManager().updateCharge(charge_id, request["charge_name"], request["comment"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] updateChargeRule
- Auth Type
- ADMIN
- Arguments
- "charge_rule_id", "charge_rule_description", "charge_rule_priority", "charge_name"
- Permission
- "CHANGE CHARGE"
- Code
def updateChargeRule(self, request): request.needAuthType(request.ADMIN) request.checkArgs("charge_rule_id", "charge_rule_description", "charge_rule_priority", "charge_name") requester = request.getAuthNameObj() requester.checkAccessToChargeByName(request["charge_name"]) requester.canDo("CHANGE CHARGE") charge_main.getActionManager().updateChargeRule(to_int(request["charge_rule_id"], "Charge Rule ID"), request["charge_rule_description"], request["charge_rule_priority"], request["charge_name"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] updateChargeRuleAttrs
- Auth Type
- ADMIN
- Arguments
- "charge_rule_id", "charge_name", "update_attrs", "delete_attrs"
- Permission
- "CHANGE CHARGE"
- Code
def updateChargeRuleAttrs(self, request): request.needAuthType(request.ADMIN) request.checkArgs("charge_rule_id", "charge_name", "update_attrs", "delete_attrs") requester = request.getAuthNameObj() requester.checkAccessToChargeByName(request["charge_name"]) requester.canDo("CHANGE CHARGE") charge_main.getActionManager().updateChargeRuleAttrs(to_int(request["charge_rule_id"], "Charge Rule ID"), request["charge_name"], report_lib.fixConditionsDic( request["update_attrs"] ), request.fixList("delete_attrs"), requester.getAdminID(), request.getRemoteAddr())
[ویرایش] VoIPTariffHandler
[ویرایش] addNewPrefixGroup
Add a new prefix group<br>
- Auth Type
- ADMIN
- Permission
- "CHANGE VOIP TARIFF"
- Arguments
- "prefix_group_name", "prefix_group_comment"
- Code
def addNewPrefixGroup(self, request): """ Add a new prefix group """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() requester.canDo("CHANGE VOIP TARIFF") request.checkArgs("prefix_group_name", "prefix_group_comment") voip_tariff_main.getPrefixGroupActions().addNewPrefixGroup(request["prefix_group_name"], request["prefix_group_comment"], requester.getISPObj().getISPName(), requester.getAdminID(), request.getRemoteAddr())
[ویرایش] addNewVoIPTariff
Add a new voip tariff<br>
- Auth Type
- ADMIN
- Permission
- "CHANGE VOIP TARIFF"
- Arguments
- "voip_tariff_name", "voip_tariff_comment", "strip_prefixes"
- Code
def addNewVoIPTariff(self, request): """ Add a new voip tariff """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() requester.canDo("CHANGE VOIP TARIFF") request.checkArgs("voip_tariff_name", "voip_tariff_comment", "strip_prefixes") voip_tariff_main.getVoIPTariffActions().addNewVoIPTariff(request["voip_tariff_name"], request["voip_tariff_comment"], requester.getISPObj().getISPName(), request["strip_prefixes"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] addUpdatePrefixes
Add new prefix(es) or update prefixes<br> voip_tariff_name(str): Name of voip tariff that prefixes will be added/updated<br> prefixes_list(list of list or str): a list in format<br> [[prefix_code, prefix_name, prefix_group_name, cpm, announcement_cpm], ...]<br> or an string, containing csv format same as above. lines should be separated by<br> new line.<br> duplicate_action(str): one of "ignore", "error", "update"<br>
- Auth Type
- ADMIN
- Arguments
- "voip_tariff_name", "prefixes_list", "duplicate_action"
- Permission
- "CHANGE VOIP TARIFF"
- Code
def addUpdatePrefixes(self, request): """ Add new prefix(es) or update prefixes voip_tariff_name(str): Name of voip tariff that prefixes will be added/updated prefixes_list(list of list or str): a list in format [[prefix_code, prefix_name, prefix_group_name, cpm, announcement_cpm], ...] or an string, containing csv format same as above. lines should be separated by new line. duplicate_action(str): one of "ignore", "error", "update" """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("voip_tariff_name", "prefixes_list", "duplicate_action") requester.canDo("CHANGE VOIP TARIFF") requester.checkAccessToVoIPTariffByName(request["voip_tariff_name"]) prefixes_list = request["prefixes_list"] if type(prefixes_list) in (types.ListType, types.DictType): prefixes_list = self.__fixPrefixesList(prefixes_list) elif type(prefixes_list) == types.StringType: prefixes_list = self.__parseCSVPrefixesList(prefixes_list) voip_tariff_main.getVoIPTariffActions().addUpdatePrefixes(request["voip_tariff_name"], prefixes_list, request["duplicate_action"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] deleteAllPrefixes
delete prefixes with names in list prefix_names<br>
- Auth Type
- ADMIN
- Arguments
- "voip_tariff_name"
- Permission
- "CHANGE VOIP TARIFF"
- Code
def deleteAllPrefixes(self, request): """ delete prefixes with names in list prefix_names """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("voip_tariff_name") requester.canDo("CHANGE VOIP TARIFF") requester.checkAccessToVoIPTariffByName(request["voip_tariff_name"]) voip_tariff_main.getVoIPTariffActions().deleteAllPrefixes(request["voip_tariff_name"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] deletePrefixGroup
delete a prefix group<br>
- Auth Type
- ADMIN
- Arguments
- "prefix_group_name"
- Permission
- "CHANGE VOIP TARIFF"
- Code
def deletePrefixGroup(self, request): """ delete a prefix group """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("prefix_group_name") requester.canDo("CHANGE VOIP TARIFF") requester.checkAccessToPrefixGroupByName(request["prefix_group_name"]) voip_tariff_main.getPrefixGroupActions().deletePrefixGroup(request["prefix_group_name"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] deletePrefixes
delete prefixes with names in list prefix_names<br>
- Auth Type
- ADMIN
- Arguments
- "voip_tariff_name", "prefix_ids"
- Permission
- "CHANGE VOIP TARIFF"
- Code
def deletePrefixes(self, request): """ delete prefixes with names in list prefix_names """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("voip_tariff_name", "prefix_ids") requester.canDo("CHANGE VOIP TARIFF") requester.checkAccessToVoIPTariffByName(request["voip_tariff_name"]) voip_tariff_main.getVoIPTariffActions().deletePrefixes(request["voip_tariff_name"], fixXMLRPCList(request["prefix_ids"]), requester.getAdminID(), request.getRemoteAddr())
[ویرایش] deleteVoIPTariff
delete a voip tariff<br>
- Auth Type
- ADMIN
- Arguments
- "voip_tariff_name"
- Permission
- "CHANGE VOIP TARIFF"
- Code
def deleteVoIPTariff(self, request): """ delete a voip tariff """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("voip_tariff_name") requester.canDo("CHANGE VOIP TARIFF") requester.checkAccessToVoIPTariffByName(request["voip_tariff_name"]) voip_tariff_main.getVoIPTariffActions().deleteVoIPTariff(request["voip_tariff_name"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] findCandidatesForDestination
Find Prefix for destination, return prefix representation.<br> If a prefix for such destination not found, raise an exception<br> Returns a list of matches , first one is the longest(best) match<br>
- Auth Type
- ADMIN
- Arguments
- "voip_tariff_name", "destination"
- Permission
- "SEE VOIP TARIFF"
- Code
def findCandidatesForDestination(self, request): """ Find Prefix for destination, return prefix representation. If a prefix for such destination not found, raise an exception Returns a list of matches , first one is the longest(best) match """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("voip_tariff_name", "destination") requester.canDo("SEE VOIP TARIFF") try: requester.checkAccessToVoIPTariffByName(request["voip_tariff_name"]) except (PermissionException, GeneralException): if request["voip_tariff_name"] not in voip_tariff_main.getVoIPTariffActions().getISPMappedUserVoIPTariffs(requester.getISPID()): raise voip_tariff_obj = voip_tariff_main.getLoader().getVoIPTariffByName(request["voip_tariff_name"]) prefix_objs = voip_tariff_obj.findCandidatesForDestination(request["destination"]) if prefix_objs: prefix_reprs = [] for prefix_obj in prefix_objs: prefix_reprs.append( prefix_obj.getReprDict(request.getDateType()) ) prefix_reprs.reverse() return prefix_reprs else: raise GeneralException(errorText("VOIP_TARIFF","NO_PREFIX_FOR_DESTINATION")%request["destination"])
[ویرایش] findPrefixForDestination
Find Prefix for destination, return prefix representation.<br> If a prefix for such destination not found, raise an exception<br>
- Auth Type
- ADMIN
- Arguments
- "voip_tariff_name", "destination"
- Permission
- "SEE VOIP TARIFF"
- Code
def findPrefixForDestination(self, request): """ Find Prefix for destination, return prefix representation. If a prefix for such destination not found, raise an exception """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("voip_tariff_name", "destination") requester.canDo("SEE VOIP TARIFF") try: requester.checkAccessToVoIPTariffByName(request["voip_tariff_name"]) except (PermissionException, GeneralException): if request["voip_tariff_name"] not in voip_tariff_main.getVoIPTariffActions().getISPMappedUserVoIPTariffs(requester.getISPID()): raise voip_tariff_obj = voip_tariff_main.getLoader().getVoIPTariffByName(request["voip_tariff_name"]) prefix_obj = voip_tariff_obj.findActivePrefixForDestination(request["destination"]) if prefix_obj: return [prefix_obj.getReprDict(request.getDateType())] else: return []
[ویرایش] getPrefixGroupRepr
return a dictionary of prefix group information<br> dictionary format is {"id":, "name":, "comment":, "attrs":{attr_name,attr_value } }<br>
- Auth Type
- ADMIN
- Arguments
- "prefix_group_name"
- Permission
- "SEE VOIP TARIFF"
- Code
def getPrefixGroupRepr(self, request): """ return a dictionary of prefix group information dictionary format is {"id":, "name":, "comment":, "attrs":{attr_name,attr_value } } """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("prefix_group_name") requester.canDo("SEE VOIP TARIFF") requester.checkAccessToPrefixGroupByName(request["prefix_group_name"]) prefix_group_obj = voip_tariff_main.getLoader().getPrefixGroupByName(request["prefix_group_name"]) return prefix_group_obj.getRepresentation(request.getDateType())
[ویرایش] getVoIPTariffRepr
return a dictionary of voip tariff information<br> dictionary format is {"voip_tarrif_id":, "voip_tariff_name":, "voip_tariff_comment":, "prefixes_count":}<br> include_prefixes(boolean): if include_prefixes set to true, a list of prefixes will be added to return value with key "prefixes"<br> format of prefixes list is:<br> [[prefix_id, prefix_code, prefix_name, prefix_group_name, cpm, announcement_cpm], ...]<br> prefix_conditions(dict): prefixes will match with patterns prefix_conditions(prefix_pattern name, prefix_pattern_code, etc.)<br> regular expressions and only prefixes with such patterns will be returned.<br> patterns can be empty, so all prefixes will be returned<br>
- Auth Type
- ADMIN
- Arguments
- "voip_tariff_name","include_prefixes", "prefix_conditions"
- Permission
- "SEE VOIP TARIFF"
- Code
def getVoIPTariffRepr(self, request): """ return a dictionary of voip tariff information dictionary format is {"voip_tarrif_id":, "voip_tariff_name":, "voip_tariff_comment":, "prefixes_count":} include_prefixes(boolean): if include_prefixes set to true, a list of prefixes will be added to return value with key "prefixes" format of prefixes list is: [[prefix_id, prefix_code, prefix_name, prefix_group_name, cpm, announcement_cpm], ...] prefix_conditions(dict): prefixes will match with patterns prefix_conditions(prefix_pattern name, prefix_pattern_code, etc.) regular expressions and only prefixes with such patterns will be returned. patterns can be empty, so all prefixes will be returned """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("voip_tariff_name","include_prefixes", "prefix_conditions") requester.canDo("SEE VOIP TARIFF") try: requester.checkAccessToVoIPTariffByName(request["voip_tariff_name"]) except PermissionException: if request["voip_tariff_name"] not in voip_tariff_main.getVoIPTariffActions().getISPMappedUserVoIPTariffs(requester.getISPID()): raise voip_tariff_obj = voip_tariff_main.getLoader().getVoIPTariffByName(request["voip_tariff_name"]) repr = {"voip_tariff_id": voip_tariff_obj._voip_tariff_id, "voip_tariff_name": voip_tariff_obj._voip_tariff_name, "voip_tariff_comment": voip_tariff_obj._voip_tariff_comment} if request["include_prefixes"]: prefixes = voip_tariff_obj.searchPrefix(request["prefix_conditions"]) prefix_reprs = map(lambda prefix: prefix.getRepr(request.getDateType()), prefixes) repr["voip_tariff_prefix"] = prefix_reprs return repr
[ویرایش] listPrefixGroups
returns a list of prefix group names<br>
- Auth Type
- ADMIN
- Permission
- "SEE VOIP TARIFF"
- Code
def listPrefixGroups(self, request): """ returns a list of prefix group names """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() requester.canDo("SEE VOIP TARIFF") return voip_tariff_main.getPrefixGroupActions().getListOfPrefixGroups(requester)
[ویرایش] listVoIPTariffs
returns a list of voip tariff names<br>
- Auth Type
- ADMIN
- Permission
- "SEE VOIP TARIFF"
- Code
def listVoIPTariffs(self, request): """ returns a list of voip tariff names """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() requester.canDo("SEE VOIP TARIFF") return voip_tariff_main.getVoIPTariffActions().getListOfVoIPTariffNames(requester)
[ویرایش] searchVoIPTariffPrefixes
- Auth Type
- ADMIN
- Arguments
- "voip_tariff_name", "conditions"
- Permission
- "SEE VOIP TARIFF"
- Code
def searchVoIPTariffPrefixes(self, request): request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("voip_tariff_name", "conditions") requester.canDo("SEE VOIP TARIFF") try: requester.checkAccessToVoIPTariffByName(request["voip_tariff_name"]) except (PermissionException, GeneralException): if request["voip_tariff_name"] not in voip_tariff_main.getVoIPTariffActions().getISPMappedUserVoIPTariffs(requester.getISPID()): raise voip_tariff_obj = voip_tariff_main.getLoader().getVoIPTariffByName(request["voip_tariff_name"]) prefix_obj_list = voip_tariff_obj.searchPrefix(request["conditions"]) prefix_reprs = [] for prefix_obj in prefix_obj_list: prefix_reprs.append( prefix_obj.getReprDict(request.getDateType())) prefix_reprs.reverse() return prefix_reprs
[ویرایش] updatePrefix
update a prefix<br>
- Auth Type
- ADMIN
- Arguments
- "voip_tariff_name", "prefix_id", "prefix_code", "prefix_name", "prefix_group_name", "cpm", "announcement_cpm"
- Permission
- "CHANGE VOIP TARIFF"
- Code
def updatePrefix(self, request): """ update a prefix """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("voip_tariff_name", "prefix_id", "prefix_code", "prefix_name", "prefix_group_name", "cpm", "announcement_cpm") requester.canDo("CHANGE VOIP TARIFF") requester.checkAccessToVoIPTariffByName(request["voip_tariff_name"]) voip_tariff_main.getVoIPTariffActions().updatePrefix(request["voip_tariff_name"], to_int(request["prefix_id"], "prefix id"), request["prefix_code"], request["prefix_name"], request["prefix_group_name"], to_float(request["cpm"], "cpm"), to_float(request["announcement_cpm"], "announcement cpm"), requester.getAdminID(), request.getRemoteAddr())
[ویرایش] updatePrefixGroup
update a prefix group<br>
- Auth Type
- ADMIN
- Arguments
- "prefix_group_id", "prefix_group_name", "prefix_group_comment"
- Permission
- "CHANGE VOIP TARIFF"
- Code
def updatePrefixGroup(self, request): """ update a prefix group """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("prefix_group_id", "prefix_group_name", "prefix_group_comment") prefix_group_id = to_int(request["prefix_group_id"], "prefix group id") requester.canDo("CHANGE VOIP TARIFF") prefix_group_obj = voip_tariff_main.getLoader().getPrefixGroupByID(prefix_group_id) requester.checkAccessToPrefixGroupByName(prefix_group_obj.getPrefixGroupName()) voip_tariff_main.getPrefixGroupActions().updatePrefixGroup(prefix_group_id, request["prefix_group_name"], request["prefix_group_comment"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] updatePrefixGroupAttrs
update prefix group attributes<br> update_attrs(dic): dictionary of attributes in format name=>value<br> delete_attrs(list): list of attribute names that will be deleted<br>
- Auth Type
- ADMIN
- Arguments
- "prefix_group_name", "update_attrs", "delete_attrs"
- Permission
- "CHANGE CHARGE"
- Code
def updatePrefixGroupAttrs(self, request): """ update prefix group attributes update_attrs(dic): dictionary of attributes in format name=>value delete_attrs(list): list of attribute names that will be deleted """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("prefix_group_name", "update_attrs", "delete_attrs") requester.canDo("CHANGE CHARGE") requester.checkAccessToPrefixGroupByName(request["prefix_group_name"]) voip_tariff_main.getPrefixGroupActions().updatePrefixGroupAttrs( request["prefix_group_name"], report_lib.fixConditionsDic( request["update_attrs"] ), request.fixList("delete_attrs"), requester.getAdminID(), request.getRemoteAddr())
[ویرایش] updateVoIPTariff
update voip tariff<br>
- Auth Type
- ADMIN
- Arguments
- "voip_tariff_id", "voip_tariff_name", "voip_tariff_comment", "strip_intl_prefixes"
- Permission
- "CHANGE VOIP TARIFF"
- Code
def updateVoIPTariff(self, request): """ update voip tariff """ request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() request.checkArgs("voip_tariff_id", "voip_tariff_name", "voip_tariff_comment", "strip_intl_prefixes") voip_tariff_id = to_int(request["voip_tariff_id"], "voip tariff id") requester.canDo("CHANGE VOIP TARIFF") voip_tariff_obj = voip_tariff_main.getLoader().getVoIPTariffByID(voip_tariff_id) requester.checkAccessToVoIPTariffByName(voip_tariff_obj.getVoIPTariffName()) voip_tariff_main.getVoIPTariffActions().updateVoIPTariff(voip_tariff_id, request["voip_tariff_name"], request["voip_tariff_comment"], request["strip_intl_prefixes"], requester.getAdminID(), request.getRemoteAddr())
[ویرایش] DefsHandler
[ویرایش] getAllDefs
- Auth Type
- ADMIN
- Permission
- "CHANGE IBS DEFINITIONS"
- Code
def getAllDefs(self,request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE IBS DEFINITIONS") def_vars=defs.getDefsLoader().getAllVars() defs_list=self.__getDefsListFromDefVars(def_vars) sorted=SortedList(defs_list) sorted.sortByPostText('["name"]',0) return sorted.getList()
[ویرایش] saveDefs
- Auth Type
- ADMIN
- Permission
- "CHANGE IBS DEFINITIONS"
- Arguments
- "defs"
- Code
def saveDefs(self,request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE IBS DEFINITIONS") request.checkArgs("defs") defs_main.getActionManager().saveDefs(request["defs"])
[ویرایش] ExtraChargeXMLRPCHandler
[ویرایش] getExtraChargeProfileNames
- Auth Type
- ADMIN
- Code
def getExtraChargeProfileNames(self, request): request.needAuthType(request.ADMIN) admin_obj = request.getAuthNameObj() admin_obj.hasPermOrGod("CHANGE USER ATTRIBUTES") profile_names = extra_charge_main.getLoader().getAllExtraChargeProfileNames() profile_names = filter(lambda profile_name:admin_obj.hasAccessToExtraChargeProfile(profile_name), profile_names) profile_names.sort() return profile_names
[ویرایش] GroupHandler
[ویرایش] addNewGroup
add a new group<br> group_name(string): name of new group, group_name is unique for each group<br> comment(string):<br>
- Auth Type
- ADMIN
- Arguments
- "group_name", "comment"
- Permission
- "CHANGE GROUP"
- Code
def addNewGroup(self, request): """ add a new group group_name(string): name of new group, group_name is unique for each group comment(string): """ request.needAuthType(request.ADMIN) request.checkArgs("group_name", "comment") requester=request.getAuthNameObj() requester.canDo("CHANGE GROUP") return group_main.getActionManager().addGroup(request["group_name"], request["comment"], requester.getISPObj().getISPName())
[ویرایش] delGroup
delete a group<br> group_name(string): name of group to be deleted<br>
- Auth Type
- ADMIN
- Arguments
- "group_name"
- Permission
- "CHANGE GROUP"
- Code
def delGroup(self, request): """ delete a group group_name(string): name of group to be deleted """ request.needAuthType(request.ADMIN) request.checkArgs("group_name") requester=request.getAuthNameObj() requester.checkAccessToGroupByName(request["group_name"]) requester.canDo("CHANGE GROUP") return group_main.getActionManager().delGroup(request["group_name"])
[ویرایش] getGroupCredits
returns a dictionary of group credits in format {group_name:group_credit}<br> Note that only group with group credit attribute and requester admin access is in dictionary<br>
- Auth Type
- ADMIN
- Code
def getGroupCredits(self, request): """ returns a dictionary of group credits in format {group_name:group_credit} Note that only group with group credit attribute and requester admin access is in dictionary """ request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() return group_main.getActionManager().getGroupCreditDic(requester)
[ویرایش] getGroupInfo
group_name(string): group name to return info for<br>
- Auth Type
- ADMIN
- Arguments
- "group_name"
- Code
def getGroupInfo(self, request): """ group_name(string): group name to return info for """ request.needAuthType(request.ADMIN) request.checkArgs("group_name") requester=request.getAuthNameObj() requester.checkAccessToGroupByName(request["group_name"]) group_obj=group_main.getLoader().getGroupByName(request["group_name"]) return group_obj.getInfo(request.getDateType())
[ویرایش] getGroupUsersCount
returns a dictionary of group users counts in format {group_name:users_count}<br> Note that only group with group credit attribute and requester admin access is in dictionary<br>
- Auth Type
- ADMIN
- Code
def getGroupUsersCount(self, request): """ returns a dictionary of group users counts in format {group_name:users_count} Note that only group with group credit attribute and requester admin access is in dictionary """ request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() return group_main.getActionManager().getGroupUsersCountDic(requester)
[ویرایش] listGroups
return a list of group names, that requester admin has access to<br>
- Auth Type
- ADMIN
- Code
def listGroups(self, request): """ return a list of group names, that requester admin has access to """ request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() return group_main.getActionManager().getListOfGroups(requester)
[ویرایش] updateGroup
update group information<br> group_id(integer): id of group that will be updated<br> group_name(string): new group name<br> comment(string): new group comment<br> isp_name(strin): name of ISP which group belongs to<br>
- Auth Type
- ADMIN
- Arguments
- "group_id", "group_name", "comment"
- Permission
- "CHANGE GROUP"
- Code
def updateGroup(self, request): """ update group information group_id(integer): id of group that will be updated group_name(string): new group name comment(string): new group comment isp_name(strin): name of ISP which group belongs to """ request.needAuthType(request.ADMIN) request.checkArgs("group_id", "group_name", "comment") requester = request.getAuthNameObj() group_id = to_int(request["group_id"], "group id") group_name = group_main.getLoader().getGroupByID(group_id).getGroupName() if not requester.hasAccessToGroup(group_id): raise GeneralException(errorText("GROUPS", "GROUP_CHANGE_DENIED")%group_name) if not requester.hasAccessToISP(request["isp_name"]): raise GeneralException(errorText("ISP", "ACCESS_TO_ISP_DENIED")%request["isp_name"]) requester.canDo("CHANGE GROUP") return group_main.getActionManager().updateGroup(group_id, request["group_name"], request["isp_name"], request["comment"])
[ویرایش] updateGroupAttrs
update group attributes<br> group_name(string): group name that attributes will be changed<br> attrs(dic): dictionary of attr_name:attr_value. We say we want attr_name value to be attr_value<br> to_del_attrs(dic): dic of attributes that should be deleted<br>
- Auth Type
- ADMIN
- Arguments
- "group_name", "attrs", "to_del_attrs"
- Permission
- "CHANGE GROUP", request["group_name"]
- Code
def updateGroupAttrs(self, request): """ update group attributes group_name(string): group name that attributes will be changed attrs(dic): dictionary of attr_name:attr_value. We say we want attr_name value to be attr_value to_del_attrs(dic): dic of attributes that should be deleted """ request.needAuthType(request.ADMIN) request.checkArgs("group_name", "attrs", "to_del_attrs") requester=request.getAuthNameObj() requester.checkAccessToGroupByName(request["group_name"]) requester.canDo("CHANGE GROUP", request["group_name"]) to_del_attrs=requestDicToList(request["to_del_attrs"]) return group_main.getActionManager().updateGroupAttrs(request["group_name"], request["attrs"], to_del_attrs, requester, request.getRemoteAddr())
[ویرایش] IASHandler
[ویرایش] deleteEvents
- Auth Type
- ADMIN
- Permission
- "HANDLE IAS EVENTS"
- Arguments
- "event_ids"
- Code
def deleteEvents(self, request): request.needAuthType(request.ADMIN) creator_obj=request.getAuthNameObj() creator_obj.canDo("HANDLE IAS EVENTS") request.checkArgs("event_ids") event_ids=map(lambda event_id:to_int(event_id, "event_id"), request.fixList("event_ids")) return ias_main.getActionsManager().deleteEvents(event_ids)
[ویرایش] getEvents
- Auth Type
- ADMIN
- Permission
- "HANDLE IAS EVENTS"
- Arguments
- "from_event_id", "from", "to"
- Code
def getEvents(self, request): request.needAuthType(request.ADMIN) creator_obj=request.getAuthNameObj() creator_obj.canDo("HANDLE IAS EVENTS") request.checkArgs("from_event_id", "from", "to") return ias_main.getActionsManager().getEvents(to_int(request["from_event_id"], "from_event_id"), to_int(request["from"], "from"), to_int(request["to"], "to"))
[ویرایش] getIASUserInfo
- Auth Type
- ADMIN
- Permission
- "HANDLE IAS EVENTS"
- Arguments
- "user_ids"
- Code
def getIASUserInfo(self, request): request.needAuthType(request.ADMIN) requester_obj=request.getAuthNameObj() requester_obj.canDo("HANDLE IAS EVENTS") request.checkArgs("user_ids") loaded_users=user_main.getActionManager().getLoadedUsersByUserID(request.fixList("user_ids")) user_infos=user_main.getActionManager().getUserInfosFromLoadedUsers(loaded_users, request.getDateType()) return self.__filterUserInfos(user_infos)
[ویرایش] IPpoolHandler
[ویرایش] addIPtoPool
- Auth Type
- ADMIN
- Arguments
- "ippool_name","ip"
- Permission
- "CHANGE IPPOOL"
- Code
def addIPtoPool(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ippool_name","ip") requester=request.getAuthNameObj() requester.canDo("CHANGE IPPOOL") self.__checkAccessToIPPoolByName(requester, request["ippool_name"]) ippool_main.getActionsManager().addIPtoPool(request["ippool_name"],multi_strs.MultiStr(request["ip"].strip(),False))
[ویرایش] addNewIPpool
- Auth Type
- ADMIN
- Permission
- "CHANGE IPPOOL"
- Arguments
- "ippool_name","comment"
- Code
def addNewIPpool(self,request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE IPPOOL") request.checkArgs("ippool_name","comment") ippool_main.getActionsManager().addNewPool(request["ippool_name"],request["comment"])
[ویرایش] addNewLoadBalancingIPpool
- Auth Type
- ADMIN
- Permission
- "CHANGE IPPOOL"
- Arguments
- "ippool_name", "ippool_comment", "balancing_strategy", "children_ippool_percentages"
- Code
def addNewLoadBalancingIPpool(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE IPPOOL") request.checkArgs("ippool_name", "ippool_comment", "balancing_strategy", "children_ippool_percentages") ippool_main.getLoadBalancingIPPoolActionsManager().addNewLoadBalancingIPPool( request["ippool_name"], request["ippool_comment"], request["balancing_strategy"], request["children_ippool_percentages"])
[ویرایش] delIPfromPool
- Auth Type
- ADMIN
- Arguments
- "ippool_name","ip"
- Permission
- "CHANGE IPPOOL"
- Code
def delIPfromPool(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ippool_name","ip") requester=request.getAuthNameObj() requester.canDo("CHANGE IPPOOL") self.__checkAccessToIPPoolByName(requester, request["ippool_name"]) ippool_main.getActionsManager().delIPfromPool(request["ippool_name"],multi_strs.MultiStr(request["ip"].strip(),False))
[ویرایش] deleteIPpool
- Auth Type
- ADMIN
- Arguments
- "ippool_name"
- Permission
- "CHANGE IPPOOL"
- Code
def deleteIPpool(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ippool_name") requester=request.getAuthNameObj() requester.canDo("CHANGE IPPOOL") self.__checkAccessToIPPoolByName(requester, request["ippool_name"]) ippool_main.getActionsManager().deletePool(request["ippool_name"])
[ویرایش] deleteLoadBalancingIPpool
- Auth Type
- ADMIN
- Arguments
- "ippool_name"
- Permission
- "CHANGE IPPOOL"
- Code
def deleteLoadBalancingIPpool(self, request): request.needAuthType(request.ADMIN) request.checkArgs("ippool_name") requester=request.getAuthNameObj() requester.canDo("CHANGE IPPOOL") self.__checkAccessToIPPoolByName(requester, request["ippool_name"]) ippool_main.getLoadBalancingIPPoolActionsManager().deleteLoadBalancingIPPool(request["ippool_name"])
[ویرایش] getIPpoolInfo
- Auth Type
- ADMIN
- Arguments
- "ippool_name"
- Permission
- "LIST IPPOOL"
- Code
def getIPpoolInfo(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ippool_name") requester = request.getAuthNameObj() requester.canDo("LIST IPPOOL") self.__checkAccessToIPPoolByName(requester, request["ippool_name"]) return ippool_main.getLoader().getIPpoolByName(request["ippool_name"]).getInfo()
[ویرایش] getIPpoolNames
- Auth Type
- ADMIN
- Permission
- "LIST IPPOOL"
- Code
def getIPpoolNames(self,request): request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() requester.canDo("LIST IPPOOL") ippool_names = ippool_main.getLoader().getAllIPpoolNames() def filterFunc(ippool_name): ippool_obj = ippool_main.getLoader().getIPpoolByName(ippool_name) ippool_id = ippool_obj.getIPpoolID() if not requester.hasAccessToIPPool(ippool_id): return False if request.has_key("ippool_type"): if request["ippool_type"] == "load_balancing": if not isinstance(ippool_obj, LoadBalancingIPPool): return False else: if not isinstance(ippool_obj, IPPool): return False return True filtered_ippool_names = filter(filterFunc, ippool_names) sorted = SortedList(filtered_ippool_names) sorted.sort(False) return sorted.getList()
[ویرایش] updateIPpool
- Auth Type
- ADMIN
- Permission
- "CHANGE IPPOOL"
- Arguments
- "ippool_id","ippool_name","comment"
- Code
def updateIPpool(self,request): request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() requester.canDo("CHANGE IPPOOL") requester.checkAccessToIPPool(request["ippool_id"]) request.checkArgs("ippool_id","ippool_name","comment") ippool_main.getActionsManager().updatePool(to_int(request["ippool_id"],"ippool id"),request["ippool_name"],request["comment"])
[ویرایش] updateLoadBalancingIPpool
- Auth Type
- ADMIN
- Arguments
- "ippool_id", "ippool_name", "ippool_comment", "balancing_strategy", "children_ippool_percentages"
- Permission
- "CHANGE IPPOOL"
- Code
def updateLoadBalancingIPpool(self, request): request.needAuthType(request.ADMIN) request.checkArgs("ippool_id", "ippool_name", "ippool_comment", "balancing_strategy", "children_ippool_percentages") requester=request.getAuthNameObj() requester.canDo("CHANGE IPPOOL") requester.checkAccessToIPPool(request["ippool_id"]) ippool_main.getLoadBalancingIPPoolActionsManager().updateLoadBalancingIPPool(to_int(request["ippool_id"], "IPPool ID"), request["ippool_name"], request["ippool_comment"], request["balancing_strategy"], request["children_ippool_percentages"])
[ویرایش] LDAPHandler
[ویرایش] getUserInfo
Returns Information Dictionary of a single user<br>
- Auth Type
- ADMIN
- Permission
- "ADD NEW USER"
- Arguments
- "username"
- Code
def getUserInfo(self, request): """ Returns Information Dictionary of a single user """ request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("ADD NEW USER") request.checkArgs("username") ldap_user_info, ldap_domain_obj = ldap_main.getManager().getUserInfoByAdmin(request["username"], request.getAuthNameObj()) if ldap_user_info: return self.__formatLDAPUserInfo(ldap_user_info) else: return {}
[ویرایش] getUserInfos
Returns a list of user infos(dict) that has been acquired from active directory<br> Argument starts_with is used to filter the returned dictionary. An empty starts_with will return all usernames<br>
- Auth Type
- ADMIN
- Permission
- "ADD NEW USER"
- Arguments
- "starts_with"
- Code
def getUserInfos(self, request): """ Returns a list of user infos(dict) that has been acquired from active directory Argument starts_with is used to filter the returned dictionary. An empty starts_with will return all usernames """ request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("ADD NEW USER") request.checkArgs("starts_with") user_infos = ldap_main.getManager().getAllUserInfosByAdmin(request.getAuthNameObj()) usernames = user_infos.keys() filtered_usernames = self.__filterAndSortUsernames(usernames, request["starts_with"]) ret_list = [] for username in filtered_usernames: user_dict = user_infos[username] user_dict["username"] = username ret_list.append(self.__formatLDAPUserInfo(user_dict)) return ret_list
[ویرایش] getUsernames
Returns a list of usernames that has been acquired from active directory<br> Argument starts_with is used to filter the returned dictionary. An empty starts_with will return all usernames<br>
- Auth Type
- ADMIN
- Permission
- "ADD NEW USER"
- Arguments
- "starts_with"
- Code
def getUsernames(self, request): """ Returns a list of usernames that has been acquired from active directory Argument starts_with is used to filter the returned dictionary. An empty starts_with will return all usernames """ request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("ADD NEW USER") request.checkArgs("starts_with") user_infos = ldap_main.getManager().getAllUserInfosByAdmin(request.getAuthNameObj()) usernames = user_infos.keys() filtered_usernames = self.__filterAndSortUsernames(usernames, request["starts_with"]) return filtered_usernames
[ویرایش] LocationsXMLRPCHandler
[ویرایش] getCityTelcoCenters
- Auth Type
- ADMIN
- Arguments
- "region_id","province_id","city_id"
- Code
def getCityTelcoCenters(self, request): request.needAuthType(request.ADMIN) request.checkArgs("region_id","province_id","city_id") region_obj = locations_main.getLoader().getRegion(int(request["region_id"])) city_telco_centers = {} for province_obj in region_obj._provinces: if province_obj._province_id == int(request["province_id"]): for city_obj in province_obj._cities: if city_obj._city_id == int(request["city_id"]): for telco_center_obj in city_obj._telco_centers: city_telco_centers[str(telco_center_obj._telco_center_id)] = telco_center_obj._telco_center_name return city_telco_centers
[ویرایش] getDevicePorts
- Auth Type
- ADMIN
- Arguments
- "region_id","province_id","city_id","telco_center_id","device_id"
- Code
def getDevicePorts(self, request): request.needAuthType(request.ADMIN) request.checkArgs("region_id","province_id","city_id","telco_center_id","device_id") region_obj = locations_main.getLoader().getRegion(int(request["region_id"])) device_ports = {} for province_obj in region_obj._provinces: if province_obj._province_id == int(request["province_id"]): for city_obj in province_obj._cities: if city_obj._city_id == int(request["city_id"]): for telco_center_obj in city_obj._telco_centers: if telco_center_obj._telco_center_id == int(request["telco_center_id"]): for device_obj in telco_center_obj._devices: if device_obj._device_id == int(request["device_id"]): for port_obj in device_obj._ports: device_ports[str(port_obj._port_id)] = port_obj._port_name return device_ports
[ویرایش] getProvinceCities
- Auth Type
- ADMIN
- Arguments
- "region_id","province_id"
- Code
def getProvinceCities(self, request): request.needAuthType(request.ADMIN) request.checkArgs("region_id","province_id") region_obj = locations_main.getLoader().getRegion(int(request["region_id"])) province_cities = {} for province_obj in region_obj._provinces: if province_obj._province_id == int(request["province_id"]): for city_obj in province_obj._cities: province_cities[str(city_obj._city_id)] = city_obj._city_name return province_cities
[ویرایش] getRegionProvinces
- Auth Type
- ADMIN
- Arguments
- "region_id"
- Code
def getRegionProvinces(self, request): request.needAuthType(request.ADMIN) request.checkArgs("region_id") requester = request.getAuthNameObj() region_obj = locations_main.getLoader().getRegion(int(request["region_id"])) filtered_provinces = locations_main.getFilter().getLocationIDNamesForAdminView(requester,region_obj._provinces,"province") region_provinces = {} for province_id in filtered_provinces: region_provinces[str(province_id)] = filtered_provinces[province_id] return region_provinces
[ویرایش] getRegions
- Auth Type
- ADMIN
- Code
def getRegions(self, request): request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() regions = {} all_regions = locations_main.getLoader().getRegionsIDNameMap() filtered_regions = locations_main.getFilter().getLocationIDNamesForAdminView(requester,all_regions,"region") for region_id in filtered_regions: regions[str(region_id)] = filtered_regions[region_id] return regions
[ویرایش] getTelcoCenterDevices
- Auth Type
- ADMIN
- Arguments
- "region_id","province_id","city_id","telco_center_id"
- Code
def getTelcoCenterDevices(self, request): request.needAuthType(request.ADMIN) request.checkArgs("region_id","province_id","city_id","telco_center_id") region_obj = locations_main.getLoader().getRegion(int(request["region_id"])) telco_center_devices = {} for province_obj in region_obj._provinces: if province_obj._province_id == int(request["province_id"]): for city_obj in province_obj._cities: if city_obj._city_id == int(request["city_id"]): for telco_center_obj in city_obj._telco_centers: if telco_center_obj._telco_center_id == int(request["telco_center_id"]): for device_obj in telco_center_obj._devices: telco_center_devices[str(device_obj._device_id)] = device_obj._device_name return telco_center_devices
[ویرایش] LoginHandler
[ویرایش] login
- Arguments
- "login_auth_name","login_auth_type","login_auth_pass"
- Code
def login(self,request): request.checkArgs("login_auth_name","login_auth_type","login_auth_pass") if request["login_auth_type"]==request.ADMIN: admin_main.getAdminLoader().getAdminByName(request["login_auth_name"]).checkLogin(Password(request["login_auth_pass"]),\ request.getRemoteAddr()) elif request["login_auth_type"]==request.NORMAL_USER: user_main.getServerAuth().checkAuth(request["login_auth_name"],Password(request["login_auth_pass"]),request["login_auth_type"]) elif request["login_auth_type"]==request.VOIP_USER: user_main.getServerAuth().checkAuth(request["login_auth_name"],Password(request["login_auth_pass"]),request["login_auth_type"]) elif request["login_auth_type"]==request.MAIL: pass elif request["login_auth_type"]==request.ANONYMOUS: pass else: raise GeneralException(errorText("GENERAL","ACCESS_DENIED")) if request.has_key("create_session") and request["create_session"]: session_id = session_main.getSessionManager().generateSession(request["login_auth_name"], request["login_auth_pass"], request["login_auth_type"], request["auth_remoteaddr"]) return session_id return True
[ویرایش] LogConsoleHandler
[ویرایش] getConsoleBuffer
- Auth Type
- ADMIN
- Permission
- "SEE CONNECTION LOGS"
- Code
def getConsoleBuffer(self, request): request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() requester.canDo("SEE CONNECTION LOGS") return console_main.getLogConsole().getBufferFormatted(request.getDateType(), requester)
[ویرایش] MessageCenterHandler
[ویرایش] activateService
This will finally set the cell_phone attribute<br>
- Auth Type
- NORMAL_USER,request.VOIP_USER
- Arguments
- "cell_number"
- Code
def activateService(self,request): """ This will finally set the cell_phone attribute """ request.needAuthType(request.NORMAL_USER,request.VOIP_USER) request.checkArgs("cell_number") loaded_user = request.getAuthNameObj() return mc_main.getRemoteRequestManager().sendActivationConfirm(loaded_user,request["cell_number"])
[ویرایش] addNewEPGroupToProvider
Add new provider End-point Group to a specified provider.<br> end_point_range: (list:string) list of desired/available end-points<br> provider_name: (string) the name of provider<br>
- Auth Type
- ADMIN
- Arguments
- "end_point_range", "provider_name"
- Permission
- "CHANGE PROVIDERS"
- Code
def addNewEPGroupToProvider(self,request): """ Add new provider End-point Group to a specified provider. end_point_range: (list:string) list of desired/available end-points provider_name: (string) the name of provider """ request.needAuthType(request.ADMIN) request.checkArgs("end_point_range", "provider_name") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE PROVIDERS") ep_group = MultiStr(request["end_point_range"]) provider_obj = provider.Provider.loadProvider(requester_obj, provider_name=request["provider_name"]) return provider_obj.addNewEndPointGroup(ep_group)
[ویرایش] addNewProvider
Add new provider, specified by provider type.<br> provider_type: (string) type of the selected provider<br>
- Auth Type
- ADMIN
- Permission
- "CHANGE PROVIDERS"
- Arguments
- "provider_type", "provider_name", "msg_type"
- Code
def addNewProvider(self,request): """ Add new provider, specified by provider type. provider_type: (string) type of the selected provider """ request.needAuthType(request.ADMIN) requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE PROVIDERS") request.checkArgs("provider_type", "provider_name", "msg_type") provider_info = provider.Provider.createProvider(request["provider_type"], request["provider_name"], requester_obj, request["msg_type"]).getInfo() return self.__prepareDict(provider_info)
[ویرایش] adminCancelScheduledMessages
- Auth Type
- ADMIN
- Arguments
- "message_ids"
- Code
def adminCancelScheduledMessages(self, request): request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() request.checkArgs("message_ids") mc_main.getActionManager().cancelScheduledMessage(request.fixList("message_ids"), "ISP", requester.getAllAccessibleISPIDs())
[ویرایش] adminDeleteMessage
- Permission
- "SEE MESSAGE CENTER REPORTS"
- Arguments
- "message_ids","target_box"
- Code
def adminDeleteMessage(self,request): """ Only admins are allowed to delete message with this handler """ request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() requester.canDo("SEE MESSAGE CENTER REPORTS") request.checkArgs("message_ids","target_box") mc_main.getActionManager().adminDeleteMessage(request.fixList("message_ids"),request["target_box"])
[ویرایش] adminEnqueueSend
Accept a message from interface to be sent:<br> body: (string) the message text<br> dst_list: (list) contains all destination<br> msg_type: (string) type of message<br> scheduled_date: (string) timestamp, specify manually when to send the message -- can be empty<br>
- Auth Type
- ADMIN
- Arguments
- "body", "destinations", "msg_type"
- Code
def adminEnqueueSend(self,request): """ Accept a message from interface to be sent: body: (string) the message text dst_list: (list) contains all destination msg_type: (string) type of message scheduled_date: (string) timestamp, specify manually when to send the message -- can be empty """ request.needAuthType(request.ADMIN) request.checkArgs("body", "destinations", "msg_type") requester_obj=request.getAuthNameObj() if request.has_key("schedule_date") and request["schedule_date"]: sched_date = request["schedule_date"] sched_date_unit = request["schedule_date_unit"] else: sched_date = None sched_date_unit = None dst_list = MultiStr(request["destinations"]) dst_list = map(None,dst_list) return mc_main.getActionManager().enqueueSend(request["body"], dst_list, request["msg_type"], sched_date, sched_date_unit, "ISP", requester_obj)
[ویرایش] adminSearchQueuedMessage
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "order_by", "desc"
- Permission
- "SEE MESSAGE CENTER REPORTS"
- Code
def adminSearchQueuedMessage(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "order_by", "desc") requester=request.getAuthNameObj() requester.canDo("SEE MESSAGE CENTER REPORTS") conds = report_lib.fixConditionsDic(request["conds"]) searcher = mc_queue_searcher.QueuedMessageSearcher(conds, requester, "admin") result = searcher.getQueuedMessage(request["from"], request["to"], request["order_by"], request["desc"], request.getDateType()) return result
[ویرایش] adminSearchReceivedMessage
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "order_by", "desc"
- Permission
- "SEE MESSAGE CENTER REPORTS"
- Code
def adminSearchReceivedMessage(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "order_by", "desc") requester=request.getAuthNameObj() requester.canDo("SEE MESSAGE CENTER REPORTS") conds = report_lib.fixConditionsDic(request["conds"]) if request["conds"]["owner_type"]=="ISP": searcher = mc_searcher.RecveivedMessageSearcher(conds, requester, "admin","mc_isp_receive_message") else: searcher = mc_searcher.RecveivedMessageSearcher(conds, requester, "admin","mc_user_receive_message") result = searcher.getRecveivedMessage(request["from"], request["to"], request["order_by"], request["desc"], request.getDateType()) return result
[ویرایش] adminSearchSentMessage
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "order_by", "desc"
- Permission
- "SEE MESSAGE CENTER REPORTS"
- Code
def adminSearchSentMessage(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "order_by", "desc") requester=request.getAuthNameObj() requester.canDo("SEE MESSAGE CENTER REPORTS") conds = report_lib.fixConditionsDic(request["conds"]) if request["conds"]["owner_type"]=="ISP": searcher = mc_searcher.SentMessageSearcher(conds, requester, "admin","mc_isp_send_message") else: searcher = mc_searcher.SentMessageSearcher(conds, requester, "admin","mc_user_send_message") result = searcher.getSentMessage(request["from"], request["to"], request["order_by"], request["desc"], request.getDateType()) return result
[ویرایش] assignEPToUser
Assign a specified End-Point to selected User.<br> user_id: (int)<br> end_point_id: (int) id of the selected end-point<br>
- Auth Type
- ADMIN
- Arguments
- "end_point_list"
- Code
def assignEPToUser(self,request): """ Assign a specified End-Point to selected User. user_id: (int) end_point_id: (int) id of the selected end-point """ request.needAuthType(request.ADMIN) request.checkArgs("end_point_list") requester_obj=request.getAuthNameObj() return
[ویرایش] checkActivationCode
- Auth Type
- NORMAL_USER,request.VOIP_USER
- Arguments
- "activation_code"
- Code
def checkActivationCode(self, request): request.needAuthType(request.NORMAL_USER,request.VOIP_USER) request.checkArgs("activation_code") loaded_user = request.getAuthNameObj() return mc_main.getRemoteRequestManager().checkUserActivationCode(loaded_user, request["activation_code"])
[ویرایش] dialerDeleteMessage
- Auth Type
- NORMAL_USER, request.VOIP_USER
- Arguments
- "message_id"
- Code
def dialerDeleteMessage(self,request): request.needAuthType(request.NORMAL_USER, request.VOIP_USER) request.checkArgs("message_id") requester=request.getAuthNameObj() mc_main.getActionManager().dialerDeleteMessage(requester.getUserID(), request["message_id"]["0"])
[ویرایش] enqueueSend
Accept a message from interface to be sent:<br> body: (string) the message text<br> dst_list: (list) contains all destination<br> msg_type: (string) type of message<br> scheduled_date: (string) timestamp, specify manually when to send the message -- can be empty<br>
- Auth Type
- NORMAL_USER,request.VOIP_USER
- Arguments
- "body", "destinations", "msg_type"
- Code
def enqueueSend(self,request): """ Accept a message from interface to be sent: body: (string) the message text dst_list: (list) contains all destination msg_type: (string) type of message scheduled_date: (string) timestamp, specify manually when to send the message -- can be empty """ request.needAuthType(request.NORMAL_USER,request.VOIP_USER) request.checkArgs("body", "destinations", "msg_type") loaded_user_obj=request.getAuthNameObj() if request.has_key("schedule_date") and request["schedule_date"]: sched_date = request["schedule_date"] sched_date_unit = request["schedule_date_unit"] else: sched_date = None sched_date_unit = None dst_list = MultiStr(request["destinations"]) dst_list = map(None,dst_list) if mc_main.getDebug(): toLog("enqueueSend: destinations: %s"%request["destinations"],LOG_DEBUG) return mc_main.getActionManager().enqueueSend(request["body"], dst_list, request["msg_type"], sched_date, sched_date_unit, "USER", loaded_user_obj)
[ویرایش] getActiveMSGTypes
- Auth Type
- ADMIN,request.NORMAL_USER, request.VOIP_USER
- Code
def getActiveMSGTypes(self, request): request.needAuthType(request.ADMIN,request.NORMAL_USER, request.VOIP_USER) requester_obj = request.getAuthNameObj() if request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(request.VOIP_USER): request_role="user" else: request_role="admin" view_type = "SEND" if request.has_key("view_type"): view_type = request["view_type"] return mc_main.getActionManager().getActiveMSGTypes(requester_obj, request_role, view_type)
[ویرایش] getAllActiveProviders
Returns a list of all added and active providers.<br>
- Auth Type
- ADMIN
- Code
def getAllActiveProviders(self,request): """ Returns a list of all added and active providers. """ request.needAuthType(request.ADMIN) requester_obj=request.getAuthNameObj() return provider.Provider.getAllProviders(requester_obj)
[ویرایش] getAllEPGroupsOfProvider
- Auth Type
- ADMIN
- Arguments
- "provider_name"
- Permission
- "CHANGE PROVIDERS"
- Code
def getAllEPGroupsOfProvider(self,request): request.needAuthType(request.ADMIN) request.checkArgs("provider_name") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE PROVIDERS") provider_obj = provider.Provider.loadProvider(requester_obj,provider_name=request["provider_name"]) ep_ranges = provider_obj.getAllEPGroups() for ep_range in ep_ranges: range = MultiStr(ep_range['ep_range']) ep_range['ep_range'] = range[0] + "-" + range[-1] return ep_ranges
[ویرایش] getAllMSGTypes
- Auth Type
- ADMIN,request.NORMAL_USER, request.VOIP_USER
- Code
def getAllMSGTypes(self, request): request.needAuthType(request.ADMIN,request.NORMAL_USER, request.VOIP_USER) return mc_main.getAllMSGTypes()
[ویرایش] getEPGroupUsageInfo
Gives the EndPoint Group information , range from and to , used EPs.<br>
- Auth Type
- ADMIN
- Arguments
- "end_point_group_id", "provider_id"
- Permission
- "CHANGE PROVIDERS"
- Code
def getEPGroupUsageInfo(self,request): """ Gives the EndPoint Group information , range from and to , used EPs. """ request.needAuthType(request.ADMIN) request.checkArgs("end_point_group_id", "provider_id") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE PROVIDERS") provider_obj = provider.Provider.loadProvider(requester_obj, provider_id = int(request["provider_id"])) return provider_obj.getEPGroupUsedEPsInfo(int(request["end_point_group_id"]))
[ویرایش] getProviderAttrsByName
Access Type: ADMIN<br> provider_name: (string) unique name of the provider<br> Return all information of an active provider,<br> selected by provider_id (to be represented in user side).<br> provider_attrs(dict): "attr_name":"attr_val"<br>
- Auth Type
- ADMIN
- Arguments
- "provider_name"
- Code
def getProviderAttrsByName(self,request): """ Access Type: ADMIN provider_name: (string) unique name of the provider Return all information of an active provider, selected by provider_id (to be represented in user side). provider_attrs(dict): "attr_name":"attr_val" """ request.needAuthType(request.ADMIN) request.checkArgs("provider_name") requester_obj=request.getAuthNameObj() provider_obj = provider.Provider.loadProvider(requester_obj, provider_name=to_str(request["provider_name"],"provider_name")) return self.__prepareDict(provider_obj.getAttrs())
[ویرایش] getProviderInfoByName
Access Type: ADMIN<br> provider_name(string): the unique name of selected provider<br> returns info of the selected provider<br> provider_info(dict): contains the key info of the provider<br>
- Auth Type
- ADMIN
- Arguments
- "provider_name"
- Code
def getProviderInfoByName(self,request): """ Access Type: ADMIN provider_name(string): the unique name of selected provider returns info of the selected provider provider_info(dict): contains the key info of the provider """ request.needAuthType(request.ADMIN) request.checkArgs("provider_name") requester_obj=request.getAuthNameObj() provider_obj = provider.Provider.loadProvider(requester_obj, provider_name=to_str(request["provider_name"], "provider_name")) return self.__prepareDict(provider_obj.getInfo())
[ویرایش] getProviderTypes
Access Type: ADMIN<br> Returns the infromation of all supported providers.<br> provider_types(list): of strings, containing all provider types<br>
- Auth Type
- ADMIN
- Code
def getProviderTypes(self,request): """ Access Type: ADMIN Returns the infromation of all supported providers. provider_types(list): of strings, containing all provider types """ request.needAuthType(request.ADMIN) return mc_main.getFactory().getAllTypes()
[ویرایش] getProviderUnassignedEPs
Returns a list of available/unassigned End-Points on the selected Provider<br> provider_name: (str)<br> count: (int-optional) the desired count of End-Points<br>
- Auth Type
- ADMIN
- Arguments
- "provider_name", "count", "starts_with"
- Permission
- "CHANGE PROVIDERS"
- Code
def getProviderUnassignedEPs(self,request): """ Returns a list of available/unassigned End-Points on the selected Provider provider_name: (str) count: (int-optional) the desired count of End-Points """ request.needAuthType(request.ADMIN) request.checkArgs("provider_name", "count", "starts_with") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE PROVIDERS") provider_obj = provider.Provider.loadProvider(requester_obj, provider_name=request["provider_name"]) return provider_obj.getUnassignedEPs(int(request["count"]), request["starts_with"])
[ویرایش] getRemoteRequestAttrs
- Auth Type
- ADMIN
- Permission
- "SEE MESSAGE CENTER REPORTS"
- Arguments
- "type"
- Code
def getRemoteRequestAttrs(self, request): request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() requester.canDo("SEE MESSAGE CENTER REPORTS") request.checkArgs("type") return mc_main.getRemoteRequestManager().getRemoteRequestAttrs(request["type"])
[ویرایش] getUserActivationNumber
- Auth Type
- NORMAL_USER,request.VOIP_USER
- Code
def getUserActivationNumber(self,request): request.needAuthType(request.NORMAL_USER,request.VOIP_USER) loaded_user = request.getAuthNameObj() if loaded_user.userHasAttr("cell_phone"): return {"activation_number":loaded_user.getUserAttrs()["cell_phone"]} else: return {"activation_number":""}
[ویرایش] getUserLastMessageID
- Auth Type
- VOIP_USER,request.NORMAL_USER
- Code
def getUserLastMessageID(self,request): request.needAuthType(request.VOIP_USER,request.NORMAL_USER) loaded_user = request.getAuthNameObj() return mc_main.getActionManager().getUserLastMessageID(loaded_user.getUserID(), loaded_user.getBasicUser().getISPID())
[ویرایش] receive
Accept a (plain) received message from<br> upper level (mostly IBSng interface):<br> content: (string) message body<br> sender: (string) available sender identifier(provider id)<br>
- Auth Type
- ANONYMOUS
- Arguments
- "msg_info"
- Code
def receive(self, request): """ Accept a (plain) received message from upper level (mostly IBSng interface): content: (string) message body sender: (string) available sender identifier(provider id) """ request.checkArgs("msg_info") mc_main.getActionManager().receive(request["msg_info"])
[ویرایش] removeEPGroupFromProvider
Remove selected EPs from selected provider.<br> provider_id: (int)<br> end_point_group_id: (int) EndPoint Group ID to be removed<br>
- Auth Type
- ADMIN
- Arguments
- "provider_id", "end_point_group_id"
- Permission
- "CHANGE PROVIDERS"
- Code
def removeEPGroupFromProvider(self,request): """ Remove selected EPs from selected provider. provider_id: (int) end_point_group_id: (int) EndPoint Group ID to be removed """ request.needAuthType(request.ADMIN) request.checkArgs("provider_id", "end_point_group_id") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE PROVIDERS") provider_obj = provider.Provider.loadProvider(requester_obj,provider_id=int(request["provider_id"])) return provider_obj.removeEPGroup(int(request["end_point_group_id"]))
[ویرایش] removeProvider
Remove a provider, selected by provider_id.<br>
- Auth Type
- ADMIN
- Arguments
- "provider_name"
- Permission
- "CHANGE PROVIDERS"
- Code
def removeProvider(self,request): """ Remove a provider, selected by provider_id. """ request.needAuthType(request.ADMIN) request.checkArgs("provider_name") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE PROVIDERS") return provider.Provider.removeProvider(request["provider_name"],requester_obj)
[ویرایش] resetProviderAttrs
Reset all attributes of the specified provider to<br> their default value.<br>
- Auth Type
- ADMIN
- Arguments
- "provider_name"
- Permission
- "CHANGE PROVIDERS"
- Code
def resetProviderAttrs(self,request): """ Reset all attributes of the specified provider to their default value. """ request.needAuthType(request.ADMIN) request.checkArgs("provider_name") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE PROVIDERS") provider_obj=provider.Provider.loadProvider(requester_obj, provider_name=request["provider_name"]) provider_obj.resetAttrs()
[ویرایش] resetUserActivationCode
- Auth Type
- NORMAL_USER,request.VOIP_USER
- Code
def resetUserActivationCode(self, request): request.needAuthType(request.NORMAL_USER,request.VOIP_USER) loaded_user = request.getAuthNameObj() return mc_main.getRemoteRequestManager().resetUserActivationCode(loaded_user)
[ویرایش] unAssingAllFromGroup
- Auth Type
- ADMIN
- Arguments
- "provider_name","end_point_group_id"
- Permission
- "CHANGE PROVIDERS"
- Code
def unAssingAllFromGroup(self,request): request.needAuthType(request.ADMIN) request.checkArgs("provider_name","end_point_group_id") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE PROVIDERS") provider_obj = provider.Provider.loadProvider(requester_obj,provider_name=request["provider_name"]) return provider_obj.unassignEPGroup(int(request["end_point_group_id"]))
[ویرایش] updateAdminRemoteRequestAttrs
- Auth Type
- ADMIN
- Permission
- "SEE MESSAGE CENTER REPORTS"
- Arguments
- "remote_report_status","remote_report_command","allowed_requesters","attrs"
- Code
def updateAdminRemoteRequestAttrs(self, request): request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() requester.canDo("SEE MESSAGE CENTER REPORTS") request.checkArgs("remote_report_status","remote_report_command","allowed_requesters","attrs") if mc_main.getDebug(): toLog("-- admin report selected attrs: %s"%str(request.fixList("attrs")),LOG_DEBUG) toLog("-- user report enable: %s"%str(request["remote_report_status"]),LOG_DEBUG) toLog("-- user report command: %s"%str(request["remote_report_command"]),LOG_DEBUG) mc_main.getRemoteRequestManager().updateAdminRemoteReport(request["remote_report_status"], request["remote_report_command"],request["allowed_requesters"],request.fixList("attrs"))
[ویرایش] updateProviderAttrs
Call update routines to update the<br> internal information of the selected provider.<br> provider_name: (string) unique name of provider<br> to_update_attrs: (dict) list of the attributes and their value to be updated<br>
- Auth Type
- ADMIN
- Arguments
- "provider_name", "to_update_attrs"
- Permission
- "CHANGE PROVIDERS"
- Code
def updateProviderAttrs(self,request): """ Call update routines to update the internal information of the selected provider. provider_name: (string) unique name of provider to_update_attrs: (dict) list of the attributes and their value to be updated """ request.needAuthType(request.ADMIN) request.checkArgs("provider_name", "to_update_attrs") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE PROVIDERS") provider_obj = provider.Provider.loadProvider(requester_obj,provider_name=request["provider_name"]) provider_obj.updateAttrs(request["to_update_attrs"])
[ویرایش] updateUserRemoteRequestAttrs
- Auth Type
- ADMIN
- Permission
- "SEE MESSAGE CENTER REPORTS"
- Arguments
- "remote_report_status","remote_report_command","activation_reply","attrs"
- Code
def updateUserRemoteRequestAttrs(self, request): request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() requester.canDo("SEE MESSAGE CENTER REPORTS") request.checkArgs("remote_report_status","remote_report_command","activation_reply","attrs") if mc_main.getDebug(): toLog("-- user report selected attrs: %s"%str(request.fixList("attrs")),LOG_DEBUG) toLog("-- user report enable: %s"%str(request["remote_report_status"]),LOG_DEBUG) toLog("-- user report command: %s"%str(request["remote_report_command"]),LOG_DEBUG) mc_main.getRemoteRequestManager().updateUserRemoteReport(request["remote_report_status"], request["remote_report_command"],request["activation_reply"],request.fixList("attrs"))
[ویرایش] userCancelScheduledMessages
- Auth Type
- NORMAL_USER, request.VOIP_USER
- Arguments
- "message_ids"
- Code
def userCancelScheduledMessages(self, request): request.needAuthType(request.NORMAL_USER, request.VOIP_USER) requester=request.getAuthNameObj() request.checkArgs("message_ids") mc_main.getActionManager().cancelScheduledMessage(request.fixList("message_ids"), "USER", [requester.getUserID()])
[ویرایش] userDeleteMessage
- Arguments
- "message_ids","target_box"
- Code
def userDeleteMessage(self,request): """ Only admins are allowed to delete message with this handler """ request.needAuthType(request.NORMAL_USER, request.VOIP_USER) requester=request.getAuthNameObj() request.checkArgs("message_ids","target_box") user_id=requester.getUserID() mc_main.getActionManager().userDeleteMessage(request.fixList("message_ids"),request["target_box"],user_id)
[ویرایش] userSearchMessagesForDialer
- Auth Type
- NORMAL_USER, request.VOIP_USER
- Arguments
- "from", "to", "order_by", "desc"
- Code
def userSearchMessagesForDialer(self,request): request.needAuthType(request.NORMAL_USER, request.VOIP_USER) request.checkArgs("from", "to", "order_by", "desc") requester=request.getAuthNameObj() searcher = mc_searcher.DialerMessageSearcher(requester.getUserID(),request.getDateType()) ret = searcher.getMessagesForDialer(request["from"],request["to"], request["order_by"],request["desc"]) return {"messages":ret}
[ویرایش] userSearchQueuedMessage
- Auth Type
- NORMAL_USER, request.VOIP_USER
- Arguments
- "conds", "from", "to", "order_by", "desc"
- Code
def userSearchQueuedMessage(self, request): request.needAuthType(request.NORMAL_USER, request.VOIP_USER) request.checkArgs("conds", "from", "to", "order_by", "desc") requester=request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) conds["owner_ids"] = str(requester.getUserID()) conds["owner_type"] = "USER" if not conds.has_key("msg_types"): conds["msg_types"] = "Message To User" searcher = mc_queue_searcher.QueuedMessageSearcher(conds, requester, "user") result = searcher.getQueuedMessage(request["from"], request["to"], request["order_by"], request["desc"], request.getDateType()) return result
[ویرایش] userSearchReceivedMessage
- Auth Type
- NORMAL_USER, request.VOIP_USER
- Arguments
- "conds", "from", "to", "order_by", "desc"
- Code
def userSearchReceivedMessage(self, request): request.needAuthType(request.NORMAL_USER, request.VOIP_USER) request.checkArgs("conds", "from", "to", "order_by", "desc") requester=request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) conds["user_ids"] = str(requester.getUserID()) conds["user_deleted"] = "f" conds["isp_send_to_all"] = [requester.getBasicUser().getISPID()] searcher = mc_searcher.RecveivedMessageSearcher(conds, requester, "user" , "mc_user_receive_message") result = searcher.getRecveivedMessage(request["from"], request["to"], request["order_by"], request["desc"], request.getDateType()) return result
[ویرایش] userSearchSentMessage
- Auth Type
- NORMAL_USER, request.VOIP_USER
- Arguments
- "conds", "from", "to", "order_by", "desc"
- Code
def userSearchSentMessage(self, request): request.needAuthType(request.NORMAL_USER, request.VOIP_USER) request.checkArgs("conds", "from", "to", "order_by", "desc") requester=request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) conds["user_ids"] = str(requester.getUserID()) conds["user_deleted"] = "f" if not conds.has_key("msg_types"): loaded_user = request.getAuthNameObj() if loaded_user.hasAttr("activation_required") and loaded_user.userHasAttr("cell_phone"): if loaded_user.getUserAttrs()["cell_phone"].startswith("X") and loaded_user.getUserAttrs()["cell_phone"].endswith("X"): conds["msg_types"] = "Message To Admin" searcher = mc_searcher.SentMessageSearcher(conds, requester, "user") result = searcher.getSentMessage(request["from"], request["to"], request["order_by"], request["desc"], request.getDateType()) return result
[ویرایش] MessageHandler
[ویرایش] deleteMessages
- Auth Type
- ADMIN
- Arguments
- "message_ids","table"
- Code
def deleteMessages(self, request): request.needAuthType(request.ADMIN) request.checkArgs("message_ids","table") message_main.getActionsManager().deleteMessages(self.__getMessageIDs(request), request["table"])
[ویرایش] deleteUserMessages
- Auth Type
- VOIP_USER,request.NORMAL_USER
- Arguments
- "message_ids"
- Code
def deleteUserMessages(self, request): request.needAuthType(request.VOIP_USER,request.NORMAL_USER) request.checkArgs("message_ids") message_main.getActionsManager().deleteUserMessages(self.__getMessageIDs(request), request.getAuthNameObj().getUserID() )
[ویرایش] getAdminMessages
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "VIEW MESSAGES"
- Code
def getAdminMessages(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester = request.getAuthNameObj() requester.canDo("VIEW MESSAGES") conds = report_lib.fixConditionsDic(request["conds"]) if conds.has_key("table") and conds["table"] == "user": table = "user_messages" else: table = "admin_messages" searcher = message_searcher.MessageSearcher(conds, requester, "admin", table) messages = searcher.getMessages(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) return messages
[ویرایش] getLastMessageID
- Auth Type
- VOIP_USER,request.NORMAL_USER
- Code
def getLastMessageID(self, request): request.needAuthType(request.VOIP_USER,request.NORMAL_USER) return message_main.getActionsManager().getUserLastMessageID(request.getAuthNameObj().getUserID())
[ویرایش] getUserMessages
- Auth Type
- VOIP_USER,request.NORMAL_USER
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Code
def getUserMessages(self, request): request.needAuthType(request.VOIP_USER,request.NORMAL_USER) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester = request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) searcher = message_searcher.MessageSearcher(conds, requester, "user", "user_messages") messages = searcher.getMessages(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) return messages
[ویرایش] postMessageToAdmin
- Auth Type
- VOIP_USER,request.NORMAL_USER
- Arguments
- "message"
- Code
def postMessageToAdmin(self, request): request.needAuthType(request.VOIP_USER,request.NORMAL_USER) request.checkArgs("message") requester=request.getAuthNameObj() message_main.getActionsManager().postMessageToAdmin(long(requester.getUserID()), request["message"])
[ویرایش] postMessageToUser
- Auth Type
- ADMIN
- Arguments
- "user_ids","message"
- Permission
- "POST MESSAGES"
- Code
def postMessageToUser(self, request): request.needAuthType(request.ADMIN) request.checkArgs("user_ids","message") requester=request.getAuthNameObj() requester.canDo("POST MESSAGES") if request["user_ids"] == "ALL USERS": user_ids = None else: user_ids = map(lambda x:to_long(x,"user id"),MultiStr(request["user_ids"])) message_main.getActionsManager().postMessageToUser(user_ids, request["message"])
[ویرایش] NotificationXMLRPCHandler
[ویرایش] getNotificationProfileNames
- Auth Type
- ADMIN
- Code
def getNotificationProfileNames(self, request): request.needAuthType(request.ADMIN) admin_obj = request.getAuthNameObj() admin_obj.hasPermOrGod("CHANGE USER ATTRIBUTES") profile_names = notification_main.getLoader().getAllNotificationProfileNames() profile_names = filter(lambda profile_name:admin_obj.hasAccessToNotificationProfile(profile_name), profile_names) profile_names.sort() return profile_names
[ویرایش] RasHandler
[ویرایش] addIPpoolToRas
Add an IP pool to ras<br>
- Auth Type
- ADMIN
- Arguments
- "ras_ip","ippool_name"
- Permission
- "CHANGE RAS"
- Code
def addIPpoolToRas(self,request): """ Add an IP pool to ras """ request.needAuthType(request.ADMIN) request.checkArgs("ras_ip","ippool_name") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") requester_obj.checkAccessToRasByIP(request["ras_ip"]) return ras_main.getActionManager().addIPpoolToRas(request["ras_ip"], request["ippool_name"], requester_obj.getAdminID(), requester_obj.getISPID(), request.getRemoteAddr() )
[ویرایش] addNewRas
- Auth Type
- ADMIN
- Permission
- "CHANGE RAS"
- Arguments
- "ras_ip","ras_type","radius_secret","ras_description","comment"
- Code
def addNewRas(self,request): request.needAuthType(request.ADMIN) creator_obj=request.getAuthNameObj() creator_obj.canDo("CHANGE RAS") request.checkArgs("ras_ip","ras_type","radius_secret","ras_description","comment") ras_id=ras_main.getActionManager().addNewRas(request["ras_ip"].strip(), request["ras_description"].strip(), request["ras_type"], request["radius_secret"], request["comment"], creator_obj.getAdminID(), creator_obj.getISPID(), request.getRemoteAddr() ) return ras_id
[ویرایش] addPort
- Auth Type
- ADMIN
- Arguments
- "ras_ip","port_name","phone","type","comment"
- Permission
- "CHANGE RAS"
- Code
def addPort(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_ip","port_name","phone","type","comment") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") requester_obj.checkAccessToRasByIP(request["ras_ip"]) return ras_main.getActionManager().addPort(request["ras_ip"], MultiStr(request["port_name"]), request["type"], MultiStr(request["phone"]), MultiStr(request["comment"]))
[ویرایش] deActiveRas
- Auth Type
- ADMIN
- Arguments
- "ras_ip"
- Permission
- "CHANGE RAS"
- Code
def deActiveRas(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_ip") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") requester_obj.checkAccessToRasByIP(request["ras_ip"]) return ras_main.getActionManager().deActiveRas(request["ras_ip"], requester_obj.getAdminID(), requester_obj.getISPID(), request.getRemoteAddr() )
[ویرایش] delIPpoolFromRas
Del an IP pool from ras<br>
- Auth Type
- ADMIN
- Arguments
- "ras_ip","ippool_name"
- Permission
- "CHANGE RAS"
- Code
def delIPpoolFromRas(self,request): """ Del an IP pool from ras """ request.needAuthType(request.ADMIN) request.checkArgs("ras_ip","ippool_name") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") requester_obj.checkAccessToRasByIP(request["ras_ip"]) return ras_main.getActionManager().delIPpoolFromRas(request["ras_ip"], request["ippool_name"], requester_obj.getAdminID(),requester_obj.getISPID(), request.getRemoteAddr() )
[ویرایش] delPort
- Auth Type
- ADMIN
- Arguments
- "ras_ip","port_name"
- Permission
- "CHANGE RAS"
- Code
def delPort(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_ip","port_name") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") requester_obj.checkAccessToRasByIP(request["ras_ip"]) return ras_main.getActionManager().delPort(request["ras_ip"], MultiStr(request["port_name"]))
[ویرایش] deleteRas
- Auth Type
- ADMIN
- Arguments
- "ras_id"
- Permission
- "CHANGE RAS"
- Code
def deleteRas(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_id") ras_id = to_int(request["ras_id"], "Ras ID") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") requester_obj.checkAccessToRas(ras_id) return ras_main.getActionManager().deleteRas(ras_id, requester_obj.getAdminID(), requester_obj.getISPID(), request.getRemoteAddr() )
[ویرایش] getActiveRasIPs
- Auth Type
- ADMIN
- Code
def getActiveRasIPs(self,request): request.needAuthType(request.ADMIN) creator_obj=request.getAuthNameObj() if request.has_key("type_filter"): types = request.fixList("type_filter") def typeFilter(ras_obj): if ras_obj.getType() in types: return ras_obj.getRasIP() return None ras_ips = filter(None, ras_main.getLoader().runOnAllRases(typeFilter)) else: ras_ips = ras_main.getLoader().getAllRasIPs() ras_ips = filter(creator_obj.hasAccessToRasByIP, ras_ips) sorted=SortedList(ras_ips) sorted.sort(False) return sorted.getList()
[ویرایش] getInActiveRases
- Auth Type
- ADMIN
- Permission
- "LIST RAS"
- Code
def getInActiveRases(self,request): request.needAuthType(request.ADMIN) creator_obj=request.getAuthNameObj() creator_obj.canDo("LIST RAS") return ras_main.getActionManager().getInActiveRases()
[ویرایش] getPortTypes
- Auth Type
- ADMIN
- Permission
- "CHANGE RAS"
- Code
def getPortTypes(self,request): request.needAuthType(request.ADMIN) requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") return ras.PORT_TYPES
[ویرایش] getRasAttributes
- Auth Type
- ADMIN
- Arguments
- "ras_ip"
- Permission
- "GET RAS INFORMATION"
- Code
def getRasAttributes(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_ip") requester_obj=request.getAuthNameObj() requester_obj.canDo("GET RAS INFORMATION") requester_obj.checkAccessToRasByIP(request["ras_ip"]) return ras_main.getLoader().getRasByIP(request["ras_ip"]).getAllAttributes()
[ویرایش] getRasDescriptions
return list of tuples in format [(ras_description,ras_ip)]<br>
- Auth Type
- ADMIN
- Code
def getRasDescriptions(self,request): """ return list of tuples in format [(ras_description,ras_ip)] """ request.needAuthType(request.ADMIN) requester_obj=request.getAuthNameObj() desc_to_ip_map = ras_main.getLoader().getRasDescToIPMap() for ras_desc, ras_ip in desc_to_ip_map.items(): if not requester_obj.hasAccessToRasByIP(ras_ip): del(desc_to_ip_map[ras_desc]) sorted=SortedDic(desc_to_ip_map) sorted.sortByKey(False) return sorted.getList()
[ویرایش] getRasIPpools
return a sorted list of ip pool names<br>
- Auth Type
- ADMIN
- Permission
- "GET RAS INFORMATION"
- Arguments
- "ras_ip"
- Code
def getRasIPpools(self,request): """ return a sorted list of ip pool names """ request.needAuthType(request.ADMIN) requester_obj=request.getAuthNameObj() requester_obj.canDo("GET RAS INFORMATION") requester_obj.checkAccessToRasByIP(request["ras_ip"]) request.checkArgs("ras_ip") ippool_ids=ras_main.getLoader().getRasByIP(request["ras_ip"]).getIPpools() ippool_names=map(lambda ippool_id:ippool_main.getLoader().getIPpoolByID(ippool_id).getIPpoolName(),ippool_ids) return ippool_names
[ویرایش] getRasInfo
- Auth Type
- ADMIN
- Permission
- "GET RAS INFORMATION"
- Arguments
- "ras_ip"
- Code
def getRasInfo(self,request): request.needAuthType(request.ADMIN) requester_obj=request.getAuthNameObj() requester_obj.canDo("GET RAS INFORMATION") request.checkArgs("ras_ip") requester_obj.checkAccessToRasByIP(request["ras_ip"]) ras_obj=ras_main.getLoader().getRasByIP(request["ras_ip"]) return ras_obj.getInfo()
[ویرایش] getRasPortInfo
- Auth Type
- ADMIN
- Permission
- "GET RAS INFORMATION"
- Arguments
- "ras_ip","port_name"
- Code
def getRasPortInfo(self,request): request.needAuthType(request.ADMIN) requester_obj=request.getAuthNameObj() requester_obj.canDo("GET RAS INFORMATION") requester_obj.checkAccessToRasByIP(request["ras_ip"]) request.checkArgs("ras_ip","port_name") return ras_main.getActionManager().getRasPortInfo(request["ras_ip"],MultiStr(request["port_name"]))
[ویرایش] getRasPorts
- Auth Type
- ADMIN
- Arguments
- "ras_ip"
- Permission
- "GET RAS INFORMATION"
- Code
def getRasPorts(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_ip") requester_obj=request.getAuthNameObj() requester_obj.canDo("GET RAS INFORMATION") requester_obj.checkAccessToRasByIP(request["ras_ip"]) sorted=SortedList(ras_main.getLoader().getRasByIP(request["ras_ip"]).getPorts().values()) sorted.sortByPostText("[\"port_name\"]",0) return sorted.getList()
[ویرایش] getRasTypes
return a list of all available ras types<br>
- Auth Type
- ADMIN
- Permission
- "GET RAS INFORMATION"
- Code
def getRasTypes(self,request): """ return a list of all available ras types """ request.needAuthType(request.ADMIN) creator_obj=request.getAuthNameObj() creator_obj.canDo("GET RAS INFORMATION") type_list=ras_main.getFactory().getAllTypes() sorted = SortedList(type_list) sorted.sort(False) return sorted.getList()
[ویرایش] reActiveRas
- Auth Type
- ADMIN
- Arguments
- "ras_ip"
- Permission
- "CHANGE RAS"
- Code
def reActiveRas(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_ip") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") inactive_ras_id = ras_main.getActionManager().getRasIDForInactiveRas( request["ras_ip"] ) requester_obj.checkAccessToRas( inactive_ras_id ) return ras_main.getActionManager().reActiveRas(request["ras_ip"], requester_obj.getAdminID(), requester_obj.getISPID(), request.getRemoteAddr() )
[ویرایش] resetAttributes
- Auth Type
- ADMIN
- Arguments
- "ras_ip"
- Permission
- "CHANGE RAS"
- Code
def resetAttributes(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_ip") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") requester_obj.checkAccessToRasByIP(request["ras_ip"]) return ras_main.getActionManager().delAttributes(request["ras_ip"], requester_obj.getAdminID(), requester_obj.getISPID(), request.getRemoteAddr() )
[ویرایش] updateAttributes
- Auth Type
- ADMIN
- Arguments
- "ras_ip","attrs"
- Permission
- "CHANGE RAS"
- Code
def updateAttributes(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_ip","attrs") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") requester_obj.checkAccessToRasByIP(request["ras_ip"]) return ras_main.getActionManager().updateAttribute(request["ras_ip"],request["attrs"], requester_obj.getAdminID(), requester_obj.getISPID(), request.getRemoteAddr() )
[ویرایش] updatePort
- Auth Type
- ADMIN
- Arguments
- "ras_ip","port_name","phone","type","comment"
- Permission
- "CHANGE RAS"
- Code
def updatePort(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_ip","port_name","phone","type","comment") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") requester_obj.checkAccessToRasByIP(request["ras_ip"]) return ras_main.getActionManager().updatePort(request["ras_ip"], MultiStr(request["port_name"]), MultiStr(request["phone"]), request["type"], MultiStr(request["comment"]))
[ویرایش] updateRasInfo
- Auth Type
- ADMIN
- Arguments
- "ras_id","ras_ip","ras_type","radius_secret","ras_description","comment"
- Permission
- "CHANGE RAS"
- Code
def updateRasInfo(self,request): request.needAuthType(request.ADMIN) request.checkArgs("ras_id","ras_ip","ras_type","radius_secret","ras_description","comment") requester_obj=request.getAuthNameObj() requester_obj.canDo("CHANGE RAS") requester_obj.checkAccessToRas(request["ras_id"]) return ras_main.getActionManager().updateRas(to_int(request["ras_id"],"Ras ID"), request["ras_ip"], request["ras_description"], request["ras_type"], request["radius_secret"], request["comment"], requester_obj.getAdminID(), requester_obj.getISPID(), request.getRemoteAddr() )
[ویرایش] ReportHandler
[ویرایش] autoCleanReports
auto clean the tables.<br> if value is zero, it means that auto cleaning for that table is disabled<br> unit should always be valid , even for zero values<br>
- Auth Type
- ADMIN
- Arguments
- "connection_log_clean", "connection_log_unit",
"credit_change_clean", "credit_change_unit", "user_audit_log_clean", "user_audit_log_unit", "snapshots_clean", "snapshots_unit", "bw_snapshots_clean", "bw_snapshots_unit", "web_analyzer_clean", "web_analyzer_unit"
- Permission
- "DELETE REPORTS"
- Code
def autoCleanReports(self, request): """ auto clean the tables. if value is zero, it means that auto cleaning for that table is disabled unit should always be valid , even for zero values """ request.needAuthType(request.ADMIN) request.checkArgs("connection_log_clean", "connection_log_unit", "credit_change_clean", "credit_change_unit", "user_audit_log_clean", "user_audit_log_unit", "snapshots_clean", "snapshots_unit", "bw_snapshots_clean", "bw_snapshots_unit", "web_analyzer_clean", "web_analyzer_unit") requester = request.getAuthNameObj() requester.canDo("DELETE REPORTS") report_main.getReportCleaner().updateAutoCleanStates({"connection_log":(request["connection_log_clean"], request["connection_log_unit"]), "credit_change":(request["credit_change_clean"], request["credit_change_unit"]), "user_audit_log":(request["user_audit_log_clean"], request["user_audit_log_unit"]), "snapshots":(request["snapshots_clean"], request["snapshots_unit"]), "bw_snapshots":(request["bw_snapshots_clean"], request["bw_snapshots_unit"]), "web_analyzer_log":(request["web_analyzer_clean"], request["web_analyzer_unit"]) })
[ویرایش] delReports
del reports of table, before date<br>
- Auth Type
- ADMIN
- Arguments
- "table", "date", "date_unit"
- Permission
- "DELETE REPORTS"
- Code
def delReports(self, request): """ del reports of table, before date """ request.needAuthType(request.ADMIN) request.checkArgs("table", "date", "date_unit") requester = request.getAuthNameObj() requester.canDo("DELETE REPORTS") report_main.getReportCleaner().cleanLogsFromSeconds(request["table"], RelativeDate(request["date"], request["date_unit"]).getDateSeconds())
[ویرایش] emailConnections
Email Connection logs to an specified email address<br> email_address(str): E-Mail address that mail will be sent<br> cols(list of str): List of columns from connections<br> detail_cols(list of str): List of columns from details<br> email_address(str): E-Mail address that report will be sent<br> conds(dic): Dictionary of conditions. Arguments owner and user_id are only settable by admins and not users.<br> Useful options are:<br> user_ids(MultiString): One or More user ids<br> owner(str): Show connection log for users of this admin<br> login_time_from(str): Value for login time of connection logs starts with ex. "2006/1/1"<br> login_time_from_unit(str): Unit for Login time ex. "gregorian"<br> login_time_to(str): Value for login time of connection logs end with ex. "2006/1/1"<br> login_time_to_unit(str): Unit for Login time ex. "gregorian"<br> successful(str): yes or no<br> show_total_credit_used(boolean): Set value for total credit used by all of the report<br> show_total_duration(boolean): Set value for total duration used by all of the report<br> show_total_inouts(boolean): Set value for total in/outs for all of the report<br> For complete list, see connection.py file<br> sort_by(str): Sort column of report can be one of: "user_id","credit_used","login_time","logout_time","successful","service","ras_id"<br> desc(boolean): Descending sort or Ascending?<br>
- Auth Type
- ADMIN, request.NORMAL_USER, request.VOIP_USER
- Arguments
- "conds", "email_address", "cols", "detail_cols", "sort_by", "desc"
- Permission
- "SEE CONNECTION LOGS"
- Code
def emailConnections(self, request): """ Email Connection logs to an specified email address email_address(str): E-Mail address that mail will be sent cols(list of str): List of columns from connections detail_cols(list of str): List of columns from details email_address(str): E-Mail address that report will be sent conds(dic): Dictionary of conditions. Arguments owner and user_id are only settable by admins and not users. Useful options are: user_ids(MultiString): One or More user ids owner(str): Show connection log for users of this admin login_time_from(str): Value for login time of connection logs starts with ex. "2006/1/1" login_time_from_unit(str): Unit for Login time ex. "gregorian" login_time_to(str): Value for login time of connection logs end with ex. "2006/1/1" login_time_to_unit(str): Unit for Login time ex. "gregorian" successful(str): yes or no show_total_credit_used(boolean): Set value for total credit used by all of the report show_total_duration(boolean): Set value for total duration used by all of the report show_total_inouts(boolean): Set value for total in/outs for all of the report For complete list, see connection.py file sort_by(str): Sort column of report can be one of: "user_id","credit_used","login_time","logout_time","successful","service","ras_id" desc(boolean): Descending sort or Ascending? """ request.needAuthType(request.ADMIN, request.NORMAL_USER, request.VOIP_USER) request.checkArgs("conds", "email_address", "cols", "detail_cols", "sort_by", "desc") requester=request.getAuthNameObj() requester.canDo("SEE CONNECTION LOGS") role = "admin" conds=report_lib.fixConditionsDic(request["conds"]) email_address = request["email_address"] checkEmailAddress(email_address) searcher=connection.ConnectionSearcher(conds, requester, role) method = searcher.emailConnectionLogs args = (email_address, request.fixList("cols"), request.fixList("detail_cols"), request["sort_by"], request["desc"], request.getDateType()) thread_main.runThread(method, args)
[ویرایش] emailPrefixNameUsage
- Auth Type
- ADMIN
- Arguments
- "conds", "order_by", "desc", "email_address"
- Permission
- "SEE CONNECTION LOGS"
- Code
def emailPrefixNameUsage(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "order_by", "desc", "email_address") requester=request.getAuthNameObj() conds=report_lib.fixConditionsDic(request["conds"]) requester.canDo("SEE CONNECTION LOGS") role = "admin" searcher=connection_usage.PrefixNameConnectionUsageSearcher(conds, requester, role) result = searcher.emailPrefixNameUsages(request["email_address"], request["order_by"], request["desc"], request.getDateType()) return result
[ویرایش] getAutoCleanDates
- Auth Type
- ADMIN
- Permission
- "DELETE REPORTS"
- Code
def getAutoCleanDates(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("DELETE REPORTS") return report_main.getReportCleaner().getAutoCleanDates()
[ویرایش] getCallerIDUsages
return a dic in format {"total_rows":,"report":[[caller_id, duration_seconds, credit_usage, count]]}.<br> order_by(str): can be one of "duration_seconds", "credit_usage", "caller_id" and count<br>
- Code
def getCallerIDUsages(self, request): """ return a dic in format {"total_rows":,"report":[[caller_id, duration_seconds, credit_usage, count]]}. order_by(str): can be one of "duration_seconds", "credit_usage", "caller_id" and count """ return self.__connectionUsageHandler(request, "getCallerIDUsages")
[ویرایش] getConnections
return connection logs of user(s) with specified criteria<br> return value is a dictionary of five values<br> {"total_rows": Total number of rows this report has. Always Present<br> "report": List of dictionaries, containing report. Always Present<br> "total_credit": Total credit used by all of the report and not only the returned row. Present if condition set<br> "total_duration": Total duraiton of report. Present if condition set<br> "total_in_bytes": Total In Bytes of report. Present if condition set<br> "total_out_bytes": Total Out bytes of report. Present if condition set<br> }<br> conds(dic): Dictionary of conditions. Arguments owner and user_id are only settable by admins and not users.<br> Useful options are:<br> user_ids(MultiString): One or More user ids<br> owner(str): Show connection log for users of this admin<br> login_time_from(str): Value for login time of connection logs starts with ex. "2006/1/1"<br> login_time_from_unit(str): Unit for Login time ex. "gregorian"<br> login_time_to(str): Value for login time of connection logs end with ex. "2006/1/1"<br> login_time_to_unit(str): Unit for Login time ex. "gregorian"<br> successful(str): yes or no<br> show_total_credit_used(boolean): Set value for total credit used by all of the report<br> show_total_duration(boolean): Set value for total duration used by all of the report<br> show_total_inouts(boolean): Set value for total in/outs for all of the report<br> For complete list, see connection.py file<br> from(int): get connection logs, starting from this index (used for paging report)<br> to(int): get connetion logs, end with this index<br> sort_by(str): Sort column of report can be one of: "user_id","credit_used","login_time","logout_time","successful","service","ras_id"<br> desc(boolean): Descending sort or Ascending?<br>
- Auth Type
- ADMIN, request.NORMAL_USER, request.VOIP_USER
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "SEE CONNECTION LOGS"
- Code
def getConnections(self, request): """ return connection logs of user(s) with specified criteria return value is a dictionary of five values {"total_rows": Total number of rows this report has. Always Present "report": List of dictionaries, containing report. Always Present "total_credit": Total credit used by all of the report and not only the returned row. Present if condition set "total_duration": Total duraiton of report. Present if condition set "total_in_bytes": Total In Bytes of report. Present if condition set "total_out_bytes": Total Out bytes of report. Present if condition set } conds(dic): Dictionary of conditions. Arguments owner and user_id are only settable by admins and not users. Useful options are: user_ids(MultiString): One or More user ids owner(str): Show connection log for users of this admin login_time_from(str): Value for login time of connection logs starts with ex. "2006/1/1" login_time_from_unit(str): Unit for Login time ex. "gregorian" login_time_to(str): Value for login time of connection logs end with ex. "2006/1/1" login_time_to_unit(str): Unit for Login time ex. "gregorian" successful(str): yes or no show_total_credit_used(boolean): Set value for total credit used by all of the report show_total_duration(boolean): Set value for total duration used by all of the report show_total_inouts(boolean): Set value for total in/outs for all of the report For complete list, see connection.py file from(int): get connection logs, starting from this index (used for paging report) to(int): get connetion logs, end with this index sort_by(str): Sort column of report can be one of: "user_id","credit_used","login_time","logout_time","successful","service","ras_id" desc(boolean): Descending sort or Ascending? """ request.needAuthType(request.ADMIN, request.NORMAL_USER, request.VOIP_USER) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester=request.getAuthNameObj() conds=report_lib.fixConditionsDic(request["conds"]) if request.hasAuthType(request.ADMIN): requester.canDo("SEE CONNECTION LOGS") role = "admin" elif request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(request.VOIP_USER): conds["user_ids"]=str(requester.getUserID()) role = "user" searcher=connection.ConnectionSearcher(conds, requester, role) connections = searcher.getConnectionLog(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) if role == "user": connections = self.__filterConnectionsForUser(connections) elif role == "admin": if not requester.isGod(): attr_list = [] if not requester.hasPerm("SEE VOIP PROVIDER"): attr_list.extend(["called_ip", "voip_provider_id", "voip_provider"]) if not requester.hasPerm("SEE VOIP PROVIDER CREDIT USED"): attr_list.extend(["voip_provider_credit_used", "voip_provider_prefix_name", "voip_provider_prefix_code", "voip_provider_cpm"]) connections["total_voip_provider_credit_used"]=-1 if attr_list: for report_dic in connections["report"]: for attr_name in attr_list: if report_dic.has_key(attr_name): del(report_dic[attr_name]) return connections
[ویرایش] getCreditChanges
return credit logs in format<br> {"total_rows": Total Number of Rows<br> "report": List of dics for the report<br> "total_per_user_credit": Total credit changes of user<br> "total_admin_credit": Total credit changes of admin<br> }<br>
- Auth Type
- ADMIN, request.NORMAL_USER, request.VOIP_USER
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "SEE CREDIT CHANGES"
- Code
def getCreditChanges(self, request): """ return credit logs in format {"total_rows": Total Number of Rows "report": List of dics for the report "total_per_user_credit": Total credit changes of user "total_admin_credit": Total credit changes of admin } """ request.needAuthType(request.ADMIN, request.NORMAL_USER, request.VOIP_USER) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester=request.getAuthNameObj() conds=report_lib.fixConditionsDic(request["conds"]) if request.hasAuthType(request.ADMIN): requester.canDo("SEE CREDIT CHANGES") role="admin" elif request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(request.VOIP_USER): conds["user_ids"]=str(requester.getUserID()) role="user" searcher=credit.CreditSearcher(conds, requester, role) credit_changes = searcher.getCreditChanges(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) if role == "user": credit_changes = self.__filterCreditChangesForUser(credit_changes) return credit_changes
[ویرایش] getCreditUsages
- Code
def getCreditUsages(self, request): return self.__connectionUsageHandler(request, "getCreditUsages")
[ویرایش] getDurationUsages
- Code
def getDurationUsages(self, request): return self.__connectionUsageHandler(request, "getDurationUsages")
[ویرایش] getDurations
- Auth Type
- ADMIN, request.NORMAL_USER, request.VOIP_USER
- Arguments
- "conds"
- Permission
- "SEE CONNECTION LOGS"
- Code
def getDurations(self, request): request.needAuthType(request.ADMIN, request.NORMAL_USER, request.VOIP_USER) request.checkArgs("conds") requester=request.getAuthNameObj() conds=report_lib.fixConditionsDic(request["conds"]) if request.hasAuthType(request.ADMIN): requester.canDo("SEE CONNECTION LOGS") role = "admin" elif request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(request.VOIP_USER): conds["user_ids"]=str(requester.getUserID()) role = "user" searcher=connection.ConnectionSearcher(conds, requester, role) return searcher.getDurations()
[ویرایش] getExpiredUsers
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "SEE CONNECTION LOGS"
- Code
def getExpiredUsers(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester=request.getAuthNameObj() conds=report_lib.fixConditionsDic(request["conds"]) if request.hasAuthType(request.ADMIN): requester.canDo("SEE CONNECTION LOGS") role = "admin" search_helper=user_main.getAttributeManager().runAttrSearchers(conds, requester) (total_rows, users_id)= search_helper.getUserIDs(request["from"], request["to"], request["sort_by"], request["desc"]) users_info = {} def prepareResult(result): dates_list = ['abs_exp_date','rel_exp_date','first_login','real_first_login'] for item in result: user_results = result[item] if user_results == None: result[item] = "" if type(user_results).__name__=='list': users = user_results[0] if isinstance(users, DictionaryType): prepareResult(users) if item in dates_list: result[item] = AbsDateFromEpoch( float(user_results) ).getGregorianDate() return result users_info_list = [] for user_id in users_id: user_attrs = user_main.getUserLoader().getUserAttrsByUserID(user_id) users_info_list.append( prepareResult(user_attrs) ) return users_info_list
[ویرایش] getGroupUsages
- Code
def getGroupUsages(self, request): return self.__adminConnectionReport(request, "getGroupUsages")
[ویرایش] getINConnections
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Code
def getINConnections(self, request): request.checkArgs("conds", "from", "to", "sort_by", "desc") conds=report_lib.fixConditionsDic(request["conds"]) conds["caller_id_op"]="equals" if not conds["caller_id"].isdigit(): raise GeneralException(errorText("USER","INVALID_CALLER_ID")%conds["caller_id"]) in_user_ids = self.__getAllINServiceUserIDs() if in_user_ids: conds["user_ids"]= ",".join(in_user_ids) else: raise GeneralException(errorText("GENERAL","NO_IN_SERVICE")) search_requester = admin_main.getAdminLoader().getAdminByID(0) searcher=connection.ConnectionSearcher(conds, search_requester, "admin") connections = searcher.getConnectionLog(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) connections = self.__filterConnectionsForUser(connections) return connections
[ویرایش] getISPDepositChangeLogs
return ISP change deposit logs<br>
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "SEE DEPOSIT CHANGES"
- Code
def getISPDepositChangeLogs(self, request): """ return ISP change deposit logs """ request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester = request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) requester.canDo("SEE DEPOSIT CHANGES") role = "admin" searcher = isp_deposit_change_log.ISPDepositChangeLogsSearcher(conds, requester, role) deposit_log_report = searcher.getISPDepositChangeLogs(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) return deposit_log_report
[ویرایش] getISPUsages
- Code
def getISPUsages(self, request): return self.__adminConnectionReport(request, "getISPUsages")
[ویرایش] getInOutUsages
- Code
def getInOutUsages(self, request): return self.__connectionUsageHandler(request, "getInOutUsages")
[ویرایش] getManagementSummaryReport
conds(dictionary): dictionary of conditions. May include<br> login_time_from, login_time_from_unit: Required condition to show start of report<br> login_time_to, logint_time_to_unit: Optional condition to show end of report, if not specified<br> now is used<br> view_period: required, daily, weekly, monthly<br> included_objects: required, a list, one or more of: ras, isp, service, group<br> report_targets: required, a list one or more of: credit, duration, in_bytes, out_bytes<br> returns a list of dictionaries in format<br> [<br> [(period_start_date, period_end_date),<br> ["group",[(group_name,{duration:,credit:,in_bytes:,out_bytes:}), ]<br> ["isp",[(isp_name,{}),]<br> ["ras",[(ras_ip,{})],<br> ["service",[Internet:{}, VoIP:{}] ]<br> ]<br>
- Auth Type
- ADMIN
- Arguments
- "conds"
- Permission
- "SEE CONNECTION LOGS"
- Permission
- "SEE VOIP PROVIDER CREDIT USED"
- Code
def getManagementSummaryReport(self, request): """ conds(dictionary): dictionary of conditions. May include login_time_from, login_time_from_unit: Required condition to show start of report login_time_to, logint_time_to_unit: Optional condition to show end of report, if not specified now is used view_period: required, daily, weekly, monthly included_objects: required, a list, one or more of: ras, isp, service, group report_targets: required, a list one or more of: credit, duration, in_bytes, out_bytes returns a list of dictionaries in format [ [(period_start_date, period_end_date), ["group",[(group_name,{duration:,credit:,in_bytes:,out_bytes:}), ] ["isp",[(isp_name,{}),] ["ras",[(ras_ip,{})], ["service",[Internet:{}, VoIP:{}] ] ] """ request.needAuthType(request.ADMIN) request.checkArgs("conds") requester = request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) requester.canDo("SEE CONNECTION LOGS") role = "admin" if (conds.has_key("report_targets") and "voip_provider_credit_used" in conds["report_targets"]) or \ (conds.has_key("included_objects") and "voip_provider" in conds["included_objects"]): requester.canDo("SEE VOIP PROVIDER CREDIT USED") searcher = management_summary.ManagementSummarySearcher(conds, requester, role) return searcher.getManagementSummaryReport(request.getDateType())
[ویرایش] getOnlineUsers
conds(dic): dictionary of conditions. Keys can be<br> isp_names: a list of isp names to filter<br> ras_ids: a list of ras ids to filter<br> username_starts_with: a list of prefixes to filter usernames that starts with<br>
- Auth Type
- ADMIN
- Arguments
- "normal_sort_by", "normal_desc", "voip_sort_by", "voip_desc", "conds"
- Permission
- "SEE ONLINE USERS"
- Code
def getOnlineUsers(self, request): """ conds(dic): dictionary of conditions. Keys can be isp_names: a list of isp names to filter ras_ids: a list of ras ids to filter username_starts_with: a list of prefixes to filter usernames that starts with """ request.needAuthType(request.ADMIN) request.checkArgs("normal_sort_by", "normal_desc", "voip_sort_by", "voip_desc", "conds") requester=request.getAuthNameObj() requester.canDo("SEE ONLINE USERS") conds = report_lib.fixConditionsDic(request["conds"]) if not requester.isGod(): conds["isp_ids"] = requester.getAllAccessibleISPIDs() if requester.hasPerm("SEE ACCESSIBLE RAS ONLINE USERS"): conds["see_accessible_ras_onlines"]=True if requester.hasPerm("RAS ACCESS"): ras_ids = [] for ras_id in requester.getPerms()["RAS ACCESS"].getValue(): try: ras_id = int(ras_id) except ValueError: pass else: ras_ids.append(ras_id) conds["accessible_ras_ids"] = ras_ids if requester.hasPerm("LOCATION ACCESS"): conds["admin_id"] = requester.getAdminID() filter_manager = onlines_filter.createFilterManager(conds) normal_onlines, voip_onlines = online.getFormattedOnlineUsers(request.getDateType(), filter_manager) normal_onlines, voip_onlines = online.sortOnlineUsers(normal_onlines, voip_onlines, (request["normal_sort_by"], request["normal_desc"]), (request["voip_sort_by"], request["voip_desc"])) if not requester.isGod() and not requester.hasPerm("SEE VOIP PROVIDER"): for report_dic in voip_onlines: report_dic["attrs"] = report_dic["attrs"].copy() if report_dic["attrs"].has_key("called_ip"): del(report_dic["attrs"]["called_ip"]) return (normal_onlines, voip_onlines)
[ویرایش] getOnlineUsersCount
returns the number of internet users and voip users in a tuple<br> conds(dic): dictionary of conditions. Keys can be<br> isp_names: a list of isp names to filter<br> ras_ids: a list of ras ids to filter<br> username_starts_with: a list of prefixes to filter usernames that starts with<br>
- Auth Type
- ADMIN
- Permission
- "SEE ONLINE USERS"
- Code
def getOnlineUsersCount(self, request): """ returns the number of internet users and voip users in a tuple conds(dic): dictionary of conditions. Keys can be isp_names: a list of isp names to filter ras_ids: a list of ras ids to filter username_starts_with: a list of prefixes to filter usernames that starts with """ request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() requester.canDo("SEE ONLINE USERS") onlines_dic = user_main.getOnline().getOnlineUsersByRas() count_report_dict = {"internet_onlines":0, "voip_onlines": 0, "ras_description":{}, "group_name":{}, "isp_name":{} } for (ras_id,unique_id), user_obj in onlines_dic.iteritems(): if requester.hasAccessToUser(user_obj.getUserID()): try: instance = user_obj.getInstanceFromUniqueID(ras_id, unique_id) except IBSError: continue basic_user = user_obj.getLoadedUser().getBasicUser() ras_description = ras_main.getLoader().getRasByID(instance["ras_id"]).getRasDesc() isp_name = basic_user.getISPObj().getISPName() group_name = basic_user.getGroupObj().getGroupName() if count_report_dict["ras_description"].has_key(ras_description): count_report_dict["ras_description"][ras_description] += 1 else: count_report_dict["ras_description"][ras_description] = 1 if count_report_dict["isp_name"].has_key(isp_name): count_report_dict["isp_name"][isp_name] += 1 else: count_report_dict["isp_name"][isp_name] = 1 if count_report_dict["group_name"].has_key(group_name): count_report_dict["group_name"][group_name] += 1 else: count_report_dict["group_name"][group_name] = 1 if instance.isVoIP(): count_report_dict["voip_onlines"] += 1 else: count_report_dict["internet_onlines"] += 1 return count_report_dict
[ویرایش] getPrefixNameUsage
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "order_by", "desc"
- Permission
- "SEE CONNECTION LOGS"
- Code
def getPrefixNameUsage(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "order_by", "desc") requester=request.getAuthNameObj() conds=report_lib.fixConditionsDic(request["conds"]) requester.canDo("SEE CONNECTION LOGS") role = "admin" searcher=connection_usage.PrefixNameConnectionUsageSearcher(conds, requester, role) result = searcher.getPrefixNameUsages(request["from"], request["to"], request["order_by"], request["desc"]) return result
[ویرایش] getRasUsages
- Code
def getRasUsages(self, request): return self.__adminConnectionReport(request, "getRasUsages")
[ویرایش] getSuccessfulCounts
- Code
def getSuccessfulCounts(self, request): return self.__adminConnectionReport(request, "getSuccessfulCounts")
[ویرایش] getSystemAuditLogs
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "SEE SYSTEM AUDIT LOGS"
- Code
def getSystemAuditLogs(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester = request.getAuthNameObj() requester.canDo("SEE SYSTEM AUDIT LOGS") conds = report_lib.fixConditionsDic(request["conds"]) role = "admin" searcher = audit_log_searcher.AuditLogSearcher(conds, requester, role) return searcher.getSystemAuditLogs(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType() )
[ویرایش] getTemporaryExtendLogs
return temporary extennd logs, based on request["conds"] conditions<br> return value is a dic in format {"total_rows":,"report":[]}<br>
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "TEMPORARY EXTEND"
- Code
def getTemporaryExtendLogs(self, request): """ return temporary extennd logs, based on request["conds"] conditions return value is a dic in format {"total_rows":,"report":[]} """ request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester = request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) requester.canDo("TEMPORARY EXTEND") role = "admin" searcher = temp_extend_log.TempExtendLogSearcher(conds, requester, role) audit_log_report = searcher.getTempExtendLogs(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) return audit_log_report
[ویرایش] getUserAuditLogs
return user audit logs, based on request["conds"] conditions<br> return value is a dic in format {"total_rows":,"report":[]}<br>
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "SEE USER AUDIT LOGS"
- Code
def getUserAuditLogs(self, request): """ return user audit logs, based on request["conds"] conditions return value is a dic in format {"total_rows":,"report":[]} """ request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester = request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) requester.canDo("SEE USER AUDIT LOGS") role = "admin" searcher = audit_log.UserAuditLogSearcher(conds, requester, role) audit_log_report = searcher.getUserAuditLogs(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) return audit_log_report
[ویرایش] getUserDepositChanges
return deposit logs in format<br> {"total_rows": Total Number of Rows<br> "report": List of dics for the report<br> "total_deposit":Deposit<br> }<br>
- Auth Type
- ADMIN, request.NORMAL_USER, request.VOIP_USER
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "SEE USER DEPOSIT CHANGES"
- Code
def getUserDepositChanges(self, request): """ return deposit logs in format {"total_rows": Total Number of Rows "report": List of dics for the report "total_deposit":Deposit } """ request.needAuthType(request.ADMIN, request.NORMAL_USER, request.VOIP_USER) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester=request.getAuthNameObj() conds=report_lib.fixConditionsDic(request["conds"]) if request.hasAuthType(request.ADMIN): requester.canDo("SEE USER DEPOSIT CHANGES") role="admin" elif request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(request.VOIP_USER): conds["user_ids"]=str(requester.getUserID()) role="user" (conds, LOG_DEBUG) searcher=user_deposit_change_log.UserDepositSearcher(conds, requester, role) deposit_changes = searcher.getDepositChanges(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) if role == "user": deposit_changes = self.__filterCreditChangesForUser(deposit_changes) return deposit_changes
[ویرایش] getVoIPDisconnectCauses
- Code
def getVoIPDisconnectCauses(self, request): return self.__adminConnectionReport(request, "getVoIPDisconnectCauses")
[ویرایش] SessionXMLRPCHandler
[ویرایش] expireSession
- Code
def expireSession(self, request): session_id = request["session_id"] session_main.getSessionManager().expireSession(session_id) return
[ویرایش] getAuthData
return auth data for the current session id<br> @param param: session_id (str)<br> @return: tuple of (auth_name, auth_pass, auth_type)<br>
- Code
def getAuthData(self, request): """ return auth data for the current session id @param param: session_id (str) @return: tuple of (auth_name, auth_pass, auth_type) """ session_id = request["auth_session"] session_obj = session_main.getSessionManager().getSessionObj(session_id) requester_obj = request.getAuthNameObj() if session_obj.getAuthType() == request.ADMIN and \ (not isinstance(requester_obj, Admin) or \ requester_obj.getAdminUsername() != session_obj.getAuthName()): raise GeneralException(errorText("SESSION", "INVALID_SESSION_ID")) elif session_obj.getAuthType() == request.NORMAL_USER and \ (not isinstance(requester_obj, LoadedUser) or \ requester_obj.getUserAttrs()["normal_username"] != session_obj.getAuthName()): raise GeneralException(errorText("SESSION", "INVALID_SESSION_ID")) elif session_obj.getAuthType() == request.VOIP_USER and \ (not isinstance(requester_obj, LoadedUser) or \ requester_obj.getUserAttrs()["voip_username"] != session_obj.getAuthName()): raise GeneralException(errorText("SESSION", "INVALID_SESSION_ID")) return (session_obj.getAuthName(), session_obj.getAuthPass(), session_obj.getAuthType())
[ویرایش] SMSHandler
Array Array
[ویرایش] adminDeleteSMS
Only admins are allowed to delete SMS<br>
- Auth Type
- ADMIN
- Permission
- "SEE USERS SENT SMS"
- Arguments
- "sms_ids"
- Code
def adminDeleteSMS(self,request): """ Only admins are allowed to delete SMS """ request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() requester.canDo("SEE USERS SENT SMS") request.checkArgs("sms_ids") sms_main.getActionsManager().adminDeleteSMS(request.fixList("sms_ids"))
[ویرایش] adminGetSentSMS
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "SEE USERS SENT SMS"
- Code
def adminGetSentSMS(self,request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester=request.getAuthNameObj() requester.canDo("SEE USERS SENT SMS") conds = report_lib.fixConditionsDic(request["conds"]) if sms_main.getDebug(): toLog("adminGetSentSMS, conds: %s"%conds,LOG_DEBUG) searcher = sms_searcher.SMSSearcher(conds, requester, "admin") result = searcher.getSMS(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) return result
[ویرایش] getSMSDefs
getDefs: returns the values of user sms defs attributes<br>
- Auth Type
- NORMAL_USER, request.VOIP_USER
- Code
def getSMSDefs(self, request): """ getDefs: returns the values of user sms defs attributes """ request.needAuthType(request.NORMAL_USER, request.VOIP_USER) if sms_main.getDebug(): toLog("new call to get defs: ", LOG_DEBUG) requester=request.getAuthNameObj() user_id = requester.getUserID() return sms_main.getActionsManager().getSMSDefs(user_id)
[ویرایش] getSentSMS
- Auth Type
- NORMAL_USER, request.VOIP_USER
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Code
def getSentSMS(self,request): request.needAuthType(request.NORMAL_USER, request.VOIP_USER) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester=request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) conds["user_ids"] = str(requester.getUserID()) if sms_main.getDebug(): toLog("getSentSMS, conds: %s"%conds,LOG_DEBUG) searcher = sms_searcher.SMSSearcher(conds, requester, "user") result = searcher.getSMS(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) return result
[ویرایش] sendSMS
Upper level API for Clients<br> sms_body (string): the content of sms<br> phones (MultiString): iterable object of phone strings<br>
- Auth Type
- NORMAL_USER, request.VOIP_USER
- Arguments
- "sms_body", "phones"
- Code
def sendSMS(self, request): """ Upper level API for Clients sms_body (string): the content of sms phones (MultiString): iterable object of phone strings """ request.needAuthType(request.NORMAL_USER, request.VOIP_USER) request.checkArgs("sms_body", "phones") requester=request.getAuthNameObj() user_id = requester.getUserID() self.__checkUserValidity(user_id) phones = map(None,MultiStr(request["phones"])) if sms_main.getDebug(): toLog("new call to send sms: %s %s"%(request["sms_body"],request["phones"]),LOG_DEBUG) sms_main.getActionsManager().sendSMS(user_id, request["sms_body"], phones)
[ویرایش] SnapShotHandler
[ویرایش] getBWSnapShot
- Arguments
- "conds"
- Code
def getBWSnapShot(self, request): request.checkArgs("conds") conds = report_lib.fixConditionsDic(request["conds"]) requester = request.getAuthNameObj() if request.hasAuthType(request.ADMIN): if not conds.has_key("user_id"): request.raiseIncompleteRequest("user_id") user_ids = MultiStr(conds["user_id"]) loaded_users=user_main.getActionManager().getLoadedUsersByUserID(user_ids) for loaded_user in loaded_users: requester.checkAccessToLoadedUser(loaded_user) role = "admin" elif request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(request.VOIP_USER): conds["user_id"] = str(request.getAuthNameObj().getUserID()) role = "user" searcher = snapshot_searcher.SnapShotSearcher(conds, requester, role, "bw") return searcher.getSnapShots()
[ویرایش] getBWSnapShotForNormalUser
- Auth Type
- NORMAL_USER
- Arguments
- "user_id","ras_ip","unique_id_val"
- Code
def getBWSnapShotForNormalUser(self, request): request.needAuthType(request.NORMAL_USER) request.checkArgs("user_id","ras_ip","unique_id_val") return self.__getUserBWValues(to_int(request["user_id"],"user id"), ras_main.getLoader().getRasByIP(request["ras_ip"]).getRasID(), request["unique_id_val"])
[ویرایش] getBWSnapShotForUser
real time version<br>
- Auth Type
- ADMIN
- Arguments
- "user_id","ras_ip","unique_id_val"
- Permission
- "SEE REALTIME SNAPSHOTS"
- Code
def getBWSnapShotForUser(self, request): """ real time version """ request.needAuthType(request.ADMIN) request.checkArgs("user_id","ras_ip","unique_id_val") requester=request.getAuthNameObj() requester.canDo("SEE REALTIME SNAPSHOTS") return self.__getUserBWValues(to_int(request["user_id"],"user id"), ras_main.getLoader().getRasByIP(request["ras_ip"]).getRasID(), request["unique_id_val"])
[ویرایش] getGroupBWSnapShot
- Auth Type
- ADMIN
- Arguments
- "conds"
- Code
def getGroupBWSnapShot(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds") conds = report_lib.fixConditionsDic(request["conds"]) requester = request.getAuthNameObj() if conds.has_key("group_names") and conds["group_names"]: for group_name in conds["group_names"]: requester.checkAccessToGroupByName(group_name) else: raise GeneralException(errorText("SNAPSHOT","GROUP_NOT_SET")) searcher = snapshot_searcher.SnapShotSearcher(conds, requester, "admin", "group_bw") return searcher.getSnapShots()
[ویرایش] getISPBWSnapShot
- Auth Type
- ADMIN
- Arguments
- "conds"
- Code
def getISPBWSnapShot(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds") conds = report_lib.fixConditionsDic(request["conds"]) requester = request.getAuthNameObj() if conds.has_key("isp_names") and conds["isp_names"]: for isp_name in conds["isp_names"]: requester.checkAccessToISP(isp_name) else: raise GeneralException(errorText("SNAPSHOT","ISP_NOT_SET")) searcher = snapshot_searcher.SnapShotSearcher(conds, requester, "admin", "isp_bw") return searcher.getSnapShots()
[ویرایش] getOnlinesSnapShot
- Auth Type
- ADMIN
- Arguments
- "conds","type"
- Permission
- "SEE ONLINE SNAPSHOTS"
- Code
def getOnlinesSnapShot(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds","type") requester=request.getAuthNameObj() requester.canDo("SEE ONLINE SNAPSHOTS") conds = report_lib.fixConditionsDic(request["conds"]) searcher = snapshot_searcher.SnapShotSearcher(conds,requester,"admin",request["type"]) return searcher.getSnapShots()
[ویرایش] getRealTimeSnapShot
- Auth Type
- ADMIN
- Arguments
- "name"
- Permission
- "SEE REALTIME SNAPSHOTS"
- Code
def getRealTimeSnapShot(self, request): request.needAuthType(request.ADMIN) request.checkArgs("name") requester=request.getAuthNameObj() requester.canDo("SEE REALTIME SNAPSHOTS") snapshot=snapshot_main.getRealTimeManager().getSnapShot(request["name"]) values = self.__fixRealTimeSnapShotValues(requester, snapshot.getValues(), request["name"]) return (snapshot.getDates(), values)
[ویرایش] StatHandler
[ویرایش] getStatistics
- Auth Type
- ADMIN
- Permission
- "GOD"
- Code
def getStatistics(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("GOD") stat_dic = stat_main.getStatKeeper().getStats() sorted_dic=SortedDic(stat_dic) sorted_dic.sortByKey(False) return sorted_dic.getList()
[ویرایش] TelephonySupportHandler
[ویرایش] authenticate
Authenticates user.<br> auth_by(str): one of user_id, serial, voip_username and internet_username. depicts authentication method<br> auth_id(str): value for entity of "auth_by"<br> Returns (user_id, credit)<br>
- Auth Type
- ADMIN
- Arguments
- "auth_by", "auth_id"
- Permission
- "TELEPHONY SUPPORT"
- Code
def authenticate(self, request): """ Authenticates user. auth_by(str): one of user_id, serial, voip_username and internet_username. depicts authentication method auth_id(str): value for entity of "auth_by" Returns (user_id, credit) """ request.needAuthType(request.ADMIN) request.checkArgs("auth_by", "auth_id") requester=request.getAuthNameObj() requester.canDo("TELEPHONY SUPPORT") auth_id = request["auth_id"] auth_by = request["auth_by"] auth_by_mapping = {"user_id":lambda auth_id:user_main.getUserPool().getUserByID(auth_id), "serial":lambda auth_id:user_main.getUserPool().getUserBySerial(auth_id), "voip_username":lambda auth_id:user_main.getUserPool().getUserByVoIPUsername(auth_id), "internet_username":lambda auth_id:user_main.getUserPool().getUserByNormalUsername(auth_id)} try: auth_by_getter = auth_by_mapping[ auth_by ] except KeyError: toLog("TelephonySupport: Received invalid authentication by method %s"%auth_by, LOG_ERROR) raise GeneralException(errorText("TELEPHONY_SUPPORT", "INVALID_AUTH_BY")%auth_by) loaded_user = auth_by_getter(auth_id) return (loaded_user.getUserID(), loaded_user.getCredit())
[ویرایش] callerIDAuthenticate
Authenticates user via caller id. Returns (user_id, credit, preferred_language) on success and raise an exception on error<br>
- Auth Type
- ADMIN
- Arguments
- "caller_id"
- Permission
- "TELEPHONY SUPPORT"
- Code
def callerIDAuthenticate(self, request): """ Authenticates user via caller id. Returns (user_id, credit, preferred_language) on success and raise an exception on error """ request.needAuthType(request.ADMIN) request.checkArgs("caller_id") requester=request.getAuthNameObj() requester.canDo("TELEPHONY SUPPORT") loaded_user = user_main.getUserPool().getUserByCallerID(request["caller_id"]) language = "" if loaded_user.getUserAttrs().hasAttr("voip_preferred_language"): language = loaded_user.getUserAttrs()["voip_preferred_language"] return (loaded_user.getUserID(), loaded_user.getCredit(), language)
[ویرایش] changeInternetPassword
change internet password<br>
- Auth Type
- ADMIN
- Arguments
- "user_id", "new_internet_password"
- Permission
- "TELEPHONY SUPPORT"
- Code
def changeInternetPassword(self, request): """ change internet password """ request.needAuthType(request.ADMIN) request.checkArgs("user_id", "new_internet_password") requester=request.getAuthNameObj() requester.canDo("TELEPHONY SUPPORT") loaded_user = user_main.getUserPool().getUserByID(request["user_id"]) normal_username = loaded_user.getUserAttrs()["normal_username"] user_main.getActionManager().updateUserAttrs([loaded_user], admin_main.getAdminLoader().getAdminByID(0), {"normal_user_spec":{"normal_username":normal_username, "normal_password":request["new_internet_password"]}}, []) return True
[ویرایش] checkInternetPassword
Check internet password<br>
- Auth Type
- ADMIN
- Arguments
- "user_id", "internet_password"
- Permission
- "TELEPHONY SUPPORT"
- Code
def checkInternetPassword(self, request): """ Check internet password """ request.needAuthType(request.ADMIN) request.checkArgs("user_id", "internet_password") requester=request.getAuthNameObj() requester.canDo("TELEPHONY SUPPORT") loaded_user = user_main.getUserPool().getUserByID(request["user_id"]) internet_password = loaded_user.getUserAttrs()["normal_password"] return password_lib.Password(internet_password) == request["internet_password"]
[ویرایش] getCurrentCredit
Returns user's current credit<br>
- Auth Type
- ADMIN
- Arguments
- "user_id"
- Permission
- "TELEPHONY SUPPORT"
- Code
def getCurrentCredit(self, request): """ Returns user's current credit """ request.needAuthType(request.ADMIN) request.checkArgs("user_id") requester=request.getAuthNameObj() requester.canDo("TELEPHONY SUPPORT") loaded_user = user_main.getUserPool().getUserByID(request["user_id"]) return loaded_user.getCredit()
[ویرایش] getFailureReason
Returns a dialer style error code, that shows why user currently can't login.<br> Returns 0 if not failure reason could be found<br>
- Auth Type
- ADMIN
- Arguments
- "user_id"
- Permission
- "TELEPHONY SUPPORT"
- Code
def getFailureReason(self, request): """ Returns a dialer style error code, that shows why user currently can't login. Returns 0 if not failure reason could be found """ request.needAuthType(request.ADMIN) request.checkArgs("user_id") requester=request.getAuthNameObj() requester.canDo("TELEPHONY SUPPORT") loaded_user = user_main.getUserPool().getUserByID(request["user_id"]) if loaded_user.getCredit()<=0: return DialerErrors.errors["CREDIT_FINISHED"] nearest_exp_epoch = user_main.getUserPluginModules()["nearest_exp"].getNearestEXPDate(loaded_user) if nearest_exp_epoch and nearest_exp_epoch < time.time(): return DialerErrors.errors["ABS_EXP_DATE_REACHED"] if loaded_user.getUserAttrs().userHasAttr("lock"): return DialerErrors.errors["USER_LOCKED"] quota_type_error_mapping = {"time":"TIMELY_QUOTA_EXCEEDED", "traffic":"TRAFFIC_QUOTA_EXCEEDED"} for quota_type in ["time", "traffic"]: for period in ["daily", "monthly"]: base_attr_name = "%s_periodic_accounting_%s"%(quota_type, period) limit_attr_name = "%s_limit"%base_attr_name usage_attr_name = "%s_usage"%base_attr_name if loaded_user.getUserAttrs().hasAttr(limit_attr_name) and loaded_user.getUserAttrs().userHasAttr(usage_attr_name): if long(loaded_user.getUserAttrs()[limit_attr_name]) <= long(loaded_user.getUserAttrs()[usage_attr_name]): error_key = quota_type_error_mapping[quota_type] return DialerErrors.errors[error_key] return 0
[ویرایش] getLastConnection
Returns (date, duration, credit_used, successful)<br> Returns an empty list if no connection log found<br>
- Auth Type
- ADMIN
- Arguments
- "user_id"
- Permission
- "TELEPHONY SUPPORT"
- Code
def getLastConnection(self, request): """ Returns (date, duration, credit_used, successful) Returns an empty list if no connection log found """ request.needAuthType(request.ADMIN) request.checkArgs("user_id") requester=request.getAuthNameObj() requester.canDo("TELEPHONY SUPPORT") loaded_user = user_main.getUserPool().getUserByID(request["user_id"]) connection_dict = user_main.getActionManager().getLastUserConnection(loaded_user.getUserID()) if connection_dict: return (connection_dict["login_time"], connection_dict["duration_seconds"], connection_dict["credit_used"], connection_dict["successful"]=="t") else: return ()
[ویرایش] getNearestExpDate
Returns user's nearest exp date. Returns empty string if no exp date found<br>
- Auth Type
- ADMIN
- Arguments
- "user_id"
- Permission
- "TELEPHONY SUPPORT"
- Code
def getNearestExpDate(self, request): """ Returns user's nearest exp date. Returns empty string if no exp date found """ request.needAuthType(request.ADMIN) request.checkArgs("user_id") requester=request.getAuthNameObj() requester.canDo("TELEPHONY SUPPORT") loaded_user = user_main.getUserPool().getUserByID(request["user_id"]) nearest_exp_epoch = user_main.getUserPluginModules()["nearest_exp"].getNearestEXPDate(loaded_user) if nearest_exp_epoch is not None: return AbsDateFromEpoch(nearest_exp_epoch).getDate(request.getDateType()) return ""
[ویرایش] getRemainingByteDuration
Returns user status , user's remaining bytes and durations<br>
- Auth Type
- ADMIN
- Arguments
- "user_id"
- Permission
- "TELEPHONY SUPPORT"
- Code
def getRemainingByteDuration(self, request): """ Returns user status , user's remaining bytes and durations """ request.needAuthType(request.ADMIN) request.checkArgs("user_id") requester=request.getAuthNameObj() requester.canDo("TELEPHONY SUPPORT") loaded_user = user_main.getUserPool().getUserByID(request["user_id"]) return loaded_user.getBasicUser().getStatus(), user_main.getActionManager().calcRemainingDurationAndBytes(loaded_user)
[ویرایش] recharge
Recharges "user_id" by credit in "pin"<br>
- Auth Type
- ADMIN
- Arguments
- "user_id", "pin"
- Permission
- "TELEPHONY SUPPORT"
- Code
def recharge(self, request): """ Recharges "user_id" by credit in "pin" """ request.needAuthType(request.ADMIN) request.checkArgs("user_id", "pin") requester=request.getAuthNameObj() requester.canDo("TELEPHONY SUPPORT") return voucher_main.getActions().rechargeUser(to_int(request["user_id"], "User ID"), request["pin"], requester.getAdminID(), "admin")
[ویرایش] UserHandler
[ویرایش] addNewUsers
Add "count" number of raw users. Created users has no attribute assigned to them.<br> Later you should assign attribute by updateUserAttrs<br> return a list of created user_id s<br>
- Auth Type
- ADMIN
- Arguments
- "count", "credit", "isp_name", "group_name", "credit_comment"
- Permission
- "ADD NEW USER"
- Code
def addNewUsers(self, request): """ Add "count" number of raw users. Created users has no attribute assigned to them. Later you should assign attribute by updateUserAttrs return a list of created user_id s """ request.needAuthType(request.ADMIN) request.checkArgs("count", "credit", "isp_name", "group_name", "credit_comment") requester=request.getAuthNameObj() requester.canDo("ADD NEW USER") requester.checkAccessToISP(request["isp_name"]) try: _count=int(request["count"]) except ValueError: raise GeneralException(errorText("USER_ACTIONS", "COUNT_NOT_INTEGER")) try: credit=float(request["credit"]) except ValueError: raise GeneralException(errorText("USER_ACTIONS", "CREDIT_NOT_FLOAT")) requester.checkAccessToGroupByName(request["group_name"]) group_obj = group_main.getLoader().getGroupByName(request["group_name"]) if not group_obj.hasAttr("group_credit") or float(group_obj.getAttr("group_credit")) != credit: if not requester.isGod() and not requester.hasPerm("CHANGE USER CREDIT"): raise PermissionException(errorText("PERMISSION","DONT_HAVE_PERMISSION")) return user_main.getActionManager().addNewUsers(_count, credit, request["isp_name"], requester.getAdminUsername(), request["group_name"], request.getRemoteAddr(), request["credit_comment"])
[ویرایش] changeCredit
change credit of user<br> user_id(str): string in format of MultiStr, containing user ids<br> credit(float): amount of credit change<br> is_absolute_change(boolean): if set to true, credit will be set to "credit" amount \<br> otherwise "credit" is added to current amount<br> credit_comment(str):<br>
- Auth Type
- ADMIN
- Arguments
- "user_id", "credit", "is_absolute_change", "credit_comment"
- Permission
- "CHANGE USER CREDIT", loaded_users
- Code
def changeCredit(self, request): """ change credit of user user_id(str): string in format of MultiStr, containing user ids credit(float): amount of credit change is_absolute_change(boolean): if set to true, credit will be set to "credit" amount \ otherwise "credit" is added to current amount credit_comment(str): """ request.needAuthType(request.ADMIN) request.checkArgs("user_id", "credit", "is_absolute_change", "credit_comment") requester=request.getAuthNameObj() user_id_multi=MultiStr(request["user_id"]) loaded_users=user_main.getActionManager().getLoadedUsersByUserID(user_id_multi) requester.canDo("CHANGE USER CREDIT", loaded_users) return user_main.getActionManager().changeCredit(user_id_multi, to_float(request["credit"], "credit"), request["is_absolute_change"] == True, requester.getISPObj().getISPID(), requester.getAdminID(), request.getRemoteAddr(), request["credit_comment"])
[ویرایش] changeCreditExtended
change credit of user extended version<br> user_id(str): string in format of MultiStr, containing user ids<br> credit(float): amount of credit change<br> change_type(string): can be ADD, SET, MILTIPLY<br> credit_comment(str):<br>
- Auth Type
- ADMIN
- Arguments
- "user_id", "credit", "change_type", "credit_comment"
- Permission
- "CHANGE USER CREDIT", loaded_users
- Code
def changeCreditExtended(self, request): """ change credit of user extended version user_id(str): string in format of MultiStr, containing user ids credit(float): amount of credit change change_type(string): can be ADD, SET, MILTIPLY credit_comment(str): """ request.needAuthType(request.ADMIN) request.checkArgs("user_id", "credit", "change_type", "credit_comment") requester=request.getAuthNameObj() user_id_multi=MultiStr(request["user_id"]) loaded_users=user_main.getActionManager().getLoadedUsersByUserID(user_id_multi) requester.canDo("CHANGE USER CREDIT", loaded_users) return user_main.getActionManager().changeCreditExtended(user_id_multi, to_float(request["credit"], "credit"), request["change_type"], requester.getISPObj().getISPID(), requester.getAdminID(), request.getRemoteAddr(), request["credit_comment"])
[ویرایش] changeDeposit
change deposit of user<br> user_id(str): string in format of MultiStr, containing user ids<br> deposit(float): amount of deposit change<br> is_absolute_change(boolean): if set to true, deposit will be set to "deposit" amount \<br> otherwise "deposit" is added to current amount<br> deposit_comment(str):<br>
- Auth Type
- ADMIN
- Arguments
- "user_id", "deposit", "is_absolute_change", "deposit_comment"
- Permission
- "CHANGE USER DEPOSIT", loaded_users
- Code
def changeDeposit(self, request): """ change deposit of user user_id(str): string in format of MultiStr, containing user ids deposit(float): amount of deposit change is_absolute_change(boolean): if set to true, deposit will be set to "deposit" amount \ otherwise "deposit" is added to current amount deposit_comment(str): """ request.needAuthType(request.ADMIN) request.checkArgs("user_id", "deposit", "is_absolute_change", "deposit_comment") requester=request.getAuthNameObj() user_id_multi=MultiStr(request["user_id"]) loaded_users=user_main.getActionManager().getLoadedUsersByUserID(user_id_multi) requester.canDo("CHANGE USER DEPOSIT", loaded_users) return user_main.getActionManager().changeDeposit(user_id_multi, to_float(request["deposit"], "deposit"), request["is_absolute_change"] == True, requester.getISPObj().getISPID(), requester.getAdminID(), request.getRemoteAddr(), request["deposit_comment"])
[ویرایش] changeDepositExtended
change deposit of user extended version<br> user_id(str): string in format of MultiStr, containing user ids<br> deposit(float): amount of deposit change<br> is_absolute_change(boolean): if set to true, deposit will be set to "deposit" amount \<br> otherwise "deposit" is added to current amount<br> deposit_comment(str):<br>
- Auth Type
- ADMIN
- Arguments
- "user_id", "deposit", "change_type", "deposit_comment"
- Permission
- "CHANGE USER DEPOSIT", loaded_users
- Code
def changeDepositExtended(self, request): """ change deposit of user extended version user_id(str): string in format of MultiStr, containing user ids deposit(float): amount of deposit change is_absolute_change(boolean): if set to true, deposit will be set to "deposit" amount \ otherwise "deposit" is added to current amount deposit_comment(str): """ request.needAuthType(request.ADMIN) request.checkArgs("user_id", "deposit", "change_type", "deposit_comment") requester=request.getAuthNameObj() user_id_multi=MultiStr(request["user_id"]) loaded_users=user_main.getActionManager().getLoadedUsersByUserID(user_id_multi) requester.canDo("CHANGE USER DEPOSIT", loaded_users) return user_main.getActionManager().changeDepositExtended(user_id_multi, to_float(request["deposit"], "deposit"), request["change_type"], requester.getISPObj().getISPID(), requester.getAdminID(), request.getRemoteAddr(), request["deposit_comment"])
[ویرایش] getUserInfo
return user information in a list of dics in format<br> [{"basic_info":{basic_user_info},"attrs":{user_attributes}},{"basic_info":{basic_user_info},"attrs":{user_attributes}},...]<br> basic_user_info and user_attributes are dictionaries contain name=>values<br> if requester is admin, he can specify user_id or normal_username or voip_username. All can be multistrings<br> if requirter is user, no argument will be parsed and auth_name is used<br>
- Permission
- "GET USER INFORMATION", loaded_users
- Code
def getUserInfo(self, request): """ return user information in a list of dics in format [{"basic_info":{basic_user_info},"attrs":{user_attributes}},{"basic_info":{basic_user_info},"attrs":{user_attributes}},...] basic_user_info and user_attributes are dictionaries contain name=>values if requester is admin, he can specify user_id or normal_username or voip_username. All can be multistrings if requirter is user, no argument will be parsed and auth_name is used """ if request.hasAuthType(request.ADMIN): if request.has_key("user_id"): loaded_users=user_main.getActionManager().getLoadedUsersByUserID(MultiStr(request["user_id"])) elif request.has_key("normal_username"): loaded_users=user_main.getActionManager().getLoadedUsersByNormalUsername(MultiStr(request["normal_username"])) elif request.has_key("voip_username"): loaded_users=user_main.getActionManager().getLoadedUsersByVoIPUsername(MultiStr(request["voip_username"])) elif request.has_key("serial"): loaded_users=user_main.getActionManager().getLoadedUsersBySerial(request["serial"]) else: raise request.raiseIncompleteRequest("user_id") admin_obj = request.getAuthNameObj() admin_obj.canDo("GET USER INFORMATION", loaded_users) elif request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(request.VOIP_USER): loaded_users=[request.getAuthNameObj()] else: raise request.raiseIncompleteRequest("auth_type") user_infos = user_main.getActionManager().getUserInfosFromLoadedUsers(loaded_users, request.getDateType()) if request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(request.VOIP_USER): user_info = self.__filterAttrsForUser(user_infos.values()[0]) return self.__addGroupAttrsForUser(user_info, request.getDateType()) return user_infos
[ویرایش] searchUser
return (count_of_result,total_credit,user_id_lists)<br>
- Code
def searchUser(self, request): """ return (count_of_result,total_credit,user_id_lists)
[ویرایش] updateUserAttrs
update user attributes<br> user_id(string): user ids that should be updated, can be multi strings<br> attrs(dic): dictionary of attr_name:attr_value. We say we want attr_name value to be attr_value<br> to_del_attrs(list): list of attributes that should be deleted<br>
- Auth Type
- ADMIN
- Arguments
- "user_id", "attrs", "to_del_attrs"
- Permission
- "CHANGE USER ATTRIBUTES", loaded_users
- Code
def updateUserAttrs(self, request): """ update user attributes user_id(string): user ids that should be updated, can be multi strings attrs(dic): dictionary of attr_name:attr_value. We say we want attr_name value to be attr_value to_del_attrs(list): list of attributes that should be deleted """ request.needAuthType(request.ADMIN) request.checkArgs("user_id", "attrs", "to_del_attrs") loaded_users = user_main.getActionManager().getLoadedUsersByUserID(MultiStr(request["user_id"])) admin_obj = request.getAuthNameObj() admin_obj.canDo("CHANGE USER ATTRIBUTES", loaded_users) remote_ip = request.getRemoteAddr() to_del_attrs=requestDicToList(request["to_del_attrs"]) return user_main.getActionManager().updateUserAttrs(loaded_users, request.getAuthNameObj(), request["attrs"], to_del_attrs, remote_ip)
[ویرایش] UserCustomFieldHandler
[ویرایش] addNewCustomField
add a new user custom field<br> name(str): the name used for custom field id. name is used for internal user attribute recognition and should follow naming standards<br> description(str): the description that will be shown in user information page<br> comment(str): arbitrary comment<br> value_type(str): The type of value for this field. ex. integer, text.<br> interface_type(str): Form of dialg for editing field. ex. text_field, checkbox, radio_button<br> allowable_values(list): list of allowable values for this field. Empty allowable values for text_field means all values<br>
- Auth Type
- ADMIN
- Arguments
- "name", "description", "comment", "value_type", "interface_type", "allowable_values"
- Permission
- "CHANGE USER CUSTOM FIELDS"
- Code
def addNewCustomField(self, request): """ add a new user custom field name(str): the name used for custom field id. name is used for internal user attribute recognition and should follow naming standards description(str): the description that will be shown in user information page comment(str): arbitrary comment value_type(str): The type of value for this field. ex. integer, text. interface_type(str): Form of dialg for editing field. ex. text_field, checkbox, radio_button allowable_values(list): list of allowable values for this field. Empty allowable values for text_field means all values """ request.needAuthType(request.ADMIN) request.checkArgs("name", "description", "comment", "value_type", "interface_type", "allowable_values") requester=request.getAuthNameObj() requester.canDo("CHANGE USER CUSTOM FIELDS") return user_custom_field_main.getActions().addNewCustomField(request["name"], request["description"], request["comment"], request["value_type"], request["interface_type"], request["allowable_values"])
[ویرایش] deleteCustomField
delete a user custom field<br> name(str): the name used for custom field<br>
- Auth Type
- ADMIN
- Arguments
- "name"
- Permission
- "CHANGE USER CUSTOM FIELDS"
- Code
def deleteCustomField(self, request): """ delete a user custom field name(str): the name used for custom field """ request.needAuthType(request.ADMIN) request.checkArgs("name") requester=request.getAuthNameObj() requester.canDo("CHANGE USER CUSTOM FIELDS") return user_custom_field_main.getActions().deleteCustomField(request["name"])
[ویرایش] getAllCustomFields
Returns a dictionary in format <br> {custom_field_name =>{custom_field_id:, name:, description:, comment:, value_type:, interface_type:,allowable_values:}<br>
- Auth Type
- ADMIN
- Code
def getAllCustomFields(self, request): """ Returns a dictionary in format {custom_field_name =>{custom_field_id:, name:, description:, comment:, value_type:, interface_type:,allowable_values:} """ request.needAuthType(request.ADMIN) requester=request.getAuthNameObj() custom_field_info = {} custom_field_objs = user_custom_field_main.getLoader().getAllCustomFieldObjs() for custom_field_obj in custom_field_objs: custom_field_info[custom_field_obj.getCustomFieldName()] = custom_field_obj.getInfo() return custom_field_info
[ویرایش] updateCustomField
update a user custom field<br> custom_field_id(int): ID of custom field<br> name(str): the name used for custom field id. name is used for internal user attribute recognition and should follow naming standards<br> description(str): the description that will be shown in user information page<br> comment(str): arbitrary comment<br> value_type(str): The type of value for this field. ex. integer, text.<br> interface_type(str): Form of dialg for editing field. ex. text_field, checkbox, radio_button<br> allowable_values(list): list of allowable values for this field. Empty allowable values for text_field means all values<br>
- Auth Type
- ADMIN
- Arguments
- "custom_field_id", "name", "description", "comment", "value_type", "interface_type", "allowable_values"
- Permission
- "CHANGE USER CUSTOM FIELDS"
- Code
def updateCustomField(self, request): """ update a user custom field custom_field_id(int): ID of custom field name(str): the name used for custom field id. name is used for internal user attribute recognition and should follow naming standards description(str): the description that will be shown in user information page comment(str): arbitrary comment value_type(str): The type of value for this field. ex. integer, text. interface_type(str): Form of dialg for editing field. ex. text_field, checkbox, radio_button allowable_values(list): list of allowable values for this field. Empty allowable values for text_field means all values """ request.needAuthType(request.ADMIN) request.checkArgs("custom_field_id", "name", "description", "comment", "value_type", "interface_type", "allowable_values") requester=request.getAuthNameObj() requester.canDo("CHANGE USER CUSTOM FIELDS") return user_custom_field_main.getActions().updateCustomField(to_int(request["custom_field_id"], "Custom Field ID"), request["name"], request["description"], request["comment"], request["value_type"], request["interface_type"], request["allowable_values"])
[ویرایش] UtilHandler
[ویرایش] afeChangeUserCredit
- Auth Type
- ADMIN
- Arguments
- "username","amount","comment"
- Permission
- "AFE REMOTE ADMIN"
- Code
def afeChangeUserCredit(self,request): request.needAuthType(request.ADMIN) request.checkArgs("username","amount","comment") requester = request.getAuthNameObj() requester.canDo("AFE REMOTE ADMIN") if not len(request["comment"]): comment = "Change for SMS Box - Asre Fara Ertebat" else: comment = request["comment"] loaded_user = user_main.getActionManager().getLoadedUsersByNormalUsername([request["username"]])[0] user_main.getActionManager().changeCredit([loaded_user.getUserID()], float(request["amount"]), False, loaded_user.getBasicUser().getISPID(), requester.getAdminID(), request.getRemoteAddr(), comment)
[ویرایش] afeGetAllGroups
- Auth Type
- ADMIN
- Permission
- "AFE REMOTE ADMIN"
- Code
def afeGetAllGroups(self,request): request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() requester.canDo("AFE REMOTE ADMIN") return group_main.getLoader().getAllGroupNames()
[ویرایش] afeGetUserInfo
- Auth Type
- ADMIN
- Arguments
- "username"
- Permission
- "AFE REMOTE ADMIN"
- Code
def afeGetUserInfo(self,request): request.needAuthType(request.ADMIN) request.checkArgs("username") requester = request.getAuthNameObj() requester.canDo("AFE REMOTE ADMIN") user_id = user_main.getUserLoader().normalUsername2UserID(request["username"]) loaded_user = user_main.getUserLoader().getLoadedUserByUserIDs([user_id])[0] user_info = loaded_user.getUserInfo("gregorian") group_obj = group_main.getLoader().getGroupByID(user_info["basic_info"]["group_id"]) return {"password":user_info["attrs"]["normal_password"], "group":group_obj.getGroupName(), "credit":user_info["basic_info"]["credit"]}
[ویرایش] createSessionForFailedUserByIP
Creates a core session and returns it, for failed user that's calling this handler<br> Raises an exception if no such user found<br>
- Code
def createSessionForFailedUserByIP(self, request): """ Creates a core session and returns it, for failed user that's calling this handler Raises an exception if no such user found """ request_ip = request.getRemoteAddr() session_id = "" instance_obj = user_main.getOnline().getOnlineUserInstanceByUserIP(request_ip) if instance_obj is not None: if instance_obj.isInternet() and instance_obj["attrs"].has_key("failed_username"): try: loaded_user = user_main.getUserPool().getUserByNormalUsername(instance_obj["attrs"]["failed_username"]) except UserNotFoundException: pass else: username = loaded_user.getUserAttrs()["normal_username"] password = loaded_user.getUserAttrs()["normal_password"] auth_type = Request.NORMAL_USER remote_ip = request_ip session_id = session_main.getSessionManager().generateSession(username, password, auth_type, remote_ip) if session_id: return session_id else: raise GeneralException(errorText("SESSION","SESSION_NOT_FOUND"))
[ویرایش] createSessionForUserByIP
Creates a core session and returns it, for user that's calling this handler<br> Raises an exception if no such user found<br>
- Code
def createSessionForUserByIP(self, request): """ Creates a core session and returns it, for user that's calling this handler Raises an exception if no such user found """ request_ip = request.getRemoteAddr() session_id = "" instance_obj = user_main.getOnline().getOnlineUserInstanceByUserIP(request_ip) if instance_obj is not None: if instance_obj.isInternet(): loaded_user = instance_obj.getUserObj().getLoadedUser() username = loaded_user.getUserAttrs()["normal_username"] password = loaded_user.getUserAttrs()["normal_password"] auth_type = Request.NORMAL_USER remote_ip = request_ip session_id = session_main.getSessionManager().generateSession(username, password, auth_type, remote_ip) if session_id: return session_id else: raise GeneralException(errorText("SESSION","SESSION_NOT_FOUND"))
[ویرایش] echo
- Auth Type
- ADMIN
- Arguments
- "echo"
- Permission
- "GOD"
- Code
def echo(self, request): request.needAuthType(request.ADMIN) request.checkArgs("echo") requester = request.getAuthNameObj() requester.canDo("GOD") return request["echo"]
[ویرایش] getErrorForFailedUser
Returns tuple of error_key, error_description, for failed user that is calling this handler<br> Raises an error if session for user is not found<br>
- Code
def getErrorForFailedUser(self, request): """ Returns tuple of error_key, error_description, for failed user that is calling this handler Raises an error if session for user is not found """ request_ip = request.getRemoteAddr() instance_obj = user_main.getOnline().getOnlineUserInstanceByUserIP(request_ip) error_key = error_description = "" if instance_obj is not None: auth_ras_msg = instance_obj["auth_ras_msg"] if auth_ras_msg.hasAttr("error_key"): error_key = auth_ras_msg["error_key"] error_description = auth_ras_msg["error_description"] if not error_key: raise GeneralException(errorText("SESSION","SESSION_NOT_FOUND")) return error_key, error_description
[ویرایش] getISPsPageStyleRevision
- Code
def getISPsPageStyleRevision(self, request): try: return int(ibs_states.State("ISP_PAGE_STYLE_REVISION").getCurVal()) except GeneralException: return 0
[ویرایش] getNow
Return Formatted date of now<br>
- Code
def getNow(self, request): """ Return Formatted date of now """ return AbsDateFromEpoch(time.time()).getDate(request.getDateType())
[ویرایش] getSessionISPID
- Code
def getSessionISPID(self, request): if request.hasAuthType(request.ADMIN): return request.getAuthNameObj().getISPObj().getISPID() elif request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(request.VOIP_USER): return request.getAuthNameObj().getBasicUser().getISPObj().getISPID() else: return admin_main.getISPLoader().getISPIDOfWebDomain(request["web_domain"])
[ویرایش] getSessionPageStyle
- Code
def getSessionPageStyle(self, request): isp_id = self.getSessionISPID(request) target_isp_obj = admin_main.getISPLoader().getISPByID(isp_id) page_style = { "header_logo_ext" :"", "header_logo_contents" :"", "header_bg_color" :"", "header_text_color" :"", "footer_logo_ext" :"", "footer_logo_contents" :"", "footer_bg_color" :"", "footer_text_color" :"", "footer_msg" :"" } for isp_obj in [ target_isp_obj ] + target_isp_obj.getAllParentISPObjs(): page_style_tmp = admin_main.getISPLoader().getISPPageStyleByISPID(isp_obj.getISPID()) if page_style_tmp: for style_name in page_style: value = page_style_tmp[style_name] if value and not page_style[style_name]: page_style[style_name] = value if "" not in page_style.itervalues(): break page_style["is_root"] = target_isp_obj.isRootISP() return page_style
[ویرایش] getStartOfMonth
Return date, for start of this month<br>
- Code
def getStartOfMonth(self, request): """ Return date, for start of this month """ if request.getDateType() == "jalali": epoch = getJalaliNextMonthEpoch(0, 1, 0) else: epoch = getGregorianNextMonthEpoch(0, 1, 0) return AbsDateFromEpoch(epoch).getDate(request.getDateType())
[ویرایش] getUsernameForIP
Returns username of online user, that has remote ip "ip"<br>
- Auth Type
- ADMIN
- Arguments
- "ip"
- Permission
- "SEE ONLINE USERS"
- Code
def getUsernameForIP(self, request): """ Returns username of online user, that has remote ip "ip" """ request.needAuthType(request.ADMIN) request.checkArgs("ip") requester = request.getAuthNameObj() requester.canDo("SEE ONLINE USERS") user_id = user_main.getIPMap().getUserIDForIP(request["ip"]) if user_id != None: loaded_user = user_main.getUserPool().getUserByID(user_id) return loaded_user.getUserAttrs()["normal_username"] return "No User Found"
[ویرایش] kickFailedUserByIP
Force disconnect a failed user by using his IP address<br>
- Code
def kickFailedUserByIP(self, request): """ Force disconnect a failed user by using his IP address """ request_ip = request.getRemoteAddr() instance_obj = user_main.getOnline().getOnlineUserInstanceByUserIP(request_ip) if instance_obj is not None: if instance_obj.isInternet() and instance_obj["attrs"].has_key("failed_username"): user_main.getOnline().killUser(instance_obj.getUserObj().getUserID(), instance_obj.getRasID(), instance_obj.getUniqueID(), "Failed user disconnected") return True return False
[ویرایش] multiStrGetAll
- Arguments
- "str","left_pad"
- Code
def multiStrGetAll(self,request): request.checkArgs("str","left_pad") return map(None, MultiStr(request["str"],request["left_pad"]))
[ویرایش] otrsAuth
- Arguments
- "otrs_username","otrs_password","otrs_user_type"
- Code
def otrsAuth(self, request): if config.getConfig().getboolean("GENERAL", "otrs_enabled", False): raise GeneralException(errorText("GENERAL","OTRS_DISABLED")) request.checkArgs("otrs_username","otrs_password","otrs_user_type"); info = {} username = str(request["otrs_username"]) password = str(request["otrs_password"]) if request["otrs_user_type"] == "ADMIN": admin_obj = admin_main.getAdminLoader().getAdminByName(username) admin_obj.checkServerAuth( password, request.getRemoteAddr() ) isp_name = admin_main.getISPLoader().getISPByID( admin_obj.getISPID() ).getISPName() info["user_id"] = admin_obj.getAdminID() info["isp_name"] = isp_name name = admin_obj.getAdminName() if name: info["name"] = name else: info["name"] = admin_obj.getAdminUsername() email = admin_obj.getEmail() if email: info["email"] = email else: info["email"] = admin_obj.getAdminUsername()+"@localhost.com" else: loaded_user = user_main.getServerAuth().checkAuth( username, password, "NORMAL_USER" ) info["user_id"] = loaded_user.getUserID() info["isp_name"] = admin_main.getISPLoader().getISPByID( loaded_user.getBasicUser().getISPID() ).getISPName() if loaded_user.userHasAttr("name"): info["name"] = loaded_user.getUserAttrs()["name"] else: info["name"] = username if loaded_user.userHasAttr("email"): info["email"] = loaded_user.getUserAttrs()["email"] else: info["email"] = username+"@localhost.com" return {"user_info":info}
[ویرایش] runDebugCode
- Auth Type
- ADMIN
- Arguments
- "command"
- Code
def runDebugCode(self,request): request.needAuthType(request.ADMIN) request.checkArgs("command") requester=request.getAuthNameObj() if not requester.isGod(): return "Access Denied" if request.has_key("no_output"): self.__execCode(request) return True else: return self.__grabOutput(request)
[ویرایش] VoIPProviderHandler
[ویرایش] listRoutingProfiles
- Auth Type
- ADMIN
- Permission
- "SEE VOIP PROVIDER"
- Code
def listRoutingProfiles(self, request): request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() requester.canDo("SEE VOIP PROVIDER") return voip_provider_main.getActions().getListOfVoIPRoutingProfileNames(requester)
[ویرایش] listVoIPProviders
- Auth Type
- ADMIN
- Permission
- "SEE VOIP PROVIDER"
- Code
def listVoIPProviders(self, request): request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() requester.canDo("SEE VOIP PROVIDER") return voip_provider_main.getActions().getListOfVoIPProviderNames(requester)
[ویرایش] VoucherXMLRPCHandler
[ویرایش] getBatchVoucherAttrs
returns the attributes of both voucher and batch obj with voucher_pin as in request["voucher_pin"]<br>
- Auth Type
- ADMIN, request.VOIP_USER, request.NORMAL_USER
- Arguments
- "voucher_pin"
- Permission
- "SEE VOUCHERS"
- Code
def getBatchVoucherAttrs(self, request): """ returns the attributes of both voucher and batch obj with voucher_pin as in request["voucher_pin"] """ request.needAuthType(request.ADMIN, request.VOIP_USER, request.NORMAL_USER) request.checkArgs("voucher_pin") requester = request.getAuthNameObj() if request.hasAuthType(request.ADMIN): requester.canDo("SEE VOUCHERS") role = "admin" else: self.__checkUserAccessToVoucher(requester) role = "user" voucher_dict = voucher_main.getActions().getBatchVoucherAttrs(request["voucher_pin"], role) for key in ["voucher_used_date", "voucher_serial"]: value = voucher_dict[key] if value is None: voucher_dict[key] = "" return voucher_dict
[ویرایش] searchBatch
return batches, based on request["conds"] conditions<br> return value is a dic in format {"total_rows":,"report":[]}<br>
- Auth Type
- ADMIN
- Auth Type
- ADMIN, request.VOIP_USER, request.NORMAL_USER
- Arguments
- "conds", "index_from", "index_to", "sort_by", "desc"
- Permission
- "SEE VOUCHERS"
- Code
def searchBatch(self, request): """ return batches, based on request["conds"] conditions return value is a dic in format {"total_rows":,"report":[]} """ request.needAuthType(request.ADMIN) request.needAuthType(request.ADMIN, request.VOIP_USER, request.NORMAL_USER) request.checkArgs("conds", "index_from", "index_to", "sort_by", "desc") requester = request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) requester.canDo("SEE VOUCHERS") role = "admin" searcher = batch_searcher.BatchSearcher(conds, requester, role) batch_results = searcher.getBatches(request["index_from"], request["index_to"], request["sort_by"], request["desc"], request.getDateType()) return batch_results
[ویرایش] searchVoucher
return vouchers, based on request["conds"] conditions<br> return value is a dic in format {"total_rows":,"report":[]}<br>
- Auth Type
- ADMIN
- Auth Type
- ADMIN, request.VOIP_USER, request.NORMAL_USER
- Arguments
- "conds", "index_from", "index_to", "sort_by", "desc"
- Permission
- "SEE VOUCHERS"
- Code
def searchVoucher(self, request): """ return vouchers, based on request["conds"] conditions return value is a dic in format {"total_rows":,"report":[]} """ request.needAuthType(request.ADMIN) request.needAuthType(request.ADMIN, request.VOIP_USER, request.NORMAL_USER) request.checkArgs("conds", "index_from", "index_to", "sort_by", "desc") requester = request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) requester.canDo("SEE VOUCHERS") role = "admin" searcher = voucher_searcher.VoucherSearcher(conds, requester, role) voucher_results = searcher.getVouchers(request["index_from"], request["index_to"], request["sort_by"], request["desc"], request.getDateType()) return voucher_results
[ویرایش] voucherAddNewUser
adds a new user with the credit of voucher_pin_code givven<br> in the isp and group that has been set<br> returns the user id of created user<br>
- Auth Type
- ADMIN
- Arguments
- "voucher_pin", "isp_name", "group_name"
- Permission
- "USE VOUCHER ON USERS"
- Permission
- "ADD NEW USER"
- Code
def voucherAddNewUser(self, request): """ adds a new user with the credit of voucher_pin_code givven in the isp and group that has been set returns the user id of created user """ request.needAuthType(request.ADMIN) request.checkArgs("voucher_pin", "isp_name", "group_name") requester = request.getAuthNameObj() requester.canDo("USE VOUCHER ON USERS") requester.canDo("ADD NEW USER") remote_address = request.getRemoteAddr() creator_name = requester.getAdminUsername() return voucher_main.getActions().addNewUser(request["voucher_pin"], request["isp_name"], request["group_name"], remote_address, creator_name)
[ویرایش] voucherRechargeUser
recharges the user with the given voucher pin<br> if the request has been sent by admin, admin_id would be as current admin's id<br> otherwise it would be set as system admin_id<br>
- Auth Type
- ADMIN, request.VOIP_USER, request.NORMAL_USER
- Arguments
- "voucher_pin"
- Permission
- "USE VOUCHER ON USERS"
- Arguments
- "user_id"
- Code
def voucherRechargeUser(self, request): """ recharges the user with the given voucher pin if the request has been sent by admin, admin_id would be as current admin's id otherwise it would be set as system admin_id """ request.needAuthType(request.ADMIN, request.VOIP_USER, request.NORMAL_USER) request.checkArgs("voucher_pin") requester = request.getAuthNameObj() if request.hasAuthType(request.VOIP_USER) or request.hasAuthType(request.NORMAL_USER): self.__checkUserAccessToVoucher(requester) user_id = requester.getUserID() admin_id = 0 role = "user" else: requester.canDo("USE VOUCHER ON USERS") request.checkArgs("user_id") user_id = to_int(request["user_id"], "User ID") admin_id = requester.getAdminID() role = "admin" requester.checkAccessToUser(user_id) voucher_main.getActions().rechargeUser(user_id, request["voucher_pin"], admin_id, role)
[ویرایش] WebAnalyzerHandler
[ویرایش] getTopVisited
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to"
- Permission
- "SEE WEB ANALYZER LOGS"
- Code
def getTopVisited(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to") requester = request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) requester.canDo("SEE WEB ANALYZER LOGS") role = "admin" searcher = web_analyzer_report.WebAnalyzerSearcher(conds, requester, role) return searcher.getTopVisited(request["from"], request["to"], request.getDateType())
[ویرایش] getWebAnalyzerLogs
- Auth Type
- ADMIN
- Arguments
- "conds", "from", "to", "sort_by", "desc"
- Permission
- "SEE WEB ANALYZER LOGS"
- Code
def getWebAnalyzerLogs(self, request): request.needAuthType(request.ADMIN) request.checkArgs("conds", "from", "to", "sort_by", "desc") requester = request.getAuthNameObj() conds = report_lib.fixConditionsDic(request["conds"]) requester.canDo("SEE WEB ANALYZER LOGS") role = "admin" searcher = web_analyzer_report.WebAnalyzerSearcher(conds, requester, role) totals, report = searcher.getWebAnalyzerLogs(request["from"], request["to"], request["sort_by"], request["desc"], request.getDateType()) totals = self.__convTotalsToFloat(totals) return (totals, report)
[ویرایش] logAnalysis
- Arguments
- 'log_dict'
- Code
def logAnalysis(self, request): self.__checkWebAnalyzerAuth(request) request.checkArgs('log_dict') return web_analyzer_main.getAnalyzerLogger().logAnalysis(request['log_dict'])
[ویرایش] WinServiceHandler
[ویرایش] getUserInfo
Returns Information Dictionary of a single user<br>
- Auth Type
- ADMIN
- Permission
- "ADD NEW USER"
- Arguments
- "username"
- Code
def getUserInfo(self, request): """ Returns Information Dictionary of a single user """ request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("ADD NEW USER") request.checkArgs("username") return getUsersCache().getInfoByUsername(request["username"])
[ویرایش] getUserInfos
Returns a list of user infos(dict) that has been acquired from active directory<br> Argument starts_with is used to filter the returned dictionary. An empty starts_with will return all usernames<br>
- Auth Type
- ADMIN
- Permission
- "ADD NEW USER"
- Arguments
- "starts_with"
- Code
def getUserInfos(self, request): """ Returns a list of user infos(dict) that has been acquired from active directory Argument starts_with is used to filter the returned dictionary. An empty starts_with will return all usernames """ request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("ADD NEW USER") request.checkArgs("starts_with") user_infos = getUsersCache().getAllUserInfos() usernames = user_infos.keys() filtered_usernames = self.__filterAndSortUsernames(usernames, request["starts_with"]) ret_list = [] for username in filtered_usernames: user_dict = user_infos[username] user_dict["username"] = username ret_list.append(user_dict) return ret_list
[ویرایش] getUsernames
Returns a list of usernames that has been acquired from active directory<br> Argument starts_with is used to filter the returned dictionary. An empty starts_with will return all usernames<br>
- Auth Type
- ADMIN
- Permission
- "ADD NEW USER"
- Arguments
- "starts_with"
- Code
def getUsernames(self, request): """ Returns a list of usernames that has been acquired from active directory Argument starts_with is used to filter the returned dictionary. An empty starts_with will return all usernames """ request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("ADD NEW USER") request.checkArgs("starts_with") usernames = getUsersCache().getAllUsernames() filtered_usernames = self.__filterAndSortUsernames(usernames, request["starts_with"]) return filtered_usernames