Package org.rapidcontext.app.model
Class ApiUtil
java.lang.Object
org.rapidcontext.app.model.ApiUtil
A set of utility methods for API responses, etc.
- Version:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDeletes a storage object or path.Load objects from storage and serializes the results.Search for object metadata in storage.static DictCreates or extracts an options object from a value.static ObjectReturns a serialized representation of an object and its metadata.static ObjectReturns a serialized representation of an object.static booleanWrites a data object to the storage.static booleanUpdates and/or moves an existing data object in the storage.
-
Method Details
-
options
Creates or extracts an options object from a value. If the value isn't a dictionary, a new one will be created with a default key set to the specified value.- Parameters:
defaultKey- the default keyvalue- the value to convert- Returns:
- an options dictionary
-
lookup
Search for object metadata in storage.- Parameters:
storage- the storage to searchpath- the base path to queryperm- the access permission requiredopts- the query options- Returns:
- a stream of metadata for matching objects
-
load
Load objects from storage and serializes the results.- Parameters:
storage- the storage to searchpath- the base path to queryperm- the access permission requiredopts- the query options- Returns:
- a stream of serialized matching objects
-
store
Writes a data object to the storage.- Parameters:
storage- the storage to modifypath- the storage pathdata- the data object- Returns:
- true if the data was successfully written, or false otherwise
-
update
Updates and/or moves an existing data object in the storage. The object must be serializable to a dictionary, which may be merged with a dictionary of changes. Keys with a value will be overwritten, and keys with a null value will be removed. Omitted keys will be will be left unmodified in the source object.- Parameters:
storage- the storage to modifysrc- the source storage pathdst- the destination storage pathpatch- the data object changes, or null- Returns:
- true if the data was successfully written, or false otherwise
-
delete
Deletes a storage object or path.- Parameters:
storage- the storage to modifypath- the storage path- Returns:
- true if the data was successfully removed, or false otherwise
-
serialize
Returns a serialized representation of an object and its metadata.- Parameters:
meta- the object metadataobj- the object to serializeopts- the serialization optionslimitedTypes- limit allowed object value types- Returns:
- the serialized representation of the object, or null if no suitable serialization existed
-
serialize
Returns a serialized representation of an object.- Parameters:
path- the storage pathobj- the object to serializeopts- the serialization optionslimitedTypes- limit allowed object value types- Returns:
- the serialized representation of the object, or null if no suitable serialization existed
-