Class Tm1Session.Builder

java.lang.Object
io.skipcheck.tm1.client.session.Tm1Session.Builder
Enclosing class:
Tm1Session

public static final class Tm1Session.Builder extends Object
Builds a Tm1Session. Only baseUrl and credentials are required.
  • Method Details

    • address

      public 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

      public Tm1Session.Builder dialect(Tm1Dialect dialect)
      The kind of deployment, for address(String). Tm1Dialect.V11 unless set.
      Parameters:
      dialect - the dialect
      Returns:
      this builder
    • baseUrl

      public 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

      public Tm1Session.Builder basicAuth(String user, @Nullable 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

      public 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

      public 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

      public 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

      public Tm1Session.Builder timeouts(Tm1Timeouts timeouts)
      Timeouts by kind of work; Tm1Timeouts.DEFAULTS unless set.
      Parameters:
      timeouts - the timeouts
      Returns:
      this builder
    • errorClassifier

      public Tm1Session.Builder errorClassifier(Tm1ErrorClassifier classifier)
      How error responses are classified; Tm1ErrorClassifier.defaults() unless set.
      Parameters:
      classifier - the classifier
      Returns:
      this builder
    • jsonMapper

      public Tm1Session.Builder jsonMapper(tools.jackson.databind.ObjectMapper mapper)
      The mapper for request and response bodies; a plain JsonMapper unless 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

      public Tm1Session.Builder webClient(WebClient.Builder webClient)
      A WebClient.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

      public 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

      public 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