Users API
사용자 관리를 위한 API입니다.
개요
Users API를 통해 D.Hub 사용자를 생성, 조회, 수정, 삭제할 수 있습니다. 관리자 권한이 필요한 API입니다.
엔드포인트
GET /api/v1/users/
모든 사용자 목록을 조회합니다.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | integer | 100 | 최대 조회 개수 |
token | string | - | 페이지네이션 토큰 |
Response
200 OK
{
"items": {
"user-abc123": "{\"id\":\"user-abc123\",\"email\":\"user@example.com\",...}",
"user-xyz789": "{\"id\":\"user-xyz789\",\"email\":\"admin@example.com\",...}"
},
"token": "next-page-token"
}
노트
보안을 위해 password_hash 필드는 응답에서 제외됩니다.
GET /api/v1/users/{user_id}/versions
사용자의 버전 히스토리를 조회합니다.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | string | Yes | 사용자 ID |
Response
200 OK
[
{
"version_id": "v2",
"last_modified": "2024-01-20T10:30:00Z",
"size": 512
}
]
GET /api/v1/users/{user_id}
특정 사용자를 조회합니다.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | string | Yes | 사용자 ID |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_version | string | No | 특정 버전 조회 |
Response
200 OK
{
"id": "user-abc123",
"email": "user@example.com",
"name": "John Doe",
"alias": "john",
"type": "user",
"groups": ["developers"],
"tags": [],
"provider": "local",
"is_active": true,
"roles": ["user"],
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-15T09:00:00Z"
}
Error Responses
| Status Code | Description |
|---|---|
| 404 Not Found | 사용자를 찾을 수 없음 |
POST /api/v1/users/
새 사용자를 생성합니다.
Request Body
{
"email": "newuser@example.com",
"name": "New User",
"password": "secure-password",
"groups": ["developers"],
"tags": []
}
| Field | Type | Required | Description |
|---|---|---|---|
email | string | Yes | 이메일 (고유) |
name | string | Yes | 사용자 이름 |
password | string | Yes | 비밀번호 |
alias | string | No | 별칭 |
groups | array | No | 소속 그룹 |
tags | array | No | 태그 |
Response
200 OK
{
"item": "user-newid123"
}
Error Responses
| Status Code | Description |
|---|---|
| 409 Conflict | 이미 존재하는 이메일 |
PUT /api/v1/users/{user_id}
사용자 정보를 수정합니다.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | string | Yes | 사용자 ID |
Request Body
수정할 필드만 포함합니다.
{
"name": "Updated Name",
"email": "newemail@example.com",
"groups": ["developers", "admins"]
}
| Field | Type | Description |
|---|---|---|
name | string | 사용자 이름 |
alias | string | 별칭 |
type | string | 사용자 타입 |
email | string | 이메일 (변경 시 중복 검사) |
groups | array | 소속 그룹 |
tags | array | 태그 |
comment | string | 수정 코멘트 |
Response
200 OK
{
"message": "User updated successfully"
}
Error Responses
| Status Code | Description |
|---|---|
| 404 Not Found | 사용자를 찾을 수 없음 |
| 409 Conflict | 이미 존재하는 이메일 |
DELETE /api/v1/users/{user_id}
사용자를 삭제합니다.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | string | Yes | 사용자 ID |
Response
200 OK
{
"message": "User deleted successfully"
}
Error Responses
| Status Code | Description |
|---|---|
| 404 Not Found | 사용자를 찾을 수 없음 |
사용자 객체
| Field | Type | Description |
|---|---|---|
id | string | 사용자 고유 ID |
email | string | 이메일 주소 |
name | string | 사용자 이름 |
alias | string | 별칭 |
type | string | 사용자 타입 (user, admin 등) |
groups | array | 소속 그룹 목록 |
tags | array | 태그 목록 |
provider | string | 인증 제공자 (local, ldap, oidc) |
is_active | boolean | 활성화 상태 |
roles | array | 역할 목록 |
created_at | string | 생성 시간 |
updated_at | string | 수정 시간 |
사용 예시
cURL
# 사용자 목록 조회
curl https://api.dhub.io/api/v1/users/ \
-H "Authorization: Bearer <access_token>"
# 사용자 생성
curl -X POST https://api.dhub.io/api/v1/users/ \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"email": "newuser@example.com",
"name": "New User",
"password": "secure-password"
}'
# 사용자 수정
curl -X PUT https://api.dhub.io/api/v1/users/user-abc123 \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{"name": "Updated Name"}'
# 사용자 삭제
curl -X DELETE https://api.dhub.io/api/v1/users/user-abc123 \
-H "Authorization: Bearer <access_token>"