# 策略授权参考
本章节介绍DNS策略授权场景下支持的策略授权项。
#### 支持的授权项
策略包含系统策略和自定义策略，如果系统策略不满足授权要求，管理员可以创建自定义策略，并通过给用户组授予自定义策略来进行精细的访问控制。策略支持的操作与API相对应，授权项列表说明如下：
- 权限：允许或拒绝某项操作。
- 对应API接口：自定义策略实际调用的API接口。
- 授权项：自定义策略中支持的Action，在自定义策略中的Action中写入授权项，可以实现授权项对应的权限功能。
- 依赖的授权项：部分Action存在对其他Action的依赖，需要将依赖的Action同时写入授权项，才能实现对应的权限功能。
- IAM项目(Project)/企业项目(Enterprise Project)：自定义策略的授权范围，包括IAM项目与企业项目。授权范围如果同时支持IAM项目和企业项目，表示此授权项对应的自定义策略，可以在IAM和企业管理两个服务中给用户组授权并生效。如果仅支持IAM项目，不支持企业项目，表示仅能在IAM中给用户组授权并生效，如果在企业管理中授权，则该自定义策略不生效。管理员可以在授权项列表中查看授权项是否支持IAM项目或企业项目，"√"表示支持，"×"表示暂不支持。关于IAM项目与企业项目的区别，详情请参见：[IAM与企业管理的区别](https://support.huaweicloud.com/iam_faq/iam_01_0101.html)。
DNS支持的自定义策略授权项如下所示：
- [Zone]：包含DNS所有Zone管理接口对应的授权项，如创建Zone等接口。
- [Record Set]：包含DNS所有Record Set管理接口对应的授权项，如创建Record Set等接口。
- [PTR]：包含DNS所有PTR管理接口对应的授权项，如设置PTR Record等接口。
- [TAG]：包含DNS所有Tag管理接口对应的授权项，如添加资源标签等接口。
- [导入]：包含DNS所有导入管理接口对应的授权项，如创建批量导入公网Record Set任务等接口。
- [自定义线路]：包含DNS所有自定义线路管理接口对应的授权项，如创建自定义线路等接口。
 
 #### Zone
表1Zone 
| 权限              | 对应API接口                                   | 授权项（Action）               | 依赖的授权项                                                                                                                                                                                                                                                                                                                                                                                             | IAM项目(Project) | 企业项目(Enterprise Project)                                                                                                                                                                                                                                                                                                                                         |
|:---|:---|:---|:---|:---|:---|
| 创建Zone           | POST /v2/zones                             | dns:zone:create            | vpc:\*:get\* vpc:\*:list\*                                                                                                                                                                                                                                                                                                      | √              | √                                                                                                                                                                                                                                                                                                                                                               |
| 查询Zone           | GET /v2/zones/{zone_id}                     | dns:zone:get                | -                                                                                                                                                                                                                                                                                                                                                                                               | √               | √                                                                                                                                                                                                                                                                                                                                                              |
| 查询Zone列表        | GET /v2/zones                               | dns:zone:list            | -                                                                                                                                                                                                                                                                                                                                                                                                 | √               | 支持以下两种过滤条件： - 通过企业项目过滤条件。  - 通过资源ID过滤条件。   |
| 更新Zone         | PATCH /v2/zones/{zone_id}                    | dns:zone:update             | -                                                                                                                                                                                                                                                                                                                                                                                               | √              | √                                                                                                                                                                                                                                                                                                                                                                 |
| 设置Zone状态      | PUT /v2/zones/{zone_id}/statuses           | dns:zone:setStatus           | -                                                                                                                                                                                                                                                                                                                                                                                                | √            | √                                                                                                                                                                                                                                                                                                                                                                  |
| 删除Zone        | DELETE /v2/zones/{zone_id}                 | dns:zone:delete            | ces:remoteChecks:list ces:siteMonitorHealthCheck:get ces:siteMonitorHealthCheck:create ces:siteMonitorRule:delete ces:siteMonitorRule:put   | √              | √                                                                                                                                                                                                                                                                                                                                                                   |
| 批量删除Zone       | DELETE /v2.1/zones                         | dns:zone:delete           | ces:remoteChecks:list ces:siteMonitorHealthCheck:get ces:siteMonitorHealthCheck:create ces:siteMonitorRule:delete ces:siteMonitorRule:put | √             | √                                                                                                                                                                                                                                                                                                                                                                |
| 内网Zone关联VPC   | POST /v2/zones/{zone_id}/associaterouter  | dns:zone:associaterouter   | vpc:\*:get\* vpc:\*:list\*                                                                                                                                                                                                                                                                                                          | √            | √ 说明： 不含共享资源。                                                                                                                                                                                                                                                                                       |
| 内网Zone解关联VPC    | POST /v2/zones/{zone_id}/disassociaterouter | dns:zone:disassociaterouter | vpc:\*:get\* vpc:\*:list\*                                                                                                                                                                                                                                                                                                         | √               | √ 说明： 不含共享资源。                                                                                                                                                                                                                                                                                       |
| 创建公网域名找回      | POST /v2/retrieval                        | dns:zone:createRetrieval  | -                                                                                                                                                                                                                                                                                                                                                                                                 | √              | ×                                                                                                                                                                                                                                                                                                                                                                |
| 请求立即验证公网域名找回 | POST /v2/retrieval/verification/{id}     | dns:zone:createRetrieval  | -                                                                                                                                                                                                                                                                                                                                                                                                 | √              | ×                                                                                                                                                                                                                                                                                                                                                                |
| 查询公网域名找回     | GET /v2/retrieval                           | dns:zone:getRetrieval    | -                                                                                                                                                                                                                                                                                                                                                                                                 | √               | ×                                                                                                                                                                                                                                                                                                                                                                 |
| 查询公网域名找回结果     | GET /v2/retrieval/verification/{id}        | dns:zone:getRetrieval    | -                                                                                                                                                                                                                                                                                                                                                                                                 | √               | ×                                                                                                                                                                                                                                                                                                                                                                 |
| 导出Zone         | GET /v2/zones/{zone_id}/export              | dns:zone:getExport         | -                                                                                                                                                                                                                                                                                                                                                                                                | √              | √                                                                                                                                                                                                                                                                                                                                                                |
   
 #### Record Set
表2Record Set 
| 权限              | 对应API接口                                                 | 授权项（Action）             | 依赖的授权项                                                                                                                                                                                                                                                                                                                                                                                            | IAM项目(Project) | 企业项目(Enterprise Project)                                                                |
|:---|:---|:---|:---|:---|:---|
| 创建Record Set     | POST /v2/zones/{zone_id}/recordsets                    | dns:recordset:create    | -                                                                                                                                                                                                                                                                                                                                                                                                 | √               | √                                                                                    |
| 创建Record Set    | POST /v2.1/zones/{zone_id}/recordsets                  | dns:recordset:create     | -                                                                                                                                                                                                                                                                                                                                                                                                | √                | √                                                                                      |
| 查询Record Set      | GET /v2/zones/{zone_id}/recordsets/{recordset_id}      | dns:recordset:get     | -                                                                                                                                                                                                                                                                                                                                                                                                  | √                | √                                                                                       |
| 查询Record Set    | GET /v2.1/zones/{zone_id}/recordsets/{recordset_id}     | dns:recordset:get      | -                                                                                                                                                                                                                                                                                                                                                                                                 | √              | √                                                                                       |
| 查询Record Set列表    | GET /v2/zones/{zone_id}/recordsets                      | dns:recordset:list     | -                                                                                                                                                                                                                                                                                                                                                                                                 | √             | list类接口。 支持所属zone ID过滤条件。 |
| 查询Record Set列表    | GET /v2/recordsets                                    | dns:recordset:list     | -                                                                                                                                                                                                                                                                                                                                                                                                 | √             | list类接口。 支持所属zone ID过滤条件。 |
| 查询Record Set列表 | GET /v2.1/zones/{zone_id}/recordsets                    | dns:recordset:list      | -                                                                                                                                                                                                                                                                                                                                                                                                | √               | list类接口。 支持所属zone ID过滤条件。  |
| 查询Record Set列表 | GET /v2.1/recordsets                                   | dns:recordset:list      | -                                                                                                                                                                                                                                                                                                                                                                                                | √               | list类接口。 支持所属zone ID过滤条件。  |
| 更新Record Set      | PUT /v2/zones/{zone_id}/recordsets/{recordset_id}      | dns:recordset:update   | -                                                                                                                                                                                                                                                                                                                                                                                                 | √               | √                                                                                    |
| 更新Record Set      | PUT /v2.1/zones/{zone_id}/recordsets/{recordset_id}    | dns:recordset:update     | -                                                                                                                                                                                                                                                                                                                                                                                                 | √              | √                                                                                    |
| 删除Record Set     | DELETE /v2/zones/{zone_id}/recordsets/{recordset_id}   | dns:recordset:delete   | ces:remoteChecks:list ces:siteMonitorHealthCheck:get ces:siteMonitorHealthCheck:create ces:siteMonitorRule:delete ces:siteMonitorRule:put | √            | √                                                                                      |
| 删除Record Set     | DELETE /v2.1/zones/{zone_id}/recordsets/{recordset_id} | dns:recordset:delete    | ces:remoteChecks:list ces:siteMonitorHealthCheck:get ces:siteMonitorHealthCheck:create ces:siteMonitorRule:delete ces:siteMonitorRule:put  | √               | √                                                                                      |
| 批量删除Record Set    | DELETE /v2.1/zones/{zone_id}/recordsets               | dns:recordset:delete     | ces:remoteChecks:list ces:siteMonitorHealthCheck:get ces:siteMonitorHealthCheck:create ces:siteMonitorRule:delete ces:siteMonitorRule:put  | √               | √                                                                                     |
| 设置Record Set状态    | PUT /v2.1/recordsets/{recordset_id}/statuses/set       | dns:recordset:setStatus | -                                                                                                                                                                                                                                                                                                                                                                                                  | √            | √                                                                                       |
   
 #### PTR
表3PTR 
| 权限             | 对应API接口                                                  | 授权项（Action）   | 依赖的授权项                                                                                   | IAM项目(Project) | 企业项目(Enterprise Project)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|:---|:---|:---|:---|:---|:---|
| 设置PTR Record       | PATCH /v2/reverse/floatingips/{region}:{floatingip_id} | dns:ptr:set   | vpc:\*:get\* vpc:\*:list\* | √             | √                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| 修改PTR Record      | PATCH /v2/reverse/floatingips/{region}:{floatingip_id}  | dns:ptr:set   | vpc:\*:get\* vpc:\*:list\* | √             | √                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| 恢复PTR Record默认值  | PATCH /v2/reverse/floatingips/{region}:{floatingip_id}   | dns:ptr:set   | vpc:\*:get\* vpc:\*:list\* | √             | √                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| 批量恢复PTR Record默认值 | DELETE /v2.1/reverse/floatingips                      | dns:ptr:set   | vpc:\*:get\* vpc:\*:list\* | √             | √                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| 查询PTR Record      | GET /v2/reverse/floatingips/{region}:{floatingip_id}    | dns:ptr:get | -                                                                                       | √              | √                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| 查询PTR Record列表    | GET /v2/reverse/floatingips                             | dns:ptr:list | -                                                                                           | √             | × list类接口。 支持以下两种过滤条件： - 通过企业项目过滤条件。  - 通过资源ID过滤条件。 资源ID形式：{region}:{floatingip_id}    |
   
 #### TAG
表4TAG 
| 权限       | 对应API接口                                                          | 授权项（Action） | 依赖的授权项 | IAM项目 (Project) | 企业项目(Enterprise Project) |
|:---|:---|:---|:---|:---|:---|
| 添加资源标签    | POST /v2/{project_id}/{resource_type}/{resource_id}/tags          | dns:tag:set | -     | √                                                                             | √                       |
| 批量添加删除资源标签 | POST /v2/{project_id}/{resource_type}/{resource_id}/tags/action   | dns:tag:set | -     | √                                                                             | √                       |
| 删除资源标签     | DELETE /v2/{project_id}/{resource_type}/{resource_id}/tags/{key} | dns:tag:get    | -     | √                                                                             | √                       |
| 查询资源标签     | GET /v2/{project_id}/{resource_type}/{resource_id}/tags           | dns:tag:get   | -   | √                                                                            | √                       |
| 查询项目标签    | GET /v2/{project_id}/{resource_type}/tags                         | dns:tag:get   | -    | √                                                                              | ×                        |
| 查询资源实例    | POST /v2/{project_id}/{resource_type}/resource_instances/action  | dns:tag:get     | -         | √                                                                                  | ×                      |
   
 #### 导入
表5导入 
| 权限                 | 对应API接口                                                   | 授权项（Action）                       | 依赖的授权项 | IAM项目(Project) | 企业项目(Enterprise Project) |
|:---|:---|:---|:---|:---|:---|
| 创建批量导入公网Record Set任务   | POST /v2/zones/{zone_id}/import/recordsets                | dns:publicRecordset:createImport    | -       | √            | √                      |
| 查询批量导入公网Record Set任务  | GET /v2/zones/{zone_id}/import/recordsets                | dns:publicRecordset:getImport   | -       | √           | √                      |
| 删除批量导入公网Record Set任务  | DELETE /v2/zones/{zone_id}/import/tasks/{task_id}       | dns:publicRecordset:deleteImport  | -     | √          | √                        |
| 创建批量导入内网Record Set任务 | POST /v2/zones/{zone_id}/import/private/recordsets        | dns:privateRecordset:createImport  | -       | √           | √                      |
| 查询批量导入内网Record Set任务 | GET /v2/zones/{zone_id}/import/private/recordsets        | dns:privateRecordset:getImport   | -      | √          | √                      |
| 删除批量导入内网Record Set任务    | DELETE /v2/zones/{zone_id}/import/private/tasks/{task_id} | dns:privateRecordset:deleteImport | -       | √            | √                       |
   
 #### 自定义线路
表6自定义线路 
| 权限       | 对应API接口                            | 授权项（Action）           | 依赖的授权项 | IAM项目 (Project) | 企业项目 (Enterprise Project) |
|:---|:---|:---|:---|:---|:---|
| 创建自定义线路    | POST /v2.1/customlines            | dns:customline:create | -      | √                                                                               | ×                                                                                        |
| 查询自定义线路列表 | GET /v2.1/customlines             | dns:customline:list    | -    | √                                                                              | ×                                                                                       |
| 删除自定义线路    | DELETE /v2.1/customlines/{line_id} | dns:customline:delete  | -       | √                                                                                | ×                                                                                         |
| 修改自定义线路    | PUT /v2.1/customlines/{line_id}   | dns:customline:update | -     | √                                                                              | ×                                                                                        |
   
