API Exposure Guide

Automatic Asset Mutations

Auto-CRUD endpoints for REST and GraphQL that enforce data types and uniqueness.

Automatic Asset Mutations (Auto-CRUD)

Whenever Rescile detects a known asset type (either a .csv file exists or its schema is defined via a module.toml), it automatically generates item-level mutation endpoints.

These endpoints replace raw string/CSV manipulation with strict JSON/GraphQL type-safety. They enforce mandatory fields, expected data types, and uniqueness constraints.

GraphQL Interface

Rescile auto-generates GraphQL input objects based on the asset’s schema and extends the Mutation type with intent-specific operations: Add<Type>, Change<Type>, and Delete<Type>.

mutation CreateNewVM {
  AddVm(input: {
    name: "web-server-01",
    tenant: "finance",
    cores: 4
  }) {
    success
    message
  }
}

REST Interface

Dynamic JSON endpoints are automatically mounted for Auto-CRUD operations.

  • POST /api/mutations/:asset (ADD): Inserts a single JSON record. Returns 409 Conflict if the primary key already exists.
  • PUT /api/mutations/:asset/:name (CHANGE): Merges the provided JSON payload with the existing record. Returns 404 Not Found if the item doesn’t exist.
  • DELETE /api/mutations/:asset/:name (DELETE): Deletes the matching record.

Example:

POST /api/mutations/vm
Content-Type: application/json

{
  "name": "web-server-01",
  "tenant": "finance",
  "cores": 4
}