Blok Çalıştırma
Analiz Bloklarını Çalıştırma
Bireysel blokları eşzamansız olarak çalıştırın ve işlenme durumlarını izleyin. Bloklar türlerine ve yapılandırmalarına göre veri işler.
Bloğu Çalıştır
POST /api/{tenantId}/{projectId}/block/{blockId}/execute
Bir bloğu eşzamansız çalıştırma için kuyruğa alır. Blok, türüne ve yapılandırmasına (filtre, hesaplayıcı, uyarı vb.) göre veri işletecek. İlerlemeyi takip etmek için bir çalıştırma kimliği döner.
Yol Parametreleri
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
tenantId |
GUID | Evet | Kiracı kimliği |
projectId |
GUID | Evet | Proje kimliği |
blockId |
GUID | Evet | Çalıştırılacak blok kimliği |
İstek Gövdesi (Opsiyonel)
{
"parameters": {
"dateFrom": "2024-01-01",
"dateTo": "2024-12-31",
"threshold": 1000
}
}
Yanıt (202 Kabul Edildi)
{
"blockId": "550e8400-e29b-41d4-a716-446655440000",
"executionId": "770e8400-e29b-41d4-a716-446655440000",
"status": "Queued",
"dateQueued": "2024-01-15T10:30:00Z",
"dateStarted": null,
"dateEnded": null,
"result": null,
"errorMessage": null,
"message": "Block execution has been queued"
}
Yanıt Alanları
| Alan | Tür | Açıklama |
|---|---|---|
blockId |
GUID | Kuyruğa alınan blok |
executionId |
GUID | Bu çalıştırma için benzersiz kimlik |
status |
string | Mevcut çalıştırma durumu |
dateQueued |
datetime | Çalıştırmanın kuyruğa alındığı zaman |
dateStarted |
datetime | Çalıştırmanın başladığı zaman (başlamadıysa null) |
dateEnded |
datetime | Çalıştırmanın tamamlandığı zaman (bitmediyse null) |
result |
object | Çalıştırma sonucu verisi (tamamlanana kadar null) |
errorMessage |
string | Çalıştırma başarısızsa hata ayrıntıları |
message |
string | İnsan tarafından okunabilir durum mesajı |
Hata Yanıtları
Bulunamadı (404):
{
"Error": "Block not found",
"BlockId": "550e8400-e29b-41d4-a716-446655440000"
}
Yetkisiz (401):
{yetkilendirme hatasını açıklayan hata mesajı}
Çalıştırma Durumu Değerleri
Blok çalıştırması şu durum değerleriyle ilerler:
| Durum | Açıklama |
|---|---|
Queued |
Blok çalıştırma kuyruğunda bekliyor |
Running |
Blok şu anda veriyi işliyor |
Success |
Blok çalıştırmayı başarıyla tamamladı |
Failed |
Blok çalıştırması hatalarla başarısız oldu |
Cancelled |
Blok çalıştırması iptal edildi |
Uygulama Örnekleri
cURL
# Parametresiz blok çalıştırma
curl -X POST "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/block/550e8400-e29b-41d4-a716-446655440000/execute" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json"
# Parametrelerle blok çalıştırma
curl -X POST "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/block/550e8400-e29b-41d4-a716-446655440000/execute" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"parameters": {"dateFrom": "2024-01-01", "dateTo": "2024-12-31"}}'
JavaScript/Node.js
const TENANT_ID = '12345678-1234-1234-1234-123456789012';
const PROJECT_ID = '87654321-4321-4321-4321-210987654321';
const BASE_URL = 'https://your-mindzie-instance.com';
class BlockExecutor {
constructor(token) {
this.headers = {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
};
}
async executeBlock(blockId, parameters = null) {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/block/${blockId}/execute`;
const body = parameters ? JSON.stringify({ parameters }) : null;
const response = await fetch(url, {
method: 'POST',
headers: this.headers,
body: body
});
if (response.status === 202) {
return await response.json();
}
throw new Error(`Execution failed: ${response.statusText}`);
}
}
// Kullanım
const executor = new BlockExecutor('your-auth-token');
// Parametresiz çalıştırma
const result = await executor.executeBlock('block-guid');
console.log(`Çalıştırma kuyruğa alındı: ${result.executionId}`);
// Parametrelerle çalıştırma
const resultWithParams = await executor.executeBlock('block-guid', {
dateFrom: '2024-01-01',
dateTo: '2024-12-31'
});
Python
import requests
TENANT_ID = '12345678-1234-1234-1234-123456789012'
PROJECT_ID = '87654321-4321-4321-4321-210987654321'
BASE_URL = 'https://your-mindzie-instance.com'
class BlockExecutor:
def __init__(self, token):
self.headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
def execute_block(self, block_id, parameters=None):
"""Blok çalıştırma için kuyruğa al."""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/block/{block_id}/execute'
payload = {'parameters': parameters} if parameters else {}
response = requests.post(url, json=payload, headers=self.headers)
if response.status_code == 202:
return response.json()
else:
raise Exception(f'Blok çalıştırılamadı: {response.text}')
# Kullanım
executor = BlockExecutor('your-auth-token')
# Parametresiz çalıştırma
result = executor.execute_block('block-guid')
print(f"Çalıştırma kuyruğa alındı: {result['executionId']}")
# Parametrelerle çalıştırma
result = executor.execute_block('block-guid', {
'dateFrom': '2024-01-01',
'dateTo': '2024-12-31',
'threshold': 1000
})
print(f"Durum: {result['status']}")
C#
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
public class ExecuteBlockReturn
{
public Guid BlockId { get; set; }
public Guid ExecutionId { get; set; }
public string Status { get; set; }
public DateTime DateQueued { get; set; }
public DateTime? DateStarted { get; set; }
public DateTime? DateEnded { get; set; }
public object Result { get; set; }
public string ErrorMessage { get; set; }
public string Message { get; set; }
}
public class BlockExecutorClient
{
private readonly HttpClient _httpClient;
private readonly string _baseUrl;
private readonly Guid _tenantId;
private readonly Guid _projectId;
public BlockExecutorClient(string baseUrl, Guid tenantId, Guid projectId, string accessToken)
{
_baseUrl = baseUrl;
_tenantId = tenantId;
_projectId = projectId;
_httpClient = new HttpClient();
_httpClient.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
}
public async Task<ExecuteBlockReturn> ExecuteBlockAsync(Guid blockId, object parameters = null)
{
var url = $"{_baseUrl}/api/{_tenantId}/{_projectId}/block/{blockId}/execute";
var payload = parameters != null ? new { parameters } : new { };
var content = new StringContent(
JsonSerializer.Serialize(payload),
Encoding.UTF8,
"application/json");
var response = await _httpClient.PostAsync(url, content);
if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
{
var json = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<ExecuteBlockReturn>(json,
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
}
throw new Exception($"Blok çalıştırılamadı: {response.StatusCode}");
}
}
// Kullanım
var executor = new BlockExecutorClient(
"https://your-mindzie-instance.com",
Guid.Parse("12345678-1234-1234-1234-123456789012"),
Guid.Parse("87654321-4321-4321-4321-210987654321"),
"your-access-token");
// Bloğu çalıştır
var result = await executor.ExecuteBlockAsync(
Guid.Parse("block-guid"),
new { dateFrom = "2024-01-01", dateTo = "2024-12-31" });
Console.WriteLine($"Çalıştırma kuyruğa alındı: {result.ExecutionId}");
En İyi Uygulamalar
- Blok Durumunu Kontrol Edin: Çalıştırmadan önce blok devre dışı bırakılmamış olduğundan emin olun
- Parametreleri Akıllıca Kullanın: Çalıştırma sırasında blok yapılandırmasını değiştirmeden parametre geçerek özelleştirin
- Eşzamansız Doğasını Yönetin: Blok çalıştırma eşzamansızdır - tamamlanma kontrolü için sonuçlar uç noktasını kullanın
- İşlem Takibi Yapın: Uzun süren bloklar için, ilerlemeyi takip etmek üzere sonuçlar uç noktasını düzenli sorgulayın