Tm1Request
import io.skipcheck.tm1.client.Tm1Request;One TM1 REST call, described but not sent: the method, path, query, headers and body, and how to read the response.
Every service method is built on one of these. The same request can be sent on its own
(the service's ordinary methods do that) or added to a $batch, so anything the
client can do one request at a time, it can also batch. Requests are immutable.
// A cube's name, read as plain JSON
Tm1Request<JsonNode> cube = Tm1Request.get(ODataPath.of("Cubes").key("Sales"), ODataQuery.none().select("Name"),
JsonNode.class);
// An action with no answer
Tm1Request<Void> reserve = Tm1Request.post(ODataPath.of("Cubes").key("Sales").action("tm1.Reserve"), Map.of(),
Void.class);
Members
get static | GET of one entity or value. |
list static | GET of a collection, read item by item as itemType. |
bytes static | GET of raw bytes, such as a document's Content, streamed with Tm1Session.stream. |
put static | PUT of raw bytes, as application/octet-stream, such as a document's Content. |
text static | GET of plain text, such as Configuration/ProductVersion/$value. |
postList static | POST whose response is a collection, read item by item as itemType. |
post static | Create an entity, or invoke an action. |
patch static | Change the properties in body, leaving the rest as they are. |
delete static | DELETE. |
withQuery | A copy with these query options instead. |
withHeader | A copy with a header added or replaced, such as If-Match. |
withTimeout | A copy that may go timeout without receiving any data before it fails, instead of the session's request timeout. |
requires | A copy that's only sent if the server defines capability. |
requirement | What this request needs the server to define, if anything. |
ifMatch | A copy sent with If-Match. |
method | The HTTP method. |
path | The resource path, relative to the service root. |
query | The query options. |
headers | The headers this request adds, in the order they were added. |
body | The body, serialized as JSON when sent, or null for none. |
response | How the response body is read. |
type | The class the response, or each item of a collection, is read as. |
timeout | This request's own timeout, if it has one; otherwise the session's applies. |
isIdempotent | Whether sending this twice has the same effect as sending it once. |
relativeUri | The encoded path and query relative to the service root, e.g. |
toString | METHOD relative-uri, unencoded, for logs. |
get
staticstatic <T> Tm1Request<T> get(ODataPath path, ODataQuery query, Class<T> type) GET of one entity or value.
Parameters
path- the resource path
query- the query options
type- the class the response is read as
Returns
- the request
list
staticstatic <T> Tm1Request<T> list(ODataPath path, ODataQuery query, Class<T> itemType) GET of a collection, read item by item as itemType.
Parameters
path- the collection's path
query- the query options
itemType- the class each item is read as
Returns
- the request
bytes
staticstatic Tm1Request<DataBuffer> bytes(ODataPath path) GET of raw bytes, such as a document's Content, streamed with
Tm1Session.stream. Each buffer is the subscriber's to release
(DataBufferUtils.release), or to hand on to something that does, such as
DataBufferUtils.write.
Parameters
path- the resource path
Returns
- the request
put
staticstatic Tm1Request<Void> put(ODataPath path, Publisher<DataBuffer> content) PUT of raw bytes, as application/octet-stream, such as a document's
Content. TM1 (11.8) refuses a chunked body (400, with no message), so the
bytes are gathered and sent with their Content-Length: the whole content is
held in memory while it's sent. If the session has to log in again, the request is
sent once more and content subscribed again, so it should be one that can
be: DataBufferUtils.read of a file is.
Parameters
path- the resource path
content- the bytes
Returns
- the request
text
staticstatic Tm1Request<String> text(ODataPath path) GET of plain text, such as Configuration/ProductVersion/$value.
Parameters
path- the resource path
Returns
- the request
postList
staticstatic <T> Tm1Request<T> postList(ODataPath path, Object body, Class<T> itemType) POST whose response is a collection, read item by item as itemType:
an action returning Collection(...), such as tm1.CheckRules.
Parameters
path- the action's path
body- the parameters, written as JSON
itemType- the class each item is read as
Returns
- the request
post
staticstatic <T> Tm1Request<T> post(ODataPath path, Object body, Class<T> type) POST: create an entity, or invoke an action. Actions always get a JSON body
(an empty object if there are no parameters), since TM1 refuses an action without a
JSON content type. With Void.class the response is ignored.
Parameters
path- the collection or action path
body- the entity or action parameters, or
nullfor an empty object type- the class the response is read as:
Void.classto ignore it,String.classto read it as text
Returns
- the request
patch
staticstatic Tm1Request<Void> patch(ODataPath path, Object body) PATCH: change the properties in body, leaving the rest as they are.
Parameters
path- the entity's path
body- the properties to change
Returns
- the request
delete
staticstatic Tm1Request<Void> delete(ODataPath path) DELETE.
Parameters
path- the path of the entity to delete
Returns
- the request
withQuery
Tm1Request<T> withQuery(ODataQuery query)A copy with these query options instead.
Parameters
query- the query options
Returns
- the copy
withHeader
Tm1Request<T> withHeader(String name, String value) A copy with a header added or replaced, such as If-Match.
Parameters
name- the header name
value- the header value
Returns
- the copy
withTimeout
Tm1Request<T> withTimeout(Duration timeout) A copy that may go timeout without receiving any data before it fails,
instead of the session's request timeout. For calls TM1 only answers when the work
is done, such as a long process run.
Parameters
timeout- the longest wait for data; must be positive
Returns
- the copy
requires
Tm1Request<T> requires(Tm1Capability capability) A copy that's only sent if the server defines capability: before sending,
the session checks the server's $metadata and otherwise fails with
Tm1UnsupportedOperationException, without
calling the server. Service methods for newer endpoints declare it.
Parameters
capability- what the request needs the server to define
Returns
- the copy
requirement
Optional<Tm1Capability> requirement()What this request needs the server to define, if anything.
Returns
- the capability, or empty
ifMatch
Tm1Request<T> ifMatch(String etag) A copy sent with If-Match: etag, failing with 412 if the entity has changed
since.
Parameters
etag- the entity's ETag
Returns
- the copy
method
HttpMethod method()The HTTP method.
Returns
- the method
path
ODataPath path()The resource path, relative to the service root.
Returns
- the path
query
ODataQuery query()The query options.
Returns
- the query, possibly
ODataQuery.none
headers
Map<String,String> headers()The headers this request adds, in the order they were added.
Returns
- an unmodifiable map of header names to values
body
Object body() The body, serialized as JSON when sent, or null for none.
Returns
- the body, or
null
response
Tm1Request.Response response()How the response body is read.
Returns
- the response kind
type
Class<T> type()The class the response, or each item of a collection, is read as.
Returns
- the type
timeout
Optional<Duration> timeout()This request's own timeout, if it has one; otherwise the session's applies.
Returns
- the timeout, or empty
isIdempotent
boolean isIdempotent()Whether sending this twice has the same effect as sending it once: GET, PUT and DELETE are; POST (process runs, cell writes, creates) and PATCH aren't. The client never retries a non-idempotent request by itself.
Returns
truefor GET, PUT, DELETE and HEAD
relativeUri
String relativeUri() The encoded path and query relative to the service root, e.g.
Cubes('Sales')?$select=Name.
Returns
- the relative URI
toString
String toString()METHOD relative-uri, unencoded, for logs.
Also in the Javadoc.