Table of Contents

Class DataBlockController

Namespace
Datafication.Server.Core.Controllers
Assembly
Datafication.Server.Core.dll

REST API controller for managing and querying DataBlock instances.

[ApiController]
[Authorize]
public class DataBlockController : ControllerBase
Inheritance
object
ControllerBase
DataBlockController

Constructors

DataBlockController(IDataBlockRegistry, IConnectorRegistry, ISinkRegistry, IOptions<DataBlockServerOptions>)

Initializes a new instance of the DataBlockController class.

public DataBlockController(IDataBlockRegistry registry, IConnectorRegistry connectorRegistry, ISinkRegistry sinkRegistry, IOptions<DataBlockServerOptions> options)

Parameters

registry IDataBlockRegistry

The DataBlock registry service.

connectorRegistry IConnectorRegistry

The connector registry service.

sinkRegistry ISinkRegistry

The sink registry service.

options IOptions<DataBlockServerOptions>

The server configuration options.

Methods

AddRowToDataBlock(string, AddRowRequest)

Adds a new row to a DataBlock.

[HttpPost("datablocks/{id}/rows")]
[Authorize(Policy = "DataBlockAdmin")]
public ActionResult<RowOperationResponse> AddRowToDataBlock(string id, AddRowRequest request)

Parameters

id string

The unique identifier of the DataBlock.

request AddRowRequest

The row data to add.

Returns

ActionResult<RowOperationResponse>

A confirmation of the row addition.

ClearRegistryCache()

Clears the registry cache to free up memory and force fresh loads.

[HttpPost("registry/clear-cache")]
[Authorize(Policy = "DataBlockAdmin")]
public ActionResult ClearRegistryCache()

Returns

ActionResult

Success message if cache cleared successfully.

ExportRegistryState()

Exports the entire registry state as a serialized DataBlockSnapshot. This includes all DataBlock metadata and their serialized data.

[HttpGet("registry/export")]
[Authorize(Policy = "DataBlockAdmin")]
public ActionResult ExportRegistryState()

Returns

ActionResult

The registry state as a DataBlockSnapshot.

FetchDataBlock(string, int, int, string?, string)

Fetches data from a specific DataBlock with optional filtering and pagination.

[HttpGet("datablocks/{id}")]
public Task<ActionResult> FetchDataBlock(string id, int offset = 0, int limit = 100, string? columns = null, string format = "json")

Parameters

id string

The unique identifier of the DataBlock.

offset int

The number of rows to skip (default: 0).

limit int

The maximum number of rows to return (default: 100).

columns string

Comma-separated list of column names to include.

format string

The output format (json, csv, html).

Returns

Task<ActionResult>

The DataBlock data in the requested format.

ForceRegistryMaintenance()

Forces registry maintenance to run immediately, cleaning up expired entries.

[HttpPost("registry/maintenance")]
[Authorize(Policy = "DataBlockAdmin")]
public ActionResult ForceRegistryMaintenance()

Returns

ActionResult

Success message if maintenance completed successfully.

GetComprehensiveAnalytics()

Generates a comprehensive analytics report for the registry.

[HttpGet("registry/analytics/comprehensive")]
[Authorize]
public Task<ActionResult> GetComprehensiveAnalytics()

Returns

Task<ActionResult>

A detailed analytics report as a DataBlock.

GetDataBlockInfo(string)

Gets summary information for a specific DataBlock using the Info() method. Returns column names, data types, null counts, and non-null counts.

[HttpGet("datablocks/{id}/info")]
[Authorize]
public Task<ActionResult> GetDataBlockInfo(string id)

Parameters

id string

The unique identifier of the DataBlock.

Returns

Task<ActionResult>

Summary information for the DataBlock as JSON.

GetDataBlockSchema(string)

Gets the schema information for a specific DataBlock.

[HttpGet("datablocks/{id}/schema")]
public ActionResult<DataBlockSchemaResponse> GetDataBlockSchema(string id)

Parameters

id string

The unique identifier of the DataBlock.

Returns

ActionResult<DataBlockSchemaResponse>

The schema information for the DataBlock.

GetOptimizationOpportunities()

Identifies optimization opportunities in the registry.

[HttpGet("registry/analytics/optimization")]
[Authorize]
public Task<ActionResult> GetOptimizationOpportunities()

Returns

Task<ActionResult>

Optimization recommendations as a DataBlock.

GetRegisteredSinks()

Gets information about all registered sinks.

[HttpGet("sinks")]
public ActionResult GetRegisteredSinks()

Returns

ActionResult

A list of registered sinks with their details.

GetRegistryAnalytics()

Gets the registry as a queryable DataBlock for analytics and reporting. This allows treating the registry metadata as data for analysis.

[HttpGet("registry/analytics")]
[Authorize]
public Task<ActionResult> GetRegistryAnalytics()

Returns

Task<ActionResult>

The registry metadata as a DataBlock.

GetUsagePatterns()

Analyzes DataBlock usage patterns and provides insights.

[HttpGet("registry/analytics/usage-patterns")]
[Authorize]
public Task<ActionResult> GetUsagePatterns()

Returns

Task<ActionResult>

Usage pattern analysis as a DataBlock.

ImportRegistryState(DataBlockSnapshot)

Imports registry state from a DataBlockSnapshot, replacing the current state. WARNING: This will clear all existing DataBlocks in the registry.

[HttpPost("registry/import")]
[Authorize(Policy = "DataBlockAdmin")]
public ActionResult ImportRegistryState(DataBlockSnapshot snapshot)

