权限

列出项目权限项定义

请求

  1. GET /openapi/policy/resource-actions?projectName=<项目标识>&envType=<项目类型>

Query 参数说明

参数名类型描述必填
projectNamestring项目标识
envTypestring项目类型,主机项目为 pm,其他类型为k8s

成功返回说明

参数名类型描述
resourcestring操作对象
aliasstring操作对象别名
rules[]Rules操作项

操作项参数说明

参数名类型描述
actionstring操作项定义
aliasstring操作项别名

成功返回示例

  1. [
  2. {
  3. "resource": "Workflow",
  4. "alias": "工作流",
  5. "rules": [
  6. {
  7. "action": "get_workflow",
  8. "alias": "查看"
  9. },
  10. {
  11. "action": "create_workflow",
  12. "alias": "新建"
  13. },
  14. {
  15. "action": "edit_workflow",
  16. "alias": "编辑"
  17. },
  18. {
  19. "action": "delete_workflow",
  20. "alias": "删除"
  21. },
  22. {
  23. "action": "run_workflow",
  24. "alias": "执行"
  25. },
  26. {
  27. "action": "debug_workflow",
  28. "alias": "调试"
  29. }
  30. ]
  31. },
  32. {
  33. "resource": "Environment",
  34. "alias": "测试环境",
  35. "rules": [
  36. {
  37. "action": "get_environment",
  38. "alias": "查看"
  39. },
  40. {
  41. "action": "create_environment",
  42. "alias": "创建"
  43. },
  44. {
  45. "action": "config_environment",
  46. "alias": "配置"
  47. },
  48. {
  49. "action": "manage_environment",
  50. "alias": "管理服务实例"
  51. },
  52. {
  53. "action": "delete_environment",
  54. "alias": "删除"
  55. },
  56. {
  57. "action": "debug_pod",
  58. "alias": "服务调试"
  59. }
  60. ]
  61. },
  62. {
  63. "resource": "ProductionEnvironment",
  64. "alias": "生产环境",
  65. "rules": [
  66. {
  67. "action": "get_production_environment",
  68. "alias": "查看"
  69. },
  70. {
  71. "action": "create_production_environment",
  72. "alias": "创建"
  73. },
  74. {
  75. "action": "config_production_environment",
  76. "alias": "配置"
  77. },
  78. {
  79. "action": "edit_production_environment",
  80. "alias": "管理服务实例"
  81. },
  82. {
  83. "action": "delete_production_environment",
  84. "alias": "删除"
  85. },
  86. {
  87. "action": "production_debug_pod",
  88. "alias": "服务调试"
  89. }
  90. ]
  91. },
  92. {
  93. "resource": "Service",
  94. "alias": "测试服务",
  95. "rules": [
  96. {
  97. "action": "get_service",
  98. "alias": "查看"
  99. },
  100. {
  101. "action": "create_service",
  102. "alias": "新建"
  103. },
  104. {
  105. "action": "edit_service",
  106. "alias": "编辑"
  107. },
  108. {
  109. "action": "delete_service",
  110. "alias": "删除"
  111. }
  112. ]
  113. },
  114. {
  115. "resource": "ProductionService",
  116. "alias": "生产服务",
  117. "rules": [
  118. {
  119. "action": "get_production_service",
  120. "alias": "查看"
  121. },
  122. {
  123. "action": "create_production_service",
  124. "alias": "新建"
  125. },
  126. {
  127. "action": "edit_production_service",
  128. "alias": "编辑"
  129. },
  130. {
  131. "action": "delete_production_service",
  132. "alias": "删除"
  133. }
  134. ]
  135. },
  136. {
  137. "resource": "Build",
  138. "alias": "构建",
  139. "rules": [
  140. {
  141. "action": "get_build",
  142. "alias": "查看"
  143. },
  144. {
  145. "action": "create_build",
  146. "alias": "新建"
  147. },
  148. {
  149. "action": "edit_build",
  150. "alias": "编辑"
  151. },
  152. {
  153. "action": "delete_build",
  154. "alias": "删除"
  155. }
  156. ]
  157. },
  158. {
  159. "resource": "Test",
  160. "alias": "测试",
  161. "rules": [
  162. {
  163. "action": "get_test",
  164. "alias": "查看"
  165. },
  166. {
  167. "action": "create_test",
  168. "alias": "新建"
  169. },
  170. {
  171. "action": "edit_test",
  172. "alias": "编辑"
  173. },
  174. {
  175. "action": "delete_test",
  176. "alias": "删除"
  177. },
  178. {
  179. "action": "run_test",
  180. "alias": "执行"
  181. }
  182. ]
  183. },
  184. {
  185. "resource": "Scan",
  186. "alias": "代码扫描",
  187. "rules": [
  188. {
  189. "action": "get_scan",
  190. "alias": "查看"
  191. },
  192. {
  193. "action": "create_scan",
  194. "alias": "新建"
  195. },
  196. {
  197. "action": "edit_scan",
  198. "alias": "编辑"
  199. },
  200. {
  201. "action": "delete_scan",
  202. "alias": "删除"
  203. },
  204. {
  205. "action": "run_scan",
  206. "alias": "执行"
  207. }
  208. ]
  209. },
  210. {
  211. "resource": "Delivery",
  212. "alias": "版本管理",
  213. "rules": [
  214. {
  215. "action": "get_delivery",
  216. "alias": "查看"
  217. },
  218. {
  219. "action": "create_delivery",
  220. "alias": "创建"
  221. },
  222. {
  223. "action": "delete_delivery",
  224. "alias": "删除"
  225. }
  226. ]
  227. }
  228. ]

