use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifier method deleteClassifier.
/**
* Delete classifier.
*
* @param deleteClassifierOptions the {@link DeleteClassifierOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a void result
*/
public ServiceCall<Void> deleteClassifier(DeleteClassifierOptions deleteClassifierOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteClassifierOptions, "deleteClassifierOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("classifier_id", deleteClassifierOptions.classifierId());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/classifiers/{classifier_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "deleteClassifier");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Void> responseConverter = ResponseConverterUtils.getVoid();
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifier method getClassifier.
/**
* Get information about a classifier.
*
* <p>Returns status and other information about a classifier.
*
* @param getClassifierOptions the {@link GetClassifierOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link Classifier}
*/
public ServiceCall<Classifier> getClassifier(GetClassifierOptions getClassifierOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getClassifierOptions, "getClassifierOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("classifier_id", getClassifierOptions.classifierId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/classifiers/{classifier_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "getClassifier");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Classifier> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Classifier>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifier method classifyCollection.
/**
* Classify multiple phrases.
*
* <p>Returns label information for multiple phrases. The status must be `Available` before you
* can use the classifier to classify text.
*
* <p>Note that classifying Japanese texts is a beta feature.
*
* @param classifyCollectionOptions the {@link ClassifyCollectionOptions} containing the options
* for the call
* @return a {@link ServiceCall} with a result of type {@link ClassificationCollection}
*/
public ServiceCall<ClassificationCollection> classifyCollection(ClassifyCollectionOptions classifyCollectionOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(classifyCollectionOptions, "classifyCollectionOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("classifier_id", classifyCollectionOptions.classifierId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/classifiers/{classifier_id}/classify_collection", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "classifyCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("collection", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(classifyCollectionOptions.collection()));
builder.bodyJson(contentJson);
ResponseConverter<ClassificationCollection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ClassificationCollection>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class CompareComply method extractTables.
/**
* Extract a document's tables.
*
* <p>Analyzes the tables in a document.
*
* @param extractTablesOptions the {@link ExtractTablesOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link TableReturn}
*/
public ServiceCall<TableReturn> extractTables(ExtractTablesOptions extractTablesOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(extractTablesOptions, "extractTablesOptions cannot be null");
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/tables"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "extractTables");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
if (extractTablesOptions.model() != null) {
builder.query("model", String.valueOf(extractTablesOptions.model()));
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
okhttp3.RequestBody fileBody = RequestUtils.inputStreamBody(extractTablesOptions.file(), extractTablesOptions.fileContentType());
multipartBuilder.addFormDataPart("file", "filename", fileBody);
builder.body(multipartBuilder.build());
ResponseConverter<TableReturn> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<TableReturn>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class VisualRecognition method updateCollection.
/**
* Update a collection.
*
* <p>Update the name or description of a collection.
*
* <p>Encode the name and description in UTF-8 if they contain non-ASCII characters. The service
* assumes UTF-8 encoding if it encounters non-ASCII characters.
*
* @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link Collection}
*/
public ServiceCall<Collection> updateCollection(UpdateCollectionOptions updateCollectionOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateCollectionOptions, "updateCollectionOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("collection_id", updateCollectionOptions.collectionId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v4/collections/{collection_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "updateCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
final JsonObject contentJson = new JsonObject();
if (updateCollectionOptions.name() != null) {
contentJson.addProperty("name", updateCollectionOptions.name());
}
if (updateCollectionOptions.description() != null) {
contentJson.addProperty("description", updateCollectionOptions.description());
}
builder.bodyJson(contentJson);
ResponseConverter<Collection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Collection>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations