Blok Yönetimi
Analiz Bloklarını Alma, Güncelleme ve Silme
Not defterleri içindeki analiz bloklarını yönetin. Bloklar, veri dönüşümleri, hesaplamalar, filtreleme işlemleri ve uyarı verme gibi işlemleri gerçekleştiren temel analiz birimleridir.
Bağlantı Testi
Yetkisiz Ping
GET /api/{tenantId}/{projectId}/block/unauthorized-ping
Kimlik doğrulama gerektirmeyen test uç noktası. Block API'nin erişilebilir olduğunu doğrulamak için kullanılır.
Yanıt
Ping Başarılı
Kimlik Doğrulamalı Ping
GET /api/{tenantId}/{projectId}/block/ping
Belirli bir kiracı ve proje için API erişimini doğrulayan kimlik doğrulamalı ping uç noktası.
Yanıt (200 OK)
Ping Başarılı (kiracı id: {tenantId})
Yanıt (401 Yetkisiz)
{yetkilendirme hatasını açıklayan hata mesajı}
Blok Detaylarını Alma
GET /api/{tenantId}/{projectId}/block/{blockId}
Belirli bir analiz bloğuna dair yapılandırma, yürütme geçmişi ve meta veriler dahil olmak üzere kapsamlı bilgileri getirir.
Yol Parametreleri
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
tenantId |
GUID | Evet | Kiracı kimliği |
projectId |
GUID | Evet | Proje kimliği |
blockId |
GUID | Evet | Blok kimliği |
Yanıt (200 OK)
{
"blockId": "550e8400-e29b-41d4-a716-446655440000",
"notebookId": "660e8400-e29b-41d4-a716-446655440000",
"blockType": "Filter",
"blockTitle": "Tarih Aralığı Filtresi",
"blockDescription": "Son 30 gün verilerini filtreler",
"blockOrder": 0,
"configuration": "{\"filterType\": \"dateRange\", \"startDate\": \"2024-01-01\"}",
"isDisabled": false,
"dateCreated": "2024-01-15T10:30:00Z",
"dateModified": "2024-01-15T14:45:00Z",
"createdBy": "user@example.com",
"modifiedBy": "user@example.com",
"lastExecutionDate": "2024-01-15T14:45:00Z",
"lastExecutionStatus": "Success",
"executionCount": 12
}
Yanıt Alanları
| Alan | Tür | Açıklama |
|---|---|---|
blockId |
GUID | Blok için benzersiz tanımlayıcı |
notebookId |
GUID | Bu bloğun yer aldığı not defteri kimliği |
blockType |
string | Blok türü (Filtre, Hesaplayıcı, Uyarı vb.) |
blockTitle |
string | Blok için görüntülenen başlık |
blockDescription |
string | Bloğun amacını açıklayan açıklama |
blockOrder |
integer | Not defterindeki blok sırası (varsayılan: 0) |
configuration |
string | Blok ayarlarını içeren JSON dizisi |
isDisabled |
boolean | Blok devre dışı mı? |
dateCreated |
datetime | Blok oluşturulma zamanı |
dateModified |
datetime | Blok en son ne zaman değiştirildi |
createdBy |
string | Bloğu oluşturan kullanıcı |
modifiedBy |
string | Bloğu en son değiştiren kullanıcı |
lastExecutionDate |
datetime | Blok en son ne zaman çalıştırıldı |
lastExecutionStatus |
string | Son çalıştırma durumu |
executionCount |
integer | Blok kaç kez çalıştırıldı |
Hata Yanıtları
Bulunamadı (404):
{
"Error": "Blok bulunamadı",
"BlockId": "550e8400-e29b-41d4-a716-446655440000"
}
Bloğu Güncelleme
PUT /api/{tenantId}/{projectId}/block/{blockId}
Mevcut bir bloğun meta verilerini günceller. Belirtilen alanları güncellerken yürütme geçmişini korur.
İstek Gövdesi
{
"blockTitle": "Güncellenmiş Tarih Filtresi",
"blockDescription": "Özel tarih aralığı için veri filtreler",
"isDisabled": false
}
İstek Alanları
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
blockTitle |
string | Hayır | Blok için yeni başlık |
blockDescription |
string | Hayır | Blok için yeni açıklama |
isDisabled |
boolean | Hayır | Bloğu devre dışı bırakma durumu |
Yanıt (200 OK)
GET uç noktasındaki ile aynı yapıdaki güncellenmiş blok nesnesini döner.
Hata Yanıtları
Hatalı İstek (400):
Blok güncellenemedi.
Bloğu Silme
DELETE /api/{tenantId}/{projectId}/block/{blockId}
Bloğu ve tüm yürütme geçmişini kalıcı olarak not defterinden kaldırır. Bu işlem geri alınamaz.
Yanıt Kodları
204 İçerik Yok- Blok başarıyla silindi400 Hatalı İstek- Blok silinemedi401 Yetkisiz- Kimlik doğrulama yok veya erişim yok404 Bulunamadı- Blok bulunamadı
Blok Oluşturma
Blok oluşturma işlemi Block API değil, Notebook API üzerinden yapılır.
POST /api/{tenantId}/{projectId}/notebook/{notebookId}/blocks
Tam blok oluşturma dökümantasyonu için Notebook API sayfasına bakınız.
Uygulama Örnekleri
cURL
# Bağlantıyı test et (kimlik doğrulama yok)
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/block/unauthorized-ping"
# Bağlantıyı test et (kimlik doğrulamalı)
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/block/ping" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
# Blok detaylarını al
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/block/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
# Bloku güncelle
curl -X PUT "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/block/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"blockTitle": "Güncellenmiş Filtre", "isDisabled": false}'
# Bloku sil
curl -X DELETE "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/block/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
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 BlockManager {
constructor(token) {
this.token = token;
this.headers = {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
};
}
async getBlock(blockId) {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/block/${blockId}`;
const response = await fetch(url, { headers: this.headers });
if (response.ok) {
return await response.json();
} else if (response.status === 404) {
throw new Error('Blok bulunamadı');
} else {
throw new Error(`Blok alınamadı: ${response.status}`);
}
}
async updateBlock(blockId, updates) {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/block/${blockId}`;
const response = await fetch(url, {
method: 'PUT',
headers: this.headers,
body: JSON.stringify(updates)
});
if (response.ok) {
return await response.json();
} else {
throw new Error(`Blok güncellenemedi: ${response.status}`);
}
}
async deleteBlock(blockId) {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/block/${blockId}`;
const response = await fetch(url, {
method: 'DELETE',
headers: this.headers
});
return response.status === 204;
}
}
// Kullanım
const manager = new BlockManager('your-auth-token');
// Blok detaylarını al
const block = await manager.getBlock('block-guid');
console.log(`Blok: ${block.blockTitle} (${block.blockType})`);
// Bloku güncelle
const updated = await manager.updateBlock('block-guid', {
blockTitle: 'Güncellenmiş Başlık',
isDisabled: false
});
// Bloku sil
const deleted = await manager.deleteBlock('block-guid');
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 BlockManager:
def __init__(self, token):
self.headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
def get_block(self, block_id):
"""Blok detaylarını al."""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/block/{block_id}'
response = requests.get(url, headers=self.headers)
if response.ok:
return response.json()
elif response.status_code == 404:
raise Exception('Blok bulunamadı')
else:
raise Exception(f'Blok alınamadı: {response.status_code}')
def update_block(self, block_id, title=None, description=None, disabled=None):
"""Blok meta verilerini güncelle."""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/block/{block_id}'
payload = {}
if title is not None:
payload['blockTitle'] = title
if description is not None:
payload['blockDescription'] = description
if disabled is not None:
payload['isDisabled'] = disabled
response = requests.put(url, json=payload, headers=self.headers)
if response.ok:
return response.json()
else:
raise Exception(f'Blok güncellenemedi: {response.status_code}')
def delete_block(self, block_id):
"""Bloku sil."""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/block/{block_id}'
response = requests.delete(url, headers=self.headers)
return response.status_code == 204
# Kullanım
manager = BlockManager('your-auth-token')
# Bloku al
block = manager.get_block('block-guid')
print(f"Blok: {block['blockTitle']} ({block['blockType']})")
print(f"Çalıştırma sayısı: {block['executionCount']}")
# Bloku güncelle
updated = manager.update_block('block-guid', title='Yeni Başlık', disabled=False)
print(f"Güncellendi: {updated['blockTitle']}")
# Bloku sil
if manager.delete_block('block-guid'):
print('Blok başarıyla silindi')
C#
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
public class BlockReturn
{
public Guid BlockId { get; set; }
public Guid NotebookId { get; set; }
public string BlockType { get; set; }
public string BlockTitle { get; set; }
public string BlockDescription { get; set; }
public int BlockOrder { get; set; }
public string Configuration { get; set; }
public bool IsDisabled { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateModified { get; set; }
public string CreatedBy { get; set; }
public string ModifiedBy { get; set; }
public DateTime? LastExecutionDate { get; set; }
public string LastExecutionStatus { get; set; }
public int ExecutionCount { get; set; }
}
public class BlockApiClient
{
private readonly HttpClient _httpClient;
private readonly string _baseUrl;
private readonly Guid _tenantId;
private readonly Guid _projectId;
public BlockApiClient(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<BlockReturn> GetBlockAsync(Guid blockId)
{
var url = $"{_baseUrl}/api/{_tenantId}/{_projectId}/block/{blockId}";
var response = await _httpClient.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<BlockReturn>(json,
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
}
throw new Exception($"Blok alınamadı: {response.StatusCode}");
}
public async Task<BlockReturn> UpdateBlockAsync(Guid blockId, string title, string description, bool? isDisabled)
{
var url = $"{_baseUrl}/api/{_tenantId}/{_projectId}/block/{blockId}";
var payload = new
{
blockTitle = title,
blockDescription = description,
isDisabled = isDisabled
};
var content = new StringContent(
JsonSerializer.Serialize(payload),
Encoding.UTF8,
"application/json");
var response = await _httpClient.PutAsync(url, content);
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<BlockReturn>(json,
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
}
throw new Exception($"Blok güncellenemedi: {response.StatusCode}");
}
public async Task<bool> DeleteBlockAsync(Guid blockId)
{
var url = $"{_baseUrl}/api/{_tenantId}/{_projectId}/block/{blockId}";
var response = await _httpClient.DeleteAsync(url);
return response.StatusCode == System.Net.HttpStatusCode.NoContent;
}
}