본문으로 건너뛰기

Users API

사용자 관리를 위한 API입니다.

개요

Users API를 통해 D.Hub 사용자를 생성, 조회, 수정, 삭제할 수 있습니다. 관리자 권한이 필요한 API입니다.

엔드포인트

GET /api/v1/users/

모든 사용자 목록을 조회합니다.

Query Parameters

ParameterTypeDefaultDescription
limitinteger100최대 조회 개수
tokenstring-페이지네이션 토큰

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

ParameterTypeRequiredDescription
user_idstringYes사용자 ID

Response

200 OK

[
{
"version_id": "v2",
"last_modified": "2024-01-20T10:30:00Z",
"size": 512
}
]

GET /api/v1/users/{user_id}

특정 사용자를 조회합니다.

Path Parameters

ParameterTypeRequiredDescription
user_idstringYes사용자 ID

Query Parameters

ParameterTypeRequiredDescription
user_versionstringNo특정 버전 조회

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 CodeDescription
404 Not Found사용자를 찾을 수 없음

POST /api/v1/users/

새 사용자를 생성합니다.

Request Body

{
"email": "newuser@example.com",
"name": "New User",
"password": "secure-password",
"groups": ["developers"],
"tags": []
}
FieldTypeRequiredDescription
emailstringYes이메일 (고유)
namestringYes사용자 이름
passwordstringYes비밀번호
aliasstringNo별칭
groupsarrayNo소속 그룹
tagsarrayNo태그

Response

200 OK

{
"item": "user-newid123"
}

Error Responses

Status CodeDescription
409 Conflict이미 존재하는 이메일

PUT /api/v1/users/{user_id}

사용자 정보를 수정합니다.

Path Parameters

ParameterTypeRequiredDescription
user_idstringYes사용자 ID

Request Body

수정할 필드만 포함합니다.

{
"name": "Updated Name",
"email": "newemail@example.com",
"groups": ["developers", "admins"]
}
FieldTypeDescription
namestring사용자 이름
aliasstring별칭
typestring사용자 타입
emailstring이메일 (변경 시 중복 검사)
groupsarray소속 그룹
tagsarray태그
commentstring수정 코멘트

Response

200 OK

{
"message": "User updated successfully"
}

Error Responses

Status CodeDescription
404 Not Found사용자를 찾을 수 없음
409 Conflict이미 존재하는 이메일

DELETE /api/v1/users/{user_id}

사용자를 삭제합니다.

Path Parameters

ParameterTypeRequiredDescription
user_idstringYes사용자 ID

Response

200 OK

{
"message": "User deleted successfully"
}

Error Responses

Status CodeDescription
404 Not Found사용자를 찾을 수 없음

사용자 객체

FieldTypeDescription
idstring사용자 고유 ID
emailstring이메일 주소
namestring사용자 이름
aliasstring별칭
typestring사용자 타입 (user, admin 등)
groupsarray소속 그룹 목록
tagsarray태그 목록
providerstring인증 제공자 (local, ldap, oidc)
is_activeboolean활성화 상태
rolesarray역할 목록
created_atstring생성 시간
updated_atstring수정 시간

사용 예시

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>"