Class Tm1Session.Builder
java.lang.Object
io.skipcheck.tm1.client.session.Tm1Session.Builder
- Enclosing class:
Tm1Session
Builds a
Tm1Session. Only baseUrl and credentials are required.-
Method Summary
Modifier and TypeMethodDescriptionThe server's address, such ashttp://tm1:8010: its scheme, host and HTTP port.authenticator(Tm1Authenticator authenticator) How to log in: TM1's own security, CAM, or credentials of your own.The service root, such ashttp://localhost:8010/api/v1/.Basic authentication, for TM1 security modes 1 and 2: shorthand forauthenticator(Tm1Authenticator.basic(user, password)).build()The session.connector(ClientHttpConnector connector) The HTTP connector.dialect(Tm1Dialect dialect) The kind of deployment, foraddress(String).errorClassifier(Tm1ErrorClassifier classifier) How error responses are classified;Tm1ErrorClassifier.defaults()unless set.impersonate(String user) Logs in asuserrather than as the credentials' own user, with TM1'sTM1-Impersonate.jsonMapper(tools.jackson.databind.ObjectMapper mapper) The mapper for request and response bodies; a plainJsonMapperunless set.observationRegistry(io.micrometer.observation.ObservationRegistry observations) Where observations go: the session's own (tm1.session.login,tm1.session.close) and WebClient's per request (http.client.requests).sessionContext(String sessionContext) A label for the TM1 session, shown as itsContextinSessionsandThreads, such as the application's name.timeouts(Tm1Timeouts timeouts) Timeouts by kind of work;Tm1Timeouts.DEFAULTSunless set.webClient(WebClient.Builder webClient) AWebClient.Builderto start from, such as Spring Boot's, so its customizations apply.
-
Method Details
-
address
The server's address, such ashttp://tm1:8010: its scheme, host and HTTP port. The service root comes from the dialect,Tm1Dialect.V11unless set, which adds/api/v1/. UsebaseUrlto 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
The kind of deployment, foraddress(String).Tm1Dialect.V11unless set.- Parameters:
dialect- the dialect- Returns:
- this builder
-
baseUrl
The service root, such ashttp://localhost:8010/api/v1/. A missing trailing/is added.- Parameters:
baseUrl- an absolute URL with no query or fragment- Returns:
- this builder
- Throws:
IllegalArgumentException- ifbaseUrlisn't absolute or has a query or fragment
-
basicAuth
Basic authentication, for TM1 security modes 1 and 2: shorthand forauthenticator(Tm1Authenticator.basic(user, password)).- Parameters:
user- the TM1 user namepassword- the password;nullcounts as empty- Returns:
- this builder
-
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
A label for the TM1 session, shown as itsContextinSessionsandThreads, 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- ifsessionContextis longer than 250 characters
-
impersonate
Logs in asuserrather than as the credentials' own user, with TM1'sTM1-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 aTm1SessionPool.A refused login fails with
Tm1ErrorKind.UNKNOWN_USER(no such user),Tm1ErrorKind.IMPERSONATION_REFUSED(not allowed), orTm1ErrorKind.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'sHttpClientreplaces such characters- Returns:
- this builder
- Throws:
IllegalArgumentException- ifuseris blank, which TM1 would take as no impersonation at all, or has a control character
-
timeouts
Timeouts by kind of work;Tm1Timeouts.DEFAULTSunless set.- Parameters:
timeouts- the timeouts- Returns:
- this builder
-
errorClassifier
How error responses are classified;Tm1ErrorClassifier.defaults()unless set.- Parameters:
classifier- the classifier- Returns:
- this builder
-
jsonMapper
The mapper for request and response bodies; a plainJsonMapperunless set.- Parameters:
mapper- the mapper- Returns:
- this builder
-
observationRegistry
public Tm1Session.Builder observationRegistry(io.micrometer.observation.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
AWebClient.Builderto start from, such as Spring Boot's, so its customizations apply. It's copied, not changed. The connector is still set as described inconnector.- Parameters:
webClient- the builder to copy- Returns:
- this builder
-
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
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
-