skipcheck

TM1 client · Docs · Security

UserService

import { UserService } from "@skipcheck/tm1-client";

Users: /Users, the session's own user, their groups, and disconnecting them.

Group membership is set whole, with setGroups: 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
const groups = ODataPath.of("Groups");
const alice = UserPatch.builder().name("alice").password("initial-password").bindGroups(groups.key("Planners"), groups.key("Sales")).build();
return tm1.users.create(alice);

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

// Groups are set whole: keep every group but Planners
const groups = await tm1.users.groups("alice", ODataQuery.none().select(Group.Fields.Name)).toArray();
const rest = groups.map((group) => group.Name!).filter((name) => name !== "Planners");
await 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
await tm1.users.update("alice", UserPatch.builder().enabled(false).build());
await tm1.users.disconnect("alice");

Members

listGET Users, streamed.
getThe user, or a Tm1NotFoundException if there's none.
activeUserThe user this session is for.
createCreates a user, in the groups the patch binds (UserPatch.builder().bindGroups(…)).
updateChanges the properties the patch sets, such as Password or Enabled.
setGroupsPATCH Users('name') binding Groups.
deleteDELETE Users('name').
groupsGET Users('name')/Groups, streamed.
sessionsGET Users('name')/Sessions, streamed.
disconnectCloses every session the user has.

list

list(query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<User>

GET Users, streamed.

TM1 REST EntitySet Users

get

get(name: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<User>

GET Users('name'): the user, or a Tm1NotFoundException if there's none. User names match ignoring case and spaces.

TM1 REST EntitySet Users

activeUser

activeUser(query?: ODataQuery | null, options?: Tm1CallOptions): Promise<User>

GET ActiveUser: the user this session is for.

TM1 REST Singleton ActiveUser

create

create(user: UserPatch, options?: Tm1CallOptions): Promise<User>

POST Users: creates a user, in the groups the patch binds (UserPatch.builder().bindGroups(…)). It needs a name, and a password for Basic security; returns the user as created.

TM1 REST EntitySet Users

update

update(name: string, patch: UserPatch, options?: Tm1CallOptions): Promise<void>

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. Throws a RangeError (at once) if the patch sets or binds Groups, which replaces them: use setGroups.

TM1 REST EntitySet Users

setGroups

setGroups(name: string, groups: readonly string[], options?: Tm1CallOptions): Promise<void>

PATCH Users('name') binding Groups: makes the user's groups exactly these, leaving any not listed.

TM1 REST EntitySet Users Navigation User/Groups

delete

delete(name: string, options?: Tm1CallOptions): Promise<void>

DELETE Users('name').

TM1 REST EntitySet Users

groups

groups(name: string, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Group>

GET Users('name')/Groups, streamed.

TM1 REST Navigation User/Groups

sessions

sessions(name: string, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Session>

GET Users('name')/Sessions, streamed: the user's sessions on the server.

TM1 REST Navigation User/Sessions

disconnect

disconnect(name: string, options?: Tm1CallOptions): Promise<void>

tm1.Disconnect: closes every session the user has. Needs schema 10.2.2.6.

TM1 REST Action User/Disconnect