Class DatasourcesService

java.lang.Object
com.mindsdb.services.DatasourcesService

public class DatasourcesService extends Object
Service class for managing data sources. Provides methods to create, retrieve, list, and delete data sources using a REST client.
  • Constructor Details

    • DatasourcesService

      public DatasourcesService(RestClient restClient)
  • Method Details

    • create

      public Datasource create(DatabaseConfig databaseConfig) throws Exception
      Creates a new data source with the given database configuration.
      Parameters:
      databaseConfig - the configuration of the database to create a data source for
      Returns:
      the created Datasource object
      Throws:
      Exception - if an error occurs during the creation process
    • create

      public Datasource create(DatabaseConfig databaseConfig, boolean replace) throws Exception
      Creates a new data source with the given database configuration, with an option to replace an existing data source.
      Parameters:
      databaseConfig - the configuration of the database to create a data source for
      replace - if true, replaces the existing data source with the same name
      Returns:
      the created Datasource object
      Throws:
      Exception - if an error occurs during the creation process
    • list

      public Optional<List<Datasource>> list() throws Exception
      Retrieves a list of all data sources.
      Returns:
      an Optional containing a list of Datasource objects, or an empty Optional if no data sources are found
      Throws:
      Exception - if an error occurs during the retrieval process
    • get

      public Optional<Datasource> get(String datasourceName) throws Exception
      Retrieves a specific data source by name.
      Parameters:
      datasourceName - the name of the data source to retrieve
      Returns:
      an Optional containing the Datasource object, or an empty Optional if not found
      Throws:
      Exception - if an error occurs during the retrieval process
    • drop

      public void drop(String datasourceName) throws Exception
      Deletes a specific data source by name.
      Parameters:
      datasourceName - the name of the data source to delete
      Throws:
      Exception - if an error occurs during the deletion process