@@ -21,6 +21,18 @@ def __init__(self, client):
2121 self .api = client .api
2222
2323 def create (self , ds_config : DatabaseConfig , replace = False ):
24+ """
25+ Create new datasource and return it
26+
27+ :param ds_config: datasource configuration, properties:
28+ - name: str, name of datatasource
29+ - engine: str, type of database handler, for example 'postgres', 'mysql', ...
30+ - description: str, description of the database. Used by mind to know what data can be got from it.
31+ - connection_data: dict, optional, credentials to connect to database
32+ - tables: list of str, optional, list of allowed tables
33+ :return: datasource object
34+ """
35+
2436 name = ds_config .name
2537
2638 if replace :
@@ -34,6 +46,12 @@ def create(self, ds_config: DatabaseConfig, replace=False):
3446 return self .get (name )
3547
3648 def list (self ) -> List [Datasource ]:
49+ """
50+ Returns list of datasources
51+
52+ :return: iterable datasources
53+ """
54+
3755 data = self .api .get ('/datasources' ).json ()
3856 ds_list = []
3957 for item in data :
@@ -44,6 +62,13 @@ def list(self) -> List[Datasource]:
4462 return ds_list
4563
4664 def get (self , name : str ) -> Datasource :
65+ """
66+ Get datasource by name
67+
68+ :param name: name of datasource
69+ :return: datasource object
70+ """
71+
4772 data = self .api .get (f'/datasources/{ name } ' ).json ()
4873
4974 # TODO skip not sql skills
@@ -52,4 +77,10 @@ def get(self, name: str) -> Datasource:
5277 return Datasource (** data )
5378
5479 def drop (self , name : str ):
80+ """
81+ Drop datasource by name
82+
83+ :param name: name of datasource
84+ """
85+
5586 self .api .delete (f'/datasources/{ name } ' )
0 commit comments