This document should serve as a guide to breaking changes for users moving from code using the v7.x.x version of the SDK to v8.x.x.
Previously, there were different builder objects for authentication. For example:
// username and password
BasicAuthConfig config = new BasicAuthConfig.Builder()
.username("<username>")
.password("<password")
.build();
// IAM
IamOptions options = new IamOptions.Builder()
.apiKey("<iam_api_key>")
.url("<iam_url>")
.build();This could be set multiple ways:
// in the constructor
IamOptions options = new IamOptions.Builder()
.apiKey("<iam_api_key>")
.url("<iam_url>")
.build();
Assistant service = new Assistant("2019-02-28", options);
// after instantiation
service.setAuthenticator(options);
// inline in the constructor (only for username and password!)
Assistant service = new Assistant("2019-02-28", "<username>", "<password>");Overall, it was a little too open-ended and very confusing to follow. For this release, we've decided to standardize things, while developing a pattern that should be more scalable.
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.
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>");Use the BearerTokenAuthenticator. This one accepts just the bearer token.
Authenticator authenticator = new BearerTokenAuthenticator("<bearer_token>");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.
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.
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());As before, you can supply credentials to your service using external ibm-credentials.env files.
Assistant service = new Assistant("2019-02-28");
WorkspaceCollection response = service.listWorkspaces().execute().getResult();Previously we would look for these files first in the system home directory, followed by the current project directory.
Now in order to allow developers to have different configurations for each project we look first in the current project directory, followed by the home directory.
For a while now, we've allowed users to set the service URL with setEndPoint():
IamOptions options = new IamOptions.Builder()
.apiKey("<iam_api_key>")
.url("<iam_url>")
.build();
Assistant service = new Assistant("2019-02-28", options);
service.setEndPoint("<service_url>");To align with our other SDKs and be a bit more clear, that method has been renamed to setServiceUrl():
Authenticator authenticator = new IamAuthenticator("<token>");
Assistant service = new Assistant("2019-02-28", authenticator);
service.setServiceUrl("<service_url>");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. Here's the comprehensive list of models that now use this:
CaptureGroupDialogNodeActionDialogNodeNextStepDialogNodeOutputGenericDialogNodeOutputModifiersDialogNodeOutputOptionsElementDialogNodeOutputOptionsElementValueDialogNodeOutputTextValuesElementDialogNodeVisitedDetailsDialogSuggestionDialogSuggestionValueLogMessageMentionMessageContextMetadataMessageRequestRuntimeEntityRuntimeIntentWorkspaceSystemSettingsWorkspaceSystemSettingsDisambiguationWorkspaceSystemSettingsTooling
CaptureGroupMessageContextMessageContextGlobalMessageContextGlobalSystemMessageContextSkillMessageInputOptionsRuntimeEntityRuntimeIntent
CategoryFeedbackDataInputLabelLocationOriginalLabelsInShortDocTypeLabelUpdatedLabelsIn
ConfigurationConversionsCredentialDetailsCredentialsEnrichmentEventDataExpansionExpansionsFontSettingHtmlSettingsNluEnrichmentConceptsNluEnrichmentRelationsNormalizationOperationPdfHeadingDetectionPdfSettingsSegmentSettingsSourceSourceOptionsSourceOptionsBucketsSourceOptionsFolderSourceOptionsObjectSourceOptionsSiteCollSourceOptionsWebCrawlSourceScheduleTokenDictRuleTrainingExampleWordHeadingDetectionWordSettingsWordStyleXPathPatterns
ClassifyInput
MetadataOptionsSyntaxOptionsTokens
CustomWord
TranslationWordWords
Previously, options models which accepted a contentType parameter would typically contain a set of constants for possible values. For example:
RecognizeOptions.ContentType.AUDIO_WAVThese have been removed. You can use the HttpMediaType helper class to achieve the same thing:
// equivalent to above
HttpMediaType.AUDIO_WAVincludeCountis no longer a parameter of thelistWorkspaces()methodincludeCountis no longer a parameter of thelistIntents()methodincludeCountis no longer a parameter of thelistExamples()methodincludeCountis no longer a parameter of thelistCounterexamples()methodincludeCountis no longer a parameter of thelistEntities()methodincludeCountis no longer a parameter of thelistValues()methodincludeCountis no longer a parameter of thelistSynonyms()methodincludeCountis no longer a parameter of thelistDialogNodes()methodvalueTypewas renamed totypein thecreateValue()methodnewValueTypewas renamed tonewTypein theupdateValue()methodnodeTypewas renamed totypein thecreateDialogNode()methodnodeTypewas renamed totypein thecreateDialogNode()methodnewNodeTypewas renamed tonewTypein theupdateDialogNode()methodValueTypewas renamed toTypein theCreateValuemodelNodeTypewas renamed toTypein theDialogNodemodelActionTypewas renamed toTypein theDialogNodeActionmodelSEARCH_SKILLconstant was added to theDialogNodeOutputGenericmodelQueryTypeconstants were added to theDialogNodeOutputGenericmodelqueryTypeproperty was added to theDialogNodeOutputGenericmodelqueryproperty was added to theDialogNodeOutputGenericmodelfilterproperty was added to theDialogNodeOutputGenericmodeldiscoveryVersionproperty was added to theDialogNodeOutputGenericmodeloutputproperty type was converted fromMaptoDialogSuggestionOutputin theDialogSuggestionmodelLogMessagemodel no longer hasadditionalPropertiesDialogRuntimeResponseGenericwas renamed toRuntimeResponseGenericRuntimeEntitymodel no longer hasadditionalPropertiesRuntimeIntentmodel no longer hasadditionalPropertiesValueTypewas renamed toTypein theValuemodel
ActionTypewas renamed toTypein theDialogNodeActionmodelDialogRuntimeResponseGenericwas renamed toRuntimeResponseGeneric
convertToHtml()method does not require afilenameparameter
returnFieldswas renamed toxReturnin thequery()methodloggingOptOutwas renamed toxWatsonLoggingOptOutin thequery()methodspellingSuggestionswas added to thequery()methodcollectionIdsis no longer a parameter of thequery()methodreturnFieldswas renamed toxReturnin theQueryNotices()methodloggingOptOutwas renamed toxWatsonLoggingOptOutin thefederatedQuery()methodcollectionIdsis now required in thefederatedQuery()methodreturnFieldswas renamed toxReturnin thefederatedQuery()methodreturnFieldswas renamed toxReturnin thefederatedQueryNotices()methodenrichmentNamewas renamed toenrichmentin theEnrichmentmodelFieldTypeEnumValuewas renamed toTypeEnumValuein theFieldmodelFieldTypewas renamed toTypein theFieldmodelfieldNamewas renamed tofieldin theFieldmodeltestConfigurationInEnvironment()method was removedqueryEntities()method was removedqueryRelations()method was removed
defaultModelswas renamed toxDefaultin thelistModels()methodtranslationOutputwas renamed totranslationin theTranslationmodel
metadatawas renamed totrainingMetadatain thecreateClassifier()method
finalResultswas renamed toxFinalin theSpeakerLabelsResultmodelfinalResultswas renamed toxFinalin theSpeechRecognitionResultmodel
detectFaces()method was removedclassNamewas renamed toxClassin theClassmodelclassNamewas renamed toxClassin theClassResultmodel