Skip to content

Commit 4d2a36f

Browse files
committed
feat(regerate): regenerate services for pre-release
1 parent 1ef2b54 commit 4d2a36f

File tree

12 files changed

+784
-660
lines changed

12 files changed

+784
-660
lines changed

Scripts/Services/Assistant/V1/AssistantService.cs

+135-138
Large diffs are not rendered by default.

Scripts/Services/Assistant/V2/AssistantService.cs

+21-23
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Collections.Generic;
1919
using System.Text;
2020
using IBM.Cloud.SDK;
21+
using IBM.Cloud.SDK.Authentication;
2122
using IBM.Cloud.SDK.Connection;
2223
using IBM.Cloud.SDK.Utilities;
2324
using IBM.Watson.Assistant.V2.Model;
@@ -33,20 +34,16 @@ public partial class AssistantService : BaseService
3334
private const string serviceId = "assistant";
3435
private const string defaultUrl = "https://gateway.watsonplatform.net/assistant/api";
3536

36-
#region Credentials
37+
#region Authenticator
3738
/// <summary>
38-
/// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined.
39+
/// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined.
3940
/// </summary>
40-
public Credentials Credentials
41+
public Authenticator Authenticator
4142
{
42-
get { return credentials; }
43+
get { return authenticator; }
4344
set
4445
{
45-
credentials = value;
46-
if (!string.IsNullOrEmpty(credentials.Url))
47-
{
48-
Url = credentials.Url;
49-
}
46+
authenticator = value;
5047
}
5148
}
5249
#endregion
@@ -90,17 +87,14 @@ public bool DisableSslVerification
9087
/// AssistantService constructor.
9188
/// </summary>
9289
/// <param name="versionDate">The service version date in `yyyy-mm-dd` format.</param>
93-
public AssistantService(string versionDate) : base(versionDate, serviceId)
94-
{
95-
VersionDate = versionDate;
96-
}
90+
public AssistantService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {}
9791

9892
/// <summary>
9993
/// AssistantService constructor.
10094
/// </summary>
10195
/// <param name="versionDate">The service version date in `yyyy-mm-dd` format.</param>
102-
/// <param name="credentials">The service credentials.</param>
103-
public AssistantService(string versionDate, Credentials credentials) : base(versionDate, credentials, serviceId)
96+
/// <param name="authenticator">The service authenticator.</param>
97+
public AssistantService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId)
10498
{
10599
if (string.IsNullOrEmpty(versionDate))
106100
{
@@ -111,18 +105,19 @@ public AssistantService(string versionDate, Credentials credentials) : base(vers
111105
VersionDate = versionDate;
112106
}
113107

114-
if (credentials.HasCredentials() || credentials.HasTokenData())
108+
if (authenticator != null)
115109
{
116-
Credentials = credentials;
110+
Authenticator = authenticator;
117111

118-
if (string.IsNullOrEmpty(credentials.Url))
112+
if (string.IsNullOrEmpty(Url))
119113
{
120-
credentials.Url = defaultUrl;
114+
Authenticator.Url = defaultUrl;
121115
}
116+
Authenticator.Url = Url;
122117
}
123118
else
124119
{
125-
throw new IBMException("Please provide a username and password or authorization token to use the Assistant service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials");
120+
throw new IBMException("Please provide a username and password or authorization token to use the Assistant service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator");
126121
}
127122
}
128123

@@ -170,11 +165,12 @@ public bool CreateSession(Callback<SessionResponse> callback, string assistantId
170165

171166
req.OnResponse = OnCreateSessionResponse;
172167

173-
RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v2/assistants/{0}/sessions", assistantId));
168+
RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions", assistantId));
174169
if (connector == null)
175170
{
176171
return false;
177172
}
173+
Authenticator.Authenticate(connector);
178174

179175
return connector.Send(req);
180176
}
@@ -249,11 +245,12 @@ public bool DeleteSession(Callback<object> callback, string assistantId, string
249245

250246
req.OnResponse = OnDeleteSessionResponse;
251247

252-
RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v2/assistants/{0}/sessions/{1}", assistantId, sessionId));
248+
RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions/{1}", assistantId, sessionId));
253249
if (connector == null)
254250
{
255251
return false;
256252
}
253+
Authenticator.Authenticate(connector);
257254

258255
return connector.Send(req);
259256
}
@@ -343,11 +340,12 @@ public bool Message(Callback<MessageResponse> callback, string assistantId, stri
343340

344341
req.OnResponse = OnMessageResponse;
345342

346-
RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v2/assistants/{0}/sessions/{1}/message", assistantId, sessionId));
343+
RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions/{1}/message", assistantId, sessionId));
347344
if (connector == null)
348345
{
349346
return false;
350347
}
348+
Authenticator.Authenticate(connector);
351349

352350
return connector.Send(req);
353351
}

0 commit comments

Comments
 (0)