Şablon Yönetimi

Defter şablonlarını yönetmek için tam CRUD işlemleri. Tüm uç noktalar Global API Anahtarı gerektirir.


Küresel Şablonları Listele

GET /api/templates

Tüm kiracılar arasında mevcut olan tüm küresel şablonları döner.

Yanıt (200 OK)

{
  "templates": [
    {
      "templateId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
      "name": "Process Discovery",
      "description": "Standard process discovery workflow",
      "category": "Templates",
      "processName": "Order to Cash",
      "tenantId": null,
      "isGlobal": true,
      "hasThumbnail": true,
      "autoAddedDefaultSortOrder": 100,
      "dateModified": "2024-01-15T10:30:00Z"
    }
  ],
  "totalCount": 1
}

Kiracıya Ait Şablonları Listele

GET /api/templates/tenant/{tenantId}

Belirli bir kiracıya ait tüm şablonları, hem küresel hem de kiracıya özel şablonlar dahil, döner.

Yol Parametreleri

Parametre Tür Zorunlu Açıklama
tenantId GUID Evet Kiracı kimliği

Yanıt (200 OK)

{
  "templates": [
    {
      "templateId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
      "name": "Process Discovery",
      "description": "Standard process discovery workflow",
      "category": "Templates",
      "processName": "Order to Cash",
      "tenantId": null,
      "isGlobal": true,
      "hasThumbnail": true,
      "autoAddedDefaultSortOrder": 100,
      "dateCreated": "2024-01-01T00:00:00Z",
      "dateModified": "2024-01-15T10:30:00Z",
      "createdByName": "System",
      "modifiedByName": "System"
    },
    {
      "templateId": "bbbbbbbb-cccc-dddd-eeee-ffffffffffff",
      "name": "Custom Analysis",
      "description": "Tenant-specific custom analysis",
      "category": "Custom",
      "processName": null,
      "tenantId": "12345678-1234-1234-1234-123456789012",
      "isGlobal": false,
      "hasThumbnail": false,
      "autoAddedDefaultSortOrder": 0,
      "dateCreated": "2024-02-01T09:00:00Z",
      "dateModified": "2024-02-15T14:30:00Z",
      "createdByName": "API",
      "modifiedByName": "API"
    }
  ],
  "totalCount": 2
}

Kategoriye Göre Şablonları Listele

GET /api/templates/category/{category}

Kategoriye göre filtrelenmiş şablonları döner.

Yol Parametreleri

Parametre Tür Zorunlu Açıklama
category string Evet Kategori adı: Templates, Custom, veya BaseKnowledge

Sorgu Parametreleri

Parametre Tür Zorunlu Açıklama
tenantId GUID Hayır Belirli bir kiracının şablonlarına filtre uygular

Örnek

# Tüm özel şablonları al
curl -X GET "https://your-mindzie-instance.com/api/templates/category/Custom" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY"

# Belirli bir kiracı için özel şablonları al
curl -X GET "https://your-mindzie-instance.com/api/templates/category/Custom?tenantId=12345678-1234-1234-1234-123456789012" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY"

Şablon Detaylarını Al

GET /api/templates/{templateId}

MCL yapılandırma metni dahil olmak üzere tam şablon detaylarını döner.

Yol Parametreleri

Parametre Tür Zorunlu Açıklama
templateId GUID Evet Şablon kimliği

Yanıt (200 OK)

{
  "templateId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
  "name": "Process Discovery",
  "description": "Standard process discovery workflow with variant analysis",
  "category": "Templates",
  "processName": "Order to Cash",
  "mclText": "// MCL configuration defining notebook blocks and settings\n{\n  \"blocks\": [...],\n  \"settings\": {...}\n}",
  "tenantId": null,
  "isGlobal": true,
  "hasThumbnail": true,
  "autoAddedDefaultSortOrder": 100,
  "originatingNotebookId": null,
  "dateCreated": "2024-01-01T00:00:00Z",
  "dateModified": "2024-01-15T10:30:00Z",
  "createdBy": null,
  "createdByName": "System",
  "modifiedBy": null,
  "modifiedByName": "System"
}

Yanıt Alanları

Alan Tür Açıklama
templateId GUID Benzersiz kimlik
name string Şablon adı
description string Şablon açıklaması
category string Kategori (Templates, Custom, BaseKnowledge)
processName string İlgili süreç adı
mclText string MCL yapılandırma metni
tenantId GUID Kiracı ID (küresel şablonlar için null)
isGlobal boolean Küresel şablon ise true
hasThumbnail boolean Küçük resim var ise true
autoAddedDefaultSortOrder integer Görüntüleme sıralama düzeni
originatingNotebookId GUID Mevcut defterden oluşturulmuşsa kaynak defter ID'si
dateCreated datetime Oluşturulma zaman damgası
dateModified datetime Son değişiklik zaman damgası
createdBy GUID Oluşturan kullanıcı ID'si
createdByName string Oluşturan kullanıcı adı
modifiedBy GUID Son değiştiren kullanıcı ID'si
modifiedByName string Son değiştiren kullanıcı adı

