Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bb9687b
feat(core): Add model for specifying client config options
lpatino10 Sep 17, 2018
a7f9154
feat(core): Add ability to disable SSL cert verification
lpatino10 Sep 17, 2018
32a92db
feat(core): Add method to set custom proxy
lpatino10 Sep 17, 2018
dec2824
docs(README): Add information about configuring HTTP client
lpatino10 Sep 18, 2018
c9cae34
test(core): Add unit test for HttpConfigOptions
lpatino10 Sep 18, 2018
b7c086e
revert(Assistant v1): Revert erroneous addition of actions property t…
lpatino10 Sep 18, 2018
11dba3d
feat(Assistant v2): Add generated Assistant v2 classes
lpatino10 Sep 18, 2018
f40edd0
docs(Speech to Text): Edit code comments
lpatino10 Sep 18, 2018
bf38cec
build: Don't fail Travis on Javadoc complaints
lpatino10 Sep 18, 2018
9dbfcf6
build: Ignore javadoc linting on Java 8
lpatino10 Sep 19, 2018
d2fd2d0
refactor(Tone Analyzer): Change how tone() bodyContent is set
lpatino10 Sep 19, 2018
2bda500
test(Assistant v2): Add unit and integration tests
lpatino10 Sep 20, 2018
2e552ab
docs(Assistant): Add example and announcement for v2
lpatino10 Sep 20, 2018
71d9da9
Merge pull request #989 from watson-developer-cloud/disable-ssl-verif…
lpatino10 Sep 21, 2018
7db6428
build: Update credentials for Assistant v2
lpatino10 Sep 21, 2018
d3f79ed
Merge branch 'codegen-updates' of https://github.com/watson-developer…
lpatino10 Sep 21, 2018
ae86b82
test: Remove mentions checks in testing
lpatino10 Sep 22, 2018
12ad4e6
ci: Update credentials for testing
lpatino10 Sep 22, 2018
f784e86
test(Discovery): Ignore problematic test due to service
lpatino10 Sep 22, 2018
567f8e9
test(Speech to Text): Use premade acoustic model to speed up tests
lpatino10 Sep 22, 2018
87ead3d
test(Natural Language Classifier): Refactor deleteClassifier test
lpatino10 Sep 22, 2018
467af69
docs: Update version numbers from 6.6.0 -> 6.7.0
lpatino10 Sep 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 6.6.0
current_version = 6.7.0
commit = True
message = docs: Update version numbers from {current_version} -> {new_version}

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ before_script:
- 'if [ "${TRAVIS_TAG}" = "${TRAVIS_BRANCH}" ]; then chmod a+x ./appscan/ASOC.sh; fi'

