use of com.ibm.watson.developer_cloud.discovery.v1.model.Environment in project java-sdk by watson-developer-cloud.
the class Discovery method createEnvironment.
/**
* Add an environment.
*
* Creates a new environment. You can create only one environment 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));
}
Aggregations