use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method listAllLogs.
/**
* List log events in all workspaces.
*
* <p>List the events from the logs of all workspaces in the service instance.
*
* @param listAllLogsOptions the {@link ListAllLogsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link LogCollection}
*/
public ServiceCall<LogCollection> listAllLogs(ListAllLogsOptions listAllLogsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listAllLogsOptions, "listAllLogsOptions cannot be null");
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/logs"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listAllLogs");
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));
builder.query("filter", String.valueOf(listAllLogsOptions.filter()));
if (listAllLogsOptions.sort() != null) {
builder.query("sort", String.valueOf(listAllLogsOptions.sort()));
}
if (listAllLogsOptions.pageLimit() != null) {
builder.query("page_limit", String.valueOf(listAllLogsOptions.pageLimit()));
}
if (listAllLogsOptions.cursor() != null) {
builder.query("cursor", String.valueOf(listAllLogsOptions.cursor()));
}
ResponseConverter<LogCollection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<LogCollection>() {
}.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 createCounterexample.
/**
* Create counterexample.
*
* <p>Add a new counterexample to a workspace. Counterexamples are examples that have been marked
* as irrelevant input.
*
* <p>If you want to add multiple counterexamples with a single API call, consider using the
* **[Update workspace](#update-workspace)** method instead.
*
* @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the
* options for the call
* @return a {@link ServiceCall} with a result of type {@link Counterexample}
*/
public ServiceCall<Counterexample> createCounterexample(CreateCounterexampleOptions createCounterexampleOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createCounterexampleOptions, "createCounterexampleOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", createCounterexampleOptions.workspaceId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createCounterexample");
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 (createCounterexampleOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(createCounterexampleOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("text", createCounterexampleOptions.text());
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 deleteWorkspace.
/**
* Delete workspace.
*
* <p>Delete a workspace from the service instance.
*
* @param deleteWorkspaceOptions the {@link DeleteWorkspaceOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a void result
*/
public ServiceCall<Void> deleteWorkspace(DeleteWorkspaceOptions deleteWorkspaceOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteWorkspaceOptions, "deleteWorkspaceOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", deleteWorkspaceOptions.workspaceId());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteWorkspace");
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 updateValue.
/**
* Update entity value.
*
* <p>Update an existing entity value with new or modified data. You must provide component
* objects defining the content of the updated entity value.
*
* <p>If you want to update multiple entity values with a single API call, consider using the
* **[Update entity](#update-entity)** method instead.
*
* @param updateValueOptions the {@link UpdateValueOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Value}
*/
public ServiceCall<Value> updateValue(UpdateValueOptions updateValueOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateValueOptions, "updateValueOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateValueOptions.workspaceId());
pathParamsMap.put("entity", updateValueOptions.entity());
pathParamsMap.put("value", updateValueOptions.value());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateValue");
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 (updateValueOptions.append() != null) {
builder.query("append", String.valueOf(updateValueOptions.append()));
}
if (updateValueOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateValueOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
if (updateValueOptions.newValue() != null) {
contentJson.addProperty("value", updateValueOptions.newValue());
}
if (updateValueOptions.newMetadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions.newMetadata()));
}
if (updateValueOptions.newType() != null) {
contentJson.addProperty("type", updateValueOptions.newType());
}
if (updateValueOptions.newSynonyms() != null) {
contentJson.add("synonyms", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions.newSynonyms()));
}
if (updateValueOptions.newPatterns() != null) {
contentJson.add("patterns", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions.newPatterns()));
}
builder.bodyJson(contentJson);
ResponseConverter<Value> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Value>() {
}.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 deleteDialogNode.
/**
* Delete dialog node.
*
* <p>Delete a dialog node from a workspace.
*
* @param deleteDialogNodeOptions the {@link DeleteDialogNodeOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a void result
*/
public ServiceCall<Void> deleteDialogNode(DeleteDialogNodeOptions deleteDialogNodeOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteDialogNodeOptions, "deleteDialogNodeOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", deleteDialogNodeOptions.workspaceId());
pathParamsMap.put("dialog_node", deleteDialogNodeOptions.dialogNode());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteDialogNode");
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);
}
Aggregations