CodamAIDocs
Topicdone

Which endpoints a model has

The fixed set of operations per model (create, read, update, delete, query, history, rollback, file) and how the endpoint list on the model switches individual operations on and off.

Variants
standard setempty endpoint list = everything except historyUPDATE enables PUT and PATCHREAD without QUERYHISTORY / HISTORY_ROLLBACKUPLOAD / DOWNLOADsingleton modelabstract model (hub API)file modelnot present → 404

What this is about

For every model, the generator creates a REST controller with a fixed set of operations. All paths start with /api/rest followed by the model’s API path. The API path is built from the folder in the hub and the model name in lower case, for example /crm/customer.

The complete set

This is the set of a normal model with everything switched on. {base} stands for /api/rest/crm/customer.

What you want to doMethod and pathBody
createPOST {base}/createJSON
create, with filesPOST {base}/create/uploadmultipart
read, choose the fieldsPOST {base}/read/{id}JSON with response
read, quick lookGET {base}/read/{id}none, always returns *
replacePUT {base}/update/{id}JSON
replace, with filesPUT {base}/update/{id}/uploadmultipart
updatePATCH {base}/update/{id}JSON
update, with filesPATCH {base}/update/{id}/uploadmultipart
deleteDELETE {base}/delete/{id}none
search, filter, pagePOST {base}/queryJSON with response and parameter
read historyPOST {base}/{id}/historyJSON
roll back to an old revisionPOST {base}/{id}/rollback/{revision}JSON with response
download a fileGET {base}/{id}/filenone

The endpoint list on the model

In the hub, a model gets a list of endpoints. Each entry has a type, and the generator turns it into operations:

Which endpoint type creates which operations?
Type in the listGenerated operations
CREATEPOST /create (and /create/upload)
READPOST /read/{id} and GET /read/{id}, no search
LIST, QUERY or SEARCHPOST /query
UPDATEPUT /update/{id} and PATCH /update/{id} (each also /upload)
PATCHonly PATCH /update/{id}
DELETEDELETE /delete/{id}
HISTORY_READ, HISTORY_QUERYPOST /{id}/history, audited models only
HISTORY_ROLLBACKPOST /{id}/rollback/{revision}, audited models only
DOWNLOADGET /{id}/file, file models only
UPLOADthe /upload variants, only relevant for file models
unknown typenothing; the build prints a warning

Three more rules that are easy to overlook:

Empty list
the model names no endpoints at all
  • create, read, update, patch, delete, query, upload and download are generated
  • history and rollback are not, you have to add them explicitly
Reading is not searching
READ and LIST are separate
  • READ only creates reading by id
  • If you need a list, add LIST (or QUERY)
History needs auditing
the model must be audited
  • without auditing on the model, no history or rollback endpoints are created, whatever the list says

Each list entry can also say who may use the endpoint: a role of its own, the model’s base role, or public without sign-in. That is covered in Model roles.

The special forms

Endpoints per kind of model

When: the usual case

The complete set as above, filtered by the endpoint list. Each object is addressed by its id in the path.

When: The model is marked as a singleton: exactly one object per scope.

The paths have no id; the server finds the one object by itself: POST /create, POST /read, GET /read, PUT /update, PATCH /update, DELETE /delete, GET /file, POST /history, POST /rollback/{revision}. There is no search. A second create fails with 400 object-already-exists|use-update, an update without an existing object with 404 no-data-exists|use-create. See Singletons.

When: The model has subtypes, e.g. customer with privatecustomer and businesscustomer.

The model gets a hub API with the same paths. It forwards each request to the API of the concrete subtype: when writing based on @type in the payload, when reading and deleting based on the type stored for the id. See Abstract models.

When: The model stores a file.

In addition there is GET /{id}/file for downloading, as soon as DOWNLOAD or READ is listed. The /upload variants exist as soon as UPLOAD, CREATE or UPDATE is listed: a file model that cannot accept a file would be useless. See Files.

Which endpoints does my model have?

Check in this order
  1. 1
    Client
    Open the installation's OpenAPI description. It lists every generated endpoint with its payload
    It is the authoritative answer, because it is built from the generated code.
  2. 2
    Admin
    Look at the model in the hub: which types are in the endpoint list? Is the model audited, a singleton, abstract, a file model?
  3. 3
    Client
    Try it: the response tells you what is going on
    Result: 404 → the endpoint does not exist. 403 → the endpoint exists, the role is missing. 401 → the token is missing or expired.

What deliberately does not exist

ExpectationHow it is
POST /save that creates or updates depending on the iddoes not exist; the client chooses between create and update based on the id
field selection via query parameter (?fields=)the field selection is in the body, see Field selection
search via GET with parameters in the URLsearch runs through POST /query
bulk operations for many objects in one requestnot provided; related objects can be written nested
an endpoint that lists all modelsthe OpenAPI description is that overview

Pitfalls

Sources in the code and the knowledge base
  • CDMS/cdms-generator – api/ApiProcessor, ApiSingletonProcessor, ApiHubProcessor, AbstractProcessor (isUploadExposed, isDownloadExposed)
  • CDMS/cdms-generator – loader/CdmsYamlLoader.parseEndpoints
  • CDMS/cdms-rest-api – AbstractRestApi, AbstractRestSingletonApi, AbstractHubApi
  • documentation/20-api/01-endpunkte.md, 05-api-guide/03-was-geht.md
Search