skipcheck

TM1 client · Docs · Sessions and logins

Tm1Session.Builder

import io.skipcheck.tm1.client.session.Tm1Session.Builder;

Builds a Tm1Session. Only baseUrl and credentials are required.

Members

addressThe server's address, such as http://tm1:8010.
dialectThe kind of deployment, for address.
baseUrlThe service root, such as http://localhost:8010/api/v1/.
basicAuthBasic authentication, for TM1 security modes 1 and 2.
authenticatorHow to log in.
sessionContextA label for the TM1 session, shown as its Context in Sessions and Threads, such as the application's name.
impersonateLogs in as user rather than as the credentials' own user, with TM1's TM1-Impersonate.
timeoutsTimeouts by kind of work; Tm1Timeouts.DEFAULTS unless set.
errorClassifierHow error responses are classified; Tm1ErrorClassifier.defaults unless set.
jsonMapperThe mapper for request and response bodies; a plain JsonMapper unless set.
observationRegistryWhere observations go.
webClientA Tm1Session.Builder to start from, such as Spring Boot's, so its customizations apply.
connectorThe HTTP connector.
buildThe session.

address

Tm1Session.Builder address(String address)

The server's address, such as http://tm1:8010: its scheme, host and HTTP port. The service root comes from the dialect, Tm1Dialect.V11 unless set, which adds /api/v1/. Use baseUrl to give the service root itself.

Parameters

address
the server's address

Returns

this builder

Throws

IllegalArgumentException
if the address doesn't fit the dialect

dialect

Tm1Session.Builder dialect(Tm1Dialect dialect)

The kind of deployment, for address. Tm1Dialect.V11 unless set.

Parameters

dialect
the dialect

Returns

this builder

baseUrl

Tm1Session.Builder baseUrl(String baseUrl)

The service root, such as http://localhost:8010/api/v1/. A missing trailing / is added.

Parameters

baseUrl
an absolute URL with no query or fragment

Returns

this builder

Throws

IllegalArgumentException
if baseUrl isn't absolute or has a query or fragment

basicAuth

Tm1Session.Builder basicAuth(String user, String password)

Basic authentication, for TM1 security modes 1 and 2: shorthand for authenticator(Tm1Authenticator.basic(user, password)).

Parameters

user
the TM1 user name
password
the password; null counts as empty

Returns

this builder

authenticator

Tm1Session.Builder authenticator(Tm1Authenticator authenticator)

How to log in: TM1's own security, CAM, or credentials of your own. Asked for credentials on every login.

Parameters

authenticator
supplies the credentials

Returns

this builder

sessionContext

Tm1Session.Builder sessionContext(String sessionContext)

A label for the TM1 session, shown as its Context in Sessions and Threads, such as the application's name. Sent with the login.

It's a setting of the session, not of a view: TM1 keeps one label per session and the last request to send one wins, so views sharing a session can't each have their own. A different label needs a different session.

Parameters

sessionContext
the label, at most 250 characters

Returns

this builder

Throws

IllegalArgumentException
if sessionContext is longer than 250 characters

impersonate

Tm1Session.Builder impersonate(String user)

Logs in as user rather than as the credentials' own user, with TM1's TM1-Impersonate. The credentials must be an administrator's or a data administrator's, and nobody can impersonate an administrator. TM1 decides the identity at login and keeps it for the session, so one session is one identity; for many users, use a Tm1SessionPool.

A refused login fails with Tm1ErrorKind.UNKNOWN_USER (no such user), Tm1ErrorKind.IMPERSONATION_REFUSED (not allowed), or Tm1ErrorKind.CREDENTIAL_REJECTED (wrong credentials, or the user is disabled: TM1 answers both alike). The client never falls back to another identity.

Parameters

user
the TM1 user to act as; matched ignoring case and spaces, as TM1 does. A name with characters outside ASCII goes out as UTF-8, which is how TM1 (11.8) reads the header; that needs the default Reactor Netty connector, as the JDK's HttpClient replaces such characters

Returns

this builder

Throws

IllegalArgumentException
if user is blank, which TM1 would take as no impersonation at all, or has a control character

timeouts

Tm1Session.Builder timeouts(Tm1Timeouts timeouts)

Timeouts by kind of work; Tm1Timeouts.DEFAULTS unless set.

Parameters

timeouts
the timeouts

Returns

this builder

errorClassifier

Tm1Session.Builder errorClassifier(Tm1ErrorClassifier classifier)

How error responses are classified; Tm1ErrorClassifier.defaults unless set.

Parameters

classifier
the classifier

Returns

this builder

jsonMapper

Tm1Session.Builder jsonMapper(ObjectMapper mapper)

The mapper for request and response bodies; a plain JsonMapper unless set.

Parameters

mapper
the mapper

Returns

this builder

observationRegistry

Tm1Session.Builder observationRegistry(ObservationRegistry observations)

Where observations go: the session's own (tm1.session.login, tm1.session.close) and WebClient's per request (http.client.requests). None are recorded unless set.

Parameters

observations
the registry

Returns

this builder

webClient

Tm1Session.Builder webClient(WebClient.Builder webClient)

A Tm1Session.Builder to start from, such as Spring Boot's, so its customizations apply. It's copied, not changed. The connector is still set as described in connector.

Parameters

webClient
the builder to copy

Returns

this builder

connector

Tm1Session.Builder connector(ClientHttpConnector connector)

The HTTP connector. Unless set, a Reactor Netty connector with gzip and the connect timeout. With another connector, connect and request timeouts are that connector's own settings, and so is its pool: keep its idle connections under TM1's 90 seconds (the default connector closes them after 60).

Parameters

connector
the connector

Returns

this builder

build

Tm1Session build()

The session. Nothing is sent to TM1 until the first request.

Returns

a new session

Throws

IllegalStateException
if the base URL or credentials aren't set

Also in the Javadoc.