use of com.ibm.watson.developer_cloud.discovery.v1.model.UpdateEnvironmentOptions in project java-sdk by watson-developer-cloud.
the class Discovery method updateEnvironment.
/**
* Update an environment.
*
* Updates an environment. The environment's `name` and `description` parameters can be changed. You must specify a
* `name` for the environment.
*
* @param updateEnvironmentOptions the {@link UpdateEnvironmentOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Environment}
*/
public ServiceCall<Environment> updateEnvironment(UpdateEnvironmentOptions updateEnvironmentOptions) {
Validator.notNull(updateEnvironmentOptions, "updateEnvironmentOptions cannot be null");
String[] pathSegments = { "v1/environments" };
String[] pathParameters = { updateEnvironmentOptions.environmentId() };
RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
if (updateEnvironmentOptions.name() != null) {
contentJson.addProperty("name", updateEnvironmentOptions.name());
}
if (updateEnvironmentOptions.description() != null) {
contentJson.addProperty("description", updateEnvironmentOptions.description());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class));
}
Aggregations