Skip to content

feat(icp4d): add support for icp4d #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<username>",
Password = "<password>",
Url = "<icp4dUrl>",
DisableSslVerification = true
};
credentials = new Credentials(tokenOptions, "<serviceUrl>");
while(!credentials.HasTokenData())
{
yield return null;
}
service = new AssistantService(versionDate, credentials);
```

#### 2) Supplying the access token

```cs
Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions()
{
Username = "<username>",
Password = "<password>",
Url = "<icp4dUrl>",
AccessToken = "<accessToken>",
DisableSslVerification = true
};
credentials = new Credentials(tokenOptions, "<serviceUrl>");
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.

Expand Down
2 changes: 1 addition & 1 deletion Scripts/Services/Assistant/V1/AssistantService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Scripts/Services/Assistant/V2/AssistantService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Scripts/Services/CompareComply/V1/CompareComplyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Scripts/Services/Discovery/V1/DiscoveryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public LanguageTranslatorService(string versionDate, Credentials credentials) :
VersionDate = versionDate;
}

if (credentials.HasCredentials() || credentials.HasIamTokenData())
if (credentials.HasCredentials() || credentials.HasTokenData())
{
Credentials = credentials;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public NaturalLanguageClassifierService() : base(serviceId)
/// <param name="credentials">The service credentials.</param>
public NaturalLanguageClassifierService(Credentials credentials) : base(credentials, serviceId)
{
if (credentials.HasCredentials() || credentials.HasIamTokenData())
if (credentials.HasCredentials() || credentials.HasTokenData())
{
Credentials = credentials;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public NaturalLanguageUnderstandingService(string versionDate, Credentials crede
VersionDate = versionDate;
}

if (credentials.HasCredentials() || credentials.HasIamTokenData())
if (credentials.HasCredentials() || credentials.HasTokenData())
{
Credentials = credentials;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public PersonalityInsightsService(string versionDate, Credentials credentials) :
VersionDate = versionDate;
}

if (credentials.HasCredentials() || credentials.HasIamTokenData())
if (credentials.HasCredentials() || credentials.HasTokenData())
{
Credentials = credentials;

Expand Down
36 changes: 0 additions & 36 deletions Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs.meta

This file was deleted.

65 changes: 0 additions & 65 deletions Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs.meta

This file was deleted.

16 changes: 8 additions & 8 deletions Scripts/Services/SpeechToText/V1/SpeechToTextService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1941,7 +1941,7 @@ public bool TrainLanguageModel(Callback<object> callback, string customizationId

private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnector.Response resp)
{
DetailedResponse<TrainingResponse> response = new DetailedResponse<TrainingResponse>();
DetailedResponse<object> response = new DetailedResponse<object>();
foreach (KeyValuePair<string, string> kvp in resp.Headers)
{
response.Headers.Add(kvp.Key, kvp.Value);
Expand All @@ -1951,7 +1951,7 @@ private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnect
try
{
string json = Encoding.UTF8.GetString(resp.Data);
response.Result = JsonConvert.DeserializeObject<TrainingResponse>(json);
response.Result = JsonConvert.DeserializeObject<object>(json);
response.Response = json;
}
catch (Exception e)
Expand All @@ -1960,8 +1960,8 @@ private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnect
resp.Success = false;
}

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

private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnector.Response resp)
{
DetailedResponse<TrainingResponse> response = new DetailedResponse<TrainingResponse>();
DetailedResponse<object> response = new DetailedResponse<object>();
foreach (KeyValuePair<string, string> kvp in resp.Headers)
{
response.Headers.Add(kvp.Key, kvp.Value);
Expand All @@ -3858,7 +3858,7 @@ private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnect
try
{
string json = Encoding.UTF8.GetString(resp.Data);
response.Result = JsonConvert.DeserializeObject<TrainingResponse>(json);
response.Result = JsonConvert.DeserializeObject<object>(json);
response.Response = json;
}
catch (Exception e)
Expand All @@ -3867,8 +3867,8 @@ private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnect
resp.Success = false;
}

if (((RequestObject<TrainingResponse>)req).Callback != null)
((RequestObject<TrainingResponse>)req).Callback(response, resp.Error);
if (((RequestObject<object>)req).Callback != null)
((RequestObject<object>)req).Callback(response, resp.Error);
}
/// <summary>
/// Reset a custom acoustic model.
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public TextToSpeechService() : base(serviceId)
/// <param name="credentials">The service credentials.</param>
public TextToSpeechService(Credentials credentials) : base(credentials, serviceId)
{
if (credentials.HasCredentials() || credentials.HasIamTokenData())
if (credentials.HasCredentials() || credentials.HasTokenData())
{
Credentials = credentials;

Expand Down
2 changes: 1 addition & 1 deletion Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down