Skip to content

Commit ba8044d

Browse files
committed
feat(icp4d): add support for icp4d
1 parent 867223a commit ba8044d

File tree

17 files changed

+61
-142
lines changed

17 files changed

+61
-142
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,48 @@ void Example()
451451
}
452452
```
453453

454+
## IBM Cloud Pak for Data(ICP4D)
455+
If your service instance is of ICP4D, below are two ways of initializing the assistant service.
456+
457+
#### 1) Supplying the `username`, `password`, `icp4d_url` and `authentication_type`
458+
459+
The SDK will manage the token for the user
460+
461+
```cs
462+
Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions()
463+
{
464+
Username = "<username>",
465+
Password = "<password>",
466+
Url = "<icp4dUrl>",
467+
DisableSslVerification = true
468+
};
469+
credentials = new Credentials(tokenOptions, "<serviceUrl>");
470+
while(!credentials.HasTokenData())
471+
{
472+
yield return null;
473+
}
474+
service = new AssistantService(versionDate, credentials);
475+
```
476+
477+
#### 2) Supplying the access token
478+
479+
```cs
480+
Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions()
481+
{
482+
Username = "<username>",
483+
Password = "<password>",
484+
Url = "<icp4dUrl>",
485+
AccessToken = "<accessToken>",
486+
DisableSslVerification = true
487+
};
488+
credentials = new Credentials(tokenOptions, "<serviceUrl>");
489+
while(!credentials.HasTokenData())
490+
{
491+
yield return null;
492+
}
493+
service = new AssistantService(versionDate, credentials);
494+
```
495+
454496
## IBM Cloud Private
455497
The Watson Unity SDK does not support IBM Cloud Private because connection via proxy is not supported in UnityWebRequest.
456498

Scripts/Services/Assistant/V1/AssistantService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public AssistantService(string versionDate, Credentials credentials) : base(vers
111111
VersionDate = versionDate;
112112
}
113113

114-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
114+
if (credentials.HasCredentials() || credentials.HasTokenData())
115115
{
116116
Credentials = credentials;
117117

Scripts/Services/Assistant/V2/AssistantService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public AssistantService(string versionDate, Credentials credentials) : base(vers
111111
VersionDate = versionDate;
112112
}
113113

114-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
114+
if (credentials.HasCredentials() || credentials.HasTokenData())
115115
{
116116
Credentials = credentials;
117117

Scripts/Services/CompareComply/V1/CompareComplyService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public CompareComplyService(string versionDate, Credentials credentials) : base(
111111
VersionDate = versionDate;
112112
}
113113

114-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
114+
if (credentials.HasCredentials() || credentials.HasTokenData())
115115
{
116116
Credentials = credentials;
117117

Scripts/Services/Discovery/V1/DiscoveryService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public DiscoveryService(string versionDate, Credentials credentials) : base(vers
111111
VersionDate = versionDate;
112112
}
113113

114-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
114+
if (credentials.HasCredentials() || credentials.HasTokenData())
115115
{
116116
Credentials = credentials;
117117

Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public LanguageTranslatorService(string versionDate, Credentials credentials) :
111111
VersionDate = versionDate;
112112
}
113113

114-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
114+
if (credentials.HasCredentials() || credentials.HasTokenData())
115115
{
116116
Credentials = credentials;
117117

Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public NaturalLanguageClassifierService() : base(serviceId)
9393
/// <param name="credentials">The service credentials.</param>
9494
public NaturalLanguageClassifierService(Credentials credentials) : base(credentials, serviceId)
9595
{
96-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
96+
if (credentials.HasCredentials() || credentials.HasTokenData())
9797
{
9898
Credentials = credentials;
9999

Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public NaturalLanguageUnderstandingService(string versionDate, Credentials crede
111111
VersionDate = versionDate;
112112
}
113113

114-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
114+
if (credentials.HasCredentials() || credentials.HasTokenData())
115115
{
116116
Credentials = credentials;
117117

Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public PersonalityInsightsService(string versionDate, Credentials credentials) :
111111
VersionDate = versionDate;
112112
}
113113

114-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
114+
if (credentials.HasCredentials() || credentials.HasTokenData())
115115
{
116116
Credentials = credentials;
117117

Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs

Lines changed: 0 additions & 65 deletions
This file was deleted.

Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Scripts/Services/SpeechToText/V1/SpeechToTextService.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ public bool TrainLanguageModel(Callback<object> callback, string customizationId
19411941

19421942
private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnector.Response resp)
19431943
{
1944-
DetailedResponse<TrainingResponse> response = new DetailedResponse<TrainingResponse>();
1944+
DetailedResponse<object> response = new DetailedResponse<object>();
19451945
foreach (KeyValuePair<string, string> kvp in resp.Headers)
19461946
{
19471947
response.Headers.Add(kvp.Key, kvp.Value);
@@ -1951,7 +1951,7 @@ private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnect
19511951
try
19521952
{
19531953
string json = Encoding.UTF8.GetString(resp.Data);
1954-
response.Result = JsonConvert.DeserializeObject<TrainingResponse>(json);
1954+
response.Result = JsonConvert.DeserializeObject<object>(json);
19551955
response.Response = json;
19561956
}
19571957
catch (Exception e)
@@ -1960,8 +1960,8 @@ private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnect
19601960
resp.Success = false;
19611961
}
19621962

1963-
if (((RequestObject<TrainingResponse>)req).Callback != null)
1964-
((RequestObject<TrainingResponse>)req).Callback(response, resp.Error);
1963+
if (((RequestObject<object>)req).Callback != null)
1964+
((RequestObject<object>)req).Callback(response, resp.Error);
19651965
}
19661966
/// <summary>
19671967
/// Reset a custom language model.
@@ -3848,7 +3848,7 @@ public bool TrainAcousticModel(Callback<object> callback, string customizationId
38483848

38493849
private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnector.Response resp)
38503850
{
3851-
DetailedResponse<TrainingResponse> response = new DetailedResponse<TrainingResponse>();
3851+
DetailedResponse<object> response = new DetailedResponse<object>();
38523852
foreach (KeyValuePair<string, string> kvp in resp.Headers)
38533853
{
38543854
response.Headers.Add(kvp.Key, kvp.Value);
@@ -3858,7 +3858,7 @@ private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnect
38583858
try
38593859
{
38603860
string json = Encoding.UTF8.GetString(resp.Data);
3861-
response.Result = JsonConvert.DeserializeObject<TrainingResponse>(json);
3861+
response.Result = JsonConvert.DeserializeObject<object>(json);
38623862
response.Response = json;
38633863
}
38643864
catch (Exception e)
@@ -3867,8 +3867,8 @@ private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnect
38673867
resp.Success = false;
38683868
}
38693869

3870-
if (((RequestObject<TrainingResponse>)req).Callback != null)
3871-
((RequestObject<TrainingResponse>)req).Callback(response, resp.Error);
3870+
if (((RequestObject<object>)req).Callback != null)
3871+
((RequestObject<object>)req).Callback(response, resp.Error);
38723872
}
38733873
/// <summary>
38743874
/// Reset a custom acoustic model.

Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public TextToSpeechService() : base(serviceId)
9393
/// <param name="credentials">The service credentials.</param>
9494
public TextToSpeechService(Credentials credentials) : base(credentials, serviceId)
9595
{
96-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
96+
if (credentials.HasCredentials() || credentials.HasTokenData())
9797
{
9898
Credentials = credentials;
9999

Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public ToneAnalyzerService(string versionDate, Credentials credentials) : base(v
111111
VersionDate = versionDate;
112112
}
113113

114-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
114+
if (credentials.HasCredentials() || credentials.HasTokenData())
115115
{
116116
Credentials = credentials;
117117

Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public VisualRecognitionService(string versionDate, Credentials credentials) : b
110110
VersionDate = versionDate;
111111
}
112112

113-
if (credentials.HasCredentials() || credentials.HasIamTokenData())
113+
if (credentials.HasCredentials() || credentials.HasTokenData())
114114
{
115115
Credentials = credentials;
116116

0 commit comments

Comments
 (0)