SessionService
from skipcheck_tm1.services import SessionService Server sessions: every session logged in to the server (/Sessions), this one's
(ActiveSession), their users and threads, and closing another session.
To close this client's own session, close the Tm1Session or Tm1Client:
it sends ActiveSession/tm1.Close, and knows not to log in again. A closed
session stays listed in Sessions for a few seconds (5 to 9 in TM1 11.8).
List who's logged in, expanding each session's user:
# Every session on the server, with its user's name and its label
with_users = ODataQuery.none().select(Session.ID, Session.CONTEXT).expand(Session.USER, lambda user: user.select(User.NAME))
return [f"{session.id} {session.user.name if session.user else None} {session.context}" for session in tm1.sessions.list(with_users)]
Close other clients' sessions by their label, sparing this one:
# Close the sessions labelled "Nightly load", except this client's own
own = tm1.sessions.active_session(ODataQuery.none().select(Session.ID)).id
labelled = tm1.sessions.list(ODataQuery.none().select(Session.ID).filter(Session.CONTEXT.eq("Nightly load")))
for session in labelled:
if session.id is not None and session.id != own:
tm1.sessions.close(session.id)
The asyncio flavor, skipcheck_tm1.aio, has the same methods to await, on AsyncSessionService.
Members
list | Every session on the server, for an admin; expand User and Threads. |
get | The session, or a Tm1NotFoundError. |
active_session | This client's own session on the server. |
user | GET Sessions(id)/User. |
threads | What the session is running now. |
close | Ends another session; its client must log in again. |
list
list(query: ODataQuery | None = None, **options: Any) -> list[Session]GET Sessions: every session on the server, for an admin; expand User and Threads.
TM1 REST EntitySet Sessions
get
get(id: int, query: ODataQuery | None = None, **options: Any) -> SessionGET Sessions(id): the session, or a Tm1NotFoundError.
TM1 REST EntitySet Sessions
active_session
active_session(query: ODataQuery | None = None, **options: Any) -> SessionGET ActiveSession: this client's own session on the server.
TM1 REST Singleton ActiveSession
user
user(id: int, query: ODataQuery | None = None, **options: Any) -> UserGET Sessions(id)/User.
TM1 REST Navigation Session/User
threads
threads(id: int, query: ODataQuery | None = None, **options: Any) -> list[Thread]GET Sessions(id)/Threads: what the session is running now.
TM1 REST Navigation Session/Threads
close
close(id: int) -> Nonetm1.Close: ends another session; its client must log in again. Needs schema 10.2.2.5.
TM1 REST Action Session/Close