Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e2161fb
Merge branch 'master' into develop
germanattanasio Apr 13, 2018
9b27f08
feat(core): Add initial changes for IAM support
lpatino10 Apr 17, 2018
da47bdc
feat(assistant): Add testing lines for IAM support
lpatino10 Apr 17, 2018
1a503be
feat(assistant): Add newest generated code
lpatino10 Apr 17, 2018
95abd24
test(assistant): Update tests for new functionality
lpatino10 Apr 17, 2018
6b41053
feat(conversation): Add newest generated functionality
lpatino10 Apr 17, 2018
d5282e4
test(assistant): Fix failing unit tests
lpatino10 Apr 17, 2018
65dec98
test(conversation): Update tests for new functionality
lpatino10 Apr 17, 2018
0ddfc96
docs(language-translator): Update code documentation
lpatino10 Apr 17, 2018
64d27a0
docs(natural-language-understanding): Add newest generated doc changes
lpatino10 Apr 17, 2018
8303306
docs(personality-insights): Add newest generated code docs
lpatino10 Apr 17, 2018
d4b7347
docs(speech-to-text): Add newest generated code docs
lpatino10 Apr 17, 2018
c5196ae
docs(text-to-speech): Add newest generated code docs
lpatino10 Apr 17, 2018
f4b6bd2
docs(tone-analyzer): Add newest generated code docs
lpatino10 Apr 17, 2018
46ee496
test(speech-to-text): Fix failing unit tests
lpatino10 Apr 17, 2018
3a841e4
refactor(core): Use proper form to make IAM API call and switch to ha…
lpatino10 Apr 18, 2018
b71dd66
docs(personality-insights, nlu): Address review comments about docs
lpatino10 Apr 18, 2018
a671643
style(core): Add comments, style changes for clarity
lpatino10 Apr 18, 2018
5f8cf38
refactor(core): Return just the access token string from requestToken…
lpatino10 Apr 18, 2018
8aaae7c
refactor(core): Use constructor instead of builder for IamToken
lpatino10 Apr 18, 2018
d39dbdf
refactor(core): Change options model for IAM and keep user-managed to…
lpatino10 Apr 18, 2018
1bc675e
refactor(core): Don't accept refresh token when instantiating service…
lpatino10 Apr 18, 2018
9b49c96
refactor(core): Replace IAM ServiceCall implementation with a single …
lpatino10 Apr 18, 2018
9b621ad
feat(core): Add method to set user-managed access token outside of co…
lpatino10 Apr 18, 2018
3dffb61
refactor(core): Tweak manner of setting IAM credentials from user POV…
lpatino10 Apr 18, 2018
0c86ade
feat(core): Get IAM API key from VCAP_SERVICES if available
lpatino10 Apr 18, 2018
9e60eeb
test(core): Add test for getting IAM API key from VCAP_SERVICES
lpatino10 Apr 18, 2018
06f61dd
test(core): Add remaining IAM unit tests
lpatino10 Apr 18, 2018
170b94e
refactor(assistant): Remove changes for testing specifically in Assis…
lpatino10 Apr 18, 2018
2b99d4a
Merge pull request #920 from watson-developer-cloud/codegen/assistant
lpatino10 Apr 18, 2018
48d2d03
Merge branch 'develop' into codegen/conversation
lpatino10 Apr 18, 2018
de9a05d
Merge pull request #921 from watson-developer-cloud/codegen/conversation
lpatino10 Apr 18, 2018
765429f
Merge branch 'develop' into codegen/language-translator
lpatino10 Apr 18, 2018
f998241
Merge pull request #922 from watson-developer-cloud/codegen/language-…
lpatino10 Apr 18, 2018
0350529
Merge branch 'develop' into codegen/natural-language-understanding
lpatino10 Apr 18, 2018
5c5344b
Merge pull request #923 from watson-developer-cloud/codegen/natural-l…
lpatino10 Apr 18, 2018
0042d10
Merge branch 'develop' into codegen/personality-insights
lpatino10 Apr 18, 2018
e098c46
Merge pull request #924 from watson-developer-cloud/codegen/personali…
lpatino10 Apr 18, 2018
5dfb7db
Merge branch 'develop' into codegen/speech-to-text
lpatino10 Apr 18, 2018
631d877
Merge pull request #925 from watson-developer-cloud/codegen/speech-to…
lpatino10 Apr 18, 2018
c8010b4
Merge branch 'develop' into codegen/text-to-speech
lpatino10 Apr 18, 2018
65f3f1e
Merge pull request #926 from watson-developer-cloud/codegen/text-to-s…
lpatino10 Apr 18, 2018
0d86cac
Merge branch 'develop' into codegen/tone-analyzer
lpatino10 Apr 18, 2018
55f9868
Merge pull request #927 from watson-developer-cloud/codegen/tone-anal…
lpatino10 Apr 18, 2018
c0ba4aa
Merge branch 'develop' into iam-support
lpatino10 Apr 19, 2018
722ca5c
feat(service-constructors): Add constructors for IAM authentication
lpatino10 Apr 19, 2018
235f273
refactor(services): Fix merge conflicts
lpatino10 Apr 19, 2018
3341a8d
fix(conversation): Add back method that accidentally got deleted
lpatino10 Apr 19, 2018
34577e1
feat(core): Add check for expired refresh token
lpatino10 Apr 19, 2018
33ab80b
style(nlu): Fix checkstyle complaint
lpatino10 Apr 19, 2018
25c7a7d
fix(core): Fix null check in IAM logic
lpatino10 Apr 19, 2018
f61a9a3
feat(core): Pull IAM URL from VCAP_SERVICES
lpatino10 Apr 19, 2018
772ae6a
style(core): Use string constants for IAM logic
lpatino10 Apr 19, 2018
66773bd
refactor(core): Only expose getToken method in IamTokenManager
lpatino10 Apr 20, 2018
6f80223
docs(main README): Add documentation about using IAM
lpatino10 Apr 20, 2018
31c42de
docs(main README): Address review comments
lpatino10 Apr 20, 2018
f44c5af
refactor(core): Allow tokenManager creation if IAM URL is not in VCAP…
lpatino10 Apr 20, 2018
2a1f307
Merge pull request #929 from watson-developer-cloud/iam-support
lpatino10 Apr 20, 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
88 changes: 83 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ Java client library to use the [Watson APIs][wdc].
* [Gradle](#gradle)
* [Usage](#usage)
* [Running in IBM Cloud](#running-in-ibm-cloud)
* [Getting the Service Credentials](#getting-the-service-credentials)
* [Authentication](#authentication)
* [Username and Password](#username-and-password)
* [API Key](#api-key)
* [Using IAM](#using-iam)
* IBM Watson Services
* [Assistant](assistant)
* [Discovery](discovery)
Expand Down Expand Up @@ -123,17 +126,92 @@ credentials; the library will get them for you by looking at the [`VCAP_SERVICES
When running in IBM Cloud (or other platforms based on Cloud Foundry), the library will automatically get the credentials from [`VCAP_SERVICES`][vcap_services].
If you have more than one plan, you can use `CredentialUtils` to get the service credentials for an specific plan.

## Getting the Service Credentials
## Authentication

You will need the `username` and `password` (`api_key` for Visual Recognition) credentials, and the API endpoint for each service. Service credentials are different from your IBM Cloud account username and password.
There are three ways to authenticate with IBM Cloud through the SDK: using a `username` and `password`, using an `api_key`, and with IAM.

To get your service credentials, follow these steps:
Getting the credentials necessary for authentication is the same process for all methods. To get them, follow these steps:

1. Log in to [IBM Cloud](https://console.bluemix.net/catalog?category=watson)
1. In the IBM Cloud **Catalog**, select the service you want to use.
1. Click **Create**.
1. On the left side of the page, click **Service Credentials**, and then **View credentials** to view your service credentials.
1. Copy `url`, `username` and `password`(`api_key` for AlchemyAPI or Visual Recognition).
1. Copy the necessary credentials (`url`, `username`, `password`, `api_key`, `apikey`, etc.).

In your code, you can use these values in the service constructor or with a method call after instantiating your service. Here are some examples:

### Username and Password

```java
// in the constructor
Discovery service = new Discovery("2017-11-07", "<username>", "<password>");
```

```java
// after instantiation
Discovery service = new Discovery("2017-11-07");
service.setUsernameAndPassword("<username>", "<password>");
```

### API Key

_Note: This version of instantiation only works with Visual Recognition, as it's the only service that uses an API key rather than a username and password._

```java
// in the constructor
VisualRecognition service = new VisualRecognition("2016-05-20", "<api_key>");
```

```java
// after instantiation
VisualRecognition service = new VisualRecognition("2016-05-20");
service.setApiKey("<api_key>");
```

### Using IAM

When authenticating with IAM, you have the option of passing in:
- the IAM API key and, optionally, the IAM service URL
- an IAM access token

**Be aware that passing in an access token means that you're assuming responsibility for maintaining that token's lifecycle.** If you instead pass in an IAM API key, the SDK will manage it for you.

```java
// in the constructor, letting the SDK manage the IAM token
IamOptions options = new IamOptions.Builder()
.apiKey("<iam_api_key>")
.url("<iam_url>") // optional - the default value is https://iam.ng.bluemix.net/identity/token
.build();
Discovery service = new Discovery("2017-11-07", options);
```

```java
// after instantiation, letting the SDK manage the IAM token
Discovery service = new Discovery("2017-11-07");
IamOptions options = new IamOptions.Builder()
.apiKey("<iam_api_key>")
.build();
service.setIamCredentials(options);
```

```java
// in the constructor, assuming control of managing IAM token
IamOptions options = new IamOptions.Builder()
.accessToken("<access_token>")
.build();
Discovery service = new Discovery("2017-11-07", options);
```

```java
// after instantiation, assuming control of managing IAM token
Discovery service = new Discovery("2017-11-07");
IamOptions options = new IamOptions.Builder()
.accessToken("<access_token>")
.build();
service.setIamCredentials(options);
```

If at any time you would like to let the SDK take over managing your IAM token, simply override your stored IAM credentials with an IAM API key by calling the `setIamCredentials()` method again.

## Android

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import com.ibm.watson.developer_cloud.http.RequestBuilder;
import com.ibm.watson.developer_cloud.http.ServiceCall;
import com.ibm.watson.developer_cloud.service.WatsonService;
import com.ibm.watson.developer_cloud.service.security.IamOptions;
import com.ibm.watson.developer_cloud.util.GsonSingleton;
import com.ibm.watson.developer_cloud.util.ResponseConverterUtils;
import com.ibm.watson.developer_cloud.util.Validator;
Expand Down Expand Up @@ -129,6 +130,20 @@ public Assistant(String versionDate, String username, String password) {
setUsernameAndPassword(username, password);
}

/**
* Instantiates a new `Assistant` with IAM. Note that if the access token is specified in the iamOptions,
* you accept responsibility for managing the access token yourself. You must set a new access token before this one
* expires. Failing to do so will result in authentication errors after this token expires.
*
* @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API
* calls from failing when the service introduces breaking changes.
* @param iamOptions the options for authenticating through IAM
*/
public Assistant(String versionDate, IamOptions iamOptions) {
this(versionDate);
setIamCredentials(iamOptions);
}

/**
* Get a response to a user's input. There is no rate limit for this operation.
*
Expand Down Expand Up @@ -278,8 +293,8 @@ public ServiceCall<WorkspaceExport> getWorkspace(GetWorkspaceOptions getWorkspac
/**
* List workspaces.
*
* List the workspaces associated with an Assistant service instance. This operation is limited to 500 requests per 30
* minutes. For more information, see **Rate limiting**.
* List the workspaces associated with a Watson Assistant service instance. This operation is limited to 500 requests
* per 30 minutes. For more information, see **Rate limiting**.
*
* @param listWorkspacesOptions the {@link ListWorkspacesOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection}
Expand Down Expand Up @@ -311,8 +326,8 @@ public ServiceCall<WorkspaceCollection> listWorkspaces(ListWorkspacesOptions lis
/**
* List workspaces.
*
* List the workspaces associated with an Assistant service instance. This operation is limited to 500 requests per 30
* minutes. For more information, see **Rate limiting**.
* List the workspaces associated with a Watson Assistant service instance. This operation is limited to 500 requests
* per 30 minutes. For more information, see **Rate limiting**.
*
* @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
*/
package com.ibm.watson.developer_cloud.assistant.v1.model;

import com.google.gson.annotations.SerializedName;
import com.ibm.watson.developer_cloud.service.model.GenericModel;
import com.ibm.watson.developer_cloud.util.Validator;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.google.gson.annotations.SerializedName;
import com.ibm.watson.developer_cloud.service.model.GenericModel;
import com.ibm.watson.developer_cloud.util.Validator;

/**
* CreateDialogNode.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
*/
package com.ibm.watson.developer_cloud.assistant.v1.model;

import com.google.gson.annotations.SerializedName;
import com.ibm.watson.developer_cloud.service.model.GenericModel;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.google.gson.annotations.SerializedName;
import com.ibm.watson.developer_cloud.service.model.GenericModel;

/**
* DialogNode.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class DialogNodeVisitedDetails extends GenericModel {
@SerializedName("dialog_node")
private String dialogNode;
private String title;
private String conditions;

/**
* Gets the dialogNode.
Expand All @@ -46,6 +47,17 @@ public String getTitle() {
return title;
}

/**
* Gets the conditions.
*
* The conditions that trigger the dialog node.
*
* @return the conditions
*/
public String getConditions() {
return conditions;
}

/**
* Sets the dialogNode.
*
Expand All @@ -63,4 +75,13 @@ public void setDialogNode(final String dialogNode) {
public void setTitle(final String title) {
this.title = title;
}

/**
* Sets the conditions.
*
* @param conditions the new conditions
*/
public void setConditions(final String conditions) {
this.conditions = conditions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public Long pageLimit() {
/**
* Gets the cursor.
*
* A token identifying the last object from the previous page of results.
* A token identifying the page of results to retrieve.
*
* @return the cursor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public String sort() {
/**
* Gets the cursor.
*
* A token identifying the last object from the previous page of results.
* A token identifying the page of results to retrieve.
*
* @return the cursor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public String sort() {
/**
* Gets the cursor.
*
* A token identifying the last object from the previous page of results.
* A token identifying the page of results to retrieve.
*
* @return the cursor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public String sort() {
/**
* Gets the cursor.
*
* A token identifying the last object from the previous page of results.
* A token identifying the page of results to retrieve.
*
* @return the cursor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public String sort() {
/**
* Gets the cursor.
*
* A token identifying the last object from the previous page of results.
* A token identifying the page of results to retrieve.
*
* @return the cursor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public String sort() {
/**
* Gets the cursor.
*
* A token identifying the last object from the previous page of results.
* A token identifying the page of results to retrieve.
*
* @return the cursor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public Long pageLimit() {
/**
* Gets the cursor.
*
* A token identifying the last object from the previous page of results.
* A token identifying the page of results to retrieve.
*
* @return the cursor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public String sort() {
/**
* Gets the cursor.
*
* A token identifying the last object from the previous page of results.
* A token identifying the page of results to retrieve.
*
* @return the cursor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public String sort() {
/**
* Gets the cursor.
*
* A token identifying the last object from the previous page of results.
* A token identifying the page of results to retrieve.
*
* @return the cursor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public String sort() {
/**
* Gets the cursor.
*
* A token identifying the last object from the previous page of results.
* A token identifying the page of results to retrieve.
*
* @return the cursor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.ibm.watson.developer_cloud.service.model.GenericModel;

/**
* A request formatted for the Assistant service.
* A request formatted for the Watson Assistant service.
*/
public class MessageRequest extends GenericModel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.ibm.watson.developer_cloud.util.GsonSerializationHelper;

/**
* A response from the Assistant service.
* A response from the Watson Assistant service.
*/
public class MessageResponse extends DynamicModel {
private Type inputType = new TypeToken<MessageInput>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
* specific language governing permissions and limitations under the License.
*/
/**
* Assistant v1.
* Watson Assistant v1.
*/
package com.ibm.watson.developer_cloud.assistant.v1;
Loading