|
| 1 | +# 权限治理 Command Patterns |
| 2 | + |
| 3 | +本文只提供 `permission_governance` workflow 的具体 `lark-cli` 命令样例。只有进入对应 state 且需要拼装命令时才读取本文;命令可用范围仍以 [`lark-drive-workflow-permission-governance.md`](lark-drive-workflow-permission-governance.md) 的 `Command Map` 为准。 |
| 4 | + |
| 5 | +## 目录 |
| 6 | + |
| 7 | +- `目标解析` |
| 8 | +- `目标发现` |
| 9 | +- `事实读取` |
| 10 | +- `写前确认与执行` |
| 11 | + |
| 12 | +## 目标解析 |
| 13 | + |
| 14 | +```bash |
| 15 | +lark-cli drive +inspect --url '<url>' --as user --format json |
| 16 | +``` |
| 17 | + |
| 18 | +`/wiki/space/<space_id>` URL 是 Wiki space 范围,不要用 `drive +inspect` 当作单文档解析;直接提取 `space_id` 后进入 `DISCOVER_TARGETS`。 |
| 19 | + |
| 20 | +## 目标发现 |
| 21 | + |
| 22 | +发现 Wiki space / node 下目标: |
| 23 | + |
| 24 | +```bash |
| 25 | +lark-cli wiki +node-list \ |
| 26 | + --space-id '<space_id>' --page-size 50 \ |
| 27 | + --page-all --page-limit 0 \ |
| 28 | + --as user --format json |
| 29 | + |
| 30 | +lark-cli wiki +node-list \ |
| 31 | + --space-id '<space_id>' --parent-node-token '<node_token>' --page-size 50 \ |
| 32 | + --page-all --page-limit 0 \ |
| 33 | + --as user --format json |
| 34 | + |
| 35 | +lark-cli wiki +node-list \ |
| 36 | + --space-id '<space_id>' --page-token '<PAGE_TOKEN>' --page-size 50 \ |
| 37 | + --as user --format json |
| 38 | +``` |
| 39 | + |
| 40 | +解析返回时使用 `data.nodes`,不要读取顶层 `items`。`--page-limit 0` 表示当前层分页不设页数上限;`--page-all` 只覆盖当前 `space-id` / `parent-node-token` 范围内的分页,不会递归子节点。节点 `has_child=true` 时,必须继续以该节点的 `node_token` 作为 `--parent-node-token` 递归读取。 |
| 41 | + |
| 42 | +发现 Drive folder 下目标: |
| 43 | + |
| 44 | +```bash |
| 45 | +lark-cli drive files list \ |
| 46 | + --params '{"folder_token":"<folder_token>","page_size":200}' \ |
| 47 | + --as user --format json |
| 48 | + |
| 49 | +lark-cli drive files list \ |
| 50 | + --params '{"folder_token":"<folder_token>","page_size":200,"page_token":"<PAGE_TOKEN>"}' \ |
| 51 | + --as user --format json |
| 52 | +``` |
| 53 | + |
| 54 | +## 事实读取 |
| 55 | + |
| 56 | +读取 metadata: |
| 57 | + |
| 58 | +```bash |
| 59 | +lark-cli drive metas batch_query \ |
| 60 | + --data '{"request_docs":[{"doc_token":"<token>","doc_type":"<type>"}],"with_url":true}' \ |
| 61 | + --as user --format json |
| 62 | +``` |
| 63 | + |
| 64 | +读取 public permission: |
| 65 | + |
| 66 | +```bash |
| 67 | +lark-cli drive permission.public get \ |
| 68 | + --params '{"token":"<token>","type":"<type>"}' \ |
| 69 | + --as user --format json |
| 70 | +``` |
| 71 | + |
| 72 | +按需读取访问统计: |
| 73 | + |
| 74 | +```bash |
| 75 | +lark-cli drive file.statistics get \ |
| 76 | + --params '{"file_token":"<token>","file_type":"<type>"}' \ |
| 77 | + --as user --format json |
| 78 | +``` |
| 79 | + |
| 80 | +按需读取最近访问记录: |
| 81 | + |
| 82 | +```bash |
| 83 | +lark-cli drive file.view_records list \ |
| 84 | + --params '{"file_token":"<token>","file_type":"<type>","page_size":50}' \ |
| 85 | + --as user --format json |
| 86 | +``` |
| 87 | + |
| 88 | +## 写前确认与执行 |
| 89 | + |
| 90 | +patch 前检查 manage-public permission: |
| 91 | + |
| 92 | +```bash |
| 93 | +lark-cli drive permission.members auth \ |
| 94 | + --params '{"token":"<token>","type":"<type>","action":"manage_public"}' \ |
| 95 | + --as user --format json |
| 96 | +``` |
| 97 | + |
| 98 | +patch 前读取当前 schema: |
| 99 | + |
| 100 | +```bash |
| 101 | +lark-cli schema drive.permission.public.patch --format json |
| 102 | +``` |
| 103 | + |
| 104 | +只 patch 当前 schema 支持的字段;对 Wiki 目标,必须省略 schema 明确标注为 Wiki 不支持的字段。 |
| 105 | + |
| 106 | +显式确认后 patch public permission: |
| 107 | + |
| 108 | +```bash |
| 109 | +lark-cli drive permission.public patch \ |
| 110 | + --params '{"token":"<token>","type":"<type>"}' \ |
| 111 | + --data '{"link_share_entity":"closed","external_access":false}' \ |
| 112 | + --as user --yes --format json |
| 113 | +``` |
| 114 | + |
| 115 | +显式确认后申请访问权限: |
| 116 | + |
| 117 | +```bash |
| 118 | +lark-cli drive +apply-permission \ |
| 119 | + --token '<url>' \ |
| 120 | + --perm view --remark '<reason>' --as user --format json |
| 121 | + |
| 122 | +lark-cli drive +apply-permission \ |
| 123 | + --token '<bare-token>' --type '<type>' \ |
| 124 | + --perm view --remark '<reason>' --as user --format json |
| 125 | +``` |
| 126 | + |
| 127 | +owner 转移前读取当前 schema: |
| 128 | + |
| 129 | +```bash |
| 130 | +lark-cli schema drive.permission.members.transfer_owner --format json |
| 131 | +``` |
| 132 | + |
| 133 | +显式确认后转移 owner: |
| 134 | + |
| 135 | +```bash |
| 136 | +lark-cli drive permission.members transfer_owner \ |
| 137 | + --params '{"token":"<token>","type":"<type>","need_notification":true,"remove_old_owner":false,"old_owner_perm":"full_access","stay_put":true}' \ |
| 138 | + --data '{"member_id":"<new_owner_open_id>","member_type":"openid"}' \ |
| 139 | + --as user --yes --format json |
| 140 | +``` |
| 141 | + |
| 142 | +`member_type` 只能使用当前 schema 支持的值:`email`、`openid`、`userid`、`appid`。如果用户只给姓名,必须先解析为明确身份或要求用户补充;不要猜测 `member_id`。批量 owner 转移必须逐个目标顺序执行。 |
| 143 | + |
| 144 | +secure label 写前枚举可用标签: |
| 145 | + |
| 146 | +```bash |
| 147 | +lark-cli drive +secure-label-list \ |
| 148 | + --page-size 10 --lang zh \ |
| 149 | + --as user --format json |
| 150 | + |
| 151 | +lark-cli drive +secure-label-list \ |
| 152 | + --page-size 10 --page-token '<PAGE_TOKEN>' --lang zh \ |
| 153 | + --as user --format json |
| 154 | +``` |
| 155 | + |
| 156 | +当用户给出的是标签名称、密级文案或不确定的 label ID 时,必须先枚举并解析为 `label-id`;写入确认里展示目标标签名称和 ID。找不到唯一标签时,停止并让用户选择,不要猜测。 |
| 157 | + |
| 158 | +显式确认后更新 secure label: |
| 159 | + |
| 160 | +```bash |
| 161 | +lark-cli drive +secure-label-update \ |
| 162 | + --token '<url>' \ |
| 163 | + --label-id '<label-id>' --as user --format json |
| 164 | + |
| 165 | +lark-cli drive +secure-label-update \ |
| 166 | + --token '<bare-token>' --type '<type>' \ |
| 167 | + --label-id '<label-id>' --as user --format json |
| 168 | +``` |
0 commit comments