1818
1919@dataclass
2020class SessionInfo :
21+ """
22+ Represents information about a session.
23+ """
24+
2125 name : str
2226 size : str
2327 type : str
@@ -31,18 +35,38 @@ def from_specific_instance_details(cls, instance_details: InstanceSpecificDetail
3135
3236@dataclass
3337class AuraAPICredentials :
38+ """
39+ Represents the credentials required for accessing the Aura API.
40+
41+ Attributes:
42+ client_id (str): The client ID for authentication.
43+ client_secret (str): The client secret for authentication.
44+ tenant (Optional[str]): The tenant for authentication. Needed if a client belongs to multiple tenants.
45+ """
3446 client_id : str
3547 client_secret : str
3648 tenant : Optional [str ] = None
3749
3850
3951class GdsSessions :
52+ """
53+ Primary API class for managing GDS sessions hosted in Neo4j Aura.
54+ """
55+
4056 # Hardcoded neo4j user as sessions are always created with this user
4157 GDS_SESSION_USER = "neo4j"
4258
43- def __init__ (self , ds_connection : AuraAPICredentials ) -> None :
59+ def __init__ (self , api_credentials : AuraAPICredentials ) -> None :
60+ """
61+ Initializes a new instance of the GdsSessions class.
62+
63+ Args:
64+ api_credentials (AuraAPICredentials): The Aura API credentials used for establishing a connection.
65+ """
4466 self ._aura_api = AuraApi (
45- tenant_id = ds_connection .tenant , client_id = ds_connection .client_id , client_secret = ds_connection .client_secret
67+ tenant_id = api_credentials .tenant ,
68+ client_id = api_credentials .client_id ,
69+ client_secret = api_credentials .client_secret ,
4670 )
4771
4872 def get_or_create (
@@ -51,6 +75,19 @@ def get_or_create(
5175 size : SessionSizeByMemory ,
5276 db_connection : DbmsConnectionInfo ,
5377 ) -> AuraGraphDataScience :
78+ """
79+ Retrieves an existing session with the given session name and database connection,
80+ or creates a new session if one does not exist.
81+
82+ Args:
83+ session_name (str): The name of the session.
84+ size (SessionSizeByMemory): The size of the session specified by memory.
85+ db_connection (DbmsConnectionInfo): The database connection information.
86+
87+ Returns:
88+ AuraGraphDataScience: The session.
89+ """
90+
5491 connected_instance = self ._try_connect (session_name , db_connection )
5592 if connected_instance is not None :
5693 return connected_instance
@@ -101,6 +138,12 @@ def delete(self, session_name: str) -> bool:
101138 return False
102139
103140 def list (self ) -> List [SessionInfo ]:
141+ """
142+ Retrieves the list of GDS sessions visible by the user asscociated by the given api-credentials.
143+
144+ Returns:
145+ A list of SessionInfo objects representing the GDS sessions.
146+ """
104147 all_instances = self ._aura_api .list_instances ()
105148 instance_details = [
106149 self ._aura_api .list_instance (instance_id = instance .id )
0 commit comments