Hata Yanıtları

Bulunamadı (404)

{
  "error": "Template with ID 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' not found"
}

Şablon Küçük Resmini Al

GET /api/templates/{templateId}/thumbnail

Bir şablonun küçük resim görüntüsünü döner.

Yol Parametreleri

Parametre Tür Zorunlu Açıklama
templateId GUID Evet Şablon kimliği

Yanıt (200 OK)

JPEG resim verisi döner, Content-Type: image/jpeg ile.

Hata Yanıtları

Bulunamadı (404)

{
  "error": "Thumbnail not found for template 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'"
}

Şablon Oluştur

POST /api/templates/tenant/{tenantId}

Yeni bir kiracıya özel şablon oluşturur. Küresel şablonlar API ile oluşturulamaz.

Yol Parametreleri

Parametre Tür Zorunlu Açıklama
tenantId GUID Evet Kiracı kimliği

İstek Gövdesi

{
  "name": "Custom Analysis Template",
  "description": "Custom analysis workflow for monthly reporting",
  "mclText": "// MCL configuration text",
  "category": "Custom",
  "processName": "Monthly Report",
  "isGlobal": false,
  "autoAddedDefaultSortOrder": 0
}

İstek Alanları

Alan Tür Zorunlu Açıklama
name string Evet Şablon adı (benzersiz olmalı)
description string Hayır Şablon açıklaması
mclText string Evet MCL yapılandırma metni
category string Hayır Kategori (varsayılan: "Custom")
processName string Hayır İlgili süreç adı
isGlobal boolean Hayır API aracılığıyla oluşturma için false olmalı
autoAddedDefaultSortOrder integer Hayır Görüntüleme sıralama düzeni

Yanıt (201 Created)

{
  "templateId": "cccccccc-dddd-eeee-ffff-000000000000",
  "name": "Custom Analysis Template",
  "description": "Custom analysis workflow for monthly reporting",
  "category": "Custom",
  "processName": "Monthly Report",
  "mclText": "// MCL configuration text",
  "tenantId": "12345678-1234-1234-1234-123456789012",
  "isGlobal": false,
  "hasThumbnail": false,
  "autoAddedDefaultSortOrder": 0,
  "dateCreated": "2024-03-01T10:00:00Z",
  "dateModified": "2024-03-01T10:00:00Z",
  "createdByName": "API"
}

Hata Yanıtları

Kötü İstek (400) - Doğrulama Başarısız

{
  "error": "Validation failed",
  "validationErrors": ["Name is required", "MclText is required"]
}

Çakışma (409) - İsim Çakışması

{
  "error": "A template with this name already exists"
}

Şablonu Güncelle

PUT /api/templates/{templateId}

Mevcut bir kiracıya özel şablonu günceller. Küresel şablonlar API ile güncellenemez.

Yol Parametreleri

Parametre Tür Zorunlu Açıklama
templateId GUID Evet Şablon kimliği

İstek Gövdesi

{
  "name": "Updated Template Name",
  "description": "Updated description",
  "mclText": "// Updated MCL configuration",
  "category": "Custom",
  "processName": "Updated Process",
  "autoAddedDefaultSortOrder": 10
}

Tüm alanlar isteğe bağlıdır - sadece verilen alanlar güncellenecektir.

Yanıt (200 OK)

Güncellenmiş şablon detaylarını döner.

Hata Yanıtları

Kötü İstek (400) - Küresel Şablon

{
  "error": "Cannot update global templates through the API"
}

Bulunamadı (404)

{
  "error": "Template not found"
}

Çakışma (409) - İsim Çakışması

{
  "error": "A template with this name already exists"
}

Şablonu Sil

DELETE /api/templates/{templateId}

Kiracıya özel bir şablonu siler. Küresel şablonlar API ile silinemez.

Yol Parametreleri

Parametre Tür Zorunlu Açıklama
templateId GUID Evet Şablon kimliği

Yanıt (200 OK)

{
  "message": "Template deleted successfully"
}

Hata Yanıtları

Kötü İstek (400) - Küresel Şablon

{
  "error": "Cannot delete global templates"
}

Bulunamadı (404)

{
  "error": "Template not found"
}

Uygulama Örnekleri

cURL

# Bir kiracının tüm şablonlarını listele
curl -X GET "https://your-mindzie-instance.com/api/templates/tenant/12345678-1234-1234-1234-123456789012" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY"

# Şablon detaylarını al
curl -X GET "https://your-mindzie-instance.com/api/templates/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY"

# Şablon oluştur
curl -X POST "https://your-mindzie-instance.com/api/templates/tenant/12345678-1234-1234-1234-123456789012" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Custom Template",
    "description": "Custom analysis workflow",
    "mclText": "// MCL configuration",
    "category": "Custom"
  }'

# Şablonu güncelle
curl -X PUT "https://your-mindzie-instance.com/api/templates/cccccccc-dddd-eeee-ffff-000000000000" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Updated Name"}'

# Şablonu sil
curl -X DELETE "https://your-mindzie-instance.com/api/templates/cccccccc-dddd-eeee-ffff-000000000000" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY"

