获取组织自定义角色¶
GET /api/v5/orgs/{org}/customized_roles
该接口用于获取指定组织的自定义角色列表,返回各角色的 ID、名称、访问级别、成员数量等详细信息,便于查看组织的自定义角色配置情况。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
org |
path | string | 是 | 组织的路径(path/login) |
access_token |
query | string | 是 | 用户授权码 |
响应参数¶
接口返回一个自定义角色对象数组,数组中的每个元素代表组织下的一个自定义角色。
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
string | 是 | 否 | 角色 ID |
name |
string | 是 | 否 | 角色名称 |
name_cn |
string | 是 | 否 | 角色中文名称 |
product_id |
string | 是 | 否 | 产品 ID |
access_level |
integer | 是 | 否 | 访问级别 |
created_at |
string | 是 | 否 | 创建时间 |
role_type |
string | 是 | 否 | 角色类型(本接口返回的自定义角色为 project-customized) |
updated_at |
string | 是 | 否 | 更新时间 |
description |
string | 是 | 否 | 角色描述 |
member_count |
integer | 是 | 否 | 成员数量 |
role_from |
string | 是 | 否 | 角色来源 |
mgnt_mode |
integer | 是 | 否 | 管理模式 |
失败响应¶
接口在认证失败、参数错误或无权访问时返回统一的错误响应体,字段以 error_code / error_code_name / error_message / trace_id 形式给出(trace_id 可能不返回)。
400 参数错误
{
"error_code": 400,
"error_code_name": "BAD_REQUEST",
"error_message": "org not found",
"trace_id": "..."
}
401 未认证
{
"error_code": 401,
"error_code_name": "UNAUTHORIZED",
"error_message": "缺少或无效的访问令牌",
"trace_id": "..."
}
403 禁止访问
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误 |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
资源不存在 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
请求示例¶
参数说明¶
<org>替换为组织的路径名(企业、组织或个人的地址 path);<token>替换为你的 AtomGit 用户访问令牌。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/orgs/<org>/customized_roles?access_token=<token>' -H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const token = "<YOUR-TOKEN>";
const org = "<org>";
const response = await fetch(`https://api.atomgit.com/api/v5/orgs/${org}/customized_roles?access_token=${token}`, {
headers: {
"Accept": "application/json",
},
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.get(
"https://api.atomgit.com/api/v5/orgs/<org>/customized_roles",
params={"access_token": "<YOUR-TOKEN>"},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
[
{
"id": "123456",
"name": "admin-custom",
"name_cn": "管理员自定义角色",
"product_id": "gitcode",
"access_level": 60,
"created_at": "2024-01-01 00:00:00",
"role_type": "project-customized",
"updated_at": "2024-01-02 00:00:00",
"description": "组织自定义管理员角色",
"member_count": 3,
"role_from": "custom",
"mgnt_mode": 1
}
]
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
403 |
禁止访问,无权查看该组织的自定义角色 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc