Skip to content

Commit efae761

Browse files
authored
Merge pull request #388 from watson-developer-cloud/rc-2.2.3
Watson Unity SDK v2.2.3
2 parents 292c357 + 45eba4d commit efae761

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1556
-739
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ before_script:
1717
script:
1818
- ./Travis/createProject.sh
1919
- ./Travis/installSDK.sh
20-
- travis_wait 15 ./Travis/runTests.sh
20+
- ./Travis/runTests.sh
2121
- ./Travis/build.sh

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
Change Log
22
==========
3+
## Version 2.2.3
4+
_2018-05-21_
5+
* New: Abstract `DeleteUserData()` for Assistant, Conversation and Discovery ([#387](https://github.com/watson-developer-cloud/unity-sdk/pull/387)).
6+
* Fixed: Replaced `ToUnixTimeInSeconds()` with dotnet 3.5 equivalent ([#382](https://github.com/watson-developer-cloud/unity-sdk/issues/382), [#386](https://github.com/watson-developer-cloud/unity-sdk/pull/386)).
7+
* New: Get credentials for testing from internal github repo ([#4333](https://github.ibm.com/Watson/developer-experience/issues/4333), [#364](https://github.com/watson-developer-cloud/unity-sdk/pull/364)).
8+
* New: Warn user to `InstallDefaultReactors()` ([#328](https://github.com/watson-developer-cloud/unity-sdk/issues/328), [#380](https://github.com/watson-developer-cloud/unity-sdk/pull/380)).
9+
* New: Revised WSConnector for TLS 1.2 support in upcoming Unity release ([#4230](https://github.ibm.com/Watson/developer-experience/issues/4230), [#379](https://github.com/watson-developer-cloud/unity-sdk/pull/379)).
10+
* New: Added support for IAM authentication ([#4291](https://github.ibm.com/Watson/developer-experience/issues/4291), [#377](https://github.com/watson-developer-cloud/unity-sdk/pull/377)).
11+
312
## Version 2.2.2
413
* New: Send custom request headers and access response headers via `customData` object ([#4310](https://github.ibm.com/Watson/developer-experience/issues/4310), [#362](https://github.com/watson-developer-cloud/unity-sdk/pull/362)).
514
* Fixed: Unresolved errors hidden by `#ifdef` ([#368](https://github.com/watson-developer-cloud/unity-sdk/issues/368), [#369](https://github.com/watson-developer-cloud/unity-sdk/pull/369))

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "Watson Developer Cloud Unity SDK"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 2.2.2
41+
PROJECT_NUMBER = 2.2.3
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

Examples/ServiceExamples/Scripts/ExampleAssistant.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ private void OnMessage(object response, Dictionary<string, object> customData)
690690
if (_tempContext != null)
691691
_context = _tempContext as Dictionary<string, object>;
692692
else
693-
Log.Debug("ExampleConversation.OnMessage()", "Failed to get context");
693+
Log.Debug("ExampleAssistant.OnMessage()", "Failed to get context");
694694

695695
// Get intent
696696
object tempIntentsObj = null;
@@ -700,6 +700,8 @@ private void OnMessage(object response, Dictionary<string, object> customData)
700700
(tempIntentObj as Dictionary<string, object>).TryGetValue("intent", out tempIntent);
701701
string intent = tempIntent.ToString();
702702

703+
Log.Debug("ExampleAssistant.OnMessage()", "intent: {0}", intent);
704+
703705
_messageTested = true;
704706
}
705707

Examples/ServiceExamples/Scripts/ExampleDiscovery.cs

Lines changed: 90 additions & 103 deletions
Large diffs are not rendered by default.

Examples/ServiceExamples/Scripts/ExampleGetToken.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void Start ()
5050
private IEnumerator Example()
5151
{
5252
// Get token
53-
if (!Utility.GetToken(OnGetToken, _conversationUrl, _conversationUsername, _conversationPassword))
53+
if (!Utility.GetWatsonToken(OnGetWatsonToken, _conversationUrl, _conversationUsername, _conversationPassword))
5454
Log.Debug("ExampleGetToken.GetToken()", "Failed to get token.");
5555

5656
while (!_receivedAuthToken)
@@ -60,14 +60,14 @@ private IEnumerator Example()
6060
Message();
6161
}
6262

63-
private void OnGetToken(AuthenticationToken authenticationToken, string customData)
63+
private void OnGetWatsonToken(AuthenticationToken authenticationToken, string customData)
6464
{
6565
_authenticationToken = authenticationToken;
6666
Log.Debug("ExampleGetToken.OnGetToken()", "created: {0} | time to expiration: {1} minutes | token: {2}", _authenticationToken.Created, _authenticationToken.TimeUntilExpiration, _authenticationToken.Token);
6767
_receivedAuthToken = true;
6868
}
6969

70-
private IEnumerator GetTokenTimeRemaining(float time)
70+
private IEnumerator GetWatsonTokenTimeRemaining(float time)
7171
{
7272
yield return new WaitForSeconds(time);
7373
Log.Debug("ExampleGetToken.GetTokenTimeRemaining()", "created: {0} | time to expiration: {1} minutes | token: {2}", _authenticationToken.Created, _authenticationToken.TimeUntilExpiration, _authenticationToken.Token);
@@ -77,7 +77,7 @@ private void Message()
7777
{
7878
Credentials credentials = new Credentials()
7979
{
80-
AuthenticationToken = _authenticationToken.Token,
80+
WatsonAuthenticationToken = _authenticationToken.Token,
8181
Url = _conversationUrl
8282
};
8383

@@ -92,7 +92,7 @@ private void OnMessage(object resp, Dictionary<string, object> customData)
9292
Log.Debug("ExampleGetToken.OnMessage()", "message response: {0}", customData);
9393

9494
// Check token time remaining
95-
Runnable.Run(GetTokenTimeRemaining(0f));
95+
Runnable.Run(GetWatsonTokenTimeRemaining(0f));
9696
}
9797
private void OnFail(RESTConnector.Error error, Dictionary<string, object> customData)
9898
{
Binary file not shown.

Examples/ServiceExamples/TestData/Discovery/constitution.pdf.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/ServiceExamples/TestData/Discovery/exampleConfigurationData.json

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

Examples/ServiceExamples/TestData/Discovery/exampleConfigurationData.json.meta

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

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Watson APIs Unity SDK
22
[![Build Status](https://travis-ci.org/watson-developer-cloud/unity-sdk.svg?branch=develop)](https://travis-ci.org/watson-developer-cloud/unity-sdk)
3+
[![wdc-community.slack.com](https://wdc-slack-inviter.mybluemix.net/badge.svg)](http://wdc-slack-inviter.mybluemix.net/)
34

45
Use this SDK to build Watson-powered applications in Unity.
56

@@ -99,6 +100,39 @@ void Start()
99100
}
100101
```
101102

103+
You can also authenticate a service using IAM authentication. You can either supply a valid access token in the `iamTokenOptions` or get an access token using an `apikey`.
104+
105+
```cs
106+
void IEnumerator TokenExample()
107+
{
108+
// Create IAM token options and supply the apikey.
109+
// Alternatively you can supply an access token.
110+
TokenOptions iamTokenOptions = new TokenOptions()
111+
{
112+
IamApiKey = "<iam-api-key>"
113+
};
114+
115+
// Create credentials using the IAM token options
116+
_credentials = new Credentials(iamTokenOptions, "<service-url");
117+
while (!_credentials.HasIamTokenData())
118+
yield return null;
119+
120+
_assistant = new Assistant(_credentials);
121+
_assistant.VersionDate = "2018-02-16";
122+
_assistant.ListWorkspaces(OnListWorkspaces, OnFail);
123+
}
124+
125+
private void OnListWorkspaces(WorkspaceCollection response, Dictionary<string, object> customData)
126+
{
127+
Log.Debug("OnListWorkspaces()", "Response: {0}", customData["json"].ToString());
128+
}
129+
130+
private void OnFail(RESTConnector.Error error, Dictionary<string, object> customData)
131+
{
132+
Log.Debug("OnFail()", "Failed: {0}", error.ToString());
133+
}
134+
```
135+
102136
## Callbacks
103137
Success and failure callbacks are required. You can specify the return type in the callback.
104138
```cs
@@ -282,6 +316,6 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
282316
[wdc]: https://www.ibm.com/watson/developer/
283317
[wdc_unity_sdk]: https://github.com/watson-developer-cloud/unity-sdk
284318
[latest_release]: https://github.com/watson-developer-cloud/unity-sdk/releases/latest
285-
[ibm_cloud_registration]: http://console.bluemix.net/registration
319+
[ibm_cloud_registration]: http://console.bluemix.net/registration?cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Unity
286320
[get_unity]: https://unity3d.com/get-unity
287321
[documentation]: https://watson-developer-cloud.github.io/unity-sdk/

Scripts/Connection/RESTConnector.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class RESTConnector
4343
public const string AUTHENTICATION_AUTHORIZATION_HEADER = "Authorization";
4444
public const long HTTP_STATUS_OK = 200;
4545
public const long HTTP_STATUS_CREATED = 201;
46+
public const long HTTP_STATUS_ACCEPTED = 202;
4647
public const long HTTP_STATUS_NO_CONTENT = 204;
4748
#region Public Types
4849
/// <summary>
@@ -282,6 +283,8 @@ public static RESTConnector GetConnector(Credentials credentials, string functio
282283
RESTConnector connector = new RESTConnector();
283284
connector.URL = credentials.Url + function;
284285
connector.Authentication = credentials;
286+
if (connector.Authentication.HasIamTokenData())
287+
connector.Authentication.GetToken();
285288

286289
return connector;
287290
}
@@ -327,14 +330,18 @@ private void AddHeaders(Dictionary<string, string> headers)
327330
if (headers == null)
328331
throw new ArgumentNullException("headers");
329332

330-
if (Authentication.HasAuthorizationToken())
333+
if (Authentication.HasWatsonAuthenticationToken())
331334
{
332-
headers.Add(AUTHENTICATION_TOKEN_AUTHORIZATION_HEADER, Authentication.AuthenticationToken);
335+
headers.Add(AUTHENTICATION_TOKEN_AUTHORIZATION_HEADER, Authentication.WatsonAuthenticationToken);
333336
}
334337
else if (Authentication.HasCredentials())
335338
{
336339
headers.Add(AUTHENTICATION_AUTHORIZATION_HEADER, Authentication.CreateAuthorization());
337340
}
341+
else if(Authentication.HasIamTokenData())
342+
{
343+
headers.Add(AUTHENTICATION_AUTHORIZATION_HEADER, string.Format("Bearer {0}", Authentication.IamAccessToken));
344+
}
338345
}
339346

340347
if (Headers != null)
@@ -475,6 +482,7 @@ private IEnumerator ProcessRequestQueue()
475482
{
476483
case HTTP_STATUS_OK:
477484
case HTTP_STATUS_CREATED:
485+
case HTTP_STATUS_ACCEPTED:
478486
bError = false;
479487
break;
480488
default:
@@ -679,7 +687,7 @@ public IEnumerator Send(string url, Dictionary<string, string> headers)
679687
};
680688
}
681689

682-
Success = deleteReq.responseCode == HTTP_STATUS_OK || deleteReq.responseCode == HTTP_STATUS_OK || deleteReq.responseCode == HTTP_STATUS_NO_CONTENT;
690+
Success = deleteReq.responseCode == HTTP_STATUS_OK || deleteReq.responseCode == HTTP_STATUS_OK || deleteReq.responseCode == HTTP_STATUS_NO_CONTENT || deleteReq.responseCode == HTTP_STATUS_ACCEPTED;
683691
HttpResponseCode = deleteReq.responseCode;
684692
ResponseHeaders = deleteReq.GetResponseHeaders();
685693
Data = deleteReq.downloadHandler.data;

0 commit comments

Comments
 (0)