Package mindsdb.connectors
Class RestAPI
java.lang.Object
mindsdb.connectors.RestAPI
RestAPI class for handling REST API requests.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncom.google.gson.JsonObject
Get the status of the MindsDB servercom.google.gson.JsonObject
agentCompletion
(String project, String name, List<com.google.gson.JsonObject> messages) Get the status of the MindsDB servercom.google.gson.JsonArray
Get the status of the MindsDB servervoid
Close the sessioncom.google.gson.JsonObject
createAgent
(String project, String name, String model, String provider, List<String> skills, Map<String, Object> params) Create a new agentvoid
createSkill
(String project, String name, String type, com.google.gson.JsonObject params) Create a skillvoid
deleteAgent
(String project, String name) Delete an agentvoid
deleteSkill
(String project, String name) Delete a skillcom.google.gson.JsonObject
getFileMetadata
(String name) Upload a file to the MindsDB servergetUrl()
Get the URL of the MindsDB servervoid
insertFilesIntoKnowledgeBase
(String project, String knowledgeBaseName, List<String> fileNames) Insert files into a knowledge basevoid
insertWebpagesIntoKnowledgeBase
(String project, String knowledgeBaseName, List<String> urls, int crawlDepth, List<String> filters) Insert webpages into a knowledge basevoid
login()
Login to the MindsDB servertech.tablesaw.api.Table
modelPredict
(String project, String model, Map<String, String> data, Map<String, String> params, Integer version) Make a single prediction using a MindsDB modeltech.tablesaw.api.Table
modelPredict
(String project, String model, tech.tablesaw.api.Table data, Map<String, String> params, Integer version) Make a batch prediction using a MindsDB modeltech.tablesaw.api.Table
Insert data into a knowledge basetech.tablesaw.api.Table
objectsTree
(String item) Insert data into a knowledge basestatic byte[]
readDataFrameAsCSV
(tech.tablesaw.api.Table dataframe) Read the content of dataframe as csv in bytesstatic byte[]
readFileAsBytes
(String filePath) Read the content of a file as bytesstatic String
readFileAsWebpage
(String url) Read the content of a file as a webpagecom.google.gson.JsonObject
Get a skill of a projectcom.google.gson.JsonArray
Get skills of a projecttech.tablesaw.api.Table
Execute a SQL query to the MindsDB servertech.tablesaw.api.Table
Execute a SQL query to the MindsDB servercom.google.gson.JsonObject
status()
Upload a custom handler to MindsDBcom.google.gson.JsonObject
updateAgent
(String project, String name, String updatedName, String updatedModel, List<String> skillsToAdd, List<String> skillsToRemove, com.google.gson.JsonObject updatedParams) Update an agentvoid
updateSkill
(String project, String name, String updatedName, String updatedType, com.google.gson.JsonObject updatedParams) Update a skillvoid
uploadData
(String fileName, byte[] data) Upload a file to the MindsDB servervoid
uploadFile
(String name, String data) Upload a file to the MindsDB servervoid
uploadFile
(String name, tech.tablesaw.api.Table data) Upload a file to the MindsDB server
-
Constructor Details
-
RestAPI
public RestAPI(String url, String login, String password, String apiKey, boolean isManaged, Map<String, String> headers) Constructor for RestAPI- Parameters:
url
- URL to MindsDB serverlogin
- User login, for cloud version it contains emailpassword
- User password to login (for cloud version)apiKey
- API key to authenticate (for cloud version)isManaged
- Whether or not the URL points to a managed instanceheaders
- Additional headers to send with the connection, optional
-
-
Method Details
-
getUrl
Get the URL of the MindsDB server- Returns:
- URL of the MindsDB server
-
login
public void login()Login to the MindsDB server -
sqlQuery
Execute a SQL query to the MindsDB server- Parameters:
sql
- SQL query to executedatabase
- Database to execute the query on- Returns:
- Tablesaw Table containing the result of the query
-
sqlQuery
Execute a SQL query to the MindsDB server- Parameters:
sql
- SQL query to execute- Returns:
- Tablesaw Table containing the result of the query in form of table
-
closeSession
public void closeSession()Close the session -
createAgent
public com.google.gson.JsonObject createAgent(String project, String name, String model, String provider, List<String> skills, Map<String, Object> params) Create a new agent- Parameters:
project
- Name of the projectname
- Name of the Agentmodel
- Name of the modelprovider
- Name of the providerskills
- List of skillsparams
- Additional parameters- Returns:
- JsonObject containing the agent details
- Throws:
kong.unirest.core.UnirestException
- when the request fails when the request fails
-
updateAgent
public com.google.gson.JsonObject updateAgent(String project, String name, String updatedName, String updatedModel, List<String> skillsToAdd, List<String> skillsToRemove, com.google.gson.JsonObject updatedParams) Update an agent- Parameters:
project
- Project namename
- Agent nameupdatedName
- Updated agent nameupdatedModel
- Updated model nameskillsToAdd
- List of skills to addskillsToRemove
- List of skills to removeupdatedParams
- Updated parameters- Returns:
- JsonObject containing the updated agent details
-
status
public com.google.gson.JsonObject status() throws kong.unirest.core.UnirestExceptionUpload a custom handler to MindsDB- Returns:
- JsonObject containing the response
- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
agents
Get the status of the MindsDB server- Parameters:
project
- Name of the project- Returns:
- JsonObject containing the status of the project
- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
agent
public com.google.gson.JsonObject agent(String project, String name) throws kong.unirest.core.UnirestException Get the status of the MindsDB server- Parameters:
project
- Name of the projectname
- Name of the agent- Returns:
- JsonObject containing the status of the agent
- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
agentCompletion
public com.google.gson.JsonObject agentCompletion(String project, String name, List<com.google.gson.JsonObject> messages) throws kong.unirest.core.UnirestException Get the status of the MindsDB server- Parameters:
project
- Name of the projectname
- Name of the agentmessages
- List of messages- Returns:
- JsonObject containing the completion of the agent
- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
deleteAgent
Delete an agent- Parameters:
project
- Name of the projectname
- Name of the agent- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
skills
Get skills of a project- Parameters:
project
- Name of the project- Returns:
- JsonArray containing the skills of the project
- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
skill
public com.google.gson.JsonObject skill(String project, String name) throws kong.unirest.core.UnirestException Get a skill of a project- Parameters:
project
- Name of the projectname
- Name of the skill- Returns:
- JsonObject containing the skill details
- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
createSkill
public void createSkill(String project, String name, String type, com.google.gson.JsonObject params) throws kong.unirest.core.UnirestException Create a skill- Parameters:
project
- Name of the projectname
- Name of the skilltype
- Type of the skillparams
- Parameters of the skill- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
updateSkill
public void updateSkill(String project, String name, String updatedName, String updatedType, com.google.gson.JsonObject updatedParams) throws kong.unirest.core.UnirestException Update a skill- Parameters:
project
- Name of the projectname
- Name of the skillupdatedName
- Updated name of the skillupdatedType
- Updated type of the skillupdatedParams
- Updated parameters of the skill- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
deleteSkill
Delete a skill- Parameters:
project
- Name of the projectname
- Name of the skill- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
insertFilesIntoKnowledgeBase
public void insertFilesIntoKnowledgeBase(String project, String knowledgeBaseName, List<String> fileNames) throws kong.unirest.core.UnirestException Insert files into a knowledge base- Parameters:
project
- Name of the projectknowledgeBaseName
- Name of the knowledge basefileNames
- List of file names- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
insertWebpagesIntoKnowledgeBase
public void insertWebpagesIntoKnowledgeBase(String project, String knowledgeBaseName, List<String> urls, int crawlDepth, List<String> filters) throws kong.unirest.core.UnirestException Insert webpages into a knowledge base- Parameters:
project
- Name of the projectknowledgeBaseName
- Name of the knowledge baseurls
- List of URLscrawlDepth
- Crawl depthfilters
- List of filters- Throws:
kong.unirest.core.UnirestException
- when the request fails
-
objectsTree
Insert data into a knowledge base- Parameters:
item
- Name of the item- Returns:
- Tablesaw Table containing the data
-
objectsTree
public tech.tablesaw.api.Table objectsTree()Insert data into a knowledge base- Returns:
- Tablesaw Table containing the data
-
modelPredict
public tech.tablesaw.api.Table modelPredict(String project, String model, tech.tablesaw.api.Table data, Map<String, String> params, Integer version) Make a batch prediction using a MindsDB model- Parameters:
project
- Name of the projectmodel
- Name of the modeldata
- Tablesaw table containing the dataparams
- Additional params for modelversion
- Version of model to use- Returns:
- Tablesaw table object containing prediction
-
modelPredict
public tech.tablesaw.api.Table modelPredict(String project, String model, Map<String, String> data, Map<String, String> params, Integer version) Make a single prediction using a MindsDB model- Parameters:
project
- Name of field to predictmodel
- Name of the modeldata
- Data provided to modelparams
- Additional parametersversion
- Version of the model- Returns:
- Tablesaw Table containing the prediction
-
readFileAsBytes
Read the content of a file as bytes- Parameters:
filePath
- Path to the file- Returns:
- Byte array of the file
-
readDataFrameAsCSV
public static byte[] readDataFrameAsCSV(tech.tablesaw.api.Table dataframe) Read the content of dataframe as csv in bytes- Parameters:
dataframe
- DataFrame to read- Returns:
- DataFrame as csv in bytes
-
readFileAsWebpage
Read the content of a file as a webpage- Parameters:
url
- URL of the webpage- Returns:
- Content of the webpage
-
uploadData
Upload a file to the MindsDB server- Parameters:
fileName
- Name of the filedata
- Byte array of the file
-
uploadFile
Upload a file to the MindsDB server- Parameters:
name
- Name of the filedata
- Data of the file
-
uploadFile
Upload a file to the MindsDB server- Parameters:
name
- Name of the filedata
- Tablesaw Table containing the data
-
getFileMetadata
public com.google.gson.JsonObject getFileMetadata(String name) throws kong.unirest.core.UnirestException Upload a file to the MindsDB server- Parameters:
name
- Name of the file- Returns:
- Tablesaw Table containing the data
- Throws:
kong.unirest.core.UnirestException
- when the request fails
-