Search in sources :

Example 1 with UpdateEnvironmentOptions

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));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) JsonObject(com.google.gson.JsonObject) Environment(com.ibm.watson.developer_cloud.discovery.v1.model.Environment)

Aggregations

JsonObject (com.google.gson.JsonObject)1 Environment (com.ibm.watson.developer_cloud.discovery.v1.model.Environment)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1