Class UserService

java.lang.Object
io.skipcheck.tm1.client.service.security.UserService

public final class UserService extends Object
Users: /Users, the session's own user, their groups, and disconnecting them.

Group membership is set whole, with setGroups(String, List): binding Groups in a user PATCH replaces them. TM1 (11.8) has no safe way to leave one group: a DELETE Users('u')/Groups('g')/$ref, which OData means as "remove the link", deletes the group, for everyone. This service never sends it.

Create a user in some groups, binding them by path:

// A user in two existing groups, bound by their paths
ODataPath groups = ODataPath.of("Groups");
return tm1.users()
	.create(UserPatch.builder()
		.name("alice")
		.password("initial-password")
		.bindGroups(groups.key("Planners"), groups.key("Sales"))
		.build());

Take a user out of one group by setting the rest:

// Groups are set whole: keep every group but Planners
return tm1.users()
	.groups("alice", ODataQuery.none().select(Group.NAME))
	.map(Group::name)
	.filter(group -> !group.equals("Planners"))
	.collectList()
	.flatMap(rest -> tm1.users().setGroups("alice", rest));

Lock a user out: disable them, then close their sessions.

// Stop the user logging in, then end the sessions they already have
return tm1.users()
	.update("alice", UserPatch.builder().enabled(false).build())
	.then(tm1.users().disconnect("alice"));
  • Constructor Details

    • UserService

      public UserService(Tm1Session session)
      A service sending its requests through session.
      Parameters:
      session - the session
  • Method Details

    • list

      @Tm1Endpoint("EntitySet Users") public reactor.core.publisher.Flux<User> list(ODataQuery query)
      GET Users, streamed.
      Parameters:
      query - what to select, expand, filter and order
      Returns:
      the users
    • get

      @Tm1Endpoint("EntitySet Users") public reactor.core.publisher.Mono<User> get(String name, ODataQuery query)
      GET Users('name'). User names match ignoring case and spaces.
      Parameters:
      name - the user's name
      query - what to select and expand
      Returns:
      the user, or a Tm1NotFoundException if there's none
    • activeUser

      @Tm1Endpoint("Singleton ActiveUser") public reactor.core.publisher.Mono<User> activeUser(ODataQuery query)
      GET ActiveUser: the user this session is for.
      Parameters:
      query - what to select and expand
      Returns:
      the user
    • create

      @Tm1Endpoint("EntitySet Users") public reactor.core.publisher.Mono<User> create(UserPatch user)
      POST Users: creates a user, in the groups the patch binds (UserPatch.Builder#bindGroups).
      Parameters:
      user - the new user; it needs a name, and a password for Basic security
      Returns:
      the user as created
    • update

      @Tm1Endpoint("EntitySet Users") public reactor.core.publisher.Mono<Void> update(String name, UserPatch patch)
      PATCH Users('name'): changes the properties the patch sets, such as Password or Enabled. TM1 (11.8) sends no ETag for a user, so there's no If-Match form.
      Parameters:
      name - the user's name
      patch - the changes, without Groups
      Returns:
      completes when the user is changed
      Throws:
      IllegalArgumentException - if the patch sets or binds Groups, which replaces them: use setGroups(String, List)
    • setGroups

      @Tm1Endpoint("EntitySet Users") @Tm1Endpoint("Navigation User/Groups") public reactor.core.publisher.Mono<Void> setGroups(String name, List<String> groups)
      PATCH Users('name') binding Groups: makes the user's groups exactly these, leaving any not listed.
      Parameters:
      name - the user's name
      groups - the names of every group the user should be in
      Returns:
      completes when the groups are set
    • delete

      @Tm1Endpoint("EntitySet Users") public reactor.core.publisher.Mono<Void> delete(String name)
      DELETE Users('name').
      Parameters:
      name - the user's name
      Returns:
      completes when the user is deleted
    • groups

      @Tm1Endpoint("Navigation User/Groups") public reactor.core.publisher.Flux<Group> groups(String name, ODataQuery query)
      GET Users('name')/Groups, streamed.
      Parameters:
      name - the user's name
      query - what to select
      Returns:
      the user's groups
    • sessions

      @Tm1Endpoint("Navigation User/Sessions") public reactor.core.publisher.Flux<Session> sessions(String name, ODataQuery query)
      GET Users('name')/Sessions, streamed: the user's sessions on the server.
      Parameters:
      name - the user's name
      query - what to select and expand
      Returns:
      the user's sessions
    • disconnect

      @Tm1Endpoint("Action User/Disconnect") public reactor.core.publisher.Mono<Void> disconnect(String name)
      tm1.Disconnect: closes every session the user has. Needs schema 10.2.2.6.
      Parameters:
      name - the user's name
      Returns:
      completes when they're disconnected