列出项目角色信息

请求

  1. GET /openapi/policy/roles?namespace=<项目标识>

Query 参数说明

参数名类型描述必填
namespacestring项目标识

成功返回说明

参数名类型描述
idintid
namestring名称
namespacestring项目唯一标识
descstring描述
typestring类型,值为 custom 时标识为自建类型

成功返回示例

  1. [
  2. {
  3. "id": 51,
  4. "name": "dev",
  5. "namespace": "test-k8skv-2",
  6. "desc": "",
  7. "type": "custom"
  8. },
  9. {
  10. "id": 1,
  11. "name": "project-admin",
  12. "namespace": "test-k8skv-2",
  13. "desc": "",
  14. "type": "system"
  15. },
  16. {
  17. "id": 2,
  18. "name": "read-only",
  19. "namespace": "test-k8skv-2",
  20. "desc": "",
  21. "type": "system"
  22. },
  23. {
  24. "id": 3,
  25. "name": "read-project-only",
  26. "namespace": "test-k8skv-2",
  27. "desc": "",
  28. "type": "system"
  29. }
  30. ]

获取项目角色详情

请求

  1. GET /openapi/policy/roles/:name?namespace=<项目标识>

路径参数说明

参数名类型描述必填
namestring角色名称

Query 参数说明

参数名类型描述必填
namespacestring项目标识

成功返回说明

参数名类型描述
idintid
namestring名称
namespacestring项目唯一标识
rules[]Rule权限列表
descstring描述
typestring类型,值为 custom 时标识为自建类型

Rule 参数说明

参数名类型描述
resourcestring操作对象
verbs[]string权限项,具体值参考权限定义接口

成功返回示例

  1. {
  2. "id": 51,
  3. "name": "dev",
  4. "namespace": "test-k8skv-2",
  5. "desc": "",
  6. "type": "custom",
  7. "rules": [
  8. {
  9. "resource": "Test",
  10. "verbs": [
  11. "get_test"
  12. ]
  13. },
  14. {
  15. "resource": "Scan",
  16. "verbs": [
  17. "get_scan"
  18. ]
  19. },
  20. {
  21. "resource": "Delivery",
  22. "verbs": [
  23. "get_delivery"
  24. ]
  25. },
  26. {
  27. "resource": "Workflow",
  28. "verbs": [
  29. "get_workflow",
  30. "run_workflow"
  31. ]
  32. },
  33. {
  34. "resource": "ProductionEnvironment",
  35. "verbs": [
  36. "get_production_environment"
  37. ]
  38. },
  39. {
  40. "resource": "Service",
  41. "verbs": [
  42. "get_service"
  43. ]
  44. },
  45. {
  46. "resource": "ProductionService",
  47. "verbs": [
  48. "get_production_service"
  49. ]
  50. },
  51. {
  52. "resource": "Build",
  53. "verbs": [
  54. "get_build"
  55. ]
  56. },
  57. {
  58. "resource": "Environment",
  59. "verbs": [
  60. "get_environment"
  61. ]
  62. }
  63. ]
  64. }

创建项目角色

请求

  1. POST /openapi/policy/roles?namespace=<项目标识>

Query 参数说明

参数名类型描述必填
namespacestring项目标识

Body 参数说明

参数名说明类型必填
name角色名称string
namespace项目标识string
actions权限项[]string

Body 参数示例

  1. {
  2. "name": "test",
  3. "actions":
  4. [
  5. "get_test",
  6. "create_test",
  7. "edit_test"
  8. ],
  9. "namespace": "test-k8skv-2"
  10. }

成功返回示例

  1. {
  2. "message": "success"
  3. }

编辑项目角色

请求

  1. PUT /openapi/policy/roles/:name?namespace=<项目标识>

路径参数说明

参数名类型描述必填
namestring角色名称

Query 参数说明

参数名类型描述必填
namespacestring项目标识

Body 参数说明

参数名说明类型必填
actions权限项[]string

Body 参数示例

  1. {
  2. "actions":
  3. [
  4. "create_test",
  5. "edit_test",
  6. "get_test",
  7. "get_build"
  8. ]
  9. }

成功返回示例

  1. {
  2. "message": "success"
  3. }

删除项目角色

请求

  1. DELETE /openapi/policy/roles/:name?namespace=<项目标识>

路径参数说明

参数名类型描述必填
namestring角色名称

Query 参数说明

参数名类型描述必填
namespacestring项目标识

Body 参数说明

参数名说明类型必填
actions权限项[]string

