@@ -142,6 +142,10 @@ def __init__(self, name: str, loginInfo: OpalClient.LoginInfo, profile: str = "d
142142 self .rsession = None
143143 self .rsession_started = False
144144
145+ def get_name (self ) -> str :
146+ """Get the name of the connection."""
147+ return self .name
148+
145149 def check_user (self ) -> bool :
146150 """Check if the user can authenticate by trying to retrieve the current subject profile."""
147151 try :
@@ -165,10 +169,40 @@ def list_tables(self) -> list:
165169 return names
166170
167171 def has_table (self , name : str ) -> bool :
172+ # name is in format "datasource.table"
173+ if "." not in name :
174+ raise OpalDSError (ValueError (f"Invalid table name: { name } . Expected format 'datasource.table'" ))
168175 parts = name .split ("." )
169176 response = self ._get (UriBuilder (["datasource" , parts [0 ], "table" , parts [1 ]]).build ()).send ()
170177 return response .code == 200
171178
179+ def list_table_variables (self , table ) -> list :
180+ # table is in format "datasource.table"
181+ if "." not in table :
182+ raise OpalDSError (ValueError (f"Invalid table name: { table } . Expected format 'datasource.table'" ))
183+ tokens = table .split ("." )
184+ project_name = tokens [0 ]
185+ table_name = tokens [1 ]
186+ return (
187+ self
188+ ._get (UriBuilder (["datasource" , project_name , "table" , table_name , "variables" ]).build ())
189+ .fail_on_error ()
190+ .send ()
191+ .from_json ()
192+ )
193+
194+ def list_taxonomies (self ) -> list :
195+ return self ._get (UriBuilder (["system" , "conf" , "taxonomies" ]).build ()).fail_on_error ().send ().from_json ()
196+
197+ def search_variables (self , query ) -> dict :
198+ return (
199+ self
200+ ._get (UriBuilder (["datasources" , "variables" , "_search" ]).query ("query" , query ).build ())
201+ .fail_on_error ()
202+ .send ()
203+ .from_json ()
204+ )
205+
172206 def list_resources (self ) -> list :
173207 response = self ._get ("/projects" ).fail_on_error ().send ()
174208 projects = response .from_json ()
@@ -181,6 +215,8 @@ def list_resources(self) -> list:
181215 return names
182216
183217 def has_resource (self , name : str ) -> bool :
218+ if "." not in name :
219+ raise OpalDSError (ValueError (f"Invalid resource name: { name } . Expected format 'project.resource'" ))
184220 parts = name .split ("." )
185221 response = self ._get (UriBuilder (["project" , parts [0 ], "resource" , parts [1 ]]).build ()).send ()
186222 return response .code == 200
0 commit comments