watson-developer-cloud / java-sdk

:1st_place_medal: Java SDK to use the IBM Watson services.
http://watson-developer-cloud.github.io/java-sdk/
Apache License 2.0
593 stars 532 forks source link

[Discovery] - Add/update configuration does not work #826

Closed chethan-89 closed 6 years ago

chethan-89 commented 6 years ago

I am using the latest Java SDK. I tried adding configuration to Discovery using Java API. But it is failing. Although the config is pushed to Discovery, when you try to open the configuration at Discovery UI it does not since the configuration is parsed and uploaded in an incorrect format.

After debugging for a while, I noticed that, when parsing local config Json, it is skipping options part of enrichment. Please look at it and get the issue resolved. We have a client waiting for this feature.

Here is the code I used to add config:

Discovery discovery = new Discovery("Version");
discovery.setEndPoint("https://gateway.watsonplatform.net/discovery/api/");
discovery.setUsernameAndPassword("username:password");
String environmentId = "Env_ID";
String configurationName = "ConfigName";

CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId);
Configuration configuration =  GsonSingleton.getGson().fromJson(
    new FileReader("config.json"), com.ibm.watson.developer_cloud.discovery.v1.model.Configuration.class);
createBuilder.configuration(configuration);
Configuration createResponse = discovery.createConfiguration(createBuilder.build()).execute();
lpatino10 commented 6 years ago

This issue is currently due to the EnrichmentOptions model being incorrectly described in the API spec. As soon as this is resolved, I'll make the change in the Java SDK.

rhorsfal commented 6 years ago

I have a PR for that I expect it to be merged later today.