Package ai.rev.languageid
Class LanguageIdClient
- java.lang.Object
-
- ai.rev.languageid.LanguageIdClient
-
public class LanguageIdClient extends Object
The LanguageIdClient object provides methods to send and retrieve information from all the Rev AI Language Identification API endpoints using the Retrofit HTTP client.
-
-
Field Summary
Fields Modifier and Type Field Description LanguageIdInterfaceapiInterfaceInterface that LanguageIdClient methods use to make requests
-
Constructor Summary
Constructors Constructor Description LanguageIdClient(String accessToken)Constructs the API client used to send HTTP requests to Rev AI.LanguageIdClient(String accessToken, String baseUrl)Constructs the API client used to send HTTP requests to Rev AI.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseConnection()Manually closes the connection when the code is running in a JVMvoiddeleteJob(String id)This method sends a DELETE request to the /jobs/{id} endpoint.LanguageIdJobgetJobDetails(String id)This method sends a GET request to the /jobs/{id} endpoint and returns aLanguageIdJobobject.List<LanguageIdJob>getListOfJobs()Overload ofgetListOfJobs(Integer, String)without the optional limit and startingAfter parameter.List<LanguageIdJob>getListOfJobs(Integer limit)Overload ofgetListOfJobs(Integer, String)without the optional startingAfter parameter.List<LanguageIdJob>getListOfJobs(Integer limit, String startingAfter)This method sends a GET request to the /jobs endpoint and returns a list ofLanguageIdJobobjects.List<LanguageIdJob>getListOfJobs(String startingAfter)Overload ofgetListOfJobs(Integer, String)without the optional limit parameter.LanguageIdResultgetResultObject(String id)The method sends a GET request to the /jobs/{id}/result endpoint and returns aLanguageIdResultobject.LanguageIdJobsubmitJob(LanguageIdJobOptions options)The method sends a POST request to the /jobs endpoint, starts a language id job for the provided options and returns aLanguageIdJobobject.LanguageIdJobsubmitJobLocalFile(InputStream inputStream)An overload ofsubmitJobLocalFile(InputStream, String, LanguageIdJobOptions)without the optional filename and language id options.LanguageIdJobsubmitJobLocalFile(InputStream inputStream, LanguageIdJobOptions options)An overload ofsubmitJobLocalFile(InputStream, String, LanguageIdJobOptions)without the optional filename.LanguageIdJobsubmitJobLocalFile(InputStream inputStream, String fileName)An overload ofsubmitJobLocalFile(InputStream, String, LanguageIdJobOptions)without the additional language id options.LanguageIdJobsubmitJobLocalFile(InputStream inputStream, String fileName, LanguageIdJobOptions options)The method sends a multipart/form POST request to the /jobs endpoint, starts a language id job for the provided media file provided by InputStream and returns aLanguageIdJobobject.LanguageIdJobsubmitJobLocalFile(String filePath, LanguageIdJobOptions options)The method sends multipart/form POST request to the /jobs endpoint, starts a language id job for the provided local media file and returns aLanguageIdJobobject.
-
-
-
Field Detail
-
apiInterface
public LanguageIdInterface apiInterface
Interface that LanguageIdClient methods use to make requests
-
-
Constructor Detail
-
LanguageIdClient
public LanguageIdClient(String accessToken, String baseUrl)
Constructs the API client used to send HTTP requests to Rev AI. The user access token can be generated on the website at https://www.rev.ai/access_token.- Parameters:
accessToken- Rev AI authorization token associate with the account.baseUrl- Optional url of the Rev AI API deployment to use, defaults to the US deployement, i.e. 'https://api.rev.ai', which can be referenced as RevAiApiDeploymentConfiguration.getConfig(RevAiApiDeploymentConfiguration.RevAiApiDeployment.US).getBaseUrl().- Throws:
IllegalArgumentException- If the access token is null or empty.
-
LanguageIdClient
public LanguageIdClient(String accessToken)
Constructs the API client used to send HTTP requests to Rev AI. The user access token can be generated on the website at https://www.rev.ai/access_token.- Parameters:
accessToken- Rev AI authorization token associate with the account.- Throws:
IllegalArgumentException- If the access token is null or empty.
-
-
Method Detail
-
closeConnection
public void closeConnection()
Manually closes the connection when the code is running in a JVM
-
getListOfJobs
public List<LanguageIdJob> getListOfJobs(Integer limit, String startingAfter) throws IOException
This method sends a GET request to the /jobs endpoint and returns a list ofLanguageIdJobobjects.- Parameters:
limit- The maximum number of jobs to return. The default is 100, max is 1000.startingAfter- The job ID at which the list begins.- Returns:
- A list of
LanguageIdJobobjects. - Throws:
IOException- If the response has a status code > 399.- See Also:
LanguageIdJob, https://docs.rev.ai/api/language-identification/reference/#operation/GetListOfLanguageIdentificationJobs
-
getListOfJobs
public List<LanguageIdJob> getListOfJobs(Integer limit) throws IOException
Overload ofgetListOfJobs(Integer, String)without the optional startingAfter parameter.- Parameters:
limit- The maximum number of jobs to return. The default is 100, max is 1000.- Returns:
- A list of
LanguageIdJobobjects. - Throws:
IOException- If the response has a status code > 399.
-
getListOfJobs
public List<LanguageIdJob> getListOfJobs(String startingAfter) throws IOException
Overload ofgetListOfJobs(Integer, String)without the optional limit parameter.- Parameters:
startingAfter- The job ID at which the list begins.- Returns:
- A list of
LanguageIdJobobjects. - Throws:
IOException- If the response has a status code > 399.
-
getListOfJobs
public List<LanguageIdJob> getListOfJobs() throws IOException
Overload ofgetListOfJobs(Integer, String)without the optional limit and startingAfter parameter.- Returns:
- A list of
LanguageIdJobobjects. - Throws:
IOException- If the response has a status code > 399.
-
getJobDetails
public LanguageIdJob getJobDetails(String id) throws IOException
This method sends a GET request to the /jobs/{id} endpoint and returns aLanguageIdJobobject.- Parameters:
id- The ID of the job to return an object for.- Returns:
- A
LanguageIdJobobject. - Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- If the job ID is null.
-
deleteJob
public void deleteJob(String id) throws IOException
This method sends a DELETE request to the /jobs/{id} endpoint.- Parameters:
id- The id of the job to be deleted.- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- If the job ID is null.- See Also:
- https://docs.rev.ai/api/language-identification/reference/#operation/DeleteLanguageIdentificationJobById
-
getResultObject
public LanguageIdResult getResultObject(String id) throws IOException
The method sends a GET request to the /jobs/{id}/result endpoint and returns aLanguageIdResultobject.- Parameters:
id- The id of the job to return a result for.- Returns:
- LanguageIdResult The result object.
- Throws:
IOException- If the response has a status code > 399.- See Also:
LanguageIdResult, https://docs.rev.ai/api/language-identification/reference/#operation/GetLanguageIdentificationResultById
-
submitJob
public LanguageIdJob submitJob(LanguageIdJobOptions options) throws IOException
The method sends a POST request to the /jobs endpoint, starts a language id job for the provided options and returns aLanguageIdJobobject.- Parameters:
options- The language id options associated with this job.- Returns:
- LanguageIdJob A representation of the language id job.
- Throws:
IOException- If the response has a status code > 399.- See Also:
LanguageIdJob, https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob
-
submitJobLocalFile
public LanguageIdJob submitJobLocalFile(String filePath, LanguageIdJobOptions options) throws IOException
The method sends multipart/form POST request to the /jobs endpoint, starts a language id job for the provided local media file and returns aLanguageIdJobobject.- Parameters:
filePath- A local path to the file on the computer.options- The language id options associated with this job.- Returns:
- LanguageIdJob A representation of the language id job.
- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- If the file path is null.- See Also:
LanguageIdJob, https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob
-
submitJobLocalFile
public LanguageIdJob submitJobLocalFile(InputStream inputStream, String fileName, LanguageIdJobOptions options) throws IOException
The method sends a multipart/form POST request to the /jobs endpoint, starts a language id job for the provided media file provided by InputStream and returns aLanguageIdJobobject.- Parameters:
inputStream- An InputStream of the media file.fileName- The name of the file being streamed.options- The language id options associated with this job.- Returns:
- LanguageIdJob A representation of the language id job.
- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- If the InputStream provided is null.- See Also:
LanguageIdJob, https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob
-
submitJobLocalFile
public LanguageIdJob submitJobLocalFile(InputStream inputStream) throws IOException
An overload ofsubmitJobLocalFile(InputStream, String, LanguageIdJobOptions)without the optional filename and language id options.- Parameters:
inputStream- An InputStream of the media file.- Returns:
- LanguageIdJob A representation of the language id job.
- Throws:
IOException- If the response has a status code > 399.- See Also:
LanguageIdJob, https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob
-
submitJobLocalFile
public LanguageIdJob submitJobLocalFile(InputStream inputStream, String fileName) throws IOException
An overload ofsubmitJobLocalFile(InputStream, String, LanguageIdJobOptions)without the additional language id options.- Parameters:
inputStream- An InputStream of the media file.fileName- The name of the file being streamed.- Returns:
- LanguageIdJob A representation of the language id job.
- Throws:
IOException- If the response has a status code > 399.- See Also:
LanguageIdJob, https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob
-
submitJobLocalFile
public LanguageIdJob submitJobLocalFile(InputStream inputStream, LanguageIdJobOptions options) throws IOException
An overload ofsubmitJobLocalFile(InputStream, String, LanguageIdJobOptions)without the optional filename.- Parameters:
inputStream- An InputStream of the media file.options- The language id options associated with this job.- Returns:
- LanguageIdJob A representation of the language id job.
- Throws:
IOException- If the response has a status code > 399.- See Also:
LanguageIdJob, https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob
-
-