Proje Kullanıcıları

Projeler için kullanıcı erişimini ve izinlerini yönetin. Projelere kullanıcı ekleyin, izin seviyelerini güncelleyin ve gerektiğinde erişimi kaldırın.

İzin Seviyeleri

Seviye Açıklama
Sahip (isOwner: true) Tam kontrol - proje ayarlarını değiştirebilir, kullanıcıları yönetebilir, projeyi silebilir
Üye (isOwner: false) Proje içeriğini görebilir ve çalışabilir, kullanıcıları yönetemez veya projeyi silemez

Proje Kullanıcılarını Listele

GET /api/{tenantId}/project/{projectId}/users

Projeye erişimi olan tüm kullanıcıları getirir.

Yol Parametreleri

Parametre Tip Zorunlu Açıklama
tenantId GUID Evet Kiracı kimliği
projectId GUID Evet Proje kimliği

Yanıt (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
}

Kullanıcı İzin Alanları

Alan Tip Açıklama
permissionId GUID Benzersiz izin kayıt ID'si
userId GUID Kullanıcı kimliği
email string Kullanıcının e-posta adresi
displayName string Kullanıcının görüntüleme adı
isOwner boolean Kullanıcının proje sahibi olup olmadığı
dateAssigned datetime Erişimin verildiği tarih

Projeye Kullanıcı Ekle

POST /api/{tenantId}/project/{projectId}/users/{userId}

Belirtilen izinlerle projeye kullanıcı ekler.

Yol Parametreleri

Parametre Tip Zorunlu Açıklama
tenantId GUID Evet Kiracı kimliği
projectId GUID Evet Proje kimliği
userId GUID Evet Eklenecek kullanıcı

İstek Gövdesi (Opsiyonel)

{
  "isOwner": false
}

İstek Alanları

Alan Tip Varsayılan Açıklama
isOwner boolean false Sahip izinleri vermek

Yanıt (201 Created)

{
  "message": "Kullanıcı başarıyla projeye eklendi"
}

Hata Yanıtları

Çakışma (409):

{
  "error": "Kullanıcı zaten bu projenin üyesi"
}

Bulunamadı (404):

{
  "error": "ID'si '{userId}' olan kullanıcı bulunamadı"
}

Kullanıcı İznini Güncelle

PUT /api/{tenantId}/project/{projectId}/users/{userId}

Bir kullanıcının proje üzerindeki izin seviyesini günceller.

Yol Parametreleri

Parametre Tip Zorunlu Açıklama
tenantId GUID Evet Kiracı kimliği
projectId GUID Evet Proje kimliği
userId GUID Evet Güncellenecek kullanıcı

İstek Gövdesi

{
  "isOwner": true
}

Yanıt (200 OK)

{
  "message": "Kullanıcı izni başarıyla güncellendi"
}

Projeden Kullanıcı Kaldır

DELETE /api/{tenantId}/project/{projectId}/users/{userId}

Bir kullanıcının proje erişimini kaldırır.

Yol Parametreleri

Parametre Tip Zorunlu Açıklama
tenantId GUID Evet Kiracı kimliği
projectId GUID Evet Proje kimliği
userId GUID Evet Kaldırılacak kullanıcı

Yanıt (200 OK)

{
  "message": "Kullanıcı başarıyla projeden kaldırıldı"
}

Hata Yanıtları

Bulunamadı (404):

{
  "error": "Kullanıcı bu projenin üyesi değil"
}

Uygulama Örnekleri

cURL

# Proje kullanıcılarını listele
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"

# Kullanıcıyı projeye üye olarak ekle
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}'

# Kullanıcıyı sahip olarak ekle
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}'

# Kullanıcıyı sahip olarak terfi ettir
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}'

# Kullanıcıyı projeden kaldır
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):
        """Projeye erişimi olan tüm kullanıcıları listeler."""
        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):
        """Projeye kullanıcı ekler."""
        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):
        """Kullanıcının izin seviyesini günceller."""
        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):
        """Projeden kullanıcı kaldırır."""
        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()

# Kullanım
manager = ProjectUserManager('your-auth-token')
project_id = '87654321-4321-4321-4321-210987654321'

# Mevcut kullanıcıları listele
result = manager.list_users(project_id)
print(f"Projede {result['totalCount']} kullanıcı var:")

for user in result['users']:
    role = 'Sahip' if user['isOwner'] else 'Üye'
    print(f"  - {user['displayName']} ({user['email']}) - {role}")

# Yeni kullanıcıyı üye olarak ekle
new_user_id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
manager.add_user(project_id, new_user_id, is_owner=False)
print(f"Kullanıcı {new_user_id} üye olarak eklendi")

# Kullanıcıyı sahip olarak terfi ettir
manager.update_permission(project_id, new_user_id, is_owner=True)
print(f"Kullanıcı {new_user_id} sahip olarak terfi etti")

# Kullanıcıyı kaldır
manager.remove_user(project_id, new_user_id)
print(f"Kullanıcı {new_user_id} kaldırıldı")

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(`Başarısız: ${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(`Başarısız: ${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(`Başarısız: ${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(`Başarısız: ${response.status}`);
    return await response.json();
  }
}

// Kullanım
const manager = new ProjectUserManager('your-auth-token');
const projectId = '87654321-4321-4321-4321-210987654321';

// Kullanıcıları listele
const users = await manager.listUsers(projectId);
console.log(`Projede ${users.totalCount} kullanıcı var`);

users.users.forEach(user => {
  const role = user.isOwner ? 'Sahip' : 'Üye';
  console.log(`  - ${user.displayName} (${role})`);
});

// Üye olarak kullanıcı ekle, sonra sahip olarak terfi ettir
await manager.addUser(projectId, 'user-id-here', false);
await manager.updatePermission(projectId, 'user-id-here', true);

En İyi Uygulamalar

  1. Sahipleri Sınırlayın: Sadece projeyi yönetmesi gereken kullanıcılara sahip erişimi verin
  2. Erişimi Denetleyin: Proje kullanıcılarını düzenli olarak gözden geçirin ve gereksiz erişimi kaldırın
  3. Analistler İçin Üyeleri Kullanın: Düzenli analistler sahip değil, üye olmalıdır
  4. Değişiklikleri Belgelendirin: Denetim amaçları için izin değişikliklerini kaydedin