script:
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_b248e84a4806_key -iv $encrypted_b248e84a4806_iv -in config.properties.enc -out core/src/test/resources/config.properties -d || true'
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_42d9c68e608d_key -iv $encrypted_42d9c68e608d_iv -in config.properties.enc -out core/src/test/resources/config.properties -d || true'
- 'if [ "${TRAVIS_TAG}" = "${TRAVIS_BRANCH}" ]; then ./appscan/ASOC.sh; fi'
- ./gradlew install -x check
- ./gradlew checkstyleMain
Expand Down
49 changes: 20 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Java client library to use the [Watson APIs][wdc].
* [Tradeoff Analytics](tradeoff-analytics)
* [Visual Recognition](visual-recognition)
* [Android](#android)
* [Using a proxy](#using-a-proxy)
* [Configuring the HTTP client](#configuring-the-http-client)
* [Default headers](#default-headers)
* [Sending request headers](#sending-request-headers)
* [Parsing HTTP response info](#parsing-http-response-info)
Expand All @@ -60,7 +60,7 @@ All the services:
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>java-sdk</artifactId>
<version>6.6.0</version>
<version>6.7.0</version>
</dependency>
```

Expand All @@ -70,7 +70,7 @@ Only Discovery:
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>discovery</artifactId>
<version>6.6.0</version>
<version>6.7.0</version>
</dependency>
```

Expand All @@ -79,13 +79,13 @@ Only Discovery:
All the services:

```gradle
'com.ibm.watson.developer_cloud:java-sdk:6.6.0'
'com.ibm.watson.developer_cloud:java-sdk:6.7.0'
```

Only Assistant:

```gradle
'com.ibm.watson.developer_cloud:assistant:6.6.0'
'com.ibm.watson.developer_cloud:assistant:6.7.0'
```

##### Development snapshots
Expand All @@ -108,7 +108,7 @@ And then reference the snapshot version on your app module gradle
Only Speech to Text:

```gradle
'com.ibm.watson.developer_cloud:speech-to-text:6.6.1-SNAPSHOT'
'com.ibm.watson.developer_cloud:speech-to-text:6.7.1-SNAPSHOT'
```

##### JAR
Expand Down Expand Up @@ -228,33 +228,24 @@ service.setApiKey("<api_key>");

The Android SDK utilizes the Java SDK while making some Android-specific additions. This repository can be found [here](https://github.com/watson-developer-cloud/android-sdk). It depends on [OkHttp][] and [gson][].

## Using a proxy
## Configuring the HTTP client

Override the `configureHttpClient()` method and add the proxy using the `OkHttpClient.Builder` object.
The HTTP client can be configured by using the `configureClient()` method on your service object, passing in an `HttpConfigOptions` object. Currently, the following options are supported:
- Disabling SSL verification (only do this if you really mean to!) ⚠️
- Using a proxy (more info here: [OkHTTPClient Proxy authentication how to?](https://stackoverflow.com/a/35567936/456564))

For example:
Here's an example of setting both of the above:

```java
Assistant service = new Assistant("2018-02-16") {
@Override
protected OkHttpClient configureHttpClient() {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", 8080));
return super.configureHttpClient().newBuilder().proxy(proxy).build();
}
};

service.setUsernameAndPassword("<username>", "<password>");

WorkspaceCollection workspaces = service.listWorkspaces().execute();
System.out.println(workspaces);
```
Discovery service = new Discovery("2017-11-07");

For more information see: [OkHTTPClient Proxy authentication how to?](https://stackoverflow.com/a/35567936/456564)
// setting configuration options
HttpConfigOptions options = new HttpConfigOptions.Builder()
.disableSslVerification(true)
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", 8080)))
.build();

```java
PersonalityInsights service = new PersonalityInsights("2016-10-19");
String apiKey = CredentialUtils.getAPIKey(service.getName(), CredentialUtils.PLAN_STANDARD);
service.setApiKey(apiKey);
service.configureClient(options);
```

## Sending request headers
Expand Down Expand Up @@ -375,7 +366,7 @@ Gradle:

```sh
cd java-sdk
gradle jar # build jar file (build/libs/watson-developer-cloud-6.6.0.jar)
gradle jar # build jar file (build/libs/watson-developer-cloud-6.7.0.jar)
gradle test # run tests
gradle check # performs quality checks on source files and generates reports
gradle testReport # run tests and generate the aggregated test report (build/reports/allTests)
Expand Down Expand Up @@ -428,4 +419,4 @@ or [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-watson).
[ibm-cloud-onboarding]: http://console.bluemix.net/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Java


[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-6.6.0/java-sdk-6.6.0-jar-with-dependencies.jar
[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-6.7.0/java-sdk-6.7.0-jar-with-dependencies.jar
80 changes: 74 additions & 6 deletions assistant/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
# Assistant

## Assistant v2 is now available :tada::tada::tada:
Check it out in the `assistant/v2` folder.

## Installation

##### Maven
```xml
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>assistant</artifactId>
<version>6.6.0</version>
<version>6.7.0</version>
</dependency>
```

##### Gradle
```gradle
'com.ibm.watson.developer_cloud:assistant:6.6.0'
'com.ibm.watson.developer_cloud:assistant:6.7.0'
```

## Usage

Use the [Assistant][assistant] service to identify intents, entities, and conduct conversations.

### Using Assistant v1
```java
// make sure to use the Assistant v1 import!
import com.ibm.watson.developer_cloud.assistant.v1.Assistant;

Assistant service = new Assistant("2018-02-16");
service.setUsernameAndPassword("<username>", "<password>");

Expand All @@ -32,9 +38,11 @@ MessageResponse response = service.message(options).execute();
System.out.println(response);
```

Moving from Node 1 to Node 2.

Maintaining context across messages:
```java
// make sure to use the Assistant v1 import!
import com.ibm.watson.developer_cloud.assistant.v1.Assistant;

Context context = null;

// first message
Expand All @@ -45,17 +53,77 @@ MessageOptions newMessageOptions = new MessageOptions.Builder()
.build();

MessageResponse response = service.message(newMessageOptions).execute();
context = response.getContext();

// second message
newMessageOptions = new MessageOptions.Builder()
.workspaceId("<workspace-id>")
.input(new InputData.Builder("Second message").build())
.context(response.getContext()) // output context from the first message
.context(context) // using context from the first message
.build();

response = service.message(newMessageOptions).execute();

System.out.println(response);
```

---

### Using Assistant v2
```java
// make sure to use the Assistant v2 import!
import com.ibm.watson.developer_cloud.assistant.v2.Assistant;

Assistant service = new Assistant("2018-09-20");
service.setUsernameAndPassword("<username>", "<password>");

MessageInput input = new MessageInput.Builder()
.text("Hi")
.build();
MessageOptions messageOptions = new MessageOptions.Builder()
.assistantId("<assistant_id>")
.sessionId("<session_id>")
.input(input)
.build();
MessageResponse messageResponse = service.message(messageOptions).execute();

System.out.println(messageResponse);
```

Maintaining context across messages:
```java
// make sure to use the Assistant v2 import!
import com.ibm.watson.developer_cloud.assistant.v2.Assistant;

MessageContext context = new MessageContext();

// first message
MessageInput input = new MessageInput.Builder()
.text("First message")
.build();
MessageOptions messageOptions = new MessageOptions.Builder()
.assistantId(assistantId)
.sessionId(sessionId)
.input(input)
.context(context)
.build();

MessageResponse messageResponse = service.message(messageOptions).execute();
context = messageResponse.getContext();

// second message
input = new MessageInput.Builder()
.text("Second message")
.build();
messageOptions = new MessageOptions.Builder()
.assistantId(assistantId)
.sessionId(sessionId)
.input(input)
.context(context) // using context from first message
.build();

messageResponse = service.message(messageOptions).execute();

System.out.println(messageResponse);
```
[assistant]: https://console.bluemix.net/docs/services/assistant/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public class OutputData extends DynamicModel {
}.getType();
private Type nodesVisitedDetailsType = new TypeToken<List<DialogNodeVisitedDetails>>() {
}.getType();
private Type actionsType = new TypeToken<List<DialogNodeAction>>() {
}.getType();

/**
* Gets the logMessages.
Expand Down Expand Up @@ -83,15 +81,6 @@ public List<DialogNodeVisitedDetails> getNodesVisitedDetails() {
nodesVisitedDetailsType);
}

/**
* Gets the actions.
*
* @return the actions
*/
public List<DialogNodeAction> getActions() {
return GsonSerializationHelper.serializeDynamicModelProperty(this.get("actions"), actionsType);
}

/**
* Sets the logMessages.
*
Expand Down Expand Up @@ -136,13 +125,4 @@ public void setNodesVisited(final List<String> nodesVisited) {
public void setNodesVisitedDetails(final List<DialogNodeVisitedDetails> nodesVisitedDetails) {
this.put("nodes_visited_details", nodesVisitedDetails);
}

/**
* Sets the actions.
*
* @param actions the new actions
*/
public void setActions(final List<DialogNodeAction> actions) {
this.put("actions", actions);
}
}
Loading