Python

import requests

BASE_URL = 'https://your-mindzie-instance.com'
TENANT_ID = '12345678-1234-1234-1234-123456789012'

class TemplateManager:
    def __init__(self, global_api_key):
        self.headers = {
            'Authorization': f'Bearer {global_api_key}',
            'Content-Type': 'application/json'
        }

    def list_templates(self, tenant_id=None):
        """Şablonları listeler, isteğe bağlı olarak kiracıya göre filtreler."""
        if tenant_id:
            url = f'{BASE_URL}/api/templates/tenant/{tenant_id}'
        else:
            url = f'{BASE_URL}/api/templates'
        response = requests.get(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def get_template(self, template_id):
        """MCL metni dahil olmak üzere şablon detaylarını alır."""
        url = f'{BASE_URL}/api/templates/{template_id}'
        response = requests.get(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def create_template(self, tenant_id, name, mcl_text, description=None, category='Custom'):
        """Yeni bir kiracıya özel şablon oluşturur."""
        url = f'{BASE_URL}/api/templates/tenant/{tenant_id}'
        data = {
            'name': name,
            'mclText': mcl_text,
            'description': description,
            'category': category
        }
        response = requests.post(url, json=data, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def update_template(self, template_id, **kwargs):
        """Bir şablonu günceller. Güncellenecek alanları parametre olarak geçin."""
        url = f'{BASE_URL}/api/templates/{template_id}'
        response = requests.put(url, json=kwargs, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def delete_template(self, template_id):
        """Kiracıya özel bir şablonu siler."""
        url = f'{BASE_URL}/api/templates/{template_id}'
        response = requests.delete(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

# Kullanım
manager = TemplateManager('your-global-api-key')

# Şablonları listele
templates = manager.list_templates(TENANT_ID)
print(f"{templates['totalCount']} adet şablon bulundu")

for t in templates['templates']:
    print(f"  - {t['name']} ({'Küresel' if t['isGlobal'] else 'Kiracı'})")

# Şablon oluştur
new_template = manager.create_template(
    tenant_id=TENANT_ID,
    name='My Analysis Template',
    mcl_text='// MCL configuration here',
    description='Custom workflow'
)
print(f"Oluşturulan şablon: {new_template['templateId']}")

# Şablonu güncelle
updated = manager.update_template(
    new_template['templateId'],
    name='Renamed Template'
)

# Şablonu sil
manager.delete_template(new_template['templateId'])
print("Şablon silindi")

JavaScript/Node.js

const BASE_URL = 'https://your-mindzie-instance.com';
const TENANT_ID = '12345678-1234-1234-1234-123456789012';

class TemplateManager {
  constructor(globalApiKey) {
    this.headers = {
      'Authorization': `Bearer ${globalApiKey}`,
      'Content-Type': 'application/json'
    };
  }

  async listTemplates(tenantId = null) {
    const url = tenantId
      ? `${BASE_URL}/api/templates/tenant/${tenantId}`
      : `${BASE_URL}/api/templates`;
    const response = await fetch(url, { headers: this.headers });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }

  async getTemplate(templateId) {
    const url = `${BASE_URL}/api/templates/${templateId}`;
    const response = await fetch(url, { headers: this.headers });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }

  async createTemplate(tenantId, name, mclText, description = null, category = 'Custom') {
    const url = `${BASE_URL}/api/templates/tenant/${tenantId}`;
    const response = await fetch(url, {
      method: 'POST',
      headers: this.headers,
      body: JSON.stringify({ name, mclText, description, category })
    });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }

  async updateTemplate(templateId, updates) {
    const url = `${BASE_URL}/api/templates/${templateId}`;
    const response = await fetch(url, {
      method: 'PUT',
      headers: this.headers,
      body: JSON.stringify(updates)
    });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }

  async deleteTemplate(templateId) {
    const url = `${BASE_URL}/api/templates/${templateId}`;
    const response = await fetch(url, {
      method: 'DELETE',
      headers: this.headers
    });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }
}

// Kullanım
const manager = new TemplateManager('your-global-api-key');

// Şablonları listele
const templates = await manager.listTemplates(TENANT_ID);
console.log(`${templates.totalCount} adet şablon bulundu`);

// Şablon oluştur
const newTemplate = await manager.createTemplate(
  TENANT_ID,
  'My Analysis Template',
  '// MCL configuration',
  'Custom workflow'
);
console.log(`Oluşturuldu: ${newTemplate.templateId}`);

// Şablonu sil
await manager.deleteTemplate(newTemplate.templateId);

En İyi Uygulamalar

  1. Küresel API Anahtarları Kullanın: Şablon işlemleri küresel API anahtarları gerektirir
  2. Benzersiz İsimler: Şablon isimleri kendi kapsamlarında benzersiz olmalıdır
  3. MCL Metni: Tekrarlanabilir defterler için tam MCL yapılandırmasını saklayın
  4. Kategoriler: Düzen için standart kategoriler kullanın
  5. Küçük Resimler: API üzerinden oluşturulan şablonların küçük resmi otomatik olarak olmaz