Skip to content

Commit e7ceb0d

Browse files
committed
commented out getting credentials through vcap file in example files, throw error if no credentials are present
1 parent fbfff57 commit e7ceb0d

31 files changed

+550
-447
lines changed

Examples/ServiceExamples/Scripts/ExampleAlchemyDataNews.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,32 @@ void Start()
3939
{
4040
LogSystem.InstallDefaultReactors();
4141

42-
VcapCredentials vcapCredentials = new VcapCredentials();
43-
fsData data = null;
44-
45-
// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
46-
// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
47-
var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
48-
var fileContent = File.ReadAllText(environmentalVariable);
49-
50-
// Add in a parent object because Unity does not like to deserialize root level collection types.
51-
fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
52-
53-
// Convert json to fsResult
54-
fsResult r = fsJsonParser.Parse(fileContent, out data);
55-
if (!r.Succeeded)
56-
throw new WatsonException(r.FormattedMessages);
57-
58-
// Convert fsResult to VcapCredentials
59-
object obj = vcapCredentials;
60-
r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
61-
if (!r.Succeeded)
62-
throw new WatsonException(r.FormattedMessages);
63-
64-
// Set credentials from imported credntials
65-
Credential credential = vcapCredentials.VCAP_SERVICES["alchemy_api"][0].Credentials;
66-
_apikey = credential.Apikey.ToString();
67-
_url = credential.Url.ToString();
42+
//VcapCredentials vcapCredentials = new VcapCredentials();
43+
//fsData data = null;
44+
45+
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
46+
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
47+
//var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
48+
//var fileContent = File.ReadAllText(environmentalVariable);
49+
50+
//// Add in a parent object because Unity does not like to deserialize root level collection types.
51+
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
52+
53+
//// Convert json to fsResult
54+
//fsResult r = fsJsonParser.Parse(fileContent, out data);
55+
//if (!r.Succeeded)
56+
// throw new WatsonException(r.FormattedMessages);
57+
58+
//// Convert fsResult to VcapCredentials
59+
//object obj = vcapCredentials;
60+
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
61+
//if (!r.Succeeded)
62+
// throw new WatsonException(r.FormattedMessages);
63+
64+
//// Set credentials from imported credntials
65+
//Credential credential = vcapCredentials.VCAP_SERVICES["alchemy_api"][0].Credentials;
66+
//_apikey = credential.Apikey.ToString();
67+
//_url = credential.Url.ToString();
6868

6969
// Create credential and instantiate service
7070
Credentials credentials = new Credentials(_apikey, _url);

Examples/ServiceExamples/Scripts/ExampleAlchemyLanguage.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -106,32 +106,32 @@ void Start()
106106
{
107107
LogSystem.InstallDefaultReactors();
108108

109-
VcapCredentials vcapCredentials = new VcapCredentials();
110-
fsData data = null;
111-
112-
// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
113-
// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
114-
var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
115-
var fileContent = File.ReadAllText(environmentalVariable);
116-
117-
// Add in a parent object because Unity does not like to deserialize root level collection types.
118-
fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
119-
120-
// Convert json to fsResult
121-
fsResult r = fsJsonParser.Parse(fileContent, out data);
122-
if (!r.Succeeded)
123-
throw new WatsonException(r.FormattedMessages);
124-
125-
// Convert fsResult to VcapCredentials
126-
object obj = vcapCredentials;
127-
r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
128-
if (!r.Succeeded)
129-
throw new WatsonException(r.FormattedMessages);
130-
131-
// Set credentials from imported credntials
132-
Credential credential = vcapCredentials.VCAP_SERVICES["alchemy_api"][0].Credentials;
133-
_apikey = credential.Apikey.ToString();
134-
_url = credential.Url.ToString();
109+
//VcapCredentials vcapCredentials = new VcapCredentials();
110+
//fsData data = null;
111+
112+
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
113+
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
114+
//var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
115+
//var fileContent = File.ReadAllText(environmentalVariable);
116+
117+
//// Add in a parent object because Unity does not like to deserialize root level collection types.
118+
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
119+
120+
//// Convert json to fsResult
121+
//fsResult r = fsJsonParser.Parse(fileContent, out data);
122+
//if (!r.Succeeded)
123+
// throw new WatsonException(r.FormattedMessages);
124+
125+
//// Convert fsResult to VcapCredentials
126+
//object obj = vcapCredentials;
127+
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
128+
//if (!r.Succeeded)
129+
// throw new WatsonException(r.FormattedMessages);
130+
131+
//// Set credentials from imported credntials
132+
//Credential credential = vcapCredentials.VCAP_SERVICES["alchemy_api"][0].Credentials;
133+
//_apikey = credential.Apikey.ToString();
134+
//_url = credential.Url.ToString();
135135

136136
// Create credential and instantiate service
137137
Credentials credentials = new Credentials(_apikey, _url);

Examples/ServiceExamples/Scripts/ExampleConversation.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,34 @@ void Start()
4646
{
4747
LogSystem.InstallDefaultReactors();
4848

49-
VcapCredentials vcapCredentials = new VcapCredentials();
50-
fsData data = null;
51-
52-
// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
53-
// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
54-
var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
55-
var fileContent = File.ReadAllText(environmentalVariable);
56-
57-
// Add in a parent object because Unity does not like to deserialize root level collection types.
58-
fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
59-
60-
// Convert json to fsResult
61-
fsResult r = fsJsonParser.Parse(fileContent, out data);
62-
if (!r.Succeeded)
63-
throw new WatsonException(r.FormattedMessages);
64-
65-
// Convert fsResult to VcapCredentials
66-
object obj = vcapCredentials;
67-
r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
68-
if (!r.Succeeded)
69-
throw new WatsonException(r.FormattedMessages);
70-
71-
// Set credentials from imported credntials
72-
Credential credential = vcapCredentials.VCAP_SERVICES["conversation"][1].Credentials;
73-
_username = credential.Username.ToString();
74-
_password = credential.Password.ToString();
75-
_url = credential.Url.ToString();
76-
_workspaceId = credential.WorkspaceId.ToString();
49+
//VcapCredentials vcapCredentials = new VcapCredentials();
50+
//fsData data = null;
51+
52+
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
53+
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
54+
//var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
55+
//var fileContent = File.ReadAllText(environmentalVariable);
56+
57+
//// Add in a parent object because Unity does not like to deserialize root level collection types.
58+
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
59+
60+
//// Convert json to fsResult
61+
//fsResult r = fsJsonParser.Parse(fileContent, out data);
62+
//if (!r.Succeeded)
63+
// throw new WatsonException(r.FormattedMessages);
64+
65+
//// Convert fsResult to VcapCredentials
66+
//object obj = vcapCredentials;
67+
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
68+
//if (!r.Succeeded)
69+
// throw new WatsonException(r.FormattedMessages);
70+
71+
//// Set credentials from imported credntials
72+
//Credential credential = vcapCredentials.VCAP_SERVICES["conversation"][1].Credentials;
73+
//_username = credential.Username.ToString();
74+
//_password = credential.Password.ToString();
75+
//_url = credential.Url.ToString();
76+
//_workspaceId = credential.WorkspaceId.ToString();
7777

7878
// Create credential and instantiate service
7979
Credentials credentials = new Credentials(_username, _password, _url);

Examples/ServiceExamples/Scripts/ExampleDiscoveryV1.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,33 @@ private void Start()
7171
{
7272
LogSystem.InstallDefaultReactors();
7373

74-
VcapCredentials vcapCredentials = new VcapCredentials();
75-
fsData data = null;
76-
77-
// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
78-
// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
79-
var environmentalVariable = System.Environment.GetEnvironmentVariable("VCAP_SERVICES");
80-
var fileContent = File.ReadAllText(environmentalVariable);
81-
82-
// Add in a parent object because Unity does not like to deserialize root level collection types.
83-
fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
84-
85-
// Convert json to fsResult
86-
fsResult r = fsJsonParser.Parse(fileContent, out data);
87-
if (!r.Succeeded)
88-
throw new WatsonException(r.FormattedMessages);
89-
90-
// Convert fsResult to VcapCredentials
91-
object obj = vcapCredentials;
92-
r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
93-
if (!r.Succeeded)
94-
throw new WatsonException(r.FormattedMessages);
95-
96-
// Set credentials from imported credntials
97-
Credential credential = vcapCredentials.VCAP_SERVICES["discovery"][0].Credentials;
98-
_username = credential.Username.ToString();
99-
_password = credential.Password.ToString();
100-
_url = credential.Url.ToString();
74+
//VcapCredentials vcapCredentials = new VcapCredentials();
75+
//fsData data = null;
76+
77+
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
78+
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
79+
//var environmentalVariable = System.Environment.GetEnvironmentVariable("VCAP_SERVICES");
80+
//var fileContent = File.ReadAllText(environmentalVariable);
81+
82+
//// Add in a parent object because Unity does not like to deserialize root level collection types.
83+
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
84+
85+
//// Convert json to fsResult
86+
//fsResult r = fsJsonParser.Parse(fileContent, out data);
87+
//if (!r.Succeeded)
88+
// throw new WatsonException(r.FormattedMessages);
89+
90+
//// Convert fsResult to VcapCredentials
91+
//object obj = vcapCredentials;
92+
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
93+
//if (!r.Succeeded)
94+
// throw new WatsonException(r.FormattedMessages);
95+
96+
//// Set credentials from imported credntials
97+
//Credential credential = vcapCredentials.VCAP_SERVICES["discovery"][0].Credentials;
98+
//_username = credential.Username.ToString();
99+
//_password = credential.Password.ToString();
100+
//_url = credential.Url.ToString();
101101

102102
// Create credential and instantiate service
103103
Credentials credentials = new Credentials(_username, _password, _url);

Examples/ServiceExamples/Scripts/ExampleDocumentConversion.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,33 @@ void Start()
4141
{
4242
LogSystem.InstallDefaultReactors();
4343

44-
VcapCredentials vcapCredentials = new VcapCredentials();
45-
fsData data = null;
46-
47-
// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
48-
// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
49-
var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
50-
var fileContent = File.ReadAllText(environmentalVariable);
51-
52-
// Add in a parent object because Unity does not like to deserialize root level collection types.
53-
fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
54-
55-
// Convert json to fsResult
56-
fsResult r = fsJsonParser.Parse(fileContent, out data);
57-
if (!r.Succeeded)
58-
throw new WatsonException(r.FormattedMessages);
59-
60-
// Convert fsResult to VcapCredentials
61-
object obj = vcapCredentials;
62-
r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
63-
if (!r.Succeeded)
64-
throw new WatsonException(r.FormattedMessages);
65-
66-
// Set credentials from imported credntials
67-
Credential credential = vcapCredentials.VCAP_SERVICES["document_conversion"][0].Credentials;
68-
_username = credential.Username.ToString();
69-
_password = credential.Password.ToString();
70-
_url = credential.Url.ToString();
44+
//VcapCredentials vcapCredentials = new VcapCredentials();
45+
//fsData data = null;
46+
47+
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
48+
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
49+
//var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
50+
//var fileContent = File.ReadAllText(environmentalVariable);
51+
52+
//// Add in a parent object because Unity does not like to deserialize root level collection types.
53+
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
54+
55+
//// Convert json to fsResult
56+
//fsResult r = fsJsonParser.Parse(fileContent, out data);
57+
//if (!r.Succeeded)
58+
// throw new WatsonException(r.FormattedMessages);
59+
60+
//// Convert fsResult to VcapCredentials
61+
//object obj = vcapCredentials;
62+
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
63+
//if (!r.Succeeded)
64+
// throw new WatsonException(r.FormattedMessages);
65+
66+
//// Set credentials from imported credntials
67+
//Credential credential = vcapCredentials.VCAP_SERVICES["document_conversion"][0].Credentials;
68+
//_username = credential.Username.ToString();
69+
//_password = credential.Password.ToString();
70+
//_url = credential.Url.ToString();
7171

7272
// Create credential and instantiate service
7373
Credentials credentials = new Credentials(_username, _password, _url);

Examples/ServiceExamples/Scripts/ExampleLanguageTranslator.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,33 @@ void Start()
5252
{
5353
LogSystem.InstallDefaultReactors();
5454

55-
VcapCredentials vcapCredentials = new VcapCredentials();
56-
fsData data = null;
57-
58-
// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
59-
// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
60-
var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
61-
var fileContent = File.ReadAllText(environmentalVariable);
62-
63-
// Add in a parent object because Unity does not like to deserialize root level collection types.
64-
fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
65-
66-
// Convert json to fsResult
67-
fsResult r = fsJsonParser.Parse(fileContent, out data);
68-
if (!r.Succeeded)
69-
throw new WatsonException(r.FormattedMessages);
70-
71-
// Convert fsResult to VcapCredentials
72-
object obj = vcapCredentials;
73-
r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
74-
if (!r.Succeeded)
75-
throw new WatsonException(r.FormattedMessages);
76-
77-
// Set credentials from imported credntials
78-
Credential credential = vcapCredentials.VCAP_SERVICES["language_translator"][0].Credentials;
79-
_username = credential.Username.ToString();
80-
_password = credential.Password.ToString();
81-
_url = credential.Url.ToString();
55+
//VcapCredentials vcapCredentials = new VcapCredentials();
56+
//fsData data = null;
57+
58+
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
59+
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
60+
//var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
61+
//var fileContent = File.ReadAllText(environmentalVariable);
62+
63+
//// Add in a parent object because Unity does not like to deserialize root level collection types.
64+
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
65+
66+
//// Convert json to fsResult
67+
//fsResult r = fsJsonParser.Parse(fileContent, out data);
68+
//if (!r.Succeeded)
69+
// throw new WatsonException(r.FormattedMessages);
70+
71+
//// Convert fsResult to VcapCredentials
72+
//object obj = vcapCredentials;
73+
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
74+
//if (!r.Succeeded)
75+
// throw new WatsonException(r.FormattedMessages);
76+
77+
//// Set credentials from imported credntials
78+
//Credential credential = vcapCredentials.VCAP_SERVICES["language_translator"][0].Credentials;
79+
//_username = credential.Username.ToString();
80+
//_password = credential.Password.ToString();
81+
//_url = credential.Url.ToString();
8282

8383
// Create credential and instantiate service
8484
Credentials credentials = new Credentials(_username, _password, _url);

0 commit comments

Comments
 (0)