diff --git a/README.md b/README.md index 4e588d825..18c515546 100755 --- a/README.md +++ b/README.md @@ -451,6 +451,48 @@ void Example() } ``` +## IBM Cloud Pak for Data(ICP4D) +If your service instance is of ICP4D, below are two ways of initializing the assistant service. + +#### 1) Supplying the `username`, `password`, `icp4d_url` and `authentication_type` + +The SDK will manage the token for the user + +```cs + Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions() + { + Username = "", + Password = "", + Url = "", + DisableSslVerification = true + }; + credentials = new Credentials(tokenOptions, ""); + while(!credentials.HasTokenData()) + { + yield return null; + } + service = new AssistantService(versionDate, credentials); +``` + +#### 2) Supplying the access token + +```cs + Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions() + { + Username = "", + Password = "", + Url = "", + AccessToken = "", + DisableSslVerification = true + }; + credentials = new Credentials(tokenOptions, ""); + while(!credentials.HasTokenData()) + { + yield return null; + } + service = new AssistantService(versionDate, credentials); +``` + ## IBM Cloud Private The Watson Unity SDK does not support IBM Cloud Private because connection via proxy is not supported in UnityWebRequest. diff --git a/Scripts/Services/Assistant/V1/AssistantService.cs b/Scripts/Services/Assistant/V1/AssistantService.cs index f19981856..95c961813 100644 --- a/Scripts/Services/Assistant/V1/AssistantService.cs +++ b/Scripts/Services/Assistant/V1/AssistantService.cs @@ -111,7 +111,7 @@ public AssistantService(string versionDate, Credentials credentials) : base(vers VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials; diff --git a/Scripts/Services/Assistant/V2/AssistantService.cs b/Scripts/Services/Assistant/V2/AssistantService.cs index dee3c568f..ffc755fff 100644 --- a/Scripts/Services/Assistant/V2/AssistantService.cs +++ b/Scripts/Services/Assistant/V2/AssistantService.cs @@ -111,7 +111,7 @@ public AssistantService(string versionDate, Credentials credentials) : base(vers VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials; diff --git a/Scripts/Services/CompareComply/V1/CompareComplyService.cs b/Scripts/Services/CompareComply/V1/CompareComplyService.cs index 33a2aeb1f..56de45268 100644 --- a/Scripts/Services/CompareComply/V1/CompareComplyService.cs +++ b/Scripts/Services/CompareComply/V1/CompareComplyService.cs @@ -111,7 +111,7 @@ public CompareComplyService(string versionDate, Credentials credentials) : base( VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials; diff --git a/Scripts/Services/Discovery/V1/DiscoveryService.cs b/Scripts/Services/Discovery/V1/DiscoveryService.cs index eeef0c267..53d4730fa 100644 --- a/Scripts/Services/Discovery/V1/DiscoveryService.cs +++ b/Scripts/Services/Discovery/V1/DiscoveryService.cs @@ -111,7 +111,7 @@ public DiscoveryService(string versionDate, Credentials credentials) : base(vers VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials; diff --git a/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs b/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs index f8a8d3464..8d8c33947 100644 --- a/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs +++ b/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs @@ -111,7 +111,7 @@ public LanguageTranslatorService(string versionDate, Credentials credentials) : VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials; diff --git a/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs b/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs index 40d41ec8e..06e17d66f 100644 --- a/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs +++ b/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs @@ -93,7 +93,7 @@ public NaturalLanguageClassifierService() : base(serviceId) /// The service credentials. public NaturalLanguageClassifierService(Credentials credentials) : base(credentials, serviceId) { - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials; diff --git a/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs b/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs index 638378909..6c2801238 100644 --- a/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs +++ b/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs @@ -111,7 +111,7 @@ public NaturalLanguageUnderstandingService(string versionDate, Credentials crede VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials; diff --git a/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs b/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs index d5a62b9d9..2d838cf56 100644 --- a/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs +++ b/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs @@ -111,7 +111,7 @@ public PersonalityInsightsService(string versionDate, Credentials credentials) : VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials; diff --git a/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs b/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs deleted file mode 100644 index 731e5e655..000000000 --- a/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs +++ /dev/null @@ -1,36 +0,0 @@ -/** -* Copyright 2018, 2019 IBM Corp. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ - -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace IBM.Watson.SpeechToText.V1.Model -{ - /// - /// The response from training of a custom language or custom acoustic model. - /// - public class TrainingResponse - { - /// - /// An array of `TrainingWarning` objects that lists any invalid resources contained in the custom model. For - /// custom language models, invalid resources are grouped and identified by type of resource. The method can - /// return warnings only if the `strict` parameter is set to `false`. - /// - [JsonProperty("warnings", NullValueHandling = NullValueHandling.Ignore)] - public List Warnings { get; set; } - } -} diff --git a/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs.meta b/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs.meta deleted file mode 100644 index bf2f82604..000000000 --- a/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 33d4cee63fb5e1844af6d08da0a27274 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs b/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs deleted file mode 100644 index 3aebc3045..000000000 --- a/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs +++ /dev/null @@ -1,65 +0,0 @@ -/** -* Copyright 2018, 2019 IBM Corp. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ - -using Newtonsoft.Json; - -namespace IBM.Watson.SpeechToText.V1.Model -{ - /// - /// A warning from training of a custom language or custom acoustic model. - /// - public class TrainingWarning - { - /// - /// An identifier for the type of invalid resources listed in the `description` field. - /// - public class WarningIdValue - { - /// - /// Constant INVALID_AUDIO_FILES for invalid_audio_files - /// - public const string INVALID_AUDIO_FILES = "invalid_audio_files"; - /// - /// Constant INVALID_CORPUS_FILES for invalid_corpus_files - /// - public const string INVALID_CORPUS_FILES = "invalid_corpus_files"; - /// - /// Constant INVALID_GRAMMAR_FILES for invalid_grammar_files - /// - public const string INVALID_GRAMMAR_FILES = "invalid_grammar_files"; - /// - /// Constant INVALID_WORDS for invalid_words - /// - public const string INVALID_WORDS = "invalid_words"; - - } - - /// - /// An identifier for the type of invalid resources listed in the `description` field. - /// Constants for possible values can be found using TrainingWarning.WarningIdValue - /// - [JsonProperty("warning_id", NullValueHandling = NullValueHandling.Ignore)] - public string WarningId { get; set; } - /// - /// A warning message that lists the invalid resources that are excluded from the custom model's training. The - /// message has the following format: `Analysis of the following {resource_type} has not completed successfully: - /// [{resource_names}]. They will be excluded from custom {model_type} model training.`. - /// - [JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)] - public string Description { get; set; } - } -} diff --git a/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs.meta b/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs.meta deleted file mode 100644 index d53e1fa85..000000000 --- a/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5b07bb901232b8f45ba096084e80829b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs b/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs index 8f5879da5..560c6ad9a 100644 --- a/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs +++ b/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs @@ -1941,7 +1941,7 @@ public bool TrainLanguageModel(Callback callback, string customizationId private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnector.Response resp) { - DetailedResponse response = new DetailedResponse(); + DetailedResponse response = new DetailedResponse(); foreach (KeyValuePair kvp in resp.Headers) { response.Headers.Add(kvp.Key, kvp.Value); @@ -1951,7 +1951,7 @@ private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnect try { string json = Encoding.UTF8.GetString(resp.Data); - response.Result = JsonConvert.DeserializeObject(json); + response.Result = JsonConvert.DeserializeObject(json); response.Response = json; } catch (Exception e) @@ -1960,8 +1960,8 @@ private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnect resp.Success = false; } - if (((RequestObject)req).Callback != null) - ((RequestObject)req).Callback(response, resp.Error); + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); } /// /// Reset a custom language model. @@ -3848,7 +3848,7 @@ public bool TrainAcousticModel(Callback callback, string customizationId private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnector.Response resp) { - DetailedResponse response = new DetailedResponse(); + DetailedResponse response = new DetailedResponse(); foreach (KeyValuePair kvp in resp.Headers) { response.Headers.Add(kvp.Key, kvp.Value); @@ -3858,7 +3858,7 @@ private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnect try { string json = Encoding.UTF8.GetString(resp.Data); - response.Result = JsonConvert.DeserializeObject(json); + response.Result = JsonConvert.DeserializeObject(json); response.Response = json; } catch (Exception e) @@ -3867,8 +3867,8 @@ private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnect resp.Success = false; } - if (((RequestObject)req).Callback != null) - ((RequestObject)req).Callback(response, resp.Error); + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); } /// /// Reset a custom acoustic model. diff --git a/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs b/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs index 0cc2a7ce0..d413ac5b5 100644 --- a/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs +++ b/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs @@ -93,7 +93,7 @@ public TextToSpeechService() : base(serviceId) /// The service credentials. public TextToSpeechService(Credentials credentials) : base(credentials, serviceId) { - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials; diff --git a/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs b/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs index f4f05b9f6..78c3fab42 100644 --- a/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs +++ b/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs @@ -111,7 +111,7 @@ public ToneAnalyzerService(string versionDate, Credentials credentials) : base(v VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials; diff --git a/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs b/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs index 681d34fae..e7d77f02a 100644 --- a/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs +++ b/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs @@ -110,7 +110,7 @@ public VisualRecognitionService(string versionDate, Credentials credentials) : b VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasIamTokenData()) + if (credentials.HasCredentials() || credentials.HasTokenData()) { Credentials = credentials;