Parameters

snapshot DataBlockSnapshot

The DataBlockSnapshot containing the state to import.

Returns

ActionResult

Success message if imported successfully.

InsertRowInDataBlock(string, int, AddRowRequest)

Inserts a row at a specific index in a DataBlock.

[HttpPost("datablocks/{id}/rows/{index}")]
[Authorize(Policy = "DataBlockAdmin")]
public ActionResult<RowOperationResponse> InsertRowInDataBlock(string id, int index, AddRowRequest request)

Parameters

id string

The unique identifier of the DataBlock.

index int

The index where the row should be inserted.

request AddRowRequest

The row data to insert.

Returns

ActionResult<RowOperationResponse>

A confirmation of the row insertion.

ListDataBlocks()

Lists all registered DataBlocks with their metadata.

[HttpGet("datablocks")]
public ActionResult<IEnumerable<DataBlockSummary>> ListDataBlocks()

Returns

ActionResult<IEnumerable<DataBlockSummary>>

A list of DataBlock summaries.

QueryDataBlock(string, DataBlockQueryRequest)

Executes a comprehensive query on a DataBlock with support for filtering, sorting, aggregation, grouping, window functions, merging, and more.

[HttpPost("datablocks/{id}/query")]
[Authorize]
public Task<ActionResult> QueryDataBlock(string id, DataBlockQueryRequest request)

Parameters

id string

The unique identifier of the DataBlock to query.

request DataBlockQueryRequest

The query request containing all operations to apply.

Returns

Task<ActionResult>

The query results in the requested format.

QueryRegistry(RegistryQueryRequest)

Queries the registry using DataBlock operations for advanced analytics.

[HttpPost("registry/query")]
[Authorize]
public Task<ActionResult> QueryRegistry(RegistryQueryRequest query)

Parameters

query RegistryQueryRequest

The query parameters for filtering and analysis.

Returns

Task<ActionResult>

Query results as a DataBlock.

RegisterDataBlock(DataBlockRegistrationRequest)

Registers a new DataBlock or replaces an existing one. Supports both manual data registration and connector-based data loading.

[HttpPost("datablocks")]
[Authorize(Policy = "DataBlockAdmin")]
public Task<ActionResult> RegisterDataBlock(DataBlockRegistrationRequest request)

Parameters

request DataBlockRegistrationRequest

The DataBlock registration request.

Returns

Task<ActionResult>

A confirmation of the registration.

RemoveRowFromDataBlock(string, int)

Removes a row from a DataBlock.

[HttpDelete("datablocks/{id}/rows/{index}")]
[Authorize(Policy = "DataBlockAdmin")]
public ActionResult<RowOperationResponse> RemoveRowFromDataBlock(string id, int index)

Parameters

id string

The unique identifier of the DataBlock.

index int

The index of the row to remove.

Returns

ActionResult<RowOperationResponse>

A confirmation of the row removal.

TransformDataBlockUsingSink(string, string, Dictionary<string, object>?, int, int?, string?)

Transforms a DataBlock using a registered sink with optional configuration.

[HttpPost("datablocks/{dataBlockId}/transform/{sinkId}")]
public Task<ActionResult> TransformDataBlockUsingSink(string dataBlockId, string sinkId, Dictionary<string, object>? sinkOptions = null, int offset = 0, int? limit = null, string? columns = null)

Parameters

dataBlockId string

The unique identifier of the DataBlock.

sinkId string

The sink identifier (e.g., "pdf", "excel").

sinkOptions Dictionary<string, object>

Optional configuration options for the sink as JSON object.

offset int

The number of rows to skip (default: 0).

limit int?

The maximum number of rows to include (default: all).

columns string

Comma-separated list of column names to include.

Returns

Task<ActionResult>

The transformed data in the sink's output format.

UnregisterDataBlock(string)

Removes a DataBlock from the registry.

[HttpDelete("datablocks/{id}")]
[Authorize(Policy = "DataBlockAdmin")]
public ActionResult UnregisterDataBlock(string id)

Parameters

id string

The unique identifier of the DataBlock to remove.

Returns

ActionResult

A confirmation of the removal.

UpdateDataBlockMetadata(string, DataBlockMetadataUpdateRequest)

Updates metadata for an existing DataBlock without modifying the actual data. This is useful for correcting typos in names, updating descriptions, or changing tags.

[HttpPatch("datablocks/{id}/metadata")]
[Authorize(Policy = "DataBlockAdmin")]
public ActionResult<DataBlockMetadataUpdateResponse> UpdateDataBlockMetadata(string id, DataBlockMetadataUpdateRequest request)

Parameters

id string

The unique identifier of the DataBlock to update.

request DataBlockMetadataUpdateRequest

The metadata update request containing the fields to change.

Returns

ActionResult<DataBlockMetadataUpdateResponse>

A confirmation of the metadata update with details of what changed.

UpdateRowInDataBlock(string, int, UpdateRowRequest)

Updates an existing row in a DataBlock.

[HttpPut("datablocks/{id}/rows/{index}")]
[Authorize(Policy = "DataBlockAdmin")]
public ActionResult<RowOperationResponse> UpdateRowInDataBlock(string id, int index, UpdateRowRequest request)

Parameters

id string

The unique identifier of the DataBlock.

index int

The index of the row to update.

request UpdateRowRequest

The new row data.

Returns

ActionResult<RowOperationResponse>

A confirmation of the row update.