session
Session service module
Attributes
Classes
ActivitySessionService
Bases: BaseService
Activity session service layer
Initializes the ActivitySessionService with the given SQLAlchemy and Neo4j sessions.
Parameters:
-
sa_session
(SASession
) –The SQLAlchemy session.
-
neo4j_session
(NJSession
) –The Neo4j session.
Attributes
agent_service
instance-attribute
agent_service = AgentService(
sa_session=sa_session, neo4j_session=neo4j_session
)
namespace_service
instance-attribute
namespace_service = NamespaceService(
sa_session=sa_session, neo4j_session=neo4j_session
)
session_participant_dao
instance-attribute
session_participant_dao = ActivitySessionParticipantDao(
session=sa_session
)
user_service
instance-attribute
user_service = UserService(
sa_session=sa_session, neo4j_session=neo4j_session
)
Functions
bind_session_to_participant
bind_session_to_participant(
namespace: str,
activity_session: str,
participant: str,
db_transact: bool = True,
) -> None
Binds a session to a participant.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace.
-
session_pkid
(str
) –The primary key of the session.
-
participant_pkid
(str
) –The primary key of the participant.
-
db_transact
(bool
, default:True
) –Whether to commit the transaction. Defaults to True.
Raises:
-
ServiceError
–If an error occurs during the binding operation.
create_activity_session
create_activity_session(
namespace: str,
name: str,
settings: SessionResourceSettings | None = None,
enabled: bool = True,
auto_created: bool = False,
managed: bool = False,
data: str | None = None,
description: str | None = None,
participant_pkids: Union[str, List[str]] | None = None,
db_transact: bool = True,
) -> ActivitySession
Create an activity session within a namespace.
Parameters:
-
namespace_pkid
(str
) –The primary key ID of the namespace.
-
name
(str
) –The name of the activity session.
-
enabled
(bool
, default:True
) –Whether the activity session is enabled. Defaults to True.
-
description
(str
, default:None
) –The description of the activity session. Defaults to None.
-
participant_pkids
(str or List[str]
, default:None
) –The primary key ID(s) of the participant(s) to be associated with the activity session. Defaults to None.
-
db_transact
(bool
, default:True
) –Flag indicating whether to commit the transaction. Defaults to True.
Returns:
-
ActivitySession
–orm.ActivitySession: The newly created activity session.
Raises:
-
ServiceError
–If an error occurs during the operation.
delete_session
Soft deletes an activity session resource
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace.
-
activity_session_pkid
(str
) –The primary key of the activity session to delete.
-
db_transact
(bool
, default:True
) –Whether to commit the transaction. Defaults to True.
Raises:
-
ServiceError
–If the activity session is already deleted or if an error occurs during the deletion process.
get_session
get_session(
namespace: str,
activity_session: str,
error_deleted: bool = True,
error_disabled: bool = True,
) -> ActivitySession
Retrieve an activity session by its primary key.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace.
-
activity_session
(str
) –The primary key of the activity session.
-
filter_deleted
(bool
) –Whether to filter out deleted activity sessions. Defaults to True.
-
filter_disabled
(bool
) –Whether to filter out disabled activity sessions. Defaults to True.
Returns:
-
ActivitySession
–orm.ActivitySession: The retrieved activity session.
session_truncate
Truncates session state
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace.
-
session_pkid
(str
) –The primary key of the session.
-
db_transact
(bool
, default:True
) –Whether to commit the transaction. Defaults to True.
Raises:
-
ServiceError
–If an error occurs during the unbinding operation.
unbind_session_from_participant
unbind_session_from_participant(
namespace: str,
activity_session: str,
participant: str,
db_transact: bool = True,
) -> None
Unbinds a session from a participant.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace.
-
session_pkid
(str
) –The primary key of the session to unbind.
-
participant_pkid
(str
) –The primary key of the participant to unbind.
-
db_transact
(bool
, default:True
) –Whether to commit the transaction. Defaults to True.
Raises:
-
ServiceError
–If an error occurs during the unbinding operation.
undelete_session
Undeletes the specified activity sessions.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace.
-
activity_session_pkid
(str
) –The primary key of the activity session to undelete.
-
db_transact
(bool
, default:True
) –Whether to commit the transaction. Defaults to True.
Raises:
-
ServiceError
–If an error occurs during the undelete operation.
update_session
update_session(
namespace: str,
activity_session: str,
name: str | None = None,
description: str | None = None,
settings: SessionResourceSettings | None = None,
data: str | None = None,
managed: bool | None = None,
enabled: bool | None = None,
db_transact: bool = True,
) -> ActivitySession
Update an activity session with the given parameters.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace.
-
activity_session_pkid
(str
) –The primary key of the activity session.
-
name
(str
, default:None
) –The name of the activity session.
-
description
(str
, default:None
) –The description of the activity session.
-
settings
(SessionResourceSettings
, default:None
) –The settings of the activity session.
-
data
(str
, default:None
) –The data of the activity session.
-
managed
(bool
, default:None
) –The managed flag of the activity session.
-
enabled
(bool
, default:None
) –The enabled flag of the activity session.
Returns:
-
ActivitySession
–orm.ActivitySession: The updated activity session object.
Raises:
-
ServiceError
–If an error occurs during the update operation.