MIGRATION-V1.md
October 4, 2019 ยท View on GitHub
Here are simple steps to move from v0.11.0 to v1.0.0.
AUTHENTICATION MECHANISM
The constructor no longer accepts individual credentials like IAMApiKey, etc. We initialize authenticators from the core. The core supports various authentication mechanisms, choose the one appropriate to your instance and use case.
For example, to pass a IAM apikey:
Before
service, serviceErr := servicev1.
NewServiceV1(&servicev1.ServiceV1Options{
URL: "{url}",
IAMApiKey: "{apikey}",
})
After(V1.0)
import "github.com/IBM/go-sdk-core/core"
authenticator := &core.IamAuthenticator{
ApiKey: "{apikey}",
}
service, serviceErr := servicev1.
NewServiceV1(&servicev1.ServiceV1Options{
URL: "{url}",
Authenticator: authenticator,
})
There are 5 authentication variants supplied in the SDK (shown below): You can also find detailed explanation Authentication
BasicAuthenticator
import (
"github.com/IBM/go-sdk-core/core"
"<appropriate-git-repo-url>/myservicev1"
)
authenticator := &core.BasicAuthenticator{
Username: "user1",
Password: "password1",
}
options := &myservicev1.MyServiceV1Options{
Authenticator: authenticator,
}
service := myservicev1.NewMyServiceV1(options)
BearerTokenAuthenticator
import (
"github.com/IBM/go-sdk-core/core"
"<appropriate-git-repo-url>/myservicev1"
)
authenticator := &core.BearerTokenAuthenticator{
BearerToken: token,
}
options := &myservicev1.MyServiceV1Options{
Authenticator: authenticator,
}
service := myservicev1.NewMyServiceV1(options)
CloudPakForDataAuthenticator
import (
"github.com/IBM/go-sdk-core/core"
"<appropriate-git-repo-url>/myservicev1"
)
authenticator := &core.CloudPakForDataAuthenticator{
URL: "https://my-cp4d-url"
Username: "user1",
Password: "password1",
DisableSSLVerification: true,
}
options := &myservicev1.MyServiceV1Options{
Authenticator: authenticator,
}
service := myservicev1.NewMyServiceV1(options)
IAMAuthenticator
import (
"github.com/IBM/go-sdk-core/core"
"<appropriate-git-repo-url>/myservicev1"
)
...
authenticator := &core.IamAuthenticator{
ApiKey: "my-iam-apikey",
}
options := &myservicev1.MyServiceV1Options{
Authenticator: authenticator,
}
service := myservicev1.NewMyServiceV1(options)
NoAuthAuthenticator
import (
"github.com/IBM/go-sdk-core/core"
"<appropriate-git-repo-url>/myservicev1"
)
...
options := &myservicev1.MyServiceV1Options{
Authenticator: &core.NoAuthAuthenticator{},
}
service := myservicev1.NewMyServiceV1(options)
Creating an Authenticator from Environmental Configuration
External env variables can be obtained from CREDENTIALS, Environment variables or VCAP_SERVICES
import (
"github.com/IBM/go-sdk-core/core"
"<appropriate-git-repo-url>/myservicev1"
)
...
authenticator := core.GetAuthenticatorFromEnvironment("my_service")
options := &myservicev1.MyServiceV1Options{
Authenticator: authenticator,
}
service := myservicev1.NewMyServiceV1(options)
METHOD CALLS RETURN FIRST PARAM AS RESULT
For functions which have a result, method calls will return result as the first param
Before
response, responseErr := service.MethodCall(&servicev1.MethodCallOptions{})
result := discovery.GetListEnvironmentsResult(response)
After(V1.0)
Result would be returned directly
result, response, responseErr := service.MethodCall(&servicev1.MethodCallOptions{})
SERVICE CHANGES
AssistantV1
IncludeCountis no longer a parameter of the ListWorkspacesOptionsIncludeCountis no longer a parameter of the ListIntentsOptionsIncludeCountis no longer a parameter of the ListExamplesOptionsIncludeCountis no longer a parameter of the ListCounterexamplesOptionsIncludeCountis no longer a parameter of the ListEntitiesOptionsIncludeCountis no longer a parameter of the ListValuesOptionsIncludeCountis no longer a parameter of the ListSynonymsOptionsIncludeCountis no longer a parameter of the ListDialogNodesValueTypewas renamed toTypein the CreateValueOptions methodValueTypewas renamed toNewTypein the UpdateValueOptions methodNodeTypewas renamed toTypein the CreateDialogNodeOptionsNewNodeTypewas renamed toNewTypein the UpdateDialogNodeOptionsValueTypewas renamed toTypein the CreateValue modelNodeTypewas renamed toTypein the DialogNode modelActionTypewas renamed toTypein the DialogNodeAction modelQueryTypeproperty was added to the DialogNodeOutputGeneric modelQueryproperty was added to the DialogNodeOutputGeneric modelFilterproperty was added to the DialogNodeOutputGeneric modelDiscoveryVersionproperty was added to the DialogNodeOutputGeneric model- LogMessage model no longer has allows additonal properties
DialogRuntimeResponseGenericwas renamed toRuntimeResponseGeneric- RuntimeEntity model no longer has allows additonal properties
- RuntimeIntent model no longer has allows additonal properties
ValueTypewas renamed toTypein the Value model
AssistantV2
ActionTypewas renamed toTypein the DialogNodeAction model- DialogRuntimeResponseGeneric was renamed to RuntimeResponseGeneric
Compare and Comply
convertToHTMLOptionsdoes not require a filename parameter
DiscoveryV1
ReturnFieldswas renamed toReturnin the QueryOptionsLoggingOptOutwas renamed toXWatsonLoggingOptOutin the QueryOptionsSpellingSuggestionswas added to the QueryOptionscollectionIdsis no longer a parameter of the QueryOptionsReturnFieldswas renamed toReturnin the QueryNoticesOptionsLoggingOptOutwas renamed toXWatsonLoggingOptOutin the FederatedQueryOptionsReturnFieldswas renamed toReturnin the FederatedQueryOptionsReturnFieldswas renamed toReturnin the FederatedQueryNoticesOptionsEnrichmentNamewas renamed toEnrichmentin the Enrichment modelFieldTypewas renamed toTypein the Field modelFieldNamewas renamed toFieldin the Field model- TestConfigurationInEnvironment() method was removed
- QueryEntities() method was removed
- QueryRelations() method was removed
Language Translator V3
DefaultModelswas renamed toDefaultin the ListModelsOptionsTranslationOutputwas renamed toTranslationin the Translation model
Natural Language Classifier V1
Metadatawas renamed toTrainingMetadatain the CreateClassifierOptions
Speech to Text V1
FinalResultswas renamed toFinalin the SpeakerLabelsResult modelFinalResultswas renamed toFinalin the SpeechRecognitionResult model
Visual Recognition V3
DetectFaces()method was removedClassNamewas renamed toClassin the ClassResult modelClassNamewas renamed toClassin the ModelClass model
Visual Recognition V4
- New Service!