Tm1Session.Builder
import io.skipcheck.tm1.client.session.Tm1Session.Builder; Builds a Tm1Session. Only baseUrl and credentials are required.
Members
address | The server's address, such as http://tm1:8010. |
dialect | The kind of deployment, for address. |
baseUrl | The service root, such as http://localhost:8010/api/v1/. |
basicAuth | Basic authentication, for TM1 security modes 1 and 2. |
authenticator | How to log in. |
sessionContext | A label for the TM1 session, shown as its Context in Sessions and Threads, such as the application's name. |
impersonate | Logs in as user rather than as the credentials' own user, with TM1's TM1-Impersonate. |
timeouts | Timeouts by kind of work; Tm1Timeouts.DEFAULTS unless set. |
errorClassifier | How error responses are classified; Tm1ErrorClassifier.defaults unless set. |
jsonMapper | The mapper for request and response bodies; a plain JsonMapper unless set. |
observationRegistry | Where observations go. |
webClient | A Tm1Session.Builder to start from, such as Spring Boot's, so its customizations apply. |
connector | The HTTP connector. |
build | The 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
baseUrlisn'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;
nullcounts 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
sessionContextis 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
HttpClientreplaces such characters
Returns
- this builder
Throws
IllegalArgumentException- if
useris 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.