com.ibm.watson.developer_cloud.http.RequestBuilder.bodyJson()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(23.7k)|赞(0)|评价(0)|浏览(69)

本文整理了Java中com.ibm.watson.developer_cloud.http.RequestBuilder.bodyJson方法的一些代码示例,展示了RequestBuilder.bodyJson的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RequestBuilder.bodyJson方法的具体详情如下:
包路径:com.ibm.watson.developer_cloud.http.RequestBuilder
类名称:RequestBuilder
方法名:bodyJson

RequestBuilder.bodyJson介绍

[英]Adds a JSON content to the request (used with POST/PUT). This will encapsulate the json into a RequestBody encoded with UTF-8 and use "application/json" as Content-Type
[中]向请求中添加JSON内容(与POST/PUT一起使用)。这将把json封装到一个用UTF-8编码的请求体中,并使用“application/json”作为内容类型

代码示例

代码示例来源:origin: com.ibm.watson.developer_cloud/dialog

/**
 * Updates a dialog profile with a profile.<br>
 * Profile variables are case sensitive.
 *
 * @param dialogId The dialog identifier
 * @param clientId the client identifier
 * @param profile the profile variables
 * @return the service call
 */
public ServiceCall<Void> updateProfile(final String dialogId, final Integer clientId,
  final Map<String, String> profile) {
 Validator.isTrue((dialogId != null) && !dialogId.isEmpty(), "dialogId cannot be null or empty");
 Validator.isTrue((profile != null) && !profile.isEmpty(), "profile cannot be null or empty");
 final JsonObject contentJson = new JsonObject();
 if (clientId != null) {
  contentJson.addProperty(CLIENT_ID, clientId);
 }
 contentJson.add(NAME_VALUES, GSON.toJsonTree(toNameValue(profile)));
 final Request request = RequestBuilder.put(String.format(PATH_PROFILE, dialogId)).bodyJson(contentJson).build();
 return createServiceCall(request, ResponseConverterUtils.getVoid());
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Create event.
 *
 * The **Events** API can be used to create log entries that are associated with specific queries. For example, you
 * can record which documents in the results set were \"clicked\" by a user and when that click occured.
 *
 * @param createEventOptions the {@link CreateEventOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link CreateEventResponse}
 */
public ServiceCall<CreateEventResponse> createEvent(CreateEventOptions createEventOptions) {
 Validator.notNull(createEventOptions, "createEventOptions cannot be null");
 String[] pathSegments = { "v1/events" };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 contentJson.addProperty("type", createEventOptions.type());
 contentJson.add("data", GsonSingleton.getGson().toJsonTree(createEventOptions.data()));
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(CreateEventResponse.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Classify multiple phrases.
 *
 * Returns label information for multiple phrases. The status must be `Available` before you can use the classifier to
 * classify text.
 *
 * 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 response type of {@link ClassificationCollection}
 */
public ServiceCall<ClassificationCollection> classifyCollection(ClassifyCollectionOptions classifyCollectionOptions) {
 Validator.notNull(classifyCollectionOptions, "classifyCollectionOptions cannot be null");
 String[] pathSegments = { "v1/classifiers", "classify_collection" };
 String[] pathParameters = { classifyCollectionOptions.classifierId() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 final JsonObject contentJson = new JsonObject();
 contentJson.add("collection", GsonSingleton.getGson().toJsonTree(classifyCollectionOptions.collection()));
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassificationCollection.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Classify a phrase.
 *
 * Returns label information for the input. The status must be `Available` before you can use the classifier to
 * classify text.
 *
 * @param classifyOptions the {@link ClassifyOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Classification}
 */
public ServiceCall<Classification> classify(ClassifyOptions classifyOptions) {
 Validator.notNull(classifyOptions, "classifyOptions cannot be null");
 String[] pathSegments = { "v1/classifiers", "classify" };
 String[] pathParameters = { classifyOptions.classifierId() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 final JsonObject contentJson = new JsonObject();
 contentJson.addProperty("text", classifyOptions.text());
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classification.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Translate.
 *
 * Translates the input text from the source language to the target language.
 *
 * @param translateOptions the {@link TranslateOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link TranslationResult}
 */
public ServiceCall<TranslationResult> translate(TranslateOptions translateOptions) {
 Validator.notNull(translateOptions, "translateOptions cannot be null");
 String[] pathSegments = { "v3/translate" };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 contentJson.add("text", GsonSingleton.getGson().toJsonTree(translateOptions.text()));
 if (translateOptions.modelId() != null) {
  contentJson.addProperty("model_id", translateOptions.modelId());
 }
 if (translateOptions.source() != null) {
  contentJson.addProperty("source", translateOptions.source());
 }
 if (translateOptions.target() != null) {
  contentJson.addProperty("target", translateOptions.target());
 }
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationResult.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Create an environment.
 *
 * Creates a new environment for private data. An environment must be created before collections can be created.
 *
 * **Note**: You can create only one environment for private data per service instance. An attempt to create another
 * environment results in an error.
 *
 * @param createEnvironmentOptions the {@link CreateEnvironmentOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Environment}
 */
public ServiceCall<Environment> createEnvironment(CreateEnvironmentOptions createEnvironmentOptions) {
 Validator.notNull(createEnvironmentOptions, "createEnvironmentOptions cannot be null");
 String[] pathSegments = { "v1/environments" };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 contentJson.addProperty("name", createEnvironmentOptions.name());
 if (createEnvironmentOptions.description() != null) {
  contentJson.addProperty("description", createEnvironmentOptions.description());
 }
 if (createEnvironmentOptions.size() != null) {
  contentJson.addProperty("size", createEnvironmentOptions.size());
 }
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class));
}

代码示例来源:origin: com.ibm.watson.developer_cloud/natural-language-classifier

/**
 * Classify multiple phrases.
 *
 * Returns label information for multiple phrases. The status must be `Available` before you can use the classifier to
 * classify text.
 *
 * 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 response type of {@link ClassificationCollection}
 */
public ServiceCall<ClassificationCollection> classifyCollection(ClassifyCollectionOptions classifyCollectionOptions) {
 Validator.notNull(classifyCollectionOptions, "classifyCollectionOptions cannot be null");
 String[] pathSegments = { "v1/classifiers", "classify_collection" };
 String[] pathParameters = { classifyCollectionOptions.classifierId() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.header("X-IBMCloud-SDK-Analytics",
   "service_name=natural_language_classifier;service_version=v1;operation_id=classifyCollection");
 final JsonObject contentJson = new JsonObject();
 contentJson.add("collection", GsonSingleton.getGson().toJsonTree(classifyCollectionOptions.collection()));
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassificationCollection.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Create counterexample.
 *
 * Add a new counterexample to a workspace. Counterexamples are examples that have been marked as irrelevant input.
 *
 * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
 *
 * @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Counterexample}
 */
public ServiceCall<Counterexample> createCounterexample(CreateCounterexampleOptions createCounterexampleOptions) {
 Validator.notNull(createCounterexampleOptions, "createCounterexampleOptions cannot be null");
 String[] pathSegments = { "v1/workspaces", "counterexamples" };
 String[] pathParameters = { createCounterexampleOptions.workspaceId() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 contentJson.addProperty("text", createCounterexampleOptions.text());
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Create counterexample.
 *
 * Add a new counterexample to a workspace. Counterexamples are examples that have been marked as irrelevant input.
 *
 * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
 *
 * @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Counterexample}
 */
public ServiceCall<Counterexample> createCounterexample(CreateCounterexampleOptions createCounterexampleOptions) {
 Validator.notNull(createCounterexampleOptions, "createCounterexampleOptions cannot be null");
 String[] pathSegments = { "v1/workspaces", "counterexamples" };
 String[] pathParameters = { createCounterexampleOptions.workspaceId() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 contentJson.addProperty("text", createCounterexampleOptions.text());
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Create user input example.
 *
 * Add a new user input example to an intent.
 *
 * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
 *
 * @param createExampleOptions the {@link CreateExampleOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Example}
 */
public ServiceCall<Example> createExample(CreateExampleOptions createExampleOptions) {
 Validator.notNull(createExampleOptions, "createExampleOptions cannot be null");
 String[] pathSegments = { "v1/workspaces", "intents", "examples" };
 String[] pathParameters = { createExampleOptions.workspaceId(), createExampleOptions.intent() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 contentJson.addProperty("text", createExampleOptions.text());
 if (createExampleOptions.mentions() != null) {
  contentJson.add("mentions", GsonSingleton.getGson().toJsonTree(createExampleOptions.mentions()));
 }
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Example.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Create tokenization dictionary.
 *
 * Upload a custom tokenization dictionary to use with the specified collection.
 *
 * @param createTokenizationDictionaryOptions the {@link CreateTokenizationDictionaryOptions} containing the options
 *          for the call
 * @return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse}
 */
public ServiceCall<TokenDictStatusResponse> createTokenizationDictionary(
  CreateTokenizationDictionaryOptions createTokenizationDictionaryOptions) {
 Validator.notNull(createTokenizationDictionaryOptions, "createTokenizationDictionaryOptions cannot be null");
 String[] pathSegments = { "v1/environments", "collections", "word_lists/tokenization_dictionary" };
 String[] pathParameters = { createTokenizationDictionaryOptions.environmentId(), createTokenizationDictionaryOptions
   .collectionId() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 if (createTokenizationDictionaryOptions.tokenizationRules() != null) {
  contentJson.add("tokenization_rules", GsonSingleton.getGson().toJsonTree(createTokenizationDictionaryOptions
    .tokenizationRules()));
 }
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TokenDictStatusResponse.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Create Gateway.
 *
 * Create a gateway configuration to use with a remotely installed gateway.
 *
 * @param createGatewayOptions the {@link CreateGatewayOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Gateway}
 */
public ServiceCall<Gateway> createGateway(CreateGatewayOptions createGatewayOptions) {
 Validator.notNull(createGatewayOptions, "createGatewayOptions cannot be null");
 String[] pathSegments = { "v1/environments", "gateways" };
 String[] pathParameters = { createGatewayOptions.environmentId() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 if (createGatewayOptions.name() != null) {
  contentJson.addProperty("name", createGatewayOptions.name());
 }
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Gateway.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Test with body JSON object.
 *
 * @throws IOException Signals that an I/O exception has occurred.
 */
@Test
public void testWithBodyJsonJsonObject() throws IOException {
 final JsonObject json = new JsonObject();
 json.addProperty("status", "ok");
 final Request request = RequestBuilder.post(HttpUrl.parse(urlWithQuery)).bodyJson(json).build();
 final RequestBody requestedBody = request.body();
 final Buffer buffer = new Buffer();
 requestedBody.writeTo(buffer);
 assertEquals(json.toString(), buffer.readUtf8());
 assertEquals(HttpMediaType.JSON, requestedBody.contentType());
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Update counterexample.
 *
 * Update the text of a counterexample. Counterexamples are examples that have been marked as irrelevant input.
 *
 * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
 *
 * @param updateCounterexampleOptions the {@link UpdateCounterexampleOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Counterexample}
 */
public ServiceCall<Counterexample> updateCounterexample(UpdateCounterexampleOptions updateCounterexampleOptions) {
 Validator.notNull(updateCounterexampleOptions, "updateCounterexampleOptions cannot be null");
 String[] pathSegments = { "v1/workspaces", "counterexamples" };
 String[] pathParameters = { updateCounterexampleOptions.workspaceId(), updateCounterexampleOptions.text() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 if (updateCounterexampleOptions.newText() != null) {
  contentJson.addProperty("text", updateCounterexampleOptions.newText());
 }
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Update counterexample.
 *
 * Update the text of a counterexample. Counterexamples are examples that have been marked as irrelevant input.
 *
 * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
 *
 * @param updateCounterexampleOptions the {@link UpdateCounterexampleOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Counterexample}
 */
public ServiceCall<Counterexample> updateCounterexample(UpdateCounterexampleOptions updateCounterexampleOptions) {
 Validator.notNull(updateCounterexampleOptions, "updateCounterexampleOptions cannot be null");
 String[] pathSegments = { "v1/workspaces", "counterexamples" };
 String[] pathParameters = { updateCounterexampleOptions.workspaceId(), updateCounterexampleOptions.text() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 if (updateCounterexampleOptions.newText() != null) {
  contentJson.addProperty("text", updateCounterexampleOptions.newText());
 }
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Add entity value synonym.
 *
 * Add a new synonym to an entity value.
 *
 * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
 *
 * @param createSynonymOptions the {@link CreateSynonymOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Synonym}
 */
public ServiceCall<Synonym> createSynonym(CreateSynonymOptions createSynonymOptions) {
 Validator.notNull(createSynonymOptions, "createSynonymOptions cannot be null");
 String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" };
 String[] pathParameters = { createSynonymOptions.workspaceId(), createSynonymOptions.entity(), createSynonymOptions
   .value() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 contentJson.addProperty("synonym", createSynonymOptions.synonym());
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Add entity value synonym.
 *
 * Add a new synonym to an entity value.
 *
 * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
 *
 * @param createSynonymOptions the {@link CreateSynonymOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Synonym}
 */
public ServiceCall<Synonym> createSynonym(CreateSynonymOptions createSynonymOptions) {
 Validator.notNull(createSynonymOptions, "createSynonymOptions cannot be null");
 String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" };
 String[] pathParameters = { createSynonymOptions.workspaceId(), createSynonymOptions.entity(), createSynonymOptions
   .value() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 contentJson.addProperty("synonym", createSynonymOptions.synonym());
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class));
}

代码示例来源:origin: com.ibm.watson.developer_cloud/conversation

/**
 * Add entity value synonym.
 *
 * Add a new synonym to an entity value.
 *
 * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
 *
 * @param createSynonymOptions the {@link CreateSynonymOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Synonym}
 */
public ServiceCall<Synonym> createSynonym(CreateSynonymOptions createSynonymOptions) {
 Validator.notNull(createSynonymOptions, "createSynonymOptions cannot be null");
 String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" };
 String[] pathParameters = { createSynonymOptions.workspaceId(), createSynonymOptions.entity(), createSynonymOptions
   .value() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 contentJson.addProperty("synonym", createSynonymOptions.synonym());
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Update entity value synonym.
 *
 * Update an existing entity value synonym with new text.
 *
 * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
 *
 * @param updateSynonymOptions the {@link UpdateSynonymOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Synonym}
 */
public ServiceCall<Synonym> updateSynonym(UpdateSynonymOptions updateSynonymOptions) {
 Validator.notNull(updateSynonymOptions, "updateSynonymOptions cannot be null");
 String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" };
 String[] pathParameters = { updateSynonymOptions.workspaceId(), updateSynonymOptions.entity(), updateSynonymOptions
   .value(), updateSynonymOptions.synonym() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 if (updateSynonymOptions.newSynonym() != null) {
  contentJson.addProperty("synonym", updateSynonymOptions.newSynonym());
 }
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class));
}

代码示例来源:origin: watson-developer-cloud/java-sdk

/**
 * Update entity value synonym.
 *
 * Update an existing entity value synonym with new text.
 *
 * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
 *
 * @param updateSynonymOptions the {@link UpdateSynonymOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Synonym}
 */
public ServiceCall<Synonym> updateSynonym(UpdateSynonymOptions updateSynonymOptions) {
 Validator.notNull(updateSynonymOptions, "updateSynonymOptions cannot be null");
 String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" };
 String[] pathParameters = { updateSynonymOptions.workspaceId(), updateSynonymOptions.entity(), updateSynonymOptions
   .value(), updateSynonymOptions.synonym() };
 RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
   pathParameters));
 builder.query(VERSION, versionDate);
 final JsonObject contentJson = new JsonObject();
 if (updateSynonymOptions.newSynonym() != null) {
  contentJson.addProperty("synonym", updateSynonymOptions.newSynonym());
 }
 builder.bodyJson(contentJson);
 return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class));
}

相关文章