Draft an ODCS contract for a saved view, optionally sampling, saving and binding it
const url = 'http://localhost:11044/api/v1/admin/kg/views/example/contract';const options = { method: 'POST', headers: {'X-Embabel-Api-Key': '<X-Embabel-Api-Key>', 'Content-Type': 'application/json'}, body: '{"args":{"additionalProperty":"example"},"bind":true,"persist":true,"sample":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:11044/api/v1/admin/kg/views/example/contract \ --header 'Content-Type: application/json' \ --header 'X-Embabel-Api-Key: <X-Embabel-Api-Key>' \ --data '{ "args": { "additionalProperty": "example" }, "bind": true, "persist": true, "sample": true }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The view’s name, as GET /views lists it.
Query Parameters
Section titled “Query Parameters”Optional, and never needed: the call always acts as the signed-in principal. Naming the principal changes nothing; naming anyone else is refused with 403.
Request Body
Section titled “Request Body”Optional; omitted is a declaration-only preview that reads no data and writes nothing. sample runs the view under a row cap (with args for a parameterized view) to infer types; persist writes the draft into the world; bind also pins the view to it in observe mode and needs persist. Each defaults to false
How to draft an ODCS contract for a named view, and how far to go with it.
object
Arguments for a parameterized view. Used only when sampling.
object
Also pin the view to the new contract in observe mode. Requires persist.
Write the draft into the world. False previews it and writes nothing.
Run the view under a row cap to infer types and suggestions. Off by default: generation reads the declaration only unless asked to touch data.
Example generated
{ "args": { "additionalProperty": "example" }, "bind": true, "persist": true, "sample": true}Responses
Section titled “Responses”The drafted contract and what was done with it
A drafted ODCS contract for a named view, in draft status and unreviewed.
object
One entry per column the view projects, in the order the draft lists them.
One drafted column, and whether its entry was read or inferred.
object
declared (read from the view) or sampled (inferred from rows).
ODCS logical type, present only when a sample agreed unanimously.
The column’s name, as the view’s RETURN aliases it.
What the sample SUGGESTS but does not prove, as ODCS extension keys.
The contract’s id: a name-based (version 5) UUID over the world and view, so regenerating for the same view yields the same id.
What was written and bound, and what an author still has to do.
object
Whether the view now pins this contract in observe mode.
Human-readable notes: what was not done, and why.
Rows read while sampling. Zero when the view was not run.
Whether sampling stopped at its row cap.
World-relative path written, or null when this was a preview.
declaration or sample — how much of this draft came from data.
ODCS status of the generated document. Always draft.
The contract’s version: 0.1.0 for every generated draft, pre-1.0 because it is unreviewed.
The name of the view the contract was drafted for.
The contract document. Review this before promoting anything.
Example generated
{ "columns": [ { "evidence": "example", "logicalType": "example", "name": "example", "suggestions": [ "example" ] } ], "contractId": "example", "disposition": { "bound": true, "notes": [ "example" ], "sampleRows": 1, "sampleTruncated": true, "savedAs": "example" }, "mode": "example", "status": "example", "version": "example", "view": "example", "yaml": "example"}The view’s output shape is not contractable, or the draft could not be saved
A refusal to draft a contract, naming what about the view made it impossible.
object
Why no contract was drafted: no such view, a projection that cannot be read (*, a bare variable, an unaliased or duplicate column), or a write the world refused.
Example generated
{ "error": "example"}No authenticated principal
A refusal carrying only a human-readable reason.
object
What went wrong, in the terms the caller can act on.
Example generated
{ "error": "example"}username names someone other than the signed-in principal
A refusal carrying only a human-readable reason.
object
What went wrong, in the terms the caller can act on.
Example generated
{ "error": "example"}
