java-sdk-8.0.0-rc1
Pre-releaseBreaking changes
There are some small breaking changes present, like some methods dropping a parameter or two or some parameters being renamed, but below are the big changes throughout the SDK.
Authentication methods
Authentication methods have changed to make things more extensible for the future. There are 5 authentication variants supplied in the SDK (shown below), and it's possible now to create your own authentication implementation if you need something specific by implementing the Authenticator
implementation.
Basic
You can authenticate with basic auth using the BasicAuthenticator
. This allows you to pass in a username and password.
Authenticator authenticator = new BasicAuthenticator("<username>", "<password>");
Bearer token
Use the BearerTokenAuthenticator
. This one accepts just the bearer token.
Authenticator authenticator = new BearerTokenAuthenticator("<bearer_token>");
Cloud Pak for Data
This class helps you authenticate with your services on (Cloud Pak for Data)[https://www.ibm.com/analytics/cloud-pak-for-data).
// constructor with required parameters
Authenticator authenticator = new CloudPakForDataAuthenticator(
"<url>",
"<test_username>",
"<test_password>"
);
There's also another constructor to disable SSL verification or send request headers on the token exchange.
IAM
Like the CloudPakForDataAuthenticator
, there's a basic constructor
Authenticator authenticator = new IamAuthenticator("<token>");
and another one to supply additional arguments like a particular token exchange URL, a client ID and secret, and the same options to disable SSL verification and send headers.
None
Finally, there's the NoAuthAuthenticator
, which is pretty self-explanatory. Pass this when you don't need any authentication to happen.
Assistant service = new Assistant("2019-02-28", new NoAuthAuthenticator());
More model builders
If you've used the SDK before, you're probably familiar with the use of the builder pattern across the board. With this release, we've tweaked the generation process to capture better which are models that are being constructed to be sent to the service. These are models we'd prefer to have builders, making it easier to put them together.
There are unfortunately a decent number of models which move to this pattern, but it's one we expect to use well into the future.
Features
Better control over HTTP logging
Logging used to be controlled with a .properties
file somewhere in the namespace, but it was confusing to many people. We also didn't leave an option to shut them off!
We've added control over this to the existing HttpConfigOptions
class. Information on usage can be found here.
Ability to cancel an API call
It's possible that in your code, you may want to cancel an API call you made. Some reasons for this might be requests exceeding some response time threshold or sending multiple async requests and just wanting to keep the fastest one, canceling the rest.
Regardless, this feature has been added for this release. You can see more information here.