1818
1919@dataclass
2020class SessionInfo :
21+ """
22+ Represents information about a session.
23+
24+ Attributes:
25+ name (str): The name of the session.
26+ size (str): The size of the session.
27+ """
28+
2129 name : str
2230 size : str
2331 type : str
@@ -31,18 +39,39 @@ def from_specific_instance_details(cls, instance_details: InstanceSpecificDetail
3139
3240@dataclass
3341class AuraAPICredentials :
42+ """
43+ Represents the credentials required for accessing the Aura API.
44+
45+ Attributes:
46+ client_id (str): The client ID for authentication.
47+ client_secret (str): The client secret for authentication.
48+ tenant (Optional[str]): The tenant for authentication. Needed if a client belongs to multiple tenants.
49+ """
50+
3451 client_id : str
3552 client_secret : str
3653 tenant : Optional [str ] = None
3754
3855
3956class GdsSessions :
57+ """
58+ Primary API class for managing GDS sessions hosted in Neo4j Aura.
59+ """
60+
4061 # Hardcoded neo4j user as sessions are always created with this user
4162 GDS_SESSION_USER = "neo4j"
4263
43- def __init__ (self , ds_connection : AuraAPICredentials ) -> None :
64+ def __init__ (self , api_credentials : AuraAPICredentials ) -> None :
65+ """
66+ Initializes a new instance of the GdsSessions class.
67+
68+ Args:
69+ api_credentials (AuraAPICredentials): The Aura API credentials used for establishing a connection.
70+ """
4471 self ._aura_api = AuraApi (
45- tenant_id = ds_connection .tenant , client_id = ds_connection .client_id , client_secret = ds_connection .client_secret
72+ tenant_id = api_credentials .tenant ,
73+ client_id = api_credentials .client_id ,
74+ client_secret = api_credentials .client_secret ,
4675 )
4776
4877 def get_or_create (
@@ -51,6 +80,19 @@ def get_or_create(
5180 size : SessionSizeByMemory ,
5281 db_connection : DbmsConnectionInfo ,
5382 ) -> AuraGraphDataScience :
83+ """
84+ Retrieves an existing session with the given session name and database connection,
85+ or creates a new session if one does not exist.
86+
87+ Args:
88+ session_name (str): The name of the session.
89+ size (SessionSizeByMemory): The size of the session specified by memory.
90+ db_connection (DbmsConnectionInfo): The database connection information.
91+
92+ Returns:
93+ AuraGraphDataScience: The session.
94+ """
95+
5496 connected_instance = self ._try_connect (session_name , db_connection )
5597 if connected_instance is not None :
5698 return connected_instance
@@ -101,6 +143,12 @@ def delete(self, session_name: str) -> bool:
101143 return False
102144
103145 def list (self ) -> List [SessionInfo ]:
146+ """
147+ Retrieves the list of GDS sessions visible by the user asscociated by the given api-credentials.
148+
149+ Returns:
150+ A list of SessionInfo objects representing the GDS sessions.
151+ """
104152 all_instances = self ._aura_api .list_instances ()
105153 instance_details = [
106154 self ._aura_api .list_instance (instance_id = instance .id )
0 commit comments