Data Source¶
-
class
alpine.datasource.
DataSource
(base_url=None, session=None, token=None)¶ A class for interacting with data sources. These methods may require a login as a user with admin privileges.
-
class
DSType
¶ Convenience strings for data source types.
-
get
(ds_id, type)¶ Get one data source’s metadata.
Parameters: - ds_id (int) – A unique ID of the data source.
- type (str) – Data source type. Either “Database” or “Hadoop”.
Returns: Selected data source’s metadata.
Return type: dict
Raises: DataSourceNotFoundException – the data source does not exist.
Example:
>>> session.datasource.get(ds_id = 1, type = "Database")
-
get_database_list
(data_source_id, per_page=100)¶ Return a list of metadata for all databases in a data source.
Parameters: - data_source_id (int) – ID of the data source.
- per_page (int) – Maximum number to fetch with each API call.
Returns: List of database metadata.
Return type: list of dict
Example:
>>> database_list = session.datasource.get_database_list(data_source_id = 1) >>> len(database_list) 3
-
get_id
(name, type=None)¶ Gets the ID of the data source. Will throw an exception if the data source does not exist.
Parameters: - name (str) – Data source name.
- type (str) – Data source type. Choose to search by “Database” or “Hadoop.” Entering None searches both types.
Returns: ID of the data source.
Return type: int
Raises: DataSourceNotFoundException – The data source does not exist.
Example:
>>> data_source_id = session.datasource.get_id(name = "Demo_GP", type = "Database") >>> print(data_source_id) 786
-
get_list
(type=None, per_page=100)¶ Get a list of metadata for all data sources.
Parameters: - type (str) – Type of the data source. Select “Database”, “Hadoop”, or None for both types.
- per_page (int) – Maximum number to fetch with each API call.
Returns: List of data source’s metadata.
Return type: list of dict
Example:
>>> all_datasources = session.datasource.get_list() >>> all_database_datasources = session.datasource.get_list(type = "Database") >>> all_hadoop_datasources = session.datasource.get_list(type = "Hadoop") >>> len(all_datasources) 20
-
class