use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method listExamples.
/**
* List user input examples.
*
* <p>List the user input examples for an intent, optionally including contextual entity mentions.
*
* @param listExamplesOptions the {@link ListExamplesOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ExampleCollection}
*/
public ServiceCall<ExampleCollection> listExamples(ListExamplesOptions listExamplesOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listExamplesOptions, "listExamplesOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", listExamplesOptions.workspaceId());
pathParamsMap.put("intent", listExamplesOptions.intent());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}/examples", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listExamples");
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 (listExamplesOptions.pageLimit() != null) {
builder.query("page_limit", String.valueOf(listExamplesOptions.pageLimit()));
}
if (listExamplesOptions.includeCount() != null) {
builder.query("include_count", String.valueOf(listExamplesOptions.includeCount()));
}
if (listExamplesOptions.sort() != null) {
builder.query("sort", String.valueOf(listExamplesOptions.sort()));
}
if (listExamplesOptions.cursor() != null) {
builder.query("cursor", String.valueOf(listExamplesOptions.cursor()));
}
if (listExamplesOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(listExamplesOptions.includeAudit()));
}
ResponseConverter<ExampleCollection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ExampleCollection>() {
}.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 Assistant method deleteIntent.
/**
* Delete intent.
*
* <p>Delete an intent from a workspace.
*
* @param deleteIntentOptions the {@link DeleteIntentOptions} containing the options for the call
* @return a {@link ServiceCall} with a void result
*/
public ServiceCall<Void> deleteIntent(DeleteIntentOptions deleteIntentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteIntentOptions, "deleteIntentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", deleteIntentOptions.workspaceId());
pathParamsMap.put("intent", deleteIntentOptions.intent());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteIntent");
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));
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 Assistant method deleteCounterexample.
/**
* Delete counterexample.
*
* <p>Delete a counterexample from a workspace. Counterexamples are examples that have been marked
* as irrelevant input.
*
* @param deleteCounterexampleOptions the {@link DeleteCounterexampleOptions} containing the
* options for the call
* @return a {@link ServiceCall} with a void result
*/
public ServiceCall<Void> deleteCounterexample(DeleteCounterexampleOptions deleteCounterexampleOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteCounterexampleOptions, "deleteCounterexampleOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", deleteCounterexampleOptions.workspaceId());
pathParamsMap.put("text", deleteCounterexampleOptions.text());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples/{text}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteCounterexample");
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));
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 Assistant method updateCounterexample.
/**
* Update counterexample.
*
* <p>Update the text of a counterexample. Counterexamples are examples that have been marked as
* irrelevant input.
*
* @param updateCounterexampleOptions the {@link UpdateCounterexampleOptions} containing the
* options for the call
* @return a {@link ServiceCall} with a result of type {@link Counterexample}
*/
public ServiceCall<Counterexample> updateCounterexample(UpdateCounterexampleOptions updateCounterexampleOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateCounterexampleOptions, "updateCounterexampleOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateCounterexampleOptions.workspaceId());
pathParamsMap.put("text", updateCounterexampleOptions.text());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples/{text}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateCounterexample");
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 (updateCounterexampleOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateCounterexampleOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
if (updateCounterexampleOptions.newText() != null) {
contentJson.addProperty("text", updateCounterexampleOptions.newText());
}
builder.bodyJson(contentJson);
ResponseConverter<Counterexample> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Counterexample>() {
}.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 Assistant method createExample.
/**
* Create user input example.
*
* <p>Add a new user input example to an intent.
*
* <p>If you want to add multiple examples with a single API call, consider using the **[Update
* intent](#update-intent)** method instead.
*
* @param createExampleOptions the {@link CreateExampleOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link Example}
*/
public ServiceCall<Example> createExample(CreateExampleOptions createExampleOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createExampleOptions, "createExampleOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", createExampleOptions.workspaceId());
pathParamsMap.put("intent", createExampleOptions.intent());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}/examples", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createExample");
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 (createExampleOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(createExampleOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("text", createExampleOptions.text());
if (createExampleOptions.mentions() != null) {
contentJson.add("mentions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createExampleOptions.mentions()));
}
builder.bodyJson(contentJson);
ResponseConverter<Example> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Example>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations