- Index
- »
- fan.haystack
- »
- Client
Client
class Client : Obj
Client manages a network connection to a haystack server.
URI of endpoint such as "http://host/api/myProj/"
Call "about" operation to query server summary info
Call the given REST operation with its request and return the response
Close the session by sending the close op
Commit a set of diffs
Evaluate an Axon expression and return the result
Open with URI of project such as "http://host/api/myProj/"
Call "read" operation to read a record that matches the given filter
Call "read" operation to read a record all recs which match the given filter
Call "read" operation to read a record by its identifier
Call "read" operation to read a list of records by their identifiers
Return uri.toStr
Dict about()
Call "about" operation to query server summary info. Also see HTTP API.
Obj? call(Str op, Obj? req := null, Bool checked := true)
Call the given REST operation with its request and return the response. If req is null, then an empty grid used for request. If the checked flag is true and server returns an error grid, then raise CallErr, otherwise return the result itself.
Through the v4 REST API both the request and response are always a Grid; the v5 API may use other data types. The parameter and return types are typed as Obj? to bind the future v5 signature at the JVM level now, but currently a Grid must be passed for req.
Void close()
Close the session by sending the close op.
Grid commit(Grid req)
Commit a set of diffs. The req parameter must be a grid with a "commit" tag in the grid.meta. The rows are the items to commit. Return result as Grid or or raise CallErr if server returns error grid.
Also see HTTP API.
Examples:
// add new record
tags := ["site":Marker.val, "dis":"Example Site"])
toCommit := Etc.makeDictGrid(["commit":"add"], tags)
client.commit(toCommit)
// update dis tag
changes := ["id": orig->id, "mod":orig->mod, "dis": "New dis"]
toCommit := Etc.makeDictGrid(["commit":"update"], changes)
client.commit(toCommit)
Obj? eval(Str expr)
Evaluate an Axon expression and return the result. Through the v4 REST API the result is always a Grid; the v5 API may return other data types. Raise CallErr if server returns error grid. Also see HTTP API.
static Client open(Uri uri, Str username, Str password, [Str:Obj]? opts := null)
Open with URI of project such as "http://host/api/myProj/".
Throw IOErr for network/connection error or AuthErr if
credentials are not authenticated.
Dict? read(Str filter, Bool checked := true)
Call "read" operation to read a record that matches the given filter. If there is more than one record, then it is undefined which one is returned. If there are no matches then return null or raise UnknownRecException based on checked flag. Raise CallErr if server returns error grid. Also see HTTP API.
Grid readAll(Str filter)
Call "read" operation to read a record all recs which match the given filter. Raise CallErr if server returns error grid. Also see HTTP API.
Dict? readById(Obj id, Bool checked := true)
Call "read" operation to read a record by its identifier. If the record is not found then return null or raise UnknownRecException based on checked flag. Raise CallErr if server returns error grid. Also see HTTP API.
Grid readByIds(Obj[] ids, Bool checked := true)
Call "read" operation to read a list of records by their identifiers. Return a grid where each row of the grid maps to the respective id list (indexes line up). If checked is true and any one of the ids cannot be resolved then raise UnknownRecErr for first id not resolved. If checked is false, then each id not found has a row where every cell is null. Raise CallErr if server returns error grid. Also see HTTP API.
virtual Str toStr()
Return uri.toStr
const Uri : uri
URI of endpoint such as "http://host/api/myProj/". This URI always ends in a trailing slash.