プロジェクトユーザー
プロジェクトのユーザーアクセスと権限を管理します。ユーザーをプロジェクトに追加し、権限レベルを更新し、必要に応じてアクセス権を削除します。
権限レベル
| レベル | 説明 |
|---|---|
オーナー (isOwner: true) |
完全な制御 - プロジェクト設定の変更、ユーザー管理、プロジェクト削除が可能 |
メンバー (isOwner: false) |
プロジェクトの内容の閲覧および操作が可能、ユーザー管理や削除は不可 |
プロジェクトユーザー一覧の取得
GET /api/{tenantId}/project/{projectId}/users
プロジェクトにアクセス権を持つすべてのユーザーを取得します。
パスパラメーター
| パラメーター | 種類 | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナント識別子 |
projectId |
GUID | はい | プロジェクト識別子 |
レスポンス (200 OK)
{
"users": [
{
"permissionId": "11111111-1111-1111-1111-111111111111",
"userId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"email": "john.smith@example.com",
"displayName": "John Smith",
"isOwner": true,
"dateAssigned": "2024-01-15T10:30:00Z"
},
{
"permissionId": "22222222-2222-2222-2222-222222222222",
"userId": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
"email": "jane.doe@example.com",
"displayName": "Jane Doe",
"isOwner": false,
"dateAssigned": "2024-01-20T14:00:00Z"
}
],
"totalCount": 2
}
ユーザー権限フィールド
| フィールド | 種類 | 説明 |
|---|---|---|
permissionId |
GUID | 一意の権限レコードID |
userId |
GUID | ユーザー識別子 |
email |
string | ユーザーのメールアドレス |
displayName |
string | ユーザーの表示名 |
isOwner |
boolean | ユーザーがプロジェクトオーナーかどうか |
dateAssigned |
datetime | アクセスが付与された日時 |
ユーザーをプロジェクトに追加
POST /api/{tenantId}/project/{projectId}/users/{userId}
指定した権限でユーザーをプロジェクトに追加します。
パスパラメーター
| パラメーター | 種類 | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナント識別子 |
projectId |
GUID | はい | プロジェクト識別子 |
userId |
GUID | はい | 追加するユーザー |
リクエストボディ (任意)
{
"isOwner": false
}
リクエストフィールド
| フィールド | 種類 | デフォルト | 説明 |
|---|---|---|---|
isOwner |
boolean | false | オーナー権限を付与するか |
レスポンス (201 Created)
{
"message": "User added to project successfully"
}
エラー応答
Conflict (409):
{
"error": "User is already a member of this project"
}
Not Found (404):
{
"error": "User not found with ID '{userId}'"
}
ユーザー権限の更新
PUT /api/{tenantId}/project/{projectId}/users/{userId}
ユーザーのプロジェクト内の権限レベルを更新します。
パスパラメーター
| パラメーター | 種類 | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナント識別子 |
projectId |
GUID | はい | プロジェクト識別子 |
userId |
GUID | はい | 更新対象ユーザー |
リクエストボディ
{
"isOwner": true
}
レスポンス (200 OK)
{
"message": "User permission updated successfully"
}
ユーザーをプロジェクトから削除
DELETE /api/{tenantId}/project/{projectId}/users/{userId}
ユーザーのプロジェクトへのアクセス権を削除します。
パスパラメーター
| パラメーター | 種類 | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナント識別子 |
projectId |
GUID | はい | プロジェクト識別子 |
userId |
GUID | はい | 削除対象ユーザー |
レスポンス (200 OK)
{
"message": "User removed from project successfully"
}
エラー応答
Not Found (404):
{
"error": "User is not a member of this project"
}
実装例
cURL
# プロジェクトユーザー一覧取得
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/project/87654321-4321-4321-4321-210987654321/users" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
# ユーザーをメンバーとしてプロジェクトに追加
curl -X POST "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/project/87654321-4321-4321-4321-210987654321/users/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"isOwner": false}'
# ユーザーをオーナーとして追加
curl -X POST "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/project/87654321-4321-4321-4321-210987654321/users/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"isOwner": true}'
# ユーザーをオーナーに昇格
curl -X PUT "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/project/87654321-4321-4321-4321-210987654321/users/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"isOwner": true}'
# ユーザーをプロジェクトから削除
curl -X DELETE "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/project/87654321-4321-4321-4321-210987654321/users/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Python
import requests
TENANT_ID = '12345678-1234-1234-1234-123456789012'
BASE_URL = 'https://your-mindzie-instance.com'
class ProjectUserManager:
def __init__(self, token):
self.headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
def list_users(self, project_id):
"""プロジェクトにアクセス権を持つすべてのユーザーを一覧表示します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/project/{project_id}/users'
response = requests.get(url, headers=self.headers)
response.raise_for_status()
return response.json()
def add_user(self, project_id, user_id, is_owner=False):
"""ユーザーをプロジェクトに追加します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/project/{project_id}/users/{user_id}'
payload = {'isOwner': is_owner}
response = requests.post(url, json=payload, headers=self.headers)
response.raise_for_status()
return response.json()
def update_permission(self, project_id, user_id, is_owner):
"""ユーザーの権限レベルを更新します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/project/{project_id}/users/{user_id}'
payload = {'isOwner': is_owner}
response = requests.put(url, json=payload, headers=self.headers)
response.raise_for_status()
return response.json()
def remove_user(self, project_id, user_id):
"""ユーザーをプロジェクトから削除します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/project/{project_id}/users/{user_id}'
response = requests.delete(url, headers=self.headers)
response.raise_for_status()
return response.json()
# 使用例
manager = ProjectUserManager('your-auth-token')
project_id = '87654321-4321-4321-4321-210987654321'
# 現在のユーザー一覧を取得
result = manager.list_users(project_id)
print(f"プロジェクトのユーザー数: {result['totalCount']}")
for user in result['users']:
role = 'オーナー' if user['isOwner'] else 'メンバー'
print(f" - {user['displayName']} ({user['email']}) - {role}")
# 新しいユーザーをメンバーとして追加
new_user_id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
manager.add_user(project_id, new_user_id, is_owner=False)
print(f"ユーザー {new_user_id} をメンバーとして追加しました")
# ユーザーをオーナーに昇格
manager.update_permission(project_id, new_user_id, is_owner=True)
print(f"ユーザー {new_user_id} をオーナーに昇格しました")
# ユーザーを削除
manager.remove_user(project_id, new_user_id)
print(f"ユーザー {new_user_id} を削除しました")
JavaScript/Node.js
const TENANT_ID = '12345678-1234-1234-1234-123456789012';
const BASE_URL = 'https://your-mindzie-instance.com';
class ProjectUserManager {
constructor(token) {
this.headers = {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
};
}
async listUsers(projectId) {
const url = `${BASE_URL}/api/${TENANT_ID}/project/${projectId}/users`;
const response = await fetch(url, { headers: this.headers });
if (!response.ok) throw new Error(`Failed: ${response.status}`);
return await response.json();
}
async addUser(projectId, userId, isOwner = false) {
const url = `${BASE_URL}/api/${TENANT_ID}/project/${projectId}/users/${userId}`;
const response = await fetch(url, {
method: 'POST',
headers: this.headers,
body: JSON.stringify({ isOwner })
});
if (!response.ok) throw new Error(`Failed: ${response.status}`);
return await response.json();
}
async updatePermission(projectId, userId, isOwner) {
const url = `${BASE_URL}/api/${TENANT_ID}/project/${projectId}/users/${userId}`;
const response = await fetch(url, {
method: 'PUT',
headers: this.headers,
body: JSON.stringify({ isOwner })
});
if (!response.ok) throw new Error(`Failed: ${response.status}`);
return await response.json();
}
async removeUser(projectId, userId) {
const url = `${BASE_URL}/api/${TENANT_ID}/project/${projectId}/users/${userId}`;
const response = await fetch(url, {
method: 'DELETE',
headers: this.headers
});
if (!response.ok) throw new Error(`Failed: ${response.status}`);
return await response.json();
}
}
// 使用例
const manager = new ProjectUserManager('your-auth-token');
const projectId = '87654321-4321-4321-4321-210987654321';
// ユーザー一覧を取得
const users = await manager.listUsers(projectId);
console.log(`プロジェクトのユーザー数: ${users.totalCount}`);
users.users.forEach(user => {
const role = user.isOwner ? 'オーナー' : 'メンバー';
console.log(` - ${user.displayName} (${role})`);
});
// ユーザーをメンバーとして追加し、その後オーナーに昇格
await manager.addUser(projectId, 'user-id-here', false);
await manager.updatePermission(projectId, 'user-id-here', true);
ベストプラクティス
- オーナーを制限する: プロジェクト管理が必要なユーザーのみにオーナー権限を付与する
- アクセスを監査する: 定期的にプロジェクトユーザーを確認し、不要なアクセスを削除する
- アナリストにはメンバーを利用する: 通常のアナリストはオーナーではなくメンバーに設定する
- 変更を記録する: 監査目的で権限変更のログを残す