Blokbeheer

Analyseblokken ophalen, bijwerken en verwijderen

Beheer analyseblokken binnen notitieboeken. Blokken zijn de fundamentele analyseeenheden die datatransformaties, berekeningen, filteroperaties en waarschuwingen uitvoeren.

Connectiviteitstesten

Ongeautoriseerde Ping

GET /api/{tenantId}/{projectId}/block/unauthorized-ping

Testendpoint dat geen authenticatie vereist. Gebruik dit om te verifiëren dat de Block API toegankelijk is.

Respons

Ping geslaagd

Geauthentiseerde Ping

GET /api/{tenantId}/{projectId}/block/ping

Geauthenticeerd ping-endpoint om API-toegang voor een specifieke tenant en project te verifiëren.

Respons (200 OK)

Ping geslaagd (tenant id: {tenantId})

Respons (401 Unauthorized)

{foutmelding die autorisatiefout beschrijft}

Blokdetails ophalen

GET /api/{tenantId}/{projectId}/block/{blockId}

Haalt uitgebreide informatie op over een specifiek analyseblok inclusief configuratie, uitvoeringsgeschiedenis en metadata.

Padparameters

Parameter Type Vereist Beschrijving
tenantId GUID Ja De tenant-identificatie
projectId GUID Ja De projectidentificatie
blockId GUID Ja De blokidentificatie

Respons (200 OK)

{
  "blockId": "550e8400-e29b-41d4-a716-446655440000",
  "notebookId": "660e8400-e29b-41d4-a716-446655440000",
  "blockType": "Filter",
  "blockTitle": "Datumbereikfilter",
  "blockDescription": "Filtert data voor de laatste 30 dagen",
  "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
}

Responsvelden

Veld Type Beschrijving
blockId GUID Unieke identificatie voor het blok
notebookId GUID ID van het notitieboek dat dit blok bevat
blockType string Type blok (Filter, Calculator, Alert, etc.)
blockTitle string Weergavetitel van het blok
blockDescription string Beschrijving van het doel van het blok
blockOrder integer Volgorde van het blok in het notitieboek (standaard: 0)
configuration string JSON-string met blokinstellingen
isDisabled boolean Of het blok is uitgeschakeld
dateCreated datetime Wanneer het blok is aangemaakt
dateModified datetime Wanneer het blok voor het laatst is aangepast
createdBy string Gebruiker die het blok heeft aangemaakt
modifiedBy string Gebruiker die het blok voor het laatst heeft gewijzigd
lastExecutionDate datetime Wanneer het blok voor het laatst is uitgevoerd
lastExecutionStatus string Status van de laatste uitvoering
executionCount integer Aantal keren dat het blok is uitgevoerd

Foutresponsen

Niet gevonden (404):

{
  "Error": "Blok niet gevonden",
  "BlockId": "550e8400-e29b-41d4-a716-446655440000"
}

Blok bijwerken

PUT /api/{tenantId}/{projectId}/block/{blockId}

Werkt de metadata van een bestaand blok bij. Behoudt de uitvoeringsgeschiedenis en werkt alleen de opgegeven velden bij.

Verzoekbody

{
  "blockTitle": "Bijgewerkt datumfilter",
  "blockDescription": "Filtert data voor aangepast datum bereik",
  "isDisabled": false
}

Verzoekvelden

Veld Type Vereist Beschrijving
blockTitle string Nee Nieuwe titel voor het blok
blockDescription string Nee Nieuwe beschrijving voor het blok
isDisabled boolean Nee Of het blok uitgeschakeld moet worden

Respons (200 OK)

Retourneert het bijgewerkte blokobject met dezelfde structuur als het GET-endpoint.

Foutresponsen

Ongeldig verzoek (400):

Bijwerken van het blok mislukt.

Blok verwijderen

DELETE /api/{tenantId}/{projectId}/block/{blockId}

Verwijdert permanent een blok en alle bijbehorende uitvoeringsgeschiedenis uit het notitieboek. Deze bewerking kan niet ongedaan gemaakt worden.

Responscodes

  • 204 No Content - Blok succesvol verwijderd
  • 400 Bad Request - Verwijderen van het blok mislukt
  • 401 Unauthorized - Niet geauthenticeerd of geen toegang
  • 404 Not Found - Blok niet gevonden

Blokken aanmaken

Het aanmaken van blokken gebeurt via de Notebook API, niet via de Block API.

POST /api/{tenantId}/{projectId}/notebook/{notebookId}/blocks

Zie Notebook API voor volledige documentatie over het aanmaken van blokken.

Implementatievoorbeelden

cURL

# Connectiviteit testen (zonder auth)
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/block/unauthorized-ping"

# Connectiviteit testen (geauthenticeerd)
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"

# Blokdetails ophalen
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"

# Blok bijwerken
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": "Bijgewerkt Filter", "isDisabled": false}'

# Blok verwijderen
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 niet gevonden');
    } else {
      throw new Error(`Ophalen blok mislukt: ${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(`Bijwerken blok mislukt: ${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;
  }
}

// Gebruik
const manager = new BlockManager('your-auth-token');

// Blokdetails ophalen
const block = await manager.getBlock('block-guid');
console.log(`Blok: ${block.blockTitle} (${block.blockType})`);

// Blok bijwerken
const updated = await manager.updateBlock('block-guid', {
  blockTitle: 'Bijgewerkte Titel',
  isDisabled: false
});

// Blok verwijderen
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):
        """Blokdetails ophalen."""
        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 niet gevonden')
        else:
            raise Exception(f'Ophalen blok mislukt: {response.status_code}')

    def update_block(self, block_id, title=None, description=None, disabled=None):
        """Blokmetadata bijwerken."""
        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'Bijwerken blok mislukt: {response.status_code}')

    def delete_block(self, block_id):
        """Een blok verwijderen."""
        url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/block/{block_id}'
        response = requests.delete(url, headers=self.headers)
        return response.status_code == 204

# Gebruik
manager = BlockManager('your-auth-token')

# Blok ophalen
block = manager.get_block('block-guid')
print(f"Blok: {block['blockTitle']} ({block['blockType']})")
print(f"Aantal uitvoeringen: {block['executionCount']}")

# Blok bijwerken
updated = manager.update_block('block-guid', title='Nieuwe Titel', disabled=False)
print(f"Bijgewerkt: {updated['blockTitle']}")

# Blok verwijderen
if manager.delete_block('block-guid'):
    print('Blok succesvol verwijderd')

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($"Ophalen blok mislukt: {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($"Bijwerken blok mislukt: {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;
    }
}