Application Modules

REST API for Assets

Manage asset data via REST endpoints to support reading, full mutations, partial writes, and deletions.

REST API for Assets

The rescile backend exposes a REST API under /api/assets to manage native CSV asset files. This interface enables developers to build custom web applications (like table editors) that can read and mutate the graph data.

Note: Asset mutation endpoints (POST/PUT) require enterprise features. Use the /api/features endpoint to verify if the admin_assets feature is available.

API Interfaces

The API supports reading, full replacements, and partial writes (updates/deletions) using multipart/form-data.

1. List Assets

  • URL: /api/assets or /api/assets/
  • Method: GET
  • Response: Returns a JSON array containing the list of available .csv asset files (e.g., ["application.csv", "server.csv"]).

2. Read Asset

  • URL: /api/assets/{filename}
  • Method: GET
  • Response: Returns the raw text content of the CSV file. Returns 404 if the file does not exist.

3. Mutate Asset (Writes)

  • URL: /api/assets/{filename}
  • Method: POST or PUT
  • Content-Type: multipart/form-data

The mutation endpoint accepts one of three fields in the form data to dictate how the file is processed:

A. Full Overwrite (data)

Replaces the entire content of the CSV file.

  • Field Name: data
  • Value: The complete CSV string (including headers).
  • Example:
    const fd = new FormData();
    fd.append('data', 'name,customer\ninst1,ydc\ninst2,ydc');
    fetch('/api/assets/instance.csv', { method: 'POST', body: fd });
    

B. Partial Write / Update (update)

Updates existing rows or appends new rows based on the primary key (typically the first column).

  • Field Name: update
  • Value: A CSV string containing the headers and the row(s) to be updated or added.
  • Note: Only modifies matched rows and leaves all other entries intact.

C. Partial Write / Delete (remove)

Removes specific rows based on the primary key.

  • Field Name: remove
  • Value: A CSV string containing the header of the primary key and the keys of the row(s) to delete.
  • Note: This effectively deletes the respective record(s) without needing to re-send the whole dataset.

Live Update and Build Status Integration

To provide real-time feedback when the backend is processing CSV changes and generating a new graph, you can integrate live updates into your frontend.

1. Build Logs Stream

When a mutation is triggered, you can display live build logs by connecting to the Server-Sent Events (SSE) endpoint:

  • URL: /api/build/stream
  • Method: GET

Listen to messages until the stream sends the BUILD_COMPLETE event. For more details, see Streaming Graph Rebuilds.

2. Polling Engine Status

Background tasks might still be updating the enterprise graph. You can poll the backend to check if an update is currently running:

  • URL: /api/engine-info
  • Method: GET
  • Response: Returns a JSON object with the boolean field is_publishing. Use this to show a global “Update Running” banner, and auto-refresh your application’s data when is_publishing transitions from true to false.