Body 参数示例

  1. {
  2. "actions":
  3. [
  4. "create_test",
  5. "edit_test",
  6. "get_test",
  7. "get_build"
  8. ]
  9. }

成功返回示例

  1. {
  2. "message": "success"
  3. }

列出项目成员

请求

  1. GET /openapi/policy/role-bindings?namespace=<项目标识>

Query 参数说明

参数名类型描述必填
namespacestring项目标识

成功返回说明

参数名类型描述
binding_typestring成员类型,user为用户,group为用户组
user_infoUserInfo(#userinfo-1)用户成员信息,当binding_type值为user时生效
group_infoUserInfo(#groupinfo-1)用户组成员信息,当binding_type值为group时生效
roles[]string拥有的角色

用户成员参数说明

参数名说明类型
uiduidstring
name用户名string
accout账户名string

用户组成员参数说明

参数名说明类型
group_idgroup_idstring
name用户组名称string

成功返回示例

  1. [
  2. {
  3. "binding_type": "user",
  4. "user_info": {
  5. "identity_type": "system",
  6. "uid": "d456d705-73a9-11ee-98cf-56ef622fc735",
  7. "account": "demo",
  8. "username": "demo"
  9. },
  10. "roles": [
  11. "prod-test",
  12. "read-project-only"
  13. ]
  14. },
  15. {
  16. "binding_type": "user",
  17. "user_info": {
  18. "identity_type": "system",
  19. "uid": "290a3f01-73aa-11ee-98cf-56ef622fc735",
  20. "account": "leo",
  21. "username": "leo"
  22. },
  23. "roles": [
  24. "read-project-only"
  25. ]
  26. },
  27. {
  28. "binding_type": "group",
  29. "group_info": {
  30. "group_id": "98256be6-6e53-11ee-a205-9653dd3e9c32",
  31. "name": "XX"
  32. },
  33. "roles": [
  34. "read-project-only"
  35. ]
  36. },
  37. {
  38. "binding_type": "group",
  39. "group_info": {
  40. "group_id": "cce58580-5131-11ee-b458-4a4088364d94",
  41. "name": "所有用户"
  42. },
  43. "roles": [
  44. "read-project-only"
  45. ]
  46. }
  47. ]

增加项目成员

请求

  1. POST /openapi/policy/role-bindings?namespace=<项目标识>

Query 参数说明

参数名类型描述必填
namespacestring项目标识

Body 参数说明

参数名说明类型必填
role角色类型string
identities成员数据列表[]identities

Body 参数示例

成员数据参数说明

参数名说明类型必填
identity_type成员类型string user 或者 group
gid用户组idstring添加用户组时必填
uid用户idstring添加用户时必填
  1. {
  2. "role": "read-project-only",
  3. "identities":
  4. [
  5. {
  6. "identity_type": "group",
  7. "gid": "98256be6-6e53-11ee-a205-9653dd3e9c32"
  8. },
  9. {
  10. "identity_type": "group",
  11. "gid": "cce58580-5131-11ee-b458-4a4088364d94"
  12. },
  13. {
  14. "identity_type": "user",
  15. "uid": "ddd405d5-5131-11ee-b458-4a4088364d94"
  16. }
  17. ]
  18. }

成功返回示例

  1. {
  2. "message": "success"
  3. }

更新项目成员角色

请求

  1. POST /openapi/policy/role-bindings/user/:uid?namespace=<项目标识>

路径参数说明

参数名类型描述必填
uidstring用户id

Query 参数说明

参数名类型描述必填
namespacestring项目标识

Body 参数说明

参数名说明类型必填
roles角色列表[]string

Body 参数示例

  1. {
  2. "roles":
  3. [
  4. "prod-test",
  5. "read-project-only",
  6. "lilian"
  7. ]
  8. }

成功返回示例

  1. {
  2. "message": "success"
  3. }

删除项目成员

请求

  1. DELETE /openapi/policy/role-bindings/user/:uid?namespace=<项目标识>

路径参数说明

参数名类型描述必填
uidstring用户id

Query 参数说明

参数名类型描述必填
namespacestring项目标识

成功返回示例

  1. {
  2. "message": "success"
  3. }

更新项目用户组成员角色

请求

  1. POST /openapi/policy/role-bindings/group/:gid?namespace=<项目标识>

路径参数说明

参数名类型描述必填
gidstring用户组id

Query 参数说明

参数名类型描述必填
namespacestring项目标识

Body 参数说明

参数名说明类型必填
roles角色列表[]string

Body 参数示例

  1. {
  2. "roles":
  3. [
  4. "prod-test",
  5. "read-project-only",
  6. "lilian"
  7. ]
  8. }

成功返回示例

  1. {
  2. "message": "success"
  3. }

删除项目用户组成员

请求

  1. DELETE /openapi/policy/role-bindings/group/:gid?namespace=<项目标识>

路径参数说明

参数名类型描述必填
gidstring用户组id

Query 参数说明

参数名类型描述必填
namespacestring项目标识

成功返回示例

  1. {
  2. "message": "success"
  3. }