Skip to content

Commit bb661da

Browse files
authored
Merge pull request #960 from watson-developer-cloud/develop
Release v6.1.1
2 parents f55fac7 + 2feb57e commit bb661da

File tree

3 files changed

+82
-64
lines changed

3 files changed

+82
-64
lines changed

README.md

Lines changed: 75 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ Java client library to use the [Watson APIs][wdc].
99

1010
<details>
1111
<summary>Table of Contents</summary>
12-
12+
* [Before you begin](#before-you-begin)
1313
* [Installation](#installation)
1414
* [Maven](#maven)
1515
* [Gradle](#gradle)
1616
* [Usage](#usage)
1717
* [Running in IBM Cloud](#running-in-ibm-cloud)
1818
* [Authentication](#authentication)
19-
* [Username and Password](#username-and-password)
20-
* [API Key](#api-key)
21-
* [Using IAM](#using-iam)
19+
* [IAM](#iam)
20+
* [Username and password](#username-and-password)
21+
* [API key](#api-key)
2222
* IBM Watson Services
2323
* [Assistant](assistant)
2424
* [Discovery](discovery)
@@ -32,12 +32,12 @@ Java client library to use the [Watson APIs][wdc].
3232
* [Tradeoff Analytics](tradeoff-analytics)
3333
* [Visual Recognition](visual-recognition)
3434
* [Android](#android)
35-
* [Using a Proxy](#using-a-proxy)
36-
* [Default Headers](#default-headers)
37-
* [Sending Request Headers](#sending-request-headers)
38-
* [Parsing HTTP Response Info](#parsing-http-response-info)
39-
* [Specifying a Service URL](#specifying-a-service-url)
40-
* [401 Unauthorized Error](#401-unauthorized-error)
35+
* [Using a proxy](#using-a-proxy)
36+
* [Default headers](#default-headers)
37+
* [Sending request headers](#sending-request-headers)
38+
* [Parsing HTTP response info](#parsing-http-response-info)
39+
* [Specifying a service URL](#specifying-a-service-url)
40+
* [401 unauthorized error](#401-unauthorized-error)
4141
* [Changes for v4.0](#changes-for-v40)
4242
* [Debug](#debug)
4343
* [Eclipse and Intellij](#working-with-eclipse-and-intellij-idea)
@@ -46,6 +46,9 @@ Java client library to use the [Watson APIs][wdc].
4646

4747
</details>
4848

49+
## Before you begin
50+
* You need an [IBM Cloud][ibm-cloud-onboarding] account.
51+
4952
## Installation
5053

5154
##### Maven
@@ -84,7 +87,7 @@ Only Assistant:
8487
'com.ibm.watson.developer_cloud:assistant:6.1.0'
8588
```
8689

87-
##### Development Snapshots
90+
##### Development snapshots
8891

8992
Snapshots of the development version are available in [Sonatype's snapshots repository][sonatype_snapshots].
9093

@@ -116,7 +119,7 @@ Now, you are ready to see some [examples](https://github.com/watson-developer-cl
116119
## Usage
117120

118121
The examples within each service assume that you already have service credentials. If not,
119-
you will have to create a service in [IBM Cloud][ibm_cloud].
122+
you will have to [create a service](#getting-credentials) in IBM Cloud.
120123

121124
If you are running your application in IBM Cloud (or other platforms based on Cloud Foundry), you don't need to specify the
122125
credentials; the library will get them for you by looking at the [`VCAP_SERVICES`][vcap_services] environment variable.
@@ -128,54 +131,33 @@ If you have more than one plan, you can use `CredentialUtils` to get the service
128131

129132
## Authentication
130133

131-
There are three ways to authenticate with IBM Cloud through the SDK: using a `username` and `password`, using an `api_key`, and with IAM.
132-
133-
Getting the credentials necessary for authentication is the same process for all methods. To get them, follow these steps:
134-
135-
1. Log in to [IBM Cloud](https://console.bluemix.net/catalog?category=watson)
136-
1. In the IBM Cloud **Catalog**, select the service you want to use.
137-
1. Click **Create**.
138-
1. On the left side of the page, click **Service Credentials**, and then **View credentials** to view your service credentials.
139-
1. Copy the necessary credentials (`url`, `username`, `password`, `api_key`, `apikey`, etc.).
140-
141-
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:
142-
143-
### Username and Password
134+
Watson services are migrating to token-based Identity and Access Management (IAM) authentication.
144135

145-
```java
146-
// in the constructor
147-
Discovery service = new Discovery("2017-11-07", "<username>", "<password>");
148-
```
136+
- With some service instances, you authenticate to the API by using **[IAM](#iam)**.
137+
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
138+
- Visual Recognition uses a form of [API key](#api-key) only with instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam).
149139

150-
```java
151-
// after instantiation
152-
Discovery service = new Discovery("2017-11-07");
153-
service.setUsernameAndPassword("<username>", "<password>");
154-
```
140+
### Getting credentials
141+
To find out which authentication to use, view the service credentials. You find the service credentials for authentication the same way for all Watson services:
155142

156-
### API Key
143+
1. Go to the IBM Cloud **[Dashboard][watson-dashboard]** page.
144+
1. Either click an existing Watson service instance or click **Create**.
145+
1. Click **Show** to view your service credentials.
146+
1. Copy the `url` and either `apikey` or `username` and `password`.
157147

158-
_Important: Instantiation with API key works only with Visual Recognition service instances created before May 23, 2018. Visual Recognition instances created after May 22 use IAM._
148+
In your code, you can use these values in the service constructor or with a method call after instantiating your service.
159149

160-
```java
161-
// in the constructor
162-
VisualRecognition service = new VisualRecognition("2016-05-20", "<api_key>");
163-
```
150+
### IAM
164151

165-
```java
166-
// after instantiation
167-
VisualRecognition service = new VisualRecognition("2016-05-20");
168-
service.setApiKey("<api_key>");
169-
```
152+
Some services use token-based Identity and Access Management (IAM) authentication. IAM authentication uses a service API key to get an access token that is passed with the call. Access tokens are valid for approximately one hour and must be regenerated.
170153

171-
### Using IAM
154+
You supply either an IAM service **API key** or an **access token**:
172155

173-
When authenticating with IAM, you have the option of passing in:
174-
- the IAM API key and, optionally, the IAM service URL
175-
- an IAM access token
156+
- Use the API key to have the SDK manage the lifecycle of the access token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary.
157+
- Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://console.bluemix.net/docs/services/watson/getting-started-iam.html). If you want to switch to API key, override your stored IAM credentials with an IAM API key. Then call the `setIamCredentials()` method again.
176158

177-
**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.
178159

160+
#### Supplying the IAM API key
179161
```java
180162
// in the constructor, letting the SDK manage the IAM token
181163
IamOptions options = new IamOptions.Builder()
@@ -194,6 +176,7 @@ IamOptions options = new IamOptions.Builder()
194176
service.setIamCredentials(options);
195177
```
196178

179+
#### Supplying the access token
197180
```java
198181
// in the constructor, assuming control of managing IAM token
199182
IamOptions options = new IamOptions.Builder()
@@ -211,13 +194,39 @@ IamOptions options = new IamOptions.Builder()
211194
service.setIamCredentials(options);
212195
```
213196

214-
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.
197+
### Username and password
198+
199+
```java
200+
// in the constructor
201+
Discovery service = new Discovery("2017-11-07", "<username>", "<password>");
202+
```
203+
204+
```java
205+
// after instantiation
206+
Discovery service = new Discovery("2017-11-07");
207+
service.setUsernameAndPassword("<username>", "<password>");
208+
```
209+
210+
### API key
211+
212+
**Important**: This type of authentication works only with Visual Recognition instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam).
213+
214+
```java
215+
// in the constructor
216+
VisualRecognition service = new VisualRecognition("2016-05-20", "<api_key>");
217+
```
218+
219+
```java
220+
// after instantiation
221+
VisualRecognition service = new VisualRecognition("2016-05-20");
222+
service.setApiKey("<api_key>");
223+
```
215224

216225
## Android
217226

218227
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][].
219228

220-
## Using a Proxy
229+
## Using a proxy
221230

222231
Override the `configureHttpClient()` method and add the proxy using the `OkHttpClient.Builder` object.
223232

@@ -246,7 +255,7 @@ String apiKey = CredentialUtils.getAPIKey(service.getName(), CredentialUtils.PLA
246255
service.setApiKey(apiKey);
247256
```
248257

249-
## Sending Request Headers
258+
## Sending request headers
250259

251260
Custom headers can be passed with any request. To do so, add the header to the `ServiceCall` object before executing the request. For example, this is what it looks like to send the header `Custom-Header` along with a call to the Watson Assistant service:
252261

@@ -256,7 +265,7 @@ WorkspaceCollection workspaces = service.listWorkspaces()
256265
.execute();
257266
```
258267

259-
## Parsing HTTP Response Info
268+
## Parsing HTTP response info
260269

261270
The basic `execute()`, `enqueue()`, and `rx()` methods make HTTP requests to your Watson service and return models based on the requested endpoint. If you would like access to some HTTP response information along with the response model, you can use the more detailed versions of those three methods: `executeWithDetails()`, `enqueueWithDetails()`, and `rxWithDetails()`. To capture the responses, use the new `Response<T>` class, with `T` being the expected response model.
262271

@@ -287,7 +296,7 @@ service.listWorkspaces().enqueueWithDetails(new ServiceCallbackWithDetails<Works
287296
});
288297
```
289298

290-
## Default Headers
299+
## Default headers
291300

292301
Default headers can be specified at any time by using the `setDefaultHeaders(Map<String, String> headers)` method.
293302

@@ -304,11 +313,11 @@ service.setDefaultHeaders(headers);
304313
// All the api calls from now on will send the default headers
305314
```
306315

307-
## Specifying a Service URL
316+
## Specifying a service URL
308317

309-
You can set the correct API Endpoint for your service calling `setEndPoint()`.
318+
You can set the correct API endpoint for your service calling `setEndPoint()`.
310319

311-
For example, if you have the Discovery service in Germany, the Endpoint may be `https://gateway-fra.watsonplatform.net/discovery/api`.
320+
For example, if you have the Discovery service in Germany, the endpoint may be `https://gateway-fra.watsonplatform.net/discovery/api`.
312321

313322
You will need to call
314323

@@ -317,10 +326,10 @@ Discovery service = new Discovery("2017-11-07");
317326
service.sentEndPoint("https://gateway-fra.watsonplatform.net/discovery/api")
318327
```
319328

320-
## 401 Unauthorized Error
329+
## 401 unauthorized error
321330

322331
Make sure you are using the service credentials and not your IBM Cloud account/password.
323-
Check the API Endpoint, you may need to update the default using `setEndPoint()`.
332+
Check the API endpoint, you may need to update the default using `setEndPoint()`.
324333

325334
## Changes for v4.0
326335
Version 4.0 focuses on the move to programmatically-generated code for many of the services. See the [changelog](https://github.com/watson-developer-cloud/java-sdk/wiki/Changelog) for the details. This version also includes many breaking changes as a result of standardizing behavior across the new generated services. Full details on migration from previous versions can be found [here](https://github.com/watson-developer-cloud/java-sdk/wiki/Migration).
@@ -356,7 +365,7 @@ INFO: <-- 200 OK https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/di
356365

357366
**Warning:** The logs generated by this logger when using the level `FINE` or `ALL` has the potential to leak sensitive information such as "Authorization" or "Cookie" headers and the contents of request and response bodies. This data should only be logged in a controlled way or in a non-production environment.
358367

359-
## Build + Test
368+
## Build + test
360369

361370
To build and test the project you can use [Gradle][] (version 1.x).
362371

@@ -381,7 +390,7 @@ gradle idea # Intellij IDEA
381390
gradle eclipse # Eclipse
382391
```
383392

384-
## Open Source @ IBM
393+
## Open source @ IBM
385394

386395
Find more open source projects on the [IBM Github Page](http://ibm.github.io/)
387396

@@ -394,7 +403,7 @@ available in [LICENSE](LICENSE).
394403

395404
See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
396405

397-
## Code of Conduct
406+
## Code of conduct
398407

399408
See [CODE_OF_CONDUCT.md](.github/CODE_OF_CONDUCT.md).
400409

@@ -408,12 +417,14 @@ or [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-watson).
408417

409418
[wdc]: https://www.ibm.com/watson/developer/
410419
[ibm_cloud]: https://console.bluemix.net
420+
[watson-dashboard]: https://console.bluemix.net/dashboard/apps?category=watson
411421
[Gradle]: http://www.gradle.org/
412422
[OkHttp]: http://square.github.io/okhttp/
413423
[gson]: https://github.com/google/gson
414424
[apache_maven]: http://maven.apache.org/
415425
[sonatype_snapshots]: https://oss.sonatype.org/content/repositories/snapshots/com/ibm/watson/developer_cloud/
416-
[vcap_services]: https://docs.run.pivotal.io/devguide/deploy-apps/environment-variable.html#VCAP-SERVICES
426+
[vcap_services]: https://console.bluemix.net/docs/services/watson/getting-started-variables.html
427+
[ibm-cloud-onboarding]: http://console.bluemix.net/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Java
417428

418429

419430
[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-6.1.0/java-sdk-6.1.0-jar-with-dependencies.jar

language-translator/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Language Translator
22

3+
## Deprecation notice
4+
Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information.
5+
36
## Installation
47

58
##### Maven

language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@
4444
*
4545
* @version v2
4646
* @see <a href="http://www.ibm.com/watson/developercloud/language-translator.html">Language Translator</a>
47+
* @deprecated Language Translator v3 is now available. The v2 Language Translator API will no longer be available
48+
* after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the
49+
* following page for more information: https://console.bluemix.net/docs/services/language-translator/migrating.html).
4750
*/
51+
@Deprecated
4852
public class LanguageTranslator extends WatsonService {
4953

5054
private static final String SERVICE_NAME = "language_translator";

0 commit comments

Comments
 (0)