本文整理汇总了Python中pritunl.organization.Organization.get_users方法的典型用法代码示例。如果您正苦于以下问题:Python Organization.get_users方法的具体用法?Python Organization.get_users怎么用?Python Organization.get_users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pritunl.organization.Organization
的用法示例。
在下文中一共展示了Organization.get_users方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: user_get
# 需要导入模块: from pritunl.organization import Organization [as 别名]
# 或者: from pritunl.organization.Organization import get_users [as 别名]
def user_get(org_id):
org = Organization(org_id)
org_servers = org.get_servers()
users = []
users_dict = {}
users_sort = []
clients = {}
for server in org_servers:
server_clients = server.get_clients()
for client_id in server_clients:
client = server_clients[client_id]
if client_id not in clients:
clients[client_id] = []
clients[client_id].append(client['virt_address'])
for user in org.get_users():
name_id = '%s_%s' % (user.name, user.id)
users_sort.append(name_id)
users_dict[name_id] = {
'id': user.id,
'organization': org.id,
'name': user.name,
'type': user.type,
'status': True if user.id in clients else False,
'virt_addresses': clients[user.id] if user.id in clients else [],
}
for name_id in sorted(users_sort):
users.append(users_dict[name_id])
return utils.jsonify(users)
示例2: user_get
# 需要导入模块: from pritunl.organization import Organization [as 别名]
# 或者: from pritunl.organization.Organization import get_users [as 别名]
def user_get(org_id):
org = Organization(org_id)
otp_auth = False
users = []
users_dict = {}
users_sort = []
clients = {}
for server in org.get_servers():
if server.otp_auth:
otp_auth = True
server_clients = server.get_clients()
for client_id in server_clients:
client = server_clients[client_id]
if client_id not in clients:
clients[client_id] = {}
clients[client_id][server.id] = client
for user in org.get_users():
name_id = '%s_%s' % (user.name, user.id)
users_sort.append(name_id)
users_dict[name_id] = {
'id': user.id,
'organization': org.id,
'name': user.name,
'type': user.type,
'status': True if user.id in clients else False,
'otp_auth': otp_auth,
'otp_secret': user.otp_secret,
'servers': clients[user.id] if user.id in clients else {},
}
for name_id in sorted(users_sort):
users.append(users_dict[name_id])
return utils.jsonify(users)