skipcheck

TM1 client · Docs · The client

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 staticGET of one entity or value.
list staticGET of a collection, read item by item as itemType.
bytes staticGET of raw bytes, such as a document's Content, streamed with Tm1Session.stream.
put staticPUT of raw bytes, as application/octet-stream, such as a document's Content.
text staticGET of plain text, such as Configuration/ProductVersion/$value.
postList staticPOST whose response is a collection, read item by item as itemType.
post staticCreate an entity, or invoke an action.
patch staticChange the properties in body, leaving the rest as they are.
delete staticDELETE.
withQueryA copy with these query options instead.
withHeaderA copy with a header added or replaced, such as If-Match.
withTimeoutA copy that may go timeout without receiving any data before it fails, instead of the session's request timeout.
requiresA copy that's only sent if the server defines capability.
requirementWhat this request needs the server to define, if anything.
ifMatchA copy sent with If-Match.
methodThe HTTP method.
pathThe resource path, relative to the service root.
queryThe query options.
headersThe headers this request adds, in the order they were added.
bodyThe body, serialized as JSON when sent, or null for none.
responseHow the response body is read.
typeThe class the response, or each item of a collection, is read as.
timeoutThis request's own timeout, if it has one; otherwise the session's applies.
isIdempotentWhether sending this twice has the same effect as sending it once.
relativeUriThe encoded path and query relative to the service root, e.g.
toStringMETHOD relative-uri, unencoded, for logs.

get

static
static <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

static
static <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

static
static 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

static
static 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

static
static Tm1Request<String> text(ODataPath path)

GET of plain text, such as Configuration/ProductVersion/$value.

Parameters

path
the resource path

Returns

the request

postList

static
static <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

static
static <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 null for an empty object
type
the class the response is read as: Void.class to ignore it, String.class to read it as text

Returns

the request

patch

static
static 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

static
static 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

true for 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.