-
Notifications
You must be signed in to change notification settings - Fork 158
获取简单信息
foyou edited this page Nov 11, 2021
·
1 revision
from aligo import Aligo
ali = Aligo()
以下例子,省略此段
user = ali.get_user()
成功的返回值是一个 BaseUser
对象,定义如下:
@dataclass
class BaseUser(DataClass):
"""..."""
user_name: str = None
user_id: str = None
default_drive_id: str = None
description: str = field(default=None, repr=False)
nick_name: str = field(default=None, repr=False)
email: str = field(default=None, repr=False)
phone: str = field(default=None, repr=False)
role: str = field(default=None, repr=False)
status: str = field(default=None, repr=False)
created_at: int = field(default=None, repr=False)
domain_id: str = field(default=None, repr=False)
updated_at: int = field(default=None, repr=False)
avatar: str = field(default=None, repr=False)
user_data: dict = field(default=None, repr=False)
deny_change_password_by_self: bool = field(default=False, repr=False)
need_change_password_next_login: bool = field(default=False, repr=False)
permission: str = field(default=None, repr=False)
包含 用户名
、用户id
、昵称
、创建时间
等信息。
其他例子中,将不再列出对象信息
-
此方法会将信息缓存在一个内部变量中,若要刷新信息,请提供
f5
参数user = ali.get_user(f5=True)
,直接给True
当然也是可以的,因为它只有这个可选参数。
personal_info = ali.get_personal_info()
# 已用大小
used_size = personal_info.personal_space_info.used_size
# 总大小
total_size = personal_info.personal_space_info.total_size
drive_id = ali.default_drive_id
# 有一个可选的 `drive_id` 参数
drive = ali.get_drive()
信息展示
{
"drive_id": "1066884",
"used_size": 6998969779282,
"total_size": 8480412925952,
"drive_name": "Default",
"owner": "3e935da769594ca4849c7c1409efb96f",
"description": "Created by system",
"drive_type": "normal",
"creator": "System",
"domain_id": "bj29",
"status": "enabled",
"store_id": "b5e9de389ef241d084733b520ea8b57d",
"owner_type": "user",
"relative_path": "",
"encrypt_mode": "none",
"encrypt_data_access": false,
"permission": null,
"created_at": "2021-02-25T08:16:02.642Z",
"subdomain_id": ""
}
用Python连接阿里云盘