use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifier method createClassifier.
/**
* Create classifier.
*
* Sends data to create and train a classifier and returns information about the new classifier.
*
* @param createClassifierOptions the {@link CreateClassifierOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Classifier}
*/
public ServiceCall<Classifier> createClassifier(CreateClassifierOptions createClassifierOptions) {
Validator.notNull(createClassifierOptions, "createClassifierOptions cannot be null");
String[] pathSegments = { "v1/classifiers" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody trainingMetadataBody = RequestUtils.inputStreamBody(createClassifierOptions.metadata(), "application/json");
multipartBuilder.addFormDataPart("training_metadata", createClassifierOptions.metadataFilename(), trainingMetadataBody);
RequestBody trainingDataBody = RequestUtils.inputStreamBody(createClassifierOptions.trainingData(), "text/csv");
multipartBuilder.addFormDataPart("training_data", createClassifierOptions.trainingDataFilename(), trainingDataBody);
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class));
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Discovery method getDocumentStatus.
/**
* Get document details.
*
* Fetch status details about a submitted document. **Note:** this operation does not return the document itself.
* Instead, it returns only the document's processing status and any notices (warnings or errors) that were generated
* when the document was ingested. Use the query API to retrieve the actual document content.
*
* @param getDocumentStatusOptions the {@link GetDocumentStatusOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link DocumentStatus}
*/
public ServiceCall<DocumentStatus> getDocumentStatus(GetDocumentStatusOptions getDocumentStatusOptions) {
Validator.notNull(getDocumentStatusOptions, "getDocumentStatusOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "documents" };
String[] pathParameters = { getDocumentStatusOptions.environmentId(), getDocumentStatusOptions.collectionId(), getDocumentStatusOptions.documentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DocumentStatus.class));
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Discovery method deleteTrainingData.
/**
* Removes the training data and all associated examples from the training data set.
*
* @param deleteTrainingDataOptions the {@link DeleteTrainingDataOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
*/
public ServiceCall<Void> deleteTrainingData(DeleteTrainingDataOptions deleteTrainingDataOptions) {
Validator.notNull(deleteTrainingDataOptions, "deleteTrainingDataOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data" };
String[] pathParameters = { deleteTrainingDataOptions.environmentId(), deleteTrainingDataOptions.collectionId(), deleteTrainingDataOptions.queryId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Discovery method deleteConfiguration.
/**
* Delete a configuration.
*
* The deletion is performed unconditionally. A configuration deletion request succeeds even if the configuration is
* referenced by a collection or document ingestion. However, documents that have already been submitted for
* processing continue to use the deleted configuration. Documents are always processed with a snapshot of the
* configuration as it existed at the time the document was submitted.
*
* @param deleteConfigurationOptions the {@link DeleteConfigurationOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
*/
public ServiceCall<Void> deleteConfiguration(DeleteConfigurationOptions deleteConfigurationOptions) {
Validator.notNull(deleteConfigurationOptions, "deleteConfigurationOptions cannot be null");
String[] pathSegments = { "v1/environments", "configurations" };
String[] pathParameters = { deleteConfigurationOptions.environmentId(), deleteConfigurationOptions.configurationId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Discovery method getEnvironment.
/**
* Get environment info.
*
* @param getEnvironmentOptions the {@link GetEnvironmentOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Environment}
*/
public ServiceCall<Environment> getEnvironment(GetEnvironmentOptions getEnvironmentOptions) {
Validator.notNull(getEnvironmentOptions, "getEnvironmentOptions cannot be null");
String[] pathSegments = { "v1/environments" };
String[] pathParameters = { getEnvironmentOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class));
}
Aggregations