Liking cljdoc? Tell your friends :D

openadr3.vtn.handler.common

Shared handler utilities: ID generation, metadata, body coercion, pagination, search-window construction, error responses.

The VTN's storage layer is canonically ZonedDateTime / Duration. Wire-format request bodies arrive with string datetimes (parsed JSON); the coerce-*-body helpers here normalise them to the storage canon before reaching add-metadata and the storage protocol.

Shared handler utilities: ID generation, metadata, body coercion,
pagination, search-window construction, error responses.

The VTN's storage layer is canonically `ZonedDateTime` / `Duration`.
Wire-format request bodies arrive with string datetimes (parsed JSON);
the `coerce-*-body` helpers here normalise them to the storage canon
before reaching `add-metadata` and the storage protocol.
raw docstring

add-metadataclj

(add-metadata body object-type)

Add objectMetadata fields to a request body. Sets id, createdDateTime, modificationDateTime (both ZonedDateTime), and objectType.

Add objectMetadata fields to a request body.
Sets id, createdDateTime, modificationDateTime (both ZonedDateTime),
and objectType.
sourceraw docstring

bad-requestclj

(bad-request detail)

400 Bad Request response.

400 Bad Request response.
sourceraw docstring

coerce-event-bodyclj

(coerce-event-body body)

Parse string datetime/duration fields in an EVENT request body to the storage canon (ZonedDateTime / Duration). Idempotent.

Parse string datetime/duration fields in an EVENT request body to the
storage canon (ZonedDateTime / Duration). Idempotent.
sourceraw docstring

coerce-program-bodyclj

(coerce-program-body body)

Parse string datetime/duration fields in a PROGRAM request body.

Parse string datetime/duration fields in a PROGRAM request body.
sourceraw docstring

conflictclj

(conflict detail)

409 Conflict response.

409 Conflict response.
sourceraw docstring

event-search-windowclj

(event-search-window query-params)

Build a search-window opts map for /events listing.

When dateStart and/or dateEnd are present in the query, returns a map with :date-start / :date-end as ZonedDateTimes (BETWEEN semantics). Otherwise returns a map with :active-from / :active-until set to [now, now + 2 days] for zone-neutral overlap semantics.

Build a search-window opts map for /events listing.

When dateStart and/or dateEnd are present in the query, returns a map
with :date-start / :date-end as ZonedDateTimes (BETWEEN semantics).
Otherwise returns a map with :active-from / :active-until set to
[now, now + 2 days] for zone-neutral overlap semantics.
sourceraw docstring

get-paramclj

(get-param params k)

Get a query param by keyword, falling back to string key. Legba uses string keys for query params.

Get a query param by keyword, falling back to string key.
Legba uses string keys for query params.
sourceraw docstring

new-idclj

(new-id)

Generate a new object ID (random UUID string).

Generate a new object ID (random UUID string).
sourceraw docstring

not-foundclj

(not-found resource-type id)

404 Not Found response.

404 Not Found response.
sourceraw docstring

not-implementedclj

(not-implemented)

501 Not Implemented response.

501 Not Implemented response.
sourceraw docstring

paginateclj

(paginate coll {:keys [skip limit]})

Apply skip/limit pagination to a collection. Defaults: skip=0, limit=50 (OpenADR max).

Apply skip/limit pagination to a collection.
Defaults: skip=0, limit=50 (OpenADR max).
sourceraw docstring

parse-paginationclj

(parse-pagination query-params)

Extract skip/limit from query params, coercing to integers. Handles both keyword and string keys (Legba uses string keys).

Extract skip/limit from query params, coercing to integers.
Handles both keyword and string keys (Legba uses string keys).
sourceraw docstring

touch-metadataclj

(touch-metadata stored updated)

Merge update body into stored object, preserving metadata fields. The update body overrides stored fields, but id, createdDateTime, and objectType are always preserved from stored. modificationDateTime is set to now (ZonedDateTime).

Merge update body into stored object, preserving metadata fields.
The update body overrides stored fields, but id, createdDateTime, and
objectType are always preserved from stored. modificationDateTime is
set to now (ZonedDateTime).
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close